All files config.ts

80% Statements 8/10
50% Branches 2/4
100% Functions 3/3
80% Lines 8/10

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          2x           2x 2x       2x     2x 2x         1x     1x      
export interface ConfigProperties {
  aesKey: string;
  hmacKey: string;
}
 
export class CoreMBConfig {
  private static instance: CoreMBConfig;
  public readonly aesKey: Buffer;
  public readonly hmacKey: Buffer;
 
  private constructor(props: ConfigProperties) {
    this.aesKey = Buffer.from(props.aesKey, "base64");
    this.hmacKey = Buffer.from(props.hmacKey, "base64");
  }
 
  public static initialize(props: ConfigProperties): CoreMBConfig {
    Iif (CoreMBConfig.instance) {
      throw new Error("CoreMBConfig has already been initialized");
    }
    CoreMBConfig.instance = new CoreMBConfig(props);
    return CoreMBConfig.instance;
  }
 
  // Access the singleton instance
  public static getInstance(): CoreMBConfig {
    Iif (!CoreMBConfig.instance) {
      throw new Error("CoreMBConfig has not been initialized yet");
    }
    return CoreMBConfig.instance;
  }
}