@rebasepro/client 0.17.3 → 0.18.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.
Files changed (63) hide show
  1. package/README.md +4 -0
  2. package/dist/auth.d.ts +80 -0
  3. package/dist/functions.d.ts +6 -1
  4. package/dist/index.d.ts +8 -0
  5. package/dist/index.es.js +471 -94
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/offline-connectivity.d.ts +12 -1
  8. package/dist/offline.d.ts +23 -1
  9. package/dist/query-contract.types.d.ts +30 -0
  10. package/dist/realtime-channel.d.ts +29 -1
  11. package/dist/sdk_query_builder.d.ts +21 -2
  12. package/dist/transport.d.ts +24 -0
  13. package/package.json +28 -15
  14. package/src/admin.ts +0 -90
  15. package/src/anonymous-client-guard.test.ts +0 -190
  16. package/src/api-keys.ts +0 -87
  17. package/src/auth-listener-errors.test.ts +0 -57
  18. package/src/auth-refresh-overflow.test.ts +0 -89
  19. package/src/auth.ts +0 -982
  20. package/src/backups.ts +0 -40
  21. package/src/client-close.test.ts +0 -80
  22. package/src/collection-listen-meta.test.ts +0 -105
  23. package/src/collection-observe.test.ts +0 -138
  24. package/src/collection.test.ts +0 -293
  25. package/src/collection.ts +0 -525
  26. package/src/cron.test.ts +0 -164
  27. package/src/cron.ts +0 -62
  28. package/src/data-proxy.test.ts +0 -183
  29. package/src/errors.ts +0 -9
  30. package/src/functions.ts +0 -82
  31. package/src/index.ts +0 -639
  32. package/src/like-pattern-redos.test.ts +0 -61
  33. package/src/offline-codec.ts +0 -79
  34. package/src/offline-connectivity.test.ts +0 -191
  35. package/src/offline-connectivity.ts +0 -255
  36. package/src/offline-idb-store.test.ts +0 -340
  37. package/src/offline-integration.test.ts +0 -180
  38. package/src/offline-query.test.ts +0 -431
  39. package/src/offline-query.ts +0 -529
  40. package/src/offline-store.ts +0 -357
  41. package/src/offline-sync-engine.test.ts +0 -857
  42. package/src/offline.test.ts +0 -897
  43. package/src/offline.ts +0 -1928
  44. package/src/query-contract.types.ts +0 -206
  45. package/src/query_builder.ts +0 -1
  46. package/src/realtime-channel.test.ts +0 -542
  47. package/src/realtime-channel.ts +0 -539
  48. package/src/realtime-concurrent-subscribe.test.ts +0 -102
  49. package/src/realtime-error-surfacing.test.ts +0 -105
  50. package/src/realtime-optout.test.ts +0 -279
  51. package/src/realtime-row-identity.test.ts +0 -254
  52. package/src/realtime-subscription-key.test.ts +0 -92
  53. package/src/reviver.ts +0 -39
  54. package/src/sdk_query_builder.ts +0 -206
  55. package/src/storage-key-encoding.test.ts +0 -65
  56. package/src/storage-registry.ts +0 -102
  57. package/src/storage.ts +0 -253
  58. package/src/transport-baseurl.test.ts +0 -101
  59. package/src/transport.ts +0 -505
  60. package/src/vector-search-listen.test.ts +0 -42
  61. package/src/vector-search-query.test.ts +0 -55
  62. package/src/websocket-url.test.ts +0 -97
  63. package/src/websocket.ts +0 -1837
package/README.md CHANGED
@@ -8,6 +8,10 @@ HTTP SDK client for the Rebase backend — typed CRUD, auth, storage, realtime W
8
8
  pnpm add @rebasepro/client
