@selvajs/supabase-provider 0.17.0-beta.4 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +26 -39
  2. package/dist/auth/SupabaseAuthProvider.d.ts +37 -82
  3. package/dist/auth/SupabaseAuthProvider.d.ts.map +1 -1
  4. package/dist/auth/SupabaseAuthProvider.js +62 -114
  5. package/dist/auth/SupabaseAuthProvider.js.map +1 -1
  6. package/dist/cli/sync-migrations.js +4 -6
  7. package/dist/cli/sync-migrations.js.map +1 -1
  8. package/dist/data/SupabaseAuditQuery.d.ts +3 -3
  9. package/dist/data/SupabaseAuditQuery.d.ts.map +1 -1
  10. package/dist/data/SupabaseAuditQuery.js +8 -14
  11. package/dist/data/SupabaseAuditQuery.js.map +1 -1
  12. package/dist/data/SupabaseComputeServerStore.d.ts +7 -13
  13. package/dist/data/SupabaseComputeServerStore.d.ts.map +1 -1
  14. package/dist/data/SupabaseComputeServerStore.js +15 -39
  15. package/dist/data/SupabaseComputeServerStore.js.map +1 -1
  16. package/dist/data/SupabaseDataProvider.d.ts +30 -46
  17. package/dist/data/SupabaseDataProvider.d.ts.map +1 -1
  18. package/dist/data/SupabaseDataProvider.js +39 -66
  19. package/dist/data/SupabaseDataProvider.js.map +1 -1
  20. package/dist/data/SupabaseDefinitionStore.d.ts +3 -10
  21. package/dist/data/SupabaseDefinitionStore.d.ts.map +1 -1
  22. package/dist/data/SupabaseDefinitionStore.js +29 -39
  23. package/dist/data/SupabaseDefinitionStore.js.map +1 -1
  24. package/dist/data/SupabaseInviteStore.d.ts +6 -6
  25. package/dist/data/SupabaseInviteStore.d.ts.map +1 -1
  26. package/dist/data/SupabaseInviteStore.js +16 -15
  27. package/dist/data/SupabaseInviteStore.js.map +1 -1
  28. package/dist/data/SupabaseOrgStore.d.ts +0 -4
  29. package/dist/data/SupabaseOrgStore.d.ts.map +1 -1
  30. package/dist/data/SupabaseOrgStore.js +19 -29
  31. package/dist/data/SupabaseOrgStore.js.map +1 -1
  32. package/dist/data/SupabaseProjectStore.d.ts +4 -8
  33. package/dist/data/SupabaseProjectStore.d.ts.map +1 -1
  34. package/dist/data/SupabaseProjectStore.js +15 -26
  35. package/dist/data/SupabaseProjectStore.js.map +1 -1
  36. package/dist/data/SupabaseShareLinkStore.d.ts +4 -9
  37. package/dist/data/SupabaseShareLinkStore.d.ts.map +1 -1
  38. package/dist/data/SupabaseShareLinkStore.js +9 -18
  39. package/dist/data/SupabaseShareLinkStore.js.map +1 -1
  40. package/dist/data/SupabaseSolveMetricSink.d.ts +13 -14
  41. package/dist/data/SupabaseSolveMetricSink.d.ts.map +1 -1
  42. package/dist/data/SupabaseSolveMetricSink.js +13 -14
  43. package/dist/data/SupabaseSolveMetricSink.js.map +1 -1
  44. package/dist/data/client.d.ts +25 -54
  45. package/dist/data/client.d.ts.map +1 -1
  46. package/dist/data/client.js +6 -14
  47. package/dist/data/client.js.map +1 -1
  48. package/dist/data/errors.d.ts.map +1 -1
  49. package/dist/data/errors.js.map +1 -1
  50. package/dist/data/migrationHead.d.ts +4 -11
  51. package/dist/data/migrationHead.d.ts.map +1 -1
  52. package/dist/data/migrationHead.js +4 -11
  53. package/dist/data/migrationHead.js.map +1 -1
  54. package/dist/data/pagination.d.ts +5 -16
  55. package/dist/data/pagination.d.ts.map +1 -1
  56. package/dist/data/pagination.js +5 -16
  57. package/dist/data/pagination.js.map +1 -1
  58. package/dist/data/query.d.ts +2 -14
  59. package/dist/data/query.d.ts.map +1 -1
  60. package/dist/data/query.js +1 -9
  61. package/dist/data/query.js.map +1 -1
  62. package/dist/data/rowStamp.d.ts +8 -24
  63. package/dist/data/rowStamp.d.ts.map +1 -1
  64. package/dist/data/rowStamp.js +8 -24
  65. package/dist/data/rowStamp.js.map +1 -1
  66. package/dist/permissions/SupabasePlatformPermissionStore.d.ts +8 -10
  67. package/dist/permissions/SupabasePlatformPermissionStore.d.ts.map +1 -1
  68. package/dist/permissions/SupabasePlatformPermissionStore.js +9 -15
  69. package/dist/permissions/SupabasePlatformPermissionStore.js.map +1 -1
  70. package/dist/storage/SupabaseStorageProvider.d.ts +14 -35
  71. package/dist/storage/SupabaseStorageProvider.d.ts.map +1 -1
  72. package/dist/storage/SupabaseStorageProvider.js +10 -25
  73. package/dist/storage/SupabaseStorageProvider.js.map +1 -1
  74. package/dist/userProfile/SupabaseUserProfileProvider.d.ts.map +1 -1
  75. package/dist/userProfile/SupabaseUserProfileProvider.js +8 -15
  76. package/dist/userProfile/SupabaseUserProfileProvider.js.map +1 -1
  77. package/package.json +6 -6
  78. package/supabase/migrations/20260817120000_invite_platform_permissions.sql +16 -0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Supabase (Auth + Postgres + Storage) implementation of the `@selvajs/platform` interfaces.
