@opensecret/react 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,6 +79,7 @@ The `useOpenSecret` hook provides access to the OpenSecret API. It returns an ob
79
79
  #### Account Management Methods
80
80
  - `refetchUser(): Promise<void>`: Refreshes the user's authentication state.
81
81
  - `changePassword(currentPassword: string, newPassword: string): Promise<void>`: Changes the user's password.
82
+ - `generateThirdPartyToken(audience: string): Promise<{ token: string }>`: Generates a JWT token for use with pre-authorized third-party services (e.g. "https://api.devservice.com"). Developers must register this URL in advance (coming soon).
82
83
 
83
84
  #### Cryptographic Methods
84
85
  - `getPrivateKey(): Promise<PrivateKeyResponse>`: Retrieves the user's private key mnemonic phrase. This is used for cryptographic operations and should be kept secure.
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ declare namespace api {
31
31
  signMessage,
32
32
  fetchPublicKey,
33
33
  convertGuestToEmailAccount,
34
+ generateThirdPartyToken,
34
35
  LoginResponse,
35
36
  UserResponse,
36
37
  KVListItem,
@@ -38,7 +39,9 @@ declare namespace api {
38
39
  GoogleAuthResponse,
39
40
  PrivateKeyResponse,
40
41
  SignMessageResponse,
41
- PublicKeyResponse
42
+ PublicKeyResponse,
43
+ ThirdPartyTokenRequest,
44
+ ThirdPartyTokenResponse
42
45
  }
43
46
  }
44
47
 
@@ -121,6 +124,8 @@ declare function fetchUser(): Promise<UserResponse>;
121
124
 
122
125
  export declare function generateSecureSecret(): string;
123
126
 
127
+ declare function generateThirdPartyToken(audience: string): Promise<ThirdPartyTokenResponse>;
128
+
124
129
  declare function getAttestation(forceRefresh?: boolean): Promise<Attestation>;
125
130
 
126
131
  export declare type GithubAuthResponse = {
@@ -406,6 +411,22 @@ export declare type OpenSecretContextType = {
406
411
  * 3. Parses it for viewing
407
412
  */
408
413
  getAttestationDocument: () => Promise<ParsedAttestationView>;
414
+ /**
415
+ * Generates a JWT token for use with authorized third-party services
416
+ * @param audience - The URL of the authorized service (e.g. "https://billing.opensecret.cloud")
417
+ * @returns A promise resolving to the token response
418
+ * @throws {Error} If:
419
+ * - The user is not authenticated
420
+ * - The audience URL is invalid
421
+ * - The audience URL is not authorized
422
+ *
423
+ * @description
424
+ * - Generates a signed JWT token for use with specific authorized third-party services
425
+ * - The audience must be an pre-authorized URL registered by the developer (e.g. api.devservice.com)
426
+ * - Requires an active authentication session
427
+ * - Token can be used to authenticate with the specified service
428
+ */
429
+ generateThirdPartyToken: (audience: string) => Promise<ThirdPartyTokenResponse>;
409
430
  };
410
431
 
411
432
  /**
@@ -497,6 +518,14 @@ declare type SignMessageResponse = {
497
518
  message_hash: string;
498
519
  };
499
520
 
521
+ declare type ThirdPartyTokenRequest = {
522
+ audience: string;
523
+ };
524
+
525
+ declare type ThirdPartyTokenResponse = {
526
+ token: string;
527
+ };
528
+
500
529
  export declare function useOpenSecret(): OpenSecretContextType;
501
530
 
502
531
  export declare type UserResponse = {