All files / src/database/entity GKey.ts

100% Statements 9/9
80% Branches 8/10
100% Functions 1/1
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                              1x 1x 1x         1x         1x           2x 2x 2x 2x      
import { Column, Entity, type EProperties } from '../../classes/annotation';
import CoreEntity from '../../classes/CoreEntity';
 
/**
 * Represents a cryptographic key with its associated metadata.
 *
 * @class GKey
 * @extends CoreEntity
 * @property {string} secret - The secret value of the key stored as text.
 * @property {Buffer} iv - Initialization vector used in encryption operations.
 * @property {Buffer} auth - Authentication tag used to verify data integrity.
 *
 * @constructor
 * @param {EProperties<GKey>} [props] - Optional initial values for the key properties.
 */
@Entity('GKey', 0)
export default class GKey extends CoreEntity {
  @Column({
    dataType: 'text',
  })
  secret: string;
 
  @Column({
    dataType: 'blob',
  })
  iv: Buffer;
 
  @Column({
    dataType: 'blob',
  })
  auth: Buffer;
 
  constructor(props?: EProperties<GKey>) {
    super();
    this.secret = props?.secret ?? '';
    this.iv = props?.iv || Buffer.from('');
    this.auth = props?.auth || Buffer.from('');
  }
}