better-supabase 0.15.1 → 0.16.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/{ai-schedules-D_Hz-ik5.d.ts → ai-schedules-BmkARmQ9.d.ts} +1 -1
- package/dist/{api-DxAPqMrE.d.ts → api-hHwieEfz.d.ts} +1 -1
- package/dist/{app-tables-CbCFSXLG.d.ts → app-tables-yMQ4ubyY.d.ts} +1 -1
- package/dist/astro/index.d.ts +4 -4
- package/dist/{auth-module-BEFESDC4.js → auth-module-BbmX-N4L.js} +12 -4
- package/dist/better-result/index.d.ts +2 -2
- package/dist/{bind-h5jre2K0.d.ts → bind-JGCPGUJh.d.ts} +4 -4
- package/dist/{block-env-BrfRvPrj.d.ts → block-env-y65GF_px.d.ts} +4 -4
- package/dist/blocks/access-requests/index.d.ts +1 -1
- package/dist/blocks/activities/index.d.ts +1 -1
- package/dist/blocks/agents/index.d.ts +1 -1
- package/dist/blocks/ai-cache/index.d.ts +1 -1
- package/dist/blocks/ai-chat/index.d.ts +4 -4
- package/dist/blocks/ai-files/index.d.ts +1 -1
- package/dist/blocks/ai-keys/index.d.ts +1 -1
- package/dist/blocks/ai-schedules/index.d.ts +2 -2
- package/dist/blocks/announcements/index.d.ts +4 -4
- package/dist/blocks/api-keys/index.d.ts +2 -2
- package/dist/blocks/approvals/index.d.ts +1 -1
- package/dist/blocks/assets/index.d.ts +1 -1
- package/dist/blocks/assignment/index.d.ts +1 -1
- package/dist/blocks/attachments/index.d.ts +2 -2
- package/dist/blocks/audit/index.d.ts +5 -5
- package/dist/blocks/automations/index.d.ts +3 -3
- package/dist/blocks/billable-time/index.d.ts +1 -1
- package/dist/blocks/billing/index.d.ts +3 -3
- package/dist/blocks/bookings/index.d.ts +2 -2
- package/dist/blocks/bulk/index.d.ts +1 -1
- package/dist/blocks/calendar/index.d.ts +2 -2
- package/dist/blocks/catalog/index.d.ts +1 -1
- package/dist/blocks/channels/index.d.ts +1 -1
- package/dist/blocks/collections/index.d.ts +1 -1
- package/dist/blocks/comments/index.d.ts +4 -4
- package/dist/blocks/compliance/index.d.ts +1 -1
- package/dist/blocks/connectors/index.d.ts +1 -1
- package/dist/blocks/contacts/index.d.ts +1 -1
- package/dist/blocks/content/index.d.ts +1 -1
- package/dist/blocks/contracts/index.d.ts +1 -1
- package/dist/blocks/courses/index.d.ts +1 -1
- package/dist/blocks/created-by/index.d.ts +1 -1
- package/dist/blocks/custom-fields/index.d.ts +1 -1
- package/dist/blocks/data-lifecycle/index.d.ts +1 -1
- package/dist/blocks/deals/index.d.ts +1 -1
- package/dist/blocks/dispatch/index.d.ts +1 -1
- package/dist/blocks/documents/index.d.ts +1 -1
- package/dist/blocks/domains/index.d.ts +1 -1
- package/dist/blocks/donations/index.d.ts +1 -1
- package/dist/blocks/drive/index.d.ts +1 -1
- package/dist/blocks/employees/index.d.ts +2 -2
- package/dist/blocks/enrichment/index.d.ts +1 -1
- package/dist/blocks/enrollments/index.d.ts +1 -1
- package/dist/blocks/entitlements/index.d.ts +3 -3
- package/dist/blocks/expenses/index.d.ts +1 -1
- package/dist/blocks/field-history/index.d.ts +1 -1
- package/dist/blocks/flags/index.d.ts +1 -1
- package/dist/blocks/forecasts/index.d.ts +1 -1
- package/dist/blocks/forms/index.d.ts +2 -2
- package/dist/blocks/goals/index.d.ts +1 -1
- package/dist/blocks/guests/index.d.ts +1 -1
- package/dist/blocks/hiring/index.d.ts +1 -1
- package/dist/blocks/identities/index.d.ts +1 -1
- package/dist/blocks/imports/index.d.ts +1 -1
- package/dist/blocks/inbox/index.d.ts +5 -5
- package/dist/blocks/incidents/index.d.ts +1 -1
- package/dist/blocks/index.d.ts +2 -2
- package/dist/blocks/inventory/index.d.ts +1 -1
- package/dist/blocks/invoices/index.d.ts +1 -1
- package/dist/blocks/knowledge/index.d.ts +1 -1
- package/dist/blocks/lead-scoring/index.d.ts +1 -1
- package/dist/blocks/leases/index.d.ts +1 -1
- package/dist/blocks/leave/index.d.ts +1 -1
- package/dist/blocks/ledger/index.d.ts +1 -1
- package/dist/blocks/mail-sync/index.d.ts +1 -1
- package/dist/blocks/memberships/index.d.ts +1 -1
- package/dist/blocks/memory/index.d.ts +1 -1
- package/dist/blocks/messaging/index.d.ts +4 -4
- package/dist/blocks/metrics/index.d.ts +1 -1
- package/dist/blocks/mfa/index.d.ts +2 -2
- package/dist/blocks/moderation/index.d.ts +1 -1
- package/dist/blocks/notifications/index.d.ts +4 -4
- package/dist/blocks/numbering/index.d.ts +1 -1
- package/dist/blocks/oauth-server/index.d.ts +1 -1
- package/dist/blocks/onboarding/index.d.ts +2 -2
- package/dist/blocks/orders/index.d.ts +2 -2
- package/dist/blocks/organizations/index.d.ts +2 -2
- package/dist/blocks/outbox/index.d.ts +1 -1
- package/dist/blocks/passes/index.d.ts +1 -1
- package/dist/blocks/permissions/index.d.ts +3 -3
- package/dist/blocks/pipelines/index.d.ts +1 -1
- package/dist/blocks/posts/index.d.ts +1 -1
- package/dist/blocks/profiles/index.d.ts +1 -1
- package/dist/blocks/promotions/index.d.ts +1 -1
- package/dist/blocks/push/index.d.ts +2 -2
- package/dist/blocks/queue/index.d.ts +29 -2
- package/dist/blocks/queue/index.js +1 -1
- package/dist/blocks/quotes/index.d.ts +1 -1
- package/dist/blocks/rank/index.d.ts +1 -1
- package/dist/blocks/reactions/index.d.ts +4 -4
- package/dist/blocks/relations/index.d.ts +1 -1
- package/dist/blocks/reminders/index.d.ts +1 -1
- package/dist/blocks/reviews/index.d.ts +1 -1
- package/dist/blocks/saved-views/index.d.ts +3 -3
- package/dist/blocks/scores/index.d.ts +1 -1
- package/dist/blocks/search/index.d.ts +3 -3
- package/dist/blocks/security-events/index.d.ts +1 -1
- package/dist/blocks/segments/index.d.ts +1 -1
- package/dist/blocks/sequences/index.d.ts +1 -1
- package/dist/blocks/service-accounts/index.d.ts +1 -1
- package/dist/blocks/sessions/index.d.ts +2 -2
- package/dist/blocks/settings/index.d.ts +2 -2
- package/dist/blocks/share-links/index.d.ts +1 -1
- package/dist/blocks/shipments/index.d.ts +1 -1
- package/dist/blocks/signatures/index.d.ts +1 -1
- package/dist/blocks/signing-keys/index.d.ts +1 -1
- package/dist/blocks/sla/index.d.ts +1 -1
- package/dist/blocks/sso/index.d.ts +1 -1
- package/dist/blocks/state-machine/index.d.ts +1 -1
- package/dist/blocks/subjects/index.d.ts +2 -2
- package/dist/blocks/tags/index.d.ts +2 -2
- package/dist/blocks/tasks/index.d.ts +2 -2
- package/dist/blocks/teams/index.d.ts +1 -1
- package/dist/blocks/templates/index.d.ts +1 -1
- package/dist/blocks/time-tracking/index.d.ts +1 -1
- package/dist/blocks/timeline/index.d.ts +3 -3
- package/dist/blocks/trash/index.d.ts +1 -1
- package/dist/blocks/undo/index.d.ts +2 -2
- package/dist/blocks/updated-at/index.d.ts +1 -1
- package/dist/blocks/usage/index.d.ts +2 -2
- package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
- package/dist/blocks/versions/index.d.ts +1 -1
- package/dist/blocks/waitlist/index.d.ts +1 -1
- package/dist/blocks/webhooks/index.d.ts +2 -2
- package/dist/blocks/webhooks/index.js +1 -1
- package/dist/blocks/workflow-editor/index.d.ts +4 -4
- package/dist/blocks/workflows/index.d.ts +4 -4
- package/dist/{bucket-CiNi8sIw.d.ts → bucket-vc-QRrva.d.ts} +40 -1
- package/dist/cli/add-Bfb_ISrO.js +1 -0
- package/dist/cli/{add-DNOL9PDu.js → add-D7TkPdco.js} +9 -9
- package/dist/cli/{add-C04vkBk9.js → add-I8OW-qJH.js} +2 -2
- package/dist/cli/{backfill-VFzf-TJP.js → backfill-DIz5DnlQ.js} +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/{blocks-Bn7WUca5.js → blocks-Bp5RPoft.js} +1 -1
- package/dist/cli/{blocks-Cb7mILFU.js → blocks-xk-SE8gS.js} +1 -1
- package/dist/cli/{cache-DkplpIGe.js → cache-AznIssjI.js} +1 -1
- package/dist/cli/{codemod-BbaE5dL_.js → codemod-Aewxza6i.js} +1 -1
- package/dist/cli/{content-mapper-Cdx6arxu.js → content-mapper-DCrz6OIv.js} +2 -2
- package/dist/cli/{doctor-C-VO-QQ2.js → doctor-DkOSLPEQ.js} +13 -13
- package/dist/cli/{gen-yRHOHW1b.js → gen-CFkYUnWq.js} +10 -10
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +6 -6
- package/dist/cli/{init-BOw0SX65.js → init-CHj9ad4S.js} +5 -5
- package/dist/cli/{live-Lmg-hYyO.js → live-DGdLR41j.js} +2 -2
- package/dist/cli/{mcp-DQ1zR2eA.js → mcp-BZno503V.js} +2 -2
- package/dist/cli/{metadata-CZaxkv21.js → metadata-BfgHMe4q.js} +3 -3
- package/dist/cli/{migration-safety-BbhLu2fo.js → migration-safety-BnnXPAro.js} +1 -1
- package/dist/cli/{module-migration-DOn6EmNz.js → module-migration-O_IxewFs.js} +1 -1
- package/dist/cli/{print-D_xf8PPj.js → print-DosQIFSy.js} +1 -1
- package/dist/cli/{remove-BY_TOTRj.js → remove-DK2G_KHm.js} +5 -5
- package/dist/cli/{render-lJmHr0y9.js → render-5y5a1QZr.js} +3 -3
- package/dist/cli/{run-BJ6IMs_H.js → run-Bs4OKdDI.js} +7 -7
- package/dist/cli/{run-DkB0fhc9.js → run-MRET30vh.js} +20 -20
- package/dist/cli/{shared-Bh-6IqJS.js → shared-BLqbvY2x.js} +1 -1
- package/dist/cli/{snapshot-Bzcigm7T.js → snapshot-uTUlEzY2.js} +2 -2
- package/dist/cli/{source-WoLdcQzN.js → source-D2gJHKwC.js} +1 -1
- package/dist/cli/{spec-CZMiLhv_.js → spec-Cm2einTO.js} +2 -2
- package/dist/cli/{spec-BF_dpwzW.js → spec-DUjOtciN.js} +1 -1
- package/dist/cli/{sql-layout-rFP0oq1N.js → sql-layout-lUWenjJw.js} +2 -2
- package/dist/cli/{sync-mANmYYoL.js → sync-CZMRB3aU.js} +2 -2
- package/dist/cli/{upgrade-B0Q9wMs-.js → upgrade-BFEIMC7U.js} +3 -3
- package/dist/cli/{upgrade-BrNLt92u.js → upgrade-fVsJniXm.js} +2 -2
- package/dist/cli/{version-CyavsyGA.js → version-B2Dr6VmJ.js} +1 -1
- package/dist/client/index.d.ts +5 -5
- package/dist/client/index.js +1 -1
- package/dist/client/native/index.d.ts +5 -5
- package/dist/client/native/index.js +1 -1
- package/dist/{client-BAEbEA7t.js → client-C_mlji5R.js} +6 -5
- package/dist/{composite-BZYXlVBN.d.ts → composite-CfYyU3vs.d.ts} +4 -3
- package/dist/config/index.d.ts +1 -1
- package/dist/{context-TGX2eDS5.d.ts → context-8kb8m5uO.d.ts} +1 -1
- package/dist/{controller-DyPPMFSw.d.ts → controller-BW-5Opig.d.ts} +1 -1
- package/dist/{conversion-O-kyhXcC.d.ts → conversion-3iv2r7YC.d.ts} +1 -1
- package/dist/create/index.d.ts +2 -2
- package/dist/create/index.js +1 -1
- package/dist/{define-DFBnQyYg.d.ts → define-C5AcEkEJ.d.ts} +1 -1
- package/dist/{define-block-DvvcM54N.d.ts → define-block-C1RHXz7L.d.ts} +2 -2
- package/dist/edge/index.d.ts +5 -5
- package/dist/{entitlements-BnhDBxLW.d.ts → entitlements-sO977DO-.d.ts} +1 -1
- package/dist/{executor-CVIn6JHa.d.ts → executor-BcNWcD-4.d.ts} +2 -2
- package/dist/expo/index.d.ts +2 -2
- package/dist/{field-errors-DYtg1mwv.d.ts → field-errors-Dt86dCKk.d.ts} +12 -12
- package/dist/{framework-h5lP_5yj.d.ts → framework-BGdZVyPL.d.ts} +3 -3
- package/dist/hono/index.d.ts +4 -4
- package/dist/{index-BAHGLvGD.d.ts → index-CENWq3zb.d.ts} +1 -1
- package/dist/{index-Do2ChN_y.d.ts → index-CQhPHHDF.d.ts} +20 -2
- package/dist/{index-DN9mfmhA.d.ts → index-CTu-3fJB.d.ts} +51 -3
- package/dist/{index-BfK6olKm.d.ts → index-Cc4mIQS8.d.ts} +2 -2
- package/dist/{index-BfkltrGJ.d.ts → index-CcAmFNVi.d.ts} +2 -2
- package/dist/{index-Ab4UeEn_.d.ts → index-Craf712U.d.ts} +44 -12
- package/dist/{index-B4gcStOz.d.ts → index-DZKCc2WM.d.ts} +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/list/index.d.ts +1 -1
- package/dist/{list-query-BDVutLFr.d.ts → list-query-DYhgRTd5.d.ts} +1 -1
- package/dist/mapper/bin.js +5 -5
- package/dist/mcp/index.d.ts +3 -3
- package/dist/mcp/sdk/index.d.ts +2 -2
- package/dist/next/client/index.d.ts +81 -1
- package/dist/next/client/index.js +178 -2
- package/dist/next/index.d.ts +15 -14
- package/dist/orpc/index.d.ts +4 -4
- package/dist/otel/index.js +4 -4
- package/dist/{ports-DOhtuw3c.js → ports-CaVRXjxq.js} +1 -1
- package/dist/{ports-CpdiQv1D.d.ts → ports-mObLgH1z.d.ts} +1 -1
- package/dist/powersync/index.d.ts +2 -2
- package/dist/preset/index.d.ts +3 -3
- package/dist/{push-token-B3m3pWAv.d.ts → push-token-BSSvsWXZ.d.ts} +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/{rate-limit-o44SYkVY.js → rate-limit-Dt9vAY4E.js} +53 -0
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +3 -3
- package/dist/react/native/index.d.ts +1 -1
- package/dist/react/native/index.js +1 -1
- package/dist/react/server.d.ts +12 -7
- package/dist/react/server.js +8 -3
- package/dist/react/session.d.ts +5 -0
- package/dist/react/session.js +9 -1
- package/dist/{react-BuDYI62C.js → react-CZUZYn9E.js} +41 -4
- package/dist/react-router/index.d.ts +3 -3
- package/dist/realtime/index.d.ts +5 -5
- package/dist/realtime/index.js +2 -1
- package/dist/{record-form-DB_5Ue_B.d.ts → record-form-D9ILuVtA.d.ts} +1 -1
- package/dist/records/index.d.ts +7 -7
- package/dist/relay-gKvKJ3xf.js +208 -0
- package/dist/{resource-execute-CzHuDsil.d.ts → resource-execute-Cpnob1Vj.d.ts} +1 -1
- package/dist/{resource-types-DnKiH4G2.d.ts → resource-types-pMeLs68X.d.ts} +1 -1
- package/dist/{resources-B9cQxhjw.d.ts → resources-7iq2-5_A.d.ts} +1 -1
- package/dist/server/index.d.ts +147 -9
- package/dist/server/index.js +396 -1
- package/dist/{server-types-7QPzW2bF.d.ts → server-types-CK8mUIUT.d.ts} +5 -354
- package/dist/{session-CfBCJGgc.d.ts → session-DWmFv3vB.d.ts} +2 -1
- package/dist/session-status-qQLm7jzh.d.ts +82 -0
- package/dist/{sign-in-BsIaNx2C.js → sign-in-CmPK1AgM.js} +20 -10
- package/dist/solid/index.d.ts +7 -7
- package/dist/solid/index.js +1 -1
- package/dist/solid-start/index.d.ts +3 -3
- package/dist/spec/index.d.ts +1 -1
- package/dist/sql/index.d.ts +3 -3
- package/dist/sql/index.js +1 -1
- package/dist/{sql-OLVW4t08.js → sql-Dl3Alk43.js} +127 -0
- package/dist/sqlite/index.d.ts +1 -1
- package/dist/ssr/index.d.ts +1 -1
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +54 -1
- package/dist/support-B4ZBVxt3.d.ts +357 -0
- package/dist/svelte/index.d.ts +7 -7
- package/dist/svelte/index.js +1 -1
- package/dist/sveltekit/index.d.ts +4 -4
- package/dist/{tags-BjHflcHF.d.ts → tags-qvVk79pp.d.ts} +1 -1
- package/dist/tanstack-db/index.d.ts +1 -1
- package/dist/tanstack-start/index.d.ts +3 -3
- package/dist/{tenant-DzFsg0Pc.d.ts → tenant-DOKIJI62.d.ts} +1 -1
- package/dist/testing/index.d.ts +8 -7
- package/dist/{timeline-WrFMgd3U.d.ts → timeline-CvTuXYvn.d.ts} +3 -3
- package/dist/{topic-DNFEFGKI.d.ts → topic-CZXHhZye.d.ts} +2 -2
- package/dist/{verify-CMou8dWZ.d.ts → verify-CjvNLY7N.d.ts} +1 -1
- package/dist/vue/index.d.ts +7 -7
- package/dist/vue/index.js +1 -1
- package/dist/{watch-topic-Bo9S2R4P.d.ts → watch-topic-BAxoPKZx.d.ts} +1 -1
- package/dist/yjs/index.d.ts +1 -1
- package/package.json +1 -1
- package/skills/better-supabase-api/SKILL.md +3 -1
- package/skills/better-supabase-auth/SKILL.md +7 -0
- package/dist/cli/add-CUH0rORo.js +0 -1
|
@@ -6,16 +6,15 @@ import { o as EnvSource, t as BetterSupabaseEnv } from "./index-NRMMhhEi.js";
|
|
|
6
6
|
import { a as ResolveAuthOptions, m as CookieWrite, o as ResolvePhase, r as AuthState, t as AuthResolution } from "./resolve-CXX6DHv3.js";
|
|
7
7
|
import { r as CredentialProvider } from "./provider-CqwEOLCA.js";
|
|
8
8
|
import { n as SqlClient } from "./executor-hGjrop3A.js";
|
|
9
|
-
import { a as ProblemFormat } from "./problem-DNwN8iGz.js";
|
|
10
9
|
import { c as AuthzVersionCache, t as AnyAuthorizer, u as RequestMemo } from "./authorizer-B6X09otb.js";
|
|
11
|
-
import { J as DbStats, X as StatsRecorder, t as BetterSupabase, v as Db } from "./define-
|
|
12
|
-
import {
|
|
10
|
+
import { J as DbStats, X as StatsRecorder, t as BetterSupabase, v as Db } from "./define-C5AcEkEJ.js";
|
|
11
|
+
import { j as StorageApi, n as Bucket } from "./bucket-vc-QRrva.js";
|
|
13
12
|
import { t as ImpersonationOptions } from "./impersonation-YTa9dZUv.js";
|
|
14
13
|
import { i as EventSink } from "./cloud-event-CzZTJkXv.js";
|
|
15
|
-
import {
|
|
14
|
+
import { b as TicketSubject, i as AuthorizationHooks } from "./authorization-hooks-D_pwXlBs.js";
|
|
16
15
|
import { s as SqlClaims, t as BetterPostgres } from "./pool-CrtT4dg-.js";
|
|
16
|
+
import { n as SupportApi, o as SupportSessions, t as ActiveSupport } from "./support-B4ZBVxt3.js";
|
|
17
17
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
18
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
19
18
|
import { JWTClaims } from "@supabase/server";
|
|
20
19
|
//#region src/auth/snapshot.d.ts
|
|
21
20
|
/**
|
|
@@ -169,354 +168,6 @@ interface RequestIdOptions {
|
|
|
169
168
|
readonly generate?: boolean;
|
|
170
169
|
}
|
|
171
170
|
//#endregion
|
|
172
|
-
//#region src/auth/support.d.ts
|
|
173
|
-
type SupportEndedBy = "admin" | "expired" | "revoked";
|
|
174
|
-
/** A support session: a platform admin viewing the app as `targetUserId`. */
|
|
175
|
-
interface SupportSession {
|
|
176
|
-
readonly id: string;
|
|
177
|
-
readonly adminId: string;
|
|
178
|
-
readonly targetUserId: string;
|
|
179
|
-
readonly reason: string;
|
|
180
|
-
/** Writes fail while it is true (`begin read only`). */
|
|
181
|
-
readonly readOnly: boolean;
|
|
182
|
-
readonly tenant?: string;
|
|
183
|
-
readonly startedAt: Temporal.Instant;
|
|
184
|
-
readonly expiresAt: Temporal.Instant;
|
|
185
|
-
readonly endedAt?: Temporal.Instant;
|
|
186
|
-
readonly endedBy?: SupportEndedBy;
|
|
187
|
-
/** App data, such as a ticket id. */
|
|
188
|
-
readonly metadata: Readonly<Record<string, unknown>>;
|
|
189
|
-
}
|
|
190
|
-
interface SupportStartInput {
|
|
191
|
-
readonly adminId: string;
|
|
192
|
-
/**
|
|
193
|
-
* The admin's verified claims. The SQL store runs `start_support_session`
|
|
194
|
-
* with them, so `is_platform()` checks the admin in the database too.
|
|
195
|
-
*/
|
|
196
|
-
readonly adminClaims: Readonly<Record<string, unknown>>;
|
|
197
|
-
readonly targetUserId: string;
|
|
198
|
-
readonly reason: string;
|
|
199
|
-
readonly ttlSeconds: number;
|
|
200
|
-
readonly readOnly: boolean;
|
|
201
|
-
readonly tenant?: string;
|
|
202
|
-
readonly metadata: Readonly<Record<string, unknown>>;
|
|
203
|
-
/** The approved request this start uses, when the server found one. */
|
|
204
|
-
readonly requestId?: string;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* A request for a support session that waits for a second admin. A start uses
|
|
208
|
-
* an approved request once; `approvedBy` is never `adminId`.
|
|
209
|
-
*/
|
|
210
|
-
interface SupportRequest {
|
|
211
|
-
readonly id: string;
|
|
212
|
-
readonly adminId: string;
|
|
213
|
-
readonly targetUserId: string;
|
|
214
|
-
readonly reason: string;
|
|
215
|
-
readonly readOnly: boolean;
|
|
216
|
-
readonly tenant?: string;
|
|
217
|
-
readonly metadata: Readonly<Record<string, unknown>>;
|
|
218
|
-
readonly requestedAt: Temporal.Instant;
|
|
219
|
-
/** An unapproved or unused request is closed after this. */
|
|
220
|
-
readonly expiresAt: Temporal.Instant;
|
|
221
|
-
readonly approvedBy?: string;
|
|
222
|
-
readonly approvedAt?: Temporal.Instant;
|
|
223
|
-
/** The session the approval started. */
|
|
224
|
-
readonly sessionId?: string;
|
|
225
|
-
}
|
|
226
|
-
interface SupportRequestInput {
|
|
227
|
-
readonly adminId: string;
|
|
228
|
-
/** The admin's verified claims; the SQL store asks as the admin with them. */
|
|
229
|
-
readonly adminClaims: Readonly<Record<string, unknown>>;
|
|
230
|
-
readonly targetUserId: string;
|
|
231
|
-
readonly reason: string;
|
|
232
|
-
readonly readOnly: boolean;
|
|
233
|
-
readonly tenant?: string;
|
|
234
|
-
readonly metadata: Readonly<Record<string, unknown>>;
|
|
235
|
-
/**
|
|
236
|
-
* An approver the server's authorization hook already decided, never the
|
|
237
|
-
* admin. The SQL store then records the request approved, over the admin
|
|
238
|
-
* connection.
|
|
239
|
-
*/
|
|
240
|
-
readonly approvedBy?: string;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Who approves a request: with `claims` the store runs as them and decides
|
|
244
|
-
* eligibility itself.
|
|
245
|
-
*/
|
|
246
|
-
interface SupportApprover {
|
|
247
|
-
readonly id: string;
|
|
248
|
-
readonly claims?: SupportCallerClaims;
|
|
249
|
-
}
|
|
250
|
-
/** What `approvedRequest` looks up. */
|
|
251
|
-
interface SupportApprovalQuery {
|
|
252
|
-
readonly adminId: string;
|
|
253
|
-
readonly targetUserId: string;
|
|
254
|
-
readonly tenant?: string;
|
|
255
|
-
readonly readOnly: boolean;
|
|
256
|
-
}
|
|
257
|
-
/** A caller's verified claims, which the store runs a call with. */
|
|
258
|
-
type SupportCallerClaims = Readonly<Record<string, unknown>>;
|
|
259
|
-
interface SupportListFilter {
|
|
260
|
-
readonly adminId?: string;
|
|
261
|
-
readonly targetUserId?: string;
|
|
262
|
-
/** `true`: running sessions only; `false`: ended or expired ones only. */
|
|
263
|
-
readonly active?: boolean;
|
|
264
|
-
/** Defaults to 50. */
|
|
265
|
-
readonly limit?: number;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Where support sessions live. `sqlSupportStore` uses the `impersonation` SQL
|
|
269
|
-
* module; implement this for another store and check it with
|
|
270
|
-
* `testSupportSessionStore` from `better-supabase/testing`.
|
|
271
|
-
*/
|
|
272
|
-
interface SupportSessionStore {
|
|
273
|
-
readonly apiVersion: 1;
|
|
274
|
-
readonly name: string;
|
|
275
|
-
/**
|
|
276
|
-
* Starts a session and ends the admin's previous one. Rejects when the store
|
|
277
|
-
* refuses.
|
|
278
|
-
*/
|
|
279
|
-
start(input: SupportStartInput): Promise<SupportSession>;
|
|
280
|
-
/**
|
|
281
|
-
* The admin's session while it is running; `undefined` once ended or expired.
|
|
282
|
-
* With the admin's `claims`, the store also checks that the admin may still
|
|
283
|
-
* start sessions.
|
|
284
|
-
*/
|
|
285
|
-
get(sessionId: string, adminId: string, claims?: SupportCallerClaims): Promise<SupportSession | undefined>;
|
|
286
|
-
/**
|
|
287
|
-
* `false` when it was not running. With `claims`, it runs as that caller: the
|
|
288
|
-
* session's admin, or staff with the revoke permission.
|
|
289
|
-
*/
|
|
290
|
-
end(sessionId: string, endedBy: SupportEndedBy, claims?: SupportCallerClaims): Promise<boolean>;
|
|
291
|
-
/** With `claims`, only what that caller may view. */
|
|
292
|
-
list(filter?: SupportListFilter, claims?: SupportCallerClaims): Promise<readonly SupportSession[]>;
|
|
293
|
-
/** The claims `targetUserId` would get, when the store can build them. */
|
|
294
|
-
claims?(targetUserId: string): Promise<Readonly<Record<string, unknown>>>;
|
|
295
|
-
/**
|
|
296
|
-
* Ends every running session past its expiry with `endedBy: "expired"` and
|
|
297
|
-
* returns them. Optional; `support.expire()` fails without it.
|
|
298
|
-
*/
|
|
299
|
-
expire?(): Promise<readonly SupportSession[]>;
|
|
300
|
-
/**
|
|
301
|
-
* The store with `namespace` for its time values, unless it was given one
|
|
302
|
-
* itself. Optional; `createServer` calls it with the definition's
|
|
303
|
-
* `temporal`.
|
|
304
|
-
*/
|
|
305
|
-
withTemporal?(namespace: typeof Temporal): SupportSessionStore;
|
|
306
|
-
/**
|
|
307
|
-
* Records a request for a session that waits for a second admin. Optional;
|
|
308
|
-
* without it and the two methods below, starts that need an approval are
|
|
309
|
-
* refused.
|
|
310
|
-
*/
|
|
311
|
-
request?(input: SupportRequestInput): Promise<SupportRequest>;
|
|
312
|
-
/** A request by id, or `undefined`. */
|
|
313
|
-
getRequest?(requestId: string): Promise<SupportRequest | undefined>;
|
|
314
|
-
/** Approves a request. Rejects when the approver is the requester. */
|
|
315
|
-
approve?(requestId: string, approver: SupportApprover): Promise<SupportRequest>;
|
|
316
|
-
/** The approved, unused, unexpired request a start would use, or `undefined`. */
|
|
317
|
-
approvedRequest?(query: SupportApprovalQuery): Promise<SupportRequest | undefined>;
|
|
318
|
-
}
|
|
319
|
-
interface SqlSupportStoreOptions {
|
|
320
|
-
/** `blocks.impersonation.schema`. Defaults to `better_supabase`. */
|
|
321
|
-
readonly schema?: string;
|
|
322
|
-
/**
|
|
323
|
-
* The Temporal namespace for the sessions' time values, for runtimes without
|
|
324
|
-
* a global one. Defaults to the one `createServer` passes from the
|
|
325
|
-
* definition, then the provided or global Temporal.
|
|
326
|
-
*/
|
|
327
|
-
readonly temporal?: typeof Temporal;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Support sessions in the `impersonation` SQL module. `start` runs as the
|
|
331
|
-
* admin, so the module's `is_platform()` gate applies; the reads run on the
|
|
332
|
-
* admin connection.
|
|
333
|
-
*/
|
|
334
|
-
declare function sqlSupportStore(postgres: Pick<BetterPostgres, "admin" | "asUser">, options?: SqlSupportStoreOptions): SupportSessionStore;
|
|
335
|
-
/**
|
|
336
|
-
* The claims a support session runs with: the target's, plus `act` naming the
|
|
337
|
-
* admin, the reason and the session (the audit module records all three),
|
|
338
|
-
* marked `kind: "support"` so `actorOf` never reads it as an OAuth client.
|
|
339
|
-
* `role` falls back to `authenticated`; the admin's claims never leak in.
|
|
340
|
-
*/
|
|
341
|
-
declare function supportClaims(session: Pick<SupportSession, "id" | "adminId" | "targetUserId" | "reason" | "readOnly">, target: Readonly<Record<string, unknown>>): Record<string, unknown>;
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region src/auth/support-cookie.d.ts
|
|
344
|
-
/** The cookie that carries the support session id. */
|
|
345
|
-
declare const SUPPORT_COOKIE = "bsb-support";
|
|
346
|
-
interface SupportCookieOptions {
|
|
347
|
-
/** Defaults to `bsb-support`. */
|
|
348
|
-
readonly name?: string;
|
|
349
|
-
/** Defaults to `/`. */
|
|
350
|
-
readonly path?: string;
|
|
351
|
-
/** Defaults to true; set false for plain-HTTP local development. */
|
|
352
|
-
readonly secure?: boolean;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* `Set-Cookie` for a session: HttpOnly, SameSite=Lax, gone when the session
|
|
356
|
-
* expires.
|
|
357
|
-
*/
|
|
358
|
-
declare function supportCookie(session: Pick<SupportSession, "id" | "expiresAt">, options?: SupportCookieOptions, now?: number): string;
|
|
359
|
-
/** `Set-Cookie` that removes the support cookie. */
|
|
360
|
-
declare function clearSupportCookie(options?: SupportCookieOptions): string;
|
|
361
|
-
/** The support session id in a `Cookie` header, or `undefined`. */
|
|
362
|
-
declare function supportCookieValue(cookieHeader: string | null, name?: string): string | undefined;
|
|
363
|
-
//#endregion
|
|
364
|
-
//#region src/server/support.d.ts
|
|
365
|
-
interface SupportPolicy {
|
|
366
|
-
/** Seconds a session lasts. Defaults to 1800 (30 minutes). */
|
|
367
|
-
readonly ttl?: number;
|
|
368
|
-
/** The longest `ttl` a start may ask for. Defaults to 14400 (4 hours). */
|
|
369
|
-
readonly maxTtl?: number;
|
|
370
|
-
/** Defaults to true. */
|
|
371
|
-
readonly requireReason?: boolean;
|
|
372
|
-
/**
|
|
373
|
-
* `always` (the default): every session is read-only. `default`: read-only
|
|
374
|
-
* unless the start passes `readOnly: false`.
|
|
375
|
-
*/
|
|
376
|
-
readonly readOnly?: "always" | "default";
|
|
377
|
-
/**
|
|
378
|
-
* `distinct` (the default): a start needs a request that another admin
|
|
379
|
-
* approved (`support.request`, then `support.approve`), or an `authorize`
|
|
380
|
-
* decision of `{ approvedBy }` naming someone else. `none`: no second admin.
|
|
381
|
-
* Set `blocks.impersonation.options.approval` to the same value, because the
|
|
382
|
-
* SQL store checks it again.
|
|
383
|
-
*/
|
|
384
|
-
readonly approval?: "distinct" | "none";
|
|
385
|
-
}
|
|
386
|
-
interface SupportOptions {
|
|
387
|
-
readonly store: SupportSessionStore;
|
|
388
|
-
/**
|
|
389
|
-
* Whether `admin` may view the app as the target. Without it, the
|
|
390
|
-
* authorization hooks' `support.authorize` decides, and without those every
|
|
391
|
-
* start is refused (`SUPPORT_FORBIDDEN`). A throw or rejection counts as a
|
|
392
|
-
* deny. `true` still needs a second admin under `policy.approval:
|
|
393
|
-
* 'distinct'`; `{ approvedBy }` names that admin.
|
|
394
|
-
*
|
|
395
|
-
* `'store'` hands the decision to the store alone: the SQL store checks
|
|
396
|
-
* `is_platform(blocks['impersonation'].permissions.start)` and nothing else,
|
|
397
|
-
* so use it only when that permission is the whole rule.
|
|
398
|
-
*/
|
|
399
|
-
readonly authorize?: SupportAuthorize | "store";
|
|
400
|
-
/**
|
|
401
|
-
* The claims the target gets. Defaults to `store.claims` (the SQL store runs
|
|
402
|
-
* your custom access token hook), then `{ role: 'authenticated' }`.
|
|
403
|
-
*/
|
|
404
|
-
readonly claims?: (targetUserId: string) => Readonly<Record<string, unknown>> | Promise<Readonly<Record<string, unknown>>>;
|
|
405
|
-
readonly policy?: SupportPolicy;
|
|
406
|
-
readonly cookie?: SupportCookieOptions;
|
|
407
|
-
/**
|
|
408
|
-
* Where a request names its support session, for apps that keep it in a
|
|
409
|
-
* header or their own request store instead of the `bsb-support` cookie.
|
|
410
|
-
* Defaults to reading the cookie.
|
|
411
|
-
*/
|
|
412
|
-
readonly sessionId?: (request: Request) => string | undefined;
|
|
413
|
-
}
|
|
414
|
-
interface SupportStartRequest {
|
|
415
|
-
readonly targetUserId: string;
|
|
416
|
-
readonly reason?: string;
|
|
417
|
-
/** Seconds; defaults to `policy.ttl`. */
|
|
418
|
-
readonly ttl?: number;
|
|
419
|
-
/** Honoured only with `policy.readOnly: 'default'`. */
|
|
420
|
-
readonly readOnly?: boolean;
|
|
421
|
-
readonly tenant?: string;
|
|
422
|
-
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
423
|
-
}
|
|
424
|
-
/** Options for `support.expireRoute`. */
|
|
425
|
-
interface SupportExpireRouteOptions {
|
|
426
|
-
/** The bearer token the cron caller sends, such as `process.env.CRON_SECRET`. */
|
|
427
|
-
readonly secret: string | undefined;
|
|
428
|
-
/** Rewrites the Problem Details bodies of the route's errors. */
|
|
429
|
-
readonly problem?: ProblemFormat;
|
|
430
|
-
}
|
|
431
|
-
/** A running support session, as the request that carries its cookie sees it. */
|
|
432
|
-
interface ActiveSupport {
|
|
433
|
-
readonly session: SupportSession;
|
|
434
|
-
/** The admin behind the session, from their own verified token. */
|
|
435
|
-
readonly admin: {
|
|
436
|
-
readonly id: string;
|
|
437
|
-
readonly email?: string;
|
|
438
|
-
};
|
|
439
|
-
/** The target's claims plus `act`, which repositories run with. */
|
|
440
|
-
readonly claims: Readonly<Record<string, unknown>>;
|
|
441
|
-
}
|
|
442
|
-
/** `bsb.support`: start, stop and inspect support sessions. */
|
|
443
|
-
interface SupportApi {
|
|
444
|
-
/**
|
|
445
|
-
* Starts a session for a signed-in admin and returns it with the `Set-Cookie`
|
|
446
|
-
* value that switches the admin's next requests to the target.
|
|
447
|
-
*/
|
|
448
|
-
start(admin: AuthState, request: SupportStartRequest): AsyncResult<{
|
|
449
|
-
readonly session: SupportSession;
|
|
450
|
-
readonly cookie: string;
|
|
451
|
-
}>;
|
|
452
|
-
/**
|
|
453
|
-
* Asks for a session that a second admin approves with `approve`; the policy
|
|
454
|
-
* checks of `start` apply. `ttl` is not stored: `start` passes it.
|
|
455
|
-
*/
|
|
456
|
-
request(admin: AuthState, request: SupportStartRequest): AsyncResult<SupportRequest>;
|
|
457
|
-
/**
|
|
458
|
-
* Approves a request as `approver`, who is never the admin who asked. With
|
|
459
|
-
* the hooks' `approverOf`, it decides who may approve; otherwise the store
|
|
460
|
-
* does (the SQL store: the provider's `isApprover`, else the start
|
|
461
|
-
* permission).
|
|
462
|
-
*/
|
|
463
|
-
approve(approver: AuthState, requestId: string): AsyncResult<SupportRequest>;
|
|
464
|
-
/**
|
|
465
|
-
* Ends the admin's own session and returns the `Set-Cookie` that clears the
|
|
466
|
-
* cookie.
|
|
467
|
-
*/
|
|
468
|
-
stop(admin: AuthState, sessionId: string): AsyncResult<{
|
|
469
|
-
readonly ended: boolean;
|
|
470
|
-
readonly cookie: string;
|
|
471
|
-
}>;
|
|
472
|
-
/**
|
|
473
|
-
* Ends a session as `caller`: the SQL store allows the session's admin and
|
|
474
|
-
* staff with the revoke permission.
|
|
475
|
-
*/
|
|
476
|
-
revoke(caller: AuthState, sessionId: string): AsyncResult<boolean>;
|
|
477
|
-
/** The running session the request names (`sessionIdOf`) for `auth`, if any. */
|
|
478
|
-
current(request: Request, auth: AuthState): Promise<ActiveSupport | undefined>;
|
|
479
|
-
/**
|
|
480
|
-
* The running session `sessionId` for the admin in `auth`, if any. Use it
|
|
481
|
-
* when the app keeps the session id in its own request context; pass the
|
|
482
|
-
* result to `contextFor(auth, { support })` or `dbFor(auth, context, {
|
|
483
|
-
* support })`.
|
|
484
|
-
*/
|
|
485
|
-
resolve(sessionId: string, auth: AuthState): Promise<ActiveSupport | undefined>;
|
|
486
|
-
/** The sessions `caller` may view (the SQL store checks the view permission). */
|
|
487
|
-
list(caller: AuthState, filter?: SupportListFilter): AsyncResult<readonly SupportSession[]>;
|
|
488
|
-
/**
|
|
489
|
-
* Ends every session past its expiry through the store and emits
|
|
490
|
-
* `support.ended` with `endedBy: "expired"` for each; the SQL store runs over
|
|
491
|
-
* `postgres.admin`. Returns the sessions it ended.
|
|
492
|
-
*/
|
|
493
|
-
expire(): AsyncResult<readonly SupportSession[]>;
|
|
494
|
-
/**
|
|
495
|
-
* A `GET` or `POST` handler for a cron caller that runs `expire()` and
|
|
496
|
-
* answers `{ expired }`, the number of sessions it ended.
|
|
497
|
-
*/
|
|
498
|
-
expireRoute(options: SupportExpireRouteOptions): (request: Request) => Promise<Response>;
|
|
499
|
-
/** The support session id a request names: `options.sessionId`, or the cookie. */
|
|
500
|
-
sessionIdOf(request: Request): string | undefined;
|
|
501
|
-
/** `Set-Cookie` that clears the support cookie. */
|
|
502
|
-
clearCookie(): string;
|
|
503
|
-
}
|
|
504
|
-
/** `ServerOptions.support`, from `supportSessions(options)`. */
|
|
505
|
-
interface SupportSessions {
|
|
506
|
-
readonly options: SupportOptions;
|
|
507
|
-
/**
|
|
508
|
-
* Builds `bsb.support`; `createServer` calls it once, with the definition's
|
|
509
|
-
* `temporal`, which goes on to the store's `withTemporal`, and the server's
|
|
510
|
-
* authorization hooks.
|
|
511
|
-
*/
|
|
512
|
-
readonly create: (events: EventHub, claimsSchema: StandardSchemaV1 | undefined, temporal?: typeof Temporal, authorization?: AuthorizationHooks) => SupportApi;
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Support sessions for `createServer(betterSupabase, { support })`. Apps that
|
|
516
|
-
* never import it don't bundle the support code.
|
|
517
|
-
*/
|
|
518
|
-
declare function supportSessions(options: SupportOptions): SupportSessions;
|
|
519
|
-
//#endregion
|
|
520
171
|
//#region src/server/suspend-account.d.ts
|
|
521
172
|
interface EndSessionsResult {
|
|
522
173
|
readonly userId: string;
|
|
@@ -943,4 +594,4 @@ interface BetterServer<M extends AnyModels, F extends AnyFunctions, E, C = unkno
|
|
|
943
594
|
}
|
|
944
595
|
type ServerKeys = keyof BetterServer<AnyModels, AnyFunctions, unknown>;
|
|
945
596
|
//#endregion
|
|
946
|
-
export {
|
|
597
|
+
export { isSessionSnapshot as A, DeleteAccountResult as C, SessionMemoStats as D, SessionMemoOptions as E, sessionCacheKey as M, sessionMemo as N, SessionSnapshot as O, snapshotOf as P, DeleteAccountOptions as S, SessionMemo as T, suspendAccount as _, ServerContext as a, ReplicaState as b, ServerOptions as c, EndSessionsResult as d, LastSignIn as f, lastSignIns as g, endSessions as h, ForContextOptions as i, issuedAtOf as j, authzVersionOf as k, SharedServer as l, SuspendAccountResult as m, BetterServer as n, ServerDbOptions as o, SuspendAccountOptions as p, ContextOptions as r, ServerKeys as s, AdminDb as t, TENANT_HEADER as u, RequestIdOptions as v, deleteAccount as w, LiteDriver as x, PRIMARY_COOKIE as y };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { O as AnyFunctions, k as AnyModels } from "./types-DFdg_4yN.js";
|
|
2
2
|
import { n as AuthOutageEvent, o as EventHub } from "./events-vcqenSYU.js";
|
|
3
3
|
import { g as SessionEncoding, o as ResolvePhase, p as CookieScope, r as AuthState, t as AuthResolution } from "./resolve-CXX6DHv3.js";
|
|
4
|
-
import { a as ServerContext, r as ContextOptions
|
|
4
|
+
import { a as ServerContext, r as ContextOptions } from "./server-types-CK8mUIUT.js";
|
|
5
|
+
import { t as ActiveSupport } from "./support-B4ZBVxt3.js";
|
|
5
6
|
import { d as RefreshPolicy } from "./respond-Dn1_YhC1.js";
|
|
6
7
|
import { SingleKeyEntry } from "@supabase/middleware";
|
|
7
8
|
//#region src/server/entries/core.d.ts
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { r as AuthState, t as AuthResolution } from "./resolve-CXX6DHv3.js";
|
|
2
|
+
import { t as ActiveSupport } from "./support-B4ZBVxt3.js";
|
|
3
|
+
//#region src/server/session-status.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* `active`: the session is valid. `expired`: the cookie's token expired and the
|
|
6
|
+
* route may not refresh it; the next navigation through the proxy does. `ended`
|
|
7
|
+
* and `banned`: Auth ended the session or banned the user, and the cookies are
|
|
8
|
+
* cleared. `signed_out`: no user session.
|
|
9
|
+
*/
|
|
10
|
+
type SessionWatchStatus = "active" | "expired" | "ended" | "banned" | "signed_out";
|
|
11
|
+
/** The JSON `sessionStatusRoute` answers with. */
|
|
12
|
+
interface SessionStatusBody {
|
|
13
|
+
readonly status: SessionWatchStatus;
|
|
14
|
+
/** The signed-in user (the admin in a support session). */
|
|
15
|
+
readonly userId: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* SHA-256 (hex) of the claims that decide access and of the support session,
|
|
18
|
+
* so a role, tenant or support target change gives a new value. `null` when
|
|
19
|
+
* there is no active session.
|
|
20
|
+
*/
|
|
21
|
+
readonly fingerprint: string | null;
|
|
22
|
+
/** Seconds since epoch, from the token's `exp`. */
|
|
23
|
+
readonly expiresAt: number | null;
|
|
24
|
+
/** The running support session, when the admin views the app as a user. */
|
|
25
|
+
readonly support: {
|
|
26
|
+
readonly sessionId: string;
|
|
27
|
+
readonly targetUserId: string;
|
|
28
|
+
readonly readOnly: boolean;
|
|
29
|
+
} | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The part of a server `sessionStatusRoute` uses: `createServer`, `createNext`
|
|
33
|
+
* and the other adapters fit.
|
|
34
|
+
*/
|
|
35
|
+
interface SessionStatusServer {
|
|
36
|
+
resolve(request: Request, options?: {
|
|
37
|
+
readonly refresh?: boolean;
|
|
38
|
+
readonly checkSession?: boolean;
|
|
39
|
+
}): Promise<AuthResolution>;
|
|
40
|
+
readonly support: {
|
|
41
|
+
current(request: Request, auth: AuthState): Promise<ActiveSupport | undefined>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
interface SessionStatusRouteOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Ask Auth whether the session still exists, one network call per check, so a
|
|
47
|
+
* revoked session or a ban shows up before the token expires. Defaults to
|
|
48
|
+
* true.
|
|
49
|
+
*/
|
|
50
|
+
readonly checkSession?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Refresh an expiring session cookie and send the new cookies. Defaults to
|
|
53
|
+
* false: the proxy refreshes, and an expired token answers `expired`.
|
|
54
|
+
*/
|
|
55
|
+
readonly refresh?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Claims left out of the fingerprint besides the ones that change on every
|
|
58
|
+
* refresh (`exp`, `iat`, `nbf`, `jti`).
|
|
59
|
+
*/
|
|
60
|
+
readonly ignoreClaims?: readonly string[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The fingerprint `sessionStatusRoute` reports for a user's claims and support
|
|
64
|
+
* session: a SHA-256 hex digest that changes when a claim that decides access
|
|
65
|
+
* changes (role, tenant, memberships, `aal`) or the support target does.
|
|
66
|
+
*/
|
|
67
|
+
declare function claimsFingerprint(claims: Readonly<Record<string, unknown>>, support?: ActiveSupport, ignore?: readonly string[]): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* A `GET` handler that tells a browser whether its session still holds, for
|
|
70
|
+
* apps that keep the session in httpOnly cookies and have no browser Supabase
|
|
71
|
+
* client: `useSessionWatch()` from `better-supabase/next/client` polls it. It
|
|
72
|
+
* answers `{ status, userId, fingerprint, expiresAt, support }` with
|
|
73
|
+
* `Cache-Control: no-store`.
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* // app/api/session-status/route.ts
|
|
77
|
+
* export const GET = sessionStatusRoute(bsb);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare function sessionStatusRoute(server: SessionStatusServer, options?: SessionStatusRouteOptions): (request: Request) => Promise<Response>;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { claimsFingerprint as a, SessionWatchStatus as i, SessionStatusRouteOptions as n, sessionStatusRoute as o, SessionStatusServer as r, SessionStatusBody as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as specKey, i as sessionUserId, n as hasAuthModule, t as authModuleOf } from "./auth-module-BbmX-N4L.js";
|
|
2
2
|
import { t as clearOnUserChange } from "./user-change-DgWC6RRC.js";
|
|
3
|
-
import { c as liveKey, d as shownCount, f as startBroadcast, i as countSource, m as startLiveQuery, p as startLiveCount, t as NO_COUNT } from "./client-
|
|
3
|
+
import { c as liveKey, d as shownCount, f as startBroadcast, i as countSource, m as startLiveQuery, p as startLiveCount, t as NO_COUNT } from "./client-C_mlji5R.js";
|
|
4
4
|
import { useSession } from "./react/session.js";
|
|
5
5
|
import { createContext, createElement, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
6
6
|
//#region src/react/context.ts
|
|
@@ -18,12 +18,17 @@ const LOADING = {
|
|
|
18
18
|
};
|
|
19
19
|
/** Provides the better-supabase client to the hooks. */
|
|
20
20
|
function BetterSupabaseProvider(props) {
|
|
21
|
-
const { client, queryClient } = props;
|
|
21
|
+
const { client, queryClient, realtime } = props;
|
|
22
22
|
useEffect(() => queryClient ? clearOnUserChange(queryClient, client.auth) : void 0, [client, queryClient]);
|
|
23
23
|
const value = useMemo(() => ({
|
|
24
24
|
client,
|
|
25
|
-
queryClient
|
|
26
|
-
|
|
25
|
+
queryClient,
|
|
26
|
+
realtime
|
|
27
|
+
}), [
|
|
28
|
+
client,
|
|
29
|
+
queryClient,
|
|
30
|
+
realtime
|
|
31
|
+
]);
|
|
27
32
|
return createElement(ClientContext.Provider, { value }, props.children);
|
|
28
33
|
}
|
|
29
34
|
function useClientContext() {
|
|
@@ -84,7 +89,7 @@ function createHooks() {
|
|
|
84
89
|
*/
|
|
85
90
|
function useBroadcast(topic, values, handlers, options) {
|
|
86
91
|
const context = useContext(ClientContext);
|
|
87
|
-
const supabase = options?.client ?? context?.client.supabase;
|
|
92
|
+
const supabase = options?.client ?? context?.realtime ?? context?.client.supabase;
|
|
88
93
|
if (!supabase) throw new Error("better-supabase: useBroadcast needs <BetterSupabaseProvider client={bsb}> or { client: supabase }");
|
|
89
94
|
const queryClient = options?.queryClient ?? context?.queryClient;
|
|
90
95
|
const auth = useBroadcastAuth(options?.client === void 0 ? context?.client : void 0, supabase);
|
|
@@ -139,8 +144,9 @@ function useBroadcastAuth(client, supabase) {
|
|
|
139
144
|
});
|
|
140
145
|
useEffect(() => {
|
|
141
146
|
if (client) return;
|
|
142
|
-
|
|
143
|
-
|
|
147
|
+
const authModule = authModuleOf(supabase);
|
|
148
|
+
if (!authModule) return;
|
|
149
|
+
const { data } = authModule.onAuthStateChange((_event, session) => {
|
|
144
150
|
setPlain({
|
|
145
151
|
status: session ? "signed-in" : "signed-out",
|
|
146
152
|
userId: session ? sessionUserId(session) : null
|
|
@@ -188,7 +194,7 @@ function useHeldSpec(spec) {
|
|
|
188
194
|
* ```
|
|
189
195
|
*/
|
|
190
196
|
function useLiveQuery(spec, options = {}) {
|
|
191
|
-
const { client, queryClient } = useClientContext();
|
|
197
|
+
const { client, queryClient, realtime } = useClientContext();
|
|
192
198
|
const auth = useAuth();
|
|
193
199
|
const [status, setStatus] = useState("closed");
|
|
194
200
|
if (spec && !queryClient) throw new Error("better-supabase: useLiveQuery needs <BetterSupabaseProvider queryClient={...}>");
|
|
@@ -209,6 +215,7 @@ function useLiveQuery(spec, options = {}) {
|
|
|
209
215
|
joined.current = held.key;
|
|
210
216
|
return startLiveQuery({
|
|
211
217
|
client,
|
|
218
|
+
...realtime ? { realtime } : {},
|
|
212
219
|
queryClient,
|
|
213
220
|
spec: held.spec,
|
|
214
221
|
auth: latest.current.auth,
|
|
@@ -218,6 +225,7 @@ function useLiveQuery(spec, options = {}) {
|
|
|
218
225
|
});
|
|
219
226
|
}, [
|
|
220
227
|
client,
|
|
228
|
+
realtime,
|
|
221
229
|
queryClient,
|
|
222
230
|
held,
|
|
223
231
|
key
|
|
@@ -235,7 +243,7 @@ function useLiveQuery(spec, options = {}) {
|
|
|
235
243
|
* ```
|
|
236
244
|
*/
|
|
237
245
|
function useLiveCount(source, options = {}) {
|
|
238
|
-
const { client } = useClientContext();
|
|
246
|
+
const { client, realtime } = useClientContext();
|
|
239
247
|
const auth = useAuth();
|
|
240
248
|
const parsed = countSource(source, options);
|
|
241
249
|
const [state, setState] = useState(NO_COUNT);
|
|
@@ -264,6 +272,7 @@ function useLiveCount(source, options = {}) {
|
|
|
264
272
|
};
|
|
265
273
|
return startLiveCount({
|
|
266
274
|
client,
|
|
275
|
+
...realtime ? { realtime } : {},
|
|
267
276
|
spec: held.spec,
|
|
268
277
|
key: specKey,
|
|
269
278
|
auth: latest.current.auth,
|
|
@@ -283,6 +292,7 @@ function useLiveCount(source, options = {}) {
|
|
|
283
292
|
});
|
|
284
293
|
}, [
|
|
285
294
|
client,
|
|
295
|
+
realtime,
|
|
286
296
|
held.spec,
|
|
287
297
|
held.key,
|
|
288
298
|
key,
|
package/dist/solid/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { b as DbError } from "../result-DZeA5KS6.js";
|
|
2
2
|
import { Ct as Events, D as BlockEventPattern, T as BlockEvent, bt as EventMap, k as BlockEventsMatching } from "../events-vcqenSYU.js";
|
|
3
|
-
import { pt as QuerySpec } from "../define-
|
|
4
|
-
import {
|
|
5
|
-
import { g as TopicHandlers, m as Topic, p as SubscriptionStatus, r as PresenceMember, t as EventSchemas } from "../topic-
|
|
6
|
-
import { t as AuthSnapshot } from "../bind-
|
|
3
|
+
import { pt as QuerySpec } from "../define-C5AcEkEJ.js";
|
|
4
|
+
import { tt as TemplateValues } from "../bucket-vc-QRrva.js";
|
|
5
|
+
import { g as TopicHandlers, m as Topic, p as SubscriptionStatus, r as PresenceMember, t as EventSchemas } from "../topic-CZXHhZye.js";
|
|
6
|
+
import { t as AuthSnapshot } from "../bind-JGCPGUJh.js";
|
|
7
7
|
import { t as AuthSession } from "../view-DyFdMCqg.js";
|
|
8
|
-
import { n as Controller } from "../controller-
|
|
9
|
-
import { C as LiveCountSource, D as ProfileOf, E as PresenceTopic, O as UseActionOptions, S as LiveCountHookOptions, T as PresenceHookOptions, _ as ActionResultOf, a as DataRows, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, h as BlockRefetchOn, i as DataRow, l as BlockEventSource, m as BlockQueryState, n as DataId, o as DataSource, p as BlockQueryOptions, r as DataListArgs, s as DataState, t as fieldErrorsOf, u as BlockMutationActions, v as ActionState, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-
|
|
10
|
-
import { n as BlockOptions } from "../block-env-
|
|
8
|
+
import { n as Controller } from "../controller-BW-5Opig.js";
|
|
9
|
+
import { C as LiveCountSource, D as ProfileOf, E as PresenceTopic, O as UseActionOptions, S as LiveCountHookOptions, T as PresenceHookOptions, _ as ActionResultOf, a as DataRows, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, h as BlockRefetchOn, i as DataRow, l as BlockEventSource, m as BlockQueryState, n as DataId, o as DataSource, p as BlockQueryOptions, r as DataListArgs, s as DataState, t as fieldErrorsOf, u as BlockMutationActions, v as ActionState, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-Dt86dCKk.js";
|
|
10
|
+
import { n as BlockOptions } from "../block-env-y65GF_px.js";
|
|
11
11
|
import { n as BlockDataOf, r as BlockMethodName, t as BlockArgsOf } from "../block-method-CiVa2G-J.js";
|
|
12
12
|
import { t as SupportView } from "../support-view-BYOgwXsJ.js";
|
|
13
13
|
import { SupabaseClient } from "@supabase/supabase-js";
|
package/dist/solid/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as clearOnUserChange } from "../user-change-DgWC6RRC.js";
|
|
2
|
-
import { a as createActionRunner, c as liveKey, d as shownCount, f as startBroadcast, i as countSource, l as notJoined, m as startLiveQuery, n as assertInvalidateClient, o as joinPresence, p as startLiveCount, r as callerOf, s as keyed, t as NO_COUNT, u as plainCaller } from "../client-
|
|
2
|
+
import { a as createActionRunner, c as liveKey, d as shownCount, f as startBroadcast, i as countSource, l as notJoined, m as startLiveQuery, n as assertInvalidateClient, o as joinPresence, p as startLiveCount, r as callerOf, s as keyed, t as NO_COUNT, u as plainCaller } from "../client-C_mlji5R.js";
|
|
3
3
|
import { t as supportOf } from "../support-view-g4YLBeqX.js";
|
|
4
4
|
import { c as listenToBlockEvents, d as fieldErrorsOf, i as dataTarget, l as blockEnv, n as createDataOne, o as createBlockMutation, s as createBlockQuery, t as createDataList, u as withEnv } from "../data-hooks-tgF1Ct0F.js";
|
|
5
5
|
import { createComponent, createContext, createEffect, createMemo, createSignal, from, onCleanup, onMount, untrack, useContext } from "solid-js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { O as AnyFunctions, k as AnyModels } from "../types-DFdg_4yN.js";
|
|
2
2
|
import { l as PermissionRef, t as AnyAuthorizer } from "../authorizer-B6X09otb.js";
|
|
3
|
-
import { t as BetterSupabase } from "../define-
|
|
4
|
-
import { n as BetterServer } from "../server-types-
|
|
3
|
+
import { t as BetterSupabase } from "../define-C5AcEkEJ.js";
|
|
4
|
+
import { n as BetterServer } from "../server-types-CK8mUIUT.js";
|
|
5
5
|
import { a as AuthorizedContext, l as Unwrapped, n as ActionParsed, o as BlockActionOptions, r as ActionResult, s as BlockRequireOptions } from "../kit-DOwKpSkA.js";
|
|
6
6
|
import { t as RefusalRedirects } from "../refusal-CSntB_x8.js";
|
|
7
|
-
import { n as FrameworkOptions, r as LocalsResource, t as FrameworkLocals } from "../framework-
|
|
7
|
+
import { n as FrameworkOptions, r as LocalsResource, t as FrameworkLocals } from "../framework-BGdZVyPL.js";
|
|
8
8
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
9
9
|
//#region src/solid-start/index.d.ts
|
|
10
10
|
/** The part of a SolidStart `FetchEvent` the integration reads and writes. */
|
package/dist/spec/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { t as DescribedFunction } from "../function-contract-DxFNOmsm.js";
|
|
|
2
2
|
import { C as ModelWebhook, D as ResourceOperation, E as OperationSource, O as SecurityRequirement, S as ModelTag, T as OAuthFlow, _ as ModelResponseOrRef, a as JsonSchema, b as ModelServer, c as ModelChannelOperation, d as ModelInfo, f as ModelMessage, g as ModelResponse, h as ModelParameter, i as JsonObject, k as TableVerb, l as ModelContent, m as ModelOperation, n as DataApiOperation, o as ModelBody, p as ModelMessageTrait, r as HttpMethod, s as ModelChannel, t as ApiModel, u as ModelExample, v as ModelSecurityProfileRequirement, w as ModelWorkflow, x as ModelStep, y as ModelSecurityScheme } from "../model-hwpvole9.js";
|
|
3
3
|
import { a as ResourcePlan, o as StandardLike, r as ResourceDescription } from "../resource-D8pzB5Qf.js";
|
|
4
4
|
import { t as SPEC_PINS } from "../spec-pins-DIx95afw.js";
|
|
5
|
-
import { A as AnyOpenApiDocument, B as OpenApiSecurityRequirement, C as TopicInput, D as DEFAULT_ERRORS, E as CustomSecurity, F as OpenApi33PreviewDocument, H as RenderedOpenApi, I as OpenApiComponents, L as OpenApiDocument, M as OpenApi30Document, N as OpenApi31Document, O as PROBLEM_SCHEMA, P as OpenApi32Document, R as OpenApiDocuments, S as EventsOptions, T as DataApiOptions, V as OpenApiVersion, _ as WorkflowSource, a as OverlayEngine, b as CLOUD_EVENT_TRAIT, c as defineApi, d as BuiltModel, f as ComponentNameContext, g as RouteSpec, h as ResourceInput, i as OpenApiRenderResult, j as OPENAPI_33_PREVIEW_VERSION, k as SecurityPreset, l as ApiOptions, m as OperationIdContext, n as DefineApiOptions, o as RenderOptions, p as EnrichHooks, r as OpenApiRenderOptions, s as RenderResult, t as Api, u as ApiSource, v as BlockEventSchema, w as topicsFrom, x as CloudEventsInput, y as BlockEventSchemas, z as OpenApiInfo } from "../api-
|
|
5
|
+
import { A as AnyOpenApiDocument, B as OpenApiSecurityRequirement, C as TopicInput, D as DEFAULT_ERRORS, E as CustomSecurity, F as OpenApi33PreviewDocument, H as RenderedOpenApi, I as OpenApiComponents, L as OpenApiDocument, M as OpenApi30Document, N as OpenApi31Document, O as PROBLEM_SCHEMA, P as OpenApi32Document, R as OpenApiDocuments, S as EventsOptions, T as DataApiOptions, V as OpenApiVersion, _ as WorkflowSource, a as OverlayEngine, b as CLOUD_EVENT_TRAIT, c as defineApi, d as BuiltModel, f as ComponentNameContext, g as RouteSpec, h as ResourceInput, i as OpenApiRenderResult, j as OPENAPI_33_PREVIEW_VERSION, k as SecurityPreset, l as ApiOptions, m as OperationIdContext, n as DefineApiOptions, o as RenderOptions, p as EnrichHooks, r as OpenApiRenderOptions, s as RenderResult, t as Api, u as ApiSource, v as BlockEventSchema, w as topicsFrom, x as CloudEventsInput, y as BlockEventSchemas, z as OpenApiInfo } from "../api-hHwieEfz.js";
|
|
6
6
|
import { a as FormatVersion, c as SpecDiagnostic, d as defineDocumentFormat, i as DocumentOf, l as VersionOf, n as DiagnosticSeverity, o as LowerContext, r as DocumentFormat, s as RenderedOf, t as AnyDocumentFormat, u as VersionStatus } from "../format-u-65igKI.js";
|
|
7
7
|
//#region src/spec/build.d.ts
|
|
8
8
|
/**
|