@veridex/sdk 1.1.5 → 1.1.7

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 (102) hide show
  1. package/dist/{EVMClient-Bmy9czkE.d.mts → EVMClient-DqDiFak8.d.mts} +1 -1
  2. package/dist/auth/prepareAuth.d.mts +5 -4
  3. package/dist/auth/prepareAuth.js +143 -1422
  4. package/dist/auth/prepareAuth.js.map +1 -1
  5. package/dist/auth/prepareAuth.mjs +17 -96
  6. package/dist/auth/prepareAuth.mjs.map +1 -1
  7. package/dist/chains/aptos/index.d.mts +1 -1
  8. package/dist/chains/aptos/index.js +11 -33
  9. package/dist/chains/aptos/index.js.map +1 -1
  10. package/dist/chains/aptos/index.mjs +2 -2
  11. package/dist/chains/avalanche/index.d.mts +2 -2
  12. package/dist/chains/avalanche/index.js +19 -115
  13. package/dist/chains/avalanche/index.js.map +1 -1
  14. package/dist/chains/avalanche/index.mjs +3 -3
  15. package/dist/chains/evm/index.d.mts +5 -4
  16. package/dist/chains/evm/index.js +19 -115
  17. package/dist/chains/evm/index.js.map +1 -1
  18. package/dist/chains/evm/index.mjs +2 -2
  19. package/dist/chains/solana/index.d.mts +1 -1
  20. package/dist/chains/solana/index.js +11 -33
  21. package/dist/chains/solana/index.js.map +1 -1
  22. package/dist/chains/solana/index.mjs +2 -2
  23. package/dist/chains/stacks/index.d.mts +1 -1
  24. package/dist/chains/stacks/index.js +11 -38
  25. package/dist/chains/stacks/index.js.map +1 -1
  26. package/dist/chains/stacks/index.mjs +2 -2
  27. package/dist/chains/starknet/index.d.mts +36 -2
  28. package/dist/chains/starknet/index.js +208 -37
  29. package/dist/chains/starknet/index.js.map +1 -1
  30. package/dist/chains/starknet/index.mjs +9 -4
  31. package/dist/chains/stellar/index.d.mts +2 -1
  32. package/dist/chains/sui/index.d.mts +1 -1
  33. package/dist/chains/sui/index.js +11 -27
  34. package/dist/chains/sui/index.js.map +1 -1
  35. package/dist/chains/sui/index.mjs +2 -2
  36. package/dist/{chunk-ZNIVNPGF.mjs → chunk-3PCAVZUZ.mjs} +173 -37
  37. package/dist/chunk-3PCAVZUZ.mjs.map +1 -0
  38. package/dist/{chunk-DQOW3G7M.mjs → chunk-6BINP4RT.mjs} +48 -9
  39. package/dist/{chunk-DQOW3G7M.mjs.map → chunk-6BINP4RT.mjs.map} +1 -1
  40. package/dist/{chunk-7KN6Y4GX.mjs → chunk-AK5HWYX4.mjs} +12 -40
  41. package/dist/chunk-AK5HWYX4.mjs.map +1 -0
  42. package/dist/{chunk-QVTADARB.mjs → chunk-FPSCAGYS.mjs} +12 -35
  43. package/dist/chunk-FPSCAGYS.mjs.map +1 -0
  44. package/dist/{chunk-USVZH4QC.mjs → chunk-H3WRT6Y4.mjs} +20 -117
  45. package/dist/chunk-H3WRT6Y4.mjs.map +1 -0
  46. package/dist/{chunk-GXJUY2SC.mjs → chunk-MNH22BM2.mjs} +12 -35
  47. package/dist/chunk-MNH22BM2.mjs.map +1 -0
  48. package/dist/chunk-N42LPFPJ.mjs +177 -0
  49. package/dist/chunk-N42LPFPJ.mjs.map +1 -0
  50. package/dist/{chunk-D57UJ4L5.mjs → chunk-NKSRF45N.mjs} +12 -29
  51. package/dist/chunk-NKSRF45N.mjs.map +1 -0
  52. package/dist/{chunk-BJH5HJL5.mjs → chunk-SKZLZFE2.mjs} +91 -65
  53. package/dist/chunk-SKZLZFE2.mjs.map +1 -0
  54. package/dist/{chunk-NVRAQPSF.mjs → chunk-UF5NWMSQ.mjs} +20 -4
  55. package/dist/chunk-UF5NWMSQ.mjs.map +1 -0
  56. package/dist/chunk-WC4X3MAO.mjs +58 -0
  57. package/dist/chunk-WC4X3MAO.mjs.map +1 -0
  58. package/dist/{chunk-5FH67KLG.mjs → chunk-XHDOSV2F.mjs} +2 -2
  59. package/dist/{index-CKKUV4J7.d.mts → index-D1nb2JV9.d.mts} +2 -2
  60. package/dist/index-qyOqd8tx.d.mts +517 -0
  61. package/dist/index.d.mts +30 -366
  62. package/dist/index.js +2412 -2486
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +986 -55
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/passkey-fh8bo2w-.d.mts +241 -0
  67. package/dist/passkey.d.mts +2 -182
  68. package/dist/passkey.js +86 -7
  69. package/dist/passkey.js.map +1 -1
  70. package/dist/passkey.mjs +2 -1
  71. package/dist/payload.d.mts +22 -28
  72. package/dist/payload.js +50 -9
  73. package/dist/payload.js.map +1 -1
  74. package/dist/payload.mjs +7 -3
  75. package/dist/platform/index.d.mts +3 -0
  76. package/dist/platform/index.js +216 -0
  77. package/dist/platform/index.js.map +1 -0
  78. package/dist/platform/index.mjs +21 -0
  79. package/dist/platform/index.mjs.map +1 -0
  80. package/dist/{portfolio-W2FQ2G3O.mjs → portfolio-MLP2JIFK.mjs} +2 -3
  81. package/dist/queries/index.mjs +324 -10
  82. package/dist/queries/index.mjs.map +1 -1
  83. package/dist/{types-DP2CQT8p.d.mts → types-CdlEbixV.d.mts} +12 -1
  84. package/dist/types.d.mts +1 -0
  85. package/dist/types.js.map +1 -1
  86. package/package.json +7 -1
  87. package/dist/chunk-72ZA3OYQ.mjs +0 -20
  88. package/dist/chunk-72ZA3OYQ.mjs.map +0 -1
  89. package/dist/chunk-7KN6Y4GX.mjs.map +0 -1
  90. package/dist/chunk-BJH5HJL5.mjs.map +0 -1
  91. package/dist/chunk-D57UJ4L5.mjs.map +0 -1
  92. package/dist/chunk-GXJUY2SC.mjs.map +0 -1
  93. package/dist/chunk-NVRAQPSF.mjs.map +0 -1
  94. package/dist/chunk-QVTADARB.mjs.map +0 -1
  95. package/dist/chunk-USVZH4QC.mjs.map +0 -1
  96. package/dist/chunk-XDIIFIW6.mjs +0 -330
  97. package/dist/chunk-XDIIFIW6.mjs.map +0 -1
  98. package/dist/chunk-ZNIVNPGF.mjs.map +0 -1
  99. package/dist/chunk-ZXMTPBSP.mjs +0 -857
  100. package/dist/chunk-ZXMTPBSP.mjs.map +0 -1
  101. /package/dist/{chunk-5FH67KLG.mjs.map → chunk-XHDOSV2F.mjs.map} +0 -0
  102. /package/dist/{portfolio-W2FQ2G3O.mjs.map → portfolio-MLP2JIFK.mjs.map} +0 -0
