@rebasepro/client 0.1.2 → 0.2.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/client",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.2.1",
5
5
  "description": "HTTP SDK client for the Rebase custom backend",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/rebaseco"
@@ -23,27 +23,26 @@
23
23
  "exports": {
24
24
  ".": {
25
25
  "types": "./dist/index.d.ts",
26
- "development": "./src/index.ts",
26
+ "development": "./dist/index.es.js",
27
27
  "import": "./dist/index.es.js",
28
28
  "require": "./dist/index.umd.cjs"
29
29
  },
30
30
  "./package.json": "./package.json"
31
31
  },
32
32
  "dependencies": {
33
- "@rebasepro/types": "0.1.2",
34
- "@rebasepro/utils": "0.1.2"
33
+ "@rebasepro/types": "0.2.1",
34
+ "@rebasepro/utils": "0.2.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@jest/globals": "^29.7.0",
38
38
  "@types/jest": "^29.5.14",
39
- "@types/node": "^20.17.14",
39
+ "@types/node": "^20.19.41",
40
40
  "cross-env": "^7.0.3",
41
41
  "jest": "^29.7.0",
42
- "npm-run-all": "^4.1.5",
43
- "ts-jest": "^29.3.1",
42
+ "ts-jest": "^29.4.10",
44
43
  "tsd": "^0.31.2",
45
- "typescript": "^5.8.3",
46
- "vite": "^5.4.17"
44
+ "typescript": "^5.9.3",
45
+ "vite": "^5.4.21"
47
46
  },
48
47
  "files": [
49
48
  "dist",
package/src/auth.ts CHANGED
@@ -29,8 +29,8 @@ export type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "
29
29
  export interface AuthConfig {
30
30
  needsSetup: boolean;
31
31
  registrationEnabled: boolean;
32
- googleEnabled: boolean;
33
32
  emailServiceEnabled: boolean;
33
+ enabledProviders: string[];
34
34
  }
35
35
 
36
36
  export interface AuthStorage {
@@ -196,23 +196,19 @@ refreshToken: session.refreshToken };
196
196
  /**
197
197
  * Sign in with Google.
198
198
  *
199
- * Supports two invocation styles:
199
+ * Supports three invocation styles:
200
200
  * - `signInWithGoogle({ idToken })` — ID-token flow (One Tap / Sign In button)
201
201
  * - `signInWithGoogle({ accessToken })` — Access-token flow (popup)
202
202
  * - `signInWithGoogle({ code, redirectUri })` — Authorization code flow (most secure)
203
- * - `signInWithGoogle(idToken)` — Legacy shorthand for ID-token flow
204
203
  */
205
204
  async function signInWithGoogle(
206
- tokenOrPayload: string | { idToken?: string; accessToken?: string; code?: string; redirectUri?: string }
205
+ payload: { idToken: string } | { accessToken: string } | { code: string; redirectUri: string }
207
206
  ) {
208
207
  const fetchFn = getFetch();
209
- const body = typeof tokenOrPayload === "string"
210
- ? { idToken: tokenOrPayload }
211
- : tokenOrPayload;
212
208
  const res = await fetchFn(authUrl("/google"), {
213
209
  method: "POST",
214
210
  headers: { "Content-Type": "application/json" },
215
- body: JSON.stringify(body)
211
+ body: JSON.stringify(payload)
216
212
  });
217
213
  const responseBody = await res.json().catch(() => ({}));
218
214
  if (!res.ok) throwApiError(res.status, responseBody, res.statusText);
package/src/index.ts CHANGED
@@ -163,7 +163,7 @@ export function createRebaseClient<DB = Record<string, unknown>>(options: Create
163
163
  method: "POST",
164
164
  body: payload ? JSON.stringify(payload) : undefined
165
165
  });
166
- return res.data ?? (res as unknown as T);
166
+ return res.data ?? (res as T);
167
167
  },
168
168
  data: dataProxy,
169
169
  email: undefined
package/src/transport.ts CHANGED
@@ -166,7 +166,7 @@ export function createTransport(config: RebaseClientConfig): Transport {
166
166
  const res = await fetchFn(url, { ...init,
167
167
  headers });
168
168
 
169
- if (res.status === 204) return undefined as unknown as T;
169
+ if (res.status === 204) return undefined as T; // SAFETY: HTTP 204 No Content has no body
170
170
 
171
171
  const text = await res.text().catch(() => "");
172
172
  let body: any = {};
@@ -193,7 +193,7 @@ headers });
193
193
  const retryHeaders = getHeaders(retryToken, init) as Record<string, string>;
194
194
  const retryRes = await fetchFn(url, { ...init,
195
195
  headers: retryHeaders });
196
- if (retryRes.status === 204) return undefined as unknown as T;
196
+ if (retryRes.status === 204) return undefined as T; // SAFETY: HTTP 204 No Content has no body
197
197
  const retryText = await retryRes.text().catch(() => "");
198
198
  let retryBody: any = {};
199
199
  if (retryText) {