DenoDDeno
Powered by
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
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);
    }
  }
  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
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

DNT build type check fails on std/streams/buffer byobRequest
SiilwynSSiilwyn / help
2y ago
Importing pdfjs?
patwasalinguistPpatwasalinguist / help
13mo ago
Importing submodules
monkeymom2Mmonkeymom2 / help
3y ago