4
4
 
5
- Runs the Selva backend against **either** a managed Supabase project (production) or a local Supabase CLI stack in Docker (development). Same code — different `SUPABASE_URL` and keys.
5
+ Runs against **either** a managed Supabase project (production) or a local Supabase CLI stack in Docker (development) — same code, different `SUPABASE_URL` and keys.
6
6
 
7
7
  ---
8
8
 
@@ -10,7 +10,7 @@ Runs the Selva backend against **either** a managed Supabase project (production
10
10
 
11
11
  - [Quick start](#quick-start)
12
12
  - [Environment variables](#environment-variables)
13
- - [Wiring into `selva.config.ts`](#wiring-into-selvaconfigts)
13
+ - [Switching to the Supabase provider](#switching-to-the-supabase-provider)
14
14
  - [Applying the schema](#applying-the-schema)
15
15
  - [Development — local Supabase stack](#development--local-supabase-stack)
16
16
  - [Production — hosted Supabase project](#production--hosted-supabase-project)
@@ -25,16 +25,16 @@ Runs the Selva backend against **either** a managed Supabase project (production
25
25
  2. Provision Supabase — either local (`npx supabase start`) or hosted (supabase.com).
26
26
  3. Apply the migrations from `packages/providers/supabase/supabase/migrations/` (the local CLI does this automatically on `db reset`).
27
27
  4. Copy the three env vars into your selva app `.env` (see below).
28
- 5. Edit [`selva.config.ts`](../../../selva.config.ts) at the repo root to swap the local provider for the Supabase provider.
28
+ 5. Set `SELVA_AUTH_PROVIDER=supabase`, `SELVA_DATA_PROVIDER=supabase`, `SELVA_STORAGE_PROVIDER=supabase` in the same `.env`.
29
29
  6. `pnpm dev` — the selva app now reads and writes from Supabase.
30
30
 
31
31
  ---
32
32
 
33
33
  ## Environment variables
34
34
 
35
- All env vars are documented in [`packages/selva/.env.example`](../../selva/.env.example) — copy that file to `.env` and edit it. The Supabase provider needs `SUPABASE_URL`, `SUPABASE_ANON_KEY`, and `SUPABASE_SERVICE_ROLE_KEY`; the optional bucket / private-URL / signup overrides are also listed there.
35
+ All env vars are documented in [`packages/selva/.env.example`](../../selva/.env.example) — copy that file to `.env` and edit it. This provider needs `SUPABASE_URL`, `SUPABASE_ANON_KEY`, and `SUPABASE_SERVICE_ROLE_KEY`; the optional bucket / private-URL / signup overrides are also listed there.
36
36
 
37
- Both `SELVA_*` keys are still required under this provider, for narrower jobs than under the local provider:
37
+ Both `SELVA_*` keys are still required, but for narrower jobs than under the local provider:
38
38
 
39
39
  - `SELVA_HMAC_KEY` — **not** used for sessions here (those are Supabase JWTs), but still hashes share-link and invite tokens before they're stored.
40
40
  - `SELVA_AT_REST_KEY` — encrypts `compute_servers.api_key` before it reaches the database. `SupabaseDataProvider` refuses to construct without it.
@@ -60,28 +60,19 @@ Rhino.Compute URL + API key are configured in `/admin/compute` and persisted in
60
60
 
61
61
  ---
62
62
 
63
- ## Wiring into `selva.config.ts`
64
-
65
- The repo's [`selva.config.ts`](../../selva.config.ts) is the single DI point — it picks which provider backs every interface. Switch between providers by changing imports:
66
-
67
- ```ts
68
- import { defineConfig } from '@selvajs/platform';
69
- import * as supa from '@selvajs/supabase-provider';
70
-
71
- export default defineConfig((env) => ({
72
- tenancy: 'single' as const,
73
- flags: {
74
- ALLOW_CROSS_ORG_PUBLIC: false,
75
- ALLOW_ORG_COMPUTE_OVERRIDE: false,
76
- ALLOW_ORG_CREATION: false
77
- },
78
- auth: supa.SupabaseAuthProvider.fromEnv(env),
79
- data: supa.SupabaseDataProvider.fromEnv(env),
80
- storage: supa.SupabaseStorageProvider.fromEnv(env)
81
- }));
63
+ ## Switching to the Supabase provider
64
+
65
+ The selva app picks a provider per interface from env vars, via `createSelvaProviders` (`packages/server/src/providers/create-selva-providers.ts`) and the registry in `packages/selva/src/lib/server/providers.server.ts`:
66
+
67
+ ```
68
+ SELVA_AUTH_PROVIDER=supabase # local | supabase | header (default: local)
69
+ SELVA_DATA_PROVIDER=supabase # local | supabase (default: local)
70
+ SELVA_STORAGE_PROVIDER=supabase # local | supabase (default: local)
82
71
  ```
83
72
 
84
- To switch back to the local provider, swap the import and the three provider lines. See the commented example in [`selva.config.ts`](../../selva.config.ts).
73
+ To switch back to the local provider, remove the three vars (or set them to `local`) and restart.
74
+
75
+ For a provider not bundled in the app, point `SELVA_CONFIG_PATH` at an external `selva.config.js`, loaded dynamically at boot in place of the env-driven wiring. It must be an actual `.js` file — there's no TS compiler at runtime.
85
76
 
86
77
  ---
87
78
 
@@ -91,12 +82,12 @@ To switch back to the local provider, swap the import and the three provider lin
91
82
 
92
83
  The `supabase/migrations/` directory holds timestamp-prefixed files, applied in filename order:
93
84
 
94
- | File | What it installs |
95
- | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
96
- | `20260425155514_selva_initial.sql` | Everything: `user_profiles` (+ auto-seed trigger), `orgs` / `org_members` / `projects` / `project_members` (+ RLS helpers), `definitions` / `definition_versions` (+ deletion-protection FKs and the atomic `increment_run_count` RPC), `invites` (+ `get_invite_by_token` RPC), `compute_servers` (+ per-org/instance defaults, spec §3 BYO compute), `share_links` (+ `try_increment_share_link_solve_count` RPC, spec §7), and the `selva-public` / `selva-private` storage policies. |
97
- | `20260529202220_selva_definition_version_schema.sql` | Adds `definition_versions.schema` + `schema_extracted_at` (cached compute-extracted UI schema) and the previously-missing `change_note` column. All `add column if not exists`, so it's safe to re-run. |
85
+ | File | What it installs |
86
+ | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
87
+ | `20260425155514_selva_initial.sql` | The `selva` schema itself, plus `user_profiles` (+ auto-seed trigger), `orgs` / `org_members` / `projects` / `project_members` (+ RLS helpers), `definitions` / `definition_versions` (+ deletion-protection FKs and the atomic `increment_run_count` RPC), `invites` (+ `get_invite_by_token` RPC), `compute_servers` (+ per-org/instance defaults), `share_links` (+ `try_increment_share_link_solve_count` RPC), and the `selva-public` / `selva-private` storage policies. |
88
+ | `20260529202220_selva_definition_version_schema.sql` | Adds `definition_versions.schema` + `schema_extracted_at` (cached compute-extracted UI schema) and the `change_note` column. All `add column if not exists`, safe to re-run. |
98
89
 
99
- These two are only the foundation — the directory ships further timestamp-prefixed migrations on top (solve metrics, org assets, definition status/audit, erasure functions, …). The table above is not the full list; `supabase/migrations/` in filename order is authoritative.
90
+ These two are only the foundation — `supabase/migrations/` ships further timestamp-prefixed files on top (solve metrics, org assets, definition status/audit, erasure functions, …). Filename order in that directory is authoritative, not this table.
100
91
 
101
92
  Future schema changes go in new timestamp-prefixed files: `<UTCtimestamp>_selva_<name>.sql` (e.g. `date -u +%Y%m%d%H%M%S` for the prefix). The `_selva_` infix and timestamp prefix let a consuming app's own migrations interleave by time without ever colliding with Selva's — see [Consuming migrations in an external app](#consuming-migrations-in-an-external-app).
102
93
 
@@ -119,7 +110,7 @@ npx supabase db diff
119
110
  npx supabase db push
120
111
  ```
121
112
 
122
- Alternatively you can copy each `.sql` file into Supabase Dashboard → **SQL Editor** and run them in order. The CLI path is strongly preferred: it tracks which migrations already ran, so re-running it is safe, and the files stay under version control.
113
+ You can also copy each `.sql` file into Supabase Dashboard → **SQL Editor** and run them in order, but prefer the CLI: it tracks which migrations already ran, so re-running it is safe.
123
114
 
124
115
  ### Exposing the `selva` schema to PostgREST
125
116
 
@@ -138,9 +129,9 @@ No backfill step is required for the schema-caching migration: existing definiti
138
129
 
139
130
  #### Migrated from the old `000N_` filenames?
140
131
 
141
- Earlier releases shipped `0001_initial.sql` / `0002_definition_version_schema.sql`. These were renamed to timestamp-prefixed names (`20260425155514_selva_initial.sql`, `20260529202220_selva_definition_version_schema.sql`) so they slot into a consuming app's migration timeline without collisions. The **file contents are unchanged** — only the names.
132
+ Earlier releases shipped `0001_initial.sql` / `0002_definition_version_schema.sql`, since renamed to `20260425155514_selva_initial.sql` / `20260529202220_selva_definition_version_schema.sql` (contents unchanged, only the names, so the files slot into a consuming app's migration timeline without collisions).
142
133
 
143
- To a database that already applied the `000N_` versions, the renamed files look like brand-new migrations. Both are idempotent (`create or replace`, `add column if not exists`), so a stray re-run is a harmless no-op, but you'd end up with duplicate history rows. To reconcile cleanly:
134
+ To a database that already applied the `000N_` versions, the renamed files look like brand-new migrations. Both are idempotent (`create or replace`, `add column if not exists`), so a stray re-run is a harmless no-op, but you'd end up with duplicate history rows. To reconcile:
144
135
 
145
136
  - **Local dev stack:** just `npx supabase db reset` — applies the renamed files from scratch.
146
137
  - **Hosted project with the old versions applied:** tell the CLI the new versions are already present so it doesn't re-run them:
@@ -198,7 +189,7 @@ SUPABASE_SERVICE_ROLE_KEY=sb_secret_...
198
189
 
199
190
  Rhino.Compute server URL + API key are registered in `/admin/compute` after first boot.
200
191
 
201
- Switch `selva.config.ts` to Supabase (snippet above), then:
192
+ Set the three `SELVA_*_PROVIDER=supabase` env vars (above), then:
202
193
 
203
194
  ```bash
204
195
  pnpm dev
@@ -235,7 +226,7 @@ Studio is a full admin UI at `http://127.0.0.1:54323`. Use it to inspect tables,
235
226
  SUPABASE_SERVICE_ROLE_KEY=sb_secret_...
236
227
  ```
237
228
  After deploying, register your Rhino.Compute server URL (+ optional API key) via `/admin/compute`.
238
- 6. Deploy the selva app with `selva.config.ts` wired to `@selvajs/supabase-provider`.
229
+ 6. Deploy the selva app with the three `SELVA_*_PROVIDER=supabase` env vars set.
239
230
  7. Bootstrap the first user:
240
231
  - Open `/setup` once — creates the first admin with `instance_admin`.
241
232
  - Or manually: Dashboard → **Authentication** → **Add user**, then in the SQL Editor: `UPDATE selva.user_profiles SET platform_permissions = ARRAY['instance_admin']::text[] WHERE user_id = '<uuid>';`
@@ -312,10 +303,6 @@ Helper SQL functions (`selva.is_instance_admin`, `selva.is_org_member`, `selva.v
312
303
 
313
304
  - **`incrementRunCount`** uses a SQL function (`UPDATE … SET run_count = run_count + 1`) — atomic. The local provider does read-modify-write and can lose bumps under concurrent solves.
314
305
 
315
- ### Findings
316
-
317
- Every abstraction-pressure point hit during implementation is logged in [FINDINGS.md](./FINDINGS.md). Short version: six items, none requiring platform contract changes beyond the Phase 0 set.
318
-
319
306
  ---
320
307
 
321
308
  ## Status
@@ -1,65 +1,39 @@
1
1
  import { type ILogger } from '@selvajs/platform';
2
2
  import type { IAuthProvider, IEmailLinkAuth, IOAuthAuth, IPasswordAuth, ISessionRefresh, AuthUser, UserManagementResult, ListOptions, Page } from '@selvajs/platform';
3
3
  /**
4
- * Auth backed by Supabase Auth (GoTrue).
5
- *
6
- * Identity + session lifecycle are fully delegated:
7
- * - `verifyLogin` wraps `auth.signInWithPassword` — returns the access_token
8
- * straight from Supabase as the session token.
9
- * - `verifyToken` calls `auth.getUser(token)` against an anon client scoped
10
- * to that bearer; GoTrue validates the JWT for us.
11
- * - User management uses `auth.admin.*` with the service-role client.
12
- *
13
- * Identity-only — platform permissions live on `IPlatformPermissionStore`
14
- * (`SupabasePlatformPermissionStore` reads `user_profiles.platform_permissions`)
15
- * and profile state on `IUserProfileStore`.
4
+ * Auth backed by Supabase Auth (GoTrue). Identity-only — platform permissions
5
+ * live on `IPlatformPermissionStore`, profile state on `IUserProfileStore`.
16
6
  */
17
7
  export interface SupabaseAuthProviderConfig {
18
8
  supabaseUrl: string;
19
9
  anonKey: string;
20
10
  serviceRoleKey: string;
21
- /**
22
- * Whether self-service signup is allowed via `passwordAuth.registerUser`.
23
- * Default false — production deployments start with invite-only.
24
- */
11
+ /** Allow self-service signup via `passwordAuth.registerUser`. Default false. */
25
12
  enableSelfSignup?: boolean;
26
13
  /**
27
- * OAuth providers enabled in the Supabase dashboard (lowercased:
28
- * "google", "github", …). Surfaced via `oauth.listProviders()` so the
29
- * driving layer doesn't read provider-specific env vars itself. Defaults
30
- * to an empty list.
14
+ * OAuth providers enabled in the Supabase dashboard (lowercased: "google",
15
+ * "github", …), surfaced via `oauth.listProviders()`. Default empty.
31
16
  */
32
17
  oauthProviders?: readonly string[];
33
18
  /**
34
19
  * Allow `emailLink.sendMagicLink` to create new users on first request.
35
- * Default true — matches Supabase's `signInWithOtp` default and gives
36
- * fresh installs a working signup path. Set false for invite-only
37
- * deployments; `sendMagicLink` for an unknown email returns
38
- * `{ ok: false, reason: 'signup_disabled' }`.
20
+ * Default true, matching Supabase's `signInWithOtp` default. Set false for
21
+ * invite-only deployments; `sendMagicLink` for an unknown email then
22
+ * returns `{ ok: false, reason: 'signup_disabled' }`.
39
23
  */
40
24
  allowEmailLinkSignup?: boolean;
41
25
  /**
42
- * How `verifyToken` validates session JWTs (see the method for the full
43
- * rationale):
44
- * - `'hybrid'` (default): verify the JWT LOCALLY via `getClaims()` on every
45
- * request (no network call when the project uses asymmetric signing keys —
46
- * the modern default), and additionally re-check against GoTrue at most
47
- * once per `revalidateMs` per session to catch server-side sign-outs and
48
- * `disabled` flips. Bounds revocation latency to `revalidateMs`.
49
- * - `'strict'`: call `getUser()` on every request (the pre-1b behavior).
50
- * Instant revocation, one network round-trip per request. For operators
51
- * who don't accept any revocation lag.
26
+ * How `verifyToken` validates session JWTs — see that method for the
27
+ * rationale. `'hybrid'` (default) verifies locally and rechecks GoTrue
28
+ * periodically; `'strict'` calls GoTrue on every request.
52
29
  */
53
30
  tokenVerification?: 'hybrid' | 'strict';
54
- /**
55
- * Recheck window for `'hybrid'` verification, in ms. A verified session is
56
- * re-validated against GoTrue at most once per this interval. Default 60s.
57
- */
31
+ /** Recheck window for `'hybrid'` verification, in ms. Default 60s. */
58
32
  revalidateMs?: number;
59
33
  /**
60
34
  * Sink for best-effort failures the provider swallows rather than throwing
61
- * (currently `touchLastLogin`). Defaults to `NoopLogger` — pass one to make
62
- * those failures visible. Only identifiers are ever logged, never payloads.
35
+ * (currently `touchLastLogin`). Defaults to `NoopLogger`. Only identifiers
36
+ * are ever logged, never payloads.
63
37
  */
64
38
  logger?: ILogger;
65
39
  }
@@ -71,11 +45,10 @@ export declare class SupabaseAuthProvider implements IAuthProvider {
71
45
  readonly sessionRefresh: ISessionRefresh;
72
46
  private readonly admin;
73
47
  /**
74
- * Service-role client pinned to the engine schema (`selva`). Engine tables
75
- * live there, not in `public` — `this.admin` is deliberately left unpinned
76
- * because it exists to drive `auth.admin.*` (GoTrue's own REST surface,
77
- * which the PostgREST schema setting does not affect). Any table read or
78
- * write from this provider MUST go through this client instead.
48
+ * Service-role client pinned to the `selva` schema. `this.admin` stays
49
+ * unpinned because it only drives `auth.admin.*` (GoTrue's own REST
50
+ * surface, unaffected by the PostgREST schema setting) — any table read
51
+ * or write must go through `db` instead.
79
52
  */
80
53
  private readonly db;
81
54
  private readonly anon;
@@ -85,37 +58,31 @@ export declare class SupabaseAuthProvider implements IAuthProvider {
85
58
  private readonly revalidateMs;
86
59
  private readonly logger;
87
60
  /**
88
- * Last time a given session was re-validated against GoTrue (epoch ms),
89
- * keyed by the JWT `session_id`. Bounds the hybrid recheck to once per
90
- * `revalidateMs` per session. Swept lazily (see `verifyToken`) so a burst of
91
- * distinct sessions can't leak memory. Per-process; multi-instance drift is
92
- * harmless (each instance rechecks on its own schedule).
61
+ * Last GoTrue recheck per session (epoch ms), keyed by JWT `session_id`.
62
+ * Swept lazily in `markRevalidated` so session churn can't leak memory.
63
+ * Per-process — multi-instance drift is harmless, each instance rechecks
64
+ * on its own schedule.
93
65
  */
94
66
  private readonly lastRevalidatedAt;
95
67
  constructor(config: SupabaseAuthProviderConfig);
96
68
  static fromEnv(env: Record<string, string | undefined>, logger?: ILogger): SupabaseAuthProvider;
97
69
  /**
98
70
  * Verify a session JWT and return the user, or null if invalid/disabled.
99
- * Runs on EVERY authenticated request, so the fast path avoids a network
71
+ * Runs on every authenticated request, so the fast path avoids a network
100
72
  * round-trip.
101
73
  *
102
- * `'hybrid'` (default):
103
- * 1. `getClaims(token)` verifies the JWT. With asymmetric signing keys (the
104
- * modern Supabase default) this is LOCAL — the SDK verifies against the
105
- * cached JWKS via Web Crypto, no call to GoTrue. With a legacy symmetric
106
- * HS256 secret the SDK transparently falls back to a network verify, so
107
- * this is correct for both project types without us detecting the scheme
108
- * or hand-rolling JWKS handling (which the Supabase docs warn against —
109
- * it breaks under key rotation).
110
- * 2. Local verification can't see a server-side sign-out or a `disabled`
111
- * flip that happened AFTER the token was issued (the claims are a
112
- * snapshot). So we additionally re-check against GoTrue via `getUser`,
113
- * but at most once per `revalidateMs` per session — bounding revocation
114
- * latency to that window while eliminating ~all per-request network
115
- * calls under steady load.
74
+ * `'hybrid'` (default): `getClaims(token)` verifies the JWT locally with
75
+ * asymmetric signing keys (the modern Supabase default — the SDK checks
76
+ * against the cached JWKS via Web Crypto, no GoTrue call), and falls back
77
+ * to a network verify for legacy symmetric HS256 projects. Either way, a
78
+ * local check can't see a server-side sign-out or `disabled` flip that
79
+ * happened after the token was issued — the claims are a snapshot — so we
80
+ * also re-check against GoTrue via `getUser`, at most once per
81
+ * `revalidateMs` per session, bounding revocation latency to that window
82
+ * while skipping the network call on most requests.
116
83
  *
117
- * `'strict'`: `getUser` on every request — instant revocation, one round
118
- * trip per request. The pre-1b behavior, for operators who accept no lag.
84
+ * `'strict'`: `getUser` on every request. Instant revocation, one round
85
+ * trip per request.
119
86
  */
120
87
  verifyToken(token: string): Promise<AuthUser | null>;
121
88
  /** Full network verify against GoTrue. Also the `'strict'`-mode path. */
@@ -130,23 +97,11 @@ export declare class SupabaseAuthProvider implements IAuthProvider {
130
97
  deleteUser(id: string): Promise<UserManagementResult>;
131
98
  disableUser(id: string): Promise<UserManagementResult>;
132
99
  touchLastLogin(id: string): Promise<void>;
133
- /**
134
- * Sign in via GoTrue. Returns the access token string and the hydrated
135
- * user. Called by `SupabasePasswordAuth.verifyLogin` — kept on the
136
- * provider class so it has access to the hydrate helper without plumbing.
137
- */
100
+ /** Kept on the provider class so it can call `hydrate` without plumbing it through. */
138
101
  private signIn;
139
- /**
140
- * Map a GoTrue `User` to our identity-only `AuthUser`. Platform permissions
141
- * live on `IPlatformPermissionStore` and profile fields (displayName,
142
- * starred, recentRuns) on `IUserProfileStore` — neither is in AuthUser.
143
- */
102
+ /** Map a GoTrue `User` to our identity-only `AuthUser`. */
144
103
  private hydrate;
145
- /**
146
- * Expose the anon URL + key so other code (e.g. the same process's
147
- * storage provider or per-request client factories) can build user-scoped
148
- * clients without requiring a second config read.
149
- */
104
+ /** Lets other code (storage provider, per-request client factories) build user-scoped clients without a second config read. */
150
105
  getAnonClientConfig(): {
151
106
  supabaseUrl: string;
152
107
  anonKey: string;
@@ -1 +1 @@
1
- {"version":3,"file":"SupabaseAuthProvider.d.ts","sourceRoot":"","sources":["../../src/auth/SupabaseAuthProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EACX,aAAa,EACb,cAAc,EACd,UAAU,EACV,aAAa,EACb,eAAe,EACf,QAAQ,EAER,oBAAoB,EACpB,WAAW,EACX,IAAI,EACJ,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,0BAA0B;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;;;;OAMG;IACH,oBA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