@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.
@@ -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;
@@ -154,6 +156,7 @@ declare const schema: s.ObjectSchema<{
154
156
  secure_password_change?: boolean | undefined;
155
157
  otp_expiry?: number | undefined;
156
158
  smtp?: {
159
+ enabled?: boolean | undefined;
157
160
  port?: number | undefined;
158
161
  host?: string | undefined;
159
162
  user?: string | undefined;
@@ -207,6 +210,7 @@ declare const schema: s.ObjectSchema<{
207
210
  url?: string | undefined;
208
211
  redirect_uri?: string | undefined;
209
212
  skip_nonce_check?: boolean | undefined;
213
+ email_optional?: boolean | undefined;
210
214
  } | undefined;
211
215
  azure?: {
212
216
  enabled?: boolean | undefined;
@@ -215,6 +219,7 @@ declare const schema: s.ObjectSchema<{
215
219
  url?: string | undefined;
216
220
  redirect_uri?: string | undefined;
217
221
  skip_nonce_check?: boolean | undefined;
222
+ email_optional?: boolean | undefined;
218
223
  } | undefined;
219
224
  bitbucket?: {
220
225
  enabled?: boolean | undefined;
@@ -223,6 +228,7 @@ declare const schema: s.ObjectSchema<{
223
228
  url?: string | undefined;
224
229
  redirect_uri?: string | undefined;
225
230
  skip_nonce_check?: boolean | undefined;
231
+ email_optional?: boolean | undefined;
226
232
  } | undefined;
227
233
  discord?: {
228
234
  enabled?: boolean | undefined;
@@ -231,6 +237,7 @@ declare const schema: s.ObjectSchema<{
231
237
  url?: string | undefined;
232
238
  redirect_uri?: string | undefined;
233
239
  skip_nonce_check?: boolean | undefined;
240
+ email_optional?: boolean | undefined;
234
241
  } | undefined;
235
242
  facebook?: {
236
243
  enabled?: boolean | undefined;
@@ -239,6 +246,7 @@ declare const schema: s.ObjectSchema<{
239
246
  url?: string | undefined;
240
247
  redirect_uri?: string | undefined;
241
248
  skip_nonce_check?: boolean | undefined;
249
+ email_optional?: boolean | undefined;
242
250
  } | undefined;
243
251
  github?: {
244
252
  enabled?: boolean | undefined;
@@ -247,6 +255,7 @@ declare const schema: s.ObjectSchema<{
247
255
  url?: string | undefined;
248
256
  redirect_uri?: string | undefined;
249
257
  skip_nonce_check?: boolean | undefined;
258
+ email_optional?: boolean | undefined;
250
259
  } | undefined;
251
260
  gitlab?: {
252
261
  enabled?: boolean | undefined;
@@ -255,6 +264,7 @@ declare const schema: s.ObjectSchema<{
255
264
  url?: string | undefined;
256
265
  redirect_uri?: string | undefined;
257
266
  skip_nonce_check?: boolean | undefined;
267
+ email_optional?: boolean | undefined;
258
268
  } | undefined;
259
269
  google?: {
260
270
  enabled?: boolean | undefined;
@@ -263,6 +273,7 @@ declare const schema: s.ObjectSchema<{
263
273
  url?: string | undefined;
264
274
  redirect_uri?: string | undefined;
265
275
  skip_nonce_check?: boolean | undefined;
276
+ email_optional?: boolean | undefined;
266
277
  } | undefined;
267
278
  kakao?: {
268
279
  enabled?: boolean | undefined;
@@ -271,6 +282,7 @@ declare const schema: s.ObjectSchema<{
271
282
  url?: string | undefined;
272
283
  redirect_uri?: string | undefined;
273
284
  skip_nonce_check?: boolean | undefined;
285
+ email_optional?: boolean | undefined;
274
286
  } | undefined;
275
287
  keycloak?: {
276
288
  enabled?: boolean | undefined;
@@ -279,6 +291,7 @@ declare const schema: s.ObjectSchema<{
279
291
  url?: string | undefined;
280
292
  redirect_uri?: string | undefined;
281
293
  skip_nonce_check?: boolean | undefined;
294
+ email_optional?: boolean | undefined;
282
295
  } | undefined;
283
296
  linkedin?: {
284
297
  enabled?: boolean | undefined;
@@ -287,6 +300,7 @@ declare const schema: s.ObjectSchema<{
287
300
  url?: string | undefined;
288
301
  redirect_uri?: string | undefined;
289
302
  skip_nonce_check?: boolean | undefined;
303
+ email_optional?: boolean | undefined;
290
304
  } | undefined;
291
305
  notion?: {
292
306
  enabled?: boolean | undefined;
@@ -295,6 +309,7 @@ declare const schema: s.ObjectSchema<{
295
309
  url?: string | undefined;
296
310
  redirect_uri?: string | undefined;
297
311
  skip_nonce_check?: boolean | undefined;
312
+ email_optional?: boolean | undefined;
298
313
  } | undefined;
299
314
  twitch?: {
300
315
  enabled?: boolean | undefined;
@@ -303,6 +318,7 @@ declare const schema: s.ObjectSchema<{
303
318
  url?: string | undefined;
304
319
  redirect_uri?: string | undefined;
305
320
  skip_nonce_check?: boolean | undefined;
321
+ email_optional?: boolean | undefined;
306
322
  } | undefined;
307
323
  twitter?: {
308
324
  enabled?: boolean | undefined;
@@ -311,6 +327,7 @@ declare const schema: s.ObjectSchema<{
311
327
  url?: string | undefined;
312
328
  redirect_uri?: string | undefined;
313
329
  skip_nonce_check?: boolean | undefined;
330
+ email_optional?: boolean | undefined;
314
331
  } | undefined;
315
332
  slack?: {
316
333
  enabled?: boolean | undefined;
@@ -319,6 +336,7 @@ declare const schema: s.ObjectSchema<{
319
336
  url?: string | undefined;
320
337
  redirect_uri?: string | undefined;
321
338
  skip_nonce_check?: boolean | undefined;
339
+ email_optional?: boolean | undefined;
322
340
  } | undefined;
323
341
  spotify?: {
324
342
  enabled?: boolean | undefined;
@@ -327,6 +345,7 @@ declare const schema: s.ObjectSchema<{
327
345
  url?: string | undefined;
328
346
  redirect_uri?: string | undefined;
329
347
  skip_nonce_check?: boolean | undefined;
348
+ email_optional?: boolean | undefined;
330
349
  } | undefined;
331
350
  workos?: {
332
351
  enabled?: boolean | undefined;
@@ -335,6 +354,7 @@ declare const schema: s.ObjectSchema<{
335
354
  url?: string | undefined;
336
355
  redirect_uri?: string | undefined;
337
356
  skip_nonce_check?: boolean | undefined;
357
+ email_optional?: boolean | undefined;
338
358
  } | undefined;
339
359
  zoom?: {
340
360
  enabled?: boolean | undefined;
@@ -343,11 +363,14 @@ declare const schema: s.ObjectSchema<{
343
363
  url?: string | undefined;
344
364
  redirect_uri?: string | undefined;
345
365
  skip_nonce_check?: boolean | undefined;
366
+ email_optional?: boolean | undefined;
346
367
  } | undefined;
347
368
  } | undefined;
348
369
  } | undefined, {
349
370
  enabled?: boolean | undefined;
350
371
  jwt_secret?: string | undefined;
372
+ publishable_key?: string | undefined;
373
+ secret_key?: string | undefined;
351
374
  site_url?: string | undefined;
352
375
  additional_redirect_urls?: string[] | undefined;
353
376
  jwt_expiry?: number | undefined;
@@ -435,6 +458,7 @@ declare const schema: s.ObjectSchema<{
435
458
  secure_password_change?: boolean | undefined;
436
459
  otp_expiry?: number | undefined;
437
460
  smtp?: {
461
+ enabled?: boolean | undefined;
438
462
  port?: number | undefined;
439
463
  host?: string | undefined;
440
464
  user?: string | undefined;
@@ -488,6 +512,7 @@ declare const schema: s.ObjectSchema<{
488
512
  url?: string | undefined;
489
513
  redirect_uri?: string | undefined;
490
514
  skip_nonce_check?: boolean | undefined;
515
+ email_optional?: boolean | undefined;
491
516
  } | undefined;
492
517
  azure?: {
493
518
  enabled?: boolean | undefined;
@@ -496,6 +521,7 @@ declare const schema: s.ObjectSchema<{
496
521
  url?: string | undefined;
497
522
  redirect_uri?: string | undefined;
498
523
  skip_nonce_check?: boolean | undefined;
524
+ email_optional?: boolean | undefined;
499
525
  } | undefined;
500
526
  bitbucket?: {
501
527
  enabled?: boolean | undefined;
@@ -504,6 +530,7 @@ declare const schema: s.ObjectSchema<{
504
530
  url?: string | undefined;
505
531
  redirect_uri?: string | undefined;
506
532
  skip_nonce_check?: boolean | undefined;
533
+ email_optional?: boolean | undefined;
507
534
  } | undefined;
508
535
  discord?: {
509
536
  enabled?: boolean | undefined;
@@ -512,6 +539,7 @@ declare const schema: s.ObjectSchema<{
512
539
  url?: string | undefined;
513
540
  redirect_uri?: string | undefined;
514
541
  skip_nonce_check?: boolean | undefined;
542
+ email_optional?: boolean | undefined;
515
543
  } | undefined;
516
544
  facebook?: {
517
545
  enabled?: boolean | undefined;
@@ -520,6 +548,7 @@ declare const schema: s.ObjectSchema<{
520
548
  url?: string | undefined;
521
549
  redirect_uri?: string | undefined;
522
550
  skip_nonce_check?: boolean | undefined;
551
+ email_optional?: boolean | undefined;
523
552
  } | undefined;
524
553
  github?: {
525
554
  enabled?: boolean | undefined;
@@ -528,6 +557,7 @@ declare const schema: s.ObjectSchema<{
528
557
  url?: string | undefined;
529
558
  redirect_uri?: string | undefined;
530
559
  skip_nonce_check?: boolean | undefined;
560
+ email_optional?: boolean | undefined;
531
561
  } | undefined;
532
562
  gitlab?: {
533
563
  enabled?: boolean | undefined;
@@ -536,6 +566,7 @@ declare const schema: s.ObjectSchema<{
536
566
  url?: string | undefined;
537
567
  redirect_uri?: string | undefined;
538
568
  skip_nonce_check?: boolean | undefined;
569
+ email_optional?: boolean | undefined;
539
570
  } | undefined;
540
571
  google?: {
541
572
  enabled?: boolean | undefined;
@@ -544,6 +575,7 @@ declare const schema: s.ObjectSchema<{
544
575
  url?: string | undefined;
545
576
  redirect_uri?: string | undefined;
546
577
  skip_nonce_check?: boolean | undefined;
578
+ email_optional?: boolean | undefined;
547
579
  } | undefined;
548
580
  kakao?: {
549
581
  enabled?: boolean | undefined;
@@ -552,6 +584,7 @@ declare const schema: s.ObjectSchema<{
552
584
  url?: string | undefined;
553
585
  redirect_uri?: string | undefined;
554
586
  skip_nonce_check?: boolean | undefined;
587
+ email_optional?: boolean | undefined;
555
588
  } | undefined;
556
589
  keycloak?: {
557
590
  enabled?: boolean | undefined;
@@ -560,6 +593,7 @@ declare const schema: s.ObjectSchema<{
560
593
  url?: string | undefined;
561
594
  redirect_uri?: string | undefined;
562
595
  skip_nonce_check?: boolean | undefined;
596
+ email_optional?: boolean | undefined;
563
597
  } | undefined;
564
598
  linkedin?: {
565
599
  enabled?: boolean | undefined;
@@ -568,6 +602,7 @@ declare const schema: s.ObjectSchema<{
568
602
  url?: string | undefined;
569
603
  redirect_uri?: string | undefined;
570
604
  skip_nonce_check?: boolean | undefined;
605
+ email_optional?: boolean | undefined;
571
606
  } | undefined;
572
607
  notion?: {
573
608
  enabled?: boolean | undefined;
@@ -576,6 +611,7 @@ declare const schema: s.ObjectSchema<{
576
611
  url?: string | undefined;
577
612
  redirect_uri?: string | undefined;
578
613
  skip_nonce_check?: boolean | undefined;
614
+ email_optional?: boolean | undefined;
579
615
  } | undefined;
580
616
  twitch?: {
581
617
  enabled?: boolean | undefined;
@@ -584,6 +620,7 @@ declare const schema: s.ObjectSchema<{
584
620
  url?: string | undefined;
585
621
  redirect_uri?: string | undefined;
586
622
  skip_nonce_check?: boolean | undefined;
623
+ email_optional?: boolean | undefined;
587
624
  } | undefined;
588
625
  twitter?: {
589
626
  enabled?: boolean | undefined;
@@ -592,6 +629,7 @@ declare const schema: s.ObjectSchema<{
592
629
  url?: string | undefined;
593
630
  redirect_uri?: string | undefined;
594
631
  skip_nonce_check?: boolean | undefined;
632
+ email_optional?: boolean | undefined;
595
633
  } | undefined;
596
634
  slack?: {
597
635
  enabled?: boolean | undefined;
@@ -600,6 +638,7 @@ declare const schema: s.ObjectSchema<{
600
638
  url?: string | undefined;
601
639
  redirect_uri?: string | undefined;
602
640
  skip_nonce_check?: boolean | undefined;
641
+ email_optional?: boolean | undefined;
603
642
  } | undefined;
604
643
  spotify?: {
605
644
  enabled?: boolean | undefined;
@@ -608,6 +647,7 @@ declare const schema: s.ObjectSchema<{
608
647
  url?: string | undefined;
609
648
  redirect_uri?: string | undefined;
610
649
  skip_nonce_check?: boolean | undefined;
650
+ email_optional?: boolean | undefined;
611
651
  } | undefined;
612
652
  workos?: {
613
653
  enabled?: boolean | undefined;
@@ -616,6 +656,7 @@ declare const schema: s.ObjectSchema<{
616
656
  url?: string | undefined;
617
657
  redirect_uri?: string | undefined;
618
658
  skip_nonce_check?: boolean | undefined;
659
+ email_optional?: boolean | undefined;
619
660
  } | undefined;
620
661
  zoom?: {
621
662
  enabled?: boolean | undefined;
@@ -624,6 +665,7 @@ declare const schema: s.ObjectSchema<{
624
665
  url?: string | undefined;
625
666
  redirect_uri?: string | undefined;
626
667
  skip_nonce_check?: boolean | undefined;
668
+ email_optional?: boolean | undefined;
627
669
  } | undefined;
628
670
  } | undefined;
629
671
  } | undefined>;
@@ -849,6 +891,26 @@ interface IdentitiesTable {
849
891
  created_at: string;
850
892
  updated_at: string;
851
893
  }
894
+ interface FlowStateTable {
895
+ id: string;
896
+ user_id: string | null;
897
+ auth_code: string | null;
898
+ authentication_method: string;
899
+ code_challenge_method: string | null;
900
+ code_challenge: string | null;
901
+ provider_type: string;
902
+ provider_access_token: string | null;
903
+ provider_refresh_token: string | null;
904
+ auth_code_issued_at: string | null;
905
+ invite_token: string | null;
906
+ referrer: string | null;
907
+ oauth_client_state_id: string | null;
908
+ linking_target_id: string | null;
909
+ email_optional: boolean;
910
+ created_at: string;
911
+ updated_at: string;
912
+ }
913
+ 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
914
  interface UserResponse {
853
915
  id: string;
854
916
  aud: string;
@@ -910,14 +972,28 @@ interface AuthConfig {
910
972
  otp_length?: number;
911
973
  otp_expiry?: number;
912
974
  smtp?: {
913
- sender_name?: string;
975
+ enabled?: boolean;
976
+ host?: string;
977
+ port?: number;
978
+ user?: string;
979
+ pass?: string;
914
980
  admin_email?: string;
981
+ sender_name?: string;
915
982
  };
916
983
  template?: Partial<Record<EmailTemplateType, EmailTemplateConfig>>;
917
984
  };
918
985
  enable_confirmations?: boolean;
919
986
  site_url?: string;
920
987
  additional_redirect_urls?: string[];
988
+ external?: Record<string, {
989
+ enabled?: boolean;
990
+ client_id?: string;
991
+ secret?: string;
992
+ url?: string;
993
+ redirect_uri?: string;
994
+ skip_nonce_check?: boolean;
995
+ email_optional?: boolean;
996
+ }>;
921
997
  }
922
998
  type EmailTemplateType = "invite" | "confirmation" | "recovery" | "magic_link" | "email_change";
923
999
  interface EmailTemplateConfig {
@@ -926,12 +1002,28 @@ interface EmailTemplateConfig {
926
1002
  }
927
1003
 
928
1004
  type Dialect$1 = "postgres" | "sqlite";
1005
+ /** Bound `Connection#runInTransaction` — see db/Connection.ts for why this
1006
+ * indirection exists (DO storage has no BEGIN/COMMIT over kysely). */
1007
+ type TransactionRunner = <T>(fn: (trx: Kysely<any>) => Promise<T>) => Promise<T>;
929
1008
  declare class AuthRepository {
930
1009
  private db;
931
1010
  private dialect;
1011
+ private runInTransaction;
932
1012
  private schema;
933
- constructor(db: Kysely<any>, dialect: Dialect$1);
1013
+ constructor(db: Kysely<any>, dialect: Dialect$1, runInTransaction?: TransactionRunner);
934
1014
  private bool;
1015
+ /**
1016
+ * Runs `fn` inside a database transaction, handing it a repository bound to
1017
+ * the transaction's executor. All reads/writes performed through that
1018
+ * repository (including this one's other methods) participate in the same
1019
+ * transaction, and are rolled back together if `fn` throws.
1020
+ *
1021
+ * Callers that need existing private helpers (which close over `this.repo`)
1022
+ * to run against the transaction should swap `this.repo` for the duration
1023
+ * of the callback — safe because AuthService/AuthRepository instances are
1024
+ * constructed fresh per request (see server/auth.ts createAuthService).
1025
+ */
1026
+ transaction<T>(fn: (repo: AuthRepository) => Promise<T>): Promise<T>;
935
1027
  private table;
936
1028
  private insertInto;
937
1029
  private update;
@@ -939,9 +1031,22 @@ declare class AuthRepository {
939
1031
  findUserByEmail(email: string): Promise<UsersTable | null>;
940
1032
  findUserById(id: string): Promise<UsersTable | null>;
941
1033
  findUserByToken(column: string, token: string): Promise<UsersTable | null>;
1034
+ /**
1035
+ * Atomically consumes a one-time token: the UPDATE only matches a row whose
1036
+ * `column` still holds `token`, so exactly one of two concurrent verifies
1037
+ * for the same OTP can win, and a token rotated/cleared by another request
1038
+ * (resend, a competing verify) no longer matches. Returns false when no row
1039
+ * was updated — callers must treat that as an invalid/consumed token and
1040
+ * mutate nothing further.
1041
+ *
1042
+ * This is the guard that survives on D1, whose `runInTransaction` cannot
1043
+ * group statements (see D1SqliteConnection L131-140): a single conditional
1044
+ * UPDATE with a rowcount check is atomic on every driver.
1045
+ */
1046
+ claimUserToken(userId: string, column: string, token: string): Promise<boolean>;
942
1047
  createUser(user: Partial<UsersTable> & {
943
1048
  id: string;
944
- email: string;
1049
+ email: string | null;
945
1050
  }): Promise<UsersTable>;
946
1051
  updateUser(id: string, updates: Partial<UsersTable>): Promise<UsersTable | null>;
947
1052
  createSession(session: {
@@ -977,6 +1082,52 @@ declare class AuthRepository {
977
1082
  }): Promise<IdentitiesTable>;
978
1083
  findIdentitiesByUserId(userId: string): Promise<IdentitiesTable[]>;
979
1084
  updateIdentity(id: string, updates: Partial<IdentitiesTable>): Promise<void>;
1085
+ deleteIdentitiesExcept(userId: string, keepId: string): Promise<void>;
1086
+ findIdentityByProviderAndId(provider: string, providerId: string): Promise<IdentitiesTable | null>;
1087
+ findIdentitiesByEmails(emails: string[]): Promise<IdentitiesTable[]>;
1088
+ createFlowState(flow: NewFlowState): Promise<FlowStateTable>;
1089
+ findFlowStateById(id: string): Promise<FlowStateTable | null>;
1090
+ findFlowStateByAuthCode(authCode: string): Promise<FlowStateTable | null>;
1091
+ updateFlowState(id: string, updates: Partial<FlowStateTable>): Promise<void>;
1092
+ /**
1093
+ * Atomically claims a PKCE flow_state row for a callback: the UPDATE only
1094
+ * matches (and thus only succeeds for) a row whose user_id is still null,
1095
+ * so exactly one of two concurrent callbacks for the same state can win.
1096
+ * Returns false if the row was already claimed (or no longer exists) —
1097
+ * callers should treat that as a replay (flow_state_already_used).
1098
+ */
1099
+ claimFlowStateForPkce(id: string, updates: {
1100
+ user_id: string;
1101
+ provider_access_token: string;
1102
+ provider_refresh_token: string;
1103
+ auth_code_issued_at: string;
1104
+ }): Promise<boolean>;
1105
+ /**
1106
+ * Atomically deletes a flow_state row, returning whether a row was
1107
+ * actually removed. A single DELETE...WHERE id = ? is inherently atomic
1108
+ * (at most one caller can ever delete a given row), so this doubles as the
1109
+ * "claim" step for implicit-flow callbacks and PKCE auth-code redemption:
1110
+ * only the caller that observes `true` may proceed to issue a session.
1111
+ */
1112
+ /**
1113
+ * Deletes at most {@link FLOW_STATE_CLEANUP_BATCH} flow_state rows created
1114
+ * before `cutoffIso`. Ports the flow_state statement of GoTrue's periodic
1115
+ * cleanup (internal/models/cleanup.go L62):
1116
+ *
1117
+ * delete from "flow_state" where id in (
1118
+ * select id from "flow_state" where created_at < now() - interval '24 hours'
1119
+ * limit 100 for update skip locked);
1120
+ *
1121
+ * The bound is the point of that statement: cleanup must never turn into an
1122
+ * unbounded delete that blocks the request it is piggybacking on (lite has
1123
+ * no background scheduler, so this runs opportunistically on the /authorize
1124
+ * insert path). A backlog is drained across subsequent /authorize calls.
1125
+ * `for update skip locked` has no sqlite equivalent and is omitted; the
1126
+ * id-in-subquery-with-LIMIT shape works on both dialects. Returns the number
1127
+ * of rows removed.
1128
+ */
1129
+ deleteFlowStatesCreatedBefore(cutoffIso: string): Promise<number>;
1130
+ deleteFlowState(id: string): Promise<boolean>;
980
1131
  createAuditLogEntry(entry: {
981
1132
  id: string;
982
1133
  payload?: Record<string, unknown>;
@@ -1088,6 +1239,11 @@ declare class AuthService {
1088
1239
  token_hash?: string;
1089
1240
  type: string;
1090
1241
  }): Promise<SessionResponse>;
1242
+ /**
1243
+ * The mutating half of {@link verifyOtp}, always run inside a transaction
1244
+ * (`this.repo` is bound to it) — see the comment at the call site.
1245
+ */
1246
+ private completeVerifyOtp;
1091
1247
  recover(email: string | undefined): Promise<void>;
1092
1248
  resend(type: string, email: string | undefined): Promise<void>;
1093
1249
  reauthenticate(userId: string): Promise<void>;
@@ -1100,6 +1256,51 @@ declare class AuthService {
1100
1256
  private isTokenExpired;
1101
1257
  private getTokenColumnsForType;
1102
1258
  private createAuditLog;
1259
+ /**
1260
+ * Same entry shape as {@link createAuditLog}, for the call sites whose
1261
+ * traits map is not `{provider: ...}` (GoTrue builds the map per call site;
1262
+ * see models.NewAuditLogEntry's `traits map[string]any` argument).
1263
+ */
1264
+ private createAuditLogWithTraits;
1265
+ getExternalProviderRedirectUrl(query: Record<string, string | undefined>, opts: {
1266
+ refererHeader?: string;
1267
+ defaultRedirectUri: string;
1268
+ }): Promise<string>;
1269
+ loadOAuthFlowState(state: string | undefined): Promise<FlowStateTable>;
1270
+ resolveOAuthRedirectTarget(flowState: FlowStateTable): string;
1271
+ handleExternalProviderCallback(flowState: FlowStateTable, params: Record<string, string | undefined>, opts: {
1272
+ defaultRedirectUri: string;
1273
+ }): Promise<{
1274
+ type: "pkce" | "implicit";
1275
+ redirectUrl: string;
1276
+ }>;
1277
+ /**
1278
+ * Tail of the external-provider callback, shared by the account-linking and
1279
+ * invite branches: claims the flow state and either hands back the PKCE
1280
+ * auth code or issues a session in the URL fragment (external.go
1281
+ * L221-286). Runs inside the callback's transaction — `this.repo` is
1282
+ * already bound to it by the caller.
1283
+ */
1284
+ private issueOAuthCallbackResult;
1285
+ /**
1286
+ * Ports internal/api/external.go's processInvite (L449-514): accepts an
1287
+ * invitation with an external identity. The invite token is the user's
1288
+ * `confirmation_token` (models.FindUserByConfirmationToken), the external
1289
+ * email must match the invited email, and the user is confirmed because
1290
+ * they were able to respond to the invite email.
1291
+ *
1292
+ * Runs inside the callback's transaction (`this.repo` is bound to it).
1293
+ */
1294
+ private processInvite;
1295
+ exchangePkceCode(authCode: string | undefined, codeVerifier: string | undefined): Promise<SessionResponse & {
1296
+ provider_token?: string;
1297
+ provider_refresh_token?: string;
1298
+ }>;
1299
+ private resolveOAuthReferrer;
1300
+ private updateUserMetaDataAndProviders;
1301
+ private buildAppMetaDataProviders;
1302
+ private removeUnconfirmedIdentities;
1303
+ private determineAccountLinking;
1103
1304
  }
1104
1305
 
1105
1306
  type CrossReadableStream = ReadableStream | ReadableStream$1;
@@ -1361,31 +1562,25 @@ type HonoContext = {
1361
1562
  userId?: string;
1362
1563
  sessionId?: string;
1363
1564
  jwt?: Record<string, unknown>;
1565
+ apiKeyType?: "publishable" | "secret";
1566
+ ignoreAuthorization?: boolean;
1567
+ /**
1568
+ * Set by `adminAuth()` when local admin mode elevated this request to
1569
+ * `service_role`. Observability/tests only — the elevation itself is
1570
+ * carried by `apiKeyType`/`ignoreAuthorization`/`jwt`.
1571
+ */
1572
+ admin?: boolean;
1364
1573
  };
1365
1574
  };
1366
1575
 
1367
- type Where = Record<string, unknown>;
1576
+ type ApiKeyType = "publishable" | "secret";
1368
1577
 
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
- }
1578
+ /** Claims are applied verbatim as `request.jwt.claims` MUST include `role`. */
1579
+ type ResolvedKey = {
1580
+ type: ApiKeyType;
1581
+ claims: Record<string, unknown>;
1582
+ };
1583
+ type ApiKeyResolver = (key: string, c: Context<HonoContext>) => Promise<ResolvedKey | null>;
1389
1584
 
1390
1585
  type ServerOptions = {
1391
1586
  middlewares?: MiddlewareHandler<HonoContext>[];
@@ -1395,6 +1590,33 @@ type ServerOptions = {
1395
1590
  * Test-only PostgREST mode: execute each request in a transaction and roll it back.
1396
1591
  */
1397
1592
  forceRollback?: boolean;
1593
+ /**
1594
+ * `false` disables apikey enforcement outright. Otherwise a custom
1595
+ * `resolver` can be supplied (the lite-platform seam); when omitted, keys
1596
+ * configured under `config.auth.publishable_key`/`secret_key` are used.
1597
+ */
1598
+ apiKeys?: false | {
1599
+ resolver?: ApiKeyResolver;
1600
+ };
1601
+ /**
1602
+ * Local admin mode (default `false`): run *keyless* `/rest/v1` and
1603
+ * `/storage/v1` requests as `service_role`, so a browser studio can do
1604
+ * privileged work without a secret key shipping to the browser. Only
1605
+ * same-origin requests addressed to loopback are elevated.
1606
+ *
1607
+ * Two caveats, both local-dev only:
1608
+ * 1. RLS is not enforced for keyless traffic while this is on. To exercise
1609
+ * policies, send an `apikey`: the publishable key for `anon`, or the
1610
+ * publishable key PLUS `Authorization: Bearer <user JWT>` for
1611
+ * `authenticated`. Those requests are never elevated. A bearer token on
1612
+ * its own is rejected before RLS is reached (401), since opaque keys are
1613
+ * only sourced from `apikey`.
1614
+ * 2. Localhost trust is not per-request trust. Any page open in the
1615
+ * developer's browser can reach the server; the same-origin and
1616
+ * loopback guards are what keep that from being a data-exfiltration
1617
+ * hole. Never enable outside local development.
1618
+ */
1619
+ admin?: boolean;
1398
1620
  };
1399
1621
  declare function createServer(app: App, options?: ServerOptions): hono_hono_base.HonoBase<HonoContext & {
1400
1622
  Variables: {
@@ -1707,32 +1929,9 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
1707
1929
  input: {};
1708
1930
  output: {
1709
1931
  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
1932
  email: boolean;
1734
1933
  phone: boolean;
1735
- zoom: boolean;
1934
+ anonymous_users: boolean;
1736
1935
  };
1737
1936
  disable_signup: boolean;
1738
1937
  mailer_autoconfirm: boolean;
@@ -1774,6 +1973,33 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
1774
1973
  status: 200;
1775
1974
  };
1776
1975
  };
1976
+ } & {
1977
+ "/authorize": {
1978
+ $get: {
1979
+ input: {};
1980
+ output: string;
1981
+ outputFormat: "body";
1982
+ status: 302;
1983
+ };
1984
+ };
1985
+ } & {
1986
+ "/callback": {
1987
+ $get: {
1988
+ input: {};
1989
+ output: {};
1990
+ outputFormat: string;
1991
+ status: hono_utils_http_status.StatusCode;
1992
+ };
1993
+ };
1994
+ } & {
1995
+ "/callback": {
1996
+ $post: {
1997
+ input: {};
1998
+ output: {};
1999
+ outputFormat: string;
2000
+ status: hono_utils_http_status.StatusCode;
2001
+ };
2002
+ };
1777
2003
  } & {
1778
2004
  "/nonexistent": {
1779
2005
  $all: {
@@ -2126,14 +2352,14 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2126
2352
  json: {
2127
2353
  [x: string]: unknown;
2128
2354
  search?: string | undefined;
2129
- prefix?: string | undefined;
2130
- limit?: number | undefined;
2131
- offset?: number | undefined;
2132
2355
  sortBy?: {
2133
2356
  [x: string]: unknown;
2134
2357
  column: string;
2135
2358
  order: string;
2136
2359
  } | undefined;
2360
+ limit?: number | undefined;
2361
+ offset?: number | undefined;
2362
+ prefix?: string | undefined;
2137
2363
  };
2138
2364
  } & {
2139
2365
  param: {
@@ -2415,431 +2641,7 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2415
2641
  "/config": {
2416
2642
  $get: {
2417
2643
  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
- };
2644
+ output: {};
2843
2645
  outputFormat: "json";
2844
2646
  status: hono_utils_http_status.ContentfulStatusCode;
2845
2647
  };
@@ -2848,7 +2650,11 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2848
2650
  "/info": {
2849
2651
  $get: {
2850
2652
  input: {};
2851
- output: {};
2653
+ output: {
2654
+ connection: any;
2655
+ config: any;
2656
+ admin: boolean;
2657
+ };
2852
2658
  outputFormat: "json";
2853
2659
  status: hono_utils_http_status.ContentfulStatusCode;
2854
2660
  };
@@ -2987,6 +2793,29 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
2987
2793
  };
2988
2794
  }, "/_system">, "/", "*">;
2989
2795
 
2796
+ type Where = Record<string, unknown>;
2797
+
2798
+ type PolicyCommand = "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "ALL";
2799
+ type PolicyRole = "anon" | "authenticated" | string;
2800
+ interface PolicyData {
2801
+ name: string;
2802
+ table: string;
2803
+ schema?: string;
2804
+ command: PolicyCommand;
2805
+ permissive: boolean;
2806
+ roles: PolicyRole[];
2807
+ using?: Where;
2808
+ withCheck?: Where;
2809
+ }
2810
+ declare class Policy {
2811
+ readonly data: PolicyData;
2812
+ constructor(data: PolicyData);
2813
+ appliesTo(cmd: "SELECT" | "INSERT" | "UPDATE" | "DELETE"): boolean;
2814
+ appliesToRole(role: string): boolean;
2815
+ toJSON(): PolicyData;
2816
+ static fromJSON(data: PolicyData): Policy;
2817
+ }
2818
+
2990
2819
  interface IAppConfig extends DefaultSchema {
2991
2820
  connection: Connection | Promise<Connection>;
2992
2821
  rls?: {
@@ -3027,6 +2856,11 @@ declare class App<Config extends IAppConfig = DefaultAppConfig, Conn = Config ex
3027
2856
  private readonly _rls;
3028
2857
  readonly config: DefaultSchema & Omit<Config, "connection">;
3029
2858
  readonly server: ReturnType<typeof createServer>;
2859
+ /**
2860
+ * Resolved local admin mode, after CLI-flag / config-file precedence. Read
2861
+ * this (never the raw CLI flag) when reporting what the server is doing.
2862
+ */
2863
+ readonly adminMode: boolean;
3030
2864
  readonly drivers: AppDrivers;
3031
2865
  _mailer?: Mailer;
3032
2866
  _storageAdapter?: StorageAdapter;
@@ -3052,7 +2886,9 @@ declare class App<Config extends IAppConfig = DefaultAppConfig, Conn = Config ex
3052
2886
  force?: boolean;
3053
2887
  }): Promise<void>;
3054
2888
  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 {
2889
+ getClient<SchemaName extends string = "public">(options?: SupabaseClientOptions<SchemaName> & {
2890
+ apikey?: string;
2891
+ }): _supabase_supabase_js.SupabaseClient<any, "public", SchemaName, Omit<any, "__InternalSupabase">[SchemaName] extends {
3056
2892
  Tables: Record<string, {
3057
2893
  Row: Record<string, unknown>;
3058
2894
  Insert: Record<string, unknown>;
@@ -3116,6 +2952,17 @@ type SupaliteOptions = {
3116
2952
  forceSchema?: boolean;
3117
2953
  initOnBoot?: boolean;
3118
2954
  prefixes?: string[];
2955
+ /**
2956
+ * Local admin mode (default `true`): keyless, same-origin, loopback
2957
+ * requests from the dev server run as `service_role`. In practice that
2958
+ * means `/rest/v1` here — admin mode also covers `/storage/v1`, but this
2959
+ * plugin does not mount that prefix unless you add it to `prefixes`.
2960
+ *
2961
+ * See `ServerOptions.admin` for the caveats. Never applied in
2962
+ * `vite preview`, which serves a production build; an explicit value here
2963
+ * also outranks `options.server.admin` in `config.toml`.
2964
+ */
2965
+ admin?: boolean;
3119
2966
  };
3120
2967
  declare function supalite(options?: SupaliteOptions): Plugin;
3121
2968