@protobase/server 0.47.1 → 0.49.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.
Files changed (105) hide show
  1. package/dist/admin-options.d.ts +2 -2
  2. package/dist/app-identity.d.ts +2 -2
  3. package/dist/app-name.d.ts +2 -0
  4. package/dist/auth-store.d.ts +3 -0
  5. package/dist/auth-store.js +3 -0
  6. package/dist/better-auth/auth-schema.d.ts +7 -8
  7. package/dist/better-auth/auth-schema.js +40 -42
  8. package/dist/better-auth/auth-settings.d.ts +8754 -0
  9. package/dist/better-auth/auth-settings.js +43 -0
  10. package/dist/better-auth/auth-tables.d.ts +1 -1
  11. package/dist/better-auth/auth-tables.js +11 -9
  12. package/dist/better-auth/authenticate-settings.d.ts +15 -0
  13. package/dist/better-auth/authenticate-settings.js +12 -0
  14. package/dist/better-auth/authenticator.d.ts +1 -1
  15. package/dist/better-auth/create-auth.d.ts +34 -14
  16. package/dist/better-auth/create-auth.js +27 -10
  17. package/dist/better-auth/mcp/mcp-auth-plugins.d.ts +2719 -0
  18. package/dist/better-auth/mcp/mcp-auth-plugins.js +68 -0
  19. package/dist/better-auth/mcp/mcp-plugins.d.ts +7 -2
  20. package/dist/better-auth/mcp/mcp-plugins.js +3 -68
  21. package/dist/better-auth/mcp/mcp-token-claims.js +1 -1
  22. package/dist/better-auth/organizations/store.d.ts +1 -0
  23. package/dist/better-auth/saml-plugin.d.ts +993 -0
  24. package/dist/better-auth/saml-plugin.js +36 -0
  25. package/dist/better-auth/saml-sign-in.d.ts +27 -1
  26. package/dist/better-auth/saml-sign-in.js +1 -33
  27. package/dist/better-auth/store/adoption.js +87 -0
  28. package/dist/better-auth/store/ddl.js +18 -0
  29. package/dist/better-auth/store/drift.d.ts +9 -0
  30. package/dist/better-auth/store/drift.js +18 -0
  31. package/dist/better-auth/store/migration-sql.js +15 -0
  32. package/dist/better-auth/store/migrations/001-core.js +80 -0
  33. package/dist/better-auth/store/migrations/002-two-factor.js +25 -0
  34. package/dist/better-auth/store/migrations/003-passkeys.js +29 -0
  35. package/dist/better-auth/store/migrations/004-sign-in-policy.js +22 -0
  36. package/dist/better-auth/store/migrations/005-staff-sign-in.js +25 -0
  37. package/dist/better-auth/store/migrations/006-organizations.js +50 -0
  38. package/dist/better-auth/store/migrations/007-mcp.js +150 -0
  39. package/dist/better-auth/store/migrations/index.js +22 -0
  40. package/dist/better-auth/store/migrations/migration.d.ts +3 -0
  41. package/dist/better-auth/store/migrations/migration.js +14 -0
  42. package/dist/better-auth/store/migrations-table.d.ts +7 -0
  43. package/dist/better-auth/store/migrations-table.js +23 -0
  44. package/dist/better-auth/store/resources-outside.d.ts +7 -0
  45. package/dist/better-auth/store/resources-outside.js +20 -0
  46. package/dist/better-auth/store/store-db.js +13 -0
  47. package/dist/better-auth/store/store-names.d.ts +2 -0
  48. package/dist/better-auth/store/store-names.js +14 -0
  49. package/dist/better-auth/store/table-names.d.ts +7 -0
  50. package/dist/better-auth/store/table-names.js +10 -0
  51. package/dist/better-auth/user-table.js +1 -1
  52. package/dist/better-auth/users.d.ts +2 -2
  53. package/dist/comments/comment-users.d.ts +1 -1
  54. package/dist/config-exports.d.ts +2 -0
  55. package/dist/config-exports.js +2 -0
  56. package/dist/create-admin.d.ts +6 -4
  57. package/dist/create-admin.js +3 -1
  58. package/dist/encryption/keyring.js +1 -1
  59. package/dist/files/options.d.ts +5 -8
  60. package/dist/files/provider-settings.d.ts +16 -0
  61. package/dist/files/provider-settings.js +17 -0
  62. package/dist/files/runtime.js +4 -4
  63. package/dist/forms/runtime.js +3 -3
  64. package/dist/index.d.ts +22 -19
  65. package/dist/index.js +11 -11
  66. package/dist/internal.d.ts +13 -0
  67. package/dist/internal.js +13 -0
  68. package/dist/jobs/declared-job.d.ts +24 -0
  69. package/dist/jobs/declared-job.js +26 -0
  70. package/dist/jobs/job-types.d.ts +2 -2
  71. package/dist/mcp/mcp-authenticator.js +3 -3
  72. package/dist/notifications/device-store-of.d.ts +2 -2
  73. package/dist/notifications/device-store-of.js +1 -1
  74. package/dist/notifications/device-store.d.ts +1 -1
  75. package/dist/notifications/device-store.js +1 -1
  76. package/dist/notifications/history-store-of.d.ts +2 -2
  77. package/dist/notifications/history-store-of.js +1 -1
  78. package/dist/notifications/history-store.d.ts +1 -1
  79. package/dist/notifications/history-store.js +1 -1
  80. package/dist/notifications/options.d.ts +3 -1
  81. package/dist/notifications/options.js +1 -1
  82. package/dist/notifications/schema.d.ts +3 -3
  83. package/dist/notifications/schema.js +8 -8
  84. package/dist/notifications/send-notification.js +1 -1
  85. package/dist/notifications/sender.d.ts +1 -1
  86. package/dist/notifications/sender.js +2 -2
  87. package/dist/notifications/senders-of.d.ts +1 -1
  88. package/dist/notifications/senders-of.js +1 -1
  89. package/dist/package.js +1 -1
  90. package/dist/webhooks/subscription.d.ts +1 -0
  91. package/dist/webhooks/table/options.d.ts +1 -1
  92. package/dist/webhooks/table/schema.d.ts +2 -2
  93. package/dist/webhooks/table/schema.js +2 -2
  94. package/dist/webhooks/table/webhook-table.js +2 -2
  95. package/dist/webhooks/table/webhooks-module.d.ts +108 -0
  96. package/dist/webhooks/table/webhooks-module.js +11 -0
  97. package/package.json +8 -5
  98. package/dist/better-auth/mcp/mcp-tables.js +0 -32
  99. package/dist/better-auth/snake-case-migration.js +0 -122
  100. package/dist/notifications/plugin.d.ts +0 -13
  101. package/dist/notifications/plugin.js +0 -16
  102. package/dist/project-config.d.ts +0 -54
  103. package/dist/project-config.js +0 -182
  104. package/dist/webhooks/table/plugin.d.ts +0 -10
  105. package/dist/webhooks/table/plugin.js +0 -18
