@hazae41/glacier
Version:
Yet another React data (re)fetching library
1 lines • 1.23 kB
Source Map (JSON)
{"version":3,"file":"hmac.cjs","sources":["../../../../../../../src/mods/coders/crypto/hmac/hmac.ts"],"sourcesContent":["import { Base64 } from \"@hazae41/base64\"\nimport { Bytes } from \"@hazae41/bytes\"\nimport { AsyncEncoder } from \"mods/coders/coder.js\"\n\nexport class HmacEncoder implements AsyncEncoder<string, string> {\n\n constructor(\n readonly key: CryptoKey\n ) { }\n\n async hashOrThrow(preimage: Uint8Array): Promise<Uint8Array> {\n return new Uint8Array(await crypto.subtle.sign({ name: \"HMAC\" }, this.key, preimage))\n }\n\n async encodeOrThrow(value: string): Promise<string> {\n return Base64.get().getOrThrow().encodePaddedOrThrow(await this.hashOrThrow(Bytes.fromUtf8(value)))\n }\n\n}"],"names":["Base64","Bytes"],"mappings":";;;;;MAIa,WAAW,CAAA;AAGX,IAAA,GAAA,CAAA;AADX,IAAA,WAAA,CACW,GAAc,EAAA;QAAd,IAAG,CAAA,GAAA,GAAH,GAAG,CAAW;KACpB;IAEL,MAAM,WAAW,CAAC,QAAoB,EAAA;QACpC,OAAO,IAAI,UAAU,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA;KACtF;IAED,MAAM,aAAa,CAAC,KAAa,EAAA;QAC/B,OAAOA,aAAM,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC,mBAAmB,CAAC,MAAM,IAAI,CAAC,WAAW,CAACC,WAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;KACpG;AAEF;;;;"}