ox 0.12.3 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/_cjs/core/P256.js +1 -1
- package/_cjs/core/P256.js.map +1 -1
- package/_cjs/core/WebAuthnP256.js +15 -256
- package/_cjs/core/WebAuthnP256.js.map +1 -1
- package/_cjs/core/WebCryptoP256.js +3 -1
- package/_cjs/core/WebCryptoP256.js.map +1 -1
- package/_cjs/core/internal/webauthn.js +5 -13
- package/_cjs/core/internal/webauthn.js.map +1 -1
- package/_cjs/index.docs.js +1 -0
- package/_cjs/index.docs.js.map +1 -1
- package/_cjs/tempo/TxEnvelopeTempo.js +19 -1
- package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_cjs/webauthn/Authentication.js +246 -0
- package/_cjs/webauthn/Authentication.js.map +1 -0
- package/_cjs/webauthn/Authenticator.js +55 -0
- package/_cjs/webauthn/Authenticator.js.map +1 -0
- package/_cjs/webauthn/Credential.js +53 -0
- package/_cjs/webauthn/Credential.js.map +1 -0
- package/_cjs/webauthn/Registration.js +349 -0
- package/_cjs/webauthn/Registration.js.map +1 -0
- package/_cjs/webauthn/Types.js +3 -0
- package/_cjs/webauthn/Types.js.map +1 -0
- package/_cjs/webauthn/index.js +9 -0
- package/_cjs/webauthn/index.js.map +1 -0
- package/_cjs/webauthn/internal/utils.js +53 -0
- package/_cjs/webauthn/internal/utils.js.map +1 -0
- package/_esm/core/P256.js +1 -1
- package/_esm/core/P256.js.map +1 -1
- package/_esm/core/WebAuthnP256.js +13 -261
- package/_esm/core/WebAuthnP256.js.map +1 -1
- package/_esm/core/WebCryptoP256.js +4 -1
- package/_esm/core/WebCryptoP256.js.map +1 -1
- package/_esm/core/internal/webauthn.js +5 -13
- package/_esm/core/internal/webauthn.js.map +1 -1
- package/_esm/erc8021/index.js +2 -2
- package/_esm/index.docs.js +1 -0
- package/_esm/index.docs.js.map +1 -1
- package/_esm/tempo/TransactionReceipt.js +1 -1
- package/_esm/tempo/TransactionRequest.js +1 -1
- package/_esm/tempo/TxEnvelopeTempo.js +20 -1
- package/_esm/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_esm/webauthn/Authentication.js +453 -0
- package/_esm/webauthn/Authentication.js.map +1 -0
- package/_esm/webauthn/Authenticator.js +176 -0
- package/_esm/webauthn/Authenticator.js.map +1 -0
- package/_esm/webauthn/Credential.js +95 -0
- package/_esm/webauthn/Credential.js.map +1 -0
- package/_esm/webauthn/Registration.js +512 -0
- package/_esm/webauthn/Registration.js.map +1 -0
- package/_esm/webauthn/Types.js +2 -0
- package/_esm/webauthn/Types.js.map +1 -0
- package/_esm/webauthn/index.js +31 -0
- package/_esm/webauthn/index.js.map +1 -0
- package/_esm/webauthn/internal/utils.js +52 -0
- package/_esm/webauthn/internal/utils.js.map +1 -0
- package/_types/core/WebAuthnP256.d.ts +33 -208
- package/_types/core/WebAuthnP256.d.ts.map +1 -1
- package/_types/core/WebCryptoP256.d.ts +2 -0
- package/_types/core/WebCryptoP256.d.ts.map +1 -1
- package/_types/core/internal/webauthn.d.ts +2 -110
- package/_types/core/internal/webauthn.d.ts.map +1 -1
- package/_types/erc8021/index.d.ts +2 -2
- package/_types/index.docs.d.ts +1 -0
- package/_types/index.docs.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +2 -2
- package/_types/tempo/TransactionReceipt.d.ts +2 -2
- package/_types/tempo/TransactionRequest.d.ts +2 -2
- package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/_types/webauthn/Authentication.d.ts +324 -0
- package/_types/webauthn/Authentication.d.ts.map +1 -0
- package/_types/webauthn/Authenticator.d.ts +182 -0
- package/_types/webauthn/Authenticator.d.ts.map +1 -0
- package/_types/webauthn/Credential.d.ts +77 -0
- package/_types/webauthn/Credential.d.ts.map +1 -0
- package/_types/webauthn/Registration.d.ts +308 -0
- package/_types/webauthn/Registration.d.ts.map +1 -0
- package/_types/webauthn/Types.d.ts +106 -0
- package/_types/webauthn/Types.d.ts.map +1 -0
- package/_types/webauthn/index.d.ts +33 -0
- package/_types/webauthn/index.d.ts.map +1 -0
- package/_types/webauthn/internal/utils.d.ts +17 -0
- package/_types/webauthn/internal/utils.d.ts.map +1 -0
- package/core/P256.ts +1 -1
- package/core/WebAuthnP256.ts +37 -582
- package/core/WebCryptoP256.ts +6 -1
- package/core/internal/webauthn.ts +6 -165
- package/erc8021/index.ts +2 -2
- package/index.docs.ts +1 -0
- package/package.json +31 -1
- package/tempo/Transaction.ts +2 -2
- package/tempo/TransactionReceipt.ts +2 -2
- package/tempo/TransactionRequest.ts +2 -2
- package/tempo/TxEnvelopeTempo.test.ts +6 -0
- package/tempo/TxEnvelopeTempo.ts +22 -2
- package/version.ts +1 -1
- package/webauthn/Authentication/package.json +6 -0
- package/webauthn/Authentication.ts +673 -0
- package/webauthn/Authenticator/package.json +6 -0
- package/webauthn/Authenticator.ts +259 -0
- package/webauthn/Credential/package.json +6 -0
- package/webauthn/Credential.ts +146 -0
- package/webauthn/Registration/package.json +6 -0
- package/webauthn/Registration.ts +805 -0
- package/webauthn/Types/package.json +6 -0
- package/webauthn/Types.ts +158 -0
- package/webauthn/index.ts +38 -0
- package/webauthn/internal/utils.ts +63 -0
- package/webauthn/package.json +6 -0
|
@@ -13,7 +13,7 @@ type KeyType = 'secp256k1' | 'p256' | 'webAuthn';
|
|
|
13
13
|
* Extends the [Execution API specification](https://github.com/ethereum/execution-apis/blob/4aca1d7a3e5aab24c8f6437131289ad386944eaa/src/schemas/transaction.yaml#L358-L423)
|
|
14
14
|
* with Tempo-specific fields for batched calls, fee tokens, access keys, and scheduled execution.
|
|
15
15
|
*
|
|
16
|
-
* @see {@link https://docs.tempo.xyz/protocol/transactions
|
|
16
|
+
* @see {@link https://docs.tempo.xyz/protocol/transactions}
|
|
17
17
|
*/
|
|
18
18
|
export type TransactionRequest<bigintType = bigint, numberType = number, type extends string = string> = Compute<Omit<ox_TransactionRequest.TransactionRequest<bigintType, numberType, type>, 'authorizationList'> & {
|
|
19
19
|
authorizationList?: AuthorizationTempo.ListSigned<bigintType, numberType> | undefined;
|
|
@@ -35,7 +35,7 @@ export type Rpc = Omit<TransactionRequest<Hex.Hex, Hex.Hex, string>, 'authorizat
|
|
|
35
35
|
/**
|
|
36
36
|
* Converts a {@link ox#TransactionRequest.TransactionRequest} to a {@link ox#TransactionRequest.Rpc}.
|
|
37
37
|
*
|
|
38
|
-
* @see {@link https://docs.tempo.xyz/protocol/transactions
|
|
38
|
+
* @see {@link https://docs.tempo.xyz/protocol/transactions}
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
41
|
* ```ts twoslash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxEnvelopeTempo.d.ts","sourceRoot":"","sources":["../../tempo/TxEnvelopeTempo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,EACV,MAAM,EACN,OAAO,EACP,KAAK,EACL,SAAS,EACT,cAAc,EACf,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AAErC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;;GAMG;AACH,MA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AsB,CAAC,OAAO,GACtC,sBAAsB,CAAC,WAAW,CAUpC;AAED,MAAM,CAAC,OAAO,WAAW,sBAAsB,CAAC;IAC9C,KAAK,OAAO,GAAG;QACb;;WAEG;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAA;KACxB,CAAA;IAED,KAAK,WAAW,GAAG,GAAG,CAAC,GAAG,CAAA;IAE1B,KAAK,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACzD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC,WAOpE;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,KAAK,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACxC;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAgB,SAAQ,MAAM,CAAC,SAAS;IACnD,SAAkB,IAAI,qCAAoC;;CAI3D;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,0BAA2B,SAAQ,MAAM,CAAC,SAAS;IAC9D,SAAkB,IAAI,gDAA+C;gBACzD,EACV,WAAW,EACX,UAAU,GACX,EAAE;QACD,WAAW,EAAE,MAAM,CAAA;QACnB,UAAU,EAAE,MAAM,CAAA;KACnB;CAKF"}
|
package/_types/version.d.ts
CHANGED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import * as Base64 from '../core/Base64.js';
|
|
2
|
+
import * as Bytes from '../core/Bytes.js';
|
|
3
|
+
import * as Errors from '../core/Errors.js';
|
|
4
|
+
import * as Hash from '../core/Hash.js';
|
|
5
|
+
import * as Hex from '../core/Hex.js';
|
|
6
|
+
import type { OneOf } from '../core/internal/types.js';
|
|
7
|
+
import * as P256 from '../core/P256.js';
|
|
8
|
+
import type * as PublicKey from '../core/PublicKey.js';
|
|
9
|
+
import * as Signature from '../core/Signature.js';
|
|
10
|
+
import type * as Credential_ from './Credential.js';
|
|
11
|
+
import type * as Types from './Types.js';
|
|
12
|
+
/** Response from a WebAuthn authentication ceremony. */
|
|
13
|
+
export type Response<serialized extends boolean = false> = {
|
|
14
|
+
id: string;
|
|
15
|
+
metadata: Credential_.SignMetadata;
|
|
16
|
+
raw: Types.PublicKeyCredential<serialized>;
|
|
17
|
+
signature: serialized extends true ? Hex.Hex : Signature.Signature<false>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Deserializes credential request options that can be passed to
|
|
21
|
+
* `navigator.credentials.get()`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts twoslash
|
|
25
|
+
* import { Authentication } from 'ox/webauthn'
|
|
26
|
+
*
|
|
27
|
+
* const options = Authentication.getOptions({
|
|
28
|
+
* challenge: '0xdeadbeef',
|
|
29
|
+
* })
|
|
30
|
+
* const serialized = Authentication.serializeOptions(options)
|
|
31
|
+
*
|
|
32
|
+
* // ... send to server and back ...
|
|
33
|
+
*
|
|
34
|
+
* const deserialized = Authentication.deserializeOptions(serialized) // [!code focus]
|
|
35
|
+
* const credential = await window.navigator.credentials.get(deserialized)
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param options - The serialized credential request options.
|
|
39
|
+
* @returns The deserialized credential request options.
|
|
40
|
+
*/
|
|
41
|
+
export declare function deserializeOptions(options: Types.CredentialRequestOptions<true>): Types.CredentialRequestOptions;
|
|
42
|
+
export declare namespace deserializeOptions {
|
|
43
|
+
type ErrorType = Base64.toBytes.ErrorType | Errors.GlobalErrorType;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Deserializes a serialized authentication response.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts twoslash
|
|
50
|
+
* import { Authentication } from 'ox/webauthn'
|
|
51
|
+
*
|
|
52
|
+
* const response = Authentication.deserializeResponse({ // [!code focus]
|
|
53
|
+
* id: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', // [!code focus]
|
|
54
|
+
* metadata: { // [!code focus]
|
|
55
|
+
* authenticatorData: '0x49960de5...', // [!code focus]
|
|
56
|
+
* clientDataJSON: '{"type":"webauthn.get",...}', // [!code focus]
|
|
57
|
+
* challengeIndex: 23, // [!code focus]
|
|
58
|
+
* typeIndex: 1, // [!code focus]
|
|
59
|
+
* userVerificationRequired: true, // [!code focus]
|
|
60
|
+
* }, // [!code focus]
|
|
61
|
+
* raw: { // [!code focus]
|
|
62
|
+
* id: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', // [!code focus]
|
|
63
|
+
* type: 'public-key', // [!code focus]
|
|
64
|
+
* authenticatorAttachment: 'platform', // [!code focus]
|
|
65
|
+
* rawId: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', // [!code focus]
|
|
66
|
+
* response: { clientDataJSON: 'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0In0' }, // [!code focus]
|
|
67
|
+
* }, // [!code focus]
|
|
68
|
+
* signature: '0x...', // [!code focus]
|
|
69
|
+
* }) // [!code focus]
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param response - The serialized authentication response.
|
|
73
|
+
* @returns The deserialized authentication response.
|
|
74
|
+
*/
|
|
75
|
+
export declare function deserializeResponse(response: Response<true>): Response;
|
|
76
|
+
export declare namespace deserializeResponse {
|
|
77
|
+
type ErrorType = Base64.toBytes.ErrorType | Signature.from.ErrorType | Errors.GlobalErrorType;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Returns the request options to sign a challenge with the Web Authentication API.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts twoslash
|
|
84
|
+
* import { Authentication } from 'ox/webauthn'
|
|
85
|
+
*
|
|
86
|
+
* const options = Authentication.getOptions({
|
|
87
|
+
* challenge: '0xdeadbeef',
|
|
88
|
+
* })
|
|
89
|
+
*
|
|
90
|
+
* const credential = await window.navigator.credentials.get(options)
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @param options - Options.
|
|
94
|
+
* @returns The credential request options.
|
|
95
|
+
*/
|
|
96
|
+
export declare function getOptions(options: getOptions.Options): Types.CredentialRequestOptions;
|
|
97
|
+
export declare namespace getOptions {
|
|
98
|
+
type Options = {
|
|
99
|
+
/** The credential ID to use. */
|
|
100
|
+
credentialId?: string | string[] | undefined;
|
|
101
|
+
/** The challenge to sign. */
|
|
102
|
+
challenge: Hex.Hex;
|
|
103
|
+
/** List of Web Authentication API credentials to use during creation or authentication. */
|
|
104
|
+
extensions?: Types.PublicKeyCredentialRequestOptions['extensions'] | undefined;
|
|
105
|
+
/** The relying party identifier to use. */
|
|
106
|
+
rpId?: Types.PublicKeyCredentialRequestOptions['rpId'] | undefined;
|
|
107
|
+
/** The user verification requirement. */
|
|
108
|
+
userVerification?: Types.PublicKeyCredentialRequestOptions['userVerification'] | undefined;
|
|
109
|
+
};
|
|
110
|
+
type ErrorType = Bytes.fromHex.ErrorType | Base64.toBytes.ErrorType | Errors.GlobalErrorType;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Constructs the final digest that was signed and computed by the authenticator. This payload includes
|
|
114
|
+
* the cryptographic `challenge`, as well as authenticator metadata (`authenticatorData` + `clientDataJSON`).
|
|
115
|
+
* This value can be also used with raw P256 verification (such as `P256.verify` or
|
|
116
|
+
* `WebCryptoP256.verify`).
|
|
117
|
+
*
|
|
118
|
+
* :::warning
|
|
119
|
+
*
|
|
120
|
+
* This function is mainly for testing purposes or for manually constructing
|
|
121
|
+
* signing payloads. In most cases you will not need this function and
|
|
122
|
+
* instead use `Authentication.sign`.
|
|
123
|
+
*
|
|
124
|
+
* :::
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts twoslash
|
|
128
|
+
* import { Authentication } from 'ox/webauthn'
|
|
129
|
+
* import { WebCryptoP256 } from 'ox'
|
|
130
|
+
*
|
|
131
|
+
* const { metadata, payload } = Authentication.getSignPayload({ // [!code focus]
|
|
132
|
+
* challenge: '0xdeadbeef', // [!code focus]
|
|
133
|
+
* }) // [!code focus]
|
|
134
|
+
*
|
|
135
|
+
* const { publicKey, privateKey } = await WebCryptoP256.createKeyPair()
|
|
136
|
+
*
|
|
137
|
+
* const signature = await WebCryptoP256.sign({
|
|
138
|
+
* payload,
|
|
139
|
+
* privateKey,
|
|
140
|
+
* })
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @param options - Options to construct the signing payload.
|
|
144
|
+
* @returns The signing payload.
|
|
145
|
+
*/
|
|
146
|
+
export declare function getSignPayload(options: getSignPayload.Options): getSignPayload.ReturnType;
|
|
147
|
+
export declare namespace getSignPayload {
|
|
148
|
+
type Options = {
|
|
149
|
+
/** The challenge to sign. */
|
|
150
|
+
challenge: Hex.Hex;
|
|
151
|
+
/** If set to `true`, it means that the calling context is an `<iframe>` that is not same origin with its ancestor frames. */
|
|
152
|
+
crossOrigin?: boolean | undefined;
|
|
153
|
+
/** Additional client data to include in the client data JSON. */
|
|
154
|
+
extraClientData?: Record<string, unknown> | undefined;
|
|
155
|
+
/** If set to `true`, the payload will be hashed before being returned. */
|
|
156
|
+
hash?: boolean | undefined;
|
|
157
|
+
/** A bitfield that indicates various attributes that were asserted by the authenticator. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data#flags) */
|
|
158
|
+
flag?: number | undefined;
|
|
159
|
+
/** The fully qualified origin of the relying party which has been given by the client/browser to the authenticator. */
|
|
160
|
+
origin?: string | undefined;
|
|
161
|
+
/** The [Relying Party ID](https://w3c.github.io/webauthn/#relying-party-identifier) that the credential is scoped to. */
|
|
162
|
+
rpId?: Types.PublicKeyCredentialRequestOptions['rpId'] | undefined;
|
|
163
|
+
/** A signature counter, if supported by the authenticator (set to 0 otherwise). */
|
|
164
|
+
signCount?: number | undefined;
|
|
165
|
+
/** The user verification requirement that the authenticator will enforce. */
|
|
166
|
+
userVerification?: Types.PublicKeyCredentialRequestOptions['userVerification'] | undefined;
|
|
167
|
+
};
|
|
168
|
+
type ReturnType = {
|
|
169
|
+
metadata: Credential_.SignMetadata;
|
|
170
|
+
payload: Hex.Hex;
|
|
171
|
+
};
|
|
172
|
+
type ErrorType = Hash.sha256.ErrorType | Hex.concat.ErrorType | Hex.fromString.ErrorType | Errors.GlobalErrorType;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Serializes credential request options into a JSON-serializable
|
|
176
|
+
* format, converting `BufferSource` fields to base64url strings.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts twoslash
|
|
180
|
+
* import { Authentication } from 'ox/webauthn'
|
|
181
|
+
*
|
|
182
|
+
* const options = Authentication.getOptions({
|
|
183
|
+
* challenge: '0xdeadbeef',
|
|
184
|
+
* })
|
|
185
|
+
*
|
|
186
|
+
* const serialized = Authentication.serializeOptions(options) // [!code focus]
|
|
187
|
+
*
|
|
188
|
+
* // `serialized` is JSON-serializable — send it to a server, store it, etc.
|
|
189
|
+
* const json = JSON.stringify(serialized)
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @param options - The credential request options to serialize.
|
|
193
|
+
* @returns The serialized credential request options.
|
|
194
|
+
*/
|
|
195
|
+
export declare function serializeOptions(options: Types.CredentialRequestOptions): Types.CredentialRequestOptions<true>;
|
|
196
|
+
export declare namespace serializeOptions {
|
|
197
|
+
type ErrorType = Base64.fromBytes.ErrorType | Errors.GlobalErrorType;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Serializes an authentication response into a JSON-serializable
|
|
201
|
+
* format, converting `BufferSource` fields to base64url strings
|
|
202
|
+
* and the signature to a hex string.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts twoslash
|
|
206
|
+
* import { Authentication } from 'ox/webauthn'
|
|
207
|
+
*
|
|
208
|
+
* const response = await Authentication.sign({
|
|
209
|
+
* challenge: '0xdeadbeef',
|
|
210
|
+
* })
|
|
211
|
+
*
|
|
212
|
+
* const serialized = Authentication.serializeResponse(response) // [!code focus]
|
|
213
|
+
*
|
|
214
|
+
* // `serialized` is JSON-serializable — send it to a server, store it, etc.
|
|
215
|
+
* const json = JSON.stringify(serialized)
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @param response - The authentication response to serialize.
|
|
219
|
+
* @returns The serialized authentication response.
|
|
220
|
+
*/
|
|
221
|
+
export declare function serializeResponse(response: Response): Response<true>;
|
|
222
|
+
export declare namespace serializeResponse {
|
|
223
|
+
type ErrorType = Base64.fromBytes.ErrorType | Signature.toHex.ErrorType | Errors.GlobalErrorType;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Signs a challenge using a stored WebAuthn P256 Credential. If no Credential is provided,
|
|
227
|
+
* a prompt will be displayed for the user to select an existing Credential
|
|
228
|
+
* that was previously registered.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts twoslash
|
|
232
|
+
* import { Registration, Authentication } from 'ox/webauthn'
|
|
233
|
+
*
|
|
234
|
+
* const credential = await Registration.create({
|
|
235
|
+
* name: 'Example',
|
|
236
|
+
* })
|
|
237
|
+
*
|
|
238
|
+
* const { metadata, signature } = await Authentication.sign({ // [!code focus]
|
|
239
|
+
* credentialId: credential.id, // [!code focus]
|
|
240
|
+
* challenge: '0xdeadbeef', // [!code focus]
|
|
241
|
+
* }) // [!code focus]
|
|
242
|
+
* // @log: {
|
|
243
|
+
* // @log: metadata: {
|
|
244
|
+
* // @log: authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000',
|
|
245
|
+
* // @log: clientDataJSON: '{"type":"webauthn.get","challenge":"9jEFijuhEWrM4SOW-tChJbUEHEP44VcjcJ-Bqo1fTM8","origin":"http://localhost:5173","crossOrigin":false}',
|
|
246
|
+
* // @log: challengeIndex: 23,
|
|
247
|
+
* // @log: typeIndex: 1,
|
|
248
|
+
* // @log: userVerificationRequired: true,
|
|
249
|
+
* // @log: },
|
|
250
|
+
* // @log: signature: { r: 51231...4215n, s: 12345...6789n },
|
|
251
|
+
* // @log: }
|
|
252
|
+
* ```
|
|
253
|
+
*
|
|
254
|
+
* @param options - Options.
|
|
255
|
+
* @returns The signature.
|
|
256
|
+
*/
|
|
257
|
+
export declare function sign(options: sign.Options): Promise<sign.ReturnType>;
|
|
258
|
+
export declare namespace sign {
|
|
259
|
+
type Options = OneOf<(getOptions.Options & {
|
|
260
|
+
/**
|
|
261
|
+
* Credential request function. Useful for environments that do not support
|
|
262
|
+
* the WebAuthn API natively (i.e. React Native or testing environments).
|
|
263
|
+
*
|
|
264
|
+
* @default window.navigator.credentials.get
|
|
265
|
+
*/
|
|
266
|
+
getFn?: ((options?: Types.CredentialRequestOptions | undefined) => Promise<Types.Credential | null>) | undefined;
|
|
267
|
+
}) | Types.CredentialRequestOptions>;
|
|
268
|
+
type ReturnType = Response;
|
|
269
|
+
type ErrorType = Hex.fromBytes.ErrorType | getOptions.ErrorType | Errors.GlobalErrorType;
|
|
270
|
+
}
|
|
271
|
+
/** Thrown when a WebAuthn P256 credential request fails. */
|
|
272
|
+
export declare class SignFailedError extends Errors.BaseError<Error> {
|
|
273
|
+
readonly name = "Authentication.SignFailedError";
|
|
274
|
+
constructor({ cause }?: {
|
|
275
|
+
cause?: Error | undefined;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Verifies a signature using the Credential's public key and the challenge which was signed.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts twoslash
|
|
283
|
+
* import { Registration, Authentication } from 'ox/webauthn'
|
|
284
|
+
*
|
|
285
|
+
* const credential = await Registration.create({
|
|
286
|
+
* name: 'Example',
|
|
287
|
+
* })
|
|
288
|
+
*
|
|
289
|
+
* const { metadata, signature } = await Authentication.sign({
|
|
290
|
+
* credentialId: credential.id,
|
|
291
|
+
* challenge: '0xdeadbeef',
|
|
292
|
+
* })
|
|
293
|
+
*
|
|
294
|
+
* const result = Authentication.verify({ // [!code focus]
|
|
295
|
+
* metadata, // [!code focus]
|
|
296
|
+
* challenge: '0xdeadbeef', // [!code focus]
|
|
297
|
+
* publicKey: credential.publicKey, // [!code focus]
|
|
298
|
+
* signature, // [!code focus]
|
|
299
|
+
* }) // [!code focus]
|
|
300
|
+
* // @log: true
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* @param options - Options.
|
|
304
|
+
* @returns Whether the signature is valid.
|
|
305
|
+
*/
|
|
306
|
+
export declare function verify(options: verify.Options): boolean;
|
|
307
|
+
export declare namespace verify {
|
|
308
|
+
type Options = {
|
|
309
|
+
/** The challenge to verify. */
|
|
310
|
+
challenge: Hex.Hex;
|
|
311
|
+
/** The public key to verify the signature with. */
|
|
312
|
+
publicKey: PublicKey.PublicKey;
|
|
313
|
+
/** The signature to verify. */
|
|
314
|
+
signature: Signature.Signature<false>;
|
|
315
|
+
/** The metadata to verify the signature with. */
|
|
316
|
+
metadata: Credential_.SignMetadata;
|
|
317
|
+
/** Expected origin(s). If provided, the `clientDataJSON` origin will be validated. */
|
|
318
|
+
origin?: string | string[] | undefined;
|
|
319
|
+
/** Expected relying party ID. If provided, the `rpIdHash` in `authenticatorData` will be validated. */
|
|
320
|
+
rpId?: string | undefined;
|
|
321
|
+
};
|
|
322
|
+
type ErrorType = Base64.toBytes.ErrorType | Bytes.concat.ErrorType | Bytes.fromHex.ErrorType | Bytes.isEqual.ErrorType | Hash.sha256.ErrorType | Hex.fromString.ErrorType | P256.verify.ErrorType | Errors.GlobalErrorType;
|
|
323
|
+
}
|
|
324
|
+
//# sourceMappingURL=Authentication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Authentication.d.ts","sourceRoot":"","sources":["../../webauthn/Authentication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC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AA+B;QAC/B,SAAS,EAAE,GAAG,CAAC,GAAG,CAAA;QAClB,mDAAmD;QACnD,SAAS,EAAE,SAAS,CAAC,SAAS,CAAA;QAC9B,+BAA+B;QAC/B,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QACrC,iDAAiD;QACjD,QAAQ,EAAE,WAAW,CAAC,YAAY,CAAA;QAClC,sFAAsF;QACtF,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;QACtC,uGAAuG;QACvG,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1B,CAAA;IAED,KAAK,SAAS,GACV,MAAM,CAAC,OAAO,CAAC,SAAS,GACxB,KAAK,CAAC,MAAM,CAAC,SAAS,GACtB,KAAK,CAAC,OAAO,CAAC,SAAS,GACvB,KAAK,CAAC,OAAO,CAAC,SAAS,GACvB,IAAI,CAAC,MAAM,CAAC,SAAS,GACrB,GAAG,CAAC,UAAU,CAAC,SAAS,GACxB,IAAI,CAAC,MAAM,CAAC,SAAS,GACrB,MAAM,CAAC,eAAe,CAAA;CAC3B"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import * as Bytes from '../core/Bytes.js';
|
|
2
|
+
import * as Cbor from '../core/Cbor.js';
|
|
3
|
+
import type * as Errors from '../core/Errors.js';
|
|
4
|
+
import * as Hex from '../core/Hex.js';
|
|
5
|
+
import type * as PublicKey from '../core/PublicKey.js';
|
|
6
|
+
import type * as Types from './Types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Gets the authenticator data which contains information about the
|
|
9
|
+
* processing of an authenticator request (ie. from `Authentication.sign`).
|
|
10
|
+
*
|
|
11
|
+
* :::warning
|
|
12
|
+
*
|
|
13
|
+
* This function is mainly for testing purposes or for manually constructing
|
|
14
|
+
* autenticator data. In most cases you will not need this function.
|
|
15
|
+
* `authenticatorData` is typically returned as part of the
|
|
16
|
+
* authenticator response.
|
|
17
|
+
*
|
|
18
|
+
* :::
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts twoslash
|
|
22
|
+
* import { Authenticator } from 'ox/webauthn'
|
|
23
|
+
*
|
|
24
|
+
* const authenticatorData = Authenticator.getAuthenticatorData({
|
|
25
|
+
* rpId: 'example.com',
|
|
26
|
+
* signCount: 420,
|
|
27
|
+
* })
|
|
28
|
+
* // @log: "0xa379a6f6eeafb9a55e378c118034e2751e682fab9f2d30ab13d2125586ce194705000001a4"
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ### With Attested Credential Data
|
|
33
|
+
*
|
|
34
|
+
* Include a credential ID and public key in the authenticator data (for registration responses):
|
|
35
|
+
*
|
|
36
|
+
* ```ts twoslash
|
|
37
|
+
* import { P256 } from 'ox'
|
|
38
|
+
* import { Authenticator } from 'ox/webauthn'
|
|
39
|
+
*
|
|
40
|
+
* const { publicKey } = P256.createKeyPair()
|
|
41
|
+
*
|
|
42
|
+
* const authenticatorData = Authenticator.getAuthenticatorData({
|
|
43
|
+
* rpId: 'example.com',
|
|
44
|
+
* flag: 0x41, // UP + AT
|
|
45
|
+
* credential: {
|
|
46
|
+
* id: new Uint8Array(32),
|
|
47
|
+
* publicKey,
|
|
48
|
+
* },
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param options - Options to construct the authenticator data.
|
|
53
|
+
* @returns The authenticator data.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getAuthenticatorData(options?: getAuthenticatorData.Options): Hex.Hex;
|
|
56
|
+
export declare namespace getAuthenticatorData {
|
|
57
|
+
type Options = {
|
|
58
|
+
/** Attested credential data to include (credential ID + public key). When set, the AT flag (0x40) should also be set. */
|
|
59
|
+
credential?: {
|
|
60
|
+
/** The credential ID as raw bytes. */
|
|
61
|
+
id: Uint8Array;
|
|
62
|
+
/** The P256 public key associated with the credential. */
|
|
63
|
+
publicKey: PublicKey.PublicKey;
|
|
64
|
+
} | undefined;
|
|
65
|
+
/** A bitfield that indicates various attributes that were asserted by the authenticator. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data#flags) */
|
|
66
|
+
flag?: number | undefined;
|
|
67
|
+
/** The [Relying Party ID](https://w3c.github.io/webauthn/#relying-party-identifier) that the credential is scoped to. */
|
|
68
|
+
rpId?: Types.PublicKeyCredentialRequestOptions['rpId'] | undefined;
|
|
69
|
+
/** A signature counter, if supported by the authenticator (set to 0 otherwise). */
|
|
70
|
+
signCount?: number | undefined;
|
|
71
|
+
};
|
|
72
|
+
type ErrorType = Errors.GlobalErrorType;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Extracts the signature counter from the authenticator data.
|
|
76
|
+
* The counter is a 4-byte big-endian unsigned integer at bytes 33–36.
|
|
77
|
+
*
|
|
78
|
+
* Useful for detecting cloned authenticators: if the counter is non-zero and
|
|
79
|
+
* does not monotonically increase between assertions, it may indicate a cloned key.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts twoslash
|
|
83
|
+
* import { Authenticator } from 'ox/webauthn'
|
|
84
|
+
*
|
|
85
|
+
* const signCount = Authenticator.getSignCount(
|
|
86
|
+
* '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000001',
|
|
87
|
+
* )
|
|
88
|
+
* // @log: 1
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @param authenticatorData - The authenticator data hex string.
|
|
92
|
+
* @returns The signature counter.
|
|
93
|
+
*/
|
|
94
|
+
export declare function getSignCount(authenticatorData: Hex.Hex): number;
|
|
95
|
+
export declare namespace getSignCount {
|
|
96
|
+
type ErrorType = Bytes.fromHex.ErrorType | Errors.GlobalErrorType;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Constructs the Client Data in stringified JSON format which represents client data that
|
|
100
|
+
* was passed to `credentials.get()` or `credentials.create()`.
|
|
101
|
+
*
|
|
102
|
+
* :::warning
|
|
103
|
+
*
|
|
104
|
+
* This function is mainly for testing purposes or for manually constructing
|
|
105
|
+
* client data. In most cases you will not need this function.
|
|
106
|
+
* `clientDataJSON` is typically returned as part of the authenticator response.
|
|
107
|
+
*
|
|
108
|
+
* :::
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts twoslash
|
|
112
|
+
* import { Authenticator } from 'ox/webauthn'
|
|
113
|
+
*
|
|
114
|
+
* const clientDataJSON = Authenticator.getClientDataJSON({
|
|
115
|
+
* challenge: '0xdeadbeef',
|
|
116
|
+
* origin: 'https://example.com',
|
|
117
|
+
* })
|
|
118
|
+
* // @log: "{"type":"webauthn.get","challenge":"3q2-7w","origin":"https://example.com","crossOrigin":false}"
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @param options - Options to construct the client data.
|
|
122
|
+
* @returns The client data.
|
|
123
|
+
*/
|
|
124
|
+
export declare function getClientDataJSON(options: getClientDataJSON.Options): string;
|
|
125
|
+
export declare namespace getClientDataJSON {
|
|
126
|
+
type Options = {
|
|
127
|
+
/** The challenge to sign. */
|
|
128
|
+
challenge: Hex.Hex;
|
|
129
|
+
/** If set to `true`, it means that the calling context is an `<iframe>` that is not same origin with its ancestor frames. */
|
|
130
|
+
crossOrigin?: boolean | undefined;
|
|
131
|
+
/** Additional client data to include in the client data JSON. */
|
|
132
|
+
extraClientData?: Record<string, unknown> | undefined;
|
|
133
|
+
/** The fully qualified origin of the relying party which has been given by the client/browser to the authenticator. */
|
|
134
|
+
origin?: string | undefined;
|
|
135
|
+
/** The WebAuthn ceremony type. @default 'webauthn.get' */
|
|
136
|
+
type?: 'webauthn.create' | 'webauthn.get' | undefined;
|
|
137
|
+
};
|
|
138
|
+
type ErrorType = Errors.GlobalErrorType;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Constructs a CBOR-encoded attestation object for testing WebAuthn registration
|
|
142
|
+
* verification. Combines the authenticator data with an attestation statement.
|
|
143
|
+
*
|
|
144
|
+
* :::warning
|
|
145
|
+
*
|
|
146
|
+
* This function is mainly for testing purposes. In production, the attestation
|
|
147
|
+
* object is returned by the authenticator during `navigator.credentials.create()`.
|
|
148
|
+
*
|
|
149
|
+
* :::
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts twoslash
|
|
153
|
+
* import { P256 } from 'ox'
|
|
154
|
+
* import { Authenticator } from 'ox/webauthn'
|
|
155
|
+
*
|
|
156
|
+
* const { publicKey } = P256.createKeyPair()
|
|
157
|
+
*
|
|
158
|
+
* const attestationObject = Authenticator.getAttestationObject({
|
|
159
|
+
* authData: Authenticator.getAuthenticatorData({
|
|
160
|
+
* rpId: 'example.com',
|
|
161
|
+
* flag: 0x41,
|
|
162
|
+
* credential: { id: new Uint8Array(32), publicKey },
|
|
163
|
+
* }),
|
|
164
|
+
* })
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @param options - Options to construct the attestation object.
|
|
168
|
+
* @returns The CBOR-encoded attestation object as a Hex string.
|
|
169
|
+
*/
|
|
170
|
+
export declare function getAttestationObject(options: getAttestationObject.Options): Hex.Hex;
|
|
171
|
+
export declare namespace getAttestationObject {
|
|
172
|
+
type Options = {
|
|
173
|
+
/** Attestation statement. */
|
|
174
|
+
attStmt?: Record<string, unknown> | undefined;
|
|
175
|
+
/** Authenticator data as a Hex string (from `Authenticator.getAuthenticatorData`). */
|
|
176
|
+
authData: Hex.Hex;
|
|
177
|
+
/** Attestation format. @default 'none' */
|
|
178
|
+
fmt?: string | undefined;
|
|
179
|
+
};
|
|
180
|
+
type ErrorType = Cbor.encode.ErrorType | Errors.GlobalErrorType;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=Authenticator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Authenticator.d.ts","sourceRoot":"","sources":["../../webauthn/Authenticator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,M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BAAiB,CAAC,OAAO,EAAE,iBAAiB,CAAC,OAAO,GAAG,MAAM,CAgB5E;AAED,MAAM,CAAC,OAAO,WAAW,iBAAiB,CAAC;IACzC,KAAK,OAAO,GAAG;QACb,6BAA6B;QAC7B,SAAS,EAAE,GAAG,CAAC,GAAG,CAAA;QAClB,6HAA6H;QAC7H,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;QACjC,iEAAiE;QACjE,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;QACrD,uHAAuH;QACvH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC3B,0DAA0D;QAC1D,IAAI,CAAC,EAAE,iBAAiB,GAAG,cAAc,GAAG,SAAS,CAAA;KACtD,CAAA;IAED,KAAK,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,oBAAoB,CAAC,OAAO,GACpC,GAAG,CAAC,GAAG,CAOT;AAED,MAAM,CAAC,OAAO,WAAW,oBAAoB,CAAC;IAC5C,KAAK,OAAO,GAAG;QACb,6BAA6B;QAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;QAC7C,sFAAsF;QACtF,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAA;QACjB,0CAA0C;QAC1C,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KACzB,CAAA;IAED,KAAK,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CAChE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as Base64 from '../core/Base64.js';
|
|
2
|
+
import type * as Errors from '../core/Errors.js';
|
|
3
|
+
import type * as Hex from '../core/Hex.js';
|
|
4
|
+
import type { Compute } from '../core/internal/types.js';
|
|
5
|
+
import * as PublicKey from '../core/PublicKey.js';
|
|
6
|
+
import type * as Types from './Types.js';
|
|
7
|
+
/** A WebAuthn-flavored P256 credential. */
|
|
8
|
+
export type Credential<serialized extends boolean = false> = {
|
|
9
|
+
attestationObject: serialized extends true ? string : ArrayBuffer;
|
|
10
|
+
clientDataJSON: serialized extends true ? string : ArrayBuffer;
|
|
11
|
+
id: string;
|
|
12
|
+
publicKey: serialized extends true ? Hex.Hex : PublicKey.PublicKey;
|
|
13
|
+
raw: Types.PublicKeyCredential<serialized>;
|
|
14
|
+
};
|
|
15
|
+
/** Metadata for a WebAuthn P256 signature. */
|
|
16
|
+
export type SignMetadata = Compute<{
|
|
17
|
+
authenticatorData: Hex.Hex;
|
|
18
|
+
challengeIndex?: number | undefined;
|
|
19
|
+
clientDataJSON: string;
|
|
20
|
+
typeIndex?: number | undefined;
|
|
21
|
+
userVerificationRequired?: boolean | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Serializes a credential into a JSON-serializable
|
|
25
|
+
* format.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts twoslash
|
|
29
|
+
* import { Registration, Credential } from 'ox/webauthn'
|
|
30
|
+
*
|
|
31
|
+
* const credential = await Registration.create({ name: 'Example' })
|
|
32
|
+
*
|
|
33
|
+
* const serialized = Credential.serialize(credential) // [!code focus]
|
|
34
|
+
*
|
|
35
|
+
* // `serialized` is JSON-serializable — send it to a server, store it, etc.
|
|
36
|
+
* const json = JSON.stringify(serialized)
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param credential - The credential to serialize.
|
|
40
|
+
* @returns The serialized credential.
|
|
41
|
+
*/
|
|
42
|
+
export declare function serialize(credential: Credential): Credential<true>;
|
|
43
|
+
export declare namespace serialize {
|
|
44
|
+
type ErrorType = Base64.fromBytes.ErrorType | PublicKey.toHex.ErrorType | Errors.GlobalErrorType;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Deserializes a serialized credential.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts twoslash
|
|
51
|
+
* import { Credential } from 'ox/webauthn'
|
|
52
|
+
*
|
|
53
|
+
* const credential = Credential.deserialize({ // [!code focus]
|
|
54
|
+
* attestationObject: 'o2NmbXRkbm9uZQ...', // [!code focus]
|
|
55
|
+
* clientDataJSON: 'eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0', // [!code focus]
|
|
56
|
+
* id: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', // [!code focus]
|
|
57
|
+
* publicKey: '0x04ab891400140fc4f8e941ce0ff90e419de9470acaca613bbd717a4775435031a7d884318e919fd3b3e5a631d866d8a380b44063e70f0c381ee16e0652f7f97554', // [!code focus]
|
|
58
|
+
* raw: { // [!code focus]
|
|
59
|
+
* id: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', // [!code focus]
|
|
60
|
+
* type: 'public-key', // [!code focus]
|
|
61
|
+
* authenticatorAttachment: 'platform', // [!code focus]
|
|
62
|
+
* rawId: 'm1-bMPuAqpWhCxHZQZTT6e-lSPntQbh3opIoGe7g4Qs', // [!code focus]
|
|
63
|
+
* response: { // [!code focus]
|
|
64
|
+
* clientDataJSON: 'eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0', // [!code focus]
|
|
65
|
+
* }, // [!code focus]
|
|
66
|
+
* }, // [!code focus]
|
|
67
|
+
* }) // [!code focus]
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @param credential - The serialized credential.
|
|
71
|
+
* @returns The deserialized credential.
|
|
72
|
+
*/
|
|
73
|
+
export declare function deserialize(credential: Credential<true>): Credential;
|
|
74
|
+
export declare namespace deserialize {
|
|
75
|
+
type ErrorType = Base64.toBytes.ErrorType | PublicKey.from.ErrorType | Errors.GlobalErrorType;
|
|
76
|
+
}
|
|
77
|
+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