ox 0.12.4 → 0.13.1
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 +21 -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/KeyAuthorization.js +18 -3
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/SignatureEnvelope.js +26 -0
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
- package/_cjs/tempo/TxEnvelopeTempo.js +5 -10
- 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/KeyAuthorization.js +66 -3
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/SignatureEnvelope.js +74 -0
- package/_esm/tempo/SignatureEnvelope.js.map +1 -1
- package/_esm/tempo/TransactionReceipt.js +1 -1
- package/_esm/tempo/TransactionRequest.js +1 -1
- package/_esm/tempo/TxEnvelopeTempo.js +5 -10
- 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/KeyAuthorization.d.ts +57 -0
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/SignatureEnvelope.d.ts +75 -0
- package/_types/tempo/SignatureEnvelope.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/KeyAuthorization.test.ts +139 -0
- package/tempo/KeyAuthorization.ts +82 -3
- package/tempo/SignatureEnvelope.test.ts +147 -0
- package/tempo/SignatureEnvelope.ts +113 -0
- package/tempo/Transaction.ts +2 -2
- package/tempo/TransactionReceipt.ts +2 -2
- package/tempo/TransactionRequest.ts +2 -2
- package/tempo/TxEnvelopeTempo.ts +5 -12
- package/tempo/e2e.test.ts +265 -0
- 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
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type * as Hex from '../core/Hex.js'
|
|
2
|
+
|
|
3
|
+
export type AttestationConveyancePreference =
|
|
4
|
+
| 'direct'
|
|
5
|
+
| 'enterprise'
|
|
6
|
+
| 'indirect'
|
|
7
|
+
| 'none'
|
|
8
|
+
|
|
9
|
+
export type AuthenticatorAttachment = 'cross-platform' | 'platform'
|
|
10
|
+
|
|
11
|
+
export type AuthenticatorTransport =
|
|
12
|
+
| 'ble'
|
|
13
|
+
| 'hybrid'
|
|
14
|
+
| 'internal'
|
|
15
|
+
| 'nfc'
|
|
16
|
+
| 'usb'
|
|
17
|
+
|
|
18
|
+
export type COSEAlgorithmIdentifier = number
|
|
19
|
+
|
|
20
|
+
export type CredentialMediationRequirement =
|
|
21
|
+
| 'conditional'
|
|
22
|
+
| 'optional'
|
|
23
|
+
| 'required'
|
|
24
|
+
| 'silent'
|
|
25
|
+
|
|
26
|
+
export type PublicKeyCredentialType = 'public-key'
|
|
27
|
+
|
|
28
|
+
export type ResidentKeyRequirement = 'discouraged' | 'preferred' | 'required'
|
|
29
|
+
|
|
30
|
+
export type UserVerificationRequirement =
|
|
31
|
+
| 'discouraged'
|
|
32
|
+
| 'preferred'
|
|
33
|
+
| 'required'
|
|
34
|
+
|
|
35
|
+
export type LargeBlobSupport = {
|
|
36
|
+
support: 'required' | 'preferred'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type BufferSource = ArrayBufferView | ArrayBuffer
|
|
40
|
+
|
|
41
|
+
export type PrfExtension = Record<'eval', Record<'first', Uint8Array>>
|
|
42
|
+
|
|
43
|
+
export interface AuthenticationExtensionsClientInputs<
|
|
44
|
+
serialized extends boolean = false,
|
|
45
|
+
> {
|
|
46
|
+
appid?: string
|
|
47
|
+
credProps?: boolean
|
|
48
|
+
hmacCreateSecret?: boolean
|
|
49
|
+
minPinLength?: boolean
|
|
50
|
+
prf?: serialized extends true ? { eval: { first: string } } : PrfExtension
|
|
51
|
+
largeBlob?: LargeBlobSupport
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface AuthenticatorSelectionCriteria {
|
|
55
|
+
authenticatorAttachment?: AuthenticatorAttachment
|
|
56
|
+
requireResidentKey?: boolean
|
|
57
|
+
residentKey?: ResidentKeyRequirement
|
|
58
|
+
userVerification?: UserVerificationRequirement
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Available only in secure contexts.
|
|
63
|
+
*
|
|
64
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse)
|
|
65
|
+
*/
|
|
66
|
+
export interface AuthenticatorAttestationResponse<
|
|
67
|
+
serialized extends boolean = false,
|
|
68
|
+
> extends AuthenticatorResponse<serialized> {
|
|
69
|
+
readonly attestationObject: serialized extends true ? string : ArrayBuffer
|
|
70
|
+
getAuthenticatorData(): ArrayBuffer
|
|
71
|
+
getPublicKey(): ArrayBuffer | null
|
|
72
|
+
getPublicKeyAlgorithm(): COSEAlgorithmIdentifier
|
|
73
|
+
getTransports(): string[]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface AuthenticatorResponse<serialized extends boolean = false> {
|
|
77
|
+
readonly clientDataJSON: serialized extends true ? string : ArrayBuffer
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface Credential {
|
|
81
|
+
readonly id: string
|
|
82
|
+
readonly type: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface CredentialCreationOptions<serialized extends boolean = false> {
|
|
86
|
+
publicKey?: PublicKeyCredentialCreationOptions<serialized>
|
|
87
|
+
signal?: AbortSignal
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface CredentialRequestOptions<serialized extends boolean = false> {
|
|
91
|
+
mediation?: CredentialMediationRequirement
|
|
92
|
+
publicKey?: PublicKeyCredentialRequestOptions<serialized>
|
|
93
|
+
signal?: AbortSignal
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type PublicKeyCredential<serialized extends boolean = false> =
|
|
97
|
+
Credential & {
|
|
98
|
+
readonly authenticatorAttachment: string | null
|
|
99
|
+
readonly rawId: serialized extends true ? string : ArrayBuffer
|
|
100
|
+
readonly response: AuthenticatorResponse<serialized>
|
|
101
|
+
} & (serialized extends true
|
|
102
|
+
? {}
|
|
103
|
+
: {
|
|
104
|
+
getClientExtensionResults(): AuthenticationExtensionsClientOutputs
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
export interface PublicKeyCredentialCreationOptions<
|
|
108
|
+
serialized extends boolean = false,
|
|
109
|
+
> {
|
|
110
|
+
attestation?: AttestationConveyancePreference
|
|
111
|
+
authenticatorSelection?: AuthenticatorSelectionCriteria
|
|
112
|
+
challenge: serialized extends true ? Hex.Hex : BufferSource
|
|
113
|
+
excludeCredentials?: PublicKeyCredentialDescriptor<serialized>[]
|
|
114
|
+
extensions?: AuthenticationExtensionsClientInputs<serialized>
|
|
115
|
+
pubKeyCredParams: PublicKeyCredentialParameters[]
|
|
116
|
+
rp: PublicKeyCredentialRpEntity
|
|
117
|
+
timeout?: number
|
|
118
|
+
user: PublicKeyCredentialUserEntity<serialized>
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface PublicKeyCredentialDescriptor<
|
|
122
|
+
serialized extends boolean = false,
|
|
123
|
+
> {
|
|
124
|
+
id: serialized extends true ? string : BufferSource
|
|
125
|
+
transports?: AuthenticatorTransport[]
|
|
126
|
+
type: PublicKeyCredentialType
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface PublicKeyCredentialEntity {
|
|
130
|
+
name: string
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface PublicKeyCredentialParameters {
|
|
134
|
+
alg: COSEAlgorithmIdentifier
|
|
135
|
+
type: PublicKeyCredentialType
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface PublicKeyCredentialRequestOptions<
|
|
139
|
+
serialized extends boolean = false,
|
|
140
|
+
> {
|
|
141
|
+
allowCredentials?: PublicKeyCredentialDescriptor<serialized>[]
|
|
142
|
+
challenge: serialized extends true ? Hex.Hex : BufferSource
|
|
143
|
+
extensions?: AuthenticationExtensionsClientInputs<serialized>
|
|
144
|
+
rpId?: string
|
|
145
|
+
timeout?: number
|
|
146
|
+
userVerification?: UserVerificationRequirement
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface PublicKeyCredentialRpEntity extends PublicKeyCredentialEntity {
|
|
150
|
+
id: string
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface PublicKeyCredentialUserEntity<
|
|
154
|
+
serialized extends boolean = false,
|
|
155
|
+
> extends PublicKeyCredentialEntity {
|
|
156
|
+
displayName: string
|
|
157
|
+
id: serialized extends true ? string : BufferSource
|
|
158
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** @entrypointCategory WebAuthn */
|
|
2
|
+
// biome-ignore lint/complexity/noUselessEmptyExport: tsdoc
|
|
3
|
+
export type {}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Utility functions and types for WebAuthn authentication ceremonies (signing and verification).
|
|
7
|
+
*
|
|
8
|
+
* @category WebAuthn
|
|
9
|
+
*/
|
|
10
|
+
export * as Authentication from './Authentication.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Utility functions for constructing and parsing authenticator data and client data JSON.
|
|
14
|
+
*
|
|
15
|
+
* @category WebAuthn
|
|
16
|
+
*/
|
|
17
|
+
export * as Authenticator from './Authenticator.js'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Utility functions and types for WebAuthn P256 credentials.
|
|
21
|
+
*
|
|
22
|
+
* @category WebAuthn
|
|
23
|
+
*/
|
|
24
|
+
export * as Credential from './Credential.js'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Utility functions and types for WebAuthn registration ceremonies (credential creation and verification).
|
|
28
|
+
*
|
|
29
|
+
* @category WebAuthn
|
|
30
|
+
*/
|
|
31
|
+
export * as Registration from './Registration.js'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* WebAuthn type definitions.
|
|
35
|
+
*
|
|
36
|
+
* @category WebAuthn
|
|
37
|
+
*/
|
|
38
|
+
export * as Types from './Types.js'
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as Base64 from '../../core/Base64.js'
|
|
2
|
+
import type * as Types from '../Types.js'
|
|
3
|
+
|
|
4
|
+
/** @internal */
|
|
5
|
+
export const base64UrlOptions = { url: true, pad: false } as const
|
|
6
|
+
|
|
7
|
+
/** @internal */
|
|
8
|
+
export const responseKeys = [
|
|
9
|
+
'attestationObject',
|
|
10
|
+
'authenticatorData',
|
|
11
|
+
'clientDataJSON',
|
|
12
|
+
'signature',
|
|
13
|
+
'userHandle',
|
|
14
|
+
] as const
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export function bytesToArrayBuffer(bytes: Uint8Array): ArrayBuffer {
|
|
18
|
+
return bytes.buffer.slice(
|
|
19
|
+
bytes.byteOffset,
|
|
20
|
+
bytes.byteOffset + bytes.byteLength,
|
|
21
|
+
) as ArrayBuffer
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** @internal */
|
|
25
|
+
export function bufferSourceToBytes(source: Types.BufferSource): Uint8Array {
|
|
26
|
+
if (source instanceof Uint8Array) return source
|
|
27
|
+
if (source instanceof ArrayBuffer) return new Uint8Array(source)
|
|
28
|
+
return new Uint8Array(source.buffer, source.byteOffset, source.byteLength)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @internal */
|
|
32
|
+
export function serializeExtensions(
|
|
33
|
+
extensions: Types.AuthenticationExtensionsClientInputs,
|
|
34
|
+
): Types.AuthenticationExtensionsClientInputs<true> {
|
|
35
|
+
const { prf, ...rest } = extensions
|
|
36
|
+
return {
|
|
37
|
+
...rest,
|
|
38
|
+
...(prf && {
|
|
39
|
+
prf: {
|
|
40
|
+
eval: {
|
|
41
|
+
first: Base64.fromBytes(prf.eval.first, base64UrlOptions),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** @internal */
|
|
49
|
+
export function deserializeExtensions(
|
|
50
|
+
extensions: Types.AuthenticationExtensionsClientInputs<true>,
|
|
51
|
+
): Types.AuthenticationExtensionsClientInputs {
|
|
52
|
+
const { prf, ...rest } = extensions
|
|
53
|
+
return {
|
|
54
|
+
...rest,
|
|
55
|
+
...(prf && {
|
|
56
|
+
prf: {
|
|
57
|
+
eval: {
|
|
58
|
+
first: Base64.toBytes(prf.eval.first),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
}
|
|
63
|
+
}
|