@@ -0,0 +1,22 @@
1
+ import { core } from "./001-core.js";
2
+ import { twoFactor } from "./002-two-factor.js";
3
+ import { passkeys } from "./003-passkeys.js";
4
+ import { signInPolicy } from "./004-sign-in-policy.js";
5
+ import { staffSignIn } from "./005-staff-sign-in.js";
6
+ import { organizations } from "./006-organizations.js";
7
+ import { mcp } from "./007-mcp.js";
8
+ //#region src/better-auth/store/migrations/index.ts
9
+ /** The auth store's migrations, by version. A new one goes last, with the next version. */
10
+ const storeMigrations = [
11
+ core,
12
+ twoFactor,
13
+ passkeys,
14
+ signInPolicy,
15
+ staffSignIn,
16
+ organizations,
17
+ mcp
18
+ ];
19
+ /** The version the store is at once every migration is applied. */
20
+ const latestStoreVersion = storeMigrations.at(-1).version;
21
+ //#endregion
22
+ export { latestStoreVersion, storeMigrations };
@@ -0,0 +1,3 @@
1
+ import "../../user-table.js";
2
+ import "../store-names.js";
3
+ import "kysely";
@@ -0,0 +1,14 @@
1
+ import { storeTable } from "../store-names.js";
2
+ import { sql } from "kysely";
3
+ //#region src/better-auth/store/migrations/migration.ts
4
+ /** The `ddl` parts of the app's names. */
5
+ const migrationNames = (names) => ({
6
+ table: (name) => storeTable(names, name),
7
+ user: storeTable(names, names.users.modelName),
8
+ userColumn: names.users.column,
9
+ metadata: names.users.metadata,
10
+ id: sql.raw(names.uuidIds ? "uuid default pg_catalog.gen_random_uuid()" : "text"),
11
+ idRef: sql.raw(names.uuidIds ? "uuid" : "text")
12
+ });
13
+ //#endregion
14
+ export { migrationNames };
@@ -0,0 +1,7 @@
1
+ import "./store-names.js";
2
+ import "./migrations/migration.js";
3
+ import { Kysely } from "kysely";
4
+ //#region src/better-auth/store/migrations-table.d.ts
5
+ /** The table, in the store's schema. */
6
+ export declare const migrationsTableName = "auth_migrations";
7
+ //#endregion
@@ -0,0 +1,23 @@
1
+ import { ddl, ddlText } from "./ddl.js";
2
+ import { storeTable } from "./store-names.js";
3
+ import { sql } from "kysely";
4
+ //#region src/better-auth/store/migrations-table.ts
5
+ /** The table, in the store's schema. */
6
+ const migrationsTableName = "auth_migrations";
7
+ const migrationsTable = (names) => storeTable(names, migrationsTableName);
8
+ /** The statement that makes the table. */
9
+ const createMigrationsTable = (names) => ddl`create table ${migrationsTable(names)} (
10
+ version integer primary key,
11
+ name text not null,
12
+ applied_at timestamptz default current_timestamp not null
13
+ )`;
14
+ /** The statement that records `migrations` as applied. */
15
+ const recordMigrations = (names, migrations) => ddl`insert into ${migrationsTable(names)} (version, name) values ${sql.join(migrations.map(({ version, name }) => ddl`(${sql.lit(version)}, ${sql.lit(name)})`))}`;
16
+ /** The versions the store has applied, in order; `undefined` when it has no migrations table. */
17
+ const appliedVersions = async (db, names) => {
18
+ const [found] = (await sql`select to_regclass(${ddlText(migrationsTable(names))}) is not null as found`.execute(db)).rows;
19
+ if (!found?.found) return void 0;
20
+ return (await sql`select version from ${migrationsTable(names)} order by version`.execute(db)).rows.map((row) => row.version);
21
+ };
22
+ //#endregion
23
+ export { appliedVersions, createMigrationsTable, migrationsTableName, recordMigrations };
@@ -0,0 +1,7 @@
1
+ import { AdminAuth } from "../create-auth.js";
2
+ import { ResourceModel } from "@protobase/schema";
3
+ import { Kysely } from "kysely";
4
+ //#region src/better-auth/store/resources-outside.d.ts
5
+ /** Refuses a resource over a table of the admin store: the user table, a feature's table or the record of migrations. */
6
+ export declare const checkResourcesOutsideAuthStore: (db: Kysely<any>, models: readonly ResourceModel[], auth: AdminAuth) => Promise<void>;
7
+ //#endregion
@@ -0,0 +1,20 @@
1
+ import { storeDb } from "./store-db.js";
2
+ import { authStoreTables } from "../auth-tables.js";
3
+ import { sql } from "kysely";
4
+ //#region src/better-auth/store/resources-outside.ts
5
+ const quoted = (name) => `"${name.replaceAll("\"", "\"\"")}"`;
6
+ const resolve = async (db, tables) => (await sql`select t.n::int as n, ns.nspname as schema, c.relname as name, current_database() as database
7
+ from unnest(${tables.map(({ schema, name }) => schema ? `${quoted(schema)}.${quoted(name)}` : quoted(name))}::text[]) with ordinality as t(name, n)
8
+ join pg_class c on c.oid = to_regclass(t.name) join pg_namespace ns on ns.oid = c.relnamespace order by t.n`.execute(db)).rows;
9
+ /** Refuses a resource over a table of the admin store: the user table, a feature's table or the record of migrations. */
10
+ const checkResourcesOutsideAuthStore = async (db, models, auth) => {
11
+ if (models.length === 0) return;
12
+ const store = await resolve(storeDb(auth), authStoreTables(auth));
13
+ const same = (a, b) => a.database === b.database && a.schema === b.schema && a.name === b.name;
14
+ const over = (await resolve(db, models.map((model) => model.table))).filter((table) => store.some((own) => same(own, table)));
15
+ if (over.length === 0) return;
16
+ const named = over.map((table) => `${models[table.n - 1].name} (${table.schema}.${table.name})`).join(", ");
17
+ throw new Error(`Resources over the auth store's tables, which hold password hashes, sessions and tokens: ${named}. Remove them from the config; the auth store is read through Better Auth alone.`);
18
+ };
19
+ //#endregion
20
+ export { checkResourcesOutsideAuthStore };
@@ -0,0 +1,13 @@
1
+ import { Kysely, PostgresDialect } from "kysely";
2
+ //#region src/better-auth/store/store-db.ts
3
+ /**
4
+ * A Kysely on the admin store's connections: `createAuth`'s `database`, a `pg` Pool or `{ dialect, type: 'postgres' }`.
5
+ * The pool is the app's, so it is never destroyed here.
6
+ */
7
+ const storeDb = ({ options: { database } }) => {
8
+ if (database && typeof database === "object" && "dialect" in database) return new Kysely({ dialect: database.dialect });
9
+ if (database && typeof database === "object" && "connect" in database) return new Kysely({ dialect: new PostgresDialect({ pool: database }) });
10
+ throw new Error("The admin store's database is neither a pg Pool nor { dialect, type: 'postgres' }");
11
+ };
12
+ //#endregion
13
+ export { storeDb };
@@ -0,0 +1,2 @@
1
+ import "../user-table.js";
2
+ import "../create-auth.js";
@@ -0,0 +1,14 @@
1
+ import { sql } from "kysely";
2
+ //#region src/better-auth/store/store-names.ts
3
+ /** The schema the admin store lives in; the search path decides when its options name none. */
4
+ const storeSchema = ({ options: { database } }) => database && "schemaName" in database ? database.schemaName : void 0;
5
+ /** The store's configured names, from the app's auth. */
6
+ const storeNames = (auth) => ({
7
+ schema: storeSchema(auth),
8
+ users: auth.userTable,
9
+ uuidIds: auth.options.advanced?.database?.generateId === "uuid"
10
+ });
11
+ /** A table of the store, in its schema, as an identifier for `ddl`. */
12
+ const storeTable = ({ schema }, name) => schema === void 0 ? sql.id(name) : sql.id(schema, name);
13
+ //#endregion
14
+ export { storeNames, storeSchema, storeTable };
@@ -0,0 +1,7 @@
1
+ //#region src/better-auth/store/table-names.d.ts
2
+ /**
3
+ * The admin store's tables besides the user table, whose name the app may configure: every feature's, which the store
4
+ * has whether the app turns the feature on or not, and the record of its migrations.
5
+ */
6
+ export declare const storeTableNames: string[];
7
+ //#endregion
@@ -0,0 +1,10 @@
1
+ import { storeMigrations } from "./migrations/index.js";
2
+ import { migrationsTableName } from "./migrations-table.js";
3
+ //#region src/better-auth/store/table-names.ts
4
+ /**
5
+ * The admin store's tables besides the user table, whose name the app may configure: every feature's, which the store
6
+ * has whether the app turns the feature on or not, and the record of its migrations.
7
+ */
8
+ const storeTableNames = [...storeMigrations.flatMap((migration) => migration.tables), migrationsTableName];
9
+ //#endregion
10
+ export { storeTableNames };
@@ -16,7 +16,7 @@ const userFields = {
16
16
  last_role: "lastRole",
17
17
  last_organization_id: "lastOrganizationId"
18
18
  };