9
9
  ```
10
10
 
11
+ ESM-only: `"type": "module"` with no CommonJS build, so it is loaded with
12
+ `import`. `require()` of it resolves only on Node 22.12+, which supports
13
+ `require(esm)`.
14
+
11
15
  ## What This Package Does
12
16
 
13
17
  `@rebasepro/client` is the primary SDK for interacting with a Rebase backend from any JavaScript/TypeScript environment (browser, Node.js, edge). It creates a single client instance that provides:
package/dist/auth.d.ts CHANGED
@@ -123,6 +123,86 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
123
123
  accessToken: string;
124
124
  refreshToken: string;
125
125
  }>;
126
+ signInAnonymously: () => Promise<{
127
+ user: User;
128
+ accessToken: string;
129
+ refreshToken: string;
130
+ }>;
131
+ linkAnonymous: (email: string, password: string) => Promise<{
132
+ user: User;
133
+ accessToken: string;
134
+ refreshToken: string;
135
+ }>;
136
+ mfa: {
137
+ /**
138
+ * Start enrolling a TOTP factor.
139
+ *
140
+ * Returns the secret and an `otpauth://` URI to render as a QR code,
141
+ * plus ten single-use recovery codes. **Show the recovery codes once
142
+ * and never again** — only their hashes are stored.
143
+ *
144
+ * The factor is not usable until `verify` confirms the user's
145
+ * authenticator produced a correct code from it.
146
+ */
147
+ enroll(options?: {
148
+ friendlyName?: string;
149
+ issuer?: string;
150
+ }): Promise<{
151
+ factor: {
152
+ id: string;
153
+ factorType: string;
154
+ friendlyName?: string;
155
+ };
156
+ totp: {
157
+ secret: string;
158
+ uri: string;
159
+ qrUri: string;
160
+ };
161
+ recoveryCodes: string[];
162
+ }>;
163
+ /** Confirm an enrolment with a code from the authenticator app. */
164
+ verify(factorId: string, code: string): Promise<{
165
+ success: boolean;
166
+ factor: {
167
+ id: string;
168
+ verified: boolean;
169
+ };
170
+ }>;
171
+ /** The factors on this account, verified or not. */
172
+ listFactors(): Promise<{
173
+ id: string;
174
+ factorType: string;
175
+ friendlyName?: string;
176
+ verified: boolean;
177
+ createdAt: string;
178
+ }[]>;
179
+ /**
180
+ * Remove a factor. Requires an `aal2` session — one that has already
181
+ * answered a challenge — so a stolen `aal1` token cannot turn MFA off.
182
+ */
183
+ unenroll(factorId: string): Promise<{
184
+ success: boolean;
185
+ message: string;
186
+ }>;
187
+ /** Open a challenge against a verified factor. Expires in five minutes. */
188
+ challenge(factorId: string): Promise<{
189
+ challengeId: string;
190
+ factorId: string;
191
+ expiresAt: string;
192
+ }>;
193
+ /**
194
+ * Answer a challenge with a TOTP code or a recovery code.
195
+ *
196
+ * This is where an MFA-enrolled account's real session is minted, at
197
+ * `aal2` — so the returned tokens replace the ones the sign-in handed
198
+ * back, and this client adopts them.
199
+ */
200
+ verifyChallenge(challengeId: string, code: string): Promise<{
201
+ user: User;
202
+ accessToken: string;
203
+ refreshToken: string;
204
+ }>;
205
+ };
126
206
  signOut: () => Promise<void>;
127
207
  stopAutoRefresh: () => void;
128
208
  refreshSession: () => Promise<RebaseSession>;
@@ -19,9 +19,14 @@ export interface FunctionsClient {
19
19
  /**
20
20
  * Invoke a custom backend function by name.
21
21
  *
22
+ * **The method is `POST` unless you say otherwise.** A function whose only
23
+ * route is `app.get("/")` therefore answers 404 to a bare `invoke(name)` —
24
+ * pass `{ method: "GET" }`, or write the route as `app.post`.
25
+ *
22
26
  * @typeParam T - Expected shape of the response payload.
23
27
  * @param name - Function name (the filename without extension, e.g. `"extract-job"`).
24
- * @param payload - Optional JSON-serialisable body sent as `POST`.
28
+ * One path segment: a sub-path goes in `options.path`.
29
+ * @param payload - Optional JSON-serialisable body. Dropped for `GET`.
25
30
  * @param options - Optional overrides (HTTP method, sub-path, extra headers).
26
31
  * @returns The parsed JSON response from the function.
27
32
  */
package/dist/index.d.ts CHANGED
@@ -136,6 +136,14 @@ export type CreateRebaseClientResult<DB = Record<string, unknown>> = Omit<Rebase
136
136
  storageRegistry: StorageSourceRegistry;
137
137
  createStorageSource: (storageId: string) => StorageSource;
138
138
  fetchStorageSources: () => Promise<StorageSourceDefinition[]>;
139
+ /**
140
+ * POST to an arbitrary endpoint on this backend, returning its body
141
+ * verbatim.
142
+ *
143
+ * The shorthand for {@link FunctionsClient.invoke} — `call("functions/x",
144
+ * p)` is `functions.invoke("x", p)` — and it unwraps exactly as little.
145
+ * Neither reaches into the response for a `data` key.
146
+ */
139
147
  call: <T = unknown>(endpoint: string, payload?: unknown) => Promise<T>;
140
148
  collection: <M extends Record<string, unknown> = Record<string, unknown>>(slug: string) => CollectionClient<M>;
141
149
  data: TypedDataLayer<DB>;