{"version":3,"file":"hmac-CrI8fGKH.mjs","sources":["../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/hmac.js"],"sourcesContent":["import { hash as assertHash, bytes as assertBytes, exists as assertExists } from './_assert.js';\nimport { Hash, toBytes } from './utils.js';\n// HMAC (RFC 2104)\nexport class HMAC extends Hash {\n    constructor(hash, _key) {\n        super();\n        this.finished = false;\n        this.destroyed = false;\n        assertHash(hash);\n        const key = toBytes(_key);\n        this.iHash = hash.create();\n        if (typeof this.iHash.update !== 'function')\n            throw new Error('Expected instance of class which extends utils.Hash');\n        this.blockLen = this.iHash.blockLen;\n        this.outputLen = this.iHash.outputLen;\n        const blockLen = this.blockLen;\n        const pad = new Uint8Array(blockLen);\n        // blockLen can be bigger than outputLen\n        pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);\n        for (let i = 0; i < pad.length; i++)\n            pad[i] ^= 0x36;\n        this.iHash.update(pad);\n        // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone\n        this.oHash = hash.create();\n        // Undo internal XOR && apply outer XOR\n        for (let i = 0; i < pad.length; i++)\n            pad[i] ^= 0x36 ^ 0x5c;\n        this.oHash.update(pad);\n        pad.fill(0);\n    }\n    update(buf) {\n        assertExists(this);\n        this.iHash.update(buf);\n        return this;\n    }\n    digestInto(out) {\n        assertExists(this);\n        assertBytes(out, this.outputLen);\n        this.finished = true;\n        this.iHash.digestInto(out);\n        this.oHash.update(out);\n        this.oHash.digestInto(out);\n        this.destroy();\n    }\n    digest() {\n        const out = new Uint8Array(this.oHash.outputLen);\n        this.digestInto(out);\n        return out;\n    }\n    _cloneInto(to) {\n        // Create new instance without calling constructor since key already in state and we don't know it.\n        to || (to = Object.create(Object.getPrototypeOf(this), {}));\n        const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;\n        to = to;\n        to.finished = finished;\n        to.destroyed = destroyed;\n        to.blockLen = blockLen;\n        to.outputLen = outputLen;\n        to.oHash = oHash._cloneInto(to.oHash);\n        to.iHash = iHash._cloneInto(to.iHash);\n        return to;\n    }\n    destroy() {\n        this.destroyed = true;\n        this.oHash.destroy();\n        this.iHash.destroy();\n    }\n}\n/**\n * HMAC: RFC2104 message authentication code.\n * @param hash - function that would be used e.g. sha256\n * @param key - message key\n * @param message - message data\n */\nexport const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();\nhmac.create = (hash, key) => new HMAC(hash, key);\n//# sourceMappingURL=hmac.js.map"],"names":["HMAC","Hash","hash","_key","assertHash","key","toBytes","blockLen","pad","i","buf","assertExists","out","assertBytes","to","oHash","iHash","finished","destroyed","outputLen","hmac","message"],"mappings":";AAGO,MAAMA,UAAaC,EAAK;AAAA,EAC3B,YAAYC,GAAMC,GAAM;AACpB,UAAO,GACP,KAAK,WAAW,IAChB,KAAK,YAAY,IACjBC,EAAWF,CAAI;AACf,UAAMG,IAAMC,EAAQH,CAAI;AAExB,QADA,KAAK,QAAQD,EAAK,OAAQ,GACtB,OAAO,KAAK,MAAM,UAAW;AAC7B,YAAM,IAAI,MAAM,qDAAqD;AACzE,SAAK,WAAW,KAAK,MAAM,UAC3B,KAAK,YAAY,KAAK,MAAM;AAC5B,UAAMK,IAAW,KAAK,UAChBC,IAAM,IAAI,WAAWD,CAAQ;AAEnC,IAAAC,EAAI,IAAIH,EAAI,SAASE,IAAWL,EAAK,OAAQ,EAAC,OAAOG,CAAG,EAAE,OAAM,IAAKA,CAAG;AACxE,aAASI,IAAI,GAAGA,IAAID,EAAI,QAAQC;AAC5B,MAAAD,EAAIC,CAAC,KAAK;AACd,SAAK,MAAM,OAAOD,CAAG,GAErB,KAAK,QAAQN,EAAK,OAAQ;AAE1B,aAASO,IAAI,GAAGA,IAAID,EAAI,QAAQC;AAC5B,MAAAD,EAAIC,CAAC,KAAK;AACd,SAAK,MAAM,OAAOD,CAAG,GACrBA,EAAI,KAAK,CAAC;AAAA,EAClB;AAAA,EACI,OAAOE,GAAK;AACRC,WAAAA,EAAa,IAAI,GACjB,KAAK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