@aws-amplify/core
Version:
Core category of aws-amplify
1 lines • 1.1 kB
Source Map (JSON)
{"version":3,"file":"generateRandomString.mjs","sources":["../../../src/utils/generateRandomString.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getCrypto } from './globalHelpers';\nexport const generateRandomString = (length) => {\n const STATE_CHARSET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const result = [];\n const randomNums = new Uint8Array(length);\n getCrypto().getRandomValues(randomNums);\n for (const num of randomNums) {\n result.push(STATE_CHARSET[num % STATE_CHARSET.length]);\n }\n return result.join('');\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,oBAAoB,GAAG,CAAC,MAAM,KAAK;AAChD,IAAI,MAAM,aAAa,GAAG,gEAAgE;AAC1F,IAAI,MAAM,MAAM,GAAG,EAAE;AACrB,IAAI,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC;AAC7C,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC;AAC3C,IAAI,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;AAClC,QAAQ,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAC9D;AACA,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;AAC1B;;;;"}