{"version":3,"file":"cryptoHelpers-browser.mjs","sourceRoot":"","sources":["../../src/cryptoHelpers-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,0BAA0B;AAE1B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc,EAAE,YAAoB;IACnE,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAClD,KAAK,EACL,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EACrD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,SAAS;KAChB,EACD,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAClD,MAAM,EACN,GAAG,EACH,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CACvC,CAAC;IAEF,6FAA6F;IAC7F,kFAAkF;IAClF,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/// <reference lib=\"dom\"/>\n\n/**\n * @internal\n */\nexport async function sha256Hmac(secret: string, stringToSign: string): Promise<string> {\n  const key = await globalThis.crypto.subtle.importKey(\n    \"raw\",\n    Uint8Array.from(atob(secret), (c) => c.charCodeAt(0)),\n    {\n      name: \"HMAC\",\n      hash: \"SHA-256\",\n    },\n    false,\n    [\"sign\"],\n  );\n\n  const sigArray = await globalThis.crypto.subtle.sign(\n    \"HMAC\",\n    key,\n    new TextEncoder().encode(stringToSign),\n  );\n\n  // The conversions here are a bit odd but necessary (see \"Unicode strings\" in the link below)\n  // https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/btoa\n  return btoa(String.fromCharCode(...new Uint8Array(sigArray)));\n}\n"]}