@rebasepro/server 0.29.2 → 0.30.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.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * EXPERIMENTAL. Apps saved to the project: the TSX a show_app call ran, kept
3
+ * in `rebase.saved_apps` so it opens again — in the conversation
4
+ * (`open_app`), in the admin panel, or as a Claude artifact — for whoever it
5
+ * was saved for.
6
+ *
7
+ * Who sees one is its `visibility`: `personal` (its owner), `roles` (anyone
8
+ * holding one of its `roles`), or `team` (everyone who signs in). Saving for
9
+ * more than oneself takes the admin role, because a shared app is code an AI
10
+ * wrote, running for other people. Seeing an app is not reaching its data:
11
+ * an app reads and writes only through the data tools, as whoever opens it,
12
+ * under their RLS.
13
+ *
14
+ * The table is not a collection and carries no RLS, so no end user is granted
15
+ * anything on it; every read and write here filters by the viewer itself.
16
+ *
17
+ * @module
18
+ */
19
+ import type { DataDriver } from "@rebasepro/types";
20
+ import { type SqlExec } from "../boot/ddl-bootstrap.js";
21
+ export type AppVisibility = "personal" | "roles" | "team";
22
+ export declare const APP_VISIBILITIES: readonly AppVisibility[];
23
+ export interface SavedAppSummary {
24
+ id: string;
25
+ title: string;
26
+ collections: string[];
27
+ visibility: AppVisibility;
28
+ roles: string[];
29
+ ownerId: string;
30
+ updatedAt: string;
31
+ }
32
+ export interface SavedApp extends SavedAppSummary {
33
+ code: string;
34
+ createdAt: string;
35
+ }
36
+ /** Who is asking: whose personal apps, which roles' apps, and whether they may share. */
37
+ export interface AppViewer {
38
+ uid: string;
39
+ roles: readonly string[];
40
+ }
41
+ export interface SaveAppInput {
42
+ /** The app to replace, by its owner (or an admin); a new app without it. */
43
+ id?: string;
44
+ title: string;
45
+ code: string;
46
+ collections: string[];
47
+ visibility: AppVisibility;
48
+ /** For `roles`: who sees it. */
49
+ roles?: string[];
50
+ }
51
+ /** A request the store refuses, with a reason the caller can show. */
52
+ export declare class SavedAppError extends Error {
53
+ }
54
+ export interface SavedAppStore {
55
+ list(viewer: AppViewer): Promise<SavedAppSummary[]>;
56
+ get(id: string, viewer: AppViewer): Promise<SavedApp | undefined>;
57
+ save(input: SaveAppInput, viewer: AppViewer): Promise<SavedApp>;
58
+ remove(id: string, viewer: AppViewer): Promise<boolean>;
59
+ }
60
+ /** The most apps one person keeps: saved apps are a place to keep work, not storage. */
61
+ export declare const MAX_APPS_PER_OWNER = 200;
62
+ /** The longest app one person saves, in characters: any signed-in user may save, so the store is bounded per app too. */
63
+ export declare const MAX_APP_CODE_LENGTH = 256000;
64
+ /**
65
+ * The store on `driver`'s database, made once per driver; `undefined` on a
66
+ * driver with no SQL (saved apps need a table).
67
+ */
68
+ export declare function savedAppStore(driver: DataDriver): SavedAppStore | undefined;
69
+ export declare function createSavedAppStore(exec: SqlExec): SavedAppStore;
@@ -293,19 +293,23 @@ export interface RebaseAuthConfig {
293
293
  */
294
294
  emailOtp?: boolean;
295
295
  /**
296
- * Opt-in httpOnly cookie mode for refresh tokens.
296
+ * Where the refresh token is handed to a browser. On by default, as the
297
+ * runtime has it.
297
298
  *
298
- * When set, the refresh token is delivered as an `httpOnly`, `Secure`,
299
- * `SameSite` cookie instead of in the JSON response body. This
300
- * prevents XSS from stealing the long-lived refresh token.
299
+ * The refresh token is delivered as an `httpOnly`, `Secure`, `SameSite=Lax`
300
+ * cookie instead of in the JSON response body, out of reach of XSS. The
301
+ * access token remains in the body for `Authorization: Bearer` headers. A
302
+ * browser `@rebasepro/client` defaults to this flow; a client without a
303
+ * cookie jar sends `x-rebase-auth-flow: json` and is answered in the body.
301
304
  *
302
- * The access token remains in the JSON body so the client can use it
303
- * in `Authorization: Bearer` headers for API calls.
305
+ * Pass an object to change the cookie's name, path, domain, `SameSite` or
306
+ * `Secure`. Pass `false` to answer every client in the body, as a server
307
+ * without cookies does; a browser client then needs `authFlowMode: "json"`.
304
308
  *
305
- * **Requires** `credentials: "include"` on client-side fetch calls to
306
- * auth endpoints, and CORS must allow credentials (no `origin: "*"`).
309
+ * A browser app on another origin needs CORS that allows credentials (no
310
+ * `origin: "*"`).
307
311
  */
308
- cookieAuth?: import("../auth/index.js").CookieAuthConfig;
312
+ cookieAuth?: import("../auth/index.js").CookieAuthConfig | false;
309
313
  /**
310
314
  * Refuse password sign-in until the account's email address is verified,
311
315
  * and make registration confirm-first. Off by default.