@supabase/lite 0.6.2-next.4 → 0.7.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.
package/LIMITATIONS.md CHANGED
@@ -23,6 +23,10 @@ Anchors below point to the corresponding STATUS.md section. If a limitation here
23
23
  - Range operators (`rangeGt`, …) and quantified comparisons (`eq(any)`, …) → not implemented on SQLite. See [Range Operators](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#range-operators) and [Quantified Comparison Operators](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#quantified-comparison-operators).
24
24
  - `schema()` → SQLite is single-schema. See [Control & Specialized](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#control--specialized).
25
25
 
26
+ ## Auth (shipped with caveats)
27
+
28
+ - `double_confirm_changes = true` (secure email change) is spec-compatible but **not** GoTrue's full two-mailbox flow: it finalizes from the current-email confirmation only, so it does not require the new mailbox to also confirm. It still prevents a session thief from changing the email using only a mailbox they control. See [Auth email delivery & templates](https://github.com/supabase-community/lite/blob/HEAD/docs/src/content/docs/auth/email.mdx).
29
+
26
30
  ## Auth (planned, not yet shipped)
27
31
 
28
32
  - OAuth, anonymous sign-in, identity linking, admin API, MFA → planned. See [Auth API: Planned](https://github.com/supabase-community/lite/blob/HEAD/STATUS.md#-planned).
package/STATUS.md CHANGED
@@ -495,7 +495,7 @@ Backend implementation in `app/src/auth/`. GoTrue-compatible HTTP endpoints at `
495
495
  | `signUp()` | `POST /signup` | Email/password, optional metadata, email confirmation |
496
496
  | `signInWithPassword()` | `POST /token?grant_type=password` | JWT + refresh token |
497
497
  | `signInWithOtp()` | `POST /otp` | Magic link / OTP via email |
498
- | `verifyOtp()` | `POST /verify` | Supports: signup, magiclink, recovery, email_change, reauthentication |
498
+ | `verifyOtp()` | `POST /verify`, `GET /verify` | signup, magiclink, recovery, email_change, reauthentication. Numeric code + `token_hash` both verify against the DB (durable on Workers); `otp_expiry`/`otp_length` honored. `GET /verify` 303-redirects to `redirect_to` (allow-list checked) |
499
499
  | `refreshSession()` | `POST /token?grant_type=refresh_token` | Token rotation, immediate reuse compatibility, session expiry checks |
500
500
  | `signOut()` | `POST /logout` | Scopes: local, global, others |
501
501
  | `getUser()` | `GET /user` | JWT-authenticated |
@@ -510,8 +510,10 @@ Supporting infrastructure:
510
510
  - Password hashing (bcrypt-compatible)
511
511
  - Refresh token rotation with revocation, reuse, and parent-chain tracking
512
512
  - Session management (create, validate, refresh, expire, delete)
513
- - Configurable email signup, confirmations, and secure/insecure email change
514
- - Mailer integration (confirmation, recovery, magic link, email change)
513
+ - Configurable email signup, confirmations, and secure/insecure email change. Note: `double_confirm_changes=true` is spec-compatible (finalizes from the current-email confirmation, delivered to the current address) but does not implement GoTrue's full two-mailbox confirmation. See [LIMITATIONS.md](https://github.com/supabase-community/lite/blob/HEAD/LIMITATIONS.md#auth-shipped-with-caveats).
514
+ - Mailer integration (confirmation, recovery, magic link, email change, reauthentication)
515
+ - Default Supabase-styled email templates with `site_url`-based verify links; per-type overrides via `auth.email.template.<type>.{subject,content_path}` (GoTrue `{{ .ConfirmationURL }}` etc. variables)
516
+ - Email drivers `Resend` / `AWS SES` / `Sendmail` (injected via `options.drivers.email`; default `NoopEmailDriver` logs only)
515
517
 
516
518
  ### 🔄 Planned
517
519
 
package/dist/cli/index.js CHANGED
@@ -277,8 +277,9 @@ CREATE INDEX IF NOT EXISTS users_is_anonymous_idx
277
277
  ON auth.users (is_anonymous);
278
278
 
279
279
  -- Partial unique indexes on token columns.
280
- -- Only hash tokens (len > 6) need uniqueness; 6-digit OTPs can collide across users.
281
- -- Uses length check instead of GoTrue's Postgres regex \u2014 portable across Postgres and SQLite.
280
+ -- Columns store the OTP hash (hex SHA-256 of email+otp, len > 6), not the raw
281
+ -- 6-digit code, so the length guard always includes real tokens while staying
282
+ -- portable across Postgres and SQLite (vs GoTrue's Postgres-only regex).
282
283
  CREATE UNIQUE INDEX IF NOT EXISTS users_confirmation_token_idx
283
284
  ON auth.users (confirmation_token)
284
285
  WHERE length(confirmation_token) > 6;
package/dist/index.d.ts CHANGED
@@ -302,9 +302,22 @@ interface AuthConfig {
302
302
  enable_signup?: boolean;
303
303
  enable_confirmations?: boolean;
304
304
  double_confirm_changes?: boolean;
305
+ otp_length?: number;
306
+ otp_expiry?: number;
307
+ smtp?: {
308
+ sender_name?: string;
309
+ admin_email?: string;
310
+ };
311
+ template?: Partial<Record<EmailTemplateType, EmailTemplateConfig>>;
305
312
  };
306
313
  enable_confirmations?: boolean;
307
314
  site_url?: string;
315
+ additional_redirect_urls?: string[];
316
+ }
317
+ type EmailTemplateType = "invite" | "confirmation" | "recovery" | "magic_link" | "email_change";
318
+ interface EmailTemplateConfig {
319
+ subject?: string;
320
+ content_path?: string;
308
321
  }
309
322
 
310
323
  type Dialect$1 = "postgres" | "sqlite";
@@ -541,6 +554,11 @@ interface MailMeta {
541
554
  tokenNew?: string;
542
555
  tokenHashNew?: string;
543
556
  redirectTo?: string;
557
+ /** Current (old) email — used as the `Email` template var for email change. */
558
+ currentEmail?: string;
559
+ /** Pending (new) email — used as the `NewEmail` template var for email change. */
560
+ newEmail?: string;
561
+ data?: string;
544
562
  }
545
563
 
546
564
  declare class AuthService {
@@ -553,6 +571,18 @@ declare class AuthService {
553
571
  private sessionTimeboxSeconds?;
554
572
  private sessionInactivitySeconds?;
555
573
  constructor(repo: AuthRepository, config: AuthConfig, mailer: Mailer);
574
+ private get otpLength();
575
+ private get otpExpirySeconds();
576
+ /**
577
+ * Returns a safe post-verification redirect target: `redirectTo` if allowed,
578
+ * otherwise `site_url`. Mirrors GoTrue's `IsRedirectURLValid`:
579
+ * - same scheme + host + port as `site_url` (any path; port ignored for
580
+ * loopback hosts), or
581
+ * - a glob match of `additional_redirect_urls` against the full URL
582
+ * (patterns use `.`/`/` as separators, so `*` does not cross them but
583
+ * `**` does).
584
+ */
585
+ resolveEmailRedirect(redirectTo?: string | null): string;
556
586
  signUp(email: string | undefined, password: string | undefined, data?: Record<string, unknown>): Promise<{
557
587
  user: UserResponse;
558
588
  session?: SessionResponse;
@@ -587,7 +617,8 @@ declare class AuthService {
587
617
  private mapUserToResponse;
588
618
  private mapIdentityToResponse;
589
619
  private findUserByTokenAndType;
590
- private otpMatchesStoredTokenHash;
620
+ private static readonly SENT_AT_COLUMN;
621
+ private isTokenExpired;
591
622
  private getTokenColumnsForType;
592
623
  private createAuditLog;
593
624
  }
@@ -1120,6 +1151,15 @@ declare function createServer(app: App, options?: ServerOptions): hono_hono_base
1120
1151
  status: 200;
1121
1152
  };
1122
1153
  };
1154
+ } & {
1155
+ "/verify": {
1156
+ $get: {
1157
+ input: {};
1158
+ output: undefined;
1159
+ outputFormat: "redirect";
1160
+ status: 303;
1161
+ };
1162
+ };
1123
1163
  } & {
1124
1164
  "/recover": {
1125
1165
  $post: {