@opensecret/react 0.4.0 → 1.0.0-beta.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 +6 -0
- package/dist/index.d.ts +577 -3
- package/dist/opensecret-react.es.js +6238 -6396
- package/dist/opensecret-react.umd.js +44 -73
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -189,6 +189,12 @@ To test the library, run the following command:
|
|
|
189
189
|
bun test --env-file .env.local
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
+
To test a specific file or test case:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
bun test --test-name-pattern="Developer login and token storage" src/lib/developer.test.ts --env-file .env.local
|
|
196
|
+
```
|
|
197
|
+
|
|
192
198
|
Currently this build step requires `npx` because of [a Bun incompatibility with `vite-plugin-dts`](https://github.com/OpenSecretCloud/OpenSecret-SDK/issues/16).
|
|
193
199
|
|
|
194
200
|
To pack the library (for publishing) run the following command:
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ import { default as default_2 } from 'react';
|
|
|
2
2
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
+
declare function acceptInvite(code: string): Promise<{
|
|
6
|
+
message: string;
|
|
7
|
+
}>;
|
|
8
|
+
|
|
5
9
|
declare namespace api {
|
|
6
10
|
export {
|
|
7
11
|
setApiUrl,
|
|
@@ -49,6 +53,54 @@ declare namespace api {
|
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
export declare const apiConfig: ApiConfigService;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* ApiConfig service that manages URL configuration for both contexts
|
|
60
|
+
*/
|
|
61
|
+
declare class ApiConfigService {
|
|
62
|
+
private _appApiUrl;
|
|
63
|
+
private _platformApiUrl;
|
|
64
|
+
/**
|
|
65
|
+
* Configure the API URLs for both app and platform contexts
|
|
66
|
+
*/
|
|
67
|
+
configure(appApiUrl: string, platformApiUrl: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Get the platform API URL
|
|
70
|
+
*/
|
|
71
|
+
get platformApiUrl(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get the app API URL
|
|
74
|
+
*/
|
|
75
|
+
get appApiUrl(): string;
|
|
76
|
+
/**
|
|
77
|
+
* Determine if a path is for the platform context
|
|
78
|
+
*/
|
|
79
|
+
isPlatformPath(path: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Get the API endpoint for a given path
|
|
82
|
+
*/
|
|
83
|
+
resolveEndpoint(path: string): ApiEndpoint;
|
|
84
|
+
/**
|
|
85
|
+
* Build a complete URL for an API path
|
|
86
|
+
*/
|
|
87
|
+
buildUrl(path: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* Get the appropriate refresh token function name for a given path
|
|
90
|
+
*/
|
|
91
|
+
getRefreshFunction(path: string): "platformRefreshToken" | "refreshToken";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* API configuration service that manages endpoints for both app and platform APIs
|
|
96
|
+
*/
|
|
97
|
+
export declare type ApiContext = "app" | "platform";
|
|
98
|
+
|
|
99
|
+
export declare interface ApiEndpoint {
|
|
100
|
+
baseUrl: string;
|
|
101
|
+
context: ApiContext;
|
|
102
|
+
}
|
|
103
|
+
|
|
52
104
|
declare interface Attestation {
|
|
53
105
|
sessionKey: Uint8Array | null;
|
|
54
106
|
sessionId: string | null;
|
|
@@ -98,9 +150,37 @@ declare function confirmPasswordReset(email: string, alphanumericCode: string, p
|
|
|
98
150
|
|
|
99
151
|
declare function convertGuestToEmailAccount(email: string, password: string, name?: string | null): Promise<void>;
|
|
100
152
|
|
|
153
|
+
declare function createOrganization(name: string): Promise<Organization>;
|
|
154
|
+
|
|
155
|
+
declare function createProject(orgId: string, name: string, description?: string): Promise<Project>;
|
|
156
|
+
|
|
157
|
+
declare function createProjectSecret(orgId: string, projectId: string, keyName: string, secret: string): Promise<ProjectSecret>;
|
|
158
|
+
|
|
159
|
+
declare function deleteOrganization(orgId: string): Promise<void>;
|
|
160
|
+
|
|
161
|
+
declare function deleteOrganizationInvite(orgId: string, inviteCode: string): Promise<{
|
|
162
|
+
message: string;
|
|
163
|
+
}>;
|
|
164
|
+
|
|
165
|
+
declare function deleteProject(orgId: string, projectId: string): Promise<void>;
|
|
166
|
+
|
|
167
|
+
declare function deleteProjectSecret(orgId: string, projectId: string, keyName: string): Promise<void>;
|
|
168
|
+
|
|
169
|
+
declare type DeveloperResponse = PlatformUser & {
|
|
170
|
+
organizations: PlatformOrg[];
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export declare type DeveloperRole = "owner" | "admin" | "developer" | "viewer";
|
|
174
|
+
|
|
175
|
+
declare type EmailSettings = {
|
|
176
|
+
provider: string;
|
|
177
|
+
send_from: string;
|
|
178
|
+
email_verification_url: string;
|
|
179
|
+
};
|
|
180
|
+
|
|
101
181
|
declare const EXPECTED_ROOT_CERT_HASH = "641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";
|
|
102
182
|
|
|
103
|
-
declare function fetchAttestationDocument(nonce: string): Promise<string>;
|
|
183
|
+
declare function fetchAttestationDocument(nonce: string, explicitApiUrl?: string): Promise<string>;
|
|
104
184
|
|
|
105
185
|
declare function fetchDelete(key: string): Promise<void>;
|
|
106
186
|
|
|
@@ -161,7 +241,17 @@ declare function generateThirdPartyToken(audience: string): Promise<ThirdPartyTo
|
|
|
161
241
|
|
|
162
242
|
declare function getApiUrl(): string;
|
|
163
243
|
|
|
164
|
-
declare function getAttestation(forceRefresh?: boolean,
|
|
244
|
+
declare function getAttestation(forceRefresh?: boolean, explicitApiUrl?: string): Promise<Attestation>;
|
|
245
|
+
|
|
246
|
+
declare function getEmailSettings(orgId: string, projectId: string): Promise<EmailSettings>;
|
|
247
|
+
|
|
248
|
+
declare function getOAuthSettings(orgId: string, projectId: string): Promise<OAuthSettings>;
|
|
249
|
+
|
|
250
|
+
declare function getOrganizationInvite(orgId: string, inviteCode: string): Promise<OrganizationInvite>;
|
|
251
|
+
|
|
252
|
+
declare function getPlatformApiUrl(): string;
|
|
253
|
+
|
|
254
|
+
declare function getProject(orgId: string, projectId: string): Promise<Project>;
|
|
165
255
|
|
|
166
256
|
export declare type GithubAuthResponse = {
|
|
167
257
|
auth_url: string;
|
|
@@ -183,7 +273,9 @@ declare function initiateGitHubAuth(client_id: string, inviteCode?: string): Pro
|
|
|
183
273
|
|
|
184
274
|
declare function initiateGoogleAuth(client_id: string, inviteCode?: string): Promise<GoogleAuthResponse>;
|
|
185
275
|
|
|
186
|
-
declare function
|
|
276
|
+
declare function inviteDeveloper(orgId: string, email: string, role?: string): Promise<OrganizationInvite>;
|
|
277
|
+
|
|
278
|
+
declare function keyExchange(clientPublicKey: string, nonce: string, explicitApiUrl?: string): Promise<{
|
|
187
279
|
encrypted_session_key: string;
|
|
188
280
|
session_id: string;
|
|
189
281
|
}>;
|
|
@@ -195,6 +287,16 @@ export declare type KVListItem = {
|
|
|
195
287
|
updated_at: number;
|
|
196
288
|
};
|
|
197
289
|
|
|
290
|
+
declare function listOrganizationInvites(orgId: string): Promise<OrganizationInvite[]>;
|
|
291
|
+
|
|
292
|
+
declare function listOrganizationMembers(orgId: string): Promise<OrganizationMember[]>;
|
|
293
|
+
|
|
294
|
+
declare function listOrganizations(): Promise<Organization[]>;
|
|
295
|
+
|
|
296
|
+
declare function listProjects(orgId: string): Promise<Project[]>;
|
|
297
|
+
|
|
298
|
+
declare function listProjectSecrets(orgId: string, projectId: string): Promise<ProjectSecret[]>;
|
|
299
|
+
|
|
198
300
|
export declare type LoginResponse = {
|
|
199
301
|
id: string;
|
|
200
302
|
email?: string;
|
|
@@ -202,6 +304,26 @@ export declare type LoginResponse = {
|
|
|
202
304
|
refresh_token: string;
|
|
203
305
|
};
|
|
204
306
|
|
|
307
|
+
declare type MeResponse = {
|
|
308
|
+
user: PlatformUser;
|
|
309
|
+
organizations: PlatformOrg[];
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Provider-specific OAuth settings
|
|
314
|
+
*/
|
|
315
|
+
declare type OAuthProviderSettings = {
|
|
316
|
+
client_id: string;
|
|
317
|
+
redirect_url: string;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
declare type OAuthSettings = {
|
|
321
|
+
google_oauth_enabled: boolean;
|
|
322
|
+
github_oauth_enabled: boolean;
|
|
323
|
+
google_oauth_settings?: OAuthProviderSettings;
|
|
324
|
+
github_oauth_settings?: OAuthProviderSettings;
|
|
325
|
+
};
|
|
326
|
+
|
|
205
327
|
export declare type OpenSecretAuthState = {
|
|
206
328
|
loading: boolean;
|
|
207
329
|
user?: api.UserResponse;
|
|
@@ -490,6 +612,289 @@ export declare type OpenSecretContextType = {
|
|
|
490
612
|
generateThirdPartyToken: (audience: string) => Promise<ThirdPartyTokenResponse>;
|
|
491
613
|
};
|
|
492
614
|
|
|
615
|
+
/**
|
|
616
|
+
* Provider component for OpenSecret developer operations.
|
|
617
|
+
* This provider is used for managing organizations, projects, and developer access.
|
|
618
|
+
*
|
|
619
|
+
* @param props - Configuration properties for the OpenSecret developer provider
|
|
620
|
+
* @param props.children - React child components to be wrapped by the provider
|
|
621
|
+
* @param props.apiUrl - URL of OpenSecret developer API
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* ```tsx
|
|
625
|
+
* <OpenSecretDeveloper
|
|
626
|
+
* apiUrl='https://developer.opensecret.cloud'
|
|
627
|
+
* >
|
|
628
|
+
* <App />
|
|
629
|
+
* </OpenSecretDeveloper>
|
|
630
|
+
* ```
|
|
631
|
+
*/
|
|
632
|
+
export declare function OpenSecretDeveloper({ children, apiUrl, pcrConfig }: {
|
|
633
|
+
children: default_2.ReactNode;
|
|
634
|
+
apiUrl: string;
|
|
635
|
+
pcrConfig?: PcrConfig;
|
|
636
|
+
}): JSX_2.Element;
|
|
637
|
+
|
|
638
|
+
export declare type OpenSecretDeveloperAuthState = {
|
|
639
|
+
loading: boolean;
|
|
640
|
+
developer?: DeveloperResponse;
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
export declare const OpenSecretDeveloperContext: default_2.Context<OpenSecretDeveloperContextType>;
|
|
644
|
+
|
|
645
|
+
export declare type OpenSecretDeveloperContextType = {
|
|
646
|
+
auth: OpenSecretDeveloperAuthState;
|
|
647
|
+
/**
|
|
648
|
+
* Signs in a developer with email and password
|
|
649
|
+
* @param email - Developer's email address
|
|
650
|
+
* @param password - Developer's password
|
|
651
|
+
* @returns A promise that resolves to the login response with access and refresh tokens
|
|
652
|
+
*
|
|
653
|
+
* @description
|
|
654
|
+
* - Calls the login API endpoint
|
|
655
|
+
* - Stores access_token and refresh_token in localStorage
|
|
656
|
+
* - Updates the developer state with user information
|
|
657
|
+
* - Throws an error if authentication fails
|
|
658
|
+
*/
|
|
659
|
+
signIn: (email: string, password: string) => Promise<platformApi.PlatformLoginResponse>;
|
|
660
|
+
/**
|
|
661
|
+
* Registers a new developer account
|
|
662
|
+
* @param email - Developer's email address
|
|
663
|
+
* @param password - Developer's password
|
|
664
|
+
* @param name - Optional developer name
|
|
665
|
+
* @returns A promise that resolves to the login response with access and refresh tokens
|
|
666
|
+
*
|
|
667
|
+
* @description
|
|
668
|
+
* - Calls the registration API endpoint
|
|
669
|
+
* - Stores access_token and refresh_token in localStorage
|
|
670
|
+
* - Updates the developer state with new user information
|
|
671
|
+
* - Throws an error if account creation fails
|
|
672
|
+
*/
|
|
673
|
+
signUp: (email: string, password: string, name?: string) => Promise<platformApi.PlatformLoginResponse>;
|
|
674
|
+
/**
|
|
675
|
+
* Signs out the current developer by removing authentication tokens
|
|
676
|
+
*
|
|
677
|
+
* @description
|
|
678
|
+
* - Calls the logout API endpoint with the current refresh_token
|
|
679
|
+
* - Removes access_token, refresh_token from localStorage
|
|
680
|
+
* - Resets the developer state to show no user is authenticated
|
|
681
|
+
*/
|
|
682
|
+
signOut: () => Promise<void>;
|
|
683
|
+
/**
|
|
684
|
+
* Refreshes the developer's authentication state
|
|
685
|
+
* @returns A promise that resolves when the refresh is complete
|
|
686
|
+
* @throws {Error} If the refresh fails
|
|
687
|
+
*
|
|
688
|
+
* @description
|
|
689
|
+
* - Retrieves the latest developer information from the server
|
|
690
|
+
* - Updates the developer state with fresh data
|
|
691
|
+
* - Useful after making changes that affect developer profile or organization membership
|
|
692
|
+
*/
|
|
693
|
+
refetchDeveloper: () => Promise<void>;
|
|
694
|
+
/**
|
|
695
|
+
* Additional PCR0 hashes to validate against
|
|
696
|
+
*/
|
|
697
|
+
pcrConfig: PcrConfig;
|
|
698
|
+
/**
|
|
699
|
+
* Gets attestation from the enclave
|
|
700
|
+
*/
|
|
701
|
+
getAttestation: typeof getAttestation;
|
|
702
|
+
/**
|
|
703
|
+
* Authenticates an attestation document
|
|
704
|
+
*/
|
|
705
|
+
authenticate: typeof authenticate;
|
|
706
|
+
/**
|
|
707
|
+
* Parses an attestation document for viewing
|
|
708
|
+
*/
|
|
709
|
+
parseAttestationForView: (document: AttestationDocument, cabundle: Uint8Array[], pcrConfig?: PcrConfig) => Promise<ParsedAttestationView>;
|
|
710
|
+
/**
|
|
711
|
+
* AWS root certificate in DER format
|
|
712
|
+
*/
|
|
713
|
+
awsRootCertDer: typeof AWS_ROOT_CERT_DER;
|
|
714
|
+
/**
|
|
715
|
+
* Expected hash of the AWS root certificate
|
|
716
|
+
*/
|
|
717
|
+
expectedRootCertHash: typeof EXPECTED_ROOT_CERT_HASH;
|
|
718
|
+
/**
|
|
719
|
+
* Gets and verifies an attestation document from the enclave
|
|
720
|
+
* @returns A promise resolving to the parsed attestation document
|
|
721
|
+
* @throws {Error} If attestation fails or is invalid
|
|
722
|
+
*
|
|
723
|
+
* @description
|
|
724
|
+
* This is a convenience function that:
|
|
725
|
+
* 1. Fetches the attestation document with a random nonce
|
|
726
|
+
* 2. Authenticates the document
|
|
727
|
+
* 3. Parses it for viewing
|
|
728
|
+
*/
|
|
729
|
+
getAttestationDocument: () => Promise<ParsedAttestationView>;
|
|
730
|
+
/**
|
|
731
|
+
* Creates a new organization
|
|
732
|
+
* @param name - Organization name
|
|
733
|
+
* @returns A promise that resolves to the created organization
|
|
734
|
+
*/
|
|
735
|
+
createOrganization: (name: string) => Promise<Organization>;
|
|
736
|
+
/**
|
|
737
|
+
* Lists all organizations the developer has access to
|
|
738
|
+
* @returns A promise resolving to array of organization details
|
|
739
|
+
*/
|
|
740
|
+
listOrganizations: () => Promise<Organization[]>;
|
|
741
|
+
/**
|
|
742
|
+
* Deletes an organization (requires owner role)
|
|
743
|
+
* @param orgId - Organization ID
|
|
744
|
+
*/
|
|
745
|
+
deleteOrganization: (orgId: string) => Promise<void>;
|
|
746
|
+
/**
|
|
747
|
+
* Creates a new project within an organization
|
|
748
|
+
* @param orgId - Organization ID
|
|
749
|
+
* @param name - Project name
|
|
750
|
+
* @param description - Optional project description
|
|
751
|
+
* @returns A promise that resolves to the project details including client ID
|
|
752
|
+
*/
|
|
753
|
+
createProject: (orgId: string, name: string, description?: string) => Promise<Project>;
|
|
754
|
+
/**
|
|
755
|
+
* Lists all projects within an organization
|
|
756
|
+
* @param orgId - Organization ID
|
|
757
|
+
* @returns A promise resolving to array of project details
|
|
758
|
+
*/
|
|
759
|
+
listProjects: (orgId: string) => Promise<Project[]>;
|
|
760
|
+
/**
|
|
761
|
+
* Gets a single project by ID
|
|
762
|
+
* @param orgId - Organization ID
|
|
763
|
+
* @param projectId - Project ID
|
|
764
|
+
* @returns A promise resolving to the project details
|
|
765
|
+
*/
|
|
766
|
+
getProject: (orgId: string, projectId: string) => Promise<Project>;
|
|
767
|
+
/**
|
|
768
|
+
* Updates project details
|
|
769
|
+
* @param orgId - Organization ID
|
|
770
|
+
* @param projectId - Project ID
|
|
771
|
+
* @param updates - Object containing fields to update
|
|
772
|
+
*/
|
|
773
|
+
updateProject: (orgId: string, projectId: string, updates: {
|
|
774
|
+
name?: string;
|
|
775
|
+
description?: string;
|
|
776
|
+
status?: string;
|
|
777
|
+
}) => Promise<Project>;
|
|
778
|
+
/**
|
|
779
|
+
* Deletes a project
|
|
780
|
+
* @param orgId - Organization ID
|
|
781
|
+
* @param projectId - Project ID
|
|
782
|
+
*/
|
|
783
|
+
deleteProject: (orgId: string, projectId: string) => Promise<void>;
|
|
784
|
+
/**
|
|
785
|
+
* Creates a new secret for a project
|
|
786
|
+
* @param orgId - Organization ID
|
|
787
|
+
* @param projectId - Project ID
|
|
788
|
+
* @param keyName - Secret key name (must be alphanumeric)
|
|
789
|
+
* @param secret - Secret value (must be base64 encoded by the caller)
|
|
790
|
+
*
|
|
791
|
+
* Example:
|
|
792
|
+
* ```typescript
|
|
793
|
+
* // To encode a string secret
|
|
794
|
+
* import { encode } from "@stablelib/base64";
|
|
795
|
+
* const encodedSecret = encode(new TextEncoder().encode("my-secret-value"));
|
|
796
|
+
*
|
|
797
|
+
* // Now pass the encoded secret to the function
|
|
798
|
+
* createProjectSecret(orgId, projectId, "mySecretKey", encodedSecret);
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
createProjectSecret: (orgId: string, projectId: string, keyName: string, secret: string) => Promise<ProjectSecret>;
|
|
802
|
+
/**
|
|
803
|
+
* Lists all secrets for a project
|
|
804
|
+
* @param orgId - Organization ID
|
|
805
|
+
* @param projectId - Project ID
|
|
806
|
+
*/
|
|
807
|
+
listProjectSecrets: (orgId: string, projectId: string) => Promise<ProjectSecret[]>;
|
|
808
|
+
/**
|
|
809
|
+
* Deletes a project secret
|
|
810
|
+
* @param orgId - Organization ID
|
|
811
|
+
* @param projectId - Project ID
|
|
812
|
+
* @param keyName - Secret key name
|
|
813
|
+
*/
|
|
814
|
+
deleteProjectSecret: (orgId: string, projectId: string, keyName: string) => Promise<void>;
|
|
815
|
+
/**
|
|
816
|
+
* Gets email configuration for a project
|
|
817
|
+
* @param orgId - Organization ID
|
|
818
|
+
* @param projectId - Project ID
|
|
819
|
+
*/
|
|
820
|
+
getEmailSettings: (orgId: string, projectId: string) => Promise<EmailSettings>;
|
|
821
|
+
/**
|
|
822
|
+
* Updates email configuration
|
|
823
|
+
* @param orgId - Organization ID
|
|
824
|
+
* @param projectId - Project ID
|
|
825
|
+
* @param settings - Email settings
|
|
826
|
+
*/
|
|
827
|
+
updateEmailSettings: (orgId: string, projectId: string, settings: EmailSettings) => Promise<EmailSettings>;
|
|
828
|
+
/**
|
|
829
|
+
* Gets OAuth settings for a project
|
|
830
|
+
* @param orgId - Organization ID
|
|
831
|
+
* @param projectId - Project ID
|
|
832
|
+
*/
|
|
833
|
+
getOAuthSettings: (orgId: string, projectId: string) => Promise<OAuthSettings>;
|
|
834
|
+
/**
|
|
835
|
+
* Updates OAuth configuration
|
|
836
|
+
* @param orgId - Organization ID
|
|
837
|
+
* @param projectId - Project ID
|
|
838
|
+
* @param settings - OAuth settings
|
|
839
|
+
*/
|
|
840
|
+
updateOAuthSettings: (orgId: string, projectId: string, settings: OAuthSettings) => Promise<OAuthSettings>;
|
|
841
|
+
/**
|
|
842
|
+
* Creates an invitation to join an organization
|
|
843
|
+
* @param orgId - Organization ID
|
|
844
|
+
* @param email - Developer's email address
|
|
845
|
+
* @param role - Role to assign (defaults to "admin")
|
|
846
|
+
*/
|
|
847
|
+
inviteDeveloper: (orgId: string, email: string, role?: string) => Promise<OrganizationInvite>;
|
|
848
|
+
/**
|
|
849
|
+
* Lists all members of an organization
|
|
850
|
+
* @param orgId - Organization ID
|
|
851
|
+
*/
|
|
852
|
+
listOrganizationMembers: (orgId: string) => Promise<OrganizationMember[]>;
|
|
853
|
+
/**
|
|
854
|
+
* Lists all pending invitations for an organization
|
|
855
|
+
* @param orgId - Organization ID
|
|
856
|
+
*/
|
|
857
|
+
listOrganizationInvites: (orgId: string) => Promise<OrganizationInvite[]>;
|
|
858
|
+
/**
|
|
859
|
+
* Gets a specific invitation by code
|
|
860
|
+
* @param orgId - Organization ID
|
|
861
|
+
* @param inviteCode - Invitation UUID code
|
|
862
|
+
*/
|
|
863
|
+
getOrganizationInvite: (orgId: string, inviteCode: string) => Promise<OrganizationInvite>;
|
|
864
|
+
/**
|
|
865
|
+
* Deletes an invitation
|
|
866
|
+
* @param orgId - Organization ID
|
|
867
|
+
* @param inviteCode - Invitation UUID code
|
|
868
|
+
*/
|
|
869
|
+
deleteOrganizationInvite: (orgId: string, inviteCode: string) => Promise<{
|
|
870
|
+
message: string;
|
|
871
|
+
}>;
|
|
872
|
+
/**
|
|
873
|
+
* Updates a member's role
|
|
874
|
+
* @param orgId - Organization ID
|
|
875
|
+
* @param userId - User ID to update
|
|
876
|
+
* @param role - New role to assign
|
|
877
|
+
*/
|
|
878
|
+
updateMemberRole: (orgId: string, userId: string, role: string) => Promise<OrganizationMember>;
|
|
879
|
+
/**
|
|
880
|
+
* Removes a member from the organization
|
|
881
|
+
* @param orgId - Organization ID
|
|
882
|
+
* @param userId - User ID to remove
|
|
883
|
+
*/
|
|
884
|
+
removeMember: (orgId: string, userId: string) => Promise<void>;
|
|
885
|
+
/**
|
|
886
|
+
* Accepts an organization invitation
|
|
887
|
+
* @param code - Invitation UUID code
|
|
888
|
+
*/
|
|
889
|
+
acceptInvite: (code: string) => Promise<{
|
|
890
|
+
message: string;
|
|
891
|
+
}>;
|
|
892
|
+
/**
|
|
893
|
+
* Returns the current OpenSecret developer API URL being used
|
|
894
|
+
*/
|
|
895
|
+
apiUrl: string;
|
|
896
|
+
};
|
|
897
|
+
|
|
493
898
|
/**
|
|
494
899
|
* Provider component for OpenSecret authentication and key-value storage.
|
|
495
900
|
*
|
|
@@ -523,6 +928,30 @@ export declare function OpenSecretProvider({ children, apiUrl, clientId, pcrConf
|
|
|
523
928
|
pcrConfig?: PcrConfig;
|
|
524
929
|
}): JSX_2.Element;
|
|
525
930
|
|
|
931
|
+
declare type Organization = {
|
|
932
|
+
id: string;
|
|
933
|
+
name: string;
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
export declare type OrganizationDetails = Organization;
|
|
937
|
+
|
|
938
|
+
declare type OrganizationInvite = {
|
|
939
|
+
code: string;
|
|
940
|
+
email: string;
|
|
941
|
+
role: string;
|
|
942
|
+
used: boolean;
|
|
943
|
+
expires_at: string;
|
|
944
|
+
created_at: string;
|
|
945
|
+
updated_at: string;
|
|
946
|
+
organization_name?: string;
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
declare type OrganizationMember = {
|
|
950
|
+
user_id: string;
|
|
951
|
+
role: string;
|
|
952
|
+
name?: string;
|
|
953
|
+
};
|
|
954
|
+
|
|
526
955
|
export declare type ParsedAttestationView = {
|
|
527
956
|
moduleId: string;
|
|
528
957
|
publicKey: string | null;
|
|
@@ -555,6 +984,109 @@ export declare type PcrConfig = {
|
|
|
555
984
|
pcr0DevValues?: string[];
|
|
556
985
|
};
|
|
557
986
|
|
|
987
|
+
declare namespace platformApi {
|
|
988
|
+
export {
|
|
989
|
+
setPlatformApiUrl,
|
|
990
|
+
getPlatformApiUrl,
|
|
991
|
+
platformLogin,
|
|
992
|
+
platformRegister,
|
|
993
|
+
platformLogout,
|
|
994
|
+
platformRefreshToken,
|
|
995
|
+
createOrganization,
|
|
996
|
+
listOrganizations,
|
|
997
|
+
deleteOrganization,
|
|
998
|
+
createProject,
|
|
999
|
+
listProjects,
|
|
1000
|
+
getProject,
|
|
1001
|
+
updateProject,
|
|
1002
|
+
deleteProject,
|
|
1003
|
+
createProjectSecret,
|
|
1004
|
+
listProjectSecrets,
|
|
1005
|
+
deleteProjectSecret,
|
|
1006
|
+
getEmailSettings,
|
|
1007
|
+
updateEmailSettings,
|
|
1008
|
+
getOAuthSettings,
|
|
1009
|
+
updateOAuthSettings,
|
|
1010
|
+
inviteDeveloper,
|
|
1011
|
+
listOrganizationInvites,
|
|
1012
|
+
getOrganizationInvite,
|
|
1013
|
+
deleteOrganizationInvite,
|
|
1014
|
+
listOrganizationMembers,
|
|
1015
|
+
updateMemberRole,
|
|
1016
|
+
removeMember,
|
|
1017
|
+
acceptInvite,
|
|
1018
|
+
platformMe,
|
|
1019
|
+
PlatformLoginResponse,
|
|
1020
|
+
PlatformRefreshResponse,
|
|
1021
|
+
PlatformOrg,
|
|
1022
|
+
PlatformUser,
|
|
1023
|
+
MeResponse,
|
|
1024
|
+
Organization,
|
|
1025
|
+
OrganizationInvite,
|
|
1026
|
+
Project,
|
|
1027
|
+
ProjectSecret,
|
|
1028
|
+
ProjectSettings,
|
|
1029
|
+
EmailSettings,
|
|
1030
|
+
OAuthProviderSettings,
|
|
1031
|
+
OAuthSettings,
|
|
1032
|
+
OrganizationMember
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
declare function platformLogin(email: string, password: string): Promise<PlatformLoginResponse>;
|
|
1037
|
+
|
|
1038
|
+
declare type PlatformLoginResponse = {
|
|
1039
|
+
id: string;
|
|
1040
|
+
email: string;
|
|
1041
|
+
name?: string;
|
|
1042
|
+
access_token: string;
|
|
1043
|
+
refresh_token: string;
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
declare function platformLogout(refresh_token: string): Promise<void>;
|
|
1047
|
+
|
|
1048
|
+
declare function platformMe(): Promise<MeResponse>;
|
|
1049
|
+
|
|
1050
|
+
declare type PlatformOrg = {
|
|
1051
|
+
id: string;
|
|
1052
|
+
name: string;
|
|
1053
|
+
role?: string;
|
|
1054
|
+
created_at?: string;
|
|
1055
|
+
updated_at?: string;
|
|
1056
|
+
};
|
|
1057
|
+
|
|
1058
|
+
declare type PlatformRefreshResponse = {
|
|
1059
|
+
access_token: string;
|
|
1060
|
+
refresh_token: string;
|
|
1061
|
+
};
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Refreshes platform access and refresh tokens
|
|
1065
|
+
*
|
|
1066
|
+
* This function:
|
|
1067
|
+
* 1. Gets the refresh token from localStorage
|
|
1068
|
+
* 2. Calls the platform-specific refresh endpoint (/platform/refresh)
|
|
1069
|
+
* 3. Updates localStorage with the new tokens
|
|
1070
|
+
*
|
|
1071
|
+
* The platform refresh endpoint expects:
|
|
1072
|
+
* - A refresh token with audience "platform_refresh" in the request body
|
|
1073
|
+
* - The request to be encrypted according to the platform's encryption scheme
|
|
1074
|
+
*
|
|
1075
|
+
* It returns new access and refresh tokens if validation succeeds.
|
|
1076
|
+
*/
|
|
1077
|
+
declare function platformRefreshToken(): Promise<PlatformRefreshResponse>;
|
|
1078
|
+
|
|
1079
|
+
declare function platformRegister(email: string, password: string, name?: string): Promise<PlatformLoginResponse>;
|
|
1080
|
+
|
|
1081
|
+
declare type PlatformUser = {
|
|
1082
|
+
id: string;
|
|
1083
|
+
email: string;
|
|
1084
|
+
name?: string;
|
|
1085
|
+
email_verified: boolean;
|
|
1086
|
+
created_at: string;
|
|
1087
|
+
updated_at: string;
|
|
1088
|
+
};
|
|
1089
|
+
|
|
558
1090
|
declare type PrivateKeyBytesResponse = {
|
|
559
1091
|
/** 32-byte hex string (64 characters) representing the private key */
|
|
560
1092
|
private_key: string;
|
|
@@ -565,6 +1097,30 @@ declare type PrivateKeyResponse = {
|
|
|
565
1097
|
mnemonic: string;
|
|
566
1098
|
};
|
|
567
1099
|
|
|
1100
|
+
declare type Project = {
|
|
1101
|
+
id: string;
|
|
1102
|
+
client_id: string;
|
|
1103
|
+
name: string;
|
|
1104
|
+
description?: string;
|
|
1105
|
+
status: string;
|
|
1106
|
+
created_at: string;
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
export declare type ProjectDetails = Project;
|
|
1110
|
+
|
|
1111
|
+
declare type ProjectSecret = {
|
|
1112
|
+
key_name: string;
|
|
1113
|
+
created_at: string;
|
|
1114
|
+
updated_at: string;
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
export declare type ProjectSettings = {
|
|
1118
|
+
category: string;
|
|
1119
|
+
settings: Record<string, unknown>;
|
|
1120
|
+
created_at: string;
|
|
1121
|
+
updated_at: string;
|
|
1122
|
+
};
|
|
1123
|
+
|
|
568
1124
|
declare type PublicKeyResponse = {
|
|
569
1125
|
/** Public key in hex format */
|
|
570
1126
|
public_key: string;
|
|
@@ -579,12 +1135,16 @@ declare type RefreshResponse = {
|
|
|
579
1135
|
|
|
580
1136
|
declare function refreshToken(): Promise<RefreshResponse>;
|
|
581
1137
|
|
|
1138
|
+
declare function removeMember(orgId: string, userId: string): Promise<void>;
|
|
1139
|
+
|
|
582
1140
|
declare function requestNewVerificationCode(): Promise<void>;
|
|
583
1141
|
|
|
584
1142
|
declare function requestPasswordReset(email: string, hashedSecret: string, client_id: string): Promise<void>;
|
|
585
1143
|
|
|
586
1144
|
declare function setApiUrl(url: string): void;
|
|
587
1145
|
|
|
1146
|
+
declare function setPlatformApiUrl(url: string): void;
|
|
1147
|
+
|
|
588
1148
|
declare type SigningAlgorithm = "schnorr" | "ecdsa";
|
|
589
1149
|
|
|
590
1150
|
/**
|
|
@@ -628,8 +1188,22 @@ declare type ThirdPartyTokenResponse = {
|
|
|
628
1188
|
token: string;
|
|
629
1189
|
};
|
|
630
1190
|
|
|
1191
|
+
declare function updateEmailSettings(orgId: string, projectId: string, settings: EmailSettings): Promise<EmailSettings>;
|
|
1192
|
+
|
|
1193
|
+
declare function updateMemberRole(orgId: string, userId: string, role: string): Promise<OrganizationMember>;
|
|
1194
|
+
|
|
1195
|
+
declare function updateOAuthSettings(orgId: string, projectId: string, settings: OAuthSettings): Promise<OAuthSettings>;
|
|
1196
|
+
|
|
1197
|
+
declare function updateProject(orgId: string, projectId: string, updates: {
|
|
1198
|
+
name?: string;
|
|
1199
|
+
description?: string;
|
|
1200
|
+
status?: string;
|
|
1201
|
+
}): Promise<Project>;
|
|
1202
|
+
|
|
631
1203
|
export declare function useOpenSecret(): OpenSecretContextType;
|
|
632
1204
|
|
|
1205
|
+
export declare function useOpenSecretDeveloper(): OpenSecretDeveloperContextType;
|
|
1206
|
+
|
|
633
1207
|
export declare type UserResponse = {
|
|
634
1208
|
user: {
|
|
635
1209
|
id: string;
|