@supabase/lite 0.7.1 → 0.8.1-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ import * as hono_hono_base from 'hono/hono-base';
7
7
  import * as hono_utils_http_status from 'hono/utils/http-status';
8
8
  import * as hono_utils_types from 'hono/utils/types';
9
9
  import * as hono_types from 'hono/types';
10
- import { MiddlewareHandler } from 'hono';
10
+ import { Context, MiddlewareHandler } from 'hono';
11
11
  import { Kysely } from 'kysely';
12
12
  import { ReadableStream as ReadableStream$1 } from 'node:stream/web';
13
13
 
@@ -67,6 +67,8 @@ declare const schema: s.ObjectSchema<{
67
67
  readonly auth: s.Schema<s.ISchemaOptions, {
68
68
  enabled?: boolean | undefined;
69
69
  jwt_secret?: string | undefined;
70
+ publishable_key?: string | undefined;
71
+ secret_key?: string | undefined;
70
72
  site_url?: string | undefined;
71
73
  additional_redirect_urls?: string[] | undefined;
72
74
  jwt_expiry?: number | undefined;
@@ -207,6 +209,7 @@ declare const schema: s.ObjectSchema<{
207
209
  url?: string | undefined;
208
210
  redirect_uri?: string | undefined;
209
211
  skip_nonce_check?: boolean | undefined;
212
+ email_optional?: boolean | undefined;
210
213
  } | undefined;
211
214
  azure?: {
212
215
  enabled?: boolean | undefined;
@@ -215,6 +218,7 @@ declare const schema: s.ObjectSchema<{
215
218
  url?: string | undefined;
216
219
  redirect_uri?: string | undefined;
217
220
  skip_nonce_check?: boolean | undefined;
221
+ email_optional?: boolean | undefined;
218
222
  } | undefined;
219
223
  bitbucket?: {
220
224
  enabled?: boolean | undefined;
@@ -223,6 +227,7 @@ declare const schema: s.ObjectSchema<{
223
227
  url?: string | undefined;
224
228
  redirect_uri?: string | undefined;
225
229
  skip_nonce_check?: boolean | undefined;
230
+ email_optional?: boolean | undefined;
226
231
  } | undefined;
227
232
  discord?: {
228
233
  enabled?: boolean | undefined;
@@ -231,6 +236,7 @@ declare const schema: s.ObjectSchema<{
231
236
  url?: string | undefined;
232
237
  redirect_uri?: string | undefined;
233
238
  skip_nonce_check?: boolean | undefined;
239
+ email_optional?: boolean | undefined;
234
240
  } | undefined;
235
241
  facebook?: {
236
242
  enabled?: boolean | undefined;
@@ -239,6 +245,7 @@ declare const schema: s.ObjectSchema<{
239
245
  url?: string | undefined;
240
246
  redirect_uri?: string | undefined;
241
247
  skip_nonce_check?: boolean | undefined;
248
+ email_optional?: boolean | undefined;
242
249
  } | undefined;
243
250
  github?: {
244
251
  enabled?: boolean | undefined;
@@ -247,6 +254,7 @@ declare const schema: s.ObjectSchema<{
247
254
  url?: string | undefined;
248
255
  redirect_uri?: string | undefined;
249
256
  skip_nonce_check?: boolean | undefined;
257
+ email_optional?: boolean | undefined;
250
258
  } | undefined;
251
259
  gitlab?: {
252
260
  enabled?: boolean | undefined;
@@ -255,6 +263,7 @@ declare const schema: s.ObjectSchema<{
255
263
  url?: string | undefined;
256
264
  redirect_uri?: string | undefined;
257
265
  skip_nonce_check?: boolean | undefined;
266
+ email_optional?: boolean | undefined;
258
267
  } | undefined;
259
268
  google?: {
260
269
  enabled?: boolean | undefined;
@@ -263,6 +272,7 @@ declare const schema: s.ObjectSchema<{
263
272
  url?: string | undefined;
264
273
  redirect_uri?: string | undefined;
265
274
  skip_nonce_check?: boolean | undefined;
275
+ email_optional?: boolean | undefined;
266
276
  } | undefined;
267
277
  kakao?: {
268
278
  enabled?: boolean | undefined;
@@ -271,6 +281,7 @@ declare const schema: s.ObjectSchema<{
271
281
  url?: string | undefined;
272
282
  redirect_uri?: string | undefined;
273
283
  skip_nonce_check?: boolean | undefined;
284
+ email_optional?: boolean | undefined;
274
285
  } | undefined;
275
286
  keycloak?: {
276
287
  enabled?: boolean | undefined;
@@ -279,6 +290,7 @@ declare const schema: s.ObjectSchema<{
279
290
  url?: string | undefined;
280
291
  redirect_uri?: string | undefined;
281
292
  skip_nonce_check?: boolean | undefined;
293
+ email_optional?: boolean | undefined;
282
294
  } | undefined;
283
295
  linkedin?: {
284
296
  enabled?: boolean | undefined;
@@ -287,6 +299,7 @@ declare const schema: s.ObjectSchema<{
287
299
  url?: string | undefined;
288
300
  redirect_uri?: string | undefined;
289
301
  skip_nonce_check?: boolean | undefined;
302
+ email_optional?: boolean | undefined;
290
303
  } | undefined;
291
304
  notion?: {
292
305
  enabled?: boolean | undefined;
@@ -295,6 +308,7 @@ declare const schema: s.ObjectSchema<{
295
308
  url?: string | undefined;
296
309
  redirect_uri?: string | undefined;
297
310
  skip_nonce_check?: boolean | undefined;
311
+ email_optional?: boolean | undefined;
298
312
  } | undefined;
299
313
  twitch?: {
300
314
  enabled?: boolean | undefined;
@@ -303,6 +317,7 @@ declare const schema: s.ObjectSchema<{
303
317
  url?: string | undefined;
304
318
  redirect_uri?: string | undefined;
305
319
  skip_nonce_check?: boolean | undefined;
320
+ email_optional?: boolean | undefined;
306
321
  } | undefined;
307
322
  twitter?: {
308
323
  enabled?: boolean | undefined;
@@ -311,6 +326,7 @@ declare const schema: s.ObjectSchema<{
311
326
  url?: string | undefined;
312
327
  redirect_uri?: string | undefined;
313
328
  skip_nonce_check?: boolean | undefined;
329
+ email_optional?: boolean | undefined;
314
330
  } | undefined;
315
331
  slack?: {
316
332
  enabled?: boolean | undefined;
@@ -319,6 +335,7 @@ declare const schema: s.ObjectSchema<{
319
335
  url?: string | undefined;
320
336
  redirect_uri?: string | undefined;
321
337
  skip_nonce_check?: boolean | undefined;
338
+ email_optional?: boolean | undefined;
322
339
  } | undefined;
323
340
  spotify?: {
324
341
  enabled?: boolean | undefined;
@@ -327,6 +344,7 @@ declare const schema: s.ObjectSchema<{
327
344
  url?: string | undefined;
328
345
  redirect_uri?: string | undefined;
329
346
  skip_nonce_check?: boolean | undefined;
347
+ email_optional?: boolean | undefined;
330
348
  } | undefined;
331
349
  workos?: {
332
350
  enabled?: boolean | undefined;
@@ -335,6 +353,7 @@ declare const schema: s.ObjectSchema<{
335
353
  url?: string | undefined;
336
354
  redirect_uri?: string | undefined;
337
355
  skip_nonce_check?: boolean | undefined;
356
+ email_optional?: boolean | undefined;
338
357
  } | undefined;
339
358
  zoom?: {
340
359
  enabled?: boolean | undefined;
@@ -343,11 +362,14 @@ declare const schema: s.ObjectSchema<{
343
362
  url?: string | undefined;
344
363
  redirect_uri?: string | undefined;
345
364
  skip_nonce_check?: boolean | undefined;
365
+ email_optional?: boolean | undefined;
346
366
  } | undefined;
347
367
  } | undefined;
348
368
  } | undefined, {
349
369
  enabled?: boolean | undefined;
350
370
  jwt_secret?: string | undefined;
371
+ publishable_key?: string | undefined;
372
+ secret_key?: string | undefined;
351
373
  site_url?: string | undefined;
352
374
  additional_redirect_urls?: string[] | undefined;
353
375
  jwt_expiry?: number | undefined;
@@ -488,6 +510,7 @@ declare const schema: s.ObjectSchema<{
488
510
  url?: string | undefined;
489
511
  redirect_uri?: string | undefined;
490
512
  skip_nonce_check?: boolean | undefined;
513
+ email_optional?: boolean | undefined;
491
514
  } | undefined;
492
515
  azure?: {
493
516
  enabled?: boolean | undefined;
@@ -496,6 +519,7 @@ declare const schema: s.ObjectSchema<{
496
519
  url?: string | undefined;
497
520
  redirect_uri?: string | undefined;
498
521
  skip_nonce_check?: boolean | undefined;
522
+ email_optional?: boolean | undefined;
499
523
  } | undefined;
500
524
  bitbucket?: {
501
525
  enabled?: boolean | undefined;
@@ -504,6 +528,7 @@ declare const schema: s.ObjectSchema<{
504
528
  url?: string | undefined;
505
529
  redirect_uri?: string | undefined;
506
530
  skip_nonce_check?: boolean | undefined;
531
+ email_optional?: boolean | undefined;
507
532
  } | undefined;
508
533
  discord?: {
509
534
  enabled?: boolean | undefined;
@@ -512,6 +537,7 @@ declare const schema: s.ObjectSchema<{
512
537
  url?: string | undefined;
513
538
  redirect_uri?: string | undefined;
514
539
  skip_nonce_check?: boolean | undefined;
540
+ email_optional?: boolean | undefined;
515
541
  } | undefined;
516
542
  facebook?: {
517
543
  enabled?: boolean | undefined;
@@ -520,6 +546,7 @@ declare const schema: s.ObjectSchema<{
520
546
  url?: string | undefined;
521
547
  redirect_uri?: string | undefined;
522
548
  skip_nonce_check?: boolean | undefined;
549
+ email_optional?: boolean | undefined;
523
550
  } | undefined;
524
551
  github?: {
525
552
  enabled?: boolean | undefined;
@@ -528,6 +555,7 @@ declare const schema: s.ObjectSchema<{
528
555
  url?: string | undefined;
529
556
  redirect_uri?: string | undefined;
530
557
  skip_nonce_check?: boolean | undefined;
558
+ email_optional?: boolean | undefined;
531
559
  } | undefined;
532
560
  gitlab?: {
533
561
  enabled?: boolean | undefined;
@@ -536,6 +564,7 @@ declare const schema: s.ObjectSchema<{
536
564
  url?: string | undefined;
537
565
  redirect_uri?: string | undefined;
538
566
  skip_nonce_check?: boolean | undefined;
567
+ email_optional?: boolean | undefined;
539
568
  } | undefined;
540
569
  google?: {
541
570
  enabled?: boolean | undefined;
@@ -544,6 +573,7 @@ declare const schema: s.ObjectSchema<{
544
573
  url?: string | undefined;
545
574
  redirect_uri?: string | undefined;
546
575
  skip_nonce_check?: boolean | undefined;
576
+ email_optional?: boolean | undefined;
547
577
  } | undefined;
548
578
  kakao?: {
549
579
  enabled?: boolean | undefined;
@@ -552,6 +582,7 @@ declare const schema: s.ObjectSchema<{
552
582
  url?: string | undefined;
553
583
  redirect_uri?: string | undefined;
554
584
  skip_nonce_check?: boolean | undefined;
585
+ email_optional?: boolean | undefined;
555
586
  } | undefined;
556
587
  keycloak?: {
557
588
  enabled?: boolean | undefined;
@@ -560,6 +591,7 @@ declare const schema: s.ObjectSchema<{
560
591
  url?: string | undefined;
561
592
  redirect_uri?: string | undefined;
562
593
  skip_nonce_check?: boolean | undefined;
594
+ email_optional?: boolean | undefined;
563
595
  } | undefined;
564
596
  linkedin?: {
565
597
  enabled?: boolean | undefined;
@@ -568,6 +600,7 @@ declare const schema: s.ObjectSchema<{
568
600
  url?: string | undefined;
569
601
  redirect_uri?: string | undefined;
570
602
  skip_nonce_check?: boolean | undefined;
603
+ email_optional?: boolean | undefined;
571
604
  } | undefined;
572
605
  notion?: {
573
606
  enabled?: boolean | undefined;
@@ -576,6 +609,7 @@ declare const schema: s.ObjectSchema<{
576
609
  url?: string | undefined;
577
610
  redirect_uri?: string | undefined;
578
611
  skip_nonce_check?: boolean | undefined;
612
+ email_optional?: boolean | undefined;
579
613
  } | undefined;
580
614
  twitch?: {
581
615
  enabled?: boolean | undefined;
@@ -584,6 +618,7 @@ declare const schema: s.ObjectSchema<{
584
618
  url?: string | undefined;
585
619
  redirect_uri?: string | undefined;
586
620
  skip_nonce_check?: boolean | undefined;
621
+ email_optional?: boolean | undefined;
587
622
  } | undefined;
588
623
  twitter?: {
589
624
  enabled?: boolean | undefined;
@@ -592,6 +627,7 @@ declare const schema: s.ObjectSchema<{
592
627
  url?: string | undefined;
593
628
  redirect_uri?: string | undefined;
594
629
  skip_nonce_check?: boolean | undefined;
630
+ email_optional?: boolean | undefined;
595
631
  } | undefined;
596
632
  slack?: {
597
633
  enabled?: boolean | undefined;
@@ -600,6 +636,7 @@ declare const schema: s.ObjectSchema<{
600
636
  url?: string | undefined;
601
637
  redirect_uri?: string | undefined;
602
638
  skip_nonce_check?: boolean | undefined;
639
+ email_optional?: boolean | undefined;
603
640
  } | undefined;
604
641
  spotify?: {
605
642
  enabled?: boolean | undefined;
@@ -608,6 +645,7 @@ declare const schema: s.ObjectSchema<{
608
645
  url?: string | undefined;
609
646
  redirect_uri?: string | undefined;
610
647
  skip_nonce_check?: boolean | undefined;
648
+ email_optional?: boolean | undefined;
611
649
  } | undefined;
612
650
  workos?: {
613
651
  enabled?: boolean | undefined;
@@ -616,6 +654,7 @@ declare const schema: s.ObjectSchema<{
616
654
  url?: string | undefined;
617
655
  redirect_uri?: string | undefined;
618
656
  skip_nonce_check?: boolean | undefined;
657
+ email_optional?: boolean | undefined;
619
658
  } | undefined;
620
659
  zoom?: {
621
660
  enabled?: boolean | undefined;
@@ -624,6 +663,7 @@ declare const schema: s.ObjectSchema<{
624
663
  url?: string | undefined;
625
664
  redirect_uri?: string | undefined;
626
665
  skip_nonce_check?: boolean | undefined;
666
+ email_optional?: boolean | undefined;
627
667
  } | undefined;
628
668
  } | undefined;
629
669
  } | undefined>;
@@ -849,6 +889,26 @@ interface IdentitiesTable {
849
889
  created_at: string;
850
890
  updated_at: string;
851
891
  }
892
+ interface FlowStateTable {
893
+ id: string;
894
+ user_id: string | null;
895
+ auth_code: string | null;
896
+ authentication_method: string;
897
+ code_challenge_method: string | null;
898
+ code_challenge: string | null;
899
+ provider_type: string;
900
+ provider_access_token: string | null;
901
+ provider_refresh_token: string | null;
902
+ auth_code_issued_at: string | null;
903
+ invite_token: string | null;
904
+ referrer: string | null;
905
+ oauth_client_state_id: string | null;
906
+ linking_target_id: string | null;
907
+ email_optional: boolean;
908
+ created_at: string;
909
+ updated_at: string;
910
+ }
911
+ 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">>;
852
912
  interface UserResponse {
853
913
  id: string;
854
914
  aud: string;
@@ -918,6 +978,15 @@ interface AuthConfig {
918
978
  enable_confirmations?: boolean;
919
979
  site_url?: string;
920
980
  additional_redirect_urls?: string[];
981
+ external?: Record<string, {
982
+ enabled?: boolean;
983
+ client_id?: string;
984
+ secret?: string;
985
+ url?: string;
986
+ redirect_uri?: string;
987
+ skip_nonce_check?: boolean;
988
+ email_optional?: boolean;
989
+ }>;
921
990
  }
922
991
  type EmailTemplateType = "invite" | "confirmation" | "recovery" | "magic_link" | "email_change";
923
992
  interface EmailTemplateConfig {
@@ -926,12 +995,28 @@ interface EmailTemplateConfig {
926
995
  }
927
996
 
928
997
  type Dialect$1 = "postgres" | "sqlite";
998
+ /** Bound `Connection#runInTransaction` — see db/Connection.ts for why this
999
+ * indirection exists (DO storage has no BEGIN/COMMIT over kysely). */
1000
+ type TransactionRunner = <T>(fn: (trx: Kysely<any>) => Promise<T>) => Promise<T>;
929
1001
  declare class AuthRepository {
930
1002
  private db;
931
1003
  private dialect;
1004
+ private runInTransaction;
932
1005
  private schema;
933
- constructor(db: Kysely<any>, dialect: Dialect$1);
1006
+ constructor(db: Kysely<any>, dialect: Dialect$1, runInTransaction?: TransactionRunner);
934
1007
  private bool;
1008
+ /**
1009
+ * Runs `fn` inside a database transaction, handing it a repository bound to
1010
+ * the transaction's executor. All reads/writes performed through that
1011
+ * repository (including this one's other methods) participate in the same
1012
+ * transaction, and are rolled back together if `fn` throws.
1013
+ *
1014
+ * Callers that need existing private helpers (which close over `this.repo`)
1015
+ * to run against the transaction should swap `this.repo` for the duration
1016
+ * of the callback — safe because AuthService/AuthRepository instances are
1017
+ * constructed fresh per request (see server/auth.ts createAuthService).
1018
+ */
1019
+ transaction<T>(fn: (repo: AuthRepository) => Promise<T>): Promise<T>;
935
1020
  private table;
936
1021
  private insertInto;
937
1022
  private update;
@@ -939,9 +1024,22 @@ declare class AuthRepository {
939
1024
  findUserByEmail(email: string): Promise<UsersTable | null>;
940
1025
  findUserById(id: string): Promise<UsersTable | null>;
941
1026
  findUserByToken(column: string, token: string): Promise<UsersTable | null>;
1027
+ /**
1028
+ * Atomically consumes a one-time token: the UPDATE only matches a row whose
1029
+ * `column` still holds `token`, so exactly one of two concurrent verifies
1030
+ * for the same OTP can win, and a token rotated/cleared by another request
1031
+ * (resend, a competing verify) no longer matches. Returns false when no row
1032
+ * was updated — callers must treat that as an invalid/consumed token and
1033
+ * mutate nothing further.
1034
+ *
1035
+ * This is the guard that survives on D1, whose `runInTransaction` cannot
1036
+ * group statements (see D1SqliteConnection L131-140): a single conditional
1037
+ * UPDATE with a rowcount check is atomic on every driver.
1038
+ */
1039
+ claimUserToken(userId: string, column: string, token: string): Promise<boolean>;
942
1040
  createUser(user: Partial<UsersTable> & {
943
1041
  id: string;
944
- email: string;
1042
+ email: string | null;
945
1043
  }): Promise<UsersTable>;
946
1044
  updateUser(id: string, updates: Partial<UsersTable>): Promise<UsersTable | null>;
947
1045
  createSession(session: {
@@ -977,6 +1075,52 @@ declare class AuthRepository {
977
1075
  }): Promise<IdentitiesTable>;
978
1076
  findIdentitiesByUserId(userId: string): Promise<IdentitiesTable[]>;
979
1077
  updateIdentity(id: string, updates: Partial<IdentitiesTable>): Promise<void>;
1078
+ deleteIdentitiesExcept(userId: string, keepId: string): Promise<void>;
1079
+ findIdentityByProviderAndId(provider: string, providerId: string): Promise<IdentitiesTable | null>;
1080
+ findIdentitiesByEmails(emails: string[]): Promise<IdentitiesTable[]>;
1081
+ createFlowState(flow: NewFlowState): Promise<FlowStateTable>;
1082
+ findFlowStateById(id: string): Promise<FlowStateTable | null>;
1083
+ findFlowStateByAuthCode(authCode: string): Promise<FlowStateTable | null>;
1084
+ updateFlowState(id: string, updates: Partial<FlowStateTable>): Promise<void>;
1085
+ /**
1086
+ * Atomically claims a PKCE flow_state row for a callback: the UPDATE only
1087
+ * matches (and thus only succeeds for) a row whose user_id is still null,
1088
+ * so exactly one of two concurrent callbacks for the same state can win.
1089
+ * Returns false if the row was already claimed (or no longer exists) —
1090
+ * callers should treat that as a replay (flow_state_already_used).
1091
+ */
1092
+ claimFlowStateForPkce(id: string, updates: {
1093
+ user_id: string;
1094
+ provider_access_token: string;
1095
+ provider_refresh_token: string;
1096
+ auth_code_issued_at: string;
1097
+ }): Promise<boolean>;
1098
+ /**
1099
+ * Atomically deletes a flow_state row, returning whether a row was
1100
+ * actually removed. A single DELETE...WHERE id = ? is inherently atomic
1101
+ * (at most one caller can ever delete a given row), so this doubles as the
1102
+ * "claim" step for implicit-flow callbacks and PKCE auth-code redemption:
1103
+ * only the caller that observes `true` may proceed to issue a session.
1104
+ */
1105
+ /**
1106
+ * Deletes at most {@link FLOW_STATE_CLEANUP_BATCH} flow_state rows created
1107
+ * before `cutoffIso`. Ports the flow_state statement of GoTrue's periodic
1108
+ * cleanup (internal/models/cleanup.go L62):
1109
+ *
1110
+ * delete from "flow_state" where id in (
1111
+ * select id from "flow_state" where created_at < now() - interval '24 hours'
1112
+ * limit 100 for update skip locked);
1113
+ *
1114
+ * The bound is the point of that statement: cleanup must never turn into an
1115
+ * unbounded delete that blocks the request it is piggybacking on (lite has
1116
+ * no background scheduler, so this runs opportunistically on the /authorize
1117
+ * insert path). A backlog is drained across subsequent /authorize calls.
1118
+ * `for update skip locked` has no sqlite equivalent and is omitted; the
1119
+ * id-in-subquery-with-LIMIT shape works on both dialects. Returns the number
1120
+ * of rows removed.
1121
+ */
1122
+ deleteFlowStatesCreatedBefore(cutoffIso: string): Promise<number>;
1123
+ deleteFlowState(id: string): Promise<boolean>;
980
1124
  createAuditLogEntry(entry: {
981
1125
  id: string;
982
1126
  payload?: Record<string, unknown>;
@@ -1088,6 +1232,11 @@ declare class AuthService {
1088
1232
  token_hash?: string;
1089
1233
  type: string;
1090
1234
  }): Promise<SessionResponse>;
1235
+ /**
1236
+ * The mutating half of {@link verifyOtp}, always run inside a transaction
1237
+ * (`this.repo` is bound to it) — see the comment at the call site.
1238
+ */
1239
+ private completeVerifyOtp;
1091
1240
  recover(email: string | undefined): Promise<void>;
1092
1241
  resend(type: string, email: string | undefined): Promise<void>;
1093
1242
  reauthenticate(userId: string): Promise<void>;
@@ -1100,6 +1249,51 @@ declare class AuthService {
1100
1249
  private isTokenExpired;
1101
1250
  private getTokenColumnsForType;
1102
1251
  private createAuditLog;
1252
+ /**
1253
+ * Same entry shape as {@link createAuditLog}, for the call sites whose
1254
+ * traits map is not `{provider: ...}` (GoTrue builds the map per call site;
1255
+ * see models.NewAuditLogEntry's `traits map[string]any` argument).
1256
+ */
1257
+ private createAuditLogWithTraits;
1258
+ getExternalProviderRedirectUrl(query: Record<string, string | undefined>, opts: {
1259
+ refererHeader?: string;
1260
+ defaultRedirectUri: string;
1261
+ }): Promise<string>;
1262
+ loadOAuthFlowState(state: string | undefined): Promise<FlowStateTable>;
1263
+ resolveOAuthRedirectTarget(flowState: FlowStateTable): string;
1264
+ handleExternalProviderCallback(flowState: FlowStateTable, params: Record<string, string | undefined>, opts: {
1265
+ defaultRedirectUri: string;
1266
+ }): Promise<{
1267
+ type: "pkce" | "implicit";
1268
+ redirectUrl: string;
1269
+ }>;
1270
+ /**
1271
+ * Tail of the external-provider callback, shared by the account-linking and
1272
+ * invite branches: claims the flow state and either hands back the PKCE
1273
+ * auth code or issues a session in the URL fragment (external.go
1274
+ * L221-286). Runs inside the callback's transaction — `this.repo` is
1275
+ * already bound to it by the caller.
1276
+ */
1277
+ private issueOAuthCallbackResult;
1278
+ /**
1279
+ * Ports internal/api/external.go's processInvite (L449-514): accepts an
1280
+ * invitation with an external identity. The invite token is the user's
1281
+ * `confirmation_token` (models.FindUserByConfirmationToken), the external
1282
+ * email must match the invited email, and the user is confirmed because
1283
+ * they were able to respond to the invite email.
1284
+ *
1285
+ * Runs inside the callback's transaction (`this.repo` is bound to it).
1286
+ */
1287
+ private processInvite;
1288
+ exchangePkceCode(authCode: string | undefined, codeVerifier: string | undefined): Promise<SessionResponse & {
1289
+ provider_token?: string;
1290
+ provider_refresh_token?: string;
1291
+ }>;
1292
+ private resolveOAuthReferrer;
1293
+ private updateUserMetaDataAndProviders;
1294
+ private buildAppMetaDataProviders;
1295
+ private removeUnconfirmedIdentities;
1296
+ private determineAccountLinking;
1103
1297
  }
1104
1298
 
1105
1299
  type CrossReadableStream = ReadableStream | ReadableStream$1;
@@ -1361,31 +1555,25 @@ type HonoContext = {
1361
1555
  userId?: string;
1362
1556
  sessionId?: string;
1363
1557
  jwt?: Record<string, unknown>;
1558
+ apiKeyType?: "publishable" | "secret";
1559
+ ignoreAuthorization?: boolean;
1560
+ /**
1561
+ * Set by `adminAuth()` when local admin mode elevated this request to
1562
+ * `service_role`. Observability/tests only — the elevation itself is
1563
+ * carried by `apiKeyType`/`ignoreAuthorization`/`jwt`.
1564
+ */
1565
+ admin?: boolean;
1364
1566
  };
1365
1567
  };
1366
1568
 
1367
- type Where = Record<string, unknown>;
1569
+ type ApiKeyType = "publishable" | "secret";
1368
1570
 
1369
- type PolicyCommand = "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "ALL";
1370
- type PolicyRole = "anon" | "authenticated" | string;
1371
- interface PolicyData {
1372
- name: string;
1373
- table: string;
1374
- schema?: string;
1375
- command: PolicyCommand;
1376
- permissive: boolean;
1377
- roles: PolicyRole[];
1378
- using?: Where;
1379
- withCheck?: Where;
1380
- }
1381
- declare class Policy {
1382
- readonly data: PolicyData;
1383
- constructor(data: PolicyData);
1384
- appliesTo(cmd: "SELECT" | "INSERT" | "UPDATE" | "DELETE"): boolean;
1385
- appliesToRole(role: string): boolean;
1386
- toJSON(): PolicyData;
1387
- static fromJSON(data: PolicyData): Policy;
1388
- }
1571
+ /** Claims are applied verbatim as `request.jwt.claims` MUST include `role`. */
1572
+ type ResolvedKey = {
1573
+ type: ApiKeyType;
1574
+ claims: Record<string, unknown>;
1575
+ };
1576
+ type ApiKeyResolver = (key: string, c: Context<HonoContext>) => Promise<ResolvedKey | null>;
1389
1577
 
1390
1578
  type ServerOptions = {
1391
1579
  middlewares?: MiddlewareHandler<HonoContext>[];
@@ -1395,6 +1583,33 @@ type ServerOptions = {
1395
1583
  * Test-only PostgREST mode: execute each request in a transaction and roll it back.
1396
1584
  */
1397
1585
  forceRollback?: boolean;
1586
+ /**
1587
+ * `false` disables apikey enforcement outright. Otherwise a custom
1588
+ * `resolver` can be supplied (the lite-platform seam); when omitted, keys
1589
+ * configured under `config.auth.publishable_key`/`secret_key` are used.
1590
+ */
1591
+ apiKeys?: false | {
1592
+ resolver?: ApiKeyResolver;
1593
+ };
1594
+ /**
1595
+ * Local admin mode (default `false`): run *keyless* `/rest/v1` and
1596
+ * `/storage/v1` requests as `service_role`, so a browser studio can do
1597
+ * privileged work without a secret key shipping to the browser. Only
1598
+ * same-origin requests addressed to loopback are elevated.
1599
+ *
1600
+ * Two caveats, both local-dev only:
1601
+ * 1. RLS is not enforced for keyless traffic while this is on. To exercise
1602
+ * policies, send an `apikey`: the publishable key for `anon`, or the
1603
+ * publishable key PLUS `Authorization: Bearer <user JWT>` for
1604
+ * `authenticated`. Those requests are never elevated. A bearer token on
1605
+ * its own is rejected before RLS is reached (401), since opaque keys are
1606
+ * only sourced from `apikey`.
1607
+ * 2. Localhost trust is not per-request trust. Any page open in the
1608
+ * developer's browser can reach the server; the same-origin and
1609
+ * loopback guards are what keep that from being a data-exfiltration
1610
+ * hole. Never enable outside local development.
1611
+ */
1612
+ admin?: boolean;
1398
1613
  };
1399
1614
  declare function createServer(app: App, options?: ServerOptions): hono_hono_base.HonoBase<HonoContext & {
1400
1615
  Variables: {
@@ -1707,32 +1922,9 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
1707
1922
  input: {};
1708
1923
  output: {
1709
1924
  external: {
1710
- anonymous_users: boolean;
1711
- apple: boolean;
1712
- azure: boolean;
1713
- bitbucket: boolean;
1714
- discord: boolean;
1715
- facebook: boolean;
1716
- snapchat: boolean;
1717
- figma: boolean;
1718
- fly: boolean;
1719
- github: boolean;
1720
- gitlab: boolean;
1721
- google: boolean;
1722
- keycloak: boolean;
1723
- kakao: boolean;
1724
- linkedin: boolean;
1725
- linkedin_oidc: boolean;
1726
- notion: boolean;
1727
- spotify: boolean;
1728
- slack: boolean;
1729
- slack_oidc: boolean;
1730
- workos: boolean;
1731
- twitch: boolean;
1732
- twitter: boolean;
1733
1925
  email: boolean;
1734
1926
  phone: boolean;
1735
- zoom: boolean;
1927
+ anonymous_users: boolean;
1736
1928
  };
1737
1929
  disable_signup: boolean;
1738
1930
  mailer_autoconfirm: boolean;
@@ -1774,6 +1966,33 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
1774
1966
  status: 200;
1775
1967
  };
1776
1968
  };
1969
+ } & {
1970
+ "/authorize": {
1971
+ $get: {
1972
+ input: {};
1973
+ output: string;
1974
+ outputFormat: "body";
1975
+ status: 302;
1976
+ };
1977
+ };
1978
+ } & {
1979
+ "/callback": {
1980
+ $get: {
1981
+ input: {};
1982
+ output: {};
1983
+ outputFormat: string;
1984
+ status: hono_utils_http_status.StatusCode;
1985
+ };
1986
+ };
1987
+ } & {
1988
+ "/callback": {
1989
+ $post: {
1990
+ input: {};
1991
+ output: {};
1992
+ outputFormat: string;
1993
+ status: hono_utils_http_status.StatusCode;
1994
+ };
1995
+ };
1777
1996
  } & {
1778
1997
  "/nonexistent": {
1779
1998
  $all: {
@@ -2126,14 +2345,14 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2126
2345
  json: {
2127
2346
  [x: string]: unknown;
2128
2347
  search?: string | undefined;
2129
- prefix?: string | undefined;
2130
- limit?: number | undefined;
2131
- offset?: number | undefined;
2132
2348
  sortBy?: {
2133
2349
  [x: string]: unknown;
2134
2350
  column: string;
2135
2351
  order: string;
2136
2352
  } | undefined;
2353
+ limit?: number | undefined;
2354
+ offset?: number | undefined;
2355
+ prefix?: string | undefined;
2137
2356
  };
2138
2357
  } & {
2139
2358
  param: {
@@ -2415,431 +2634,7 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2415
2634
  "/config": {
2416
2635
  $get: {
2417
2636
  input: {};
2418
- output: {
2419
- project_id?: string | undefined;
2420
- analytics?: {
2421
- enabled?: boolean | undefined;
2422
- port?: number | undefined;
2423
- vector_port?: number | undefined;
2424
- backend?: "postgres" | "bigquery" | undefined;
2425
- } | undefined;
2426
- api?: {
2427
- enabled?: boolean | undefined;
2428
- port?: number | undefined;
2429
- schemas?: string[] | undefined;
2430
- extra_search_path?: string[] | undefined;
2431
- max_rows?: number | undefined;
2432
- pg_safe_update?: boolean | undefined;
2433
- plan_enabled?: boolean | undefined;
2434
- aggregates_enabled?: boolean | undefined;
2435
- limited_mutations_enabled?: boolean | undefined;
2436
- anonymous_enabled?: boolean | undefined;
2437
- external_url?: string | undefined;
2438
- tls?: {
2439
- enabled?: boolean | undefined;
2440
- } | undefined;
2441
- } | undefined;
2442
- storage?: {
2443
- enabled?: boolean | undefined;
2444
- file_size_limit?: string | undefined;
2445
- buckets?: {
2446
- [x: string]: {
2447
- public?: boolean | undefined;
2448
- file_size_limit?: string | undefined;
2449
- allowed_mime_types?: string[] | undefined;
2450
- objects_path?: string | undefined;
2451
- };
2452
- } | undefined;
2453
- image_transformation?: {
2454
- enabled?: boolean | undefined;
2455
- } | undefined;
2456
- } | undefined;
2457
- auth?: {
2458
- enabled?: boolean | undefined;
2459
- jwt_secret?: string | undefined;
2460
- site_url?: string | undefined;
2461
- additional_redirect_urls?: string[] | undefined;
2462
- jwt_expiry?: number | undefined;
2463
- enable_refresh_token_rotation?: boolean | undefined;
2464
- refresh_token_reuse_interval?: number | undefined;
2465
- enable_manual_linking?: boolean | undefined;
2466
- enable_signup?: boolean | undefined;
2467
- enable_anonymous_sign_ins?: boolean | undefined;
2468
- minimum_password_length?: number | undefined;
2469
- password_requirements?: string | undefined;
2470
- hook?: {
2471
- mfa_verification_attempt?: {
2472
- enabled?: boolean | undefined;
2473
- uri?: string | undefined;
2474
- secrets?: string[] | undefined;
2475
- } | undefined;
2476
- password_verification_attempt?: {
2477
- enabled?: boolean | undefined;
2478
- uri?: string | undefined;
2479
- secrets?: string[] | undefined;
2480
- } | undefined;
2481
- custom_access_token?: {
2482
- enabled?: boolean | undefined;
2483
- uri?: string | undefined;
2484
- secrets?: string[] | undefined;
2485
- } | undefined;
2486
- send_sms?: {
2487
- enabled?: boolean | undefined;
2488
- uri?: string | undefined;
2489
- secrets?: string[] | undefined;
2490
- } | undefined;
2491
- send_email?: {
2492
- enabled?: boolean | undefined;
2493
- uri?: string | undefined;
2494
- secrets?: string[] | undefined;
2495
- } | undefined;
2496
- } | undefined;
2497
- mfa?: {
2498
- max_enrolled_factors?: number | undefined;
2499
- totp?: {
2500
- enroll_enabled?: boolean | undefined;
2501
- verify_enabled?: boolean | undefined;
2502
- } | undefined;
2503
- phone?: {
2504
- template?: string | undefined;
2505
- enroll_enabled?: boolean | undefined;
2506
- verify_enabled?: boolean | undefined;
2507
- otp_length?: number | undefined;
2508
- max_frequency?: string | undefined;
2509
- } | undefined;
2510
- } | undefined;
2511
- sessions?: {
2512
- timebox?: string | undefined;
2513
- inactivity_timeout?: string | undefined;
2514
- single_per_user?: boolean | undefined;
2515
- } | undefined;
2516
- email?: {
2517
- template?: {
2518
- invite?: {
2519
- subject?: string | undefined;
2520
- content_path?: string | undefined;
2521
- } | undefined;
2522
- confirmation?: {
2523
- subject?: string | undefined;
2524
- content_path?: string | undefined;
2525
- } | undefined;
2526
- recovery?: {
2527
- subject?: string | undefined;
2528
- content_path?: string | undefined;
2529
- } | undefined;
2530
- magic_link?: {
2531
- subject?: string | undefined;
2532
- content_path?: string | undefined;
2533
- } | undefined;
2534
- email_change?: {
2535
- subject?: string | undefined;
2536
- content_path?: string | undefined;
2537
- } | undefined;
2538
- } | undefined;
2539
- enable_signup?: boolean | undefined;
2540
- otp_length?: number | undefined;
2541
- max_frequency?: string | undefined;
2542
- double_confirm_changes?: boolean | undefined;
2543
- enable_confirmations?: boolean | undefined;
2544
- secure_password_change?: boolean | undefined;
2545
- otp_expiry?: number | undefined;
2546
- smtp?: {
2547
- port?: number | undefined;
2548
- host?: string | undefined;
2549
- user?: string | undefined;
2550
- pass?: string | undefined;
2551
- admin_email?: string | undefined;
2552
- sender_name?: string | undefined;
2553
- } | undefined;
2554
- } | undefined;
2555
- sms?: {
2556
- template?: string | undefined;
2557
- enable_signup?: boolean | undefined;
2558
- max_frequency?: string | undefined;
2559
- enable_confirmations?: boolean | undefined;
2560
- test_otp?: {
2561
- [x: string]: string;
2562
- } | undefined;
2563
- twilio?: {
2564
- enabled?: boolean | undefined;
2565
- account_sid?: string | undefined;
2566
- message_service_sid?: string | undefined;
2567
- auth_token?: string | undefined;
2568
- } | undefined;
2569
- twilio_verify?: {
2570
- enabled?: boolean | undefined;
2571
- account_sid?: string | undefined;
2572
- message_service_sid?: string | undefined;
2573
- auth_token?: string | undefined;
2574
- } | undefined;
2575
- messagebird?: {
2576
- enabled?: boolean | undefined;
2577
- originator?: string | undefined;
2578
- api_key?: string | undefined;
2579
- } | undefined;
2580
- textlocal?: {
2581
- enabled?: boolean | undefined;
2582
- api_key?: string | undefined;
2583
- sender?: string | undefined;
2584
- } | undefined;
2585
- vonage?: {
2586
- enabled?: boolean | undefined;
2587
- api_key?: string | undefined;
2588
- from?: string | undefined;
2589
- api_secret?: string | undefined;
2590
- } | undefined;
2591
- } | undefined;
2592
- external?: {
2593
- apple?: {
2594
- enabled?: boolean | undefined;
2595
- client_id?: string | undefined;
2596
- secret?: string | undefined;
2597
- url?: string | undefined;
2598
- redirect_uri?: string | undefined;
2599
- skip_nonce_check?: boolean | undefined;
2600
- } | undefined;
2601
- azure?: {
2602
- enabled?: boolean | undefined;
2603
- client_id?: string | undefined;
2604
- secret?: string | undefined;
2605
- url?: string | undefined;
2606
- redirect_uri?: string | undefined;
2607
- skip_nonce_check?: boolean | undefined;
2608
- } | undefined;
2609
- bitbucket?: {
2610
- enabled?: boolean | undefined;
2611
- client_id?: string | undefined;
2612
- secret?: string | undefined;
2613
- url?: string | undefined;
2614
- redirect_uri?: string | undefined;
2615
- skip_nonce_check?: boolean | undefined;
2616
- } | undefined;
2617
- discord?: {
2618
- enabled?: boolean | undefined;
2619
- client_id?: string | undefined;
2620
- secret?: string | undefined;
2621
- url?: string | undefined;
2622
- redirect_uri?: string | undefined;
2623
- skip_nonce_check?: boolean | undefined;
2624
- } | undefined;
2625
- facebook?: {
2626
- enabled?: boolean | undefined;
2627
- client_id?: string | undefined;
2628
- secret?: string | undefined;
2629
- url?: string | undefined;
2630
- redirect_uri?: string | undefined;
2631
- skip_nonce_check?: boolean | undefined;
2632
- } | undefined;
2633
- github?: {
2634
- enabled?: boolean | undefined;
2635
- client_id?: string | undefined;
2636
- secret?: string | undefined;
2637
- url?: string | undefined;
2638
- redirect_uri?: string | undefined;
2639
- skip_nonce_check?: boolean | undefined;
2640
- } | undefined;
2641
- gitlab?: {
2642
- enabled?: boolean | undefined;
2643
- client_id?: string | undefined;
2644
- secret?: string | undefined;
2645
- url?: string | undefined;
2646
- redirect_uri?: string | undefined;
2647
- skip_nonce_check?: boolean | undefined;
2648
- } | undefined;
2649
- google?: {
2650
- enabled?: boolean | undefined;
2651
- client_id?: string | undefined;
2652
- secret?: string | undefined;
2653
- url?: string | undefined;
2654
- redirect_uri?: string | undefined;
2655
- skip_nonce_check?: boolean | undefined;
2656
- } | undefined;
2657
- kakao?: {
2658
- enabled?: boolean | undefined;
2659
- client_id?: string | undefined;
2660
- secret?: string | undefined;
2661
- url?: string | undefined;
2662
- redirect_uri?: string | undefined;
2663
- skip_nonce_check?: boolean | undefined;
2664
- } | undefined;
2665
- keycloak?: {
2666
- enabled?: boolean | undefined;
2667
- client_id?: string | undefined;
2668
- secret?: string | undefined;
2669
- url?: string | undefined;
2670
- redirect_uri?: string | undefined;
2671
- skip_nonce_check?: boolean | undefined;
2672
- } | undefined;
2673
- linkedin?: {
2674
- enabled?: boolean | undefined;
2675
- client_id?: string | undefined;
2676
- secret?: string | undefined;
2677
- url?: string | undefined;
2678
- redirect_uri?: string | undefined;
2679
- skip_nonce_check?: boolean | undefined;
2680
- } | undefined;
2681
- notion?: {
2682
- enabled?: boolean | undefined;
2683
- client_id?: string | undefined;
2684
- secret?: string | undefined;
2685
- url?: string | undefined;
2686
- redirect_uri?: string | undefined;
2687
- skip_nonce_check?: boolean | undefined;
2688
- } | undefined;
2689
- twitch?: {
2690
- enabled?: boolean | undefined;
2691
- client_id?: string | undefined;
2692
- secret?: string | undefined;
2693
- url?: string | undefined;
2694
- redirect_uri?: string | undefined;
2695
- skip_nonce_check?: boolean | undefined;
2696
- } | undefined;
2697
- twitter?: {
2698
- enabled?: boolean | undefined;
2699
- client_id?: string | undefined;
2700
- secret?: string | undefined;
2701
- url?: string | undefined;
2702
- redirect_uri?: string | undefined;
2703
- skip_nonce_check?: boolean | undefined;
2704
- } | undefined;
2705
- slack?: {
2706
- enabled?: boolean | undefined;
2707
- client_id?: string | undefined;
2708
- secret?: string | undefined;
2709
- url?: string | undefined;
2710
- redirect_uri?: string | undefined;
2711
- skip_nonce_check?: boolean | undefined;
2712
- } | undefined;
2713
- spotify?: {
2714
- enabled?: boolean | undefined;
2715
- client_id?: string | undefined;
2716
- secret?: string | undefined;
2717
- url?: string | undefined;
2718
- redirect_uri?: string | undefined;
2719
- skip_nonce_check?: boolean | undefined;
2720
- } | undefined;
2721
- workos?: {
2722
- enabled?: boolean | undefined;
2723
- client_id?: string | undefined;
2724
- secret?: string | undefined;
2725
- url?: string | undefined;
2726
- redirect_uri?: string | undefined;
2727
- skip_nonce_check?: boolean | undefined;
2728
- } | undefined;
2729
- zoom?: {
2730
- enabled?: boolean | undefined;
2731
- client_id?: string | undefined;
2732
- secret?: string | undefined;
2733
- url?: string | undefined;
2734
- redirect_uri?: string | undefined;
2735
- skip_nonce_check?: boolean | undefined;
2736
- } | undefined;
2737
- } | undefined;
2738
- } | undefined;
2739
- inbucket?: {
2740
- enabled?: boolean | undefined;
2741
- port?: number | undefined;
2742
- smtp_port?: number | undefined;
2743
- pop3_port?: number | undefined;
2744
- } | undefined;
2745
- functions?: {
2746
- [x: string]: {
2747
- enabled?: boolean | undefined;
2748
- verify_jwt?: boolean | undefined;
2749
- import_map?: string | undefined;
2750
- entrypoint?: string | undefined;
2751
- };
2752
- } | undefined;
2753
- realtime?: {
2754
- enabled?: boolean | undefined;
2755
- ip_version?: string | undefined;
2756
- max_header_length?: number | undefined;
2757
- } | undefined;
2758
- studio?: {
2759
- enabled?: boolean | undefined;
2760
- port?: number | undefined;
2761
- api_url?: string | undefined;
2762
- openai_api_key?: string | undefined;
2763
- } | undefined;
2764
- experimental?: {
2765
- orioledb_version?: string | undefined;
2766
- s3_host?: string | undefined;
2767
- s3_region?: string | undefined;
2768
- s3_access_key?: string | undefined;
2769
- s3_secret_key?: string | undefined;
2770
- } | undefined;
2771
- db?: {
2772
- [x: string]: hono_utils_types.JSONValue;
2773
- port?: number | undefined;
2774
- url?: string | undefined;
2775
- driver?: "postgres" | "sqlite" | "sqlite-postgres" | "pglite" | undefined;
2776
- shadow_port?: number | undefined;
2777
- major_version?: number | undefined;
2778
- pooler?: {
2779
- [x: string]: hono_utils_types.JSONValue;
2780
- enabled?: boolean | undefined;
2781
- port?: number | undefined;
2782
- pool_mode?: string | undefined;
2783
- default_pool_size?: number | undefined;
2784
- max_client_conn?: number | undefined;
2785
- } | undefined;
2786
- seed?: {
2787
- enabled?: boolean | undefined;
2788
- sql_paths?: string[] | undefined;
2789
- } | undefined;
2790
- migrations?: {
2791
- enabled?: boolean | undefined;
2792
- schema_paths?: string[] | undefined;
2793
- } | undefined;
2794
- } | undefined;
2795
- edge_runtime?: {
2796
- enabled?: boolean | undefined;
2797
- policy?: "oneshot" | "per_worker" | undefined;
2798
- inspector_port?: number | undefined;
2799
- } | undefined;
2800
- options?: {
2801
- defaults?: true | undefined;
2802
- server?: {
2803
- middlewares?: never[] | undefined;
2804
- disableStudio?: boolean | undefined;
2805
- disableFallback?: boolean | undefined;
2806
- forceRollback?: boolean | undefined;
2807
- } | undefined;
2808
- drivers?: {
2809
- email?: {
2810
- send: never;
2811
- } | undefined;
2812
- sms?: {
2813
- send: never;
2814
- } | undefined;
2815
- cache?: {
2816
- get: never;
2817
- set: never;
2818
- delete: never;
2819
- } | undefined;
2820
- } | undefined;
2821
- system?: {
2822
- schemaReconciliation?: "additive" | "full" | undefined;
2823
- } | undefined;
2824
- } | undefined;
2825
- rls?: {
2826
- tables: string[];
2827
- policies: {
2828
- name: string;
2829
- table: string;
2830
- schema?: string | undefined;
2831
- command: PolicyCommand;
2832
- permissive: boolean;
2833
- roles: PolicyRole[];
2834
- using?: {
2835
- [x: string]: hono_utils_types.JSONValue;
2836
- } | undefined;
2837
- withCheck?: {
2838
- [x: string]: hono_utils_types.JSONValue;
2839
- } | undefined;
2840
- }[];
2841
- } | undefined;
2842
- };
2637
+ output: {};
2843
2638
  outputFormat: "json";
2844
2639
  status: hono_utils_http_status.ContentfulStatusCode;
2845
2640
  };
@@ -2848,7 +2643,11 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2848
2643
  "/info": {
2849
2644
  $get: {
2850
2645
  input: {};
2851
- output: {};
2646
+ output: {
2647
+ connection: any;
2648
+ config: any;
2649
+ admin: boolean;
2650
+ };
2852
2651
  outputFormat: "json";
2853
2652
  status: hono_utils_http_status.ContentfulStatusCode;
2854
2653
  };
@@ -2987,6 +2786,29 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2987
2786
  };
2988
2787
  }, "/_system">, "/", "*">;
2989
2788
 
2789
+ type Where = Record<string, unknown>;
2790
+
2791
+ type PolicyCommand = "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "ALL";
2792
+ type PolicyRole = "anon" | "authenticated" | string;
2793
+ interface PolicyData {
2794
+ name: string;
2795
+ table: string;
2796
+ schema?: string;
2797
+ command: PolicyCommand;
2798
+ permissive: boolean;
2799
+ roles: PolicyRole[];
2800
+ using?: Where;
2801
+ withCheck?: Where;
2802
+ }
2803
+ declare class Policy {
2804
+ readonly data: PolicyData;
2805
+ constructor(data: PolicyData);
2806
+ appliesTo(cmd: "SELECT" | "INSERT" | "UPDATE" | "DELETE"): boolean;
2807
+ appliesToRole(role: string): boolean;
2808
+ toJSON(): PolicyData;
2809
+ static fromJSON(data: PolicyData): Policy;
2810
+ }
2811
+
2990
2812
  interface IAppConfig extends DefaultSchema {
2991
2813
  connection: Connection | Promise<Connection>;
2992
2814
  rls?: {
@@ -3027,6 +2849,11 @@ declare class App<Config extends IAppConfig = DefaultAppConfig, Conn = Config ex
3027
2849
  private readonly _rls;
3028
2850
  readonly config: DefaultSchema & Omit<Config, "connection">;
3029
2851
  readonly server: ReturnType<typeof createServer>;
2852
+ /**
2853
+ * Resolved local admin mode, after CLI-flag / config-file precedence. Read
2854
+ * this (never the raw CLI flag) when reporting what the server is doing.
2855
+ */
2856
+ readonly adminMode: boolean;
3030
2857
  readonly drivers: AppDrivers;
3031
2858
  _mailer?: Mailer;
3032
2859
  _storageAdapter?: StorageAdapter;
@@ -3052,7 +2879,9 @@ declare class App<Config extends IAppConfig = DefaultAppConfig, Conn = Config ex
3052
2879
  force?: boolean;
3053
2880
  }): Promise<void>;
3054
2881
  isValidConfig(config: Schema | DefaultSchema | IAppConfig): boolean;
3055
- getClient<SchemaName extends string = "public">(options?: SupabaseClientOptions<SchemaName>): _supabase_supabase_js.SupabaseClient<any, "public", SchemaName, Omit<any, "__InternalSupabase">[SchemaName] extends {
2882
+ getClient<SchemaName extends string = "public">(options?: SupabaseClientOptions<SchemaName> & {
2883
+ apikey?: string;
2884
+ }): _supabase_supabase_js.SupabaseClient<any, "public", SchemaName, Omit<any, "__InternalSupabase">[SchemaName] extends {
3056
2885
  Tables: Record<string, {
3057
2886
  Row: Record<string, unknown>;
3058
2887
  Insert: Record<string, unknown>;
@@ -3116,6 +2945,17 @@ type SupaliteOptions = {
3116
2945
  forceSchema?: boolean;
3117
2946
  initOnBoot?: boolean;
3118
2947
  prefixes?: string[];
2948
+ /**
2949
+ * Local admin mode (default `true`): keyless, same-origin, loopback
2950
+ * requests from the dev server run as `service_role`. In practice that
2951
+ * means `/rest/v1` here — admin mode also covers `/storage/v1`, but this
2952
+ * plugin does not mount that prefix unless you add it to `prefixes`.
2953
+ *
2954
+ * See `ServerOptions.admin` for the caveats. Never applied in
2955
+ * `vite preview`, which serves a production build; an explicit value here
2956
+ * also outranks `options.server.admin` in `config.toml`.
2957
+ */
2958
+ admin?: boolean;
3119
2959
  };
3120
2960
  declare function supalite(options?: SupaliteOptions): Plugin;
3121
2961