Debian Codegraph @

addons/auth_passkey/_vendor/webauthn/helpers/generate_user_handle.py

raw
1 import secrets
2
3
4 def generate_user_handle() -> bytes:
5 """
6 Convenience method RP's can use to generate a privacy-preserving random sequence of
7 bytes as per best practices defined in the WebAuthn spec. This value is intended to
8 be used as the value of `user_id` when calling `generate_registration_options()`,
9 and can then be used during authentication verification to match the credential to
10 a user.
11
12 See https://www.w3.org/TR/webauthn-2/#sctn-user-handle-privacy:
13
14 "It is RECOMMENDED to let the user handle be 64 random bytes, and store this value
15 in the user's account."
16 """
17 return secrets.token_bytes(64)