@supabase/lite 0.8.0 → 0.8.1-next.2

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/dist/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import * as _supabase_supabase_js from '@supabase/supabase-js';
2
2
  import { SupabaseClientOptions } from '@supabase/supabase-js';
3
- import { D as DefaultSchema, S as Schema } from './index-xv_pDjEt.js';
3
+ import { D as DefaultSchema, S as Schema } from './index-DKO3OQpz.js';
4
4
  import { Connection, ConnectionMigrator, MaybePromise as MaybePromise$1, SchemaDiffResult, PlanStep, PlanResult, IConnectionConfig, Dialect as Dialect$2, IntrospectResult as IntrospectResult$1, TransactionOptions } from '@supabase/lite';
5
5
  import * as hono_hono_base from 'hono/hono-base';
6
6
  import * as hono_utils_http_status from 'hono/utils/http-status';
7
7
  import * as hono_utils_types from 'hono/utils/types';
8
8
  import * as hono_types from 'hono/types';
9
9
  import * as hono from 'hono';
10
- import { MiddlewareHandler, Context } from 'hono';
10
+ import { Context, MiddlewareHandler } from 'hono';
11
11
  import { Kysely, KyselyPlugin } from 'kysely';
12
12
  import { ReadableStream as ReadableStream$1 } from 'node:stream/web';
13
- import { a as CacheDriver, b as CacheSetOptions, W as Where, c as IntrospectResult, M as MigrateScope, A as AnyAST, V as VarsContext, T as TransactionOptions$1, C as Connection$1 } from './Connection-D9UUTsjg.js';
14
- export { d as AST, e as ASTType, f as AggregateFunction, B as BaseAST, g as BodyResult, h as CheckConstraintInfo, i as ColumnDef, j as ColumnDiff, k as ColumnInfo, l as ColumnRef, m as CommentInfo, n as ConnectionContextOptions, o as ConnectionMigrator, p as CustomTypesInfo, D as DataLossError, q as DataLossWarning, r as DeleteAST, s as Dialect, t as DiffResult, E as EmbedDef, u as EmbedTransform, v as ExplainOptions, F as FiltersResult, w as ForeignKeyDiff, x as ForeignKeyInfo, y as FunctionInfo, H as HeadersResult, I as IConnectionConfig, z as IndexDiff, G as IndexInfo, J as InsertAST, K as IntrospectOptions, L as JoinDef, N as JoinMap, O as Meta, P as MigrationError, Q as OrderEntry, R as PlanResult, S as PlanStep, U as PlanStepType, X as PreferToken, Y as PrimaryKeyInfo, Z as Qb, _ as QbDelete, $ as QbInsert, a0 as QbSelect, a1 as QbUpdate, a2 as QueryAST, a3 as QueryParamsResult, a4 as RelationNotFoundError, a5 as RouteResult, a6 as RpcAST, a7 as RpcResult, a8 as SchemaDiffResult, a9 as SelectEntry, aa as SelectResult, ab as TableDiff, ac as TableInfo, ad as TextSearchValue, ae as TransformsResult, af as TranslatorConfig, ag as TriggerInfo, ah as UniqueConstraintInfo, ai as UpdateAST, aj as UpsertAST, ak as UpsertResult, al as ViewInfo, am as ViewOptionsMetadata, an as WhereValue, ao as isRef } from './Connection-D9UUTsjg.js';
13
+ import { a as CacheDriver, b as CacheSetOptions, W as Where, c as IntrospectResult, M as MigrateScope, A as AnyAST, V as VarsContext, T as TransactionOptions$1, C as Connection$1 } from './Connection-ZWTDByQ5.js';
14
+ export { d as AST, e as ASTType, f as AggregateFunction, B as BaseAST, g as BodyResult, h as CheckConstraintInfo, i as ColumnDef, j as ColumnDiff, k as ColumnInfo, l as ColumnRef, m as CommentInfo, n as ConnectionContextOptions, o as ConnectionMigrator, p as CustomTypesInfo, D as DataLossError, q as DataLossWarning, r as DeleteAST, s as Dialect, t as DiffResult, E as EmbedDef, u as EmbedTransform, v as ExplainOptions, F as FiltersResult, w as ForeignKeyDiff, x as ForeignKeyInfo, y as FunctionInfo, H as HeadersResult, I as IConnectionConfig, z as IndexDiff, G as IndexInfo, J as InsertAST, K as IntrospectOptions, L as JoinDef, N as JoinMap, O as Meta, P as MigrationError, Q as OrderEntry, R as PlanResult, S as PlanStep, U as PlanStepType, X as PreferToken, Y as PrimaryKeyInfo, Z as Qb, _ as QbDelete, $ as QbInsert, a0 as QbSelect, a1 as QbUpdate, a2 as QueryAST, a3 as QueryParamsResult, a4 as RelationNotFoundError, a5 as RouteResult, a6 as RpcAST, a7 as RpcResult, a8 as SchemaDiffResult, a9 as SelectEntry, aa as SelectResult, ab as TableDiff, ac as TableInfo, ad as TextSearchValue, ae as TransformsResult, af as TranslatorConfig, ag as TriggerInfo, ah as UniqueConstraintInfo, ai as UpdateAST, aj as UpsertAST, ak as UpsertResult, al as ViewInfo, am as ViewOptionsMetadata, an as WhereValue, ao as isRef } from './Connection-ZWTDByQ5.js';
15
15
  import { ParseResult } from 'libpg-query';
16
16
  import { DeparserOptions } from 'pgsql-deparser';
17
17
  import 'jsonv-ts';
@@ -88,6 +88,26 @@ interface IdentitiesTable {
88
88
  created_at: string;
89
89
  updated_at: string;
90
90
  }
91
+ interface FlowStateTable {
92
+ id: string;
93
+ user_id: string | null;
94
+ auth_code: string | null;
95
+ authentication_method: string;
96
+ code_challenge_method: string | null;
97
+ code_challenge: string | null;
98
+ provider_type: string;
99
+ provider_access_token: string | null;
100
+ provider_refresh_token: string | null;
101
+ auth_code_issued_at: string | null;
102
+ invite_token: string | null;
103
+ referrer: string | null;
104
+ oauth_client_state_id: string | null;
105
+ linking_target_id: string | null;
106
+ email_optional: boolean;
107
+ created_at: string;
108
+ updated_at: string;
109
+ }
110
+ type NewFlowState = Pick<FlowStateTable, "id" | "authentication_method" | "provider_type"> & Partial<Pick<FlowStateTable, "user_id" | "auth_code" | "code_challenge_method" | "code_challenge" | "invite_token" | "referrer" | "oauth_client_state_id" | "linking_target_id" | "email_optional">>;
91
111
  interface UserResponse {
92
112
  id: string;
93
113
  aud: string;
@@ -149,14 +169,28 @@ interface AuthConfig {
149
169
  otp_length?: number;
150
170
  otp_expiry?: number;
151
171
  smtp?: {
152
- sender_name?: string;
172
+ enabled?: boolean;
173
+ host?: string;
174
+ port?: number;
175
+ user?: string;
176
+ pass?: string;
153
177
  admin_email?: string;
178
+ sender_name?: string;
154
179
  };
155
180
  template?: Partial<Record<EmailTemplateType, EmailTemplateConfig>>;
156
181
  };
157
182
  enable_confirmations?: boolean;
158
183
  site_url?: string;
159
184
  additional_redirect_urls?: string[];
185
+ external?: Record<string, {
186
+ enabled?: boolean;
187
+ client_id?: string;
188
+ secret?: string;
189
+ url?: string;
190
+ redirect_uri?: string;
191
+ skip_nonce_check?: boolean;
192
+ email_optional?: boolean;
193
+ }>;
160
194
  }
161
195
  type EmailTemplateType = "invite" | "confirmation" | "recovery" | "magic_link" | "email_change";
