better-supabase 0.29.0 → 0.31.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.
- package/dist/{adapter-D4aNBxhm.js → adapter-BTbj5N9C.js} +2 -52
- package/dist/ai-sdk/agents/index.d.ts +2 -2
- package/dist/{app-tables-DekyKNQ8.d.ts → app-tables-B2mKMNRQ.d.ts} +1 -1
- package/dist/astro/index.js +2 -2
- package/dist/{authorization-C7nuWMuB.d.ts → authorization-DfEkyFt_.d.ts} +24 -3
- package/dist/{bind-DmUGUsBd.d.ts → bind-DAx0bMSi.d.ts} +2 -2
- package/dist/{block-env-DWtZsqhH.d.ts → block-env-Dz7Caxk0.d.ts} +3 -3
- package/dist/blocks/ai-chat/index.d.ts +3 -3
- package/dist/blocks/announcements/index.d.ts +3 -3
- package/dist/blocks/api-keys/index.d.ts +1 -1
- package/dist/blocks/attachments/index.d.ts +1 -1
- package/dist/blocks/audit/index.d.ts +2 -2
- package/dist/blocks/automations/index.d.ts +1 -1
- package/dist/blocks/billing/index.d.ts +1 -1
- package/dist/blocks/bookings/index.d.ts +1 -1
- package/dist/blocks/calendar/index.d.ts +7 -3
- package/dist/blocks/calendar/index.js +5 -1
- package/dist/blocks/comments/index.d.ts +4 -4
- package/dist/blocks/employees/index.js +1 -4
- package/dist/blocks/entitlements/index.d.ts +2 -2
- package/dist/blocks/forms/index.d.ts +1 -1
- package/dist/blocks/inbox/index.d.ts +4 -4
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/messaging/index.d.ts +4 -4
- package/dist/blocks/mfa/index.d.ts +1 -1
- package/dist/blocks/notifications/index.d.ts +3 -3
- package/dist/blocks/notifications/index.js +5 -43
- package/dist/blocks/onboarding/index.d.ts +1 -1
- package/dist/blocks/organizations/index.d.ts +34 -21
- package/dist/blocks/organizations/index.js +5 -1
- package/dist/blocks/permissions/index.d.ts +32 -3
- package/dist/blocks/permissions/index.js +23 -2
- package/dist/blocks/push/index.d.ts +10 -2
- package/dist/blocks/push/index.js +23 -7
- package/dist/blocks/reactions/index.d.ts +3 -3
- package/dist/blocks/saved-views/index.d.ts +1 -1
- package/dist/blocks/search/index.d.ts +2 -2
- package/dist/blocks/sessions/index.d.ts +1 -1
- package/dist/blocks/settings/index.d.ts +1 -1
- package/dist/blocks/subjects/index.d.ts +1 -1
- package/dist/blocks/tags/index.d.ts +1 -1
- package/dist/blocks/tasks/index.js +1 -1
- package/dist/blocks/teams/index.d.ts +7 -1
- package/dist/blocks/teams/index.js +8 -7
- package/dist/blocks/undo/index.d.ts +1 -1
- package/dist/blocks/usage/index.d.ts +1 -1
- package/dist/blocks/workflow-editor/index.d.ts +3 -3
- package/dist/blocks/workflows/index.d.ts +3 -3
- package/dist/cli/{add-BKkV99g9.js → add-B9wP0YGU.js} +2 -2
- package/dist/cli/{add-CrQ3jS7t.js → add-DjZXKd7X.js} +10 -10
- package/dist/cli/add-ZcEOEK23.js +1 -0
- package/dist/cli/{app-table-files-PnPOpuB4.js → app-table-files-mtvjHa48.js} +2 -2
- package/dist/cli/{backfill-DDDLhinm.js → backfill-Coshdvh_.js} +2 -2
- package/dist/cli/bin.js +1 -1
- package/dist/cli/{blocks-tRfYx_mh.js → blocks-BWCuA0nq.js} +2 -2
- package/dist/cli/{blocks-BCVcjvbm.js → blocks-hiSazThw.js} +1 -1
- package/dist/cli/{cache-DQZ09YOg.js → cache-x2wWAy0h.js} +1 -1
- package/dist/cli/{codemod-HKuwQmi_.js → codemod-BnjV7BpC.js} +210 -11
- package/dist/cli/{command-DIPmo0wh.js → command-CCAwhiOh.js} +6 -0
- package/dist/cli/{completion-DxPxMtyP.js → completion-BJaB84Pe.js} +2 -2
- package/dist/cli/{completion-DyLMSjOD.js → completion-BkUhs1ms.js} +1 -1
- package/dist/cli/{completion-FUgqm2-N.js → completion-DmUVsUVQ.js} +2 -2
- package/dist/cli/{config-BfapErxs.js → config-zId1jkLx.js} +1 -1
- package/dist/cli/{content-mapper-B0ehR7K-.js → content-mapper-DvOSOdTE.js} +2 -2
- package/dist/cli/{db-CWvH1_46.js → db-DXKyVEDF.js} +1 -1
- package/dist/cli/{doctor-CXJOhwLB.js → doctor-Ywy8oJEU.js} +76 -18
- package/dist/cli/env-CNjT_uOV.js +1 -0
- package/dist/cli/{env-BM242BCV.js → env-XMiKvhtV.js} +2 -2
- package/dist/cli/{gen-B7rw4j19.js → gen-B-FbQmG1.js} +14 -14
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +7 -7
- package/dist/cli/{init-C1bXXB_P.js → init-fb9e1BKX.js} +9 -9
- package/dist/cli/{keys-V-HcO-21.js → keys-ORiPz1sM.js} +1 -1
- package/dist/cli/{live-PpAh9pAc.js → live-DIt7TP-N.js} +2 -2
- package/dist/cli/{mcp-BRNAchdH.js → mcp-CVWwraga.js} +3 -3
- package/dist/cli/{metadata-dAAKb_kR.js → metadata-CannIjel.js} +3 -3
- package/dist/cli/{migrate-BWYXFnaW.js → migrate-Ht2TzIQF.js} +2 -2
- package/dist/cli/{migration-safety-DGQswWZy.js → migration-safety-nNyB05I-.js} +1 -1
- package/dist/cli/{migrations-Cqk-lJwu.js → migrations-bAd7dpk1.js} +2 -2
- package/dist/cli/{module-migration-8-hMiZtW.js → module-migration-CkNux8dr.js} +2 -2
- package/dist/cli/{moved-DNOtp9LA.js → moved-C3WyRHkA.js} +1 -1
- package/dist/cli/{parse-BPf3kGnc.js → parse-DjHbTaFI.js} +1 -1
- package/dist/cli/{powersync-BWQ-8T3G.js → powersync-B2v0tDwp.js} +100 -7
- package/dist/cli/powersync-D3mAQ6QE.js +1 -0
- package/dist/cli/{print-DSTnq5xz.js → print-CxQ0rBKT.js} +2 -2
- package/dist/cli/{providers-Cjf5iOp5.js → providers-DtI90lSw.js} +1 -1
- package/dist/cli/{remove-CwG8cPv1.js → remove-DYtE4IZ4.js} +6 -6
- package/dist/cli/{render-B18iAdsT.js → render-QGWfEoiB.js} +3 -3
- package/dist/cli/{run-CvPl8iQd.js → run-B5aMwErM.js} +3 -3
- package/dist/cli/{run-C2Yg5MWt.js → run-BNoJKf5I.js} +40 -39
- package/dist/cli/{run-Wx_2Acgv.js → run-DiYX1XEa.js} +8 -8
- package/dist/cli/{seed-CDnL4Tnc.js → seed-C-Hu2n_E.js} +1 -1
- package/dist/cli/seed-Cm-c0BDd.js +1 -0
- package/dist/cli/{shared-BHbtUOvh.js → shared-D_CFi5di.js} +1 -1
- package/dist/cli/{skills-DM3oeIxY.js → skills-D98y0bSB.js} +1 -1
- package/dist/cli/{snapshot-CXgsUPGj.js → snapshot-BlQ4DDcJ.js} +9 -4
- package/dist/cli/{source-B6aMAoEK.js → source-CelMBQMj.js} +1 -1
- package/dist/cli/{spec-EO0TP84d.js → spec-BxcoGE0h.js} +1 -1
- package/dist/cli/{spec-BcYic005.js → spec-iBx1LcYO.js} +3 -3
- package/dist/cli/{sql-layout-CkxDNVEH.js → sql-layout-Dp4Rottt.js} +2 -2
- package/dist/cli/{stack-ClESAZYf.js → stack-B2slzrYH.js} +1 -1
- package/dist/cli/{stack-env-6hS-WEmh.js → stack-env-3ziggrU3.js} +1 -1
- package/dist/cli/{sync-pq6gmlhG.js → sync-BnORI43S.js} +4 -4
- package/dist/cli/{table-dyKddjwo.js → table-D6HUECKI.js} +1 -1
- package/dist/cli/{upgrade-Dp9p7A69.js → upgrade-CR6-WmIc.js} +5 -5
- package/dist/cli/{upgrade-BoHb4h9P.js → upgrade-fz92aCnh.js} +3 -3
- package/dist/cli/{version-CQHFm-ak.js → version-Dz8ZlOuh.js} +1 -1
- package/dist/client/index.d.ts +5 -5
- package/dist/client/native/index.d.ts +4 -4
- package/dist/{composite-CBRbvn5j.js → composite-B4qB6k31.js} +2 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +4 -4
- package/dist/{config-r7njjNgh.js → config-B7g-HDis.js} +3 -3
- package/dist/{config-bqKaPjst.js → config-R0m0fBiD.js} +1 -1
- package/dist/{context-B4TsE2gY.d.ts → context-DWWoP1wK.d.ts} +13 -1
- package/dist/{controller-CtwAsnVV.d.ts → controller-Br9dGKGe.d.ts} +1 -1
- package/dist/{controller-qG-B1eDn.js → controller-W97g2WGG.js} +1 -1
- package/dist/create/index.d.ts +3 -3
- package/dist/create/index.js +3 -3
- package/dist/create/lite/index.d.ts +3 -3
- package/dist/create/lite/index.js +3 -3
- package/dist/delivery-events-DbL8IHIY.js +53 -0
- package/dist/edge/index.js +3 -3
- package/dist/{entitlements-Bw3eYGKJ.d.ts → entitlements-CBjm2lvD.d.ts} +1 -1
- package/dist/eve/index.js +1 -1
- package/dist/expo/index.js +3 -2
- package/dist/{field-errors-DkzFduux.d.ts → field-errors-CEjsMAgd.d.ts} +4 -4
- package/dist/{framework-DYEUraqt.js → framework-CqiZk89W.js} +1 -1
- package/dist/hono/index.js +2 -2
- package/dist/{index-CB66nl14.d.ts → index-Clyd2Goi.d.ts} +1 -1
- package/dist/{index-Cw5gGSP8.d.ts → index-D98bQs8a.d.ts} +7 -7
- package/dist/{index-BNgpz_BV.d.ts → index-DIdPoQtO.d.ts} +2 -2
- package/dist/{index-BxckmAFc.d.ts → index-I8YLxKq8.d.ts} +2 -2
- package/dist/{index-CBQT_nXf.d.ts → index-eRBuKtMt.d.ts} +2 -2
- package/dist/{index-BM6NmKSc.d.ts → index-uIU65iEn.d.ts} +6 -6
- package/dist/{instances-C7qUTjhJ.js → instances-DY_ORk5g.js} +2 -0
- package/dist/mapper/bin.js +5 -5
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/sdk/index.js +1 -1
- package/dist/next/index.d.ts +155 -13
- package/dist/next/index.js +245 -52
- package/dist/{operations-CqmQrTKw.d.ts → operations-hm1Isvvs.d.ts} +1 -1
- package/dist/{options-C4LuqmdG.js → options-CF6EVF_G.js} +3 -1
- package/dist/{options-COo7_3MX.js → options-DSCW40_5.js} +3 -1
- package/dist/orpc/index.js +2 -1
- package/dist/otel/index.js +4 -4
- package/dist/{ports-6LBgr1Aa.d.ts → ports-DOrPTJzl.d.ts} +1 -1
- package/dist/powersync/index.d.ts +204 -4
- package/dist/powersync/index.js +361 -4
- package/dist/preset/index.d.ts +3 -3
- package/dist/preset/index.js +3 -3
- package/dist/{preset-DCdEnJj9.js → preset-CXhpPmPV.js} +2 -2
- package/dist/{project-C4NA_van.js → project-DJ9Uo0sT.js} +5 -5
- package/dist/{push-token-BXsrJ7W9.d.ts → push-token-B4vcIU4s.d.ts} +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/query/index.js +1 -1
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +1 -1
- package/dist/react/native/index.d.ts +1 -1
- package/dist/react/server.d.ts +5 -5
- package/dist/react/server.js +1 -1
- package/dist/{react-CcrQQl0_.js → react-mdVjpewL.js} +2 -2
- package/dist/react-router/index.js +2 -2
- package/dist/realtime/index.d.ts +3 -3
- package/dist/{record-type-DRbnlj5q.js → record-type-BEUyEsFx.js} +2 -2
- package/dist/records/index.d.ts +5 -5
- package/dist/records/index.js +3 -3
- package/dist/{replicas-Dyoh3CEg.js → refresh-DLBgnxjL.js} +51 -1
- package/dist/{resolved-names-iLBOUaib.js → resolved-names-kMRjmSIy.js} +1 -1
- package/dist/{runtime-CoKxZibd.js → runtime-LRJM7UqY.js} +19 -20
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +4 -4
- package/dist/sign-in-BzihC_8k.d.ts +50 -0
- package/dist/{sign-in-NO7LWlw4.js → sign-in-CuZ1Ag7O.js} +136 -26
- package/dist/solid/index.d.ts +5 -5
- package/dist/solid-start/index.js +2 -2
- package/dist/spec/index.js +1 -1
- package/dist/sql/index.d.ts +4 -4
- package/dist/sql/index.js +3 -3
- package/dist/{sql-CoBySj2F.js → sql-DHp0L7zK.js} +680 -333
- package/dist/ssr/index.d.ts +1 -1
- package/dist/svelte/index.d.ts +5 -5
- package/dist/sveltekit/index.js +2 -2
- package/dist/tanstack-start/index.js +2 -2
- package/dist/{tenant-Ded341Qz.d.ts → tenant-FfgNhd5x.d.ts} +1 -1
- package/dist/testing/index.d.ts +13 -4
- package/dist/testing/index.js +17 -15
- package/dist/{timeline-DvXtXq5q.d.ts → timeline-DqEoD8bb.d.ts} +1 -1
- package/dist/{timeline--VU3A1e4.js → timeline-Dz3hO2I6.js} +1 -1
- package/dist/{topic-XDdKzlrn.d.ts → topic-BaUElNw2.d.ts} +1 -1
- package/dist/{types-BFwB-E1j.d.ts → types-CMN0h_Ix.d.ts} +2 -2
- package/dist/vue/index.d.ts +5 -5
- package/dist/{watch-topic-DpN_GEoS.d.ts → watch-topic-BabDTZ-L.d.ts} +1 -1
- package/dist/workflow-sdk/world/index.js +2 -2
- package/dist/{workflow-sdk-CaEw822d.js → workflow-sdk-DJJkP0dT.js} +47 -8
- package/dist/yjs/index.d.ts +1 -1
- package/package.json +1 -1
- package/schemas/config-v1.json +10 -1
- package/schemas/doctor-report-v1.json +2 -0
- package/skills/better-supabase/references/ui-recipes.md +524 -295
- package/skills/better-supabase-api/references/powersync.md +16 -0
- package/skills/better-supabase-auth/SKILL.md +11 -1
- package/dist/cli/add-CwhrRJz5.js +0 -1
- package/dist/cli/env-uqfUbUzk.js +0 -1
- package/dist/cli/powersync-CbYxLsjv.js +0 -1
- package/dist/cli/seed-BOun22-k.js +0 -1
- package/dist/sign-in-CfwJAJJL.d.ts +0 -24
package/dist/mapper/bin.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as VERSION } from "../cli/version-
|
|
2
|
-
import { a as lastTypesModule, c as writeAtomic, s as typesModuleKey } from "../cli/cache-
|
|
3
|
-
import { t as loadSnapshot } from "../cli/snapshot-
|
|
4
|
-
import { i as renderTypesModule, t as mapperFilePath } from "../cli/render-
|
|
1
|
+
import { t as VERSION } from "../cli/version-Dz8ZlOuh.js";
|
|
2
|
+
import { a as lastTypesModule, c as writeAtomic, s as typesModuleKey } from "../cli/cache-x2wWAy0h.js";
|
|
3
|
+
import { t as loadSnapshot } from "../cli/snapshot-BlQ4DDcJ.js";
|
|
4
|
+
import { i as renderTypesModule, t as mapperFilePath } from "../cli/render-QGWfEoiB.js";
|
|
5
5
|
import { i as discoverConfig, s as loadConfig } from "../cli/config-Cskysxp-.js";
|
|
6
6
|
import { i as parseEnv, n as configEnvironment } from "../cli/env-BK0xKMeU.js";
|
|
7
|
-
import { s as schemaStampPath } from "../cli/content-mapper-
|
|
7
|
+
import { s as schemaStampPath } from "../cli/content-mapper-DvOSOdTE.js";
|
|
8
8
|
import { existsSync, realpathSync } from "node:fs";
|
|
9
9
|
import { basename, dirname, join, resolve } from "node:path";
|
|
10
10
|
import { createHash } from "node:crypto";
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { O as AnyFunctions, k as AnyModels, ut as TableKey } from "../types-CPl9uJ0G.js";
|
|
2
|
-
import { t as OperationTable } from "../operations-
|
|
2
|
+
import { t as OperationTable } from "../operations-hm1Isvvs.js";
|
|
3
3
|
import { l as PermissionRef, t as AnyAuthorizer } from "../authorizer-B6X09otb.js";
|
|
4
4
|
import { t as BetterSupabase } from "../define-D8_9X5fZ.js";
|
|
5
5
|
import { a as ServerContext, c as ServerOptions, n as BetterServer } from "../server-types-BkTIxW_H.js";
|
package/dist/mcp/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { r as toDraft07, t as buildJsonSchema } from "../json-schema-DHJxiizN.js
|
|
|
8
8
|
import { r as operationPermission, t as OPERATION_PREFIXES } from "../operations-DVHRHvv6.js";
|
|
9
9
|
import { r as pageSchema, t as pageInputSchema } from "../resource-schemas-up6bKOUi.js";
|
|
10
10
|
import { n as jsonResponse, t as jsonReplacer } from "../json-DaByVJpw.js";
|
|
11
|
-
import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-
|
|
11
|
+
import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-BTbj5N9C.js";
|
|
12
12
|
import { n as checkEach, r as checkPermission } from "../authorizer-BGhXaDmo.js";
|
|
13
13
|
import { i as guard, n as defaultExpose, s as settle } from "../respond-CZMWbUs3.js";
|
|
14
14
|
import { t as boundedTtlCache } from "../ttl-cache-Bhr9swjT.js";
|
package/dist/mcp/sdk/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as dbError } from "../../errors-BVFgt8BZ.js";
|
|
2
2
|
import { o as problemResponse } from "../../problem-Bf0cJ7tk.js";
|
|
3
3
|
import { i as delegationOf } from "../../actor-go7p9-CJ.js";
|
|
4
|
-
import { c as extendServer, i as resolveToken, n as flushEvents, s as createServer } from "../../adapter-
|
|
4
|
+
import { c as extendServer, i as resolveToken, n as flushEvents, s as createServer } from "../../adapter-BTbj5N9C.js";
|
|
5
5
|
import { i as guard } from "../../respond-CZMWbUs3.js";
|
|
6
6
|
import { t as withExtra } from "../../extra-CGQ2_q3S.js";
|
|
7
7
|
import { a as withCors, i as metadataPreflight, n as endpointPreflight, r as isMetadataRequest, t as discovery } from "../../http-DzbloBR-.js";
|
package/dist/next/index.d.ts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { b as DbError, f as Result } from "../result-DZeA5KS6.js";
|
|
2
2
|
import { $ as RecordRef, O as AnyFunctions, k as AnyModels } from "../types-CPl9uJ0G.js";
|
|
3
|
-
import { r as AuthState } from "../resolve-CtX6T0c0.js";
|
|
3
|
+
import { p as CookieScope, r as AuthState } from "../resolve-CtX6T0c0.js";
|
|
4
4
|
import { l as PermissionRef, t as AnyAuthorizer } from "../authorizer-B6X09otb.js";
|
|
5
5
|
import { Qt as CacheAdapter, Y as DbStats, mt as QuerySpec, nt as ReadSet, t as BetterSupabase } from "../define-D8_9X5fZ.js";
|
|
6
6
|
import { A as isSessionSnapshot, M as sessionCacheKey, O as SessionSnapshot, a as ServerContext, c as ServerOptions, j as issuedAtOf, k as authzVersionOf, l as SharedServer, n as BetterServer, r as ContextOptions } from "../server-types-BkTIxW_H.js";
|
|
7
7
|
import { n as Impersonator } from "../impersonation-YTa9dZUv.js";
|
|
8
8
|
import { n as AmrEntry, t as Aal } from "../mfa-oIOYTpvc.js";
|
|
9
9
|
import { S as BlockClientSource, on as RecordBindingOptions } from "../define-block-DWVZSZv1.js";
|
|
10
|
-
import { M as BindingName, N as BindingOf, S as RecordWriteInput, _ as RecordTypeBlocks, b as RecordTypeWriteInput, d as BindingWritesOf, f as Plain, g as RecordType, h as RecordCan, m as PlainBindings, x as RecordTypeWriteOutput } from "../index-
|
|
11
|
-
import { t as tenantOf } from "../tenant-
|
|
10
|
+
import { M as BindingName, N as BindingOf, S as RecordWriteInput, _ as RecordTypeBlocks, b as RecordTypeWriteInput, d as BindingWritesOf, f as Plain, g as RecordType, h as RecordCan, m as PlainBindings, x as RecordTypeWriteOutput } from "../index-uIU65iEn.js";
|
|
11
|
+
import { t as tenantOf } from "../tenant-FfgNhd5x.js";
|
|
12
12
|
import { n as toSession, t as AuthSession } from "../view-C8_xvD-j.js";
|
|
13
13
|
import { a as SupportPolicy, c as supportSessions, i as SupportOptions, o as SupportSessions, s as SupportStartRequest, t as ActiveSupport } from "../support-BxyPOFk4.js";
|
|
14
14
|
import { t as AuthOutageHook } from "../session-BOzx2qHC.js";
|
|
15
15
|
import { n as AuthKind, r as GuardOptions } from "../respond-Dzu_-EPH.js";
|
|
16
16
|
import { a as AuthorizedContext, c as ResourceLoaderContext, i as AuthorizeOptions, l as Unwrapped, n as ActionParsed, r as ActionResult, t as ActionInput } from "../kit-B8yWCRN7.js";
|
|
17
17
|
import { c as ListParseOptions, m as ListSearchParams } from "../list-query-BcU8NnNL.js";
|
|
18
|
-
import { r as LiveCountSeed, t as CountRunner } from "../index-
|
|
19
|
-
import { r as MembershipClaim } from "../entitlements-
|
|
18
|
+
import { r as LiveCountSeed, t as CountRunner } from "../index-DIdPoQtO.js";
|
|
19
|
+
import { r as MembershipClaim } from "../entitlements-CBjm2lvD.js";
|
|
20
20
|
import { i as ResourceContext, l as ResourceRouteOptions, o as ResourceHooks, r as ResourceAction, t as ActionArgs } from "../resource-types-BVbHgTPg.js";
|
|
21
21
|
import { t as ResourceMap } from "../resources-BSbRa0Ab.js";
|
|
22
22
|
import { t as defineAction } from "../resource-execute-BzqR8DdD.js";
|
|
23
|
+
import { a as SignOutScope, n as EmailOtpType, r as OtpParams, s as safeRedirectPath, t as AuthorizeUrlParams } from "../sign-in-BzihC_8k.js";
|
|
23
24
|
import { n as BlockDataOf, r as BlockMethodName, t as BlockArgsOf } from "../block-method-CiVa2G-J.js";
|
|
24
25
|
import { i as tagFor, t as TagOptions } from "../tags-Cm48BsOa.js";
|
|
25
|
-
import { c as RecordListCells, n as Timeline, o as RecordList, u as RecordListPage } from "../timeline-
|
|
26
|
-
import { r as safeRedirectPath } from "../sign-in-CfwJAJJL.js";
|
|
26
|
+
import { c as RecordListCells, n as Timeline, o as RecordList, u as RecordListPage } from "../timeline-DqEoD8bb.js";
|
|
27
27
|
import { n as supportOf, t as SupportView } from "../support-view-nqUWKHEs.js";
|
|
28
28
|
import { NextRequest } from "next/server.js";
|
|
29
29
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
30
|
+
import { UserClaims } from "@supabase/server";
|
|
30
31
|
//#region src/next/collector.d.ts
|
|
31
32
|
/** Forwarded by the proxy so every scope of one render shares an id. */
|
|
32
33
|
export declare const REQUEST_ID_HEADER = "x-bsb-request-id";
|
|
@@ -169,6 +170,12 @@ interface NextOptions extends ServerOptions {
|
|
|
169
170
|
readonly exposeErrors?: boolean;
|
|
170
171
|
/** Per-request database call counts. See the Budget docs. */
|
|
171
172
|
readonly debug?: NextDebugOptions;
|
|
173
|
+
/**
|
|
174
|
+
* Cookie scopes (`domain`, `path`) earlier deploys wrote the session at.
|
|
175
|
+
* `signOut` also expires the session cookie at each of them. Never list the
|
|
176
|
+
* current scope.
|
|
177
|
+
*/
|
|
178
|
+
readonly cookieScopes?: readonly CookieScope[];
|
|
172
179
|
}
|
|
173
180
|
interface NextDebugOptions {
|
|
174
181
|
/** Collect outside development too, e.g. for e2e runs against `next start`. */
|
|
@@ -488,10 +495,70 @@ interface BetterNext<M extends AnyModels, F extends AnyFunctions, E, C = unknown
|
|
|
488
495
|
* Signs in with an email and a password from a server action. It writes the
|
|
489
496
|
* session cookies, stores the verified session for the next render and
|
|
490
497
|
* returns `redirectTo`: `credentials.next` when it is a same-origin path,
|
|
491
|
-
* else `options.fallback` (`/`).
|
|
492
|
-
* `
|
|
498
|
+
* else `options.fallback` (`/`). Reads later in the same request
|
|
499
|
+
* (`getRequestSession()`, `session()`, `context()`) see the new session.
|
|
493
500
|
*/
|
|
494
501
|
signIn(credentials: SignInCredentials, options?: SignInOptions): Promise<ActionResult<SignedIn>>;
|
|
502
|
+
/** The same as `signIn`. */
|
|
503
|
+
signInWithPassword(credentials: SignInCredentials, options?: SignInOptions): Promise<ActionResult<SignedIn>>;
|
|
504
|
+
/**
|
|
505
|
+
* Verifies an email link's `token_hash` (sign-up, invite, magic link,
|
|
506
|
+
* recovery, email change) or an emailed code, then commits the session like
|
|
507
|
+
* `signIn`. The new session replaces any session the request carried.
|
|
508
|
+
*/
|
|
509
|
+
verifyOtp(params: VerifyOtpParams, options?: SignInOptions): Promise<ActionResult<SignedIn>>;
|
|
510
|
+
/**
|
|
511
|
+
* The Auth server's OAuth URL for `provider`, for a `redirect()`. It writes
|
|
512
|
+
* the PKCE verifier cookie (httpOnly, `lax`, 10 minutes) that `exchangeCode`
|
|
513
|
+
* reads. `next` rides on `redirectTo` as `?next=` when it is a same-origin
|
|
514
|
+
* path.
|
|
515
|
+
*/
|
|
516
|
+
authorizeUrl(params: OAuthStart): Promise<{
|
|
517
|
+
readonly url: string;
|
|
518
|
+
}>;
|
|
519
|
+
/**
|
|
520
|
+
* Exchanges the callback's `?code=` and the PKCE verifier cookie for a
|
|
521
|
+
* session, deletes the verifier cookie and commits the session like
|
|
522
|
+
* `signIn`.
|
|
523
|
+
*/
|
|
524
|
+
exchangeCode(params: CodeExchange, options?: SignInOptions): Promise<ActionResult<SignedIn>>;
|
|
525
|
+
/**
|
|
526
|
+
* Challenges and verifies an MFA factor for the signed-in user and commits
|
|
527
|
+
* the `aal2` session; `mfa` is then false.
|
|
528
|
+
*/
|
|
529
|
+
verifyMfa(params: MfaVerification, options?: SignInOptions): Promise<ActionResult<SignedIn>>;
|
|
530
|
+
/**
|
|
531
|
+
* Ends the session on the Auth server first (`scope`, `local` by default),
|
|
532
|
+
* then clears the session cookies (also at `cookieScopes`), forgets the
|
|
533
|
+
* verified sessions and expires its cache tags. `others` keeps this session
|
|
534
|
+
* and its cookies, and still forgets the verified sessions. Reads later in
|
|
535
|
+
* the same request are signed out.
|
|
536
|
+
*/
|
|
537
|
+
signOut(params?: SignOutParams, options?: SignInOptions): Promise<ActionResult<SignedIn>>;
|
|
538
|
+
/**
|
|
539
|
+
* Emails a magic link and a code. It writes the PKCE verifier cookie like
|
|
540
|
+
* `authorizeUrl`, so the link's `?code=` goes to `exchangeCode`, and the code
|
|
541
|
+
* to `verifyOtp` with `type: "email"`. Returns `null`: nothing is signed in
|
|
542
|
+
* yet.
|
|
543
|
+
*/
|
|
544
|
+
signInWithOtp(params: SignInWithOtpParams): Promise<ActionResult<null>>;
|
|
545
|
+
/**
|
|
546
|
+
* Emails a password reset link with the PKCE verifier cookie. `exchangeCode`
|
|
547
|
+
* on the callback signs the user in; the app then asks for the new password.
|
|
548
|
+
* Auth answers the same whether or not an account has the email.
|
|
549
|
+
*/
|
|
550
|
+
resetPasswordForEmail(params: ResetPasswordParams): Promise<ActionResult<null>>;
|
|
551
|
+
/**
|
|
552
|
+
* Signs up with an email and a password. With email confirmation on, it
|
|
553
|
+
* emails the confirmation link with the PKCE verifier cookie and returns
|
|
554
|
+
* `null`. With it off, Auth returns a session, committed like `signIn`.
|
|
555
|
+
*/
|
|
556
|
+
signUp(params: SignUpParams, options?: SignInOptions): Promise<ActionResult<SignedIn | null>>;
|
|
557
|
+
/**
|
|
558
|
+
* Emails the sign-up confirmation or the email change link again, with a new
|
|
559
|
+
* PKCE verifier cookie.
|
|
560
|
+
*/
|
|
561
|
+
resend(params: ResendParams): Promise<ActionResult<null>>;
|
|
495
562
|
}
|
|
496
563
|
interface SignInCredentials {
|
|
497
564
|
readonly email: string;
|
|
@@ -503,14 +570,89 @@ interface SignInOptions {
|
|
|
503
570
|
/** Where to go when `next` is missing or not a same-origin path. */
|
|
504
571
|
readonly fallback?: string;
|
|
505
572
|
}
|
|
506
|
-
/**
|
|
573
|
+
/** `verifyOtp` input: a link's `token_hash`, or an email and its code. */
|
|
574
|
+
type VerifyOtpParams = OtpParams & {
|
|
575
|
+
/** Checked before use, like `signIn`'s. */
|
|
576
|
+
readonly next?: string | null;
|
|
577
|
+
};
|
|
578
|
+
/** `authorizeUrl` input. */
|
|
579
|
+
interface OAuthStart extends AuthorizeUrlParams {
|
|
580
|
+
/** Where to go after the callback; checked before use. */
|
|
581
|
+
readonly next?: string | null;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Where an email link lands. The verifier cookie lives 10 minutes and holds one
|
|
585
|
+
* flow: a newer `authorizeUrl` or email flow in the same browser replaces it.
|
|
586
|
+
*/
|
|
587
|
+
interface EmailRedirect {
|
|
588
|
+
/**
|
|
589
|
+
* The absolute URL of the callback route that calls `exchangeCode`. It must
|
|
590
|
+
* be in the project's redirect allow list.
|
|
591
|
+
*/
|
|
592
|
+
readonly redirectTo: string;
|
|
593
|
+
/** Rides on `redirectTo` as `?next=` when it is a same-origin path. */
|
|
594
|
+
readonly next?: string | null;
|
|
595
|
+
}
|
|
596
|
+
/** `signInWithOtp` input. */
|
|
597
|
+
interface SignInWithOtpParams extends EmailRedirect {
|
|
598
|
+
readonly email: string;
|
|
599
|
+
/** Create a user when no account has the email. Defaults to `true`. */
|
|
600
|
+
readonly shouldCreateUser?: boolean;
|
|
601
|
+
/** `user_metadata` for a user this creates. */
|
|
602
|
+
readonly data?: Readonly<Record<string, unknown>>;
|
|
603
|
+
}
|
|
604
|
+
/** `resetPasswordForEmail` input. */
|
|
605
|
+
interface ResetPasswordParams extends EmailRedirect {
|
|
606
|
+
readonly email: string;
|
|
607
|
+
}
|
|
608
|
+
/** `signUp` input. */
|
|
609
|
+
interface SignUpParams extends EmailRedirect {
|
|
610
|
+
readonly email: string;
|
|
611
|
+
readonly password: string;
|
|
612
|
+
/** `user_metadata` for the new user. */
|
|
613
|
+
readonly data?: Readonly<Record<string, unknown>>;
|
|
614
|
+
}
|
|
615
|
+
/** `resend` input. */
|
|
616
|
+
interface ResendParams extends EmailRedirect {
|
|
617
|
+
readonly type: "signup" | "email_change";
|
|
618
|
+
readonly email: string;
|
|
619
|
+
}
|
|
620
|
+
/** `exchangeCode` input: the callback's `?code=` and `?next=`. */
|
|
621
|
+
interface CodeExchange {
|
|
622
|
+
readonly code: string;
|
|
623
|
+
readonly next?: string | null;
|
|
624
|
+
}
|
|
625
|
+
/** `verifyMfa` input. */
|
|
626
|
+
interface MfaVerification {
|
|
627
|
+
readonly factorId: string;
|
|
628
|
+
/** The code from the authenticator app. */
|
|
629
|
+
readonly code: string;
|
|
630
|
+
readonly next?: string | null;
|
|
631
|
+
}
|
|
632
|
+
/** `signOut` input. */
|
|
633
|
+
interface SignOutParams {
|
|
634
|
+
readonly scope?: SignOutScope;
|
|
635
|
+
readonly next?: string | null;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* What the sign-in and sign-out helpers return: plain data, safe across the
|
|
639
|
+
* action boundary. The committed session is on `getRequestSession()` and
|
|
640
|
+
* `context()` for the rest of the request.
|
|
641
|
+
*/
|
|
507
642
|
interface SignedIn {
|
|
643
|
+
/** `next` when it is a same-origin path, else `fallback` (`/`). */
|
|
508
644
|
readonly redirectTo: string;
|
|
509
645
|
/**
|
|
510
|
-
* The user has a verified MFA factor
|
|
511
|
-
* `redirectTo` as its `next`) before
|
|
646
|
+
* The user has a verified MFA factor and the session is not `aal2` yet: send
|
|
647
|
+
* them to the challenge (with `redirectTo` as its `next`) before
|
|
648
|
+
* `redirectTo`. Advisory: keep the proxy and `action({ aal: 2 })` gates.
|
|
512
649
|
*/
|
|
513
650
|
readonly mfa: boolean;
|
|
651
|
+
/**
|
|
652
|
+
* The signed-in user, read from the verified claims like `AuthSession.user`;
|
|
653
|
+
* `null` once signed out.
|
|
654
|
+
*/
|
|
655
|
+
readonly user: UserClaims | null;
|
|
514
656
|
}
|
|
515
657
|
/** What `startSupport` returns: plain data, safe across the action boundary. */
|
|
516
658
|
interface SupportStarted {
|
|
@@ -685,4 +827,4 @@ export declare function shouldRefresh(request: Request): boolean;
|
|
|
685
827
|
*/
|
|
686
828
|
export declare function requireAal(level: Aal, options?: RequireAalOptions): (auth: AuthState, request: NextRequest) => Response | undefined;
|
|
687
829
|
//#endregion
|
|
688
|
-
export { type Aal, type ActionArgs, type ActionOptions, type ActionResult, type ActiveSupport, type AmrEntry, type AuthKind, type AuthSession, type AuthorizeOptions, type AuthorizedContext, type BetterNext, type BlockActionArgs, type CachedContext, type CachedOptions, type DbBudget, type DbStats, type EndedSessionOptions, type GuardOptions, type Impersonator, type LiveCountSeed, type MembershipClaim, type NextCacheOptions, type NextDebugOptions, type NextOptions, type NextResourceHandler, type NextResourceRoutes, type NextResourcesOptions, type ProxyOptions, type RecordListServer, type RecordListView, type RecordLoadOptions, type RecordServer, type RecordServerActions, type RecordServerContext, type RecordTagOptions, type RecordTimelineOptions, type RecordView, type RequireAalOptions, type RequireOptions, type ResourceAction, type ResourceContext, type ResourceHooks, type ResourceLoaderContext, type ResourceMap, type ResourceRouteOptions, type RouteOptions, type ScopeOptions, type SessionSnapshot, type SessionStaleOptions, type SignInCredentials, type SignInOptions, type SignedIn, type SupportOptions, type SupportPolicy, type SupportSessions, type SupportStartRequest, type SupportStarted, type SupportView, type TagOptions, authzVersionOf, defineAction, isSessionSnapshot, issuedAtOf, safeRedirectPath, sessionCacheKey, supportOf, supportSessions, tagFor, tenantOf, toSession };
|
|
830
|
+
export { type Aal, type ActionArgs, type ActionOptions, type ActionResult, type ActiveSupport, type AmrEntry, type AuthKind, type AuthSession, type AuthorizeOptions, type AuthorizeUrlParams, type AuthorizedContext, type BetterNext, type BlockActionArgs, type CachedContext, type CachedOptions, type CodeExchange, type DbBudget, type DbStats, type EmailOtpType, type EmailRedirect, type EndedSessionOptions, type GuardOptions, type Impersonator, type LiveCountSeed, type MembershipClaim, type MfaVerification, type NextCacheOptions, type NextDebugOptions, type NextOptions, type NextResourceHandler, type NextResourceRoutes, type NextResourcesOptions, type OAuthStart, type ProxyOptions, type RecordListServer, type RecordListView, type RecordLoadOptions, type RecordServer, type RecordServerActions, type RecordServerContext, type RecordTagOptions, type RecordTimelineOptions, type RecordView, type RequireAalOptions, type RequireOptions, type ResendParams, type ResetPasswordParams, type ResourceAction, type ResourceContext, type ResourceHooks, type ResourceLoaderContext, type ResourceMap, type ResourceRouteOptions, type RouteOptions, type ScopeOptions, type SessionSnapshot, type SessionStaleOptions, type SignInCredentials, type SignInOptions, type SignInWithOtpParams, type SignOutParams, type SignOutScope, type SignUpParams, type SignedIn, type SupportOptions, type SupportPolicy, type SupportSessions, type SupportStartRequest, type SupportStarted, type SupportView, type TagOptions, type VerifyOtpParams, authzVersionOf, defineAction, isSessionSnapshot, issuedAtOf, safeRedirectPath, sessionCacheKey, supportOf, supportSessions, tagFor, tenantOf, toSession };
|
package/dist/next/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { t as DbException } from "../db-exception-Lngc1W49.js";
|
|
|
2
2
|
import { n as dbError } from "../errors-BVFgt8BZ.js";
|
|
3
3
|
import { t as isList } from "../guards-6F2bCtQR.js";
|
|
4
4
|
import { t as isStorageApi } from "../storage-api-Dg78Wqsg.js";
|
|
5
|
-
import { r as err } from "../result-ntFBW2p2.js";
|
|
5
|
+
import { a as ok, r as err } from "../result-ntFBW2p2.js";
|
|
6
6
|
import { o as isReadSet } from "../read-set-B1sDib5O.js";
|
|
7
7
|
import { n as validate } from "../standard-BA3mLh6w.js";
|
|
8
8
|
import { n as StatsRecorder, t as EMPTY_STATS } from "../stats-BHl1-zj9.js";
|
|
@@ -10,15 +10,16 @@ import { o as problemResponse } from "../problem-Bf0cJ7tk.js";
|
|
|
10
10
|
import { i as claimsOf } from "../claims-Bp9My7XP.js";
|
|
11
11
|
import { t as supportOf } from "../support-view-g4YLBeqX.js";
|
|
12
12
|
import { n as createBlockClient } from "../create-blocks-BfrDUSM6.js";
|
|
13
|
-
import { a as recordCan, c as recordWriteInput, i as plainData, l as runBindingWrite, o as recordPermissionKeys, p as loadBindings, r as findBindingWrite, s as recordSubject, t as bindingWrites } from "../record-type-
|
|
13
|
+
import { a as recordCan, c as recordWriteInput, i as plainData, l as runBindingWrite, o as recordPermissionKeys, p as loadBindings, r as findBindingWrite, s as recordSubject, t as bindingWrites } from "../record-type-BEUyEsFx.js";
|
|
14
14
|
import { n as methodOf } from "../block-method-C9hWdHom.js";
|
|
15
15
|
import { t as tenantOf } from "../tenant-BgIiMQpo.js";
|
|
16
|
-
import { t as loadTimeline } from "../timeline
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
16
|
+
import { t as loadTimeline } from "../timeline-Dz3hO2I6.js";
|
|
17
|
+
import { c as extendServer, n as flushEvents, p as supportCookieMaxAge, r as handle, s as createServer, t as bearerRequest, v as outageResponse, x as serverCore } from "../adapter-BTbj5N9C.js";
|
|
18
|
+
import { t as isPrefetch } from "../refresh-DLBgnxjL.js";
|
|
19
|
+
import { d as clearSessionAtScopes, g as sessionCookieName, t as clientIp, u as applyCookieWrites, v as writeSession } from "../resolve-B0mW2m7f.js";
|
|
20
|
+
import { a as isSessionSnapshot, f as checkAal, i as authzVersionOf, l as snapshotOf, n as toSession, o as issuedAtOf, r as authOfSnapshot, s as sessionCacheKey } from "../view-C8Ve14ja.js";
|
|
20
21
|
import { i as guard, n as defaultExpose, s as settle } from "../respond-CZMWbUs3.js";
|
|
21
|
-
import {
|
|
22
|
+
import { a as otpGrant, c as pkcePair, d as supportSessions, i as needsMfa, l as revokeSession, n as emailFlow, o as passwordGrant, r as mfaGrant, s as pkceGrant, t as authorizeUrlFor, u as safeRedirectPath } from "../sign-in-CuZ1Ag7O.js";
|
|
22
23
|
import { i as defineAction } from "../resource-BUJcZKiW.js";
|
|
23
24
|
import { r as tagFor, t as cacheTagsOf } from "../tags-CIZTqtlY.js";
|
|
24
25
|
import { i as requireCaller, n as formDataObject, t as authorizeCaller } from "../kit-Bcd9wYCV.js";
|
|
@@ -471,38 +472,190 @@ function resourceRoutes(serve) {
|
|
|
471
472
|
}
|
|
472
473
|
//#endregion
|
|
473
474
|
//#region src/next/sign-in.ts
|
|
475
|
+
/** How long the PKCE verifier cookie lives, in seconds. */
|
|
476
|
+
const VERIFIER_MAX_AGE = 600;
|
|
477
|
+
function refused(auth) {
|
|
478
|
+
return {
|
|
479
|
+
ok: false,
|
|
480
|
+
data: null,
|
|
481
|
+
error: auth.kind === "invalid" ? auth.error : dbError("unauthorized", "The new session did not verify")
|
|
482
|
+
};
|
|
483
|
+
}
|
|
474
484
|
/**
|
|
475
|
-
*
|
|
476
|
-
*
|
|
485
|
+
* The server-side sign-in and sign-out flows. Each runs one Auth call, then one
|
|
486
|
+
* commit: it verifies the new token, writes or clears the session cookies
|
|
487
|
+
* through the request's cookie jar, and publishes the session to later reads in
|
|
488
|
+
* the same request. The result carries no token: it crosses the action
|
|
489
|
+
* boundary, and the session is on the request's reads.
|
|
477
490
|
*/
|
|
478
|
-
|
|
479
|
-
const {
|
|
480
|
-
const
|
|
481
|
-
const
|
|
482
|
-
const
|
|
491
|
+
function authFlows(deps) {
|
|
492
|
+
const { auth } = deps;
|
|
493
|
+
const cookieName = () => auth?.cookie?.name ?? sessionCookieName(deps.env().url);
|
|
494
|
+
const verifierName = () => `${cookieName()}-code-verifier`;
|
|
495
|
+
const setVerifier = async (value, maxAge) => {
|
|
496
|
+
(await deps.jar()).set(verifierName(), value, {
|
|
497
|
+
path: "/",
|
|
498
|
+
...auth?.cookie?.options,
|
|
499
|
+
httpOnly: true,
|
|
500
|
+
sameSite: "lax",
|
|
501
|
+
maxAge
|
|
502
|
+
});
|
|
503
|
+
};
|
|
504
|
+
/** Writes a new PKCE verifier cookie and returns its challenge. */
|
|
505
|
+
const startPkce = async () => {
|
|
506
|
+
const { verifier, challenge } = await pkcePair();
|
|
507
|
+
await setVerifier(verifier, VERIFIER_MAX_AGE);
|
|
508
|
+
return challenge;
|
|
509
|
+
};
|
|
510
|
+
/** `redirectTo` with a same-origin `next` as `?next=`. */
|
|
511
|
+
const callbackUrl = (params) => {
|
|
512
|
+
const next = safeRedirectPath(params.next, "");
|
|
513
|
+
const target = new URL(params.redirectTo);
|
|
514
|
+
if (next) target.searchParams.set("next", next);
|
|
515
|
+
return target.href;
|
|
516
|
+
};
|
|
517
|
+
/** Starts an email flow; drops the verifier when Auth refuses it. */
|
|
518
|
+
const sendEmail = async (path, params, body) => {
|
|
519
|
+
const challenge = await startPkce();
|
|
520
|
+
const sent = await emailFlow(path, {
|
|
521
|
+
body,
|
|
522
|
+
redirectTo: callbackUrl(params),
|
|
523
|
+
challenge
|
|
524
|
+
}, await grantOptions());
|
|
525
|
+
if (!sent.ok) await setVerifier("", 0);
|
|
526
|
+
return sent;
|
|
527
|
+
};
|
|
528
|
+
const requested = (sent) => sent.ok ? {
|
|
529
|
+
ok: true,
|
|
530
|
+
data: null,
|
|
531
|
+
error: null
|
|
532
|
+
} : sent;
|
|
533
|
+
const grantOptions = async () => {
|
|
534
|
+
const env = deps.env();
|
|
535
|
+
const secretKey = env.secretKey;
|
|
536
|
+
const ip = secretKey && auth?.clientIp !== false ? (auth?.clientIp ?? clientIp)(await deps.request()) : void 0;
|
|
537
|
+
return {
|
|
538
|
+
url: env.url,
|
|
539
|
+
publishableKey: env.publishableKey,
|
|
540
|
+
...secretKey && ip ? { forwardedFor: {
|
|
541
|
+
ip,
|
|
542
|
+
secretKey
|
|
543
|
+
} } : {},
|
|
544
|
+
...auth?.fetch ? { fetch: auth.fetch } : {},
|
|
545
|
+
...auth?.refreshTimeoutMs === void 0 ? {} : { timeoutMs: auth.refreshTimeoutMs }
|
|
546
|
+
};
|
|
547
|
+
};
|
|
548
|
+
/** Verifies, writes the cookies and publishes `stored` (`null` clears). */
|
|
549
|
+
const commit = async (granted, next, options) => {
|
|
550
|
+
if (!granted.ok) return granted;
|
|
551
|
+
const stored = granted.data;
|
|
552
|
+
const resolution = await deps.verify(stored?.access_token ?? null);
|
|
553
|
+
if (stored && resolution.auth.kind !== "user") return refused(resolution.auth);
|
|
554
|
+
const jar = await deps.jar();
|
|
555
|
+
const existing = jar.getAll();
|
|
556
|
+
const writes = [...writeSession(existing, cookieName(), stored, auth?.cookie?.options, auth?.cookie?.encode === void 0 ? {} : { encode: auth.cookie.encode }), ...stored ? [] : clearSessionAtScopes(existing, cookieName(), deps.cookieScopes ?? [])];
|
|
557
|
+
for (const write of writes) jar.set(write.name, write.value, write.options);
|
|
558
|
+
const headers = new Headers((await deps.request()).headers);
|
|
559
|
+
headers.set("cookie", applyCookieWrites(existing, writes).map((cookie) => `${cookie.name}=${encodeURIComponent(cookie.value)}`).join("; "));
|
|
560
|
+
await deps.publish(resolution, new Request("http://next.local/", { headers }));
|
|
561
|
+
return {
|
|
562
|
+
ok: true,
|
|
563
|
+
data: {
|
|
564
|
+
redirectTo: safeRedirectPath(next, options.fallback ?? "/"),
|
|
565
|
+
mfa: stored !== null && needsMfa(stored) && snapshotOf(resolution.auth)?.claims["aal"] !== "aal2",
|
|
566
|
+
user: resolution.auth.kind === "user" ? resolution.auth.user : null
|
|
567
|
+
},
|
|
568
|
+
error: null
|
|
569
|
+
};
|
|
570
|
+
};
|
|
571
|
+
const signIn = async (credentials, options = {}) => commit(await passwordGrant({
|
|
483
572
|
email: credentials.email,
|
|
484
573
|
password: credentials.password
|
|
485
|
-
},
|
|
486
|
-
url: env.url,
|
|
487
|
-
publishableKey: env.publishableKey,
|
|
488
|
-
...secretKey && ip ? { forwardedFor: {
|
|
489
|
-
ip,
|
|
490
|
-
secretKey
|
|
491
|
-
} } : {},
|
|
492
|
-
...auth?.fetch ? { fetch: auth.fetch } : {},
|
|
493
|
-
...auth?.refreshTimeoutMs === void 0 ? {} : { timeoutMs: auth.refreshTimeoutMs }
|
|
494
|
-
});
|
|
495
|
-
if (!granted.ok) return granted;
|
|
496
|
-
const writes = writeSession(deps.jar.getAll(), auth?.cookie?.name ?? sessionCookieName(env.url), granted.data, auth?.cookie?.options, auth?.cookie?.encode === void 0 ? {} : { encode: auth.cookie.encode });
|
|
497
|
-
for (const write of writes) deps.jar.set(write.name, write.value, write.options);
|
|
498
|
-
await deps.seed(granted.data.access_token);
|
|
574
|
+
}, await grantOptions()), credentials.next, options);
|
|
499
575
|
return {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
576
|
+
signIn,
|
|
577
|
+
verifyOtp: async (params, options = {}) => commit(await otpGrant(params, await grantOptions()), params.next, options),
|
|
578
|
+
async authorizeUrl(params) {
|
|
579
|
+
const challenge = await startPkce();
|
|
580
|
+
return { url: authorizeUrlFor(deps.env().url, {
|
|
581
|
+
...params,
|
|
582
|
+
redirectTo: callbackUrl(params)
|
|
583
|
+
}, challenge) };
|
|
504
584
|
},
|
|
505
|
-
|
|
585
|
+
async signInWithOtp(params) {
|
|
586
|
+
return requested(await sendEmail("otp", params, {
|
|
587
|
+
email: params.email,
|
|
588
|
+
create_user: params.shouldCreateUser ?? true,
|
|
589
|
+
data: params.data ?? {}
|
|
590
|
+
}));
|
|
591
|
+
},
|
|
592
|
+
async resetPasswordForEmail(params) {
|
|
593
|
+
return requested(await sendEmail("recover", params, { email: params.email }));
|
|
594
|
+
},
|
|
595
|
+
async signUp(params, options = {}) {
|
|
596
|
+
const sent = await sendEmail("signup", params, {
|
|
597
|
+
email: params.email,
|
|
598
|
+
password: params.password,
|
|
599
|
+
data: params.data ?? {}
|
|
600
|
+
});
|
|
601
|
+
if (!sent.ok || sent.data === null) return requested(sent);
|
|
602
|
+
await setVerifier("", 0);
|
|
603
|
+
return commit(sent, params.next, options);
|
|
604
|
+
},
|
|
605
|
+
async resend(params) {
|
|
606
|
+
return requested(await sendEmail("resend", params, {
|
|
607
|
+
email: params.email,
|
|
608
|
+
type: params.type
|
|
609
|
+
}));
|
|
610
|
+
},
|
|
611
|
+
async exchangeCode(params, options = {}) {
|
|
612
|
+
const verifier = (await deps.jar()).getAll().find((cookie) => cookie.name === verifierName())?.value;
|
|
613
|
+
await setVerifier("", 0);
|
|
614
|
+
if (!verifier) return {
|
|
615
|
+
ok: false,
|
|
616
|
+
data: null,
|
|
617
|
+
error: dbError("unauthorized", "Code exchange failed", { code: "code_verifier_missing" })
|
|
618
|
+
};
|
|
619
|
+
return commit(await pkceGrant({
|
|
620
|
+
code: params.code,
|
|
621
|
+
verifier
|
|
622
|
+
}, await grantOptions()), params.next, options);
|
|
623
|
+
},
|
|
624
|
+
async verifyMfa(params, options = {}) {
|
|
625
|
+
const current = await deps.current();
|
|
626
|
+
if (!current) return {
|
|
627
|
+
ok: false,
|
|
628
|
+
data: null,
|
|
629
|
+
error: dbError("unauthorized", "MFA verification needs a session")
|
|
630
|
+
};
|
|
631
|
+
return commit(await mfaGrant({
|
|
632
|
+
accessToken: current.accessToken,
|
|
633
|
+
factorId: params.factorId,
|
|
634
|
+
code: params.code
|
|
635
|
+
}, await grantOptions()), params.next, options);
|
|
636
|
+
},
|
|
637
|
+
async signOut(params = {}, options = {}) {
|
|
638
|
+
const scope = params.scope ?? "local";
|
|
639
|
+
const current = await deps.current();
|
|
640
|
+
if (current) {
|
|
641
|
+
const revoked = await revokeSession(current.accessToken, scope, await grantOptions());
|
|
642
|
+
if (!revoked.ok) return revoked;
|
|
643
|
+
}
|
|
644
|
+
if (current) deps.signedOut(current.userId);
|
|
645
|
+
if (scope === "others") {
|
|
646
|
+
const kept = current ? authOfSnapshot(current) : void 0;
|
|
647
|
+
return {
|
|
648
|
+
ok: true,
|
|
649
|
+
data: {
|
|
650
|
+
redirectTo: safeRedirectPath(params.next, options.fallback ?? "/"),
|
|
651
|
+
mfa: false,
|
|
652
|
+
user: kept?.kind === "user" ? kept.user : null
|
|
653
|
+
},
|
|
654
|
+
error: null
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
return commit(ok(null), params.next, options);
|
|
658
|
+
}
|
|
506
659
|
};
|
|
507
660
|
}
|
|
508
661
|
//#endregion
|
|
@@ -617,7 +770,19 @@ function createNext(betterSupabase, options = {}) {
|
|
|
617
770
|
const jar = await cookies();
|
|
618
771
|
for (const write of writes) jar.set(write.name, write.value, write.options);
|
|
619
772
|
};
|
|
620
|
-
|
|
773
|
+
/**
|
|
774
|
+
* The incoming request, with the cookie header rebuilt from the cookie jar:
|
|
775
|
+
* in a Server Action or a route handler the jar already holds this request's
|
|
776
|
+
* writes (a sign-in, a sign-out), and the header never does.
|
|
777
|
+
*/
|
|
778
|
+
const incomingRequest = async () => {
|
|
779
|
+
const [incomingHeaders, jar] = await Promise.all([headers(), cookies()]);
|
|
780
|
+
const forwarded = new Headers(incomingHeaders);
|
|
781
|
+
const cookie = jar.getAll().map(({ name, value }) => `${name}=${encodeURIComponent(value)}`).join("; ");
|
|
782
|
+
if (cookie === "") forwarded.delete("cookie");
|
|
783
|
+
else forwarded.set("cookie", cookie);
|
|
784
|
+
return new Request("http://next.local/", { headers: forwarded });
|
|
785
|
+
};
|
|
621
786
|
/**
|
|
622
787
|
* The incoming request, once its dynamic APIs are awaited. Auth reads cookies
|
|
623
788
|
* and then the clock: `io()` marks that as I/O for Cache Components without
|
|
@@ -635,10 +800,21 @@ function createNext(betterSupabase, options = {}) {
|
|
|
635
800
|
});
|
|
636
801
|
};
|
|
637
802
|
/**
|
|
803
|
+
* The request's auth generation. A sign-in or sign-out in the request bumps
|
|
804
|
+
* it and stores the committed session, so the cached reads below miss once
|
|
805
|
+
* and answer from it; a render that never commits keys every read on 0.
|
|
806
|
+
*/
|
|
807
|
+
const box = cache(() => ({
|
|
808
|
+
generation: 0,
|
|
809
|
+
committed: void 0
|
|
810
|
+
}));
|
|
811
|
+
/**
|
|
638
812
|
* One token verification per render scope backs `context()`, `session()` and
|
|
639
813
|
* `cached()`.
|
|
640
814
|
*/
|
|
641
|
-
const
|
|
815
|
+
const incomingAt = cache(async (_generation) => {
|
|
816
|
+
const committed = box().committed;
|
|
817
|
+
if (committed) return committed;
|
|
642
818
|
const request = await requestScope();
|
|
643
819
|
await base.snapshot(request);
|
|
644
820
|
return {
|
|
@@ -646,7 +822,12 @@ function createNext(betterSupabase, options = {}) {
|
|
|
646
822
|
resolution: await base.resolve(request, { refresh: false })
|
|
647
823
|
};
|
|
648
824
|
});
|
|
649
|
-
const
|
|
825
|
+
const incoming = () => incomingAt(box().generation);
|
|
826
|
+
const getRequestSessionAt = cache(async (_generation) => {
|
|
827
|
+
const committed = box().committed;
|
|
828
|
+
return committed ? snapshotOf(committed.resolution.auth) : base.snapshot(await requestScope());
|
|
829
|
+
});
|
|
830
|
+
const getRequestSession = () => getRequestSessionAt(box().generation);
|
|
650
831
|
const tenantClaim = claimsOf(betterSupabase.meta).tenant;
|
|
651
832
|
/** The tenant `scoped` resolved for a context, when it wasn't the claim. */
|
|
652
833
|
const scopedTenants = /* @__PURE__ */ new WeakMap();
|
|
@@ -657,7 +838,7 @@ function createNext(betterSupabase, options = {}) {
|
|
|
657
838
|
*/
|
|
658
839
|
const authorizeCaller$1 = (ctx, checks, input) => authorizeCaller(ctx.auth, checks, input, tenantFor(ctx, toSession(ctx.auth)), base.authorizer, ctx);
|
|
659
840
|
/** `null` runs `NextOptions.tenant`; a string is the caller's explicit tenant. */
|
|
660
|
-
const
|
|
841
|
+
const scopedAt = cache(async (explicit, _generation) => {
|
|
661
842
|
const { request, resolution } = await incoming();
|
|
662
843
|
const [tenant, support] = await Promise.all([explicit ?? options.tenant?.(request, resolution.auth), base.support.current(request, resolution.auth)]);
|
|
663
844
|
const ctx = core.context(resolution, request, {
|
|
@@ -667,10 +848,11 @@ function createNext(betterSupabase, options = {}) {
|
|
|
667
848
|
if (tenant !== void 0) scopedTenants.set(ctx, tenant);
|
|
668
849
|
return ctx;
|
|
669
850
|
});
|
|
670
|
-
const current = (tenant) =>
|
|
851
|
+
const current = (tenant) => scopedAt(tenant ?? null, box().generation);
|
|
671
852
|
const context = (first, contextOptions) => first instanceof Request ? base.context(first, contextOptions) : current(first?.tenant ?? contextOptions?.tenant);
|
|
672
853
|
/** In a support session, the target's view: `impersonator` names the admin. */
|
|
673
|
-
const
|
|
854
|
+
const sessionAt = cache(async (_generation) => toSession(options.support ? (await current()).auth : (await incoming()).resolution.auth));
|
|
855
|
+
const session = () => sessionAt(box().generation);
|
|
674
856
|
const supportCookieName = options.support?.options.cookie?.name ?? "bsb-support";
|
|
675
857
|
const supportCookieOptions = {
|
|
676
858
|
httpOnly: true,
|
|
@@ -706,6 +888,28 @@ function createNext(betterSupabase, options = {}) {
|
|
|
706
888
|
return result;
|
|
707
889
|
}))
|
|
708
890
|
});
|
|
891
|
+
const flows = authFlows({
|
|
892
|
+
env: () => base.env,
|
|
893
|
+
auth: options.auth,
|
|
894
|
+
cookieScopes: options.cookieScopes,
|
|
895
|
+
request: incomingRequest,
|
|
896
|
+
jar: cookies,
|
|
897
|
+
current: getRequestSession,
|
|
898
|
+
verify: (token) => base.resolve(bearerRequest(token)),
|
|
899
|
+
async publish(resolution, request) {
|
|
900
|
+
await base.sessions.seed(resolution.auth);
|
|
901
|
+
const scope = box();
|
|
902
|
+
scope.committed = {
|
|
903
|
+
request,
|
|
904
|
+
resolution
|
|
905
|
+
};
|
|
906
|
+
scope.generation += 1;
|
|
907
|
+
},
|
|
908
|
+
signedOut: (userId) => {
|
|
909
|
+
invalidateAll([sessionTag(userId)]);
|
|
910
|
+
forget(userId);
|
|
911
|
+
}
|
|
912
|
+
});
|
|
709
913
|
const next = extendServer(withAccounts, {
|
|
710
914
|
session,
|
|
711
915
|
getRequestSession,
|
|
@@ -971,19 +1175,8 @@ function createNext(betterSupabase, options = {}) {
|
|
|
971
1175
|
error: stopped.error
|
|
972
1176
|
};
|
|
973
1177
|
},
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
return signInWithPassword(credentials, signInOptions, {
|
|
977
|
-
env: base.env,
|
|
978
|
-
auth: options.auth,
|
|
979
|
-
request,
|
|
980
|
-
jar: await cookies(),
|
|
981
|
-
seed: async (accessToken) => {
|
|
982
|
-
const verified = await base.resolve(bearerRequest(accessToken));
|
|
983
|
-
await base.sessions.seed(verified.auth);
|
|
984
|
-
}
|
|
985
|
-
});
|
|
986
|
-
},
|
|
1178
|
+
...flows,
|
|
1179
|
+
signInWithPassword: (credentials, signInOptions) => flows.signIn(credentials, signInOptions),
|
|
987
1180
|
cacheTag(table, id, tagOptions = {}) {
|
|
988
1181
|
cacheTag(...tableTags(table, tagOptions), ...id === void 0 ? [] : [tagFor(table, id)]);
|
|
989
1182
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as AuthorizationOperation } from "./authorization-
|
|
1
|
+
import { r as AuthorizationOperation } from "./authorization-DfEkyFt_.js";
|
|
2
2
|
//#region src/core/operations.d.ts
|
|
3
3
|
/** Operations by name, as `authorization.operations` or a module's own defaults. */
|
|
4
4
|
type OperationTable = Readonly<Record<string, AuthorizationOperation>>;
|