@opensecret/react 1.2.0 → 1.3.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/README.md +98 -0
- package/dist/index.d.ts +138 -54
- package/dist/opensecret-react.es.js +1606 -1517
- package/dist/opensecret-react.umd.js +21 -21
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -380,6 +380,104 @@ To deploy:
|
|
|
380
380
|
NPM_CONFIG_TOKEN=$NPM_CONFIG_TOKEN bun publish --access public
|
|
381
381
|
```
|
|
382
382
|
|
|
383
|
+
### Documentation Development
|
|
384
|
+
|
|
385
|
+
The SDK documentation is built using [Docusaurus](https://docusaurus.io/), a modern documentation framework. The documentation is automatically generated from TypeScript code comments and supplemented with manually written guides.
|
|
386
|
+
|
|
387
|
+
#### Getting Started with Documentation
|
|
388
|
+
|
|
389
|
+
To start the documentation development server:
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
bun run docs:dev
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
This will start the Docusaurus development server and open the documentation in your browser at http://localhost:3000/. The server supports hot-reloading, so any changes you make to the documentation will be immediately reflected in the browser.
|
|
396
|
+
|
|
397
|
+
#### Building Documentation
|
|
398
|
+
|
|
399
|
+
To build the documentation for production:
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
bun run docs:build
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
This will generate static HTML, JavaScript, and CSS files in the `website/build` directory.
|
|
406
|
+
|
|
407
|
+
To serve the built documentation locally:
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
bun run docs:serve
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### Documentation Structure
|
|
414
|
+
|
|
415
|
+
The documentation is organized into the following directories:
|
|
416
|
+
|
|
417
|
+
- `/website/docs/` - Contains all manual documentation files
|
|
418
|
+
- `index.md` - The documentation landing page
|
|
419
|
+
- `/guides/` - Step-by-step guides for using the SDK
|
|
420
|
+
- `/api/` - API reference documentation (mostly auto-generated)
|
|
421
|
+
|
|
422
|
+
#### API Reference Documentation
|
|
423
|
+
|
|
424
|
+
The API reference documentation is automatically generated from TypeScript code comments using [TypeDoc](https://typedoc.org/). To update the API documentation:
|
|
425
|
+
|
|
426
|
+
1. Write proper JSDoc comments in the TypeScript source code
|
|
427
|
+
2. Run `bun run docs:build` to regenerate the documentation
|
|
428
|
+
|
|
429
|
+
Important notes for API documentation:
|
|
430
|
+
|
|
431
|
+
- Use standard JSDoc syntax for documenting parameters, return types, and descriptions
|
|
432
|
+
- For Markdown in JSDoc comments, be aware that backticks (`) must be properly escaped
|
|
433
|
+
- For code examples with apostrophes (e.g., BIP paths like `m/44'/0'/0'/0/0`), use backslash escaping: `m/44\'/0\'/0\'/0/0`
|
|
434
|
+
|
|
435
|
+
#### Adding New Guides
|
|
436
|
+
|
|
437
|
+
To add a new guide:
|
|
438
|
+
|
|
439
|
+
1. Create a new Markdown file in the `/website/docs/guides/` directory
|
|
440
|
+
2. Add frontmatter at the top of the file:
|
|
441
|
+
```md
|
|
442
|
+
---
|
|
443
|
+
title: Your Guide Title
|
|
444
|
+
sidebar_position: X # Controls the order in the sidebar
|
|
445
|
+
---
|
|
446
|
+
```
|
|
447
|
+
3. Update the sidebar configuration in `/website/sidebars.ts` if needed
|
|
448
|
+
|
|
449
|
+
#### Customizing the Documentation
|
|
450
|
+
|
|
451
|
+
The main configuration files for Docusaurus are:
|
|
452
|
+
|
|
453
|
+
- `/website/docusaurus.config.ts` - Main Docusaurus configuration
|
|
454
|
+
- `/website/sidebars.ts` - Sidebar configuration
|
|
455
|
+
- `/website/typedoc.json` - TypeDoc configuration for API docs
|
|
456
|
+
|
|
457
|
+
To customize the appearance:
|
|
458
|
+
|
|
459
|
+
- Edit `/website/src/css/custom.css` for global styles
|
|
460
|
+
- Create or modify components in `/website/src/components/`
|
|
461
|
+
|
|
462
|
+
#### Deployment
|
|
463
|
+
|
|
464
|
+
The documentation can be deployed to various platforms like GitHub Pages, Netlify, or Vercel. For CloudFlare Pages deployment, as mentioned in our guideline:
|
|
465
|
+
|
|
466
|
+
1. In CloudFlare Pages, create a new project connected to your GitHub repo
|
|
467
|
+
2. Use these build settings:
|
|
468
|
+
- Build command: `cd website && bun run build`
|
|
469
|
+
- Build output directory: `website/build`
|
|
470
|
+
3. Set up a custom domain through CloudFlare's dashboard
|
|
471
|
+
|
|
472
|
+
#### Troubleshooting
|
|
473
|
+
|
|
474
|
+
Common issues:
|
|
475
|
+
|
|
476
|
+
- If TypeDoc fails to generate documentation, check the JSDoc comments for syntax errors
|
|
477
|
+
- If you see "Could not parse expression with acorn" errors, there are likely unescaped characters in code examples
|
|
478
|
+
- If links are broken, check that the referenced pages exist and paths are correct
|
|
479
|
+
- For sidebar issues, verify that the sidebar configuration in `sidebars.ts` is correct
|
|
480
|
+
|
|
383
481
|
## License
|
|
384
482
|
|
|
385
483
|
This project is licensed under the MIT License.
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,9 @@ declare namespace api {
|
|
|
32
32
|
handleGitHubCallback,
|
|
33
33
|
initiateGoogleAuth,
|
|
34
34
|
handleGoogleCallback,
|
|
35
|
+
initiateAppleAuth,
|
|
36
|
+
handleAppleCallback,
|
|
37
|
+
handleAppleNativeSignIn,
|
|
35
38
|
fetchPrivateKey,
|
|
36
39
|
fetchPrivateKeyBytes,
|
|
37
40
|
signMessage,
|
|
@@ -45,6 +48,8 @@ declare namespace api {
|
|
|
45
48
|
KVListItem,
|
|
46
49
|
GithubAuthResponse,
|
|
47
50
|
GoogleAuthResponse,
|
|
51
|
+
AppleAuthResponse,
|
|
52
|
+
AppleUser,
|
|
48
53
|
PrivateKeyResponse,
|
|
49
54
|
PrivateKeyBytesResponse,
|
|
50
55
|
KeyOptions,
|
|
@@ -107,6 +112,34 @@ export declare interface ApiEndpoint {
|
|
|
107
112
|
context: ApiContext;
|
|
108
113
|
}
|
|
109
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Response from initiating Apple OAuth authentication
|
|
117
|
+
* @property auth_url - The Apple authorization URL to redirect the user to
|
|
118
|
+
* @property state - The state parameter used to prevent CSRF attacks
|
|
119
|
+
*/
|
|
120
|
+
declare type AppleAuthResponse = {
|
|
121
|
+
auth_url: string;
|
|
122
|
+
state: string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Apple user information returned from native Apple Sign-In
|
|
127
|
+
* @property user_identifier - The user's unique ID from Apple
|
|
128
|
+
* @property identity_token - The JWT token from Apple used for authentication
|
|
129
|
+
* @property email - Optional email address (only provided on first sign-in)
|
|
130
|
+
* @property given_name - Optional user's first name (only provided on first sign-in)
|
|
131
|
+
* @property family_name - Optional user's last name (only provided on first sign-in)
|
|
132
|
+
* @property nonce - Optional nonce for preventing replay attacks
|
|
133
|
+
*/
|
|
134
|
+
declare type AppleUser = {
|
|
135
|
+
user_identifier: string;
|
|
136
|
+
identity_token: string;
|
|
137
|
+
email?: string;
|
|
138
|
+
given_name?: string;
|
|
139
|
+
family_name?: string;
|
|
140
|
+
nonce?: string;
|
|
141
|
+
};
|
|
142
|
+
|
|
110
143
|
declare interface Attestation {
|
|
111
144
|
sessionKey: Uint8Array | null;
|
|
112
145
|
sessionId: string | null;
|
|
@@ -453,12 +486,70 @@ export declare type GoogleAuthResponse = {
|
|
|
453
486
|
csrf_token: string;
|
|
454
487
|
};
|
|
455
488
|
|
|
489
|
+
/**
|
|
490
|
+
* Completes Apple OAuth authentication after user is redirected back to your app
|
|
491
|
+
* @param code - The authorization code from Apple
|
|
492
|
+
* @param state - The state parameter returned by Apple (should match the original state)
|
|
493
|
+
* @param inviteCode - Invite code for new user registration
|
|
494
|
+
* @returns A promise resolving to login response with access and refresh tokens
|
|
495
|
+
* @description
|
|
496
|
+
* This function completes the Apple OAuth authentication process by:
|
|
497
|
+
* 1. Validating the state parameter to prevent CSRF attacks
|
|
498
|
+
* 2. Exchanging the authorization code for tokens
|
|
499
|
+
* 3. Creating or authenticating the user account
|
|
500
|
+
*
|
|
501
|
+
* This function should be called in your OAuth callback route after
|
|
502
|
+
* the user is redirected back from Apple's authentication page.
|
|
503
|
+
*/
|
|
504
|
+
declare function handleAppleCallback(code: string, state: string, inviteCode: string): Promise<LoginResponse>;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Handles native Apple Sign-In for iOS devices
|
|
508
|
+
* @param appleUser - Apple user data from the native Sign in with Apple API
|
|
509
|
+
* @param client_id - The client ID for your OpenSecret project
|
|
510
|
+
* @param inviteCode - Optional invite code for new user registration
|
|
511
|
+
* @returns A promise resolving to login response with access and refresh tokens
|
|
512
|
+
* @description
|
|
513
|
+
* This function is specifically for use with iOS native Sign in with Apple:
|
|
514
|
+
* 1. Validates the Apple identity token and user information
|
|
515
|
+
* 2. Creates or authenticates the user account
|
|
516
|
+
* 3. Returns authentication tokens
|
|
517
|
+
*
|
|
518
|
+
* Unlike OAuth flow, this method doesn't require redirects and is used
|
|
519
|
+
* directly with the credential data from Apple's native authentication.
|
|
520
|
+
*
|
|
521
|
+
* Note: Email and name information are only provided by Apple on the first
|
|
522
|
+
* authentication. Your backend should store this information for future use.
|
|
523
|
+
*
|
|
524
|
+
* The nonce parameter (optional) can be provided as part of the appleUser object.
|
|
525
|
+
* When using Sign in with Apple, you can generate a nonce on your client and pass
|
|
526
|
+
* it both to Apple during authentication initiation and to this function for validation.
|
|
527
|
+
* The backend will verify that the nonce in the JWT matches what was provided.
|
|
528
|
+
*/
|
|
529
|
+
declare function handleAppleNativeSignIn(appleUser: AppleUser, client_id: string, inviteCode?: string): Promise<LoginResponse>;
|
|
530
|
+
|
|
456
531
|
declare function handleGitHubCallback(code: string, state: string, inviteCode: string): Promise<LoginResponse>;
|
|
457
532
|
|
|
458
533
|
declare function handleGoogleCallback(code: string, state: string, inviteCode: string): Promise<LoginResponse>;
|
|
459
534
|
|
|
460
535
|
export declare function hashSecret(secret: string): Promise<string>;
|
|
461
536
|
|
|
537
|
+
/**
|
|
538
|
+
* Initiates Apple OAuth authentication flow
|
|
539
|
+
* @param client_id - The client ID for your OpenSecret project
|
|
540
|
+
* @param inviteCode - Optional invite code for new user registration
|
|
541
|
+
* @returns A promise resolving to the Apple auth response containing auth URL and state
|
|
542
|
+
* @description
|
|
543
|
+
* This function starts the Apple OAuth authentication process by:
|
|
544
|
+
* 1. Generating a secure state parameter to prevent CSRF attacks
|
|
545
|
+
* 2. Getting an authorization URL from the OpenSecret backend
|
|
546
|
+
* 3. Returning the URL that the client should redirect to
|
|
547
|
+
*
|
|
548
|
+
* After the user authenticates with Apple, they will be redirected back to your application.
|
|
549
|
+
* The handleAppleCallback function should be used to complete the authentication process.
|
|
550
|
+
*/
|
|
551
|
+
declare function initiateAppleAuth(client_id: string, inviteCode?: string): Promise<AppleAuthResponse>;
|
|
552
|
+
|
|
462
553
|
declare function initiateGitHubAuth(client_id: string, inviteCode?: string): Promise<GithubAuthResponse>;
|
|
463
554
|
|
|
464
555
|
declare function initiateGoogleAuth(client_id: string, inviteCode?: string): Promise<GoogleAuthResponse>;
|
|
@@ -526,8 +617,10 @@ declare type OAuthProviderSettings = {
|
|
|
526
617
|
declare type OAuthSettings = {
|
|
527
618
|
google_oauth_enabled: boolean;
|
|
528
619
|
github_oauth_enabled: boolean;
|
|
620
|
+
apple_oauth_enabled: boolean;
|
|
529
621
|
google_oauth_settings?: OAuthProviderSettings;
|
|
530
622
|
github_oauth_settings?: OAuthProviderSettings;
|
|
623
|
+
apple_oauth_settings?: OAuthProviderSettings;
|
|
531
624
|
};
|
|
532
625
|
|
|
533
626
|
export declare type OpenSecretAuthState = {
|
|
@@ -540,22 +633,22 @@ export declare const OpenSecretContext: default_2.Context<OpenSecretContextType>
|
|
|
540
633
|
export declare type OpenSecretContextType = {
|
|
541
634
|
auth: OpenSecretAuthState;
|
|
542
635
|
/**
|
|
543
|
-
* The client ID for this project/tenant
|
|
544
|
-
*
|
|
636
|
+
* The client ID for this project/tenant.
|
|
637
|
+
* A UUID that identifies which project/tenant this instance belongs to.
|
|
545
638
|
*/
|
|
546
639
|
clientId: string;
|
|
547
640
|
/**
|
|
548
|
-
* Authenticates a user with email and password
|
|
549
|
-
* @param email - User's email address
|
|
550
|
-
* @param password - User's password
|
|
551
|
-
* @returns A promise that resolves when authentication is complete
|
|
552
|
-
* @throws {Error} If login fails
|
|
641
|
+
* Authenticates a user with email and password.
|
|
553
642
|
*
|
|
554
|
-
* @description
|
|
555
643
|
* - Calls the login API endpoint with the configured clientId
|
|
556
644
|
* - Stores access_token and refresh_token in localStorage
|
|
557
645
|
* - Updates the auth state with user information
|
|
558
646
|
* - Throws an error if authentication fails
|
|
647
|
+
*
|
|
648
|
+
* @param email - User's email address
|
|
649
|
+
* @param password - User's password
|
|
650
|
+
* @returns A promise that resolves when authentication is complete
|
|
651
|
+
* @throws {Error} If login fails
|
|
559
652
|
*/
|
|
560
653
|
signIn: (email: string, password: string) => Promise<void>;
|
|
561
654
|
/**
|
|
@@ -567,7 +660,7 @@ export declare type OpenSecretContextType = {
|
|
|
567
660
|
* @returns A promise that resolves when account creation is complete
|
|
568
661
|
* @throws {Error} If signup fails
|
|
569
662
|
*
|
|
570
|
-
*
|
|
663
|
+
*
|
|
571
664
|
* - Calls the registration API endpoint
|
|
572
665
|
* - Stores access_token and refresh_token in localStorage
|
|
573
666
|
* - Updates the auth state with new user information
|
|
@@ -581,7 +674,7 @@ export declare type OpenSecretContextType = {
|
|
|
581
674
|
* @returns A promise that resolves when authentication is complete
|
|
582
675
|
* @throws {Error} If login fails
|
|
583
676
|
*
|
|
584
|
-
*
|
|
677
|
+
*
|
|
585
678
|
* - Calls the login API endpoint
|
|
586
679
|
* - Stores access_token and refresh_token in localStorage
|
|
587
680
|
* - Updates the auth state with user information
|
|
@@ -595,7 +688,7 @@ export declare type OpenSecretContextType = {
|
|
|
595
688
|
* @returns A promise that resolves to the login response containing the guest ID
|
|
596
689
|
* @throws {Error} If signup fails
|
|
597
690
|
*
|
|
598
|
-
*
|
|
691
|
+
*
|
|
599
692
|
* - Calls the registration API endpoint
|
|
600
693
|
* - Stores access_token and refresh_token in localStorage
|
|
601
694
|
* - Updates the auth state with new user information
|
|
@@ -613,7 +706,7 @@ export declare type OpenSecretContextType = {
|
|
|
613
706
|
* - The email address is already in use
|
|
614
707
|
* - The user is not authenticated
|
|
615
708
|
*
|
|
616
|
-
*
|
|
709
|
+
*
|
|
617
710
|
* - Upgrades the currently signed-in guest account (identified by their UUID) to a full email account
|
|
618
711
|
* - Requires the user to be currently authenticated as a guest
|
|
619
712
|
* - Updates the auth state with new user information
|
|
@@ -625,7 +718,7 @@ export declare type OpenSecretContextType = {
|
|
|
625
718
|
* @returns A promise that resolves when logout is complete
|
|
626
719
|
* @throws {Error} If logout fails
|
|
627
720
|
*
|
|
628
|
-
*
|
|
721
|
+
*
|
|
629
722
|
* - Calls the logout API endpoint with the current refresh_token
|
|
630
723
|
* - Removes access_token, refresh_token from localStorage
|
|
631
724
|
* - Removes session-related items from sessionStorage
|
|
@@ -638,7 +731,7 @@ export declare type OpenSecretContextType = {
|
|
|
638
731
|
* @returns A promise resolving to the stored value
|
|
639
732
|
* @throws {Error} If the key cannot be retrieved
|
|
640
733
|
*
|
|
641
|
-
*
|
|
734
|
+
*
|
|
642
735
|
* - Calls the authenticated API endpoint to fetch a value
|
|
643
736
|
* - Returns undefined if the key does not exist
|
|
644
737
|
* - Requires an active authentication session
|
|
@@ -652,7 +745,7 @@ export declare type OpenSecretContextType = {
|
|
|
652
745
|
* @returns A promise resolving to the server's response
|
|
653
746
|
* @throws {Error} If the value cannot be stored
|
|
654
747
|
*
|
|
655
|
-
*
|
|
748
|
+
*
|
|
656
749
|
* - Calls the authenticated API endpoint to store a value
|
|
657
750
|
* - Requires an active authentication session
|
|
658
751
|
* - Overwrites any existing value for the given key
|
|
@@ -664,7 +757,7 @@ export declare type OpenSecretContextType = {
|
|
|
664
757
|
* @returns A promise resolving to an array of stored items
|
|
665
758
|
* @throws {Error} If the list cannot be retrieved
|
|
666
759
|
*
|
|
667
|
-
*
|
|
760
|
+
*
|
|
668
761
|
* - Calls the authenticated API endpoint to fetch all stored items
|
|
669
762
|
* - Returns an array of key-value pairs with metadata
|
|
670
763
|
* - Requires an active authentication session
|
|
@@ -678,7 +771,7 @@ export declare type OpenSecretContextType = {
|
|
|
678
771
|
* @returns A promise resolving when the deletion is complete
|
|
679
772
|
* @throws {Error} If the key cannot be deleted
|
|
680
773
|
*
|
|
681
|
-
*
|
|
774
|
+
*
|
|
682
775
|
* - Calls the authenticated API endpoint to remove a specific key
|
|
683
776
|
* - Requires an active authentication session
|
|
684
777
|
* - Throws an error if the deletion fails (including for non-existent keys)
|
|
@@ -697,13 +790,16 @@ export declare type OpenSecretContextType = {
|
|
|
697
790
|
handleGitHubCallback: (code: string, state: string, inviteCode: string) => Promise<void>;
|
|
698
791
|
initiateGoogleAuth: (inviteCode: string) => Promise<api.GoogleAuthResponse>;
|
|
699
792
|
handleGoogleCallback: (code: string, state: string, inviteCode: string) => Promise<void>;
|
|
793
|
+
initiateAppleAuth: (inviteCode: string) => Promise<api.AppleAuthResponse>;
|
|
794
|
+
handleAppleCallback: (code: string, state: string, inviteCode: string) => Promise<void>;
|
|
795
|
+
handleAppleNativeSignIn: (appleUser: api.AppleUser, inviteCode?: string) => Promise<void>;
|
|
700
796
|
/**
|
|
701
797
|
* Retrieves the user's private key mnemonic phrase
|
|
702
798
|
* @param options - Optional key derivation options
|
|
703
799
|
* @returns A promise resolving to the private key response
|
|
704
800
|
* @throws {Error} If the private key cannot be retrieved
|
|
705
801
|
*
|
|
706
|
-
*
|
|
802
|
+
*
|
|
707
803
|
* This function supports two modes:
|
|
708
804
|
*
|
|
709
805
|
* 1. Master mnemonic (no parameters)
|
|
@@ -723,7 +819,7 @@ export declare type OpenSecretContextType = {
|
|
|
723
819
|
* - The private key bytes cannot be retrieved
|
|
724
820
|
* - The derivation paths are invalid
|
|
725
821
|
*
|
|
726
|
-
*
|
|
822
|
+
*
|
|
727
823
|
* This function supports multiple derivation approaches:
|
|
728
824
|
*
|
|
729
825
|
* 1. Master key only (no parameters)
|
|
@@ -758,7 +854,7 @@ export declare type OpenSecretContextType = {
|
|
|
758
854
|
* @returns A promise resolving to the public key response
|
|
759
855
|
* @throws {Error} If the public key cannot be retrieved
|
|
760
856
|
*
|
|
761
|
-
*
|
|
857
|
+
*
|
|
762
858
|
* The derivation paths determine which key is used to generate the public key:
|
|
763
859
|
*
|
|
764
860
|
* 1. Master key (no derivation parameters)
|
|
@@ -776,27 +872,15 @@ export declare type OpenSecretContextType = {
|
|
|
776
872
|
*/
|
|
777
873
|
getPublicKey: typeof api.fetchPublicKey;
|
|
778
874
|
/**
|
|
779
|
-
* Signs a message using the specified algorithm
|
|
875
|
+
* Signs a message using the specified algorithm.
|
|
876
|
+
* This function supports multiple signing approaches: master key (no derivation),
|
|
877
|
+
* BIP-32 derived key, BIP-85 derived key, or combined BIP-85 and BIP-32 derivation.
|
|
878
|
+
*
|
|
780
879
|
* @param messageBytes - The message to sign as a Uint8Array
|
|
781
880
|
* @param algorithm - The signing algorithm ('schnorr' or 'ecdsa')
|
|
782
881
|
* @param options - Optional key derivation options or legacy BIP32 derivation path string
|
|
783
882
|
* @returns A promise resolving to the signature response
|
|
784
883
|
* @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
|
|
800
884
|
*/
|
|
801
885
|
signMessage: typeof api.signMessage;
|
|
802
886
|
/**
|
|
@@ -853,7 +937,7 @@ export declare type OpenSecretContextType = {
|
|
|
853
937
|
* @returns A promise resolving to the parsed attestation document
|
|
854
938
|
* @throws {Error} If attestation fails or is invalid
|
|
855
939
|
*
|
|
856
|
-
*
|
|
940
|
+
*
|
|
857
941
|
* This is a convenience function that:
|
|
858
942
|
* 1. Fetches the attestation document with a random nonce
|
|
859
943
|
* 2. Authenticates the document
|
|
@@ -868,7 +952,7 @@ export declare type OpenSecretContextType = {
|
|
|
868
952
|
* - The user is not authenticated
|
|
869
953
|
* - The audience URL is invalid (if provided)
|
|
870
954
|
*
|
|
871
|
-
*
|
|
955
|
+
*
|
|
872
956
|
* - Generates a signed JWT token for use with third-party services
|
|
873
957
|
* - If audience is provided, it can be any valid URL
|
|
874
958
|
* - If audience is omitted, a token with no audience restriction will be generated
|
|
@@ -886,25 +970,25 @@ export declare type OpenSecretContextType = {
|
|
|
886
970
|
* - Authentication fails
|
|
887
971
|
* - Server-side encryption error occurs
|
|
888
972
|
*
|
|
889
|
-
*
|
|
973
|
+
*
|
|
890
974
|
* This function supports multiple encryption approaches:
|
|
891
975
|
*
|
|
892
976
|
* 1. Encrypt with master key (no derivation parameters)
|
|
893
977
|
*
|
|
894
978
|
* 2. Encrypt with BIP-32 derived key
|
|
895
979
|
* - Derives a child key from the master seed using BIP-32
|
|
896
|
-
* - Example: "m/44'/0'/0'/0/0"
|
|
980
|
+
* - Example: "m/44\'/0\'/0\'/0/0"
|
|
897
981
|
*
|
|
898
982
|
* 3. Encrypt with BIP-85 derived key
|
|
899
983
|
* - Derives a child mnemonic using BIP-85, then uses its master key
|
|
900
|
-
* - Example: { seed_phrase_derivation_path: "m/83696968'/39'/0'/12'/0'" }
|
|
984
|
+
* - Example: { seed_phrase_derivation_path: "m/83696968\'/39\'/0\'/12\'/0\'" }
|
|
901
985
|
*
|
|
902
986
|
* 4. Encrypt with combined BIP-85 and BIP-32 derivation
|
|
903
987
|
* - First derives a child mnemonic via BIP-85
|
|
904
988
|
* - Then applies BIP-32 derivation to derive a key from that seed
|
|
905
989
|
* - Example: {
|
|
906
|
-
* seed_phrase_derivation_path: "m/83696968'/39'/0'/12'/0'",
|
|
907
|
-
* private_key_derivation_path: "m/44'/0'/0'/0/0"
|
|
990
|
+
* seed_phrase_derivation_path: "m/83696968\'/39\'/0\'/12\'/0\'",
|
|
991
|
+
* private_key_derivation_path: "m/44\'/0\'/0\'/0/0"
|
|
908
992
|
* }
|
|
909
993
|
*
|
|
910
994
|
* Technical details:
|
|
@@ -924,7 +1008,7 @@ export declare type OpenSecretContextType = {
|
|
|
924
1008
|
* - Authentication fails
|
|
925
1009
|
* - Server-side decryption error occurs
|
|
926
1010
|
*
|
|
927
|
-
*
|
|
1011
|
+
*
|
|
928
1012
|
* This function supports multiple decryption approaches:
|
|
929
1013
|
*
|
|
930
1014
|
* 1. Decrypt with master key (no derivation parameters)
|
|
@@ -983,7 +1067,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
983
1067
|
* @param password - Developer's password
|
|
984
1068
|
* @returns A promise that resolves to the login response with access and refresh tokens
|
|
985
1069
|
*
|
|
986
|
-
*
|
|
1070
|
+
*
|
|
987
1071
|
* - Calls the login API endpoint
|
|
988
1072
|
* - Stores access_token and refresh_token in localStorage
|
|
989
1073
|
* - Updates the developer state with user information
|
|
@@ -996,7 +1080,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
996
1080
|
* @returns A promise that resolves when verification is complete
|
|
997
1081
|
* @throws {Error} If verification fails
|
|
998
1082
|
*
|
|
999
|
-
*
|
|
1083
|
+
*
|
|
1000
1084
|
* - Takes the verification code from the verification email link
|
|
1001
1085
|
* - Calls the verification API endpoint
|
|
1002
1086
|
* - Updates email_verified status if successful
|
|
@@ -1007,7 +1091,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1007
1091
|
* @returns A promise that resolves to a success message
|
|
1008
1092
|
* @throws {Error} If the user is already verified or request fails
|
|
1009
1093
|
*
|
|
1010
|
-
*
|
|
1094
|
+
*
|
|
1011
1095
|
* - Used when the user needs a new verification email
|
|
1012
1096
|
* - Requires the user to be authenticated
|
|
1013
1097
|
* - Sends a new verification email to the user's registered email address
|
|
@@ -1024,7 +1108,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1024
1108
|
* @returns A promise that resolves when the reset request is successfully processed
|
|
1025
1109
|
* @throws {Error} If the request fails or the email doesn't exist
|
|
1026
1110
|
*
|
|
1027
|
-
*
|
|
1111
|
+
*
|
|
1028
1112
|
* - Sends a password reset request for a platform developer
|
|
1029
1113
|
* - The server will send an email with an alphanumeric code
|
|
1030
1114
|
* - The email and hashed_secret are paired for the reset process
|
|
@@ -1040,7 +1124,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1040
1124
|
* @returns A promise that resolves when the password is successfully reset
|
|
1041
1125
|
* @throws {Error} If the verification fails or the request is invalid
|
|
1042
1126
|
*
|
|
1043
|
-
*
|
|
1127
|
+
*
|
|
1044
1128
|
* - Completes the password reset process using the code from the email
|
|
1045
1129
|
* - Requires the plaintext_secret that matches the previously sent hashed_secret
|
|
1046
1130
|
* - Sets the new password if all verification succeeds
|
|
@@ -1054,7 +1138,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1054
1138
|
* @returns A promise that resolves when the password is successfully changed
|
|
1055
1139
|
* @throws {Error} If current password is incorrect or the request fails
|
|
1056
1140
|
*
|
|
1057
|
-
*
|
|
1141
|
+
*
|
|
1058
1142
|
* - Requires the user to be authenticated
|
|
1059
1143
|
* - Verifies the current password before allowing the change
|
|
1060
1144
|
* - Updates to the new password if verification succeeds
|
|
@@ -1068,7 +1152,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1068
1152
|
* @param name - Optional developer name
|
|
1069
1153
|
* @returns A promise that resolves to the login response with access and refresh tokens
|
|
1070
1154
|
*
|
|
1071
|
-
*
|
|
1155
|
+
*
|
|
1072
1156
|
* - Calls the registration API endpoint
|
|
1073
1157
|
* - Stores access_token and refresh_token in localStorage
|
|
1074
1158
|
* - Updates the developer state with new user information
|
|
@@ -1078,7 +1162,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1078
1162
|
/**
|
|
1079
1163
|
* Signs out the current developer by removing authentication tokens
|
|
1080
1164
|
*
|
|
1081
|
-
*
|
|
1165
|
+
*
|
|
1082
1166
|
* - Calls the logout API endpoint with the current refresh_token
|
|
1083
1167
|
* - Removes access_token, refresh_token from localStorage
|
|
1084
1168
|
* - Resets the developer state to show no user is authenticated
|
|
@@ -1089,7 +1173,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1089
1173
|
* @returns A promise that resolves when the refresh is complete
|
|
1090
1174
|
* @throws {Error} If the refresh fails
|
|
1091
1175
|
*
|
|
1092
|
-
*
|
|
1176
|
+
*
|
|
1093
1177
|
* - Retrieves the latest developer information from the server
|
|
1094
1178
|
* - Updates the developer state with fresh data
|
|
1095
1179
|
* - Useful after making changes that affect developer profile or organization membership
|
|
@@ -1124,7 +1208,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1124
1208
|
* @returns A promise resolving to the parsed attestation document
|
|
1125
1209
|
* @throws {Error} If attestation fails or is invalid
|
|
1126
1210
|
*
|
|
1127
|
-
*
|
|
1211
|
+
*
|
|
1128
1212
|
* This is a convenience function that:
|
|
1129
1213
|
* 1. Fetches the attestation document with a random nonce
|
|
1130
1214
|
* 2. Authenticates the document
|