@lilbox/client 0.0.6 → 0.1.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 CHANGED
@@ -121,6 +121,7 @@ const { data: me } = await lilbox.GET("/v1/whoami");
121
121
  | `verifyMagicLink(token)` | Signs in with the link's token; stores the session |
122
122
  | `signInUrl("google" \| "github", { returnTo?, prompt? })` | The URL "Continue with Google / GitHub" navigates to |
123
123
  | `exchangeCode(code)` | On `/signin/callback`: swaps the code from Google or GitHub; stores the session |
124
+ | `acceptTerms()` | On `/welcome`: accepts the current Terms and AUP; updates the stored user |
124
125
  | `signOut({ everywhere? })` | Signs out this browser or all of them; the store is cleared even if the call fails |
125
126
  | `listSessions()`, `revokeSession(id)` | The signed-in browsers, and signing one out |
126
127
  | `currentUser()` | The signed-in user from the stored session, without a request |
@@ -8,6 +8,7 @@ export declare const AUTH_PATHS: {
8
8
  readonly refresh: "/auth/refresh";
9
9
  readonly logout: "/auth/logout";
10
10
  readonly sessions: "/auth/sessions";
11
+ readonly acceptTerms: "/auth/accept-terms";
11
12
  };
12
13
  export interface DashboardClientOptions extends Omit<LilboxClientOptions, "token"> {
13
14
  /** Where the session lives: browserSessionStore() in the dashboard. */
@@ -38,6 +39,8 @@ export interface DashboardAuth {
38
39
  signOut(options?: {
39
40
  everywhere?: boolean;
40
41
  }): Promise<void>;
42
+ /** /welcome: the person accepts the current Terms and AUP. Updates the stored user. */
43
+ acceptTerms(): Promise<AuthResult<AuthUser>>;
41
44
  listSessions(): Promise<AuthResult<DashboardSession[]>>;
42
45
  revokeSession(id: string): Promise<AuthResult<void>>;
43
46
  /** The signed-in user from the stored session, or null. No request. */
@@ -8,6 +8,7 @@ export const AUTH_PATHS = {
8
8
  refresh: "/auth/refresh",
9
9
  logout: "/auth/logout",
10
10
  sessions: "/auth/sessions",
11
+ acceptTerms: "/auth/accept-terms",
11
12
  };
12
13
  /**
13
14
  * The lilbox client for the dashboard: the same typed /v1 client, but it owns the signed-in session. It sends the
@@ -122,6 +123,15 @@ export function createDashboardClient(options) {
122
123
  await store.clear();
123
124
  }
124
125
  },
126
+ async acceptTerms() {
127
+ const result = await callAuth(AUTH_PATHS.acceptTerms, "POST", {}, true);
128
+ if (result.error)
129
+ return result;
130
+ const session = await store.read();
131
+ if (session)
132
+ await store.write({ ...session, user: result.data.user });
133
+ return { data: result.data.user };
134
+ },
125
135
  async listSessions() {
126
136
  const result = await callAuth(AUTH_PATHS.sessions, "GET", undefined, true);
127
137
  return result.error ? result : { data: result.data.sessions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lilbox/client",
3
- "version": "0.0.6",
3
+ "version": "0.1.0",
4
4
  "description": "Typed HTTP client for the lilbox API, generated from @lilbox/contracts' OpenAPI document.",
5
5
  "license": "MIT",
6
6
  "type": "module",