@opensecret/react 0.3.5 → 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 +23 -7
- package/dist/index.d.ts +604 -18
- package/dist/opensecret-react.es.js +6322 -6460
- package/dist/opensecret-react.umd.js +44 -73
- package/package.json +8 -6
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;
|
|
@@ -94,25 +146,53 @@ declare const AWS_ROOT_CERT_DER: Uint8Array;
|
|
|
94
146
|
|
|
95
147
|
declare function changePassword(currentPassword: string, newPassword: string): Promise<void>;
|
|
96
148
|
|
|
97
|
-
declare function confirmPasswordReset(email: string, alphanumericCode: string, plaintextSecret: string, newPassword: string): Promise<void>;
|
|
149
|
+
declare function confirmPasswordReset(email: string, alphanumericCode: string, plaintextSecret: string, newPassword: string, client_id: string): Promise<void>;
|
|
150
|
+
|
|
151
|
+
declare function convertGuestToEmailAccount(email: string, password: string, name?: string | null): Promise<void>;
|
|
152
|
+
|
|
153
|
+
declare function createOrganization(name: string): Promise<Organization>;
|
|
98
154
|
|
|
99
|
-
declare function
|
|
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
|
+
};
|
|
100
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
|
|
|
107
187
|
declare function fetchGet(key: string): Promise<string | undefined>;
|
|
108
188
|
|
|
109
|
-
declare function fetchGuestLogin(id: string, password: string): Promise<LoginResponse>;
|
|
189
|
+
declare function fetchGuestLogin(id: string, password: string, client_id: string): Promise<LoginResponse>;
|
|
110
190
|
|
|
111
|
-
declare function fetchGuestSignUp(password: string, inviteCode: string): Promise<LoginResponse>;
|
|
191
|
+
declare function fetchGuestSignUp(password: string, inviteCode: string, client_id: string): Promise<LoginResponse>;
|
|
112
192
|
|
|
113
193
|
declare function fetchList(): Promise<KVListItem[]>;
|
|
114
194
|
|
|
115
|
-
declare function fetchLogin(email: string, password: string): Promise<LoginResponse>;
|
|
195
|
+
declare function fetchLogin(email: string, password: string, client_id: string): Promise<LoginResponse>;
|
|
116
196
|
|
|
117
197
|
declare function fetchLogout(refresh_token: string): Promise<void>;
|
|
118
198
|
|
|
@@ -151,7 +231,7 @@ declare function fetchPublicKey(algorithm: SigningAlgorithm, derivationPath?: st
|
|
|
151
231
|
|
|
152
232
|
declare function fetchPut(key: string, value: string): Promise<string>;
|
|
153
233
|
|
|
154
|
-
declare function fetchSignUp(email: string, password: string, inviteCode: string, name?: string | null): Promise<LoginResponse>;
|
|
234
|
+
declare function fetchSignUp(email: string, password: string, inviteCode: string, client_id: string, name?: string | null): Promise<LoginResponse>;
|
|
155
235
|
|
|
156
236
|
declare function fetchUser(): Promise<UserResponse>;
|
|
157
237
|
|
|
@@ -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;
|
|
@@ -179,11 +269,13 @@ declare function handleGoogleCallback(code: string, state: string, inviteCode: s
|
|
|
179
269
|
|
|
180
270
|
export declare function hashSecret(secret: string): Promise<string>;
|
|
181
271
|
|
|
182
|
-
declare function initiateGitHubAuth(inviteCode?: string): Promise<GithubAuthResponse>;
|
|
272
|
+
declare function initiateGitHubAuth(client_id: string, inviteCode?: string): Promise<GithubAuthResponse>;
|
|
183
273
|
|
|
184
|
-
declare function initiateGoogleAuth(inviteCode?: string): Promise<GoogleAuthResponse>;
|
|
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;
|
|
@@ -211,6 +333,11 @@ export declare const OpenSecretContext: default_2.Context<OpenSecretContextType>
|
|
|
211
333
|
|
|
212
334
|
export declare type OpenSecretContextType = {
|
|
213
335
|
auth: OpenSecretAuthState;
|
|
336
|
+
/**
|
|
337
|
+
* The client ID for this project/tenant
|
|
338
|
+
* @description A UUID that identifies which project/tenant this instance belongs to
|
|
339
|
+
*/
|
|
340
|
+
clientId: string;
|
|
214
341
|
/**
|
|
215
342
|
* Authenticates a user with email and password
|
|
216
343
|
* @param email - User's email address
|
|
@@ -219,7 +346,7 @@ export declare type OpenSecretContextType = {
|
|
|
219
346
|
* @throws {Error} If login fails
|
|
220
347
|
*
|
|
221
348
|
* @description
|
|
222
|
-
* - Calls the login API endpoint
|
|
349
|
+
* - Calls the login API endpoint with the configured clientId
|
|
223
350
|
* - Stores access_token and refresh_token in localStorage
|
|
224
351
|
* - Updates the auth state with user information
|
|
225
352
|
* - Throws an error if authentication fails
|
|
@@ -286,7 +413,7 @@ export declare type OpenSecretContextType = {
|
|
|
286
413
|
* - Updates the auth state with new user information
|
|
287
414
|
* - Preserves all existing data associated with the guest account
|
|
288
415
|
*/
|
|
289
|
-
convertGuestToUserAccount: (email: string, password: string, name?: string) => Promise<void>;
|
|
416
|
+
convertGuestToUserAccount: (email: string, password: string, name?: string | null) => Promise<void>;
|
|
290
417
|
/**
|
|
291
418
|
* Logs out the current user
|
|
292
419
|
* @returns A promise that resolves when logout is complete
|
|
@@ -358,8 +485,8 @@ export declare type OpenSecretContextType = {
|
|
|
358
485
|
refetchUser: () => Promise<void>;
|
|
359
486
|
changePassword: typeof api.changePassword;
|
|
360
487
|
refreshAccessToken: typeof api.refreshToken;
|
|
361
|
-
requestPasswordReset:
|
|
362
|
-
confirmPasswordReset:
|
|
488
|
+
requestPasswordReset: (email: string, hashedSecret: string) => Promise<void>;
|
|
489
|
+
confirmPasswordReset: (email: string, alphanumericCode: string, plaintextSecret: string, newPassword: string) => Promise<void>;
|
|
363
490
|
initiateGitHubAuth: (inviteCode: string) => Promise<api.GithubAuthResponse>;
|
|
364
491
|
handleGitHubCallback: (code: string, state: string, inviteCode: string) => Promise<void>;
|
|
365
492
|
initiateGoogleAuth: (inviteCode: string) => Promise<api.GoogleAuthResponse>;
|
|
@@ -485,32 +612,346 @@ export declare type OpenSecretContextType = {
|
|
|
485
612
|
generateThirdPartyToken: (audience: string) => Promise<ThirdPartyTokenResponse>;
|
|
486
613
|
};
|
|
487
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
|
+
|
|
488
898
|
/**
|
|
489
899
|
* Provider component for OpenSecret authentication and key-value storage.
|
|
490
900
|
*
|
|
491
901
|
* @param props - Configuration properties for the OpenSecret provider
|
|
492
902
|
* @param props.children - React child components to be wrapped by the provider
|
|
493
903
|
* @param props.apiUrl - URL of OpenSecret enclave backend
|
|
904
|
+
* @param props.clientId - UUID identifying which project/tenant this instance belongs to
|
|
905
|
+
* @param props.pcrConfig - Optional PCR configuration for attestation validation
|
|
494
906
|
*
|
|
495
907
|
* @remarks
|
|
496
908
|
* This provider manages:
|
|
497
909
|
* - User authentication state
|
|
498
910
|
* - Authentication methods (sign in, sign up, sign out)
|
|
499
911
|
* - Key-value storage operations
|
|
912
|
+
* - Project/tenant identification via clientId
|
|
500
913
|
*
|
|
501
914
|
* @example
|
|
502
915
|
* ```tsx
|
|
503
|
-
* <OpenSecretProvider
|
|
916
|
+
* <OpenSecretProvider
|
|
917
|
+
* apiUrl='https://preview.opensecret.ai'
|
|
918
|
+
* clientId='550e8400-e29b-41d4-a716-446655440000'
|
|
919
|
+
* >
|
|
504
920
|
* <App />
|
|
505
921
|
* </OpenSecretProvider>
|
|
506
922
|
* ```
|
|
507
923
|
*/
|
|
508
|
-
export declare function OpenSecretProvider({ children, apiUrl, pcrConfig }: {
|
|
924
|
+
export declare function OpenSecretProvider({ children, apiUrl, clientId, pcrConfig }: {
|
|
509
925
|
children: default_2.ReactNode;
|
|
510
926
|
apiUrl: string;
|
|
927
|
+
clientId: string;
|
|
511
928
|
pcrConfig?: PcrConfig;
|
|
512
929
|
}): JSX_2.Element;
|
|
513
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
|
+
|
|
514
955
|
export declare type ParsedAttestationView = {
|
|
515
956
|
moduleId: string;
|
|
516
957
|
publicKey: string | null;
|
|
@@ -543,6 +984,109 @@ export declare type PcrConfig = {
|
|
|
543
984
|
pcr0DevValues?: string[];
|
|
544
985
|
};
|
|
545
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
|
+
|
|
546
1090
|
declare type PrivateKeyBytesResponse = {
|
|
547
1091
|
/** 32-byte hex string (64 characters) representing the private key */
|
|
548
1092
|
private_key: string;
|
|
@@ -553,6 +1097,30 @@ declare type PrivateKeyResponse = {
|
|
|
553
1097
|
mnemonic: string;
|
|
554
1098
|
};
|
|
555
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
|
+
|
|
556
1124
|
declare type PublicKeyResponse = {
|
|
557
1125
|
/** Public key in hex format */
|
|
558
1126
|
public_key: string;
|
|
@@ -567,12 +1135,16 @@ declare type RefreshResponse = {
|
|
|
567
1135
|
|
|
568
1136
|
declare function refreshToken(): Promise<RefreshResponse>;
|
|
569
1137
|
|
|
1138
|
+
declare function removeMember(orgId: string, userId: string): Promise<void>;
|
|
1139
|
+
|
|
570
1140
|
declare function requestNewVerificationCode(): Promise<void>;
|
|
571
1141
|
|
|
572
|
-
declare function requestPasswordReset(email: string, hashedSecret: string): Promise<void>;
|
|
1142
|
+
declare function requestPasswordReset(email: string, hashedSecret: string, client_id: string): Promise<void>;
|
|
573
1143
|
|
|
574
1144
|
declare function setApiUrl(url: string): void;
|
|
575
1145
|
|
|
1146
|
+
declare function setPlatformApiUrl(url: string): void;
|
|
1147
|
+
|
|
576
1148
|
declare type SigningAlgorithm = "schnorr" | "ecdsa";
|
|
577
1149
|
|
|
578
1150
|
/**
|
|
@@ -616,8 +1188,22 @@ declare type ThirdPartyTokenResponse = {
|
|
|
616
1188
|
token: string;
|
|
617
1189
|
};
|
|
618
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
|
+
|
|
619
1203
|
export declare function useOpenSecret(): OpenSecretContextType;
|
|
620
1204
|
|
|
1205
|
+
export declare function useOpenSecretDeveloper(): OpenSecretDeveloperContextType;
|
|
1206
|
+
|
|
621
1207
|
export declare type UserResponse = {
|
|
622
1208
|
user: {
|
|
623
1209
|
id: string;
|