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.
Files changed (128) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/_cjs/core/P256.js +1 -1
  3. package/_cjs/core/P256.js.map +1 -1
  4. package/_cjs/core/WebAuthnP256.js +15 -256
  5. package/_cjs/core/WebAuthnP256.js.map +1 -1
  6. package/_cjs/core/WebCryptoP256.js +3 -1
  7. package/_cjs/core/WebCryptoP256.js.map +1 -1
  8. package/_cjs/core/internal/webauthn.js +5 -13
  9. package/_cjs/core/internal/webauthn.js.map +1 -1
  10. package/_cjs/index.docs.js +1 -0
  11. package/_cjs/index.docs.js.map +1 -1
  12. package/_cjs/tempo/KeyAuthorization.js +18 -3
  13. package/_cjs/tempo/KeyAuthorization.js.map +1 -1
  14. package/_cjs/tempo/SignatureEnvelope.js +26 -0
  15. package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
  16. package/_cjs/tempo/TxEnvelopeTempo.js +5 -10
  17. package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -1
  18. package/_cjs/version.js +1 -1
  19. package/_cjs/webauthn/Authentication.js +246 -0
  20. package/_cjs/webauthn/Authentication.js.map +1 -0
  21. package/_cjs/webauthn/Authenticator.js +55 -0
  22. package/_cjs/webauthn/Authenticator.js.map +1 -0
  23. package/_cjs/webauthn/Credential.js +53 -0
  24. package/_cjs/webauthn/Credential.js.map +1 -0
  25. package/_cjs/webauthn/Registration.js +349 -0
  26. package/_cjs/webauthn/Registration.js.map +1 -0
  27. package/_cjs/webauthn/Types.js +3 -0
  28. package/_cjs/webauthn/Types.js.map +1 -0
  29. package/_cjs/webauthn/index.js +9 -0
  30. package/_cjs/webauthn/index.js.map +1 -0
  31. package/_cjs/webauthn/internal/utils.js +53 -0
  32. package/_cjs/webauthn/internal/utils.js.map +1 -0
  33. package/_esm/core/P256.js +1 -1
  34. package/_esm/core/P256.js.map +1 -1
  35. package/_esm/core/WebAuthnP256.js +13 -261
  36. package/_esm/core/WebAuthnP256.js.map +1 -1
  37. package/_esm/core/WebCryptoP256.js +4 -1
  38. package/_esm/core/WebCryptoP256.js.map +1 -1
  39. package/_esm/core/internal/webauthn.js +5 -13
  40. package/_esm/core/internal/webauthn.js.map +1 -1
  41. package/_esm/erc8021/index.js +2 -2
  42. package/_esm/index.docs.js +1 -0
  43. package/_esm/index.docs.js.map +1 -1
  44. package/_esm/tempo/KeyAuthorization.js +66 -3
  45. package/_esm/tempo/KeyAuthorization.js.map +1 -1
  46. package/_esm/tempo/SignatureEnvelope.js +74 -0
  47. package/_esm/tempo/SignatureEnvelope.js.map +1 -1
  48. package/_esm/tempo/TransactionReceipt.js +1 -1
  49. package/_esm/tempo/TransactionRequest.js +1 -1
  50. package/_esm/tempo/TxEnvelopeTempo.js +5 -10
  51. package/_esm/tempo/TxEnvelopeTempo.js.map +1 -1
  52. package/_esm/version.js +1 -1
  53. package/_esm/webauthn/Authentication.js +453 -0
  54. package/_esm/webauthn/Authentication.js.map +1 -0
  55. package/_esm/webauthn/Authenticator.js +176 -0
  56. package/_esm/webauthn/Authenticator.js.map +1 -0
  57. package/_esm/webauthn/Credential.js +95 -0
  58. package/_esm/webauthn/Credential.js.map +1 -0
  59. package/_esm/webauthn/Registration.js +512 -0
  60. package/_esm/webauthn/Registration.js.map +1 -0
  61. package/_esm/webauthn/Types.js +2 -0
  62. package/_esm/webauthn/Types.js.map +1 -0
  63. package/_esm/webauthn/index.js +31 -0
  64. package/_esm/webauthn/index.js.map +1 -0
  65. package/_esm/webauthn/internal/utils.js +52 -0
  66. package/_esm/webauthn/internal/utils.js.map +1 -0
  67. package/_types/core/WebAuthnP256.d.ts +33 -208
  68. package/_types/core/WebAuthnP256.d.ts.map +1 -1
  69. package/_types/core/WebCryptoP256.d.ts +2 -0
  70. package/_types/core/WebCryptoP256.d.ts.map +1 -1
  71. package/_types/core/internal/webauthn.d.ts +2 -110
  72. package/_types/core/internal/webauthn.d.ts.map +1 -1
  73. package/_types/erc8021/index.d.ts +2 -2
  74. package/_types/index.docs.d.ts +1 -0
  75. package/_types/index.docs.d.ts.map +1 -1
  76. package/_types/tempo/KeyAuthorization.d.ts +57 -0
  77. package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
  78. package/_types/tempo/SignatureEnvelope.d.ts +75 -0
  79. package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
  80. package/_types/tempo/Transaction.d.ts +2 -2
  81. package/_types/tempo/TransactionReceipt.d.ts +2 -2
  82. package/_types/tempo/TransactionRequest.d.ts +2 -2
  83. package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -1
  84. package/_types/version.d.ts +1 -1
  85. package/_types/webauthn/Authentication.d.ts +324 -0
  86. package/_types/webauthn/Authentication.d.ts.map +1 -0
  87. package/_types/webauthn/Authenticator.d.ts +182 -0
  88. package/_types/webauthn/Authenticator.d.ts.map +1 -0
  89. package/_types/webauthn/Credential.d.ts +77 -0
  90. package/_types/webauthn/Credential.d.ts.map +1 -0
  91. package/_types/webauthn/Registration.d.ts +308 -0
  92. package/_types/webauthn/Registration.d.ts.map +1 -0
  93. package/_types/webauthn/Types.d.ts +106 -0
  94. package/_types/webauthn/Types.d.ts.map +1 -0
  95. package/_types/webauthn/index.d.ts +33 -0
  96. package/_types/webauthn/index.d.ts.map +1 -0
  97. package/_types/webauthn/internal/utils.d.ts +17 -0
  98. package/_types/webauthn/internal/utils.d.ts.map +1 -0
  99. package/core/P256.ts +1 -1
  100. package/core/WebAuthnP256.ts +37 -582
  101. package/core/WebCryptoP256.ts +6 -1
  102. package/core/internal/webauthn.ts +6 -165
  103. package/erc8021/index.ts +2 -2
  104. package/index.docs.ts +1 -0
  105. package/package.json +31 -1
  106. package/tempo/KeyAuthorization.test.ts +139 -0
  107. package/tempo/KeyAuthorization.ts +82 -3
  108. package/tempo/SignatureEnvelope.test.ts +147 -0
  109. package/tempo/SignatureEnvelope.ts +113 -0
  110. package/tempo/Transaction.ts +2 -2
  111. package/tempo/TransactionReceipt.ts +2 -2
  112. package/tempo/TransactionRequest.ts +2 -2
  113. package/tempo/TxEnvelopeTempo.ts +5 -12
  114. package/tempo/e2e.test.ts +265 -0
  115. package/version.ts +1 -1
  116. package/webauthn/Authentication/package.json +6 -0
  117. package/webauthn/Authentication.ts +673 -0
  118. package/webauthn/Authenticator/package.json +6 -0
  119. package/webauthn/Authenticator.ts +259 -0
  120. package/webauthn/Credential/package.json +6 -0
  121. package/webauthn/Credential.ts +146 -0
  122. package/webauthn/Registration/package.json +6 -0
  123. package/webauthn/Registration.ts +805 -0
  124. package/webauthn/Types/package.json +6 -0
  125. package/webauthn/Types.ts +158 -0
  126. package/webauthn/index.ts +38 -0
  127. package/webauthn/internal/utils.ts +63 -0
  128. package/webauthn/package.json +6 -0
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../../_types/webauthn/Types.d.ts",
4
+ "main": "../../_cjs/webauthn/Types.js",
5
+ "module": "../../_esm/webauthn/Types.js"
6
+ }
@@ -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
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../_types/webauthn/index.d.ts",
4
+ "main": "../_cjs/webauthn/index.js",
5
+ "module": "../_esm/webauthn/index.js"
6
+ }