UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.28 kB
{"version":3,"file":"generate-keys.mjs","names":["constants"],"sources":["../../../src/utils/client-integrations/generate-keys.ts"],"sourcesContent":["import { scrypt } from \"@noble/hashes/scrypt.js\";\nimport { randomBytes } from \"@noble/hashes/utils.js\";\nimport constants from \"../../constants/constants.js\";\nimport { generateSecret } from \"../helpers/index.js\";\n\nconst generateKeys = async (\n\tencryptionKey: string,\n): Promise<{\n\tkey: string;\n\tapiKey: string;\n\tapiKeyHash: string;\n\tsecret: string;\n}> => {\n\tconst apiKey = Buffer.from(randomBytes(32)).toString(\"hex\");\n\tconst { secret, encryptSecret } = generateSecret(encryptionKey);\n\n\tconst apiKeyHash = Buffer.from(\n\t\tscrypt(apiKey, secret, constants.scrypt),\n\t).toString(\"base64\");\n\n\treturn {\n\t\tkey: Buffer.from(randomBytes(3)).toString(\"hex\"),\n\t\tapiKey: apiKey,\n\t\tapiKeyHash: apiKeyHash,\n\t\tsecret: encryptSecret,\n\t};\n};\n\nexport default generateKeys;\n"],"mappings":"iMAKA,MAAM,EAAe,KACpB,IAMK,CACL,IAAM,EAAS,OAAO,KAAK,EAAY,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,EACpD,CAAE,SAAQ,iBAAkB,EAAe,CAAa,EAExD,EAAa,OAAO,KACzB,EAAO,EAAQ,EAAQA,EAAU,MAAM,CACxC,CAAC,CAAC,SAAS,QAAQ,EAEnB,MAAO,CACN,IAAK,OAAO,KAAK,EAAY,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,EACvC,SACI,aACZ,OAAQ,CACT,CACD"}