@@ -0,0 +1,241 @@
1
+ import { RegistrationResponseJSON } from '@simplewebauthn/types';
2
+
3
+ /**
4
+ * Veridex Protocol SDK - Passkey Manager
5
+ *
6
+ * Chain-agnostic WebAuthn/Passkey credential management
7
+ */
8
+
9
+ /**
10
+ * Assurance tier of a credential, derived from the authoritative WebAuthn
11
+ * Backup Eligibility (BE) flag — not from a platform guess.
12
+ *
13
+ * - `device-bound`: BE=0. The private key cannot leave the authenticator
14
+ * (secure element, or a hardware key such as a YubiKey). Not recoverable.
15
+ * - `synced`: BE=1. The credential is eligible for sync/backup by a provider
16
+ * (iCloud Keychain, Google Password Manager, Windows Hello). Recoverable via
17
+ * the user's platform account — which its security therefore depends on.
18
+ * - `unknown`: flags were not determinable from the registration response.
19
+ */
20
+ type CredentialAssuranceLevel = 'device-bound' | 'synced' | 'unknown';
21
+ /** WebAuthn-derived assurance metadata for a credential. */
22
+ interface CredentialAssurance {
23
+ /** BE flag (0x08) — credential may be backed up / synced by a provider. */
24
+ backupEligible: boolean;
25
+ /** BS flag (0x10) — credential is currently backed up / synced. */
26
+ backupState: boolean;
27
+ /** UV flag (0x04) — user was verified (biometric/PIN) at registration. */
28
+ userVerified: boolean;
29
+ /** Tier derived from BE. Consumed by the policy engine to gate authority. */
30
+ level: CredentialAssuranceLevel;
31
+ /** Authenticator model identifier (16-byte AAGUID, hex). Zeroed by many platform authenticators. */
32
+ aaguid?: string;
33
+ }
34
+ interface PasskeyCredential {
35
+ credentialId: string;
36
+ publicKeyX: bigint;
37
+ publicKeyY: bigint;
38
+ keyHash: string;
39
+ /**
40
+ * Authoritative assurance derived from the WebAuthn authenticator data.
41
+ * Optional for backward compatibility with credentials constructed from
42
+ * stored fields (e.g. env vars) that predate assurance capture.
43
+ */
44
+ assurance?: CredentialAssurance;
45
+ }
46
+ interface WebAuthnSignature {
47
+ authenticatorData: string;
48
+ clientDataJSON: string;
49
+ challengeIndex: number;
50
+ typeIndex: number;
51
+ r: bigint;
52
+ s: bigint;
53
+ }
54
+ interface PasskeyManagerConfig {
55
+ rpName?: string;
56
+ rpId?: string;
57
+ timeout?: number;
58
+ userVerification?: 'required' | 'preferred' | 'discouraged';
59
+ authenticatorAttachment?: 'platform' | 'cross-platform';
60
+ /** Relayer API URL for cross-device credential recovery */
61
+ relayerUrl?: string;
62
+ }
63
+ /**
64
+ * The canonical Veridex RP ID for cross-domain passkey sharing.
65
+ * All Veridex SDK instances should use this RP ID to enable passkey
66
+ * portability across different applications and domains.
67
+ *
68
+ * This works via W3C Related Origin Requests (ROR) - veridex.network
69
+ * hosts a .well-known/webauthn file that lists allowed origins.
70
+ */
71
+ declare const VERIDEX_RP_ID = "veridex.network";
72
+ /**
73
+ * Detects the appropriate RP ID for passkey sharing.
74
+ *
75
+ * For production: Returns VERIDEX_RP_ID ('veridex.network') to enable
76
+ * cross-domain passkey sharing via Related Origin Requests (ROR).
77
+ *
78
+ * For local development:
79
+ * - localhost/127.0.0.1 → returns as-is
80
+ * - IP addresses → returns as-is
81
+ *
82
+ * @param forceLocal - If true, uses local domain detection instead of canonical RP ID
83
+ */
84
+ declare function detectRpId(forceLocal?: boolean): string;
85
+ /**
86
+ * Check if the browser supports Related Origin Requests (ROR).
87
+ * This is a WebAuthn Level 3 feature that allows using passkeys
88
+ * across different domains listed in the RP's .well-known/webauthn file.
89
+ *
90
+ * @returns true if ROR is supported, false otherwise
91
+ */
92
+ declare function supportsRelatedOrigins(): Promise<boolean>;
93
+
94
+ /**
95
+ * Manages WebAuthn passkey credentials for Veridex Protocol
96
+ */
97
+ declare class PasskeyManager {
98
+ private config;
99
+ private credential;
100
+ constructor(config?: PasskeyManagerConfig);
101
+ static isSupported(): boolean;
102
+ static isPlatformAuthenticatorAvailable(): Promise<boolean>;
103
+ register(username: string, displayName: string): Promise<PasskeyCredential>;
104
+ sign(challenge: Uint8Array): Promise<WebAuthnSignature>;
105
+ /**
106
+ * Authenticate using a discoverable credential (passkey)
107
+ * This allows sign-in without knowing the credential ID ahead of time.
108
+ * The authenticator will show all available passkeys for this RP.
109
+ *
110
+ * @param challenge - Optional challenge bytes. If not provided, a random challenge is used.
111
+ * @returns The credential that was used to authenticate, along with the signature
112
+ */
113
+ authenticate(challenge?: Uint8Array): Promise<{
114
+ credential: PasskeyCredential;
115
+ signature: WebAuthnSignature;
116
+ }>;
117
+ /**
118
+ * Find a credential by ID in the list of stored credentials
119
+ */
120
+ private findCredentialById;
121
+ /**
122
+ * Get all credentials stored in localStorage
123
+ */
124
+ getAllStoredCredentials(key?: string): PasskeyCredential[];
125
+ private parseStoredCredential;
126
+ /**
127
+ * Save a list of credentials to localStorage
128
+ */
129
+ saveCredentials(credentials: PasskeyCredential[], key?: string): void;
130
+ /**
131
+ * Add a single credential to storage (append or update)
132
+ */
133
+ addCredentialToStorage(credential: PasskeyCredential, key?: string): void;
134
+ /**
135
+ * Check if there's ANY stored credential for this RP
136
+ */
137
+ hasStoredCredential(): boolean;
138
+ getCredential(): PasskeyCredential | null;
139
+ setCredential(credential: PasskeyCredential): void;
140
+ createCredentialFromPublicKey(credentialId: string, publicKeyX: bigint, publicKeyY: bigint): PasskeyCredential;
141
+ clearCredential(): void;
142
+ /**
143
+ * Save the current credential to localStorage (appends to list)
144
+ */
145
+ saveToLocalStorage(key?: string): void;
146
+ loadFromLocalStorage(key?: string): PasskeyCredential | null;
147
+ removeFromLocalStorage(key?: string): void;
148
+ /**
149
+ * Save the current credential to the relayer for cross-device recovery.
150
+ * This should be called after registration.
151
+ */
152
+ saveCredentialToRelayer(): Promise<boolean>;
153
+ /**
154
+ * Load a credential from the relayer by credential ID.
155
+ * Used during discoverable credential authentication when localStorage is empty.
156
+ */
157
+ loadCredentialFromRelayer(credentialId: string): Promise<PasskeyCredential | null>;
158
+ /**
159
+ * Load a credential from the relayer by keyHash.
160
+ * Useful when you know the user's keyHash but not their credential ID.
161
+ */
162
+ loadCredentialFromRelayerByKeyHash(keyHash: string): Promise<PasskeyCredential | null>;
163
+ /**
164
+ * Register a backup passkey for the current identity.
165
+ *
166
+ * This creates a new WebAuthn credential on this device/platform that becomes
167
+ * an additional authorized key for the same Veridex identity. The caller
168
+ * must submit the returned credential to VeridexHub.addKey() for on-chain registration.
169
+ *
170
+ * Use cases:
171
+ * - "Add this device" flow when signing in on a new machine
172
+ * - Proactive backup creation on a separate authenticator
173
+ * - Cross-ecosystem redundancy (iCloud + Google Password Manager)
174
+ *
175
+ * @param username - Username for the new credential (typically same as primary)
176
+ * @param displayName - Display name for the backup (e.g., "MacBook Pro Backup")
177
+ * @param excludeCredentialIds - Credential IDs to exclude (prevents re-registering same authenticator)
178
+ * @returns The newly registered backup credential
179
+ */
180
+ registerBackupPasskey(username: string, displayName: string, excludeCredentialIds?: string[]): Promise<PasskeyCredential>;
181
+ /**
182
+ * Get registration info for backup state from a registration response.
183
+ *
184
+ * This extracts the backup eligibility (BE) and backup state (BS) flags
185
+ * from the authenticator data, which indicate whether the credential
186
+ * is eligible for cloud sync and whether it is currently synced.
187
+ *
188
+ * @param authenticatorData - Hex-encoded authenticator data from registration
189
+ * @returns Backup flags, or null if not determinable
190
+ */
191
+ static parseBackupFlags(authenticatorData: string): {
192
+ backupEligible: boolean;
193
+ backupState: boolean;
194
+ } | null;
195
+ /**
196
+ * Derive credential assurance from raw WebAuthn authenticator data.
197
+ *
198
+ * authData layout:
199
+ * rpIdHash (32) | flags (1) | signCount (4) | [attestedCredentialData: aaguid (16) | ...]
200
+ *
201
+ * Flags byte: UP 0x01 | UV 0x04 | BE 0x08 | BS 0x10 | AT 0x40 | ED 0x80
202
+ *
203
+ * BE is the authoritative signal for whether a credential is device-bound or
204
+ * syncable. It is set by the authenticator itself — unlike a platform/user-agent
205
+ * guess, it correctly identifies a hardware key used on a syncing platform.
206
+ *
207
+ * @returns Assurance, or `null` if authData is too short to be valid.
208
+ */
209
+ static deriveAssurance(authData: Uint8Array): CredentialAssurance | null;
210
+ /**
211
+ * Extract raw authenticator data from a registration response.
212
+ *
213
+ * Prefers the `authenticatorData` field when the authenticator provides it,
214
+ * and otherwise locates the `authData` byte string inside the CBOR
215
+ * attestation object.
216
+ */
217
+ private static extractAuthData;
218
+ /** Derive assurance directly from a registration response. */
219
+ static assuranceFromRegistration(response: RegistrationResponseJSON): CredentialAssurance | null;
220
+ /**
221
+ * Get the number of credentials stored locally.
222
+ */
223
+ getStoredCredentialCount(): number;
224
+ /**
225
+ * Get all credential IDs stored locally (for exclude lists).
226
+ */
227
+ getStoredCredentialIds(): string[];
228
+ private extractPublicKeyFromAttestation;
229
+ private parseCOSEKey;
230
+ private tryParseCOSEKeyStrategies;
231
+ private parseCOSEKeyWithCBORStructure;
232
+ private tryParseASN1Structure;
233
+ private find32ByteSequences;
234
+ private isValidCoordinate;
235
+ private bytesToBigInt;
236
+ private bytesToHex;
237
+ private analyzeCOSEStructure;
238
+ private parseAuthenticationResponse;
239
+ }
240
+
241
+ export { type CredentialAssurance as C, PasskeyManager as P, VERIDEX_RP_ID as V, type WebAuthnSignature as W, type PasskeyCredential as a, type PasskeyManagerConfig as b, type CredentialAssuranceLevel as c, detectRpId as d, supportsRelatedOrigins as s };
@@ -1,182 +1,2 @@
1
- /**
2
- * Veridex Protocol SDK - Passkey Manager
3
- *
4
- * Chain-agnostic WebAuthn/Passkey credential management
5
- */
6
- interface PasskeyCredential {
7
- credentialId: string;
8
- publicKeyX: bigint;
9
- publicKeyY: bigint;
10
- keyHash: string;
11
- }
12
- interface WebAuthnSignature {
13
- authenticatorData: string;
14
- clientDataJSON: string;
15
- challengeIndex: number;
16
- typeIndex: number;
17
- r: bigint;
18
- s: bigint;
19
- }
20
- interface PasskeyManagerConfig {
21
- rpName?: string;
22
- rpId?: string;
23
- timeout?: number;
24
- userVerification?: 'required' | 'preferred' | 'discouraged';
25
- authenticatorAttachment?: 'platform' | 'cross-platform';
26
- /** Relayer API URL for cross-device credential recovery */
27
- relayerUrl?: string;
28
- }
29
- /**
30
- * The canonical Veridex RP ID for cross-domain passkey sharing.
31
- * All Veridex SDK instances should use this RP ID to enable passkey
32
- * portability across different applications and domains.
33
- *
34
- * This works via W3C Related Origin Requests (ROR) - veridex.network
35
- * hosts a .well-known/webauthn file that lists allowed origins.
36
- */
37
- declare const VERIDEX_RP_ID = "veridex.network";
38
- /**
39
- * Detects the appropriate RP ID for passkey sharing.
40
- *
41
- * For production: Returns VERIDEX_RP_ID ('veridex.network') to enable
42
- * cross-domain passkey sharing via Related Origin Requests (ROR).
43
- *
44
- * For local development:
45
- * - localhost/127.0.0.1 → returns as-is
46
- * - IP addresses → returns as-is
47
- *
48
- * @param forceLocal - If true, uses local domain detection instead of canonical RP ID
49
- */
50
- declare function detectRpId(forceLocal?: boolean): string;
51
- /**
52
- * Check if the browser supports Related Origin Requests (ROR).
53
- * This is a WebAuthn Level 3 feature that allows using passkeys
54
- * across different domains listed in the RP's .well-known/webauthn file.
55
- *
56
- * @returns true if ROR is supported, false otherwise
57
- */
58
- declare function supportsRelatedOrigins(): Promise<boolean>;
59
-
60
- /**
61
- * Manages WebAuthn passkey credentials for Veridex Protocol
62
- */
63
- declare class PasskeyManager {
64
- private config;
65
- private credential;
66
- constructor(config?: PasskeyManagerConfig);
67
- static isSupported(): boolean;
68
- static isPlatformAuthenticatorAvailable(): Promise<boolean>;
69
- register(username: string, displayName: string): Promise<PasskeyCredential>;
70
- sign(challenge: Uint8Array): Promise<WebAuthnSignature>;
71
- /**
72
- * Authenticate using a discoverable credential (passkey)
73
- * This allows sign-in without knowing the credential ID ahead of time.
74
- * The authenticator will show all available passkeys for this RP.
75
- *
76
- * @param challenge - Optional challenge bytes. If not provided, a random challenge is used.
77
- * @returns The credential that was used to authenticate, along with the signature
78
- */
79
- authenticate(challenge?: Uint8Array): Promise<{
80
- credential: PasskeyCredential;
81
- signature: WebAuthnSignature;
82
- }>;
83
- /**
84
- * Find a credential by ID in the list of stored credentials
85
- */
86
- private findCredentialById;
87
- /**
88
- * Get all credentials stored in localStorage
89
- */
90
- getAllStoredCredentials(key?: string): PasskeyCredential[];
91
- private parseStoredCredential;
92
- /**
93
- * Save a list of credentials to localStorage
94
- */
95
- saveCredentials(credentials: PasskeyCredential[], key?: string): void;
96
- /**
97
- * Add a single credential to storage (append or update)
98
- */
99
- addCredentialToStorage(credential: PasskeyCredential, key?: string): void;
100
- /**
101
- * Check if there's ANY stored credential for this RP
102
- */
103
- hasStoredCredential(): boolean;
104
- getCredential(): PasskeyCredential | null;
105
- setCredential(credential: PasskeyCredential): void;
106
- createCredentialFromPublicKey(credentialId: string, publicKeyX: bigint, publicKeyY: bigint): PasskeyCredential;
107
- clearCredential(): void;
108
- /**
109
- * Save the current credential to localStorage (appends to list)
110
- */
111
- saveToLocalStorage(key?: string): void;
112
- loadFromLocalStorage(key?: string): PasskeyCredential | null;
113
- removeFromLocalStorage(key?: string): void;
114
- /**
115
- * Save the current credential to the relayer for cross-device recovery.
116
- * This should be called after registration.
117
- */
118
- saveCredentialToRelayer(): Promise<boolean>;
119
- /**
120
- * Load a credential from the relayer by credential ID.
121
- * Used during discoverable credential authentication when localStorage is empty.
122
- */
123
- loadCredentialFromRelayer(credentialId: string): Promise<PasskeyCredential | null>;
124
- /**
125
- * Load a credential from the relayer by keyHash.
126
- * Useful when you know the user's keyHash but not their credential ID.
127
- */
128
- loadCredentialFromRelayerByKeyHash(keyHash: string): Promise<PasskeyCredential | null>;
129
- /**
130
- * Register a backup passkey for the current identity.
131
- *
132
- * This creates a new WebAuthn credential on this device/platform that becomes
133
- * an additional authorized key for the same Veridex identity. The caller
134
- * must submit the returned credential to VeridexHub.addKey() for on-chain registration.
135
- *
136
- * Use cases:
137
- * - "Add this device" flow when signing in on a new machine
138
- * - Proactive backup creation on a separate authenticator
139
- * - Cross-ecosystem redundancy (iCloud + Google Password Manager)
140
- *
141
- * @param username - Username for the new credential (typically same as primary)
142
- * @param displayName - Display name for the backup (e.g., "MacBook Pro Backup")
143
- * @param excludeCredentialIds - Credential IDs to exclude (prevents re-registering same authenticator)
144
- * @returns The newly registered backup credential
145
- */
146
- registerBackupPasskey(username: string, displayName: string, excludeCredentialIds?: string[]): Promise<PasskeyCredential>;
147
- /**
148
- * Get registration info for backup state from a registration response.
149
- *
150
- * This extracts the backup eligibility (BE) and backup state (BS) flags
151
- * from the authenticator data, which indicate whether the credential
152
- * is eligible for cloud sync and whether it is currently synced.
153
- *
154
- * @param authenticatorData - Hex-encoded authenticator data from registration
155
- * @returns Backup flags, or null if not determinable
156
- */
157
- static parseBackupFlags(authenticatorData: string): {
158
- backupEligible: boolean;
159
- backupState: boolean;
160
- } | null;
161
- /**
162
- * Get the number of credentials stored locally.
163
- */
164
- getStoredCredentialCount(): number;
165
- /**
166
- * Get all credential IDs stored locally (for exclude lists).
167
- */
168
- getStoredCredentialIds(): string[];
169
- private extractPublicKeyFromAttestation;
170
- private parseCOSEKey;
171
- private tryParseCOSEKeyStrategies;
172
- private parseCOSEKeyWithCBORStructure;
173
- private tryParseASN1Structure;
174
- private find32ByteSequences;
175
- private isValidCoordinate;
176
- private bytesToBigInt;
177
- private bytesToHex;
178
- private analyzeCOSEStructure;
179
- private parseAuthenticationResponse;
180
- }
181
-
182
- export { type PasskeyCredential, PasskeyManager, type PasskeyManagerConfig, VERIDEX_RP_ID, type WebAuthnSignature, detectRpId, supportsRelatedOrigins };
1
+ export { a as PasskeyCredential, P as PasskeyManager, b as PasskeyManagerConfig, V as VERIDEX_RP_ID, W as WebAuthnSignature, d as detectRpId, s as supportsRelatedOrigins } from './passkey-fh8bo2w-.mjs';
2
+ import '@simplewebauthn/types';
package/dist/passkey.js CHANGED
@@ -250,7 +250,8 @@ var PasskeyManager = class _PasskeyManager {
250
250
  credentialId: response.id,
251
251
  publicKeyX: publicKey.x,
252
252
  publicKeyY: publicKey.y,
253
- keyHash
253
+ keyHash,
254
+ assurance: _PasskeyManager.assuranceFromRegistration(response) ?? void 0
254
255
  };
