@pithy-sh/auth 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -2
- package/dist/audit/actions.d.ts +39 -0
- package/dist/audit/actions.d.ts.map +1 -1
- package/dist/audit/actions.js +40 -1
- package/dist/audit/emit.d.ts +34 -0
- package/dist/audit/emit.d.ts.map +1 -1
- package/dist/audit/emit.js +47 -1
- package/dist/audit/evidence.d.ts +8 -2
- package/dist/audit/evidence.d.ts.map +1 -1
- package/dist/capability.d.ts +31 -11
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +38 -5
- package/dist/client/api.d.ts +55 -12
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +57 -18
- package/dist/client/bearer.d.ts +110 -0
- package/dist/client/bearer.d.ts.map +1 -0
- package/dist/client/bearer.js +265 -0
- package/dist/client/handoff.d.ts +77 -0
- package/dist/client/handoff.d.ts.map +1 -0
- package/dist/client/handoff.js +119 -0
- package/dist/client/mcp.d.ts +70 -0
- package/dist/client/mcp.d.ts.map +1 -0
- package/dist/client/mcp.js +65 -0
- package/dist/data/betterAuth.d.ts +3 -2
- package/dist/data/betterAuth.d.ts.map +1 -1
- package/dist/data/betterAuth.js +5 -3
- package/dist/data/kitFields.d.ts +5 -0
- package/dist/data/kitFields.d.ts.map +1 -1
- package/dist/data/kitFields.js +5 -0
- package/dist/data/tables.d.ts +25 -4
- package/dist/data/tables.d.ts.map +1 -1
- package/dist/data/tables.js +5 -3
- package/dist/data/userLifecycle.d.ts +9 -0
- package/dist/data/userLifecycle.d.ts.map +1 -1
- package/dist/data/userLifecycle.js +6 -2
- package/dist/data/verificationOutcome.d.ts +53 -0
- package/dist/data/verificationOutcome.d.ts.map +1 -0
- package/dist/data/verificationOutcome.js +50 -0
- package/dist/email/send.js +6 -2
- package/dist/http/adminRoutes.d.ts.map +1 -1
- package/dist/http/adminRoutes.js +56 -10
- package/dist/http/csrf.d.ts.map +1 -1
- package/dist/http/csrf.js +2 -1
- package/dist/http/guards.d.ts +15 -11
- package/dist/http/guards.d.ts.map +1 -1
- package/dist/http/guards.js +46 -11
- package/dist/http/handoff.d.ts +76 -0
- package/dist/http/handoff.d.ts.map +1 -0
- package/dist/http/handoff.js +316 -0
- package/dist/http/middleware.d.ts +12 -0
- package/dist/http/middleware.d.ts.map +1 -1
- package/dist/http/middleware.js +25 -4
- package/dist/http/resolve.d.ts.map +1 -1
- package/dist/http/resolve.js +9 -3
- package/dist/http/responses.d.ts +142 -0
- package/dist/http/responses.d.ts.map +1 -1
- package/dist/http/responses.js +66 -10
- package/dist/http/routes.d.ts +2 -0
- package/dist/http/routes.d.ts.map +1 -1
- package/dist/http/routes.js +35 -4
- package/dist/http/schemas.d.ts +57 -0
- package/dist/http/schemas.d.ts.map +1 -1
- package/dist/http/schemas.js +44 -1
- package/dist/http/views.d.ts +22 -2
- package/dist/http/views.d.ts.map +1 -1
- package/dist/http/views.js +40 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/instance/auth.d.ts +148 -10
- package/dist/instance/auth.d.ts.map +1 -1
- package/dist/instance/auth.js +86 -41
- package/dist/instance/plugins.d.ts +6 -0
- package/dist/instance/plugins.d.ts.map +1 -1
- package/dist/instance/plugins.js +14 -1
- package/dist/ledger/read.d.ts +53 -0
- package/dist/ledger/read.d.ts.map +1 -0
- package/dist/ledger/read.js +85 -0
- package/dist/ledger/record.d.ts +35 -0
- package/dist/ledger/record.d.ts.map +1 -0
- package/dist/ledger/record.js +98 -0
- package/dist/lifecycle/erasure.d.ts +9 -0
- package/dist/lifecycle/erasure.d.ts.map +1 -0
- package/dist/lifecycle/erasure.js +96 -0
- package/dist/lifecycle/inactivity.d.ts +19 -0
- package/dist/lifecycle/inactivity.d.ts.map +1 -0
- package/dist/lifecycle/inactivity.js +28 -0
- package/dist/lifecycle/transitions.d.ts +22 -1
- package/dist/lifecycle/transitions.d.ts.map +1 -1
- package/dist/lifecycle/transitions.js +51 -4
- package/dist/mcp/argumentClass.d.ts +51 -0
- package/dist/mcp/argumentClass.d.ts.map +1 -0
- package/dist/mcp/argumentClass.js +69 -0
- package/dist/mcp/capability.d.ts +50 -0
- package/dist/mcp/capability.d.ts.map +1 -0
- package/dist/mcp/capability.js +140 -0
- package/dist/mcp/clientMetadata.d.ts +40 -0
- package/dist/mcp/clientMetadata.d.ts.map +1 -0
- package/dist/mcp/clientMetadata.js +68 -0
- package/dist/mcp/consent.d.ts +49 -0
- package/dist/mcp/consent.d.ts.map +1 -0
- package/dist/mcp/consent.js +69 -0
- package/dist/mcp/dispatch.d.ts +35 -0
- package/dist/mcp/dispatch.d.ts.map +1 -0
- package/dist/mcp/dispatch.js +135 -0
- package/dist/mcp/floor.d.ts +37 -0
- package/dist/mcp/floor.d.ts.map +1 -0
- package/dist/mcp/floor.js +41 -0
- package/dist/mcp/host.d.ts +34 -0
- package/dist/mcp/host.d.ts.map +1 -0
- package/dist/mcp/host.js +2 -0
- package/dist/mcp/http/redirectList.d.ts +9 -0
- package/dist/mcp/http/redirectList.d.ts.map +1 -0
- package/dist/mcp/http/redirectList.js +24 -0
- package/dist/mcp/http/responses.d.ts +143 -0
- package/dist/mcp/http/responses.d.ts.map +1 -0
- package/dist/mcp/http/responses.js +83 -0
- package/dist/mcp/http/routes.d.ts +28 -0
- package/dist/mcp/http/routes.d.ts.map +1 -0
- package/dist/mcp/http/routes.js +517 -0
- package/dist/mcp/http/schemas.d.ts +24 -0
- package/dist/mcp/http/schemas.d.ts.map +1 -0
- package/dist/mcp/http/schemas.js +18 -0
- package/dist/mcp/marker.d.ts +15 -0
- package/dist/mcp/marker.d.ts.map +1 -0
- package/dist/mcp/marker.js +15 -0
- package/dist/mcp/provider.d.ts +78 -0
- package/dist/mcp/provider.d.ts.map +1 -0
- package/dist/mcp/provider.js +108 -0
- package/dist/mcp/purge.d.ts +15 -0
- package/dist/mcp/purge.d.ts.map +1 -0
- package/dist/mcp/purge.js +31 -0
- package/dist/mcp/rpc.d.ts +79 -0
- package/dist/mcp/rpc.d.ts.map +1 -0
- package/dist/mcp/rpc.js +103 -0
- package/dist/mcp/toolAudit.d.ts +76 -0
- package/dist/mcp/toolAudit.d.ts.map +1 -0
- package/dist/mcp/toolAudit.js +86 -0
- package/dist/migrations/0006_verification_outcomes.d.ts +15 -0
- package/dist/migrations/0006_verification_outcomes.d.ts.map +1 -0
- package/dist/migrations/0006_verification_outcomes.js +35 -0
- package/dist/migrations/0007_erasure_record.d.ts +17 -0
- package/dist/migrations/0007_erasure_record.d.ts.map +1 -0
- package/dist/migrations/0007_erasure_record.js +36 -0
- package/dist/migrations/0008_last_active.d.ts +15 -0
- package/dist/migrations/0008_last_active.d.ts.map +1 -0
- package/dist/migrations/0008_last_active.js +29 -0
- package/dist/migrations/set.d.ts +4 -1
- package/dist/migrations/set.d.ts.map +1 -1
- package/dist/migrations/set.js +8 -2
- package/dist/peer.d.ts +3 -2
- package/dist/peer.d.ts.map +1 -1
- package/dist/processing/activities.d.ts +6 -0
- package/dist/processing/activities.d.ts.map +1 -0
- package/dist/processing/activities.js +12 -0
- package/dist/purge/contribution.d.ts +20 -5
- package/dist/purge/contribution.d.ts.map +1 -1
- package/dist/purge/contribution.js +20 -6
- package/dist/purge/run.d.ts +75 -5
- package/dist/purge/run.d.ts.map +1 -1
- package/dist/purge/run.js +117 -14
- package/dist/purge/workflow.d.ts +15 -2
- package/dist/purge/workflow.d.ts.map +1 -1
- package/dist/purge/workflow.js +51 -7
- package/dist/test-utils/accountFootprint.d.ts +5 -2
- package/dist/test-utils/accountFootprint.d.ts.map +1 -1
- package/dist/test-utils/accountFootprint.js +7 -2
- package/dist/test-utils/liveApp.d.ts +6 -0
- package/dist/test-utils/liveApp.d.ts.map +1 -1
- package/dist/test-utils/liveApp.js +7 -2
- package/dist/token/handoff.d.ts +80 -0
- package/dist/token/handoff.d.ts.map +1 -0
- package/dist/token/handoff.js +136 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/docs/account-lifecycle.md +59 -7
- package/docs/apple-signin.md +32 -4
- package/docs/facebook-oauth.md +2 -2
- package/docs/github-oauth.md +2 -2
- package/docs/google-oauth.md +9 -7
- package/docs/microsoft-oauth.md +2 -2
- package/package.json +11 -5
- package/pithy.manifest.json +2 -2
- package/pithy.mcp.manifest.json +36 -0
- package/src/audit/actions.ts +39 -0
- package/src/audit/emit.ts +63 -0
- package/src/audit/evidence.ts +8 -4
- package/src/capability.ts +80 -23
- package/src/client/api.ts +69 -19
- package/src/client/bearer.ts +388 -0
- package/src/client/handoff.ts +172 -0
- package/src/client/mcp.ts +140 -0
- package/src/data/betterAuth.ts +8 -4
- package/src/data/kitFields.ts +2 -0
- package/src/data/tables.ts +4 -2
- package/src/data/userLifecycle.ts +15 -3
- package/src/data/verificationOutcome.ts +86 -0
- package/src/email/send.ts +2 -2
- package/src/http/adminRoutes.ts +68 -3
- package/src/http/csrf.ts +4 -1
- package/src/http/guards.ts +48 -11
- package/src/http/handoff.ts +350 -0
- package/src/http/middleware.ts +29 -3
- package/src/http/resolve.ts +25 -25
- package/src/http/responses.ts +134 -8
- package/src/http/routes.ts +63 -4
- package/src/http/schemas.ts +85 -0
- package/src/http/views.ts +46 -2
- package/src/index.ts +2 -0
- package/src/instance/auth.ts +51 -1
- package/src/instance/plugins.ts +20 -2
- package/src/ledger/read.ts +133 -0
- package/src/ledger/record.ts +198 -0
- package/src/lifecycle/erasure.ts +118 -0
- package/src/lifecycle/inactivity.ts +56 -0
- package/src/lifecycle/transitions.ts +75 -5
- package/src/mcp/argumentClass.ts +112 -0
- package/src/mcp/capability.ts +194 -0
- package/src/mcp/clientMetadata.ts +81 -0
- package/src/mcp/consent.ts +95 -0
- package/src/mcp/dispatch.ts +154 -0
- package/src/mcp/floor.ts +62 -0
- package/src/mcp/host.ts +36 -0
- package/src/mcp/http/redirectList.ts +26 -0
- package/src/mcp/http/responses.ts +157 -0
- package/src/mcp/http/routes.ts +635 -0
- package/src/mcp/http/schemas.ts +37 -0
- package/src/mcp/marker.ts +18 -0
- package/src/mcp/provider.ts +151 -0
- package/src/mcp/purge.ts +39 -0
- package/src/mcp/rpc.ts +135 -0
- package/src/mcp/toolAudit.ts +132 -0
- package/src/migrations/0006_verification_outcomes.ts +51 -0
- package/src/migrations/0007_erasure_record.ts +43 -0
- package/src/migrations/0008_last_active.ts +30 -0
- package/src/migrations/set.ts +7 -1
- package/src/processing/activities.ts +14 -0
- package/src/purge/contribution.ts +37 -10
- package/src/purge/run.ts +179 -16
- package/src/purge/workflow.ts +65 -7
- package/src/seeds/example.ts +2 -2
- package/src/test-utils/accountFootprint.ts +10 -1
- package/src/test-utils/liveApp.ts +10 -1
- package/src/token/handoff.ts +180 -0
- package/src/version.generated.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/http/responses.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/http/responses.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyCxB,kDAAkD;AAClD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;iBAuCsF,CAAC;AACjH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAE3D,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB;;;;;;;;iBAUiF,CAAC;AAC/G,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEjE,0GAA0G;AAC1G,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;iBAawF,CAAC;AACrH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAA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mB,CAAC,CAAC;AAEvE,6BAA6B;AAC7B,eAAO,MAAM,uBAAuB;;;iBASyD,CAAC;AAC9F,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE/E,kDAAkD;AAClD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;iBAcwC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAEzD,4BAA4B;AAC5B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;iBAIqB,CAAC;AACpD,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE,oCAAoC;AACpC,eAAO,MAAM,sBAAsB;;iBAEyE,CAAC;AAC7G,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;iBAU2E,CAAC;AAC9G,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/dist/http/responses.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import { DevicePlatform } from "../data/device.js";
|
|
4
|
+
import { VerificationState, VerificationType } from "../data/verificationOutcome.js";
|
|
4
5
|
import { z } from "zod";
|
|
5
6
|
import { Locale } from "@pithy-sh/core/src/i18n/locale";
|
|
6
7
|
//#region src/http/responses.ts
|
|
@@ -40,7 +41,14 @@ const AdminUserView = z.object({
|
|
|
40
41
|
image: z.string().nullable().describe("The avatar URL from a social profile, or null."),
|
|
41
42
|
locale: Locale.nullable().optional().describe("The reader's chosen language as a BCP-47 tag; null when they have never chosen one, and absent when the Worker that answered predates the field (#450)."),
|
|
42
43
|
createdAt: z.iso.datetime().describe("When the user was created, ISO-8601."),
|
|
43
|
-
updatedAt: z.iso.datetime().describe("When the row was last written, ISO-8601.")
|
|
44
|
+
updatedAt: z.iso.datetime().describe("When the row was last written, ISO-8601."),
|
|
45
|
+
state: z.enum([
|
|
46
|
+
"active",
|
|
47
|
+
"suspended",
|
|
48
|
+
"deleted"
|
|
49
|
+
]).optional().describe("Where the account stands now: `active`; `suspended`, refused until it is reinstated or its end passes; or `deleted`, refused and restorable until `purgeAfter`. A suspension whose end has passed reads `active`, as enforcement reads it. Absent when the Worker that answered predates the field."),
|
|
50
|
+
suspendedUntil: z.iso.datetime().nullable().optional().describe("When a suspension in force ends by itself, ISO-8601. Null for one that lasts until a reinstatement, and in every other state. Absent when the Worker predates the field."),
|
|
51
|
+
purgeAfter: z.iso.datetime().nullable().optional().describe("For a deleted account, when the purge may erase it, ISO-8601 — restorable until then. Null in every other state. Absent when the Worker predates the field.")
|
|
44
52
|
}).describe("One user as a management client sees them. The table holds no credential, so nothing is withheld.");
|
|
45
53
|
/** A session as a management client may see it — the token is not part of the contract. */
|
|
46
54
|
const AdminSessionView = z.object({
|
|
@@ -107,6 +115,46 @@ const AdminDevicesResponse = z.object({
|
|
|
107
115
|
nextCursor: NextCursor
|
|
108
116
|
}).describe("A page of the device registry.");
|
|
109
117
|
/**
|
|
118
|
+
* One sign-in link or code from the verification ledger (#829), as a management client sees it.
|
|
119
|
+
*
|
|
120
|
+
* Never the token and never the address: the ledger holds neither. The mail is named by its job id, which is how
|
|
121
|
+
* a reader holding `email:jobs:read` joins this to a bounce, a deferral or a suppression.
|
|
122
|
+
*/
|
|
123
|
+
const AdminVerificationView = z.object({
|
|
124
|
+
verificationId: z.string().describe("The verification row that carries it. Opaque; not a credential."),
|
|
125
|
+
type: VerificationType.describe("What was issued."),
|
|
126
|
+
state: VerificationState.describe("Where it stood at the moment of the read."),
|
|
127
|
+
userId: z.string().nullable().describe("The account it signs in to — known at issue, or created by its use. Null for a sign-up nobody completed."),
|
|
128
|
+
emailJobId: z.string().nullable().describe("The `pithy_email_jobs` row that carried it, under `email:jobs:read`. Null when the email seam failed and nothing was queued."),
|
|
129
|
+
issuedAt: z.iso.datetime().describe("When it was issued, ISO-8601."),
|
|
130
|
+
expiresAt: z.iso.datetime().describe("When it stops working, used or not, ISO-8601."),
|
|
131
|
+
usedAt: z.iso.datetime().nullable().describe("When it signed somebody in, ISO-8601, or null.")
|
|
132
|
+
}).describe("One sign-in link or code: what it was, whose, the mail that carried it, and where it stands.");
|
|
133
|
+
/** How many of one type were issued over the window, and where they stand. */
|
|
134
|
+
const VerificationTypeCounts = z.object({
|
|
135
|
+
type: VerificationType.describe("Which type these counts are for."),
|
|
136
|
+
issued: z.number().int().min(0).describe("How many were issued in the window."),
|
|
137
|
+
used: z.number().int().min(0).describe("How many of those signed somebody in."),
|
|
138
|
+
expired: z.number().int().min(0).describe("How many ran out unused."),
|
|
139
|
+
pending: z.number().int().min(0).describe("How many are unused and still work. The three add up to `issued`.")
|
|
140
|
+
}).describe("One type's counts over the window, by state.");
|
|
141
|
+
/**
|
|
142
|
+
* `GET {base}/admin/verifications` (#829): the window it covered, the counts by type and state over all of it,
|
|
143
|
+
* and a page of its rows, newest issue first.
|
|
144
|
+
*
|
|
145
|
+
* The counts cover every row in the window whatever the page or the filters say, and every type, with zeros —
|
|
146
|
+
* so a pane reading "sign-in links: 0 issued" can tell it from a Worker that did not say.
|
|
147
|
+
*/
|
|
148
|
+
const AdminVerificationsResponse = z.object({
|
|
149
|
+
window: z.object({
|
|
150
|
+
since: z.iso.datetime().describe("The window's start, inclusive, ISO-8601."),
|
|
151
|
+
until: z.iso.datetime().describe("The window's end, exclusive, ISO-8601.")
|
|
152
|
+
}).describe("The window of issue times the counts and the rows cover."),
|
|
153
|
+
counts: z.array(VerificationTypeCounts).describe("Every type's counts over the whole window, by state."),
|
|
154
|
+
verifications: z.array(AdminVerificationView).describe("The page of rows, newest issue first."),
|
|
155
|
+
nextCursor: NextCursor
|
|
156
|
+
}).describe("The verification ledger over a window: counts by type and state, and the rows, paged.");
|
|
157
|
+
/**
|
|
110
158
|
* `POST {base}/admin/sessions/revoke` and `POST {base}/admin/users/:userId/sessions/revoke`.
|
|
111
159
|
*
|
|
112
160
|
* A count and nothing else, deliberately. Both routes are idempotent — revoking a session that has
|
|
@@ -188,7 +236,7 @@ const AuthExportProvider = z.object({
|
|
|
188
236
|
}).describe("One sign-in provider linked to the account. The provider's tokens are credentials and are not here.");
|
|
189
237
|
/** One transition in an account's history, as an export carries it — not who made it. */
|
|
190
238
|
const AuthExportTransition = z.object({
|
|
191
|
-
action: z.string().describe("What happened: `suspended`, `reinstated`, `deleted`, `restored`, `purge_step`, `purged`."),
|
|
239
|
+
action: z.string().describe("What happened: `suspended`, `reinstated`, `deleted`, `restored`, `purge_step`, `purge_retained`, `purge_failed`, `purged`."),
|
|
192
240
|
actorType: z.string().describe("Who made it: `control-plane`, `user` (the account's holder), or `system`."),
|
|
193
241
|
reason: z.string().nullable().describe("The reason given, in the words of whoever made the transition, or null."),
|
|
194
242
|
suspendedUntil: z.iso.datetime().nullable().describe("For a suspension, when it ends by itself, ISO-8601."),
|
|
@@ -213,23 +261,26 @@ const AuthUserExport = z.object({
|
|
|
213
261
|
providers: z.array(AuthExportProvider).describe("Every linked sign-in provider."),
|
|
214
262
|
devices: z.array(AdminDeviceView).describe("Every registered device, most recently seen first. Without push tokens."),
|
|
215
263
|
history: z.array(AuthExportTransition).describe("Every lifecycle transition, oldest first."),
|
|
264
|
+
verifications: z.array(AdminVerificationView).optional().describe("Every sign-in link and code the verification ledger records for the account, newest first (#829). Absent from a Worker that predates the ledger."),
|
|
216
265
|
plugins: z.record(z.string(), z.array(z.record(z.string(), z.unknown()))).describe("The account's rows in each table a composed Better Auth plugin created keyed by `userId` — two-factor, passkeys, API keys — keyed by table. Without a column that holds a credential. Empty when no such plugin is composed.")
|
|
217
266
|
}).describe("Everything `@pithy-sh/auth` holds about one account, without a credential.");
|
|
218
267
|
/** Fields every capability's export entry carries. */
|
|
219
268
|
const exportEntry = {
|
|
220
|
-
capability: z.string().describe("The capability whose rows these are — the purge step that erases them."),
|
|
221
|
-
summary: z.string().describe("What that capability's purge erases or
|
|
269
|
+
capability: z.string().describe("The capability whose rows these are — the purge step that erases or keeps them."),
|
|
270
|
+
summary: z.string().describe("What that capability's purge erases, anonymizes or keeps, in its own sentence."),
|
|
271
|
+
disposition: z.enum(["erase", "retain"]).optional().describe("What a purge does with these rows: `erase` (erased or anonymized) or `retain` (kept, for the reason in `basis`) (#814). Absent from a Worker that predates it, where every entry is `erase`."),
|
|
272
|
+
basis: z.string().optional().describe("For a `retain` entry, why the rows are kept, in one sentence written for the person — `Kept for tax records.` Absent for `erase`.")
|
|
222
273
|
};
|
|
223
274
|
/** One capability's part of an export. */
|
|
224
275
|
const AdminUserExportEntry = z.discriminatedUnion("state", [
|
|
225
276
|
z.object({
|
|
226
277
|
...exportEntry,
|
|
227
278
|
state: z.literal("exported").describe("The capability answered."),
|
|
228
|
-
data: z.record(z.string(), z.unknown()).describe("What it holds about the account, in the shape that capability exports. `auth`'s is `AuthUserExport`.")
|
|
279
|
+
data: z.record(z.string(), z.unknown()).describe("What it holds about the account, in the shape that capability exports. `auth`'s is `AuthUserExport`. For a `retain` entry, the rows a purge keeps.")
|
|
229
280
|
}).describe("A capability's rows about the account."),
|
|
230
281
|
z.object({
|
|
231
282
|
...exportEntry,
|
|
232
|
-
state: z.literal("not_exported").describe("The capability erases rows about the account and does not say how to export them.")
|
|
283
|
+
state: z.literal("not_exported").describe("The capability erases rows about the account and does not say how to export them. No kit capability answers it; an adopter's own may.")
|
|
233
284
|
}).describe("A capability that holds rows it does not export. Ask its owner."),
|
|
234
285
|
z.object({
|
|
235
286
|
...exportEntry,
|
|
@@ -253,10 +304,15 @@ const AdminUserExportResponse = z.object({
|
|
|
253
304
|
}).describe("Everything the kit holds about one account, from every composed capability, as one document.");
|
|
254
305
|
/** `POST {base}/token/rotate`. */
|
|
255
306
|
const TokenRotateResponse = z.object({
|
|
256
|
-
accessToken: z.string().describe("A
|
|
257
|
-
refreshToken: z.string().describe("The successor
|
|
307
|
+
accessToken: z.string().describe("A short-lived JWT for a service outside this Worker, which verifies it against `/jwks`. The kit's own routes do not accept it: send `refreshToken` as the bearer."),
|
|
308
|
+
refreshToken: z.string().describe("The successor session token: the bearer credential for `Authorization: Bearer` on the kit's routes, and what the next rotation takes. The one presented is spent, and presenting it again past a short grace window revokes the whole family."),
|
|
258
309
|
expiresAt: z.iso.datetime().describe("When the successor session lapses, ISO-8601.")
|
|
259
|
-
}).describe("The rotated
|
|
310
|
+
}).describe("The rotated credentials: the session token that replaces the one presented, and a JWT for outside verifiers.");
|
|
311
|
+
/** `POST {base}/handoff`. */
|
|
312
|
+
const HandoffExchangeResponse = z.object({
|
|
313
|
+
token: z.string().describe("The raw session token: the bearer credential for `Authorization: Bearer`, and the refresh credential `/token/rotate` takes. Hold it in secure storage."),
|
|
314
|
+
expiresAt: z.iso.datetime().describe("When the session lapses unless it is rotated first, ISO-8601.")
|
|
315
|
+
}).describe("The session a redirect sign-in made, handed to the native app that started it.");
|
|
260
316
|
/** One of the caller's own registered devices. */
|
|
261
317
|
const MyDeviceView = z.object({
|
|
262
318
|
id: z.string().describe("The client-generated device id it registered at sign-in."),
|
|
@@ -285,4 +341,4 @@ const AccountDeleteResponse = z.object({
|
|
|
285
341
|
mailed: z.boolean().describe("Whether the deletion-scheduled mail, with the purge date and how to ask for the account back, was sent.")
|
|
286
342
|
}).describe("The caller's own account, deleted: when its data will be erased, and whether they were mailed.");
|
|
287
343
|
//#endregion
|
|
288
|
-
export { AccountDeleteResponse, AdminDeviceRevokeResponse, AdminDeviceView, AdminDevicesResponse, AdminRevokeResponse, AdminSessionView, AdminUserDeleteResponse, AdminUserExportResponse, AdminUserReinstateResponse, AdminUserResponse, AdminUserRestoreResponse, AdminUserSuspendResponse, AdminUserView, AdminUsersResponse, AuthUserExport, MyDeviceRevokeResponse, MyDeviceView, MyDevicesResponse, TokenRotateResponse };
|
|
344
|
+
export { AccountDeleteResponse, AdminDeviceRevokeResponse, AdminDeviceView, AdminDevicesResponse, AdminRevokeResponse, AdminSessionView, AdminUserDeleteResponse, AdminUserExportResponse, AdminUserReinstateResponse, AdminUserResponse, AdminUserRestoreResponse, AdminUserSuspendResponse, AdminUserView, AdminUsersResponse, AdminVerificationView, AdminVerificationsResponse, AuthUserExport, HandoffExchangeResponse, MyDeviceRevokeResponse, MyDeviceView, MyDevicesResponse, TokenRotateResponse, VerificationTypeCounts };
|
package/dist/http/routes.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ import type { AuthWiring } from "../capability";
|
|
|
17
17
|
* | Route | Verification | Input |
|
|
18
18
|
* | -------------------------- | --------------- | --------------------------- |
|
|
19
19
|
* | `POST /token/rotate` | bearer/session | none — the credential only |
|
|
20
|
+
* | `GET /sign-in/social/start` | public | query `SocialSignInStartQuery` |
|
|
21
|
+
* | `POST /handoff` | public | json `HandoffExchangeBody` |
|
|
20
22
|
* | `GET /devices` | bearer/session | none |
|
|
21
23
|
* | `POST /devices/revoke` | bearer/session | json `RevokeDeviceBody` |
|
|
22
24
|
* | `DELETE /account` | bearer/session | json `DeleteAccountBody` |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/http/routes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/http/routes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAS7E,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAG1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAkDhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CAyKtF"}
|
package/dist/http/routes.js
CHANGED
|
@@ -14,12 +14,13 @@ import { userSessionTokens } from "../admin/users.js";
|
|
|
14
14
|
import { lifecycleDeps } from "../lifecycle/request.js";
|
|
15
15
|
import { deleteUser } from "../lifecycle/transitions.js";
|
|
16
16
|
import { consumeSession, findConsumedToken, pruneConsumedTokens, recordConsumedToken, revokeFamily } from "../token/rotation.js";
|
|
17
|
-
import { AccountDeleteResponse, MyDeviceRevokeResponse, MyDevicesResponse, TokenRotateResponse } from "./responses.js";
|
|
18
|
-
import { DeleteAccountBody, RevokeDeviceBody } from "./schemas.js";
|
|
17
|
+
import { AccountDeleteResponse, HandoffExchangeResponse, MyDeviceRevokeResponse, MyDevicesResponse, TokenRotateResponse } from "./responses.js";
|
|
18
|
+
import { DeleteAccountBody, HandoffExchangeBody, RevokeDeviceBody, SocialSignInStartQuery } from "./schemas.js";
|
|
19
19
|
import { accountDeletionView } from "./views.js";
|
|
20
20
|
import { registerAuthAdminRoutes } from "./adminRoutes.js";
|
|
21
21
|
import { guardErrorCallbackURL } from "./errorCallbackUrl.js";
|
|
22
22
|
import { apiErrorToPithy } from "./errors.js";
|
|
23
|
+
import { exchangeHandoff, handOffToApp, startNativeSignIn } from "./handoff.js";
|
|
23
24
|
import { admitsRefusedAccount, lifecycleRedirect } from "./lifecycleGate.js";
|
|
24
25
|
import { NotFoundError, UnauthorizedError } from "@pithy-sh/core/src/error/pithyError";
|
|
25
26
|
import { TURNSTILE_LOGIN_ACTION } from "@pithy-sh/turnstile/src/config/config";
|
|
@@ -27,6 +28,7 @@ import { describeRoute } from "@pithy-sh/core/src/http/routeSpec";
|
|
|
27
28
|
import { validate } from "@pithy-sh/core/src/http/validation";
|
|
28
29
|
import { STORED_IMAGE_HEADERS, storedImageBytes } from "@pithy-sh/core/src/image/storedImage";
|
|
29
30
|
import { requireSameOrigin } from "@pithy-sh/core/src/http/sameOrigin";
|
|
31
|
+
import { announceSessionRotated } from "@pithy-sh/core/src/session/rotated";
|
|
30
32
|
import { turnstile } from "@pithy-sh/turnstile/src/http/middleware";
|
|
31
33
|
//#region src/http/routes.ts
|
|
32
34
|
/**
|
|
@@ -55,6 +57,8 @@ function db(c, wiring) {
|
|
|
55
57
|
* | Route | Verification | Input |
|
|
56
58
|
* | -------------------------- | --------------- | --------------------------- |
|
|
57
59
|
* | `POST /token/rotate` | bearer/session | none — the credential only |
|
|
60
|
+
* | `GET /sign-in/social/start` | public | query `SocialSignInStartQuery` |
|
|
61
|
+
* | `POST /handoff` | public | json `HandoffExchangeBody` |
|
|
58
62
|
* | `GET /devices` | bearer/session | none |
|
|
59
63
|
* | `POST /devices/revoke` | bearer/session | json `RevokeDeviceBody` |
|
|
60
64
|
* | `DELETE /account` | bearer/session | json `DeleteAccountBody` |
|
|
@@ -76,19 +80,34 @@ function createAuthRoutes(wiring) {
|
|
|
76
80
|
const base = wiring.config.basePath;
|
|
77
81
|
const csrf = requireSameOrigin();
|
|
78
82
|
if (wiring.turnstile) {
|
|
83
|
+
const { mode, token } = wiring.turnstile;
|
|
79
84
|
const guard = turnstile({
|
|
80
|
-
mode
|
|
85
|
+
mode,
|
|
86
|
+
field: token.field,
|
|
87
|
+
header: token.header,
|
|
81
88
|
action: TURNSTILE_LOGIN_ACTION
|
|
82
89
|
});
|
|
83
90
|
app.use(`${base}/sign-in/magic-link`, guard);
|
|
84
91
|
app.use(`${base}/email-otp/send-verification-otp`, guard);
|
|
85
92
|
}
|
|
86
93
|
app.post(`${base}/token/rotate`, describeRoute({
|
|
87
|
-
summary: "Trade the current
|
|
94
|
+
summary: "Trade the current session token for its successor, and a JWT for services outside this Worker.",
|
|
88
95
|
description: "The presented session is spent. Presenting it again after a short grace window is read as theft, and revokes every session descended from the same sign-in.",
|
|
89
96
|
verification: ["bearer", "session"],
|
|
90
97
|
responses: { 200: TokenRotateResponse }
|
|
91
98
|
}), csrf, (c) => rotateToken(c, wiring));
|
|
99
|
+
app.get(`${base}/sign-in/social/start`, describeRoute({
|
|
100
|
+
summary: "Start a native app's redirect sign-in inside the system browser.",
|
|
101
|
+
description: "A native app opens this address in the system browser's sign-in sheet (ASWebAuthenticationSession, a Custom Tab) instead of posting `/sign-in/social` itself, so the signed `state` cookie Better Auth checks at the provider's callback lands in the browser that completes it. The answer is a redirect to the provider carrying that cookie. Only for the handoff: `callbackURL` must be in `trustedOrigins` and carry a well-formed `handoff_challenge`, or it is refused, and so is an `errorCallbackURL` outside `trustedOrigins`, and a navigation another page started (`Sec-Fetch-Site` other than `none`). A provider this Worker does not enable answers `core/not_found`. A web page keeps the JSON `POST /sign-in/social`.",
|
|
102
|
+
verification: ["public"],
|
|
103
|
+
responses: { 302: { description: "A redirect to the provider's authorization page, setting the sign-in's state cookie." } }
|
|
104
|
+
}), validate("query", SocialSignInStartQuery), (c) => startNativeSignIn(c, wiring, c.req.valid("query")));
|
|
105
|
+
app.post(`${base}/handoff`, describeRoute({
|
|
106
|
+
summary: "Trade the one-time code a redirect sign-in left on an app's link for the session token.",
|
|
107
|
+
description: "A social sign-in whose `callbackURL` is in `trustedOrigins` and carries a `handoff_challenge` (the S256 digest of a verifier the app holds) returns to that link with a `code` parameter instead of a cookie, whether the link is an https universal link or app link or a custom scheme. The code is good once, for sixty seconds, and only with the verifier. A spent, expired or unknown code, or a wrong or malformed verifier, is refused with `auth/handoff_invalid`, and any attempt spends the code. A custom-scheme link with no challenge gets `error=handoff_challenge_required` and no code; an https link with no challenge is a web page and gets its cookie. A magic link is handed off only to an https link: one to a custom scheme gets `error=handoff_scheme_refused`, and no session is kept. Device headers sent here register the device against the session.",
|
|
108
|
+
verification: ["public"],
|
|
109
|
+
responses: { 200: HandoffExchangeResponse }
|
|
110
|
+
}), validate("json", HandoffExchangeBody), (c) => exchangeHandoff(c, wiring, c.req.valid("json")));
|
|
92
111
|
app.get(`${base}/devices`, describeRoute({
|
|
93
112
|
summary: "List the caller's own registered devices.",
|
|
94
113
|
verification: ["bearer", "session"],
|
|
@@ -240,6 +259,8 @@ async function handleBetterAuth(c, wiring) {
|
|
|
240
259
|
});
|
|
241
260
|
return collapsed.response;
|
|
242
261
|
}
|
|
262
|
+
const handedOff = await handOffToApp(c, wiring, instance, response);
|
|
263
|
+
if (handedOff) return handedOff;
|
|
243
264
|
await auditRefusal(c, response);
|
|
244
265
|
return response;
|
|
245
266
|
}
|
|
@@ -335,6 +356,16 @@ async function rotateToken(c, wiring) {
|
|
|
335
356
|
ip,
|
|
336
357
|
userAgent
|
|
337
358
|
});
|
|
359
|
+
const failures = await announceSessionRotated(wiring.composed ?? [], {
|
|
360
|
+
previousSessionId: current.session.id,
|
|
361
|
+
sessionId: next.id,
|
|
362
|
+
userId: current.user.id,
|
|
363
|
+
env: c.env
|
|
364
|
+
});
|
|
365
|
+
for (const failure of failures) c.var.log?.child("auth").warn("a session-rotated listener failed; its state stayed on the spent session", {
|
|
366
|
+
capability: failure.capability,
|
|
367
|
+
error: failure.error instanceof Error ? failure.error.message : String(failure.error)
|
|
368
|
+
});
|
|
338
369
|
try {
|
|
339
370
|
await pruneConsumedTokens(database, /* @__PURE__ */ new Date(Date.now() - wiring.config.sessionExpiresIn * 1e3));
|
|
340
371
|
} catch {}
|
package/dist/http/schemas.d.ts
CHANGED
|
@@ -23,6 +23,42 @@ export declare const RevokeDeviceBody: z.ZodObject<{
|
|
|
23
23
|
deviceId: z.ZodString;
|
|
24
24
|
}, z.core.$strip>;
|
|
25
25
|
export type RevokeDeviceBody = z.output<typeof RevokeDeviceBody>;
|
|
26
|
+
/**
|
|
27
|
+
* The body of `POST /handoff`: the one-time code a redirect sign-in left on the app's link, and the verifier whose
|
|
28
|
+
* challenge the sign-in carried. Bounded rather than shape-checked, so a malformed code or verifier is refused, and
|
|
29
|
+
* the code spent, by the same trade that refuses a spent code, with the same answer.
|
|
30
|
+
*/
|
|
31
|
+
export declare const HandoffExchangeBody: z.ZodObject<{
|
|
32
|
+
code: z.ZodString;
|
|
33
|
+
verifier: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type HandoffExchangeBody = z.output<typeof HandoffExchangeBody>;
|
|
36
|
+
/** The providers a native app can sign in with through the system browser: every redirect provider auth offers. */
|
|
37
|
+
export declare const RedirectProvider: z.ZodEnum<{
|
|
38
|
+
apple: "apple";
|
|
39
|
+
facebook: "facebook";
|
|
40
|
+
github: "github";
|
|
41
|
+
google: "google";
|
|
42
|
+
microsoft: "microsoft";
|
|
43
|
+
}>;
|
|
44
|
+
export type RedirectProvider = z.output<typeof RedirectProvider>;
|
|
45
|
+
/**
|
|
46
|
+
* The query of `GET /sign-in/social/start`, the address a native app opens in the system browser's sign-in sheet.
|
|
47
|
+
* Bounded rather than shape-checked: the handler holds `callbackURL` to `trustedOrigins` and to carrying a
|
|
48
|
+
* `handoff_challenge`, and Better Auth checks both URLs again when the sign-in starts.
|
|
49
|
+
*/
|
|
50
|
+
export declare const SocialSignInStartQuery: z.ZodObject<{
|
|
51
|
+
provider: z.ZodEnum<{
|
|
52
|
+
apple: "apple";
|
|
53
|
+
facebook: "facebook";
|
|
54
|
+
github: "github";
|
|
55
|
+
google: "google";
|
|
56
|
+
microsoft: "microsoft";
|
|
57
|
+
}>;
|
|
58
|
+
callbackURL: z.ZodString;
|
|
59
|
+
errorCallbackURL: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export type SocialSignInStartQuery = z.output<typeof SocialSignInStartQuery>;
|
|
26
62
|
/**
|
|
27
63
|
* The user id in the path of every single-user admin route.
|
|
28
64
|
*
|
|
@@ -53,6 +89,27 @@ export declare const ListDevicesQuery: z.ZodObject<{
|
|
|
53
89
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
54
90
|
}, z.core.$strip>;
|
|
55
91
|
export type ListDevicesQuery = z.output<typeof ListDevicesQuery>;
|
|
92
|
+
/**
|
|
93
|
+
* The verification ledger read's query (#829): a window of issue times, what to narrow it to, and where to resume.
|
|
94
|
+
* Both bounds are optional — the last 30 days, ending now — and a window that ends before it starts is refused by
|
|
95
|
+
* the handler, which is where the default is known.
|
|
96
|
+
*/
|
|
97
|
+
export declare const ListVerificationsQuery: z.ZodObject<{
|
|
98
|
+
since: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
99
|
+
until: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
100
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
101
|
+
magic_link: "magic_link";
|
|
102
|
+
otp: "otp";
|
|
103
|
+
}>>;
|
|
104
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
105
|
+
expired: "expired";
|
|
106
|
+
pending: "pending";
|
|
107
|
+
used: "used";
|
|
108
|
+
}>>;
|
|
109
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
110
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
export type ListVerificationsQuery = z.output<typeof ListVerificationsQuery>;
|
|
56
113
|
/**
|
|
57
114
|
* The body of `POST /admin/sessions/revoke`.
|
|
58
115
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/http/schemas.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/http/schemas.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;iBAQ2E,CAAC;AACzG,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAA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zB,CAAC;AACJ,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE/D,yDAAyD;AACzD,eAAO,MAAM,iBAAiB;;;iBAE8D,CAAC;AAC7F,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;EAItB,CAAC;AACJ,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAEzD,iDAAiD;AACjD,eAAO,MAAM,cAAc;;;;;;;iBAakD,CAAC;AAC9E,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAE7D,uDAAuD;AACvD,eAAO,MAAM,eAAe;;iBAEiF,CAAC;AAC9G,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE/D;;;GAGG;AACH,eAAO,MAAM,eAAe;;iBAMmB,CAAC;AAChD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;iBAM+E,CAAC;AAC9G,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
package/dist/http/schemas.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import { DevicePlatform } from "../data/device.js";
|
|
4
|
+
import { VerificationState, VerificationType } from "../data/verificationOutcome.js";
|
|
4
5
|
import "../lifecycle/reason.js";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
import { JsonDate } from "@pithy-sh/core/src/data/codecs";
|
|
@@ -26,6 +27,33 @@ import { MAX_PAGE_SIZE } from "@pithy-sh/core/src/data/cursor";
|
|
|
26
27
|
*/
|
|
27
28
|
const RevokeDeviceBody = z.object({ deviceId: z.string().min(1).max(256).describe("The id of the device to revoke — the client-generated id it registered at sign-in.") }).describe("The body identifying which device to revoke — the caller's own, or an admin-named user's.");
|
|
28
29
|
/**
|
|
30
|
+
* The body of `POST /handoff`: the one-time code a redirect sign-in left on the app's link, and the verifier whose
|
|
31
|
+
* challenge the sign-in carried. Bounded rather than shape-checked, so a malformed code or verifier is refused, and
|
|
32
|
+
* the code spent, by the same trade that refuses a spent code, with the same answer.
|
|
33
|
+
*/
|
|
34
|
+
const HandoffExchangeBody = z.object({
|
|
35
|
+
code: z.string().min(1).max(256).describe("The one-time code from the `code` parameter of the deep link the sign-in returned to."),
|
|
36
|
+
verifier: z.string().min(1).max(256).describe("The random verifier the app made before the sign-in started: 43 to 128 characters from `A-Z a-z 0-9 - . _ ~`, as RFC 7636 shapes it. Its S256 digest is the `handoff_challenge` the sign-in's `callbackURL` carried.")
|
|
37
|
+
}).describe("The code a native app trades for its session after a redirect sign-in, with the verifier that binds it.");
|
|
38
|
+
/** The providers a native app can sign in with through the system browser: every redirect provider auth offers. */
|
|
39
|
+
const RedirectProvider = z.enum([
|
|
40
|
+
"apple",
|
|
41
|
+
"facebook",
|
|
42
|
+
"github",
|
|
43
|
+
"google",
|
|
44
|
+
"microsoft"
|
|
45
|
+
]).describe("A sign-in provider that completes in the browser, by redirect. Whether this Worker enables it is its config's call.");
|
|
46
|
+
/**
|
|
47
|
+
* The query of `GET /sign-in/social/start`, the address a native app opens in the system browser's sign-in sheet.
|
|
48
|
+
* Bounded rather than shape-checked: the handler holds `callbackURL` to `trustedOrigins` and to carrying a
|
|
49
|
+
* `handoff_challenge`, and Better Auth checks both URLs again when the sign-in starts.
|
|
50
|
+
*/
|
|
51
|
+
const SocialSignInStartQuery = z.object({
|
|
52
|
+
provider: RedirectProvider,
|
|
53
|
+
callbackURL: z.string().min(1).max(2048).describe("The app's own link, in `trustedOrigins`, carrying the `handoff_challenge` the app made: where the sign-in returns with a one-time code."),
|
|
54
|
+
errorCallbackURL: z.string().min(1).max(2048).optional().describe("Where a refused sign-in returns, with an `error` parameter. In `trustedOrigins`. Absent, a refusal lands on the auth error page.")
|
|
55
|
+
}).describe("A native redirect sign-in, started in the system browser so the provider's state cookie lands in its jar.");
|
|
56
|
+
/**
|
|
29
57
|
* The user id in the path of every single-user admin route.
|
|
30
58
|
*
|
|
31
59
|
* Bounded rather than `.uuid()`: Better Auth's id generator is configurable and its default is not a
|
|
@@ -50,6 +78,21 @@ const ListDevicesQuery = z.object({
|
|
|
50
78
|
cursor: PageCursorParam,
|
|
51
79
|
limit: PageLimit
|
|
52
80
|
}).describe("The device-registry query: what to filter by, how many to return, and where to resume.");
|
|
81
|
+
/** A window bound on the verification read: ISO-8601 with an offset, decoded to a `Date` here so no handler parses it. */
|
|
82
|
+
const WindowBound = z.iso.datetime({ offset: true }).transform((value) => new Date(value));
|
|
83
|
+
/**
|
|
84
|
+
* The verification ledger read's query (#829): a window of issue times, what to narrow it to, and where to resume.
|
|
85
|
+
* Both bounds are optional — the last 30 days, ending now — and a window that ends before it starts is refused by
|
|
86
|
+
* the handler, which is where the default is known.
|
|
87
|
+
*/
|
|
88
|
+
const ListVerificationsQuery = z.object({
|
|
89
|
+
since: WindowBound.optional().describe("The window's start, inclusive, on issue time, ISO-8601. Defaults to 30 days before `until`."),
|
|
90
|
+
until: WindowBound.optional().describe("The window's end, exclusive, on issue time, ISO-8601. Defaults to now."),
|
|
91
|
+
type: VerificationType.optional().describe("Narrow the rows to one type. The counts always cover every type."),
|
|
92
|
+
state: VerificationState.optional().describe("Narrow the rows to one state, judged at the moment of the read. The counts always cover every state."),
|
|
93
|
+
cursor: PageCursorParam,
|
|
94
|
+
limit: PageLimit
|
|
95
|
+
}).describe("The verification ledger query: the window, what to narrow the rows to, how many, and where to resume.");
|
|
53
96
|
/**
|
|
54
97
|
* The body of `POST /admin/sessions/revoke`.
|
|
55
98
|
*
|
|
@@ -108,4 +151,4 @@ const ExportUserQuery = z.object({ reason: LifecycleReason.describe("Why this pe
|
|
|
108
151
|
*/
|
|
109
152
|
const DeleteAccountBody = z.object({ confirm: z.literal(true).describe("Must be `true`. The person confirmed, in your app, that they want their account deleted.") }).describe("A self-service deletion: the person's own confirmation. Always soft, on the configured window.");
|
|
110
153
|
//#endregion
|
|
111
|
-
export { DeleteAccountBody, DeleteUserBody, DeletionMode, ExportUserQuery, ListDevicesQuery, ListUsersQuery, ReinstateUserBody, RestoreUserBody, RevokeDeviceBody, RevokeSessionBody, SuspendUserBody, UserIdParam };
|
|
154
|
+
export { DeleteAccountBody, DeleteUserBody, DeletionMode, ExportUserQuery, HandoffExchangeBody, ListDevicesQuery, ListUsersQuery, ListVerificationsQuery, RedirectProvider, ReinstateUserBody, RestoreUserBody, RevokeDeviceBody, RevokeSessionBody, SocialSignInStartQuery, SuspendUserBody, UserIdParam };
|
package/dist/http/views.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ import type { PurgeExportEntry } from "@pithy-sh/core/src/capability/purge";
|
|
|
4
4
|
import type { Account, Session, User } from "../data/betterAuth";
|
|
5
5
|
import type { Device } from "../data/device";
|
|
6
6
|
import type { UserLifecycleEvent } from "../data/userLifecycle";
|
|
7
|
+
import { type VerificationOutcome } from "../data/verificationOutcome";
|
|
8
|
+
import { type AccountStanding } from "../lifecycle/state";
|
|
7
9
|
import type { DeleteTransition, DeletionMode, LifecycleTransition, RestoreTransition, SuspendTransition } from "../lifecycle/transitions";
|
|
8
|
-
import type { AccountDeleteResponse, AdminDeviceView, AdminSessionView, AdminUserDeleteResponse, AdminUserExportResponse, AdminUserReinstateResponse, AdminUserRestoreResponse, AdminUserSuspendResponse, AdminUserView, AuthUserExport } from "./responses";
|
|
10
|
+
import type { AccountDeleteResponse, AdminDeviceView, AdminSessionView, AdminUserDeleteResponse, AdminUserExportResponse, AdminUserReinstateResponse, AdminUserRestoreResponse, AdminUserSuspendResponse, AdminUserView, AdminVerificationView, AuthUserExport } from "./responses";
|
|
9
11
|
/**
|
|
10
12
|
* The admin projections — what a management client is shown of a user, a session, and a device.
|
|
11
13
|
*
|
|
@@ -30,8 +32,18 @@ import type { AccountDeleteResponse, AdminDeviceView, AdminSessionView, AdminUse
|
|
|
30
32
|
* `locale` is projected for the same reason: a support pane answering "why is this person getting
|
|
31
33
|
* English emails" needs to see whether they ever chose, and null — never chosen — is the answer half
|
|
32
34
|
* the time. It is a preference, not a credential.
|
|
35
|
+
*
|
|
36
|
+
* Where the account stands is projected too (#813), judged at `now`: the listing does not filter a suspended or
|
|
37
|
+
* deleted account out, so without it a pane sees the person and cannot tell whether to offer suspend or reinstate.
|
|
38
|
+
* Not the reason and not who acted — those are the trail's.
|
|
39
|
+
*/
|
|
40
|
+
export declare function userView(user: User, now: Date): AdminUserView;
|
|
41
|
+
/**
|
|
42
|
+
* Where an account stands, as the wire carries it (#813) — the organization view's shape: the state, the end of a
|
|
43
|
+
* suspension in force, and the last day a deletion can be undone. Read through `accountStanding`, the function
|
|
44
|
+
* every enforcement point reads, so a suspension past its end reads `active` here exactly as it does at the door.
|
|
33
45
|
*/
|
|
34
|
-
export declare function
|
|
46
|
+
export declare function standingView(standing: AccountStanding): Required<Pick<AdminUserView, "state" | "suspendedUntil" | "purgeAfter">>;
|
|
35
47
|
/**
|
|
36
48
|
* The session projection — **without the token**.
|
|
37
49
|
*
|
|
@@ -55,6 +67,11 @@ export declare function sessionView(session: Session): AdminSessionView;
|
|
|
55
67
|
* adopter's users under the adopter's own app identity. It never leaves the Worker.
|
|
56
68
|
*/
|
|
57
69
|
export declare function deviceView(device: Device): AdminDeviceView;
|
|
70
|
+
/**
|
|
71
|
+
* One verification ledger row, as a management client sees it (#829). `state` is judged at `now`, the moment the
|
|
72
|
+
* read took, so it agrees with the counts beside it.
|
|
73
|
+
*/
|
|
74
|
+
export declare function verificationView(row: VerificationOutcome, now: Date): AdminVerificationView;
|
|
58
75
|
/**
|
|
59
76
|
* The suspension projection (#621): the suspension the transition left in force, and the sessions the route
|
|
60
77
|
* revoked after it. Dates cross as ISO-8601, like every other response here.
|
|
@@ -80,11 +97,14 @@ export declare function accountDeletionView(result: DeleteTransition): AccountDe
|
|
|
80
97
|
* theirs to disclose, not the person's, so the history carries the kind of actor and not its id.
|
|
81
98
|
*/
|
|
82
99
|
export declare function authUserExportView(input: {
|
|
100
|
+
/** The instant the export was taken, which its `state` is judged at. */
|
|
101
|
+
now: Date;
|
|
83
102
|
user: User;
|
|
84
103
|
sessions: readonly Session[];
|
|
85
104
|
accounts: readonly Pick<Account, "providerId" | "createdAt">[];
|
|
86
105
|
devices: readonly Device[];
|
|
87
106
|
history: readonly UserLifecycleEvent[];
|
|
107
|
+
verifications?: readonly VerificationOutcome[];
|
|
88
108
|
plugins?: Record<string, Record<string, unknown>[]>;
|
|
89
109
|
}): AuthUserExport;
|
|
90
110
|
/** The export document (#622): who it is about, when it was read, and every capability's part. */
|
package/dist/http/views.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../../src/http/views.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAA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C,aAAa,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;CACrD,GAAG,cAAc,CA0BjB;AAED,kGAAkG;AAClG,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,IAAI,EAChB,OAAO,EAAE,SAAS,gBAAgB,EAAE,GACnC,uBAAuB,CAMzB"}
|
package/dist/http/views.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { verificationStateAt } from "../data/verificationOutcome.js";
|
|
4
|
+
import { accountStanding } from "../lifecycle/state.js";
|
|
3
5
|
//#region src/http/views.ts
|
|
4
6
|
/**
|
|
5
7
|
* The admin projections — what a management client is shown of a user, a session, and a device.
|
|
@@ -25,8 +27,12 @@
|
|
|
25
27
|
* `locale` is projected for the same reason: a support pane answering "why is this person getting
|
|
26
28
|
* English emails" needs to see whether they ever chose, and null — never chosen — is the answer half
|
|
27
29
|
* the time. It is a preference, not a credential.
|
|
30
|
+
*
|
|
31
|
+
* Where the account stands is projected too (#813), judged at `now`: the listing does not filter a suspended or
|
|
32
|
+
* deleted account out, so without it a pane sees the person and cannot tell whether to offer suspend or reinstate.
|
|
33
|
+
* Not the reason and not who acted — those are the trail's.
|
|
28
34
|
*/
|
|
29
|
-
function userView(user) {
|
|
35
|
+
function userView(user, now) {
|
|
30
36
|
return {
|
|
31
37
|
id: user.id,
|
|
32
38
|
email: user.email,
|
|
@@ -35,7 +41,20 @@ function userView(user) {
|
|
|
35
41
|
image: user.image,
|
|
36
42
|
locale: user.locale,
|
|
37
43
|
createdAt: user.createdAt.toISOString(),
|
|
38
|
-
updatedAt: user.updatedAt.toISOString()
|
|
44
|
+
updatedAt: user.updatedAt.toISOString(),
|
|
45
|
+
...standingView(accountStanding(user, now))
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Where an account stands, as the wire carries it (#813) — the organization view's shape: the state, the end of a
|
|
50
|
+
* suspension in force, and the last day a deletion can be undone. Read through `accountStanding`, the function
|
|
51
|
+
* every enforcement point reads, so a suspension past its end reads `active` here exactly as it does at the door.
|
|
52
|
+
*/
|
|
53
|
+
function standingView(standing) {
|
|
54
|
+
return {
|
|
55
|
+
state: standing.state,
|
|
56
|
+
suspendedUntil: standing.state === "suspended" ? iso(standing.until) : null,
|
|
57
|
+
purgeAfter: standing.state === "deleted" ? iso(standing.purgeAfter) : null
|
|
39
58
|
};
|
|
40
59
|
}
|
|
41
60
|
/**
|
|
@@ -85,6 +104,22 @@ function deviceView(device) {
|
|
|
85
104
|
};
|
|
86
105
|
}
|
|
87
106
|
/**
|
|
107
|
+
* One verification ledger row, as a management client sees it (#829). `state` is judged at `now`, the moment the
|
|
108
|
+
* read took, so it agrees with the counts beside it.
|
|
109
|
+
*/
|
|
110
|
+
function verificationView(row, now) {
|
|
111
|
+
return {
|
|
112
|
+
verificationId: row.verificationId,
|
|
113
|
+
type: row.type,
|
|
114
|
+
state: verificationStateAt(row, now),
|
|
115
|
+
userId: row.userId,
|
|
116
|
+
emailJobId: row.emailJobId,
|
|
117
|
+
issuedAt: row.issuedAt.toISOString(),
|
|
118
|
+
expiresAt: row.expiresAt.toISOString(),
|
|
119
|
+
usedAt: row.usedAt?.toISOString() ?? null
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
88
123
|
* The suspension projection (#621): the suspension the transition left in force, and the sessions the route
|
|
89
124
|
* revoked after it. Dates cross as ISO-8601, like every other response here.
|
|
90
125
|
*/
|
|
@@ -155,7 +190,7 @@ function authUserExportView(input) {
|
|
|
155
190
|
const { user } = input;
|
|
156
191
|
return {
|
|
157
192
|
user: {
|
|
158
|
-
...userView(user),
|
|
193
|
+
...userView(user, input.now),
|
|
159
194
|
suspendedAt: iso(user.suspendedAt),
|
|
160
195
|
suspendedUntil: iso(user.suspendedUntil),
|
|
161
196
|
deletedAt: iso(user.deletedAt),
|
|
@@ -174,6 +209,7 @@ function authUserExportView(input) {
|
|
|
174
209
|
suspendedUntil: iso(event.suspendedUntil),
|
|
175
210
|
createdAt: event.createdAt.toISOString()
|
|
176
211
|
})),
|
|
212
|
+
verifications: (input.verifications ?? []).map((row) => verificationView(row, input.now)),
|
|
177
213
|
plugins: input.plugins ?? {}
|
|
178
214
|
};
|
|
179
215
|
}
|
|
@@ -189,4 +225,4 @@ function exportView(userId, exportedAt, entries) {
|
|
|
189
225
|
};
|
|
190
226
|
}
|
|
191
227
|
//#endregion
|
|
192
|
-
export { accountDeletionView, authUserExportView, deletionView, deviceView, exportView, reinstatementView, restorationView, sessionView, suspensionView, userView };
|
|
228
|
+
export { accountDeletionView, authUserExportView, deletionView, deviceView, exportView, reinstatementView, restorationView, sessionView, standingView, suspensionView, userView, verificationView };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,4 +13,6 @@ export { type AuthDatabase, authDatabase } from "./data/tables";
|
|
|
13
13
|
export { DEVICE_HEADERS, type DeviceMeta } from "./device/registry";
|
|
14
14
|
export { requireAuth } from "./http/middleware";
|
|
15
15
|
export { AppleOAuthCredentials, AUTH_APPLE_CREDENTIALS, AUTH_GOOGLE_CREDENTIALS, AUTH_SESSION_SECRET, authSecretsRegistry, GoogleOAuthCredentials, } from "./instance/secrets";
|
|
16
|
+
export { type McpCapability, McpConfig, type McpConfigInput, mcp } from "./mcp/capability";
|
|
17
|
+
export { McpFloor } from "./mcp/floor";
|
|
16
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CA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OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { AuthAuditActions } from "./audit/actions.js";
|
|
3
4
|
import { DevicePlatform } from "./data/device.js";
|
|
4
5
|
import { authDatabase } from "./data/tables.js";
|
|
5
6
|
import { AUTH_APPLE_CREDENTIALS, AUTH_GOOGLE_CREDENTIALS, AUTH_SESSION_SECRET, AppleOAuthCredentials, GoogleOAuthCredentials, authSecretsRegistry } from "./instance/secrets.js";
|
|
6
|
-
import { AuthAuditActions } from "./audit/actions.js";
|
|
7
7
|
import { DEVICE_HEADERS } from "./device/registry.js";
|
|
8
8
|
import { requireAuth } from "./http/middleware.js";
|
|
9
9
|
import { AuthConfig, auth, isAuthCapability } from "./capability.js";
|
|
10
|
-
|
|
10
|
+
import { McpFloor } from "./mcp/floor.js";
|
|
11
|
+
import { McpConfig, mcp } from "./mcp/capability.js";
|
|
12
|
+
export { AUTH_APPLE_CREDENTIALS, AUTH_GOOGLE_CREDENTIALS, AUTH_SESSION_SECRET, AppleOAuthCredentials, AuthAuditActions, AuthConfig, DEVICE_HEADERS, DevicePlatform, GoogleOAuthCredentials, McpConfig, McpFloor, auth, authDatabase, authSecretsRegistry, isAuthCapability, mcp, requireAuth };
|