@aws-amplify/auth
Version:
Auth category of aws-amplify
1 lines • 1.19 kB
Source Map (JSON)
{"version":3,"file":"getHashFromData.mjs","sources":["../../../../../../src/providers/cognito/utils/srp/getHashFromData.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Sha256 } from '@aws-crypto/sha256-js';\nimport { getHexFromBytes } from './getHexFromBytes';\n/**\n * Calculate a hash from a `SourceData`\n * @param {SourceData} data Value to hash.\n * @returns {string} Hex-encoded hash.\n * @private\n */\nexport const getHashFromData = (data) => {\n const sha256 = new Sha256();\n sha256.update(data);\n const hashedData = sha256.digestSync();\n const hashHexFromUint8 = getHexFromBytes(hashedData);\n return new Array(64 - hashHexFromUint8.length).join('0') + hashHexFromUint8;\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,IAAI,KAAK;AACzC,IAAI,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE;AAC/B,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;AACvB,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE;AAC1C,IAAI,MAAM,gBAAgB,GAAG,eAAe,CAAC,UAAU,CAAC;AACxD,IAAI,OAAO,IAAI,KAAK,CAAC,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,gBAAgB;AAC/E;;;;"}