255
256
  return this.credential;
256
257
  }
@@ -629,7 +630,8 @@ var PasskeyManager = class _PasskeyManager {
629
630
  credentialId: response.id,
630
631
  publicKeyX: publicKey.x,
631
632
  publicKeyY: publicKey.y,
632
- keyHash
633
+ keyHash,
634
+ assurance: _PasskeyManager.assuranceFromRegistration(response) ?? void 0
633
635
  };
634
636
  this.addCredentialToStorage(backupCredential);
635
637
  return backupCredential;
@@ -646,17 +648,94 @@ var PasskeyManager = class _PasskeyManager {
646
648
  */
647
649
  static parseBackupFlags(authenticatorData) {
648
650
  try {
649
- const data = import_ethers2.ethers.getBytes(authenticatorData);
650
- if (data.length < 37) return null;
651
- const flags = data[32];
651
+ const assurance = _PasskeyManager.deriveAssurance(import_ethers2.ethers.getBytes(authenticatorData));
652
+ if (!assurance) return null;
652
653
  return {
653
- backupEligible: (flags & 8) !== 0,
654
- backupState: (flags & 16) !== 0
654
+ backupEligible: assurance.backupEligible,
655
+ backupState: assurance.backupState
655
656
  };
656
657
  } catch {
657
658
  return null;
658
659
  }
659
660
  }
661
+ /**
662
+ * Derive credential assurance from raw WebAuthn authenticator data.
663
+ *
664
+ * authData layout:
665
+ * rpIdHash (32) | flags (1) | signCount (4) | [attestedCredentialData: aaguid (16) | ...]
666
+ *
667
+ * Flags byte: UP 0x01 | UV 0x04 | BE 0x08 | BS 0x10 | AT 0x40 | ED 0x80
668
+ *
669
+ * BE is the authoritative signal for whether a credential is device-bound or
670
+ * syncable. It is set by the authenticator itself — unlike a platform/user-agent
671
+ * guess, it correctly identifies a hardware key used on a syncing platform.
672
+ *
673
+ * @returns Assurance, or `null` if authData is too short to be valid.
674
+ */
675
+ static deriveAssurance(authData) {
676
+ if (authData.length < 37) return null;
677
+ const flags = authData[32];
678
+ const backupEligible = (flags & 8) !== 0;
679
+ const attestedCredentialData = (flags & 64) !== 0;
680
+ let aaguid;
681
+ if (attestedCredentialData && authData.length >= 53) {
682
+ aaguid = import_ethers2.ethers.hexlify(authData.slice(37, 53));
683
+ }
684
+ return {
685
+ backupEligible,
686
+ backupState: (flags & 16) !== 0,
687
+ userVerified: (flags & 4) !== 0,
688
+ level: backupEligible ? "synced" : "device-bound",
689
+ aaguid
690
+ };
691
+ }
692
+ /**
693
+ * Extract raw authenticator data from a registration response.
694
+ *
695
+ * Prefers the `authenticatorData` field when the authenticator provides it,
696
+ * and otherwise locates the `authData` byte string inside the CBOR
697
+ * attestation object.
698
+ */
699
+ static extractAuthData(response) {
700
+ const direct = response.response.authenticatorData;
701
+ if (direct) {
702
+ try {
703
+ return base64URLDecode(direct);
704
+ } catch {
705
+ }
706
+ }
707
+ try {
708
+ const attestationObject = base64URLDecode(response.response.attestationObject);
709
+ let offset = 0;
710
+ if (attestationObject[offset] >= 160 && attestationObject[offset] <= 191) {
711
+ offset++;
712
+ }
713
+ const key = [104, 97, 117, 116, 104, 68, 97, 116, 97];
714
+ let found = false;
715
+ while (offset < attestationObject.length - 37) {
716
+ if (key.every((byte, i) => attestationObject[offset + i] === byte)) {
717
+ offset += key.length;
718
+ found = true;
719
+ break;
720
+ }
721
+ offset++;
722
+ }
723
+ if (!found) return null;
724
+ if (attestationObject[offset] === 88) {
725
+ offset += 2;
726
+ } else if (attestationObject[offset] === 89) {
727
+ offset += 3;
728
+ }
729
+ return attestationObject.slice(offset);
730
+ } catch {
731
+ return null;
732
+ }
733
+ }
734
+ /** Derive assurance directly from a registration response. */
735
+ static assuranceFromRegistration(response) {
736
+ const authData = _PasskeyManager.extractAuthData(response);
737
+ return authData ? _PasskeyManager.deriveAssurance(authData) : null;
738
+ }
660
739
  /**
661
740
  * Get the number of credentials stored locally.
662
741
  */