{"version":3,"file":"getBytesFromHex.mjs","sources":["../../../../../../src/providers/cognito/utils/srp/getBytesFromHex.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { HEX_TO_SHORT } from './constants';\n/**\n * Converts a hexadecimal encoded string to a Uint8Array of bytes.\n *\n * @param encoded The hexadecimal encoded string\n */\nexport const getBytesFromHex = (encoded) => {\n    if (encoded.length % 2 !== 0) {\n        throw new Error('Hex encoded strings must have an even number length');\n    }\n    const out = new Uint8Array(encoded.length / 2);\n    for (let i = 0; i < encoded.length; i += 2) {\n        const encodedByte = encoded.slice(i, i + 2).toLowerCase();\n        if (encodedByte in HEX_TO_SHORT) {\n            out[i / 2] = HEX_TO_SHORT[encodedByte];\n        }\n        else {\n            throw new Error(`Cannot decode unrecognized sequence ${encodedByte} as hexadecimal`);\n        }\n    }\n    return out;\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,OAAO,KAAK;AAC5C,IAAI,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;AAClC,QAAQ,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC;AAC9E,IAAI;AACJ,IAAI,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AAClD,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AAChD,QAAQ,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE;AACjE,QAAQ,IAAI,WAAW,IAAI,YAAY,EAAE;AACzC,YAAY,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC;AAClD,QAAQ;AACR,aAAa;AACb,YAAY,MAAM,IAAI,KAAK,CAAC,CAAC,oCAAoC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;AAChG,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,GAAG;AACd;;;;"}