|
| 1 | +/** |
| 2 | + * Represents an encoded authenticator assertion response typically used in WebAuthn authentication. |
| 3 | + * This type defines the structure of the response and ensures all required fields are provided in string format. |
| 4 | + * |
| 5 | + * EncodedAuthenticatorAssertionResponse includes: |
| 6 | + * - A map of additional string properties if needed. |
| 7 | + * - Fields such as `clientDataJSON`, `authenticatorData`, `signature`, and `userHandle`. |
| 8 | + * |
| 9 | + * The primary purpose of this type is to encapsulate the components originating from the authenticator |
| 10 | + * required to validate the authentication assertion. |
| 11 | + * |
| 12 | + * @protected |
| 13 | + */ |
| 14 | +export type EncodedAuthenticatorAssertionResponse = { |
| 15 | + [k: string]: string; |
| 16 | + clientDataJSON: string; |
| 17 | + authenticatorData: string; |
| 18 | + signature: string; |
| 19 | + userHandle: string; |
| 20 | +}; |
| 21 | +/** |
| 22 | + * |
| 23 | + * @param response |
| 24 | + * @protected |
| 25 | + */ |
| 26 | +export declare function encodeResponse(response: AuthenticatorAssertionResponse & Record<string, ArrayBuffer>): EncodedAuthenticatorAssertionResponse; |
| 27 | +/** |
| 28 | + * EncodedPublicKeyCredentialDescriptor represents a type that extends the PublicKeyCredentialDescriptor interface |
| 29 | + * with an additional requirement for the 'id' property to be of type string. |
| 30 | + * |
| 31 | + * This type is used to encapsulate the properties of a public key credential, including its unique identifier, |
| 32 | + * in a form where the 'id' is explicitly defined as a string rather than an ArrayBuffer. |
| 33 | + * |
| 34 | + * It is typically utilized in contexts where serialized or encoded values of public key credentials are required. |
| 35 | + * |
| 36 | + * Properties: |
| 37 | + * - id: A string representation of the unique identifier for the public key credential. |
| 38 | + * |
| 39 | + * This type is a combination of PublicKeyCredentialDescriptor properties and overrides for specific use cases |
| 40 | + * requiring encoded identifiers. |
| 41 | + * @protected |
| 42 | + */ |
| 43 | +export type EncodedPublicKeyCredentialDescriptor = PublicKeyCredentialDescriptor & { |
| 44 | + id: string; |
| 45 | +}; |
| 46 | +/** |
| 47 | + * EncodedPublicKeyCredentialRequestOptions is a composite type that extends |
| 48 | + * the PublicKeyCredentialRequestOptions interface. This type is designed |
| 49 | + * to represent request options for a WebAuthn authentication process, |
| 50 | + * with specific adjustments to handle encoded data formats. |
| 51 | + * |
| 52 | + * The primary purpose of this type is to ensure compatibility with encoded |
| 53 | + * challenges and allow credentials that are represented in an encoded format. |
| 54 | + * |
| 55 | + * Properties: |
| 56 | + * - Includes all properties from PublicKeyCredentialRequestOptions. |
| 57 | + * - `allowCredentials` (optional): An array of encoded credential descriptors |
| 58 | + * that specify which credentials may be used for the assertion. |
| 59 | + * - `challenge`: A cryptographic random challenge provided in encoded format, |
| 60 | + * used in the WebAuthn assertion process. |
| 61 | + * |
| 62 | + * This type is intended to support workflows where cryptographic data must |
| 63 | + * be encoded for transport or storage. |
| 64 | + * |
| 65 | + * @protected |
| 66 | + */ |
| 67 | +export type EncodedPublicKeyCredentialRequestOptions = PublicKeyCredentialRequestOptions & { |
| 68 | + allowCredentials?: EncodedPublicKeyCredentialDescriptor[]; |
| 69 | + challenge: string; |
| 70 | +}; |
| 71 | +/** |
| 72 | + * Decodes the given assertion request options by converting base64URL-encoded fields |
| 73 | + * into their corresponding ArrayBuffer representations and returns the decoded options. |
| 74 | + * |
| 75 | + * @param {EncodedPublicKeyCredentialRequestOptions} options - The encoded credential options to decode, containing properties such as `challenge` and `allowCredentials`. |
| 76 | + * @return {PublicKeyCredentialRequestOptions} The decoded credential request options with binary data fields properly converted. |
| 77 | + */ |
| 78 | +export declare function decodeOptions(options: EncodedPublicKeyCredentialRequestOptions): PublicKeyCredentialRequestOptions; |
| 79 | +/** |
| 80 | + * @protected |
| 81 | + */ |
| 82 | +export type EncodedCredential = { |
| 83 | + [k: string]: string | EncodedAuthenticatorAssertionResponse; |
| 84 | + id: string; |
| 85 | + type: string; |
| 86 | + response: EncodedAuthenticatorAssertionResponse; |
| 87 | + rawId: string; |
| 88 | +}; |
| 89 | +/** |
| 90 | + * Encodes the provided PublicKeyCredential into an EncodedCredential object. |
| 91 | + * |
| 92 | + * @param {PublicKeyCredential} credential - The PublicKeyCredential to be encoded. |
| 93 | + * @return {EncodedCredential} A new object containing the encoded properties of the credential. |
| 94 | + * @throws {Error} Throws an error if the input credential is invalid or cannot be processed. |
| 95 | + */ |
| 96 | +export declare function encodeCredential(credential: Credential | null): EncodedCredential; |
0 commit comments