UNPKG

@aws-amplify/auth

Version:
1 lines 2.16 kB
{"version":3,"file":"getAuthenticationHelper.mjs","sources":["../../../../../../src/providers/cognito/utils/srp/getAuthenticationHelper.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthenticationHelper } from './AuthenticationHelper';\nimport { BigInteger } from './BigInteger';\nimport { calculateA } from './calculate';\nimport { INIT_N } from './constants';\nimport { getHexFromBytes } from './getHexFromBytes';\nimport { getRandomBytes } from './getRandomBytes';\n/**\n * Returns a new {@link AuthenticationHelper} instance with randomly generated BigInteger seed\n *\n * @param userPoolName Cognito user pool name.\n * @returns An {@link AuthenticationHelper} instance.\n *\n * @internal\n */\nexport const getAuthenticationHelper = async (userPoolName) => {\n const N = new BigInteger(INIT_N, 16);\n const g = new BigInteger('2', 16);\n const a = generateRandomBigInteger();\n const A = await calculateA({ a, g, N });\n return new AuthenticationHelper({ userPoolName, a, g, A, N });\n};\n/**\n * Generates a random BigInteger.\n *\n * @returns {BigInteger} a random value.\n */\nconst generateRandomBigInteger = () => {\n // This will be interpreted as a postive 128-bit integer\n const hexRandom = getHexFromBytes(getRandomBytes(128));\n // There is no need to do randomBigInt.mod(this.N - 1) as N (3072-bit) is > 128 bytes (1024-bit)\n return new BigInteger(hexRandom, 16);\n};\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,uBAAuB,GAAG,OAAO,YAAY,KAAK;AAC/D,IAAI,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;AACxC,IAAI,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;AACrC,IAAI,MAAM,CAAC,GAAG,wBAAwB,EAAE;AACxC,IAAI,MAAM,CAAC,GAAG,MAAM,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAI,OAAO,IAAI,oBAAoB,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACjE;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,wBAAwB,GAAG,MAAM;AACvC;AACA,IAAI,MAAM,SAAS,GAAG,eAAe,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AAC1D;AACA,IAAI,OAAO,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC;AACxC,CAAC;;;;"}