@hazae41/glacier
Version:
Yet another React data (re)fetching library
19 lines (16 loc) • 509 B
JavaScript
import { Base64 } from '@hazae41/base64';
import { Bytes } from '@hazae41/bytes';
class HmacEncoder {
key;
constructor(key) {
this.key = key;
}
async hashOrThrow(preimage) {
return new Uint8Array(await crypto.subtle.sign({ name: "HMAC" }, this.key, preimage));
}
async encodeOrThrow(value) {
return Base64.get().getOrThrow().encodePaddedOrThrow(await this.hashOrThrow(Bytes.fromUtf8(value)));
}
}
export { HmacEncoder };
//# sourceMappingURL=hmac.mjs.map