UNPKG

@azure/core-amqp

Version:

Common library for amqp based azure sdks like @azure/event-hubs.

47 lines (46 loc) 1.67 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var hmacSha256_exports = {}; __export(hmacSha256_exports, { signString: () => signString }); module.exports = __toCommonJS(hmacSha256_exports); var import_core_util = require("@azure/core-util"); async function signString(key, toSign) { const enc = new TextEncoder(); const algorithm = { name: "HMAC", hash: { name: "SHA-256" } }; const extractedKey = await globalThis.crypto.subtle.importKey( "raw", enc.encode(key), algorithm, false, ["sign", "verify"] ); const signature = await globalThis.crypto.subtle.sign( algorithm, extractedKey, enc.encode(toSign) ); const digest = (0, import_core_util.uint8ArrayToString)(new Uint8Array(signature), "base64"); return encodeURIComponent(digest); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { signString }); //# sourceMappingURL=hmacSha256.js.map