@opensecret/react 1.0.0 → 1.1.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/README.md +192 -21
- package/dist/index.d.ts +368 -50
- package/dist/opensecret-react.es.js +1333 -1294
- package/dist/opensecret-react.umd.js +19 -19
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ declare namespace api {
|
|
|
38
38
|
fetchPublicKey,
|
|
39
39
|
convertGuestToEmailAccount,
|
|
40
40
|
generateThirdPartyToken,
|
|
41
|
+
encryptData,
|
|
42
|
+
decryptData,
|
|
41
43
|
LoginResponse,
|
|
42
44
|
UserResponse,
|
|
43
45
|
KVListItem,
|
|
@@ -45,11 +47,15 @@ declare namespace api {
|
|
|
45
47
|
GoogleAuthResponse,
|
|
46
48
|
PrivateKeyResponse,
|
|
47
49
|
PrivateKeyBytesResponse,
|
|
50
|
+
KeyOptions,
|
|
48
51
|
SignMessageResponse,
|
|
49
52
|
SignMessageRequest,
|
|
50
53
|
PublicKeyResponse,
|
|
51
54
|
ThirdPartyTokenRequest,
|
|
52
|
-
ThirdPartyTokenResponse
|
|
55
|
+
ThirdPartyTokenResponse,
|
|
56
|
+
EncryptDataRequest,
|
|
57
|
+
EncryptDataResponse,
|
|
58
|
+
DecryptDataRequest
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
|
|
@@ -193,6 +199,50 @@ declare function createProject(orgId: string, name: string, description?: string
|
|
|
193
199
|
|
|
194
200
|
declare function createProjectSecret(orgId: string, projectId: string, keyName: string, secret: string): Promise<ProjectSecret>;
|
|
195
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Decrypts data that was previously encrypted with the user's key
|
|
204
|
+
* @param encryptedData - Base64-encoded encrypted data string
|
|
205
|
+
* @param key_options - Key derivation options (see KeyOptions type)
|
|
206
|
+
* @returns A promise resolving to the decrypted string
|
|
207
|
+
* @throws {Error} If:
|
|
208
|
+
* - The encrypted data is malformed
|
|
209
|
+
* - The derivation paths are invalid
|
|
210
|
+
* - Authentication fails
|
|
211
|
+
* - Server-side decryption error occurs
|
|
212
|
+
*
|
|
213
|
+
* @description
|
|
214
|
+
* This function supports multiple decryption approaches:
|
|
215
|
+
*
|
|
216
|
+
* 1. Decrypt with master key (no derivation parameters)
|
|
217
|
+
*
|
|
218
|
+
* 2. Decrypt with BIP-32 derived key
|
|
219
|
+
* - Derives a child key from the master seed using BIP-32
|
|
220
|
+
*
|
|
221
|
+
* 3. Decrypt with BIP-85 derived key
|
|
222
|
+
* - Derives a child mnemonic using BIP-85, then uses its master key
|
|
223
|
+
*
|
|
224
|
+
* 4. Decrypt with combined BIP-85 and BIP-32 derivation
|
|
225
|
+
* - First derives a child mnemonic via BIP-85
|
|
226
|
+
* - Then applies BIP-32 derivation to derive a key from that seed
|
|
227
|
+
*
|
|
228
|
+
* IMPORTANT: You must use the exact same derivation paths for decryption
|
|
229
|
+
* that were used for encryption.
|
|
230
|
+
*
|
|
231
|
+
* Technical details:
|
|
232
|
+
* - Uses AES-256-GCM decryption with authentication tag verification
|
|
233
|
+
* - Extracts the nonce from the first 12 bytes of the encrypted data
|
|
234
|
+
* - The encrypted_data must be in the exact format returned by the encrypt endpoint
|
|
235
|
+
*/
|
|
236
|
+
declare function decryptData(encryptedData: string, key_options?: KeyOptions): Promise<string>;
|
|
237
|
+
|
|
238
|
+
declare type DecryptDataRequest = {
|
|
239
|
+
encrypted_data: string;
|
|
240
|
+
key_options?: {
|
|
241
|
+
private_key_derivation_path?: string;
|
|
242
|
+
seed_phrase_derivation_path?: string;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
|
|
196
246
|
declare function deleteOrganization(orgId: string): Promise<void>;
|
|
197
247
|
|
|
198
248
|
declare function deleteOrganizationInvite(orgId: string, inviteCode: string): Promise<{
|
|
@@ -215,6 +265,53 @@ declare type EmailSettings = {
|
|
|
215
265
|
email_verification_url: string;
|
|
216
266
|
};
|
|
217
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Encrypts arbitrary string data using the user's private key
|
|
270
|
+
* @param data - String content to be encrypted
|
|
271
|
+
* @param key_options - Key derivation options (see KeyOptions type)
|
|
272
|
+
* @returns A promise resolving to the encrypted data response
|
|
273
|
+
* @throws {Error} If:
|
|
274
|
+
* - The derivation paths are invalid
|
|
275
|
+
* - Authentication fails
|
|
276
|
+
* - Server-side encryption error occurs
|
|
277
|
+
*
|
|
278
|
+
* @description
|
|
279
|
+
* This function supports multiple encryption approaches:
|
|
280
|
+
*
|
|
281
|
+
* 1. Encrypt with master key (no derivation parameters)
|
|
282
|
+
*
|
|
283
|
+
* 2. Encrypt with BIP-32 derived key
|
|
284
|
+
* - Derives a child key from the master seed using BIP-32
|
|
285
|
+
*
|
|
286
|
+
* 3. Encrypt with BIP-85 derived key
|
|
287
|
+
* - Derives a child mnemonic using BIP-85, then uses its master key
|
|
288
|
+
*
|
|
289
|
+
* 4. Encrypt with combined BIP-85 and BIP-32 derivation
|
|
290
|
+
* - First derives a child mnemonic via BIP-85
|
|
291
|
+
* - Then applies BIP-32 derivation to derive a key from that seed
|
|
292
|
+
*
|
|
293
|
+
* Technical details:
|
|
294
|
+
* - Encrypts data with AES-256-GCM
|
|
295
|
+
* - A random nonce is generated for each encryption operation (included in the result)
|
|
296
|
+
* - The encrypted_data format:
|
|
297
|
+
* - First 12 bytes: Nonce used for encryption (prepended to ciphertext)
|
|
298
|
+
* - Remaining bytes: AES-256-GCM encrypted ciphertext + authentication tag
|
|
299
|
+
* - The entire payload is base64-encoded for safe transport
|
|
300
|
+
*/
|
|
301
|
+
declare function encryptData(data: string, key_options?: KeyOptions): Promise<EncryptDataResponse>;
|
|
302
|
+
|
|
303
|
+
declare type EncryptDataRequest = {
|
|
304
|
+
data: string;
|
|
305
|
+
key_options?: {
|
|
306
|
+
private_key_derivation_path?: string;
|
|
307
|
+
seed_phrase_derivation_path?: string;
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
declare type EncryptDataResponse = {
|
|
312
|
+
encrypted_data: string;
|
|
313
|
+
};
|
|
314
|
+
|
|
218
315
|
declare const EXPECTED_ROOT_CERT_HASH = "641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";
|
|
219
316
|
|
|
220
317
|
declare function fetchAttestationDocument(nonce: string, explicitApiUrl?: string): Promise<string>;
|
|
@@ -233,38 +330,85 @@ declare function fetchLogin(email: string, password: string, client_id: string):
|
|
|
233
330
|
|
|
234
331
|
declare function fetchLogout(refresh_token: string): Promise<void>;
|
|
235
332
|
|
|
236
|
-
|
|
333
|
+
/**
|
|
334
|
+
* Fetches the private key as a mnemonic phrase with optional derivation paths
|
|
335
|
+
* @param key_options - Optional key derivation options (see KeyOptions type)
|
|
336
|
+
*
|
|
337
|
+
* @returns A promise resolving to the private key response containing the mnemonic
|
|
338
|
+
*
|
|
339
|
+
* @description
|
|
340
|
+
* - If seed_phrase_derivation_path is provided, a child mnemonic is derived via BIP-85
|
|
341
|
+
* - If seed_phrase_derivation_path is omitted, the master mnemonic is returned
|
|
342
|
+
* - BIP-85 allows deriving child mnemonics from a master seed in a deterministic way
|
|
343
|
+
* - Common BIP-85 path format: m/83696968'/39'/0'/[entropy in bits]'/[index]'
|
|
344
|
+
* where entropy is typically 12' for 12-word mnemonics
|
|
345
|
+
*/
|
|
346
|
+
declare function fetchPrivateKey(key_options?: KeyOptions): Promise<PrivateKeyResponse>;
|
|
237
347
|
|
|
238
348
|
/**
|
|
239
|
-
* Fetches private key bytes for
|
|
240
|
-
* @param
|
|
349
|
+
* Fetches private key bytes for the given derivation options
|
|
350
|
+
* @param key_options - Key derivation options (see KeyOptions type)
|
|
241
351
|
*
|
|
242
|
-
*
|
|
243
|
-
* - Absolute path: "m/44'/0'/0'/0/0"
|
|
244
|
-
* - Relative path: "0'/0'/0'/0/0"
|
|
245
|
-
* - Hardened notation: "44'" or "44h"
|
|
352
|
+
* @returns A promise resolving to the private key bytes response
|
|
246
353
|
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
354
|
+
* @description
|
|
355
|
+
* This function supports multiple derivation approaches:
|
|
356
|
+
*
|
|
357
|
+
* 1. Master key only (no parameters)
|
|
358
|
+
* - Returns the master private key bytes
|
|
359
|
+
*
|
|
360
|
+
* 2. BIP-32 derivation only
|
|
361
|
+
* - Uses a single derivation path to derive a child key from the master seed
|
|
362
|
+
* - Supports both absolute and relative paths with hardened derivation:
|
|
363
|
+
* - Absolute path: "m/44'/0'/0'/0/0"
|
|
364
|
+
* - Relative path: "0'/0'/0'/0/0"
|
|
365
|
+
* - Hardened notation: "44'" or "44h"
|
|
366
|
+
* - Common paths:
|
|
367
|
+
* - BIP44 (Legacy): m/44'/0'/0'/0/0
|
|
368
|
+
* - BIP49 (SegWit): m/49'/0'/0'/0/0
|
|
369
|
+
* - BIP84 (Native SegWit): m/84'/0'/0'/0/0
|
|
370
|
+
* - BIP86 (Taproot): m/86'/0'/0'/0/0
|
|
371
|
+
*
|
|
372
|
+
* 3. BIP-85 derivation only
|
|
373
|
+
* - Derives a child mnemonic from the master seed using BIP-85
|
|
374
|
+
* - Then returns the master private key of that derived seed
|
|
375
|
+
* - Example path: "m/83696968'/39'/0'/12'/0'"
|
|
376
|
+
*
|
|
377
|
+
* 4. Combined BIP-85 and BIP-32 derivation
|
|
378
|
+
* - First derives a child mnemonic via BIP-85
|
|
379
|
+
* - Then applies BIP-32 derivation to that derived seed
|
|
380
|
+
* - This allows for more complex derivation schemes
|
|
252
381
|
*/
|
|
253
|
-
declare function fetchPrivateKeyBytes(
|
|
382
|
+
declare function fetchPrivateKeyBytes(key_options?: KeyOptions): Promise<PrivateKeyBytesResponse>;
|
|
254
383
|
|
|
255
384
|
/**
|
|
256
|
-
* Retrieves the public key for a given algorithm and derivation
|
|
385
|
+
* Retrieves the public key for a given algorithm and derivation options
|
|
257
386
|
* @param algorithm - Signing algorithm (schnorr or ecdsa)
|
|
258
|
-
* @param
|
|
387
|
+
* @param key_options - Key derivation options (see KeyOptions type)
|
|
388
|
+
*
|
|
389
|
+
* @returns A promise resolving to the public key response
|
|
259
390
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
391
|
+
* @description
|
|
392
|
+
* The derivation paths determine which key is used to generate the public key:
|
|
393
|
+
*
|
|
394
|
+
* 1. Master key (no derivation parameters)
|
|
395
|
+
* - Returns the public key corresponding to the master private key
|
|
396
|
+
*
|
|
397
|
+
* 2. BIP-32 derived key
|
|
398
|
+
* - Returns the public key for a derived child key
|
|
399
|
+
* - Useful for:
|
|
400
|
+
* - Separating keys by purpose (e.g., different chains or applications)
|
|
401
|
+
* - Generating deterministic addresses
|
|
402
|
+
* - Supporting different address formats (Legacy, SegWit, Native SegWit, Taproot)
|
|
403
|
+
*
|
|
404
|
+
* 3. BIP-85 derived key
|
|
405
|
+
* - Returns the public key for the master key of a BIP-85 derived seed
|
|
406
|
+
*
|
|
407
|
+
* 4. Combined BIP-85 and BIP-32 derivation
|
|
408
|
+
* - First derives a child mnemonic via BIP-85
|
|
409
|
+
* - Then applies BIP-32 derivation to get the corresponding public key
|
|
266
410
|
*/
|
|
267
|
-
declare function fetchPublicKey(algorithm: SigningAlgorithm,
|
|
411
|
+
declare function fetchPublicKey(algorithm: SigningAlgorithm, key_options?: KeyOptions): Promise<PublicKeyResponse>;
|
|
268
412
|
|
|
269
413
|
declare function fetchPut(key: string, value: string): Promise<string>;
|
|
270
414
|
|
|
@@ -274,7 +418,16 @@ declare function fetchUser(): Promise<UserResponse>;
|
|
|
274
418
|
|
|
275
419
|
export declare function generateSecureSecret(): string;
|
|
276
420
|
|
|
277
|
-
|
|
421
|
+
/**
|
|
422
|
+
* Generates a JWT token for use with third-party services
|
|
423
|
+
* @param audience - Optional URL of the service
|
|
424
|
+
* @returns A promise resolving to the token response containing the JWT
|
|
425
|
+
*
|
|
426
|
+
* @description
|
|
427
|
+
* - If audience is provided, it can be any valid URL
|
|
428
|
+
* - If audience is omitted, a token with no audience restriction will be generated
|
|
429
|
+
*/
|
|
430
|
+
declare function generateThirdPartyToken(audience?: string): Promise<ThirdPartyTokenResponse>;
|
|
278
431
|
|
|
279
432
|
declare function getApiUrl(): string;
|
|
280
433
|
|
|
@@ -317,6 +470,22 @@ declare function keyExchange(clientPublicKey: string, nonce: string, explicitApi
|
|
|
317
470
|
session_id: string;
|
|
318
471
|
}>;
|
|
319
472
|
|
|
473
|
+
/**
|
|
474
|
+
* Options for key derivation operations
|
|
475
|
+
*/
|
|
476
|
+
declare type KeyOptions = {
|
|
477
|
+
/**
|
|
478
|
+
* BIP-85 derivation path to derive a child mnemonic
|
|
479
|
+
* Examples: "m/83696968'/39'/0'/12'/0'"
|
|
480
|
+
*/
|
|
481
|
+
seed_phrase_derivation_path?: string;
|
|
482
|
+
/**
|
|
483
|
+
* BIP-32 derivation path to derive a child key from the master (or BIP-85 derived) seed
|
|
484
|
+
* Examples: "m/44'/0'/0'/0/0"
|
|
485
|
+
*/
|
|
486
|
+
private_key_derivation_path?: string;
|
|
487
|
+
};
|
|
488
|
+
|
|
320
489
|
export declare type KVListItem = {
|
|
321
490
|
key: string;
|
|
322
491
|
value: string;
|
|
@@ -530,44 +699,104 @@ export declare type OpenSecretContextType = {
|
|
|
530
699
|
handleGoogleCallback: (code: string, state: string, inviteCode: string) => Promise<void>;
|
|
531
700
|
/**
|
|
532
701
|
* Retrieves the user's private key mnemonic phrase
|
|
702
|
+
* @param options - Optional key derivation options
|
|
533
703
|
* @returns A promise resolving to the private key response
|
|
534
704
|
* @throws {Error} If the private key cannot be retrieved
|
|
705
|
+
*
|
|
706
|
+
* @description
|
|
707
|
+
* This function supports two modes:
|
|
708
|
+
*
|
|
709
|
+
* 1. Master mnemonic (no parameters)
|
|
710
|
+
* - Returns the user's master 12-word BIP39 mnemonic
|
|
711
|
+
*
|
|
712
|
+
* 2. BIP-85 derived mnemonic
|
|
713
|
+
* - Derives a child mnemonic using BIP-85
|
|
714
|
+
* - Requires seed_phrase_derivation_path in options
|
|
715
|
+
* - Example: "m/83696968'/39'/0'/12'/0'"
|
|
535
716
|
*/
|
|
536
717
|
getPrivateKey: typeof api.fetchPrivateKey;
|
|
537
718
|
/**
|
|
538
|
-
* Retrieves the private key bytes for
|
|
539
|
-
* @param
|
|
719
|
+
* Retrieves the private key bytes for the given derivation options
|
|
720
|
+
* @param options - Optional key derivation options or legacy BIP32 derivation path string
|
|
540
721
|
* @returns A promise resolving to the private key bytes response
|
|
541
722
|
* @throws {Error} If:
|
|
542
723
|
* - The private key bytes cannot be retrieved
|
|
543
|
-
* - The derivation
|
|
724
|
+
* - The derivation paths are invalid
|
|
544
725
|
*
|
|
545
726
|
* @description
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
727
|
+
* This function supports multiple derivation approaches:
|
|
728
|
+
*
|
|
729
|
+
* 1. Master key only (no parameters)
|
|
730
|
+
* - Returns the master private key bytes
|
|
731
|
+
*
|
|
732
|
+
* 2. BIP-32 derivation only
|
|
733
|
+
* - Uses a single derivation path to derive a child key from the master seed
|
|
734
|
+
* - Supports both absolute and relative paths with hardened derivation:
|
|
735
|
+
* - Absolute path: "m/44'/0'/0'/0/0"
|
|
736
|
+
* - Relative path: "0'/0'/0'/0/0"
|
|
737
|
+
* - Hardened notation: "44'" or "44h"
|
|
738
|
+
* - Common paths:
|
|
739
|
+
* - BIP44 (Legacy): m/44'/0'/0'/0/0
|
|
740
|
+
* - BIP49 (SegWit): m/49'/0'/0'/0/0
|
|
741
|
+
* - BIP84 (Native SegWit): m/84'/0'/0'/0/0
|
|
742
|
+
* - BIP86 (Taproot): m/86'/0'/0'/0/0
|
|
743
|
+
*
|
|
744
|
+
* 3. BIP-85 derivation only
|
|
745
|
+
* - Derives a child mnemonic from the master seed using BIP-85
|
|
746
|
+
* - Then returns the master private key of that derived seed
|
|
747
|
+
* - Example path: "m/83696968'/39'/0'/12'/0'"
|
|
748
|
+
*
|
|
749
|
+
* 4. Combined BIP-85 and BIP-32 derivation
|
|
750
|
+
* - First derives a child mnemonic via BIP-85
|
|
751
|
+
* - Then applies BIP-32 derivation to that derived seed
|
|
554
752
|
*/
|
|
555
753
|
getPrivateKeyBytes: typeof api.fetchPrivateKeyBytes;
|
|
556
754
|
/**
|
|
557
755
|
* Retrieves the user's public key for the specified algorithm
|
|
558
756
|
* @param algorithm - The signing algorithm ('schnorr' or 'ecdsa')
|
|
559
|
-
* @param
|
|
757
|
+
* @param options - Optional key derivation options or legacy BIP32 derivation path string
|
|
560
758
|
* @returns A promise resolving to the public key response
|
|
561
759
|
* @throws {Error} If the public key cannot be retrieved
|
|
760
|
+
*
|
|
761
|
+
* @description
|
|
762
|
+
* The derivation paths determine which key is used to generate the public key:
|
|
763
|
+
*
|
|
764
|
+
* 1. Master key (no derivation parameters)
|
|
765
|
+
* - Returns the public key corresponding to the master private key
|
|
766
|
+
*
|
|
767
|
+
* 2. BIP-32 derived key
|
|
768
|
+
* - Returns the public key for a derived child key
|
|
769
|
+
*
|
|
770
|
+
* 3. BIP-85 derived key
|
|
771
|
+
* - Returns the public key for the master key of a BIP-85 derived seed
|
|
772
|
+
*
|
|
773
|
+
* 4. Combined BIP-85 and BIP-32 derivation
|
|
774
|
+
* - First derives a child mnemonic via BIP-85
|
|
775
|
+
* - Then applies BIP-32 derivation to get the corresponding public key
|
|
562
776
|
*/
|
|
563
777
|
getPublicKey: typeof api.fetchPublicKey;
|
|
564
778
|
/**
|
|
565
779
|
* Signs a message using the specified algorithm
|
|
566
780
|
* @param messageBytes - The message to sign as a Uint8Array
|
|
567
781
|
* @param algorithm - The signing algorithm ('schnorr' or 'ecdsa')
|
|
568
|
-
* @param
|
|
782
|
+
* @param options - Optional key derivation options or legacy BIP32 derivation path string
|
|
569
783
|
* @returns A promise resolving to the signature response
|
|
570
784
|
* @throws {Error} If the message signing fails
|
|
785
|
+
*
|
|
786
|
+
* @description
|
|
787
|
+
* This function supports multiple signing approaches:
|
|
788
|
+
*
|
|
789
|
+
* 1. Sign with master key (no derivation parameters)
|
|
790
|
+
*
|
|
791
|
+
* 2. Sign with BIP-32 derived key
|
|
792
|
+
* - Derives a child key from the master seed using BIP-32
|
|
793
|
+
*
|
|
794
|
+
* 3. Sign with BIP-85 derived key
|
|
795
|
+
* - Derives a child mnemonic using BIP-85, then uses its master key
|
|
796
|
+
*
|
|
797
|
+
* 4. Sign with combined BIP-85 and BIP-32 derivation
|
|
798
|
+
* - First derives a child mnemonic via BIP-85
|
|
799
|
+
* - Then applies BIP-32 derivation to derive a key from that seed
|
|
571
800
|
*/
|
|
572
801
|
signMessage: typeof api.signMessage;
|
|
573
802
|
/**
|
|
@@ -632,21 +861,88 @@ export declare type OpenSecretContextType = {
|
|
|
632
861
|
*/
|
|
633
862
|
getAttestationDocument: () => Promise<ParsedAttestationView>;
|
|
634
863
|
/**
|
|
635
|
-
* Generates a JWT token for use with
|
|
636
|
-
* @param audience -
|
|
864
|
+
* Generates a JWT token for use with third-party services
|
|
865
|
+
* @param audience - Optional URL of the service (e.g. "https://billing.opensecret.cloud")
|
|
637
866
|
* @returns A promise resolving to the token response
|
|
638
867
|
* @throws {Error} If:
|
|
639
868
|
* - The user is not authenticated
|
|
640
|
-
* - The audience URL is invalid
|
|
641
|
-
* - The audience URL is not authorized
|
|
869
|
+
* - The audience URL is invalid (if provided)
|
|
642
870
|
*
|
|
643
871
|
* @description
|
|
644
|
-
* - Generates a signed JWT token for use with
|
|
645
|
-
* -
|
|
872
|
+
* - Generates a signed JWT token for use with third-party services
|
|
873
|
+
* - If audience is provided, it can be any valid URL
|
|
874
|
+
* - If audience is omitted, a token with no audience restriction will be generated
|
|
646
875
|
* - Requires an active authentication session
|
|
647
876
|
* - Token can be used to authenticate with the specified service
|
|
648
877
|
*/
|
|
649
|
-
generateThirdPartyToken: (audience
|
|
878
|
+
generateThirdPartyToken: (audience?: string) => Promise<ThirdPartyTokenResponse>;
|
|
879
|
+
/**
|
|
880
|
+
* Encrypts arbitrary string data using the user's private key
|
|
881
|
+
* @param data - String content to be encrypted
|
|
882
|
+
* @param options - Optional key derivation options or legacy BIP32 derivation path string
|
|
883
|
+
* @returns A promise resolving to the encrypted data response
|
|
884
|
+
* @throws {Error} If:
|
|
885
|
+
* - The derivation paths are invalid
|
|
886
|
+
* - Authentication fails
|
|
887
|
+
* - Server-side encryption error occurs
|
|
888
|
+
*
|
|
889
|
+
* @description
|
|
890
|
+
* This function supports multiple encryption approaches:
|
|
891
|
+
*
|
|
892
|
+
* 1. Encrypt with master key (no derivation parameters)
|
|
893
|
+
*
|
|
894
|
+
* 2. Encrypt with BIP-32 derived key
|
|
895
|
+
* - Derives a child key from the master seed using BIP-32
|
|
896
|
+
* - Example: "m/44'/0'/0'/0/0"
|
|
897
|
+
*
|
|
898
|
+
* 3. Encrypt with BIP-85 derived key
|
|
899
|
+
* - Derives a child mnemonic using BIP-85, then uses its master key
|
|
900
|
+
* - Example: { seed_phrase_derivation_path: "m/83696968'/39'/0'/12'/0'" }
|
|
901
|
+
*
|
|
902
|
+
* 4. Encrypt with combined BIP-85 and BIP-32 derivation
|
|
903
|
+
* - First derives a child mnemonic via BIP-85
|
|
904
|
+
* - Then applies BIP-32 derivation to derive a key from that seed
|
|
905
|
+
* - Example: {
|
|
906
|
+
* seed_phrase_derivation_path: "m/83696968'/39'/0'/12'/0'",
|
|
907
|
+
* private_key_derivation_path: "m/44'/0'/0'/0/0"
|
|
908
|
+
* }
|
|
909
|
+
*
|
|
910
|
+
* Technical details:
|
|
911
|
+
* - Encrypts data with AES-256-GCM
|
|
912
|
+
* - A random nonce is generated for each encryption operation (included in the result)
|
|
913
|
+
* - The encrypted_data format includes the nonce and is base64-encoded
|
|
914
|
+
*/
|
|
915
|
+
encryptData: typeof api.encryptData;
|
|
916
|
+
/**
|
|
917
|
+
* Decrypts data that was previously encrypted with the user's key
|
|
918
|
+
* @param encryptedData - Base64-encoded encrypted data string
|
|
919
|
+
* @param options - Optional key derivation options or legacy BIP32 derivation path string
|
|
920
|
+
* @returns A promise resolving to the decrypted string
|
|
921
|
+
* @throws {Error} If:
|
|
922
|
+
* - The encrypted data is malformed
|
|
923
|
+
* - The derivation paths are invalid
|
|
924
|
+
* - Authentication fails
|
|
925
|
+
* - Server-side decryption error occurs
|
|
926
|
+
*
|
|
927
|
+
* @description
|
|
928
|
+
* This function supports multiple decryption approaches:
|
|
929
|
+
*
|
|
930
|
+
* 1. Decrypt with master key (no derivation parameters)
|
|
931
|
+
*
|
|
932
|
+
* 2. Decrypt with BIP-32 derived key
|
|
933
|
+
* - Derives a child key from the master seed using BIP-32
|
|
934
|
+
*
|
|
935
|
+
* 3. Decrypt with BIP-85 derived key
|
|
936
|
+
* - Derives a child mnemonic using BIP-85, then uses its master key
|
|
937
|
+
*
|
|
938
|
+
* 4. Decrypt with combined BIP-85 and BIP-32 derivation
|
|
939
|
+
* - First derives a child mnemonic via BIP-85
|
|
940
|
+
* - Then applies BIP-32 derivation to derive a key from that seed
|
|
941
|
+
*
|
|
942
|
+
* IMPORTANT: You must use the exact same derivation options for decryption
|
|
943
|
+
* that were used for encryption.
|
|
944
|
+
*/
|
|
945
|
+
decryptData: typeof api.decryptData;
|
|
650
946
|
};
|
|
651
947
|
|
|
652
948
|
/**
|
|
@@ -1294,10 +1590,27 @@ declare function setPlatformApiUrl(url: string): void;
|
|
|
1294
1590
|
declare type SigningAlgorithm = "schnorr" | "ecdsa";
|
|
1295
1591
|
|
|
1296
1592
|
/**
|
|
1297
|
-
* Signs a message using the specified algorithm and derivation
|
|
1593
|
+
* Signs a message using the specified algorithm and derivation options
|
|
1298
1594
|
* @param message_bytes - Message to sign as Uint8Array
|
|
1299
1595
|
* @param algorithm - Signing algorithm (schnorr or ecdsa)
|
|
1300
|
-
* @param
|
|
1596
|
+
* @param key_options - Key derivation options (see KeyOptions type)
|
|
1597
|
+
*
|
|
1598
|
+
* @returns A promise resolving to the signature response
|
|
1599
|
+
*
|
|
1600
|
+
* @description
|
|
1601
|
+
* This function supports multiple signing approaches:
|
|
1602
|
+
*
|
|
1603
|
+
* 1. Sign with master key (no derivation parameters)
|
|
1604
|
+
*
|
|
1605
|
+
* 2. Sign with BIP-32 derived key
|
|
1606
|
+
* - Derives a child key from the master seed using BIP-32
|
|
1607
|
+
*
|
|
1608
|
+
* 3. Sign with BIP-85 derived key
|
|
1609
|
+
* - Derives a child mnemonic using BIP-85, then uses its master key
|
|
1610
|
+
*
|
|
1611
|
+
* 4. Sign with combined BIP-85 and BIP-32 derivation
|
|
1612
|
+
* - First derives a child mnemonic via BIP-85
|
|
1613
|
+
* - Then applies BIP-32 derivation to derive a key from that seed
|
|
1301
1614
|
*
|
|
1302
1615
|
* Example message preparation:
|
|
1303
1616
|
* ```typescript
|
|
@@ -1308,15 +1621,20 @@ declare type SigningAlgorithm = "schnorr" | "ecdsa";
|
|
|
1308
1621
|
* const messageBytes = new Uint8Array(Buffer.from("deadbeef", "hex"));
|
|
1309
1622
|
* ```
|
|
1310
1623
|
*/
|
|
1311
|
-
declare function signMessage(message_bytes: Uint8Array, algorithm: SigningAlgorithm,
|
|
1624
|
+
declare function signMessage(message_bytes: Uint8Array, algorithm: SigningAlgorithm, key_options?: KeyOptions): Promise<SignMessageResponse>;
|
|
1312
1625
|
|
|
1313
1626
|
declare type SignMessageRequest = {
|
|
1314
1627
|
/** Base64-encoded message to sign */
|
|
1315
1628
|
message_base64: string;
|
|
1316
1629
|
/** Signing algorithm to use (schnorr or ecdsa) */
|
|
1317
1630
|
algorithm: SigningAlgorithm;
|
|
1318
|
-
/** Optional
|
|
1319
|
-
|
|
1631
|
+
/** Optional key derivation options */
|
|
1632
|
+
key_options?: {
|
|
1633
|
+
/** Optional BIP32 derivation path (e.g., "m/44'/0'/0'/0/0") */
|
|
1634
|
+
private_key_derivation_path?: string;
|
|
1635
|
+
/** Optional BIP-85 seed phrase derivation path (e.g., "m/83696968'/39'/0'/12'/0'") */
|
|
1636
|
+
seed_phrase_derivation_path?: string;
|
|
1637
|
+
};
|
|
1320
1638
|
};
|
|
1321
1639
|
|
|
1322
1640
|
declare type SignMessageResponse = {
|
|
@@ -1327,7 +1645,7 @@ declare type SignMessageResponse = {
|
|
|
1327
1645
|
};
|
|
1328
1646
|
|
|
1329
1647
|
declare type ThirdPartyTokenRequest = {
|
|
1330
|
-
audience
|
|
1648
|
+
audience?: string;
|
|
1331
1649
|
};
|
|
1332
1650
|
|
|
1333
1651
|
declare type ThirdPartyTokenResponse = {
|