Files
NapCatQQ/.pnpm-store/v3/files/dd/a059885c692803477b16835fa5356d97094d32e0ed7fe46d5b874c34f905370e1502e0599702e58b8ac041d499d1836013b6e21aca3d218f2e1845c2cab1b8
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

25 lines
839 B
Plaintext

import { isoCrypto } from './iso/index.js';
/**
* Generate a suitably random value to be used as an attestation or assertion challenge
*/
export async function generateChallenge() {
/**
* WebAuthn spec says that 16 bytes is a good minimum:
*
* "In order to prevent replay attacks, the challenges MUST contain enough entropy to make
* guessing them infeasible. Challenges SHOULD therefore be at least 16 bytes long."
*
* Just in case, let's double it
*/
const challenge = new Uint8Array(32);
await isoCrypto.getRandomValues(challenge);
return _generateChallengeInternals.stubThis(challenge);
}
/**
* Make it possible to stub the return value during testing
* @ignore Don't include this in docs output
*/
export const _generateChallengeInternals = {
stubThis: (value) => value,
};