Files
NapCatQQ/.pnpm-store/v3/files/36/58632e37edd5700500ac7d4b5ce4f251fdadf8c0087f1e5b5306c1e9a5b33638d1fa68278d3fc1c62ab53ad0905e29843985a61c56c868b59f2f42d0096f5a
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

29 lines
1018 B
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._generateChallengeInternals = void 0;
exports.generateChallenge = generateChallenge;
const index_js_1 = require("./iso/index.js");
/**
* Generate a suitably random value to be used as an attestation or assertion challenge
*/
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 index_js_1.isoCrypto.getRandomValues(challenge);
return exports._generateChallengeInternals.stubThis(challenge);
}
/**
* Make it possible to stub the return value during testing
* @ignore Don't include this in docs output
*/
exports._generateChallengeInternals = {
stubThis: (value) => value,
};