UNPKG

@hazae41/glacier

Version:

Yet another React data (re)fetching library

21 lines (17 loc) 546 B
'use strict'; var base64 = require('@hazae41/base64'); var bytes = require('@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.Base64.get().getOrThrow().encodePaddedOrThrow(await this.hashOrThrow(bytes.Bytes.fromUtf8(value))); } } exports.HmacEncoder = HmacEncoder; //# sourceMappingURL=hmac.cjs.map