@opensecret/react 1.2.0 → 1.3.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 +98 -0
- package/dist/index.d.ts +131 -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,32 @@ 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
|
+
*/
|
|
133
|
+
declare type AppleUser = {
|
|
134
|
+
user_identifier: string;
|
|
135
|
+
identity_token: string;
|
|
136
|
+
email?: string;
|
|
137
|
+
given_name?: string;
|
|
138
|
+
family_name?: string;
|
|
139
|
+
};
|
|
140
|
+
|
|
110
141
|
declare interface Attestation {
|
|
111
142
|
sessionKey: Uint8Array | null;
|
|
112
143
|
sessionId: string | null;
|
|
@@ -453,12 +484,65 @@ export declare type GoogleAuthResponse = {
|
|
|
453
484
|
csrf_token: string;
|
|
454
485
|
};
|
|
455
486
|
|
|
487
|
+
/**
|
|
488
|
+
* Completes Apple OAuth authentication after user is redirected back to your app
|
|
489
|
+
* @param code - The authorization code from Apple
|
|
490
|
+
* @param state - The state parameter returned by Apple (should match the original state)
|
|
491
|
+
* @param inviteCode - Invite code for new user registration
|
|
492
|
+
* @returns A promise resolving to login response with access and refresh tokens
|
|
493
|
+
* @description
|
|
494
|
+
* This function completes the Apple OAuth authentication process by:
|
|
495
|
+
* 1. Validating the state parameter to prevent CSRF attacks
|
|
496
|
+
* 2. Exchanging the authorization code for tokens
|
|
497
|
+
* 3. Creating or authenticating the user account
|
|
498
|
+
*
|
|
499
|
+
* This function should be called in your OAuth callback route after
|
|
500
|
+
* the user is redirected back from Apple's authentication page.
|
|
501
|
+
*/
|
|
502
|
+
declare function handleAppleCallback(code: string, state: string, inviteCode: string): Promise<LoginResponse>;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Handles native Apple Sign-In for iOS devices
|
|
506
|
+
* @param appleUser - Apple user data from the native Sign in with Apple API
|
|
507
|
+
* @param client_id - The client ID for your OpenSecret project
|
|
508
|
+
* @param inviteCode - Optional invite code for new user registration
|
|
509
|
+
* @returns A promise resolving to login response with access and refresh tokens
|
|
510
|
+
* @description
|
|
511
|
+
* This function is specifically for use with iOS native Sign in with Apple:
|
|
512
|
+
* 1. Validates the Apple identity token and user information
|
|
513
|
+
* 2. Creates or authenticates the user account
|
|
514
|
+
* 3. Returns authentication tokens
|
|
515
|
+
*
|
|
516
|
+
* Unlike OAuth flow, this method doesn't require redirects and is used
|
|
517
|
+
* directly with the credential data from Apple's native authentication.
|
|
518
|
+
*
|
|
519
|
+
* Note: Email and name information are only provided by Apple on the first
|
|
520
|
+
* authentication. Your backend should store this information for future use.
|
|
521
|
+
*/
|
|
522
|
+
declare function handleAppleNativeSignIn(appleUser: AppleUser, client_id: string, inviteCode?: string): Promise<LoginResponse>;
|
|
523
|
+
|
|
456
524
|
declare function handleGitHubCallback(code: string, state: string, inviteCode: string): Promise<LoginResponse>;
|
|
457
525
|
|
|
458
526
|
declare function handleGoogleCallback(code: string, state: string, inviteCode: string): Promise<LoginResponse>;
|
|
459
527
|
|
|
460
528
|
export declare function hashSecret(secret: string): Promise<string>;
|
|
461
529
|
|
|
530
|
+
/**
|
|
531
|
+
* Initiates Apple OAuth authentication flow
|
|
532
|
+
* @param client_id - The client ID for your OpenSecret project
|
|
533
|
+
* @param inviteCode - Optional invite code for new user registration
|
|
534
|
+
* @returns A promise resolving to the Apple auth response containing auth URL and state
|
|
535
|
+
* @description
|
|
536
|
+
* This function starts the Apple OAuth authentication process by:
|
|
537
|
+
* 1. Generating a secure state parameter to prevent CSRF attacks
|
|
538
|
+
* 2. Getting an authorization URL from the OpenSecret backend
|
|
539
|
+
* 3. Returning the URL that the client should redirect to
|
|
540
|
+
*
|
|
541
|
+
* After the user authenticates with Apple, they will be redirected back to your application.
|
|
542
|
+
* The handleAppleCallback function should be used to complete the authentication process.
|
|
543
|
+
*/
|
|
544
|
+
declare function initiateAppleAuth(client_id: string, inviteCode?: string): Promise<AppleAuthResponse>;
|
|
545
|
+
|
|
462
546
|
declare function initiateGitHubAuth(client_id: string, inviteCode?: string): Promise<GithubAuthResponse>;
|
|
463
547
|
|
|
464
548
|
declare function initiateGoogleAuth(client_id: string, inviteCode?: string): Promise<GoogleAuthResponse>;
|
|
@@ -526,8 +610,10 @@ declare type OAuthProviderSettings = {
|
|
|
526
610
|
declare type OAuthSettings = {
|
|
527
611
|
google_oauth_enabled: boolean;
|
|
528
612
|
github_oauth_enabled: boolean;
|
|
613
|
+
apple_oauth_enabled: boolean;
|
|
529
614
|
google_oauth_settings?: OAuthProviderSettings;
|
|
530
615
|
github_oauth_settings?: OAuthProviderSettings;
|
|
616
|
+
apple_oauth_settings?: OAuthProviderSettings;
|
|
531
617
|
};
|
|
532
618
|
|
|
533
619
|
export declare type OpenSecretAuthState = {
|
|
@@ -540,22 +626,22 @@ export declare const OpenSecretContext: default_2.Context<OpenSecretContextType>
|
|
|
540
626
|
export declare type OpenSecretContextType = {
|
|
541
627
|
auth: OpenSecretAuthState;
|
|
542
628
|
/**
|
|
543
|
-
* The client ID for this project/tenant
|
|
544
|
-
*
|
|
629
|
+
* The client ID for this project/tenant.
|
|
630
|
+
* A UUID that identifies which project/tenant this instance belongs to.
|
|
545
631
|
*/
|
|
546
632
|
clientId: string;
|
|
547
633
|
/**
|
|
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
|
|
634
|
+
* Authenticates a user with email and password.
|
|
553
635
|
*
|
|
554
|
-
* @description
|
|
555
636
|
* - Calls the login API endpoint with the configured clientId
|
|
556
637
|
* - Stores access_token and refresh_token in localStorage
|
|
557
638
|
* - Updates the auth state with user information
|
|
558
639
|
* - Throws an error if authentication fails
|
|
640
|
+
*
|
|
641
|
+
* @param email - User's email address
|
|
642
|
+
* @param password - User's password
|
|
643
|
+
* @returns A promise that resolves when authentication is complete
|
|
644
|
+
* @throws {Error} If login fails
|
|
559
645
|
*/
|
|
560
646
|
signIn: (email: string, password: string) => Promise<void>;
|
|
561
647
|
/**
|
|
@@ -567,7 +653,7 @@ export declare type OpenSecretContextType = {
|
|
|
567
653
|
* @returns A promise that resolves when account creation is complete
|
|
568
654
|
* @throws {Error} If signup fails
|
|
569
655
|
*
|
|
570
|
-
*
|
|
656
|
+
*
|
|
571
657
|
* - Calls the registration API endpoint
|
|
572
658
|
* - Stores access_token and refresh_token in localStorage
|
|
573
659
|
* - Updates the auth state with new user information
|
|
@@ -581,7 +667,7 @@ export declare type OpenSecretContextType = {
|
|
|
581
667
|
* @returns A promise that resolves when authentication is complete
|
|
582
668
|
* @throws {Error} If login fails
|
|
583
669
|
*
|
|
584
|
-
*
|
|
670
|
+
*
|
|
585
671
|
* - Calls the login API endpoint
|
|
586
672
|
* - Stores access_token and refresh_token in localStorage
|
|
587
673
|
* - Updates the auth state with user information
|
|
@@ -595,7 +681,7 @@ export declare type OpenSecretContextType = {
|
|
|
595
681
|
* @returns A promise that resolves to the login response containing the guest ID
|
|
596
682
|
* @throws {Error} If signup fails
|
|
597
683
|
*
|
|
598
|
-
*
|
|
684
|
+
*
|
|
599
685
|
* - Calls the registration API endpoint
|
|
600
686
|
* - Stores access_token and refresh_token in localStorage
|
|
601
687
|
* - Updates the auth state with new user information
|
|
@@ -613,7 +699,7 @@ export declare type OpenSecretContextType = {
|
|
|
613
699
|
* - The email address is already in use
|
|
614
700
|
* - The user is not authenticated
|
|
615
701
|
*
|
|
616
|
-
*
|
|
702
|
+
*
|
|
617
703
|
* - Upgrades the currently signed-in guest account (identified by their UUID) to a full email account
|
|
618
704
|
* - Requires the user to be currently authenticated as a guest
|
|
619
705
|
* - Updates the auth state with new user information
|
|
@@ -625,7 +711,7 @@ export declare type OpenSecretContextType = {
|
|
|
625
711
|
* @returns A promise that resolves when logout is complete
|
|
626
712
|
* @throws {Error} If logout fails
|
|
627
713
|
*
|
|
628
|
-
*
|
|
714
|
+
*
|
|
629
715
|
* - Calls the logout API endpoint with the current refresh_token
|
|
630
716
|
* - Removes access_token, refresh_token from localStorage
|
|
631
717
|
* - Removes session-related items from sessionStorage
|
|
@@ -638,7 +724,7 @@ export declare type OpenSecretContextType = {
|
|
|
638
724
|
* @returns A promise resolving to the stored value
|
|
639
725
|
* @throws {Error} If the key cannot be retrieved
|
|
640
726
|
*
|
|
641
|
-
*
|
|
727
|
+
*
|
|
642
728
|
* - Calls the authenticated API endpoint to fetch a value
|
|
643
729
|
* - Returns undefined if the key does not exist
|
|
644
730
|
* - Requires an active authentication session
|
|
@@ -652,7 +738,7 @@ export declare type OpenSecretContextType = {
|
|
|
652
738
|
* @returns A promise resolving to the server's response
|
|
653
739
|
* @throws {Error} If the value cannot be stored
|
|
654
740
|
*
|
|
655
|
-
*
|
|
741
|
+
*
|
|
656
742
|
* - Calls the authenticated API endpoint to store a value
|
|
657
743
|
* - Requires an active authentication session
|
|
658
744
|
* - Overwrites any existing value for the given key
|
|
@@ -664,7 +750,7 @@ export declare type OpenSecretContextType = {
|
|
|
664
750
|
* @returns A promise resolving to an array of stored items
|
|
665
751
|
* @throws {Error} If the list cannot be retrieved
|
|
666
752
|
*
|
|
667
|
-
*
|
|
753
|
+
*
|
|
668
754
|
* - Calls the authenticated API endpoint to fetch all stored items
|
|
669
755
|
* - Returns an array of key-value pairs with metadata
|
|
670
756
|
* - Requires an active authentication session
|
|
@@ -678,7 +764,7 @@ export declare type OpenSecretContextType = {
|
|
|
678
764
|
* @returns A promise resolving when the deletion is complete
|
|
679
765
|
* @throws {Error} If the key cannot be deleted
|
|
680
766
|
*
|
|
681
|
-
*
|
|
767
|
+
*
|
|
682
768
|
* - Calls the authenticated API endpoint to remove a specific key
|
|
683
769
|
* - Requires an active authentication session
|
|
684
770
|
* - Throws an error if the deletion fails (including for non-existent keys)
|
|
@@ -697,13 +783,16 @@ export declare type OpenSecretContextType = {
|
|
|
697
783
|
handleGitHubCallback: (code: string, state: string, inviteCode: string) => Promise<void>;
|
|
698
784
|
initiateGoogleAuth: (inviteCode: string) => Promise<api.GoogleAuthResponse>;
|
|
699
785
|
handleGoogleCallback: (code: string, state: string, inviteCode: string) => Promise<void>;
|
|
786
|
+
initiateAppleAuth: (inviteCode: string) => Promise<api.AppleAuthResponse>;
|
|
787
|
+
handleAppleCallback: (code: string, state: string, inviteCode: string) => Promise<void>;
|
|
788
|
+
handleAppleNativeSignIn: (appleUser: api.AppleUser, inviteCode?: string) => Promise<void>;
|
|
700
789
|
/**
|
|
701
790
|
* Retrieves the user's private key mnemonic phrase
|
|
702
791
|
* @param options - Optional key derivation options
|
|
703
792
|
* @returns A promise resolving to the private key response
|
|
704
793
|
* @throws {Error} If the private key cannot be retrieved
|
|
705
794
|
*
|
|
706
|
-
*
|
|
795
|
+
*
|
|
707
796
|
* This function supports two modes:
|
|
708
797
|
*
|
|
709
798
|
* 1. Master mnemonic (no parameters)
|
|
@@ -723,7 +812,7 @@ export declare type OpenSecretContextType = {
|
|
|
723
812
|
* - The private key bytes cannot be retrieved
|
|
724
813
|
* - The derivation paths are invalid
|
|
725
814
|
*
|
|
726
|
-
*
|
|
815
|
+
*
|
|
727
816
|
* This function supports multiple derivation approaches:
|
|
728
817
|
*
|
|
729
818
|
* 1. Master key only (no parameters)
|
|
@@ -758,7 +847,7 @@ export declare type OpenSecretContextType = {
|
|
|
758
847
|
* @returns A promise resolving to the public key response
|
|
759
848
|
* @throws {Error} If the public key cannot be retrieved
|
|
760
849
|
*
|
|
761
|
-
*
|
|
850
|
+
*
|
|
762
851
|
* The derivation paths determine which key is used to generate the public key:
|
|
763
852
|
*
|
|
764
853
|
* 1. Master key (no derivation parameters)
|
|
@@ -776,27 +865,15 @@ export declare type OpenSecretContextType = {
|
|
|
776
865
|
*/
|
|
777
866
|
getPublicKey: typeof api.fetchPublicKey;
|
|
778
867
|
/**
|
|
779
|
-
* Signs a message using the specified algorithm
|
|
868
|
+
* Signs a message using the specified algorithm.
|
|
869
|
+
* This function supports multiple signing approaches: master key (no derivation),
|
|
870
|
+
* BIP-32 derived key, BIP-85 derived key, or combined BIP-85 and BIP-32 derivation.
|
|
871
|
+
*
|
|
780
872
|
* @param messageBytes - The message to sign as a Uint8Array
|
|
781
873
|
* @param algorithm - The signing algorithm ('schnorr' or 'ecdsa')
|
|
782
874
|
* @param options - Optional key derivation options or legacy BIP32 derivation path string
|
|
783
875
|
* @returns A promise resolving to the signature response
|
|
784
876
|
* @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
877
|
*/
|
|
801
878
|
signMessage: typeof api.signMessage;
|
|
802
879
|
/**
|
|
@@ -853,7 +930,7 @@ export declare type OpenSecretContextType = {
|
|
|
853
930
|
* @returns A promise resolving to the parsed attestation document
|
|
854
931
|
* @throws {Error} If attestation fails or is invalid
|
|
855
932
|
*
|
|
856
|
-
*
|
|
933
|
+
*
|
|
857
934
|
* This is a convenience function that:
|
|
858
935
|
* 1. Fetches the attestation document with a random nonce
|
|
859
936
|
* 2. Authenticates the document
|
|
@@ -868,7 +945,7 @@ export declare type OpenSecretContextType = {
|
|
|
868
945
|
* - The user is not authenticated
|
|
869
946
|
* - The audience URL is invalid (if provided)
|
|
870
947
|
*
|
|
871
|
-
*
|
|
948
|
+
*
|
|
872
949
|
* - Generates a signed JWT token for use with third-party services
|
|
873
950
|
* - If audience is provided, it can be any valid URL
|
|
874
951
|
* - If audience is omitted, a token with no audience restriction will be generated
|
|
@@ -886,25 +963,25 @@ export declare type OpenSecretContextType = {
|
|
|
886
963
|
* - Authentication fails
|
|
887
964
|
* - Server-side encryption error occurs
|
|
888
965
|
*
|
|
889
|
-
*
|
|
966
|
+
*
|
|
890
967
|
* This function supports multiple encryption approaches:
|
|
891
968
|
*
|
|
892
969
|
* 1. Encrypt with master key (no derivation parameters)
|
|
893
970
|
*
|
|
894
971
|
* 2. Encrypt with BIP-32 derived key
|
|
895
972
|
* - Derives a child key from the master seed using BIP-32
|
|
896
|
-
* - Example: "m/44'/0'/0'/0/0"
|
|
973
|
+
* - Example: "m/44\'/0\'/0\'/0/0"
|
|
897
974
|
*
|
|
898
975
|
* 3. Encrypt with BIP-85 derived key
|
|
899
976
|
* - Derives a child mnemonic using BIP-85, then uses its master key
|
|
900
|
-
* - Example: { seed_phrase_derivation_path: "m/83696968'/39'/0'/12'/0'" }
|
|
977
|
+
* - Example: { seed_phrase_derivation_path: "m/83696968\'/39\'/0\'/12\'/0\'" }
|
|
901
978
|
*
|
|
902
979
|
* 4. Encrypt with combined BIP-85 and BIP-32 derivation
|
|
903
980
|
* - First derives a child mnemonic via BIP-85
|
|
904
981
|
* - Then applies BIP-32 derivation to derive a key from that seed
|
|
905
982
|
* - Example: {
|
|
906
|
-
* seed_phrase_derivation_path: "m/83696968'/39'/0'/12'/0'",
|
|
907
|
-
* private_key_derivation_path: "m/44'/0'/0'/0/0"
|
|
983
|
+
* seed_phrase_derivation_path: "m/83696968\'/39\'/0\'/12\'/0\'",
|
|
984
|
+
* private_key_derivation_path: "m/44\'/0\'/0\'/0/0"
|
|
908
985
|
* }
|
|
909
986
|
*
|
|
910
987
|
* Technical details:
|
|
@@ -924,7 +1001,7 @@ export declare type OpenSecretContextType = {
|
|
|
924
1001
|
* - Authentication fails
|
|
925
1002
|
* - Server-side decryption error occurs
|
|
926
1003
|
*
|
|
927
|
-
*
|
|
1004
|
+
*
|
|
928
1005
|
* This function supports multiple decryption approaches:
|
|
929
1006
|
*
|
|
930
1007
|
* 1. Decrypt with master key (no derivation parameters)
|
|
@@ -983,7 +1060,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
983
1060
|
* @param password - Developer's password
|
|
984
1061
|
* @returns A promise that resolves to the login response with access and refresh tokens
|
|
985
1062
|
*
|
|
986
|
-
*
|
|
1063
|
+
*
|
|
987
1064
|
* - Calls the login API endpoint
|
|
988
1065
|
* - Stores access_token and refresh_token in localStorage
|
|
989
1066
|
* - Updates the developer state with user information
|
|
@@ -996,7 +1073,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
996
1073
|
* @returns A promise that resolves when verification is complete
|
|
997
1074
|
* @throws {Error} If verification fails
|
|
998
1075
|
*
|
|
999
|
-
*
|
|
1076
|
+
*
|
|
1000
1077
|
* - Takes the verification code from the verification email link
|
|
1001
1078
|
* - Calls the verification API endpoint
|
|
1002
1079
|
* - Updates email_verified status if successful
|
|
@@ -1007,7 +1084,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1007
1084
|
* @returns A promise that resolves to a success message
|
|
1008
1085
|
* @throws {Error} If the user is already verified or request fails
|
|
1009
1086
|
*
|
|
1010
|
-
*
|
|
1087
|
+
*
|
|
1011
1088
|
* - Used when the user needs a new verification email
|
|
1012
1089
|
* - Requires the user to be authenticated
|
|
1013
1090
|
* - Sends a new verification email to the user's registered email address
|
|
@@ -1024,7 +1101,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1024
1101
|
* @returns A promise that resolves when the reset request is successfully processed
|
|
1025
1102
|
* @throws {Error} If the request fails or the email doesn't exist
|
|
1026
1103
|
*
|
|
1027
|
-
*
|
|
1104
|
+
*
|
|
1028
1105
|
* - Sends a password reset request for a platform developer
|
|
1029
1106
|
* - The server will send an email with an alphanumeric code
|
|
1030
1107
|
* - The email and hashed_secret are paired for the reset process
|
|
@@ -1040,7 +1117,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1040
1117
|
* @returns A promise that resolves when the password is successfully reset
|
|
1041
1118
|
* @throws {Error} If the verification fails or the request is invalid
|
|
1042
1119
|
*
|
|
1043
|
-
*
|
|
1120
|
+
*
|
|
1044
1121
|
* - Completes the password reset process using the code from the email
|
|
1045
1122
|
* - Requires the plaintext_secret that matches the previously sent hashed_secret
|
|
1046
1123
|
* - Sets the new password if all verification succeeds
|
|
@@ -1054,7 +1131,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1054
1131
|
* @returns A promise that resolves when the password is successfully changed
|
|
1055
1132
|
* @throws {Error} If current password is incorrect or the request fails
|
|
1056
1133
|
*
|
|
1057
|
-
*
|
|
1134
|
+
*
|
|
1058
1135
|
* - Requires the user to be authenticated
|
|
1059
1136
|
* - Verifies the current password before allowing the change
|
|
1060
1137
|
* - Updates to the new password if verification succeeds
|
|
@@ -1068,7 +1145,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1068
1145
|
* @param name - Optional developer name
|
|
1069
1146
|
* @returns A promise that resolves to the login response with access and refresh tokens
|
|
1070
1147
|
*
|
|
1071
|
-
*
|
|
1148
|
+
*
|
|
1072
1149
|
* - Calls the registration API endpoint
|
|
1073
1150
|
* - Stores access_token and refresh_token in localStorage
|
|
1074
1151
|
* - Updates the developer state with new user information
|
|
@@ -1078,7 +1155,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1078
1155
|
/**
|
|
1079
1156
|
* Signs out the current developer by removing authentication tokens
|
|
1080
1157
|
*
|
|
1081
|
-
*
|
|
1158
|
+
*
|
|
1082
1159
|
* - Calls the logout API endpoint with the current refresh_token
|
|
1083
1160
|
* - Removes access_token, refresh_token from localStorage
|
|
1084
1161
|
* - Resets the developer state to show no user is authenticated
|
|
@@ -1089,7 +1166,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1089
1166
|
* @returns A promise that resolves when the refresh is complete
|
|
1090
1167
|
* @throws {Error} If the refresh fails
|
|
1091
1168
|
*
|
|
1092
|
-
*
|
|
1169
|
+
*
|
|
1093
1170
|
* - Retrieves the latest developer information from the server
|
|
1094
1171
|
* - Updates the developer state with fresh data
|
|
1095
1172
|
* - Useful after making changes that affect developer profile or organization membership
|
|
@@ -1124,7 +1201,7 @@ export declare type OpenSecretDeveloperContextType = {
|
|
|
1124
1201
|
* @returns A promise resolving to the parsed attestation document
|
|
1125
1202
|
* @throws {Error} If attestation fails or is invalid
|
|
1126
1203
|
*
|
|
1127
|
-
*
|
|
1204
|
+
*
|
|
1128
1205
|
* This is a convenience function that:
|
|
1129
1206
|
* 1. Fetches the attestation document with a random nonce
|
|
1130
1207
|
* 2. Authenticates the document
|