162
196
  interface EmailTemplateConfig {
@@ -165,12 +199,28 @@ interface EmailTemplateConfig {
165
199
  }
166
200
 
167
201
  type Dialect$1 = "postgres" | "sqlite";
202
+ /** Bound `Connection#runInTransaction` — see db/Connection.ts for why this
203
+ * indirection exists (DO storage has no BEGIN/COMMIT over kysely). */
204
+ type TransactionRunner = <T>(fn: (trx: Kysely<any>) => Promise<T>) => Promise<T>;
168
205
  declare class AuthRepository {
169
206
  private db;
170
207
  private dialect;
208
+ private runInTransaction;
171
209
  private schema;
172
- constructor(db: Kysely<any>, dialect: Dialect$1);
210
+ constructor(db: Kysely<any>, dialect: Dialect$1, runInTransaction?: TransactionRunner);
173
211
  private bool;
212
+ /**
213
+ * Runs `fn` inside a database transaction, handing it a repository bound to
214
+ * the transaction's executor. All reads/writes performed through that
215
+ * repository (including this one's other methods) participate in the same
216
+ * transaction, and are rolled back together if `fn` throws.
217
+ *
218
+ * Callers that need existing private helpers (which close over `this.repo`)
219
+ * to run against the transaction should swap `this.repo` for the duration
220
+ * of the callback — safe because AuthService/AuthRepository instances are
221
+ * constructed fresh per request (see server/auth.ts createAuthService).
222
+ */
223
+ transaction<T>(fn: (repo: AuthRepository) => Promise<T>): Promise<T>;
174
224
  private table;
175
225
  private insertInto;
176
226
  private update;
@@ -178,9 +228,22 @@ declare class AuthRepository {
178
228
  findUserByEmail(email: string): Promise<UsersTable | null>;
179
229
  findUserById(id: string): Promise<UsersTable | null>;
180
230
  findUserByToken(column: string, token: string): Promise<UsersTable | null>;
231
+ /**
232
+ * Atomically consumes a one-time token: the UPDATE only matches a row whose
233
+ * `column` still holds `token`, so exactly one of two concurrent verifies
234
+ * for the same OTP can win, and a token rotated/cleared by another request
235
+ * (resend, a competing verify) no longer matches. Returns false when no row
236
+ * was updated — callers must treat that as an invalid/consumed token and
237
+ * mutate nothing further.
238
+ *
239
+ * This is the guard that survives on D1, whose `runInTransaction` cannot
240
+ * group statements (see D1SqliteConnection L131-140): a single conditional
241
+ * UPDATE with a rowcount check is atomic on every driver.
242
+ */
243
+ claimUserToken(userId: string, column: string, token: string): Promise<boolean>;
181
244
  createUser(user: Partial<UsersTable> & {
182
245
  id: string;
183
- email: string;
246
+ email: string | null;
184
247
  }): Promise<UsersTable>;
185
248
  updateUser(id: string, updates: Partial<UsersTable>): Promise<UsersTable | null>;
186
249
  createSession(session: {
@@ -216,6 +279,52 @@ declare class AuthRepository {
216
279
  }): Promise<IdentitiesTable>;
217
280
  findIdentitiesByUserId(userId: string): Promise<IdentitiesTable[]>;
218
281
  updateIdentity(id: string, updates: Partial<IdentitiesTable>): Promise<void>;
282
+ deleteIdentitiesExcept(userId: string, keepId: string): Promise<void>;
283
+ findIdentityByProviderAndId(provider: string, providerId: string): Promise<IdentitiesTable | null>;
284
+ findIdentitiesByEmails(emails: string[]): Promise<IdentitiesTable[]>;
285
+ createFlowState(flow: NewFlowState): Promise<FlowStateTable>;
286
+ findFlowStateById(id: string): Promise<FlowStateTable | null>;
287
+ findFlowStateByAuthCode(authCode: string): Promise<FlowStateTable | null>;
288
+ updateFlowState(id: string, updates: Partial<FlowStateTable>): Promise<void>;
289
+ /**
290
+ * Atomically claims a PKCE flow_state row for a callback: the UPDATE only
291
+ * matches (and thus only succeeds for) a row whose user_id is still null,
292
+ * so exactly one of two concurrent callbacks for the same state can win.
293
+ * Returns false if the row was already claimed (or no longer exists) —
294
+ * callers should treat that as a replay (flow_state_already_used).
295
+ */
296
+ claimFlowStateForPkce(id: string, updates: {
297
+ user_id: string;
298
+ provider_access_token: string;
299
+ provider_refresh_token: string;
300
+ auth_code_issued_at: string;
301
+ }): Promise<boolean>;
302
+ /**
303
+ * Atomically deletes a flow_state row, returning whether a row was
304
+ * actually removed. A single DELETE...WHERE id = ? is inherently atomic
305
+ * (at most one caller can ever delete a given row), so this doubles as the
306
+ * "claim" step for implicit-flow callbacks and PKCE auth-code redemption:
307
+ * only the caller that observes `true` may proceed to issue a session.
308
+ */
309
+ /**
310
+ * Deletes at most {@link FLOW_STATE_CLEANUP_BATCH} flow_state rows created
311
+ * before `cutoffIso`. Ports the flow_state statement of GoTrue's periodic
312
+ * cleanup (internal/models/cleanup.go L62):
313
+ *
314
+ * delete from "flow_state" where id in (
315
+ * select id from "flow_state" where created_at < now() - interval '24 hours'
316
+ * limit 100 for update skip locked);
317
+ *
318
+ * The bound is the point of that statement: cleanup must never turn into an
319
+ * unbounded delete that blocks the request it is piggybacking on (lite has
320
+ * no background scheduler, so this runs opportunistically on the /authorize
321
+ * insert path). A backlog is drained across subsequent /authorize calls.
322
+ * `for update skip locked` has no sqlite equivalent and is omitted; the
323
+ * id-in-subquery-with-LIMIT shape works on both dialects. Returns the number
324
+ * of rows removed.
325
+ */
326
+ deleteFlowStatesCreatedBefore(cutoffIso: string): Promise<number>;
327
+ deleteFlowState(id: string): Promise<boolean>;
219
328
  createAuditLogEntry(entry: {
220
329
  id: string;
221
330
  payload?: Record<string, unknown>;
@@ -323,6 +432,43 @@ declare class SendmailEmailDriver implements EmailDriver {
323
432
  }
324
433
  declare function formatSendmailMessage(from: string, message: EmailMessage): string;
325
434
 
435
+ interface SmtpTransporter {
436
+ sendMail(mail: Record<string, unknown>): Promise<unknown>;
437
+ }
438
+ type SmtpCreateTransport = (options: Record<string, unknown>) => SmtpTransporter;
439
+ type SmtpAddress = string | {
440
+ name?: string;
441
+ address: string;
442
+ };
443
+ interface SmtpEmailDriverOptions {
444
+ host: string;
445
+ port?: number;
446
+ user?: string;
447
+ pass?: string;
448
+ from: SmtpAddress;
449
+ secure?: boolean;
450
+ /** Default: true when user+pass are set and secure (implicit TLS) is false. Set false to opt out. */
451
+ requireTls?: boolean;
452
+ /** Node-only escape hatch for self-signed TLS certs; default true (validate). */
453
+ rejectUnauthorized?: boolean;
454
+ timeoutMs?: number;
455
+ /** Injectable for tests; defaults to nodemailer's createTransport. */
456
+ createTransport?: SmtpCreateTransport;
457
+ }
458
+ /** Pure mapper to nodemailer transport options, exported for tests. */
459
+ declare function buildSmtpTransportOptions(options: SmtpEmailDriverOptions): Record<string, unknown>;
460
+ /** Pure mapper to a nodemailer mail payload, exported for tests. */
461
+ declare function buildSmtpMail(from: SmtpAddress, message: EmailMessage): Record<string, unknown>;
462
+ /** Testable seam for the runtime guard below; real callers always pass isNode() || isBun(). */
463
+ declare function assertSmtpSupportedRuntime(isSupported: boolean): void;
464
+ declare class SmtpEmailDriver implements EmailDriver {
465
+ private readonly options;
466
+ private transporter?;
467
+ constructor(options: SmtpEmailDriverOptions);
468
+ send(message: EmailMessage): Promise<void>;
469
+ private getTransporter;
470
+ }
471
+
326
472
  interface EmailMessage {
327
473
  to: string;
328
474
  subject: string;
@@ -347,14 +493,14 @@ declare class InMemoryEmailDriver implements EmailDriver {
347
493
  clear(): void;
348
494
  private trim;
349
495
  }
350
- interface NoopEmailDriverOptions {
496
+ interface ConsoleEmailDriverOptions {
351
497
  silent?: boolean;
352
498
  logger?: Pick<Console, "info">;
353
499
  }
354
- declare class NoopEmailDriver extends InMemoryEmailDriver {
500
+ declare class ConsoleEmailDriver extends InMemoryEmailDriver {
355
501
  private readonly silent;
356
502
  private readonly logger;
357
- constructor(options?: NoopEmailDriverOptions);
503
+ constructor(options?: ConsoleEmailDriverOptions);
358
504
  send(message: EmailMessage): Promise<void>;
359
505
  }
360
506
 
@@ -382,7 +528,22 @@ interface AppDrivers {
382
528
  cache: CacheDriver;
383
529
  }
384
530
  type PartialAppDrivers = Partial<AppDrivers>;
385
- declare function createAppDrivers(drivers?: PartialAppDrivers): AppDrivers;
531
+ interface AppDriversConfig {
532
+ auth?: {
533
+ email?: {
534
+ smtp?: {
535
+ enabled?: boolean;
536
+ host?: string;
537
+ port?: number;
538
+ user?: string;
539
+ pass?: string;
540
+ admin_email?: string;
541
+ sender_name?: string;
542
+ };
543
+ };
544
+ };
545
+ }
546
+ declare function createAppDrivers(drivers?: PartialAppDrivers, config?: AppDriversConfig): AppDrivers;
386
547
 
387
548
  interface Mailer {
388
549
  sendConfirmation(email: string, token: string, otp: string, meta?: MailMeta): Promise<void>;
@@ -453,6 +614,11 @@ declare class AuthService {
453
614
  token_hash?: string;
454
615
  type: string;
455
616
  }): Promise<SessionResponse>;
617
+ /**
618
+ * The mutating half of {@link verifyOtp}, always run inside a transaction
619
+ * (`this.repo` is bound to it) — see the comment at the call site.
620
+ */
621
+ private completeVerifyOtp;
456
622
  recover(email: string | undefined): Promise<void>;
457
623
  resend(type: string, email: string | undefined): Promise<void>;
458
624
  reauthenticate(userId: string): Promise<void>;
@@ -465,6 +631,51 @@ declare class AuthService {
465
631
  private isTokenExpired;
466
632
  private getTokenColumnsForType;
467
633
  private createAuditLog;
634
+ /**
635
+ * Same entry shape as {@link createAuditLog}, for the call sites whose
636
+ * traits map is not `{provider: ...}` (GoTrue builds the map per call site;
637
+ * see models.NewAuditLogEntry's `traits map[string]any` argument).
638
+ */
639
+ private createAuditLogWithTraits;
640
+ getExternalProviderRedirectUrl(query: Record<string, string | undefined>, opts: {
641
+ refererHeader?: string;
642
+ defaultRedirectUri: string;
643
+ }): Promise<string>;
644
+ loadOAuthFlowState(state: string | undefined): Promise<FlowStateTable>;
645
+ resolveOAuthRedirectTarget(flowState: FlowStateTable): string;
646
+ handleExternalProviderCallback(flowState: FlowStateTable, params: Record<string, string | undefined>, opts: {
647
+ defaultRedirectUri: string;
648
+ }): Promise<{
649
+ type: "pkce" | "implicit";
650
+ redirectUrl: string;
651
+ }>;
652
+ /**
653
+ * Tail of the external-provider callback, shared by the account-linking and
654
+ * invite branches: claims the flow state and either hands back the PKCE
655
+ * auth code or issues a session in the URL fragment (external.go
656
+ * L221-286). Runs inside the callback's transaction — `this.repo` is
657
+ * already bound to it by the caller.
658
+ */
659
+ private issueOAuthCallbackResult;
660
+ /**
661
+ * Ports internal/api/external.go's processInvite (L449-514): accepts an
662
+ * invitation with an external identity. The invite token is the user's
663
+ * `confirmation_token` (models.FindUserByConfirmationToken), the external
664
+ * email must match the invited email, and the user is confirmed because
665
+ * they were able to respond to the invite email.
666
+ *
667
+ * Runs inside the callback's transaction (`this.repo` is bound to it).
668
+ */
669
+ private processInvite;
670
+ exchangePkceCode(authCode: string | undefined, codeVerifier: string | undefined): Promise<SessionResponse & {
671
+ provider_token?: string;
672
+ provider_refresh_token?: string;
673
+ }>;
674
+ private resolveOAuthReferrer;
675
+ private updateUserMetaDataAndProviders;
676
+ private buildAppMetaDataProviders;
677
+ private removeUnconfirmedIdentities;
678
+ private determineAccountLinking;
468
679
  }
469
680
 
470
681
  type CrossReadableStream = ReadableStream | ReadableStream$1;
@@ -726,10 +937,48 @@ type HonoContext = {
726
937
  userId?: string;
727
938
  sessionId?: string;
728
939
  jwt?: Record<string, unknown>;
940
+ apiKeyType?: "publishable" | "secret";
941
+ ignoreAuthorization?: boolean;
942
+ /**
943
+ * Set by `adminAuth()` when local admin mode elevated this request to
944
+ * `service_role`. Observability/tests only — the elevation itself is
945
+ * carried by `apiKeyType`/`ignoreAuthorization`/`jwt`.
946
+ */
947
+ admin?: boolean;
729
948
  };
730
949
  };
731
950
  type MaybePromise<T> = T | Promise<T>;
732
951
 
952
+ type ApiKeyType = "publishable" | "secret";
953
+ declare const SELF_HOSTED_PROJECT_REF = "supabase-self-hosted";
954
+ type GeneratedApiKey = {
955
+ key: string;
956
+ hash: string;
957
+ prefix: string;
958
+ type: ApiKeyType;
959
+ };
960
+ /**
961
+ * Generates an `sb_publishable_*` / `sb_secret_*` API key. Web-crypto only
962
+ * (`crypto.getRandomValues` / `crypto.subtle.digest`) so this also runs on
963
+ * Cloudflare Workers/DO — no `node:crypto`.
964
+ *
965
+ * Uses 17 random bytes truncated to a 22-char base64url body, so the full
966
+ * 132 bits of entropy fill those 22 chars (matches upstream self-hosted's
967
+ * `generateOpaqueKey`). If `randomBytes` is injected for testing, pass 17
968
+ * bytes to match production entropy.
969
+ */
970
+ declare function generateApiKey(type: ApiKeyType, ref?: string, randomBytes?: Uint8Array): Promise<GeneratedApiKey>;
971
+ declare function hashApiKey(key: string): Promise<string>;
972
+ /** Prefix sniff only — no checksum verification (that belongs to infra). */
973
+ declare function apiKeyType(key: string): ApiKeyType | null;
974
+
975
+ /** Claims are applied verbatim as `request.jwt.claims` — MUST include `role`. */
976
+ type ResolvedKey = {
977
+ type: ApiKeyType;
978
+ claims: Record<string, unknown>;
979
+ };
980
+ type ApiKeyResolver = (key: string, c: Context<HonoContext>) => Promise<ResolvedKey | null>;
981
+
733
982
  type ServerOptions = {
734
983
  middlewares?: MiddlewareHandler<HonoContext>[];
735
984
  disableStudio?: boolean;
@@ -738,6 +987,33 @@ type ServerOptions = {
738
987
  * Test-only PostgREST mode: execute each request in a transaction and roll it back.
739
988
  */
740
989
  forceRollback?: boolean;
990
+ /**
991
+ * `false` disables apikey enforcement outright. Otherwise a custom
992
+ * `resolver` can be supplied (the lite-platform seam); when omitted, keys
993
+ * configured under `config.auth.publishable_key`/`secret_key` are used.
994
+ */
995
+ apiKeys?: false | {
996
+ resolver?: ApiKeyResolver;
997
+ };
998
+ /**
999
+ * Local admin mode (default `false`): run *keyless* `/rest/v1` and
1000
+ * `/storage/v1` requests as `service_role`, so a browser studio can do
1001
+ * privileged work without a secret key shipping to the browser. Only
1002
+ * same-origin requests addressed to loopback are elevated.
1003
+ *
1004
+ * Two caveats, both local-dev only:
1005
+ * 1. RLS is not enforced for keyless traffic while this is on. To exercise
1006
+ * policies, send an `apikey`: the publishable key for `anon`, or the
1007
+ * publishable key PLUS `Authorization: Bearer <user JWT>` for
1008
+ * `authenticated`. Those requests are never elevated. A bearer token on
1009
+ * its own is rejected before RLS is reached (401), since opaque keys are
1010
+ * only sourced from `apikey`.
1011
+ * 2. Localhost trust is not per-request trust. Any page open in the
1012
+ * developer's browser can reach the server; the same-origin and
1013
+ * loopback guards are what keep that from being a data-exfiltration
1014
+ * hole. Never enable outside local development.
1015
+ */
1016
+ admin?: boolean;
741
1017
  };
742
1018
  declare function createServer(app: App, options?: ServerOptions): hono_hono_base.HonoBase<HonoContext & {
743
1019
  Variables: {
@@ -1050,32 +1326,9 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
1050
1326
  input: {};
1051
1327
  output: {
1052
1328
  external: {
1053
- anonymous_users: boolean;
1054
- apple: boolean;
1055
- azure: boolean;
1056
- bitbucket: boolean;
1057
- discord: boolean;
1058
- facebook: boolean;
1059
- snapchat: boolean;
1060
- figma: boolean;
1061
- fly: boolean;
1062
- github: boolean;
1063
- gitlab: boolean;
1064
- google: boolean;
1065
- keycloak: boolean;
1066
- kakao: boolean;
1067
- linkedin: boolean;
1068
- linkedin_oidc: boolean;
1069
- notion: boolean;
1070
- spotify: boolean;
1071
- slack: boolean;
1072
- slack_oidc: boolean;
1073
- workos: boolean;
1074
- twitch: boolean;
1075
- twitter: boolean;
1076
1329
  email: boolean;
1077
1330
  phone: boolean;
1078
- zoom: boolean;
1331
+ anonymous_users: boolean;
1079
1332
  };
1080
1333
  disable_signup: boolean;
1081
1334
  mailer_autoconfirm: boolean;
@@ -1117,6 +1370,33 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
1117
1370
  status: 200;
1118
1371
  };
1119
1372
  };
1373
+ } & {
1374
+ "/authorize": {
1375
+ $get: {
1376
+ input: {};
1377
+ output: string;
1378
+ outputFormat: "body";
1379
+ status: 302;
1380
+ };
1381
+ };
1382
+ } & {
1383
+ "/callback": {
1384
+ $get: {
1385
+ input: {};
1386
+ output: {};
1387
+ outputFormat: string;
1388
+ status: hono_utils_http_status.StatusCode;
1389
+ };
1390
+ };
1391
+ } & {
1392
+ "/callback": {
1393
+ $post: {
1394
+ input: {};
1395
+ output: {};
1396
+ outputFormat: string;
1397
+ status: hono_utils_http_status.StatusCode;
1398
+ };
1399
+ };
1120
1400
  } & {
1121
1401
  "/nonexistent": {
1122
1402
  $all: {
@@ -1758,431 +2038,7 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
1758
2038
  "/config": {
1759
2039
  $get: {
1760
2040
  input: {};
1761
- output: {
1762
- analytics?: {
1763
- enabled?: boolean | undefined;
1764
- port?: number | undefined;
1765
- vector_port?: number | undefined;
1766
- backend?: "postgres" | "bigquery" | undefined;
1767
- } | undefined;
1768
- api?: {
1769
- enabled?: boolean | undefined;
1770
- port?: number | undefined;
1771
- schemas?: string[] | undefined;
1772
- extra_search_path?: string[] | undefined;
1773
- max_rows?: number | undefined;
1774
- pg_safe_update?: boolean | undefined;
1775
- plan_enabled?: boolean | undefined;
1776
- aggregates_enabled?: boolean | undefined;
1777
- limited_mutations_enabled?: boolean | undefined;
1778
- anonymous_enabled?: boolean | undefined;
1779
- external_url?: string | undefined;
1780
- tls?: {
1781
- enabled?: boolean | undefined;
1782
- } | undefined;
1783
- } | undefined;
1784
- storage?: {
1785
- enabled?: boolean | undefined;
1786
- file_size_limit?: string | undefined;
1787
- buckets?: {
1788
- [x: string]: {
1789
- public?: boolean | undefined;
1790
- file_size_limit?: string | undefined;
1791
- allowed_mime_types?: string[] | undefined;
1792
- objects_path?: string | undefined;
1793
- };
1794
- } | undefined;
1795
- image_transformation?: {
1796
- enabled?: boolean | undefined;
1797
- } | undefined;
1798
- } | undefined;
1799
- auth?: {
1800
- enabled?: boolean | undefined;
1801
- enable_signup?: boolean | undefined;
1802
- jwt_secret?: string | undefined;
1803
- site_url?: string | undefined;
1804
- additional_redirect_urls?: string[] | undefined;
1805
- jwt_expiry?: number | undefined;
1806
- enable_refresh_token_rotation?: boolean | undefined;
1807
- refresh_token_reuse_interval?: number | undefined;
1808
- enable_manual_linking?: boolean | undefined;
1809
- enable_anonymous_sign_ins?: boolean | undefined;
1810
- minimum_password_length?: number | undefined;
1811
- password_requirements?: string | undefined;
1812
- hook?: {
1813
- mfa_verification_attempt?: {
1814
- enabled?: boolean | undefined;
1815
- uri?: string | undefined;
1816
- secrets?: string[] | undefined;
1817
- } | undefined;
1818
- password_verification_attempt?: {
1819
- enabled?: boolean | undefined;
1820
- uri?: string | undefined;
1821
- secrets?: string[] | undefined;
1822
- } | undefined;
1823
- custom_access_token?: {
1824
- enabled?: boolean | undefined;
1825
- uri?: string | undefined;
1826
- secrets?: string[] | undefined;
1827
- } | undefined;
1828
- send_sms?: {
1829
- enabled?: boolean | undefined;
1830
- uri?: string | undefined;
1831
- secrets?: string[] | undefined;
1832
- } | undefined;
1833
- send_email?: {
1834
- enabled?: boolean | undefined;
1835
- uri?: string | undefined;
1836
- secrets?: string[] | undefined;
1837
- } | undefined;
1838
- } | undefined;
1839
- mfa?: {
1840
- max_enrolled_factors?: number | undefined;
1841
- totp?: {
1842
- enroll_enabled?: boolean | undefined;
1843
- verify_enabled?: boolean | undefined;
1844
- } | undefined;
1845
- phone?: {
1846
- template?: string | undefined;
1847
- max_frequency?: string | undefined;
1848
- otp_length?: number | undefined;
1849
- enroll_enabled?: boolean | undefined;
1850
- verify_enabled?: boolean | undefined;
1851
- } | undefined;
1852
- } | undefined;
1853
- sessions?: {
1854
- timebox?: string | undefined;
1855
- inactivity_timeout?: string | undefined;
1856
- single_per_user?: boolean | undefined;
1857
- } | undefined;
1858
- email?: {
1859
- template?: {
1860
- invite?: {
1861
- subject?: string | undefined;
1862
- content_path?: string | undefined;
1863
- } | undefined;
1864
- confirmation?: {
1865
- subject?: string | undefined;
1866
- content_path?: string | undefined;
1867
- } | undefined;
1868
- recovery?: {
1869
- subject?: string | undefined;
1870
- content_path?: string | undefined;
1871
- } | undefined;
1872
- magic_link?: {
1873
- subject?: string | undefined;
1874
- content_path?: string | undefined;
1875
- } | undefined;
1876
- email_change?: {
1877
- subject?: string | undefined;
1878
- content_path?: string | undefined;
1879
- } | undefined;
1880
- } | undefined;
1881
- enable_signup?: boolean | undefined;
1882
- double_confirm_changes?: boolean | undefined;
1883
- enable_confirmations?: boolean | undefined;
1884
- secure_password_change?: boolean | undefined;
1885
- max_frequency?: string | undefined;
1886
- otp_length?: number | undefined;
1887
- otp_expiry?: number | undefined;
1888
- smtp?: {
1889
- port?: number | undefined;
1890
- host?: string | undefined;
1891
- user?: string | undefined;
1892
- pass?: string | undefined;
1893
- admin_email?: string | undefined;
1894
- sender_name?: string | undefined;
1895
- } | undefined;
1896
- } | undefined;
1897
- sms?: {
1898
- template?: string | undefined;
1899
- enable_signup?: boolean | undefined;
1900
- enable_confirmations?: boolean | undefined;
1901
- max_frequency?: string | undefined;
1902
- test_otp?: {
1903
- [x: string]: string;
1904
- } | undefined;
1905
- twilio?: {
1906
- enabled?: boolean | undefined;
1907
- account_sid?: string | undefined;
1908
- message_service_sid?: string | undefined;
1909
- auth_token?: string | undefined;
1910
- } | undefined;
1911
- twilio_verify?: {
1912
- enabled?: boolean | undefined;
1913
- account_sid?: string | undefined;
1914
- message_service_sid?: string | undefined;
1915
- auth_token?: string | undefined;
1916
- } | undefined;
1917
- messagebird?: {
1918
- enabled?: boolean | undefined;
1919
- originator?: string | undefined;
1920
- api_key?: string | undefined;
1921
- } | undefined;
1922
- textlocal?: {
1923
- enabled?: boolean | undefined;
1924
- api_key?: string | undefined;
1925
- sender?: string | undefined;
1926
- } | undefined;
1927
- vonage?: {
1928
- enabled?: boolean | undefined;
1929
- api_key?: string | undefined;
1930
- from?: string | undefined;
1931
- api_secret?: string | undefined;
1932
- } | undefined;
1933
- } | undefined;
1934
- external?: {
1935
- apple?: {
1936
- enabled?: boolean | undefined;
1937
- client_id?: string | undefined;
1938
- secret?: string | undefined;
1939
- url?: string | undefined;
1940
- redirect_uri?: string | undefined;
1941
- skip_nonce_check?: boolean | undefined;
1942
- } | undefined;
1943
- azure?: {
1944
- enabled?: boolean | undefined;
1945
- client_id?: string | undefined;
1946
- secret?: string | undefined;
1947
- url?: string | undefined;
1948
- redirect_uri?: string | undefined;
1949
- skip_nonce_check?: boolean | undefined;
1950
- } | undefined;
1951
- bitbucket?: {
1952
- enabled?: boolean | undefined;
1953
- client_id?: string | undefined;
1954
- secret?: string | undefined;
1955
- url?: string | undefined;
1956
- redirect_uri?: string | undefined;
1957
- skip_nonce_check?: boolean | undefined;
1958
- } | undefined;
1959
- discord?: {
1960
- enabled?: boolean | undefined;
1961
- client_id?: string | undefined;
1962
- secret?: string | undefined;
1963
- url?: string | undefined;
1964
- redirect_uri?: string | undefined;
1965
- skip_nonce_check?: boolean | undefined;
1966
- } | undefined;
1967
- facebook?: {
1968
- enabled?: boolean | undefined;
1969
- client_id?: string | undefined;
1970
- secret?: string | undefined;
1971
- url?: string | undefined;
1972
- redirect_uri?: string | undefined;
1973
- skip_nonce_check?: boolean | undefined;
1974
- } | undefined;
1975
- github?: {
1976
- enabled?: boolean | undefined;
1977
- client_id?: string | undefined;
1978
- secret?: string | undefined;
1979
- url?: string | undefined;
1980
- redirect_uri?: string | undefined;
1981
- skip_nonce_check?: boolean | undefined;
1982
- } | undefined;
1983
- gitlab?: {
1984
- enabled?: boolean | undefined;
1985
- client_id?: string | undefined;
1986
- secret?: string | undefined;
1987
- url?: string | undefined;
1988
- redirect_uri?: string | undefined;
1989
- skip_nonce_check?: boolean | undefined;
1990
- } | undefined;
1991
- google?: {
1992
- enabled?: boolean | undefined;
1993
- client_id?: string | undefined;
1994
- secret?: string | undefined;
1995
- url?: string | undefined;
1996
- redirect_uri?: string | undefined;
1997
- skip_nonce_check?: boolean | undefined;
1998
- } | undefined;
1999
- kakao?: {
2000
- enabled?: boolean | undefined;
2001
- client_id?: string | undefined;
2002
- secret?: string | undefined;
2003
- url?: string | undefined;
2004
- redirect_uri?: string | undefined;
2005
- skip_nonce_check?: boolean | undefined;
2006
- } | undefined;
2007
- keycloak?: {
2008
- enabled?: boolean | undefined;
2009
- client_id?: string | undefined;
2010
- secret?: string | undefined;
2011
- url?: string | undefined;
2012
- redirect_uri?: string | undefined;
2013
- skip_nonce_check?: boolean | undefined;
2014
- } | undefined;
2015
- linkedin?: {
2016
- enabled?: boolean | undefined;
2017
- client_id?: string | undefined;
2018
- secret?: string | undefined;
2019
- url?: string | undefined;
2020
- redirect_uri?: string | undefined;
2021
- skip_nonce_check?: boolean | undefined;
2022
- } | undefined;
2023
- notion?: {
2024
- enabled?: boolean | undefined;
2025
- client_id?: string | undefined;
2026
- secret?: string | undefined;
2027
- url?: string | undefined;
2028
- redirect_uri?: string | undefined;
2029
- skip_nonce_check?: boolean | undefined;
2030
- } | undefined;
2031
- twitch?: {
2032
- enabled?: boolean | undefined;
2033
- client_id?: string | undefined;
2034
- secret?: string | undefined;
2035
- url?: string | undefined;
2036
- redirect_uri?: string | undefined;
2037
- skip_nonce_check?: boolean | undefined;
2038
- } | undefined;
2039
- twitter?: {
2040
- enabled?: boolean | undefined;
2041
- client_id?: string | undefined;
2042
- secret?: string | undefined;
2043
- url?: string | undefined;
2044
- redirect_uri?: string | undefined;
2045
- skip_nonce_check?: boolean | undefined;
2046
- } | undefined;
2047
- slack?: {
2048
- enabled?: boolean | undefined;
2049
- client_id?: string | undefined;
2050
- secret?: string | undefined;
2051
- url?: string | undefined;
2052
- redirect_uri?: string | undefined;
2053
- skip_nonce_check?: boolean | undefined;
2054
- } | undefined;
2055
- spotify?: {
2056
- enabled?: boolean | undefined;
2057
- client_id?: string | undefined;
2058
- secret?: string | undefined;
2059
- url?: string | undefined;
2060
- redirect_uri?: string | undefined;
2061
- skip_nonce_check?: boolean | undefined;
2062
- } | undefined;
2063
- workos?: {
2064
- enabled?: boolean | undefined;
2065
- client_id?: string | undefined;
2066
- secret?: string | undefined;
2067
- url?: string | undefined;
2068
- redirect_uri?: string | undefined;
2069
- skip_nonce_check?: boolean | undefined;
2070
- } | undefined;
2071
- zoom?: {
2072
- enabled?: boolean | undefined;
2073
- client_id?: string | undefined;
2074
- secret?: string | undefined;
2075
- url?: string | undefined;
2076
- redirect_uri?: string | undefined;
2077
- skip_nonce_check?: boolean | undefined;
2078
- } | undefined;
2079
- } | undefined;
2080
- } | undefined;
2081
- inbucket?: {
2082
- enabled?: boolean | undefined;
2083
- port?: number | undefined;
2084
- smtp_port?: number | undefined;
2085
- pop3_port?: number | undefined;
2086
- } | undefined;
2087
- experimental?: {
2088
- orioledb_version?: string | undefined;
2089
- s3_host?: string | undefined;
2090
- s3_region?: string | undefined;
2091
- s3_access_key?: string | undefined;
2092
- s3_secret_key?: string | undefined;
2093
- } | undefined;
2094
- functions?: {
2095
- [x: string]: {
2096
- enabled?: boolean | undefined;
2097
- verify_jwt?: boolean | undefined;
2098
- import_map?: string | undefined;
2099
- entrypoint?: string | undefined;
2100
- };
2101
- } | undefined;
2102
- realtime?: {
2103
- enabled?: boolean | undefined;
2104
- ip_version?: string | undefined;
2105
- max_header_length?: number | undefined;
2106
- } | undefined;
2107
- studio?: {
2108
- enabled?: boolean | undefined;
2109
- port?: number | undefined;
2110
- api_url?: string | undefined;
2111
- openai_api_key?: string | undefined;
2112
- } | undefined;
2113
- project_id?: string | undefined;
2114
- db?: {
2115
- [x: string]: hono_utils_types.JSONValue;
2116
- port?: number | undefined;
2117
- url?: string | undefined;
2118
- driver?: "postgres" | "sqlite" | "sqlite-postgres" | "pglite" | undefined;
2119
- shadow_port?: number | undefined;
2120
- major_version?: number | undefined;
2121
- pooler?: {
2122
- [x: string]: hono_utils_types.JSONValue;
2123
- enabled?: boolean | undefined;
2124
- port?: number | undefined;
2125
- pool_mode?: string | undefined;
2126
- default_pool_size?: number | undefined;
2127
- max_client_conn?: number | undefined;
2128
- } | undefined;
2129
- seed?: {
2130
- enabled?: boolean | undefined;
2131
- sql_paths?: string[] | undefined;
2132
- } | undefined;
2133
- migrations?: {
2134
- enabled?: boolean | undefined;
2135
- schema_paths?: string[] | undefined;
2136
- } | undefined;
2137
- } | undefined;
2138
- edge_runtime?: {
2139
- enabled?: boolean | undefined;
2140
- policy?: "oneshot" | "per_worker" | undefined;
2141
- inspector_port?: number | undefined;
2142
- } | undefined;
2143
- options?: {
2144
- defaults?: true | undefined;
2145
- server?: {
2146
- middlewares?: never[] | undefined;
2147
- disableStudio?: boolean | undefined;
2148
- disableFallback?: boolean | undefined;
2149
- forceRollback?: boolean | undefined;
2150
- } | undefined;
2151
- drivers?: {
2152
- email?: {
2153
- send: never;
2154
- } | undefined;
2155
- sms?: {
2156
- send: never;
2157
- } | undefined;
2158
- cache?: {
2159
- get: never;
2160
- set: never;
2161
- delete: never;
2162
- } | undefined;
2163
- } | undefined;
2164
- system?: {
2165
- schemaReconciliation?: "additive" | "full" | undefined;
2166
- } | undefined;
2167
- } | undefined;
2168
- rls?: {
2169
- tables: string[];
2170
- policies: {
2171
- name: string;
2172
- table: string;
2173
- schema?: string | undefined;
2174
- command: PolicyCommand;
2175
- permissive: boolean;
2176
- roles: PolicyRole[];
2177
- using?: {
2178
- [x: string]: hono_utils_types.JSONValue;
2179
- } | undefined;
2180
- withCheck?: {
2181
- [x: string]: hono_utils_types.JSONValue;
2182
- } | undefined;
2183
- }[];
2184
- } | undefined;
2185
- };
2041
+ output: {};
2186
2042
  outputFormat: "json";
2187
2043
  status: hono_utils_http_status.ContentfulStatusCode;
2188
2044
  };
@@ -2191,7 +2047,11 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2191
2047
  "/info": {
2192
2048
  $get: {
2193
2049
  input: {};
2194
- output: {};
2050
+ output: {
2051
+ connection: any;
2052
+ config: any;
2053
+ admin: boolean;
2054
+ };
2195
2055
  outputFormat: "json";
2196
2056
  status: hono_utils_http_status.ContentfulStatusCode;
2197
2057
  };
@@ -2391,6 +2251,11 @@ declare class App<Config extends IAppConfig = DefaultAppConfig, Conn = Config ex
2391
2251
  private readonly _rls;
2392
2252
  readonly config: DefaultSchema & Omit<Config, "connection">;
2393
2253
  readonly server: ReturnType<typeof createServer>;
2254
+ /**
2255
+ * Resolved local admin mode, after CLI-flag / config-file precedence. Read
2256
+ * this (never the raw CLI flag) when reporting what the server is doing.
2257
+ */
2258
+ readonly adminMode: boolean;
2394
2259
  readonly drivers: AppDrivers;
2395
2260
  _mailer?: Mailer;
2396
2261
  _storageAdapter?: StorageAdapter;
@@ -2416,7 +2281,9 @@ declare class App<Config extends IAppConfig = DefaultAppConfig, Conn = Config ex
2416
2281
  force?: boolean;
2417
2282
  }): Promise<void>;
2418
2283
  isValidConfig(config: Schema | DefaultSchema | IAppConfig): boolean;
2419
- getClient<SchemaName extends string = "public">(options?: SupabaseClientOptions<SchemaName>): _supabase_supabase_js.SupabaseClient<any, "public", SchemaName, Omit<any, "__InternalSupabase">[SchemaName] extends {
2284
+ getClient<SchemaName extends string = "public">(options?: SupabaseClientOptions<SchemaName> & {
2285
+ apikey?: string;
2286
+ }): _supabase_supabase_js.SupabaseClient<any, "public", SchemaName, Omit<any, "__InternalSupabase">[SchemaName] extends {
2420
2287
  Tables: Record<string, {
2421
2288
  Row: Record<string, unknown>;
2422
2289
  Insert: Record<string, unknown>;
@@ -2492,6 +2359,16 @@ declare class CheckConstraintError extends Error {
2492
2359
  constructor(table: string, column: string, constraint: string, value: unknown);
2493
2360
  }
2494
2361
 
2362
+ interface FieldFactoryExtra {
2363
+ lengthConstraint?: number;
2364
+ numericPrecision?: {
2365
+ precision: number;
2366
+ scale: number;
2367
+ };
2368
+ enumValues?: string[];
2369
+ isArray?: boolean;
2370
+ }
2371
+
2495
2372
  type SqliteType = "INTEGER" | "REAL" | "TEXT" | "BLOB" | "ANY";
2496
2373
  type DefaultFn = () => unknown;
2497
2374
  interface ValidationResult {
@@ -2526,6 +2403,15 @@ interface ColumnDDLOptions {
2526
2403
  }
2527
2404
  declare abstract class Field {
2528
2405
  readonly context: FieldContext;
2406
+ /**
2407
+ * The `FieldFactoryExtra` this field was resolved with (minus `enumValues`,
2408
+ * which is re-derived from the persisted enum map at parse time to avoid
2409
+ * duplicating it per-column). Set by {@link resolveField} purely so
2410
+ * `SqliteConnection.serializeDeparseInfo` can round-trip typmod details
2411
+ * (array/length/numeric precision) that only live in the AST at collect
2412
+ * time — not consumed by the field itself.
2413
+ */
2414
+ factoryExtra?: Omit<FieldFactoryExtra, "enumValues">;
2529
2415
  constructor(context: FieldContext);
2530
2416
  abstract get sqliteType(): SqliteType;
2531
2417
  get isShimBacked(): boolean;
@@ -2701,11 +2587,18 @@ interface ISqliteConnectionConfig extends IConnectionConfig {
2701
2587
  type DeparsePostgresDdlResult = Awaited<ReturnType<typeof deparsePostgresDdl>>;
2702
2588
  type SqlitePostgresDeparseInfo = Pick<DeparsePostgresDdlResult, "enums" | "rls" | "schema" | "vars"> & Partial<Pick<DeparsePostgresDdlResult, "tableConstraints" | "comments">>;
2703
2589
  /**
2704
- * The JSON-serializable form of the deparse info the load-bearing runtime
2705
- * subset (`rls` + `vars`) that survives a `JSON.stringify` round-trip and is
2706
- * rehydrated by {@link SqliteConnection.parseDeparseInfo}. `ast`/`ddl` and the
2707
- * class-instance metadata (`schema`/`enums`/`tableConstraints`/`comments`) are
2708
- * intentionally omitted they are build-time artifacts that cannot round-trip.
2590
+ * The JSON-serializable form of the deparse info, rehydrated by
2591
+ * {@link SqliteConnection.parseDeparseInfo}. Covers the full runtime shape
2592
+ * except `ast`/`ddl` (build-time artifacts, intentionally omitted — never
2593
+ * cached). `schema` is `Map<string, TableSchema>` in memory; each `TableSchema`
2594
+ * holds `Field` instances that are fully determined by `resolveField(context,
2595
+ * extra)`, so it round-trips as `{context, extra}` per column (keyed
2596
+ * `${schema}.${table}`, matching `collectSchema`). `extra.enumValues` is
2597
+ * dropped and re-derived from the persisted `enums` map at parse time to
2598
+ * avoid duplicating enum members per column. `context.defaultFn` is always
2599
+ * `null` from the collectors today (collectors.ts, SqliteDeparser.ts) — it is
2600
+ * dropped here too; if a future collector ever sets it, it must be re-derived
2601
+ * at parse time instead of silently lost.
2709
2602
  * Produced by {@link SqliteConnection.serializeDeparseInfo}.
2710
2603
  */
2711
2604
  interface PersistedDeparseInfo {
@@ -2714,32 +2607,47 @@ interface PersistedDeparseInfo {
2714
2607
  policies: PolicyData[];
2715
2608
  };
2716
2609
  vars?: Record<string, CollectedVariable>;
2610
+ enums?: Record<string, string[]>;
2611
+ schema?: Record<string, Array<{
2612
+ context: Omit<FieldContext, "defaultFn">;
2613
+ extra?: Omit<FieldFactoryExtra, "enumValues">;
2614
+ }>>;
2615
+ tableConstraints?: CollectedTableConstraint[];
2616
+ comments?: CollectedComment[];
2717
2617
  }
2718
2618
  type SqlitePostgresTranslationResult = Pick<DeparsePostgresDdlResult, "ddl"> & Partial<DeparsePostgresDdlResult>;
2719
2619
  declare abstract class SqliteConnection<Driver = unknown, DB = any, Config extends ISqliteConnectionConfig = ISqliteConnectionConfig> extends Connection<Driver, DB, Config> {
2620
+ #private;
2720
2621
  dialect: Dialect$2;
2721
2622
  deserializeRow(row: Record<string, unknown>): Record<string, unknown>;
2722
2623
  constructor(config?: Config);
2723
- static parseDeparseInfo(details: any): {
2724
- rls?: undefined;
2725
- vars?: undefined;
2726
- } | {
2727
- rls: {
2728
- tables: any;
2729
- policies: any;
2730
- };
2731
- vars: any;
2732
- };
2624
+ /**
2625
+ * `opts.strict`: rethrow instead of swallowing a parse failure (default:
2626
+ * fail-soft, returning `{}`). The constructor path stays fail-soft — a
2627
+ * malformed `App({rls})` config shouldn't crash boot. The deparse-cache
2628
+ * restore path (`deparse-cache.ts`) uses `strict: true`: a partially
2629
+ * corrupt blob (e.g. a valid outer `rls` shape but a broken nested
2630
+ * `schema` entry) must NOT silently degrade to "restored with whatever
2631
+ * parsed" — that's indistinguishable from "restored with full RLS
2632
+ * metadata" to the caller, which would then report `restored` and enforce
2633
+ * nothing. Rethrowing lets the caller treat any nested corruption as a
2634
+ * cache miss and fall through to recalculation.
2635
+ */
2636
+ static parseDeparseInfo(details: any, opts?: {
2637
+ strict?: boolean;
2638
+ }): Partial<SqlitePostgresDeparseInfo>;
2733
2639
  /**
2734
2640
  * Serialize deparse info to its JSON form — the inverse of
2735
2641
  * {@link SqliteConnection.parseDeparseInfo}. Coerces `Set` → array, `Map` →
2736
- * object, and `Policy` → `PolicyData` (via `Policy.toJSON`), keeping only the
2737
- * `rls` + `vars` subset the runtime reconstructs. Feed the result to
2738
- * `JSON.stringify` for a `deparse.json` you can re-import into
2739
- * `translation.deparse`. Accepts a `translateDdl` result or a stored
2642
+ * object, and `Policy` → `PolicyData` (via `Policy.toJSON`), and flattens
2643
+ * `schema`'s `Field` instances to `{context, extra}` pairs (`extra` comes
2644
+ * from `Field#factoryExtra`, with `enumValues` dropped re-derived from
2645
+ * `enums` at parse time). `ast`/`ddl` are dropped; everything else round-trips.
2646
+ * Feed the result to `JSON.stringify` for a `deparse.json` you can re-import
2647
+ * into `translation.deparse`. Accepts a `translateDdl` result or a stored
2740
2648
  * `SqlitePostgresDeparseInfo`.
2741
2649
  */
2742
- static serializeDeparseInfo(info: Partial<Pick<SqlitePostgresDeparseInfo, "rls" | "vars">> | undefined | null): PersistedDeparseInfo;
2650
+ static serializeDeparseInfo(info: Partial<SqlitePostgresDeparseInfo> | undefined | null): PersistedDeparseInfo;
2743
2651
  updateDeparseInfo(details: NonNullable<ISqliteConnectionConfig["translation"]>["deparse"]): void;
2744
2652
  protected withSqlitePlugins(add_plugins?: KyselyPlugin[]): KyselyPlugin[];
2745
2653
  translateDdl(ddl: string): Promise<SqlitePostgresTranslationResult>;
@@ -2791,6 +2699,13 @@ declare abstract class SqliteConnection<Driver = unknown, DB = any, Config exten
2791
2699
  normalizeBindParams(parameters: readonly unknown[] | undefined): unknown[];
2792
2700
  normalizeDbError(e: unknown): unknown;
2793
2701
  onPostgrestAST(ast: AnyAST, vars?: VarsContext): Promise<AnyAST>;
2702
+ /**
2703
+ * Tables known to have RLS enabled in the APPLIED state of this database,
2704
+ * without any deparse metadata: the migration history replayed in applied
2705
+ * order (`rlsEnabledTables`). Empty when ddlDialect isn't postgres or the
2706
+ * history isn't readable.
2707
+ */
2708
+ private rlsEnabledFromHistory;
2794
2709
  private applyRls;
2795
2710
  }
2796
2711
 
@@ -2910,6 +2825,7 @@ declare function filterSearchParams(reqOrSearchParams: Request | URLSearchParams
2910
2825
 
2911
2826
  declare function isNode(): boolean;
2912
2827
  declare function isBun(): boolean;
2828
+ declare function isWorkerd(): boolean;
2913
2829
  declare function invariant(condition: boolean | any, message: string): void;
2914
2830
  declare function threw(fn: () => any, instance?: new (...args: any[]) => Error): boolean;
2915
2831
  declare function threwAsync(fn: Promise<any>, instance?: new (...args: any[]) => Error): Promise<boolean>;
@@ -2928,6 +2844,7 @@ declare function getStatementsArray(sql: string, clean?: boolean): string[];
2928
2844
  declare function splitSqlStatements(sql: string): string[];
2929
2845
  declare function normalizeType(t: string): string;
2930
2846
  declare function normalizeSql(sql: string): string;
2847
+ declare function tableStructuralItems(sql: string): string[] | null;
2931
2848
  declare function normalizeDefault(d: string | null): string | null;
2932
2849
 
2933
2850
  declare function randomString(length?: number, opts?: {
@@ -3001,7 +2918,9 @@ type HonoContextWithAuth = HonoContext & {
3001
2918
  declare const resolveAuth: ({ onError, }?: {
3002
2919
  onError?: (error: unknown, c: Context<HonoContextWithAuth>) => Response | Promise<Response>;
3003
2920
  }) => hono.MiddlewareHandler<HonoContextWithAuth, string, {}, Response>;
3004
- declare const requireAuth: () => hono.MiddlewareHandler<HonoContextWithAuth, string, {}, Response>;
2921
+ declare const requireAuth: (options?: {
2922
+ acceptSecretApiKey?: boolean;
2923
+ }) => hono.MiddlewareHandler<HonoContextWithAuth, string, {}, Response>;
3005
2924
 
3006
2925
  declare function getStorageSchemaSql(clean?: boolean): string;
3007
2926
 
@@ -3012,4 +2931,4 @@ declare function isExperimentalEnabled(name: ExperimentalFeature): boolean;
3012
2931
  declare function setExperimental(name: ExperimentalFeature, enabled: boolean): void;
3013
2932
  declare function listEnabledExperimentals(): ExperimentalFeature[];
3014
2933
 
3015
- export { AnyAST, App, type AppDrivers, AwsSesEmailDriver, type AwsSesEmailDriverOptions, type BooleanLike, CacheDriver, CacheSetOptions, CloudConnection, CloudflareKvCacheDriver, type CloudflareKvCacheDriverOptions, Connection$1 as Connection, type DefaultAppConfig, type EmailDriver, type EmailMessage, type ExperimentalFeature, type HistoryVariant, type HonoContext, type IAppConfig, type ICloudConnectionConfig, type ISqliteConnectionConfig, InMemoryEmailDriver, type InMemoryEmailDriverOptions, InMemoryLruCacheDriver, type InMemoryLruCacheDriverOptions, IntrospectResult, InvalidPostgresToSQLiteTranslation, type MatchPattern, type MaybePromise, MigrateScope, type MigrationHistoryRow, NoopEmailDriver, type NoopEmailDriverOptions, NoopSmsDriver, type NoopSmsDriverOptions, type PartialAppDrivers, type PersistedDeparseInfo, Policy, type PolicyCommand, type PolicyData, type PolicyRole, type Primitive, type RedisCacheClient, RedisCacheDriver, type RedisCacheDriverOptions, ResendEmailDriver, type ResendEmailDriverOptions, SUPABASE_AUTH_HELPERS_SQL, Schema, SendmailEmailDriver, type SendmailEmailDriverOptions, type ServerOptions, type SmsDriver, type SmsMessage, SqliteConnection, type SqlitePostgresDeparseInfo, type SqlitePostgresTranslationResult, type StoredEmailMessage, TransactionOptions$1 as TransactionOptions, UnableToCreateRuntimeConnection, VarsContext, Where, appliedVersions, checkPasswordStrength, cleanSql, cloud, createAppDrivers, ensureHistoryTable, ensureVar, filterSearchParams, formatSendmailMessage, fuzzyMatch, getAuthSchemaSql, getMigrationHistorySchemaSql, getPath, getStatementsArray, getStorageSchemaSql, getVersion, historyVariant, invariant, isBooleanLike, isBun, isEmail, isEqual, isExperimentalEnabled, isNode, isObject, isPlainObject, isPrimitive, isString, jsonStringify, listEnabledExperimentals, listHistory, measureTime, mergeObject, mergeObjectWith, normalizeDefault, normalizeSql, normalizeString, normalizeType, objectDiff, omit, params, parseBigInt, patternMatch, pick, pipe, pipeEach, quote, randomString, recordVersion, removeVersion, removeVersionsGte, replacePlaceholders, requireAuth, resolveAuth, setExperimental, setPath, slugify, snakeToPascalWithSpaces, splitSqlStatements, studioRouteHandler, threw, threwAsync, translatePostgresDdl, truncate, trySync, ucFirst, ucFirstAll, uuid };
2934
+ export { AnyAST, type ApiKeyResolver, type ApiKeyType, App, type AppDrivers, type AppDriversConfig, AwsSesEmailDriver, type AwsSesEmailDriverOptions, type BooleanLike, CacheDriver, CacheSetOptions, CloudConnection, CloudflareKvCacheDriver, type CloudflareKvCacheDriverOptions, Connection$1 as Connection, ConsoleEmailDriver, type ConsoleEmailDriverOptions, type DefaultAppConfig, type EmailDriver, type EmailMessage, type ExperimentalFeature, type GeneratedApiKey, type HistoryVariant, type HonoContext, type IAppConfig, type ICloudConnectionConfig, type ISqliteConnectionConfig, InMemoryEmailDriver, type InMemoryEmailDriverOptions, InMemoryLruCacheDriver, type InMemoryLruCacheDriverOptions, IntrospectResult, InvalidPostgresToSQLiteTranslation, type MatchPattern, type MaybePromise, MigrateScope, type MigrationHistoryRow, NoopSmsDriver, type NoopSmsDriverOptions, type PartialAppDrivers, type PersistedDeparseInfo, Policy, type PolicyCommand, type PolicyData, type PolicyRole, type Primitive, type RedisCacheClient, RedisCacheDriver, type RedisCacheDriverOptions, ResendEmailDriver, type ResendEmailDriverOptions, type ResolvedKey, SELF_HOSTED_PROJECT_REF, SUPABASE_AUTH_HELPERS_SQL, Schema, SendmailEmailDriver, type SendmailEmailDriverOptions, type ServerOptions, type SmsDriver, type SmsMessage, type SmtpAddress, type SmtpCreateTransport, SmtpEmailDriver, type SmtpEmailDriverOptions, type SmtpTransporter, SqliteConnection, type SqlitePostgresDeparseInfo, type SqlitePostgresTranslationResult, type StoredEmailMessage, TransactionOptions$1 as TransactionOptions, UnableToCreateRuntimeConnection, VarsContext, Where, apiKeyType, appliedVersions, assertSmtpSupportedRuntime, buildSmtpMail, buildSmtpTransportOptions, checkPasswordStrength, cleanSql, cloud, createAppDrivers, ensureHistoryTable, ensureVar, filterSearchParams, formatSendmailMessage, fuzzyMatch, generateApiKey, getAuthSchemaSql, getMigrationHistorySchemaSql, getPath, getStatementsArray, getStorageSchemaSql, getVersion, hashApiKey, historyVariant, invariant, isBooleanLike, isBun, isEmail, isEqual, isExperimentalEnabled, isNode, isObject, isPlainObject, isPrimitive, isString, isWorkerd, jsonStringify, listEnabledExperimentals, listHistory, measureTime, mergeObject, mergeObjectWith, normalizeDefault, normalizeSql, normalizeString, normalizeType, objectDiff, omit, params, parseBigInt, patternMatch, pick, pipe, pipeEach, quote, randomString, recordVersion, removeVersion, removeVersionsGte, replacePlaceholders, requireAuth, resolveAuth, setExperimental, setPath, slugify, snakeToPascalWithSpaces, splitSqlStatements, studioRouteHandler, tableStructuralItems, threw, threwAsync, translatePostgresDdl, truncate, trySync, ucFirst, ucFirstAll, uuid };