Files
NapCatQQ/.pnpm-store/v3/files/76/defe493838de6f054944cb7906e50a2a26d99266eb3bc69b0160f8991545a62766337ea4422758ecd8ffcff38330b8694ba5cba6a21837c63bd292b9db5b38
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

21 lines
681 B
Plaintext

import { isoCrypto } from './iso/index.js';
/**
* Generate a suitably random value to be used as user ID
*/
export async function generateUserID() {
/**
* WebAuthn spec says user.id has a max length of 64 bytes. I prefer how 32 random bytes look
* after they're base64url-encoded so I'm choosing to go with that here.
*/
const newUserID = new Uint8Array(32);
await isoCrypto.getRandomValues(newUserID);
return _generateUserIDInternals.stubThis(newUserID);
}
/**
* Make it possible to stub the return value during testing
* @ignore Don't include this in docs output
*/
export const _generateUserIDInternals = {
stubThis: (value) => value,
};