AkuzeA
Denoβ€’2y agoβ€’
4 replies
Akuze

Importing Buffer Type

Hi there, I am having issue typing a hash. I am trying to create an encryption key and signature key, but don't know what the return types should be in Deno. In node.js, the type appears to be Buffer, but this comes up with an error in Deno. Here's the code I'm referring to:

  class myClass {
    _encryptionKey: Buffer; // Errors: Cannot find name 'Buffer'.deno-ts(2580)
    _signatureKey: Buffer; // Errors: Cannot find name 'Buffer'.deno-ts(2580)
    constructor(secret: string, domain: string) {
      const keyMaterial = crypto.createHash("sha256").update(secret).digest();
      this._encryptionKey = keyMaterial.subarray(0, BLOCK_SIZE);
      this._signatureKey = keyMaterial.subarray(BLOCK_SIZE, 32);
    }
  }


How should I type this? I'm new to Deno, so any help is appreciated. Thanks a lot
Was this page helpful?