@veridex/sdk 1.0.0-beta.8 → 1.0.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 (130) hide show
  1. package/LICENSE +170 -21
  2. package/README.md +574 -117
  3. package/dist/EVMClient-DtqvdfUP.d.mts +376 -0
  4. package/dist/auth/prepareAuth.d.mts +25 -0
  5. package/dist/auth/prepareAuth.js +2406 -0
  6. package/dist/auth/prepareAuth.js.map +1 -0
  7. package/dist/auth/prepareAuth.mjs +151 -0
  8. package/dist/auth/prepareAuth.mjs.map +1 -0
  9. package/dist/chains/aptos/index.d.mts +6 -5
  10. package/dist/chains/aptos/index.js +66 -39
  11. package/dist/chains/aptos/index.js.map +1 -1
  12. package/dist/chains/aptos/index.mjs +5 -547
  13. package/dist/chains/aptos/index.mjs.map +1 -1
  14. package/dist/chains/avalanche/index.d.mts +137 -0
  15. package/dist/chains/avalanche/index.js +1555 -0
  16. package/dist/chains/avalanche/index.js.map +1 -0
  17. package/dist/chains/avalanche/index.mjs +10 -0
  18. package/dist/chains/avalanche/index.mjs.map +1 -0
  19. package/dist/chains/evm/index.d.mts +5 -3
  20. package/dist/chains/evm/index.js +165 -3
  21. package/dist/chains/evm/index.js.map +1 -1
  22. package/dist/chains/evm/index.mjs +8 -1200
  23. package/dist/chains/evm/index.mjs.map +1 -1
  24. package/dist/chains/solana/index.d.mts +1 -1
  25. package/dist/chains/solana/index.js.map +1 -1
  26. package/dist/chains/solana/index.mjs +4 -486
  27. package/dist/chains/solana/index.mjs.map +1 -1
  28. package/dist/chains/stacks/index.d.mts +559 -0
  29. package/dist/chains/stacks/index.js +1207 -0
  30. package/dist/chains/stacks/index.js.map +1 -0
  31. package/dist/chains/stacks/index.mjs +71 -0
  32. package/dist/chains/stacks/index.mjs.map +1 -0
  33. package/dist/chains/starknet/index.d.mts +3 -3
  34. package/dist/chains/starknet/index.js.map +1 -1
  35. package/dist/chains/starknet/index.mjs +5 -503
  36. package/dist/chains/starknet/index.mjs.map +1 -1
  37. package/dist/chains/sui/index.d.mts +2 -2
  38. package/dist/chains/sui/index.js.map +1 -1
  39. package/dist/chains/sui/index.mjs +5 -529
  40. package/dist/chains/sui/index.mjs.map +1 -1
  41. package/dist/chunk-5T6KPH7A.mjs +1082 -0
  42. package/dist/chunk-5T6KPH7A.mjs.map +1 -0
  43. package/dist/chunk-72ZA3OYQ.mjs +20 -0
  44. package/dist/chunk-72ZA3OYQ.mjs.map +1 -0
  45. package/dist/chunk-EFIURACP.mjs +438 -0
  46. package/dist/chunk-EFIURACP.mjs.map +1 -0
  47. package/dist/chunk-F3YAGZSW.mjs +269 -0
  48. package/dist/chunk-F3YAGZSW.mjs.map +1 -0
  49. package/dist/chunk-GWJRKDSA.mjs +549 -0
  50. package/dist/chunk-GWJRKDSA.mjs.map +1 -0
  51. package/dist/chunk-M3MM4YMF.mjs +417 -0
  52. package/dist/chunk-M3MM4YMF.mjs.map +1 -0
  53. package/dist/chunk-N4A2RMUN.mjs +216 -0
  54. package/dist/chunk-N4A2RMUN.mjs.map +1 -0
  55. package/dist/chunk-NUWSMJFJ.mjs +179 -0
  56. package/dist/chunk-NUWSMJFJ.mjs.map +1 -0
  57. package/dist/chunk-OVMMTL6H.mjs +330 -0
  58. package/dist/chunk-OVMMTL6H.mjs.map +1 -0
  59. package/dist/chunk-PDHZ5X5O.mjs +565 -0
  60. package/dist/chunk-PDHZ5X5O.mjs.map +1 -0
  61. package/dist/chunk-PRHNGA4G.mjs +464 -0
  62. package/dist/chunk-PRHNGA4G.mjs.map +1 -0
  63. package/dist/chunk-Q5O3M5LP.mjs +422 -0
  64. package/dist/chunk-Q5O3M5LP.mjs.map +1 -0
  65. package/dist/chunk-QDO6NQ7P.mjs +840 -0
  66. package/dist/chunk-QDO6NQ7P.mjs.map +1 -0
  67. package/dist/chunk-QT4ZZ4GM.mjs +509 -0
  68. package/dist/chunk-QT4ZZ4GM.mjs.map +1 -0
  69. package/dist/chunk-USDA5JTN.mjs +1249 -0
  70. package/dist/chunk-USDA5JTN.mjs.map +1 -0
  71. package/dist/chunk-V636MIV3.mjs +52 -0
  72. package/dist/chunk-V636MIV3.mjs.map +1 -0
  73. package/dist/chunk-X7BZMSPQ.mjs +407 -0
  74. package/dist/chunk-X7BZMSPQ.mjs.map +1 -0
  75. package/dist/chunk-YCUJZ6Z7.mjs +829 -0
  76. package/dist/chunk-YCUJZ6Z7.mjs.map +1 -0
  77. package/dist/constants.d.mts +1 -1
  78. package/dist/constants.js +26 -12
  79. package/dist/constants.js.map +1 -1
  80. package/dist/constants.mjs +16 -375
  81. package/dist/constants.mjs.map +1 -1
  82. package/dist/index-DDalBhAm.d.mts +243 -0
  83. package/dist/index.d.mts +2508 -556
  84. package/dist/index.js +14576 -9628
  85. package/dist/index.js.map +1 -1
  86. package/dist/index.mjs +4108 -7840
  87. package/dist/index.mjs.map +1 -1
  88. package/dist/passkey.d.mts +182 -0
  89. package/dist/passkey.js +914 -0
  90. package/dist/passkey.js.map +1 -0
  91. package/dist/passkey.mjs +15 -0
  92. package/dist/passkey.mjs.map +1 -0
  93. package/dist/payload.js.map +1 -1
  94. package/dist/payload.mjs +25 -244
  95. package/dist/payload.mjs.map +1 -1
  96. package/dist/portfolio-V347KZOL.mjs +13 -0
  97. package/dist/portfolio-V347KZOL.mjs.map +1 -0
  98. package/dist/queries/index.js +145 -12
  99. package/dist/queries/index.js.map +1 -1
  100. package/dist/queries/index.mjs +14 -1496
  101. package/dist/queries/index.mjs.map +1 -1
  102. package/dist/{types-FJL7j6gQ.d.ts → types-B7V5VNbO.d.mts} +6 -2
  103. package/dist/{types-ChIsqCiw.d.mts → types-DP2CQT8p.d.mts} +12 -1
  104. package/dist/types.d.mts +16 -0
  105. package/dist/types.js.map +1 -1
  106. package/dist/utils.js +25 -11
  107. package/dist/utils.js.map +1 -1
  108. package/dist/utils.mjs +19 -371
  109. package/dist/utils.mjs.map +1 -1
  110. package/dist/wormhole.js.map +1 -1
  111. package/dist/wormhole.mjs +25 -397
  112. package/dist/wormhole.mjs.map +1 -1
  113. package/package.json +28 -3
  114. package/scripts/patch-noble-curves.js +78 -0
  115. package/dist/chains/aptos/index.d.ts +0 -145
  116. package/dist/chains/evm/index.d.ts +0 -5
  117. package/dist/chains/solana/index.d.ts +0 -116
  118. package/dist/chains/starknet/index.d.ts +0 -172
  119. package/dist/chains/sui/index.d.ts +0 -182
  120. package/dist/constants.d.ts +0 -150
  121. package/dist/index-0NXfbk0z.d.ts +0 -637
  122. package/dist/index-D0dLVjTA.d.mts +0 -637
  123. package/dist/index.d.ts +0 -3123
  124. package/dist/payload.d.ts +0 -125
  125. package/dist/queries/index.d.ts +0 -148
  126. package/dist/types-ChIsqCiw.d.ts +0 -565
  127. package/dist/types-FJL7j6gQ.d.mts +0 -172
  128. package/dist/types.d.ts +0 -407
  129. package/dist/utils.d.ts +0 -81
  130. package/dist/wormhole.d.ts +0 -167
@@ -0,0 +1,182 @@
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 };