19
- /** The user table's names, from `createAuth`'s `users` option; unknown columns are an error. */
19
+ /** The user table's names, from `auth.users` option; unknown columns are an error. */
20
20
  const userTable = ({ table = "user", columns = {}, metadata } = {}) => {
21
21
  const unknown = Object.keys(columns).find((name) => !(name in userFields));
22
22
  if (unknown !== void 0) throw new Error(`users.columns names "${unknown}", which is not a column of the user table: ${Object.keys(userFields).join(", ")}`);
@@ -1,5 +1,5 @@
1
- import { AdminAuth } from "./create-auth.js";
2
1
  import { parseRoles } from "./parse-roles.js";
2
+ import { AdminAuth } from "./create-auth.js";
3
3
  //#region src/better-auth/users.d.ts
4
4
  /** The roles this auth instance allows, `admin` first. */
5
5
  export declare const roleChoices: (auth: AdminAuth) => string[];
@@ -10,7 +10,7 @@ export type LinkedAccount = {
10
10
  };
11
11
  /**
12
12
  * Without `password` the user signs in by emailed code, passkey or a sign-in provider only. `metadata` lands in the
13
- * user metadata column, which `createAuth`'s `users.metadata` names; it needs one.
13
+ * user metadata column, which `auth.users.metadata` names; it needs one.
14
14
  */
15
15
  export type NewUser = {
16
16
  email: string;
@@ -1,5 +1,5 @@
1
- import "../better-auth/create-auth.js";
2
1
  import { TenantValue } from "../types.js";
2
+ import "../better-auth/create-auth.js";
3
3
  //#region src/comments/comment-users.d.ts
4
4
  /** The users comments name, mention and mail: from the project's auth. */
5
5
  export type CommentUsers = {
@@ -0,0 +1,2 @@
1
+ import { configExports } from "./resource-source.js";
2
+ export { configExports };
@@ -0,0 +1,2 @@
1
+ import { configExports } from "./resource-source.js";
2
+ export { configExports };
@@ -1,7 +1,6 @@
1
1
  import { MobileConfig } from "./mobile-config.js";
2
2
  import { AppIdentity } from "./app-identity.js";
3
3
  import { AppIcons } from "./web-app/app-icons.js";
4
- import { AdminAuth } from "./better-auth/create-auth.js";
5
4
  import { EventsOptions } from "./changes/events-options.js";
6
5
  import { JobDefinition } from "./jobs/job-types.js";
7
6
  import { Admin, Authenticator, PageSource, ViewSource } from "./types.js";
@@ -15,6 +14,7 @@ import { Difficulty } from "./forms/challenge.js";
15
14
  import { ResourceSource } from "./resource-source.js";
16
15
  import { FunctionSource } from "./functions/define-function.js";
17
16
  import { AdminOptions } from "./admin-options.js";
17
+ import { AdminAuth } from "./better-auth/create-auth.js";
18
18
  import { BottomBarSource, UserMenuSource } from "@protobase/schema";
19
19
  import { Db } from "@protobase/query";
20
20
  import { JWTPayload } from "jose";
@@ -35,6 +35,8 @@ export type CreateAdminInput = {
35
35
  auth?: AdminAuth;
36
36
  /** API functions of the app's own, each served at `<systemPath>/functions/<name>` (see `defineFunction`). */
37
37
  functions?: Record<string, FunctionSource>;
38
+ /** The app's secret (`secret`): it signs public forms' bot checks, and upload tickets unless `files.secret` names another. */
39
+ secret?: string;
38
40
  /** Where file fields keep their bytes (see `FilesOptions`). */
39
41
  files?: FilesOptions;
40
42
  /** Where the changes that resources' events are raised from are captured (see `EventsOptions`). */
@@ -45,9 +47,9 @@ export type CreateAdminInput = {
45
47
  jobs?: JobDefinition[];
46
48
  /** Where the resources' events are delivered (`subscription(...)` exports of the config module). */
47
49
  subscriptions?: SubscriptionDefinition[];
48
- /** Webhook subscriptions made in the admin app, from `extends: [webhooks()]` (see `WebhooksOptions`). */
50
+ /** Webhook subscriptions made in the admin app, from `webhooks: {}` (see `WebhooksOptions`). */
49
51
  webhooks?: WebhooksOptions;
50
- /** Each user's devices and the endpoints that register them, from `extends: [notifications()]` (see `NotificationsOptions`). */
52
+ /** Each user's devices and the endpoints that register them, from `notifications: {}` (see `NotificationsOptions`). */
51
53
  notifications?: NotificationsOptions;
52
54
  /**
53
55
  * The app's iOS and Android build (see `MobileConfig`): the API answers its Capacitor origins through CORS, and sign-in
@@ -88,5 +90,5 @@ export type CreateAdminInput = {
88
90
  upgradeWebSocket?: UpgradeWebSocket;
89
91
  };
90
92
  /** The admin REST API as a Hono app. It uses only Web APIs, so it runs on Node, Workers and anywhere else Hono does. */
91
- export declare const createAdmin: ({ resources: appResources, views: appViews, pages, userMenu, bottomBars, db, authenticate, auth, functions, files: filesOptions, events, history: historyOptions, jobs, subscriptions, webhooks: webhooksOptions, notifications, mobile, app: identity, icons, bundlePlugins, fieldTypes, options, formsDifficulty, commentUsers: givenCommentUsers, verifyToken, upgradeWebSocket }: CreateAdminInput) => Admin;
93
+ export declare const createAdmin: ({ resources: appResources, views: appViews, pages, userMenu, bottomBars, db, authenticate, auth, functions, secret, files: filesOptions, events, history: historyOptions, jobs, subscriptions, webhooks: webhooksOptions, notifications, mobile, app: identity, icons, bundlePlugins, fieldTypes, options, formsDifficulty, commentUsers: givenCommentUsers, verifyToken, upgradeWebSocket }: CreateAdminInput) => Admin;
92
94
  //#endregion
@@ -103,7 +103,7 @@ const declaredRoles = (auth, roles) => {
103
103
  return names.length > 0 ? [...new Set(names)] : void 0;
104
104
  };
105
105
  /** The admin REST API as a Hono app. It uses only Web APIs, so it runs on Node, Workers and anywhere else Hono does. */
106
- const createAdmin = ({ resources: appResources, views: appViews = [], pages = [], userMenu, bottomBars = [], db, authenticate, auth, functions = {}, files: filesOptions, events, history: historyOptions, jobs = [], subscriptions = [], webhooks: webhooksOptions, notifications, mobile, app: identity, icons, bundlePlugins = [], fieldTypes = {}, options = {}, formsDifficulty, commentUsers: givenCommentUsers, verifyToken, upgradeWebSocket }) => {
106
+ const createAdmin = ({ resources: appResources, views: appViews = [], pages = [], userMenu, bottomBars = [], db, authenticate, auth, functions = {}, secret, files: filesOptions, events, history: historyOptions, jobs = [], subscriptions = [], webhooks: webhooksOptions, notifications, mobile, app: identity, icons, bundlePlugins = [], fieldTypes = {}, options = {}, formsDifficulty, commentUsers: givenCommentUsers, verifyToken, upgradeWebSocket }) => {
107
107
  const basePath = options.basePath ?? "/api/v1";
108
108
  const appModels = appResources.map((resource) => resource.toModel());
109
109
  const withComments = appModels.some((model) => model.comments);
@@ -154,6 +154,7 @@ const createAdmin = ({ resources: appResources, views: appViews = [], pages = []
154
154
  views: viewModels,
155
155
  limits: options.roles?.limits ?? [],
156
156
  env: globalThis.process?.env ?? {},
157
+ ...secret && { secret },
157
158
  ...formsDifficulty && { difficulty: formsDifficulty }
158
159
  });
159
160
  const systemPath = basePath.slice(0, basePath.lastIndexOf("/"));
@@ -178,6 +179,7 @@ const createAdmin = ({ resources: appResources, views: appViews = [], pages = []
178
179
  });
179
180
  const files = createFilesRuntime({
180
181
  ...filesOptions && { options: filesOptions },
182
+ ...secret && { secret },
181
183
  env: globalThis.process?.env ?? {},
182
184
  models: registry.entries.map((entry) => entry.model),
183
185
  systemPath,
@@ -27,7 +27,7 @@ const entriesOf = (env) => {
27
27
  }))];
28
28
  };
29
29
  const checkApart = (entries, env) => {
30
- for (const name of ["BETTER_AUTH_SECRET", "PROTOBASE_SECRET_KEY"]) {
30
+ for (const name of ["PROTOBASE_SECRET", "PROTOBASE_SECRET_KEY"]) {
31
31
  const secret = env[name]?.trim();
32
32
  const same = secret && entries.find((entry) => entry.text === secret);
33
33
  if (same) throw new Error(`${same.where} is the same as ${name}: give encryption a key of its own`);
@@ -1,21 +1,18 @@
1
1
  import { Sharp } from "./images.js";
2
2
  import { FileProvider } from "./store.js";
3
3
  //#region src/files/options.d.ts
4
- /** `files` in `protobase.config.ts`. Environment variables override it (see `resolveProviders`). */
4
+ /** Where file fields keep their bytes, as the API runs with them: `files` of `protobase.config.ts` with its providers made. Environment variables override it (see `resolveProviders`). */
5
5
  export type FilesOptions = {
6
6
  /**
7
- * Providers by name, such as `private: localFiles({ dir: './data/files' })`. A name is part of every stored value, so
8
- * name the role (`archive`), not the vendor. Without config, `private` and `public` are folders under `data/files`.
7
+ * Providers by name. A name is part of every stored value, so name the role (`archive`), not the vendor. Without
8
+ * config, `private` and `public` are folders under `data/files`.
9
9
  */
10
10
  providers?: Record<string, FileProvider>;
11
11
  /** How long bytes outlive their last reference, for restores; default `1 day`. Public providers default to 0. */
12
12
  retention?: number | string;
13
- /** Signs upload tickets and download URLs; default `PROTOBASE_FILES_SECRET`, then `BETTER_AUTH_SECRET`. */
13
+ /** Signs upload tickets and download URLs; default `PROTOBASE_FILES_SECRET`, then the app's `secret` (`PROTOBASE_SECRET`). */
14
14
  secret?: string;
15
- /**
16
- * The image library that makes the variants and placeholders of image fields: `import sharp from 'sharp'` in the
17
- * config, so a built bundle carries it with its native add-on.
18
- */
15
+ /** The image library that makes the variants and placeholders of image fields: sharp's default export. */
19
16
  sharp?: Sharp;
20
17
  /**
21
18
  * Hosts whose images the admin app draws with the page's referrer, besides the app's own and those its providers link
@@ -0,0 +1,16 @@
1
+ import { FileProvider } from "./store.js";
2
+ import { LocalFilesOptions } from "./local-files.js";
3
+ import { S3FilesOptions } from "./s3-files.js";
4
+ //#region src/files/provider-settings.d.ts
5
+ /**
6
+ * A built-in file provider in `files.providers`, as data: `{ kind: 'local', dir }`, a folder on local disk, or
7
+ * `{ kind: 's3', bucket }`, an S3-compatible bucket. The provider is made when the app serves.
8
+ */
9
+ export type FileProviderSettings = ({
10
+ kind: 'local';
11
+ } & LocalFilesOptions) | ({
12
+ kind: 's3';
13
+ } & S3FilesOptions);
14
+ /** The provider the settings describe. */
15
+ export declare const fileProviderOf: (name: string, settings: FileProviderSettings) => FileProvider;
16
+ //#endregion
@@ -0,0 +1,17 @@
1
+ import { localFiles } from "./local-files.js";
2
+ import { s3Files } from "./s3-files.js";
3
+ //#region src/files/provider-settings.ts
4
+ /** The provider the settings describe. */
5
+ const fileProviderOf = (name, settings) => {
6
+ if (settings.kind === "local") {
7
+ const { kind: _, ...options } = settings;
8
+ return localFiles(options);
9
+ }
10
+ if (settings.kind === "s3") {
11
+ const { kind: _, ...options } = settings;
12
+ return s3Files(options);
13
+ }
14
+ throw new Error(`files.providers.${name}: kind is "local", "s3" or "custom", whose provider is the default export of files/${name}.ts`);
15
+ };
16
+ //#endregion
17
+ export { fileProviderOf };
@@ -13,7 +13,7 @@ const imageFields = (models) => models.flatMap((model) => Object.values(model.fi
13
13
  * The runtime, when a resource has a file field, the config names providers or the app serves `/api/sb/storage/v1`. It fails at startup when a field's
14
14
  * provider is not configured, nothing signs uploads, or a field makes image variants or placeholders without sharp.
15
15
  */
16
- const createFilesRuntime = ({ options = {}, env, models, systemPath, storage: servesStorage = false }) => {
16
+ const createFilesRuntime = ({ options = {}, env, secret: appSecret, models, systemPath, storage: servesStorage = false }) => {
17
17
  const storageName = servesStorage ? storageProviderName(options) : void 0;
18
18
  const storage = storageName && options.storage !== false ? {
19
19
  provider: storageName,
@@ -22,10 +22,10 @@ const createFilesRuntime = ({ options = {}, env, models, systemPath, storage: se
22
22
  const fieldProviders = models.flatMap((model) => Object.values(model.fields).flatMap((field) => field.file ? [field.file.provider] : []));
23
23
  const used = [.../* @__PURE__ */ new Set([...fieldProviders, ...storage ? [storage.provider] : []])];
24
24
  if (used.length === 0 && !options.providers) return void 0;
25
- const secret = options.secret ?? env.PROTOBASE_FILES_SECRET ?? env.BETTER_AUTH_SECRET;
26
- if (!secret) throw new Error("File fields and /api/sb/storage/v1 need a secret to sign uploads: set BETTER_AUTH_SECRET, PROTOBASE_FILES_SECRET or files.secret");
25
+ const secret = options.secret ?? env.PROTOBASE_FILES_SECRET ?? appSecret ?? env.PROTOBASE_SECRET;
26
+ if (!secret) throw new Error("File fields and /api/sb/storage/v1 need a secret to sign uploads: set secret in protobase.config.ts, files.secret or PROTOBASE_FILES_SECRET");
27
27
  const images = imageFields(models);
28
- if (images.length > 0 && !options.sharp) throw new Error(`${images.join(", ")} make image variants or placeholders, which need sharp: add it to the project (bun add sharp), then import sharp from 'sharp' in the config and pass files: { sharp }`);
28
+ if (images.length > 0 && !options.sharp) throw new Error(`${images.join(", ")} make image variants or placeholders, which need sharp: add it to the project (bun add sharp), then give the config files: { sharp: () => import('sharp') }`);
29
29
  const providers = resolveProviders(options, env, used);
30
30
  const retention = retentionOf(options, env);
31
31
  return {
@@ -12,15 +12,15 @@ const anonymousCreates = (limits) => (resource) => {
12
12
  * The public forms of the views, checked, with the challenges that guard them and their rate limit; `undefined` without
13
13
  * any. Fails at startup on a form that cannot be served and when nothing signs the challenges.
14
14
  */
15
- const createFormsRuntime = ({ registry, views, limits, env, difficulty }) => {
15
+ const createFormsRuntime = ({ registry, views, limits, env, secret: appSecret, difficulty }) => {
16
16
  const declared = [...views].sort((a, b) => Number(a.roles !== void 0) - Number(b.roles !== void 0)).flatMap((view) => (view.forms ?? []).map((form) => ({
17
17
  form,
18
18
  view
19
19
  })));
20
20
  if (declared.length === 0) return void 0;
21
21
  const forms = checkForms(registry, declared, anonymousCreates(limits));
22
- const secret = env.PROTOBASE_FORMS_SECRET ?? env.BETTER_AUTH_SECRET;
23
- if (!secret) throw new Error("Public forms need a secret to sign their bot checks: set PROTOBASE_FORMS_SECRET or BETTER_AUTH_SECRET");
22
+ const secret = env.PROTOBASE_FORMS_SECRET ?? appSecret ?? env.PROTOBASE_SECRET;
23
+ if (!secret) throw new Error("Public forms need a secret to sign their bot checks: set secret in protobase.config.ts, or PROTOBASE_FORMS_SECRET");
24
24
  return {
25
25
  forms,
26
26
  challenges: createFormChallenges(secret, { ...difficulty && { difficulty } }),
package/dist/index.d.ts CHANGED
@@ -1,18 +1,9 @@
1
1
  import { MobileConfig } from "./mobile-config.js";
2
2
  import { AppIdentity } from "./app-identity.js";
3
3
  import { AppIcons, PngIcon, pngIcons } from "./web-app/app-icons.js";
4
- import { StaffSignIn } from "./better-auth/staff-log.js";
5
- import { RoleDefinition, RolesInput } from "./better-auth/organizations/role-definitions.js";
6
- import { MailMessage, Mailer } from "./mail/smtp-mailer.js";
7
- import { OperatorProvider, readOperatorSettings } from "./better-auth/operator-provider.js";
8
- import { OrganizationRole, StoredMember, StoredOrganization } from "./better-auth/organizations/store.js";
9
- import { SignInPolicy, SignInRule, StaffAccessRule, defaultSignInPolicy, signInPolicyMethods } from "./better-auth/sign-in-policy.js";
10
- import { OrganizationsOptions } from "./better-auth/organizations/options.js";
11
- import { PlatformSignIn, readPlatformSignIn } from "./better-auth/platform-sign-in.js";
12
- import { EmailComponent, EmailOptions, EmailTemplate, RenderedEmail, defineEmail } from "./mail/define-email.js";
13
- import { AdminAuth, CreateAuthOptions, UserCreatedHook, createAuth, normalizeRoles } from "./better-auth/create-auth.js";
14
4
  import { EventsOptions } from "./changes/events-options.js";
15
5
  import { StandardSchema, readJson } from "./functions/read-json.js";
6
+ import { MailMessage, Mailer } from "./mail/smtp-mailer.js";
16
7
  import { JsonObject, JsonValue } from "./notifications/json-value.js";
17
8
  import { HistoryPosition, NewNotification, StoredNotification, historyIdPattern, historyLimits } from "./notifications/history.js";
18
9
  import { PushMessage, PushMessageError, Urgency, WebPushFields, maxTtlSeconds, pushMessage, urgencies } from "./notifications/message.js";
@@ -60,28 +51,38 @@ import { RuntimeOptions, runtimeUrl, runtimeVariable, seesRuntime } from "./runt
60
51
  import { AdminOptions } from "./admin-options.js";
61
52
  import { CreateAdminInput, createAdmin } from "./create-admin.js";
62
53
  import { handleDroppedConnections } from "./dropped-connections.js";
63
- import { AppPoolConfig, PgModule, appPool, longQueryPool, poolWaitMs, readDbConnections } from "./app-pool.js";
54
+ import { AppPoolConfig, PgModule, poolWaitMs, readDbConnections } from "./app-pool.js";
64
55
  import { ConnectionsBusy } from "./connections-busy.js";
65
56
  import { isBackgroundWork, runInBackground, wantsLongQueries } from "./background-work.js";
66
57
  import { longQueryTimeoutMs } from "./statement-timeout.js";
67
58
  import { checkViewQueries } from "./check-view-queries.js";
68
- import { ProjectConfig, defineConfig, mergeConfig } from "./project-config.js";
69
59
  import { consoleAuditQueue } from "./audit/console-queue.js";
70
60
  import { JwtOptions, JwtVerifyOptions, jwtAuthenticator, jwtVerifier } from "./auth/jwt.js";
61
+ import { SignInPolicy, SignInRule, StaffAccessRule, defaultSignInPolicy, signInPolicyMethods } from "./better-auth/sign-in-policy.js";
62
+ import { StaffSignIn } from "./better-auth/staff-log.js";
63
+ import { RoleDefinition, RolesInput } from "./better-auth/organizations/role-definitions.js";
64
+ import { OrganizationRole, StoredMember, StoredOrganization } from "./better-auth/organizations/store.js";
65
+ import { OrganizationsOptions } from "./better-auth/organizations/options.js";
66
+ import { AuthHooks, AuthSettings, HookContext } from "./better-auth/auth-settings.js";
71
67
  import { TrustedApp, withTrustedApps } from "./better-auth/app-tokens.js";
72
- import { BetterAuthAuthenticator, BetterAuthAuthenticatorOptions, betterAuthAuthenticator, betterAuthTokens } from "./better-auth/authenticator.js";
68
+ import { BetterAuthAuthenticator, BetterAuthAuthenticatorOptions, betterAuthTokens } from "./better-auth/authenticator.js";
69
+ import { AuthenticateSettings } from "./better-auth/authenticate-settings.js";
73
70
  import { parseRoles } from "./better-auth/parse-roles.js";
74
71
  import { LinkedAccount, NewUser, StoredUser, createUser, deleteUser, hasUsers, listUsers, roleChoices, setUserBanned, setUserRole } from "./better-auth/users.js";
75
72
  import { IssueTokenOptions, issueToken, maxTokenTtlSeconds } from "./better-auth/tokens.js";
76
73
  import { passwordLength } from "./better-auth/new-account-password.js";
74
+ import { OperatorProvider, readOperatorSettings } from "./better-auth/operator-provider.js";
77
75
  import { isOAuthWellKnownPath, oauthWellKnownPaths, webauthnPath } from "./better-auth/origins.js";
78
76
  import { goTruePath } from "./gotrue/keys.js";
79
77
  import { supabasePath } from "./supabase-paths.js";
80
78
  import { realtimeLimits } from "./realtime/realtime-limits.js";
81
79
  import { capSocketMessages, honorSocketMessageCaps, socketMessageCapOf } from "./functions/socket-message-cap.js";
82
- import { defaultAppName, shownAppName } from "./app-name.js";
80
+ import { appNameOver, defaultAppName, shownAppName } from "./app-name.js";
83
81
  import { webManifestPath } from "./web-app/web-manifest-route.js";
82
+ import { PlatformSignIn, readPlatformSignIn } from "./better-auth/platform-sign-in.js";
84
83
  import { authSchemaMigration, checkAuthSchema } from "./better-auth/auth-schema.js";
84
+ import { authSchemaDrift } from "./better-auth/store/drift.js";
85
+ import { checkResourcesOutsideAuthStore } from "./better-auth/store/resources-outside.js";
85
86
  import { changesMigration, checkChanges, migrationCommand } from "./changes/capture-schema.js";
86
87
  import { checkComputed, computedMigration } from "./computed/computed-schema.js";
87
88
  import { isCaptured } from "./changes/capture-sql.js";
@@ -90,12 +91,10 @@ import { ResourceChange, recordOf, resourceChange } from "./changes/resource-cha
90
91
  import { eventMatcher } from "./changes/match-events.js";
91
92
  import { parseColumns, readOutbox } from "./changes/outbox.js";
92
93
  import { newWebhookSecret } from "./webhooks/standard-webhooks.js";
93
- import { webhooks } from "./webhooks/table/plugin.js";
94
94
  import { checkWebhooksSchema, webhooksMigration } from "./webhooks/table/schema.js";
95
95
  import { checkComments, commentsMigration } from "./comments/comments-sql.js";
96
96
  import { CheckAiInput, checkAi } from "./ai/check-ai.js";
97
97
  import { CommentItem } from "./comments/comment-item.js";
98
- import { notifications } from "./notifications/plugin.js";
99
98
  import { checkNotificationsSchema, notificationsMigration } from "./notifications/schema.js";
100
99
  import { deviceStore, removeDevicesWithUsers } from "./notifications/device-store-of.js";
101
100
  import { DeviceStoreError, postgresDeviceStore } from "./notifications/postgres-store.js";
@@ -139,9 +138,10 @@ import { SignatureOptions, StandardWebhookOptions, verifySignature, verifyStanda
139
138
  import { requireEnv } from "./functions/require-env.js";
140
139
  import { backgroundSettled, waitUntil } from "./functions/wait-until.js";
141
140
  import { FileLimits, limitedFileStore, storeUsage } from "./files/limits.js";
142
- import { LocalFilesOptions, localFileStore, localFiles } from "./files/local-files.js";
141
+ import { LocalFilesOptions, localFileStore } from "./files/local-files.js";
142
+ import { S3Bucket, S3FilesOptions, S3ListPage, S3Object, s3FileStore } from "./files/s3-files.js";
143
+ import { FileProviderSettings } from "./files/provider-settings.js";
143
144
  import { StoreFileInput, storeFile } from "./files/store-file.js";
144
- import { S3Bucket, S3FilesOptions, S3ListPage, S3Object, s3FileStore, s3Files } from "./files/s3-files.js";
145
145
  import { storageProvider } from "./files/storage-provider.js";
146
146
  import { objectKey } from "./storage/object-key.js";
147
147
  import { FileCleanupInput, createFileCleanup } from "./files/file-cleanup.js";
@@ -154,11 +154,14 @@ import { FileRef, formatUri, variantPath } from "./files/uri.js";
154
154
  import { aspectRatio, fileSize, fileType, imageSize, processor } from "./files/processors.js";
155
155
  import { defineJob, isJobDefinition, jobDefinitions } from "./jobs/define-job.js";
156
156
  import { FatalJobError } from "./jobs/run-job.js";
157
+ import { JobDeclaration, JobRun, enqueueJob } from "./jobs/declared-job.js";
157
158
  import { isSchedule } from "./jobs/schedule.js";
159
+ import { EmailComponent, EmailOptions, EmailTemplate, RenderedEmail, defineEmail } from "./mail/define-email.js";
158
160
  import { DrainResult, JobsRuntime, StartJobsOptions, startJobs } from "./jobs/runtime.js";
159
161
  import { jobsDrainApp } from "./jobs/drain-route.js";
160
162
  import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
161
163
  import { MobileRelease, ReleaseFile, ServedReleaseFile, composeRelease, releaseManifest } from "./mobile-release/release.js";
162
164
  import { MobileReleaseAppInput, OfferedRelease, mobileReleaseApp } from "./mobile-release/release-app.js";
163
165
  import { mobileSigningKeyVariable, readSigningKey } from "./mobile-release/signing-key.js";
164
- export { type Admin, type AdminAuth, type AdminOptions, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApnsEnvironment, type AppIcons, type AppIdentity, type AppPoolConfig, type ApplyOptions, type ApplyResult, type ApprovalAnswer, type ApprovalRequest, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type Authenticator, type BatchOperation, type BatchResult, type BetterAuthAuthenticator, type BetterAuthAuthenticatorOptions, type Caller, type CallerOptions, type CapturedRow, type CascadingKey, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentUsers, type Completion, type CompletionOptions, ConnectionsBusy, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type Device, type DeviceColumn, type DeviceKind, type DeviceStore, DeviceStoreError, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EncryptionStatus, type EncryptionTools, type EncryptionToolsInput, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FieldApplied, type FieldStatus, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSocket, type FunctionSource, type HistoryColumn, type HistoryOptions, type HistoryPosition, type HistoryStore, HistoryStoreError, HttpProblem, type IssueTokenOptions, type JobContext, type JobDefinition, type JobOptions, type JobsRuntime, type JsonObject, type JsonValue, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type LocalFilesOptions, type MailMessage, type Mailer, type MapLayer, type MapOptions, type MapSettings, type McpApprovals, type McpGateInput, type McpHandlerInput, type McpRoutesInput, type McpServerInput, type McpToolsInput, type McpWrites, type MemberInput, type Membership, MissingCredentials, type MobileConfig, type MobileRelease, type MobileReleaseAppInput, ModelError, type ModelSettings, type NewDevice, type NewNotification, type NewOrganization, type NewUser, type NotificationRecipients, NotificationSendError, type NotificationsOptions, type OfferedRelease, type OperatorProvider, type OrganizationRole, type OrganizationsOptions, type PgModule, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProjectConfig, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type PushAnswer, type PushMessage, PushMessageError, type PushSender, type QueryOptions, type QueryResult, type ReadableResources, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordKeyInput, type RecordPage, type ReleaseFile, type RenderedEmail, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RunContext, type RuntimeOptions, type S3Bucket, type S3FilesOptions, type S3ListPage, type S3Object, type ScanGuardMode, type ScheduledDelete, type SendNotification, type ServedReleaseFile, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SocketEvents, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StoreFileInput, type StoredMember, type StoredNotification, type StoredObject, type StoredOrganization, type StoredUser, type StrayValues, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TenantValue, type ToolAnnotations, type ToolCall, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type UnreadableEntry, type Urgency, type User, type UserCreatedHook, type VapidSettings, type ViewSource, type WebPushFields, type WebPushOptions, type WebhooksOptions, type WidgetOptions, type WriteEvent, type WriteOperation, type WriteRecordToolsInput, addAppRoleToOwners, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, appPool, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthAuthenticator, betterAuthTokens, capSocketMessages, changesMigration, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkNotificationsSchema, checkQueryRunner, checkSourceNames, checkViewQueries, checkWebhooksSchema, coalesce, commentsMigration, composeRelease, computedMigration, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineConfig, defineEmail, defineFunction, defineJob, defineTool, deleteRecordTool, deleteUser, deviceIdParam, deviceStore, devicesPath, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, localFiles, longQueryPool, longQueryTimeoutMs, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpRoutes, mcpServer, mcpToolContext, mcpTools, mergeConfig, migrationCommand, mobileReleaseApp, mobileSigningKeyVariable, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notifications, notificationsMigration, oauthWellKnownPaths, objectKey, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readDbConnections, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readRecordTools, readSigningKey, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, recordOf, releaseManifest, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, s3Files, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, startErrorReporting, startJobs, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, thumbHash, unauthorized, updateRecordTool, urgencies, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhooks, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, writeRecordTools };
166
+ import { AdminAuth, CreateAuthOptions, UserCreatedHook, normalizeRoles } from "./better-auth/create-auth.js";
167
+ export { type Admin, type AdminAuth, type AdminOptions, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApnsEnvironment, type AppIcons, type AppIdentity, type AppPoolConfig, type ApplyOptions, type ApplyResult, type ApprovalAnswer, type ApprovalRequest, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type AuthHooks, type AuthSettings, type AuthenticateSettings, type Authenticator, type BatchOperation, type BatchResult, type BetterAuthAuthenticator, type BetterAuthAuthenticatorOptions, type Caller, type CallerOptions, type CapturedRow, type CascadingKey, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentUsers, type Completion, type CompletionOptions, ConnectionsBusy, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type Device, type DeviceColumn, type DeviceKind, type DeviceStore, DeviceStoreError, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EncryptionStatus, type EncryptionTools, type EncryptionToolsInput, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FieldApplied, type FieldStatus, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileProviderSettings, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSocket, type FunctionSource, type HistoryColumn, type HistoryOptions, type HistoryPosition, type HistoryStore, HistoryStoreError, type HookContext, HttpProblem, type IssueTokenOptions, type JobContext, type JobDeclaration, type JobDefinition, type JobOptions, type JobRun, type JobsRuntime, type JsonObject, type JsonValue, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type LocalFilesOptions, type MailMessage, type Mailer, type MapLayer, type MapOptions, type MapSettings, type McpApprovals, type McpGateInput, type McpHandlerInput, type McpRoutesInput, type McpServerInput, type McpToolsInput, type McpWrites, type MemberInput, type Membership, MissingCredentials, type MobileConfig, type MobileRelease, type MobileReleaseAppInput, ModelError, type ModelSettings, type NewDevice, type NewNotification, type NewOrganization, type NewUser, type NotificationRecipients, NotificationSendError, type NotificationsOptions, type OfferedRelease, type OperatorProvider, type OrganizationRole, type OrganizationsOptions, type PgModule, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type PushAnswer, type PushMessage, PushMessageError, type PushSender, type QueryOptions, type QueryResult, type ReadableResources, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordKeyInput, type RecordPage, type ReleaseFile, type RenderedEmail, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RunContext, type RuntimeOptions, type S3Bucket, type S3FilesOptions, type S3ListPage, type S3Object, type ScanGuardMode, type ScheduledDelete, type SendNotification, type ServedReleaseFile, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SocketEvents, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StoreFileInput, type StoredMember, type StoredNotification, type StoredObject, type StoredOrganization, type StoredUser, type StrayValues, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TenantValue, type ToolAnnotations, type ToolCall, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type UnreadableEntry, type Urgency, type User, type UserCreatedHook, type VapidSettings, type ViewSource, type WebPushFields, type WebPushOptions, type WebhooksOptions, type WidgetOptions, type WriteEvent, type WriteOperation, type WriteRecordToolsInput, addAppRoleToOwners, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, capSocketMessages, changesMigration, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkNotificationsSchema, checkQueryRunner, checkResourcesOutsideAuthStore, checkSourceNames, checkViewQueries, checkWebhooksSchema, coalesce, commentsMigration, composeRelease, computedMigration, configExports, consoleAuditQueue, conversationKey, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, defineTool, deleteRecordTool, deleteUser, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, mobileReleaseApp, mobileSigningKeyVariable, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readDbConnections, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readRecordTools, readSigningKey, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, recordOf, releaseManifest, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, startErrorReporting, startJobs, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, thumbHash, unauthorized, updateRecordTool, urgencies, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, writeRecordTools };