@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 CHANGED
@@ -12,14 +12,19 @@ npm install @opensecret/react
12
12
 
13
13
  ## Usage
14
14
 
15
- Wrap your application in the `OpenSecretProvider` component and provide the URL of your OpenSecret backend:
15
+ Wrap your application in the `OpenSecretProvider` component and provide:
16
+ 1. The URL of your OpenSecret backend
17
+ 2. Your project's client ID (a UUID that identifies your project)
16
18
 
17
19
  ```tsx
18
20
  import { OpenSecretProvider } from "@opensecret/react";
19
21
 
20
22
  function App() {
21
23
  return (
22
- <OpenSecretProvider apiUrl="{URL}">
24
+ <OpenSecretProvider
25
+ apiUrl="{URL}"
26
+ clientId="{PROJECT_UUID}"
27
+ >
23
28
  <App />
24
29
  </OpenSecretProvider>
25
30
  );
@@ -52,10 +57,15 @@ function App() {
52
57
 
53
58
  ### `OpenSecretProvider`
54
59
 
55
- The `OpenSecretProvider` component is the main entry point for the SDK. It requires a single prop, `apiUrl`, which should be set to the URL of your OpenSecret backend.
60
+ The `OpenSecretProvider` component is the main entry point for the SDK. It requires two props:
61
+ - `apiUrl`: The URL of your OpenSecret backend
62
+ - `clientId`: A UUID that identifies your project/tenant. This is used to scope user accounts and data to your specific project.
56
63
 
57
64
  ```tsx
58
- <OpenSecretProvider apiUrl="{URL}">
65
+ <OpenSecretProvider
66
+ apiUrl="{URL}"
67
+ clientId="{PROJECT_UUID}"
68
+ >
59
69
  <App />
60
70
  </OpenSecretProvider>
61
71
  ```
@@ -67,9 +77,9 @@ The `useOpenSecret` hook provides access to the OpenSecret API. It returns an ob
67
77
  #### Authentication Methods
68
78
  - `signIn(email: string, password: string): Promise<void>`: Signs in a user with the provided email and password.
69
79
  - `signUp(email: string, password: string, inviteCode: string, name?: string): Promise<void>`: Signs up a new user with the provided email, password, invite code, and optional name.
70
- - `signInGuest(id: string, password: string): Promise<void>`: Signs in a guest user with their ID and password.
71
- - `signUpGuest(password: string, inviteCode: string): Promise<LoginResponse>`: Creates a new guest account with just a password and invite code. Returns a response containing the guest's ID, access token, and refresh token.
72
- - `convertGuestToUserAccount(email: string, password: string, name?: string): Promise<void>`: Converts current guest account to a regular account with email authentication. Optionally sets the user's name.
80
+ - `signInGuest(id: string, password: string): Promise<void>`: Signs in a guest user with their ID and password. Guest accounts are scoped to the project specified by `clientId`.
81
+ - `signUpGuest(password: string, inviteCode: string): Promise<LoginResponse>`: Creates a new guest account with just a password and invite code. Returns a response containing the guest's ID, access token, and refresh token. The guest account will be associated with the project specified by `clientId`.
82
+ - `convertGuestToUserAccount(email: string, password: string, name?: string): Promise<void>`: Converts current guest account to a regular account with email authentication. Optionally sets the user's name. The account remains associated with the same project it was created under.
73
83
  - `signOut(): Promise<void>`: Signs out the current user.
74
84
 
75
85
  #### Key-Value Storage Methods
@@ -179,6 +189,12 @@ To test the library, run the following command:
179
189
  bun test --env-file .env.local
180
190
  ```
181
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
+
182
198
  Currently this build step requires `npx` because of [a Bun incompatibility with `vite-plugin-dts`](https://github.com/OpenSecretCloud/OpenSecret-SDK/issues/16).
183
199
 
184
200
  To pack the library (for publishing) run the following command: