@pithy-sh/auth 0.10.0 → 0.12.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/README.md +30 -2
- package/dist/admin/users.js +1 -1
- package/dist/audit/actions.d.ts +58 -0
- package/dist/audit/actions.d.ts.map +1 -1
- package/dist/audit/actions.js +59 -1
- package/dist/audit/emit.d.ts +36 -0
- package/dist/audit/emit.d.ts.map +1 -1
- package/dist/audit/emit.js +48 -2
- package/dist/audit/evidence.d.ts +8 -2
- package/dist/audit/evidence.d.ts.map +1 -1
- package/dist/capability.d.ts +47 -8
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +56 -6
- 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 +26 -4
- package/dist/data/tables.d.ts.map +1 -1
- package/dist/data/tables.js +5 -3
- package/dist/data/userLifecycle.d.ts +10 -0
- package/dist/data/userLifecycle.d.ts.map +1 -1
- package/dist/data/userLifecycle.js +8 -3
- 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 +319 -8
- package/dist/http/csrf.d.ts.map +1 -1
- package/dist/http/csrf.js +2 -1
- package/dist/http/guards.d.ts +15 -10
- package/dist/http/guards.d.ts.map +1 -1
- package/dist/http/guards.js +76 -10
- 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 +37 -1
- package/dist/http/middleware.d.ts.map +1 -1
- package/dist/http/middleware.js +68 -6
- package/dist/http/resolve.d.ts.map +1 -1
- package/dist/http/resolve.js +9 -3
- package/dist/http/responses.d.ts +322 -0
- package/dist/http/responses.d.ts.map +1 -1
- package/dist/http/responses.js +202 -5
- package/dist/http/routes.d.ts +3 -0
- package/dist/http/routes.d.ts.map +1 -1
- package/dist/http/routes.js +78 -5
- package/dist/http/schemas.d.ts +114 -0
- package/dist/http/schemas.d.ts.map +1 -1
- package/dist/http/schemas.js +94 -1
- package/dist/http/views.d.ts +60 -3
- package/dist/http/views.d.ts.map +1 -1
- package/dist/http/views.js +143 -3
- 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 +87 -42
- 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/audited.d.ts +48 -0
- package/dist/lifecycle/audited.d.ts.map +1 -0
- package/dist/lifecycle/audited.js +65 -0
- package/dist/lifecycle/enforce.d.ts +37 -2
- package/dist/lifecycle/enforce.d.ts.map +1 -1
- package/dist/lifecycle/enforce.js +46 -5
- 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/reason.d.ts +11 -0
- package/dist/lifecycle/reason.d.ts.map +1 -0
- package/dist/lifecycle/reason.js +13 -0
- package/dist/lifecycle/request.d.ts +5 -2
- package/dist/lifecycle/request.d.ts.map +1 -1
- package/dist/lifecycle/request.js +6 -2
- package/dist/lifecycle/transitions.d.ts +179 -18
- package/dist/lifecycle/transitions.d.ts.map +1 -1
- package/dist/lifecycle/transitions.js +391 -70
- 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/0005_purge_once.d.ts +22 -0
- package/dist/migrations/0005_purge_once.d.ts.map +1 -0
- package/dist/migrations/0005_purge_once.js +35 -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/pluginTables.d.ts +8 -0
- package/dist/migrations/pluginTables.d.ts.map +1 -1
- package/dist/migrations/pluginTables.js +8 -1
- package/dist/migrations/set.d.ts +5 -1
- package/dist/migrations/set.d.ts.map +1 -1
- package/dist/migrations/set.js +10 -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 +62 -0
- package/dist/purge/contribution.d.ts.map +1 -0
- package/dist/purge/contribution.js +155 -0
- package/dist/purge/retryPolicy.d.ts +22 -0
- package/dist/purge/retryPolicy.d.ts.map +1 -0
- package/dist/purge/retryPolicy.js +26 -0
- package/dist/purge/run.d.ts +158 -0
- package/dist/purge/run.d.ts.map +1 -0
- package/dist/purge/run.js +205 -0
- package/dist/purge/specs.d.ts +71 -0
- package/dist/purge/specs.d.ts.map +1 -0
- package/dist/purge/specs.js +72 -0
- package/dist/purge/start.d.ts +42 -0
- package/dist/purge/start.d.ts.map +1 -0
- package/dist/purge/start.js +37 -0
- package/dist/purge/workflow.d.ts +71 -0
- package/dist/purge/workflow.d.ts.map +1 -0
- package/dist/purge/workflow.js +140 -0
- package/dist/test-utils/accountFootprint.d.ts +13 -0
- package/dist/test-utils/accountFootprint.d.ts.map +1 -0
- package/dist/test-utils/accountFootprint.js +49 -0
- 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 +176 -12
- 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 +58 -0
- package/src/audit/emit.ts +66 -1
- package/src/audit/evidence.ts +8 -4
- package/src/capability.ts +122 -18
- 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 +19 -4
- package/src/data/verificationOutcome.ts +86 -0
- package/src/email/send.ts +2 -2
- package/src/http/adminRoutes.ts +465 -4
- package/src/http/csrf.ts +4 -1
- package/src/http/guards.ts +79 -10
- package/src/http/handoff.ts +350 -0
- package/src/http/middleware.ts +74 -5
- package/src/http/resolve.ts +25 -25
- package/src/http/responses.ts +374 -3
- package/src/http/routes.ts +116 -5
- package/src/http/schemas.ts +195 -0
- package/src/http/views.ts +192 -3
- package/src/index.ts +2 -0
- package/src/instance/auth.ts +58 -3
- package/src/instance/plugins.ts +20 -2
- package/src/ledger/read.ts +133 -0
- package/src/ledger/record.ts +198 -0
- package/src/lifecycle/audited.ts +104 -0
- package/src/lifecycle/enforce.ts +55 -5
- package/src/lifecycle/erasure.ts +118 -0
- package/src/lifecycle/inactivity.ts +56 -0
- package/src/lifecycle/reason.ts +11 -0
- package/src/lifecycle/request.ts +10 -2
- package/src/lifecycle/transitions.ts +552 -93
- 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/0005_purge_once.ts +42 -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/pluginTables.ts +19 -1
- package/src/migrations/set.ts +9 -1
- package/src/processing/activities.ts +14 -0
- package/src/purge/contribution.ts +218 -0
- package/src/purge/retryPolicy.ts +26 -0
- package/src/purge/run.ts +348 -0
- package/src/purge/specs.ts +95 -0
- package/src/purge/start.ts +79 -0
- package/src/purge/workflow.ts +202 -0
- package/src/seeds/example.ts +2 -2
- package/src/test-utils/accountFootprint.ts +104 -0
- package/src/test-utils/liveApp.ts +10 -1
- package/src/token/handoff.ts +180 -0
- package/src/version.generated.ts +1 -1
package/src/http/resolve.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
resolveMicrosoftCredentials,
|
|
24
24
|
resolveSessionSecrets,
|
|
25
25
|
} from "../instance/secrets";
|
|
26
|
+
import { mcpAuthorizationServer } from "../mcp/provider";
|
|
26
27
|
import { baseURLResolver } from "./baseUrl";
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -50,7 +51,7 @@ export function resolveDb(env: Record<string, unknown>, bindingName: string): D1
|
|
|
50
51
|
/**
|
|
51
52
|
* The language to write a sign-in email in, for one address.
|
|
52
53
|
*
|
|
53
|
-
* **The stored preference first, the request's negotiation second
|
|
54
|
+
* **The stored preference first, the request's negotiation second.** Somebody who
|
|
54
55
|
* picked a language in a settings pane has said something durable about themselves; the device they are
|
|
55
56
|
* signing in from tonight has only sent an `Accept-Language`. But most of what this is asked about is a
|
|
56
57
|
* *first* sign-in, where no row exists yet — and that is precisely the message a project cannot afford
|
|
@@ -90,23 +91,11 @@ async function buildAuthInstance(c: Context<PithyHonoEnv>, wiring: AuthWiring):
|
|
|
90
91
|
}
|
|
91
92
|
const env = c.env as unknown as AuthEnv;
|
|
92
93
|
// Secret resolutions hit the same per-invocation cache; run them concurrently. Six reads, and they
|
|
93
|
-
// are not alike
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
// single unreadable `auth-github-credentials` rejected the whole `Promise.all` and every magic-link
|
|
99
|
-
// and OTP caller in the deployment got the secrets reader's own refusal instead of a sign-in:
|
|
100
|
-
// measured, `404 secrets/not_found`, message `Secret 'auth-github-credentials' is declared but not
|
|
101
|
-
// provisioned.` So the old behavior named the secret loudly and named it to *the browser*, on a
|
|
102
|
-
// route that has nothing to do with GitHub. Both halves of that are fixed here.
|
|
103
|
-
//
|
|
104
|
-
// `resolveProvider` catches per provider and hands back a state rather than a rejection, so this
|
|
105
|
-
// `Promise.all` settles whenever the session secret does. What the instance then lacks is one
|
|
106
|
-
// provider, and `makeAuth`'s `before` hook answers a caller who asks for it — see `instance/providers.ts`.
|
|
107
|
-
//
|
|
108
|
-
// A held failure belongs to its own secret (#170), so an unreadable provider credential does not
|
|
109
|
-
// disturb the session secret's own read, and a *disabled* provider never calls `.get()` at all.
|
|
94
|
+
// are not alike. The session secret is what an auth instance *is*, so its failure fails this call, as
|
|
95
|
+
// `resolveDb` below does. A provider credential is one sign-in method among several: `resolveProvider`
|
|
96
|
+
// hands back a state rather than a rejection, so one unreadable credential costs that provider alone,
|
|
97
|
+
// answered by `makeAuth`'s `before` hook (`instance/providers.ts`), and never reaches a caller signing in
|
|
98
|
+
// another way. A disabled provider never reads its secret at all.
|
|
110
99
|
const [sessionSecrets, google, apple, facebook, github, microsoft] = await Promise.all([
|
|
111
100
|
resolveSessionSecrets(env),
|
|
112
101
|
resolveProvider(cfg.google.enabled, () => resolveGoogleCredentials(env)),
|
|
@@ -117,7 +106,7 @@ async function buildAuthInstance(c: Context<PithyHonoEnv>, wiring: AuthWiring):
|
|
|
117
106
|
]);
|
|
118
107
|
const expiresMinutes = Math.max(1, Math.round(cfg.verificationExpiresIn / 60));
|
|
119
108
|
const d1 = resolveDb(c.env, cfg.database);
|
|
120
|
-
// The current version signs; every retained one opens
|
|
109
|
+
// The current version signs; every retained one opens. A version set with no current entry is a
|
|
121
110
|
// corrupt envelope, and the store's own reader has already refused that — this narrows it for the type.
|
|
122
111
|
const secret = sessionSecrets.versions[sessionSecrets.currentVersion];
|
|
123
112
|
if (secret === undefined) {
|
|
@@ -139,6 +128,9 @@ async function buildAuthInstance(c: Context<PithyHonoEnv>, wiring: AuthWiring):
|
|
|
139
128
|
log: (c.get("log") ?? createWorkerLogger({ name: "auth" })).child("auth"),
|
|
140
129
|
});
|
|
141
130
|
const listener = wiring.onSessionRevoked;
|
|
131
|
+
// Never `cfg.baseURL` directly — see the `baseURL` key below. Named once, because the MCP endpoint's resource is
|
|
132
|
+
// built from the same address the instance runs under.
|
|
133
|
+
const baseURL = baseURLResolver(cfg.baseURL)(c.req.raw);
|
|
142
134
|
return makeAuth({
|
|
143
135
|
db: authDatabase(d1),
|
|
144
136
|
// The adopter's listener, bound to *this* request's binding. The instance is built per request, so
|
|
@@ -152,10 +144,10 @@ async function buildAuthInstance(c: Context<PithyHonoEnv>, wiring: AuthWiring):
|
|
|
152
144
|
// one of those has to name the address this run is actually serving on — not the production origin
|
|
153
145
|
// the config records. The gate lives in `baseURLResolver` and nowhere else; outside `dev` this is
|
|
154
146
|
// `cfg.baseURL`, unchanged. Resolved here because the instance is itself built per request.
|
|
155
|
-
baseURL
|
|
147
|
+
baseURL,
|
|
156
148
|
// The language this request negotiated, for the translator plugin. `c.var.locale` is the project's
|
|
157
149
|
// own chain already resolved — never a second negotiation of Better Auth's, which would let the
|
|
158
|
-
// screens and the refusals disagree about who is reading
|
|
150
|
+
// screens and the refusals disagree about who is reading. `null` when nothing negotiated,
|
|
159
151
|
// which is every project that does not compose `i18n`, and which means English.
|
|
160
152
|
locale: c.var.locale?.catalogLocale ?? null,
|
|
161
153
|
basePath: cfg.basePath,
|
|
@@ -175,9 +167,8 @@ async function buildAuthInstance(c: Context<PithyHonoEnv>, wiring: AuthWiring):
|
|
|
175
167
|
verificationExpiresIn: cfg.verificationExpiresIn,
|
|
176
168
|
otpLength: cfg.otpLength,
|
|
177
169
|
disableSignUp: cfg.disableSignUp,
|
|
178
|
-
// Per provider, and separate from the line above
|
|
179
|
-
//
|
|
180
|
-
// not say so before, which is how an orphan user appeared (#554).
|
|
170
|
+
// Per provider, and separate from the line above: `disableSignUp` governs magic link and OTP, this
|
|
171
|
+
// governs one OAuth provider, so a project can take email sign-up and refuse GitHub sign-up.
|
|
181
172
|
providerSignUp: {
|
|
182
173
|
google: cfg.google.allowSignUp,
|
|
183
174
|
apple: cfg.apple.allowSignUp,
|
|
@@ -195,6 +186,15 @@ async function buildAuthInstance(c: Context<PithyHonoEnv>, wiring: AuthWiring):
|
|
|
195
186
|
// The adopter's additional Better Auth plugins, exactly as `auth({ plugins: [...] })` declared them
|
|
196
187
|
// and already checked for additivity at `auth()` call time. The same list the derived migrations
|
|
197
188
|
// were built from — the routes a plugin serves and the tables it needs come from one declaration.
|
|
198
|
-
plugins:
|
|
189
|
+
plugins: wiring.mcp
|
|
190
|
+
? [
|
|
191
|
+
...cfg.plugins,
|
|
192
|
+
...mcpAuthorizationServer({
|
|
193
|
+
resource: `${baseURL}${wiring.mcp.path}`,
|
|
194
|
+
consentPage: wiring.mcp.consentPage,
|
|
195
|
+
clientDiscovery: wiring.mcp.clientDiscovery,
|
|
196
|
+
}),
|
|
197
|
+
]
|
|
198
|
+
: cfg.plugins,
|
|
199
199
|
});
|
|
200
200
|
}
|
package/src/http/responses.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { Locale } from "@pithy-sh/core/src/i18n/locale";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { DevicePlatform } from "../data/device";
|
|
7
|
+
import { VerificationState, VerificationType } from "../data/verificationOutcome";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* What the auth admin routes return, as Zod objects a management client can validate against.
|
|
@@ -59,6 +60,28 @@ export const AdminUserView = z
|
|
|
59
60
|
),
|
|
60
61
|
createdAt: z.iso.datetime().describe("When the user was created, ISO-8601."),
|
|
61
62
|
updatedAt: z.iso.datetime().describe("When the row was last written, ISO-8601."),
|
|
63
|
+
// Where the account stands (#813), on the organization view's shape. Each optional: absent from a Worker
|
|
64
|
+
// older than the field. No reason and no actor — the reason is on the trail, and the trail is audit's.
|
|
65
|
+
state: z
|
|
66
|
+
.enum(["active", "suspended", "deleted"])
|
|
67
|
+
.optional()
|
|
68
|
+
.describe(
|
|
69
|
+
"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.",
|
|
70
|
+
),
|
|
71
|
+
suspendedUntil: z.iso
|
|
72
|
+
.datetime()
|
|
73
|
+
.nullable()
|
|
74
|
+
.optional()
|
|
75
|
+
.describe(
|
|
76
|
+
"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.",
|
|
77
|
+
),
|
|
78
|
+
purgeAfter: z.iso
|
|
79
|
+
.datetime()
|
|
80
|
+
.nullable()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe(
|
|
83
|
+
"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.",
|
|
84
|
+
),
|
|
62
85
|
})
|
|
63
86
|
.describe("One user as a management client sees them. The table holds no credential, so nothing is withheld.");
|
|
64
87
|
export type AdminUserView = z.output<typeof AdminUserView>;
|
|
@@ -177,6 +200,70 @@ export const AdminDevicesResponse = z
|
|
|
177
200
|
.describe("A page of the device registry.");
|
|
178
201
|
export type AdminDevicesResponse = z.output<typeof AdminDevicesResponse>;
|
|
179
202
|
|
|
203
|
+
/**
|
|
204
|
+
* One sign-in link or code from the verification ledger (#829), as a management client sees it.
|
|
205
|
+
*
|
|
206
|
+
* Never the token and never the address: the ledger holds neither. The mail is named by its job id, which is how
|
|
207
|
+
* a reader holding `email:jobs:read` joins this to a bounce, a deferral or a suppression.
|
|
208
|
+
*/
|
|
209
|
+
export const AdminVerificationView = z
|
|
210
|
+
.object({
|
|
211
|
+
verificationId: z.string().describe("The verification row that carries it. Opaque; not a credential."),
|
|
212
|
+
type: VerificationType.describe("What was issued."),
|
|
213
|
+
state: VerificationState.describe("Where it stood at the moment of the read."),
|
|
214
|
+
userId: z
|
|
215
|
+
.string()
|
|
216
|
+
.nullable()
|
|
217
|
+
.describe(
|
|
218
|
+
"The account it signs in to — known at issue, or created by its use. Null for a sign-up nobody completed.",
|
|
219
|
+
),
|
|
220
|
+
emailJobId: z
|
|
221
|
+
.string()
|
|
222
|
+
.nullable()
|
|
223
|
+
.describe(
|
|
224
|
+
"The `pithy_email_jobs` row that carried it, under `email:jobs:read`. Null when the email seam failed and nothing was queued.",
|
|
225
|
+
),
|
|
226
|
+
issuedAt: z.iso.datetime().describe("When it was issued, ISO-8601."),
|
|
227
|
+
expiresAt: z.iso.datetime().describe("When it stops working, used or not, ISO-8601."),
|
|
228
|
+
usedAt: z.iso.datetime().nullable().describe("When it signed somebody in, ISO-8601, or null."),
|
|
229
|
+
})
|
|
230
|
+
.describe("One sign-in link or code: what it was, whose, the mail that carried it, and where it stands.");
|
|
231
|
+
export type AdminVerificationView = z.output<typeof AdminVerificationView>;
|
|
232
|
+
|
|
233
|
+
/** How many of one type were issued over the window, and where they stand. */
|
|
234
|
+
export const VerificationTypeCounts = z
|
|
235
|
+
.object({
|
|
236
|
+
type: VerificationType.describe("Which type these counts are for."),
|
|
237
|
+
issued: z.number().int().min(0).describe("How many were issued in the window."),
|
|
238
|
+
used: z.number().int().min(0).describe("How many of those signed somebody in."),
|
|
239
|
+
expired: z.number().int().min(0).describe("How many ran out unused."),
|
|
240
|
+
pending: z.number().int().min(0).describe("How many are unused and still work. The three add up to `issued`."),
|
|
241
|
+
})
|
|
242
|
+
.describe("One type's counts over the window, by state.");
|
|
243
|
+
export type VerificationTypeCounts = z.output<typeof VerificationTypeCounts>;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* `GET {base}/admin/verifications` (#829): the window it covered, the counts by type and state over all of it,
|
|
247
|
+
* and a page of its rows, newest issue first.
|
|
248
|
+
*
|
|
249
|
+
* The counts cover every row in the window whatever the page or the filters say, and every type, with zeros —
|
|
250
|
+
* so a pane reading "sign-in links: 0 issued" can tell it from a Worker that did not say.
|
|
251
|
+
*/
|
|
252
|
+
export const AdminVerificationsResponse = z
|
|
253
|
+
.object({
|
|
254
|
+
window: z
|
|
255
|
+
.object({
|
|
256
|
+
since: z.iso.datetime().describe("The window's start, inclusive, ISO-8601."),
|
|
257
|
+
until: z.iso.datetime().describe("The window's end, exclusive, ISO-8601."),
|
|
258
|
+
})
|
|
259
|
+
.describe("The window of issue times the counts and the rows cover."),
|
|
260
|
+
counts: z.array(VerificationTypeCounts).describe("Every type's counts over the whole window, by state."),
|
|
261
|
+
verifications: z.array(AdminVerificationView).describe("The page of rows, newest issue first."),
|
|
262
|
+
nextCursor: NextCursor,
|
|
263
|
+
})
|
|
264
|
+
.describe("The verification ledger over a window: counts by type and state, and the rows, paged.");
|
|
265
|
+
export type AdminVerificationsResponse = z.output<typeof AdminVerificationsResponse>;
|
|
266
|
+
|
|
180
267
|
/**
|
|
181
268
|
* `POST {base}/admin/sessions/revoke` and `POST {base}/admin/users/:userId/sessions/revoke`.
|
|
182
269
|
*
|
|
@@ -198,6 +285,256 @@ export const AdminDeviceRevokeResponse = z
|
|
|
198
285
|
.describe("How many sessions the device revocation ended, and whether the registry row went with them.");
|
|
199
286
|
export type AdminDeviceRevokeResponse = z.output<typeof AdminDeviceRevokeResponse>;
|
|
200
287
|
|
|
288
|
+
/**
|
|
289
|
+
* `POST {base}/admin/users/:userId/suspend` (#621).
|
|
290
|
+
*
|
|
291
|
+
* The suspension the account is now under, how many sessions ended with it, and whether the person was told.
|
|
292
|
+
* Not the reason: the caller wrote it, the trail keeps it, and echoing it back would put it in one more place
|
|
293
|
+
* a dashboard logs.
|
|
294
|
+
*/
|
|
295
|
+
export const AdminUserSuspendResponse = z
|
|
296
|
+
.object({
|
|
297
|
+
userId: z.string().describe("The account suspended, as `pithy_auth_users.id` stores it."),
|
|
298
|
+
state: z.literal("suspended").describe("Where the account stands now. Every sign-in and refresh is refused."),
|
|
299
|
+
outcome: z
|
|
300
|
+
.enum(["suspended", "updated"])
|
|
301
|
+
.describe(
|
|
302
|
+
"`suspended` when this call suspended an account in good standing; `updated` when it was already suspended and this call restated the reason and the end.",
|
|
303
|
+
),
|
|
304
|
+
suspendedAt: z.iso
|
|
305
|
+
.datetime()
|
|
306
|
+
.describe("When the suspension in force began, ISO-8601. A restatement keeps the original start."),
|
|
307
|
+
suspendedUntil: z.iso
|
|
308
|
+
.datetime()
|
|
309
|
+
.nullable()
|
|
310
|
+
.describe("When it ends by itself, ISO-8601, with nothing written to end it. Null lasts until a reinstatement."),
|
|
311
|
+
sessionsRevoked: RevokedCount,
|
|
312
|
+
mailed: z
|
|
313
|
+
.boolean()
|
|
314
|
+
.describe(
|
|
315
|
+
"Whether the account-suspended mail was enqueued. False for `notify: false`, when the config turns it off, or when no email capability is composed.",
|
|
316
|
+
),
|
|
317
|
+
})
|
|
318
|
+
.describe("A suspended account: since when, until when, how many sessions it cost, and whether the person was told.");
|
|
319
|
+
export type AdminUserSuspendResponse = z.output<typeof AdminUserSuspendResponse>;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* `POST {base}/admin/users/:userId/reinstate` (#621).
|
|
323
|
+
*
|
|
324
|
+
* No session count: a reinstatement restores none. The person signs in again.
|
|
325
|
+
*/
|
|
326
|
+
export const AdminUserReinstateResponse = z
|
|
327
|
+
.object({
|
|
328
|
+
userId: z.string().describe("The account reinstated, as `pithy_auth_users.id` stores it."),
|
|
329
|
+
state: z.literal("active").describe("Where the account stands now. It can sign in again."),
|
|
330
|
+
outcome: z
|
|
331
|
+
.enum(["reinstated", "unchanged"])
|
|
332
|
+
.describe(
|
|
333
|
+
"`reinstated` when this call lifted a suspension; `unchanged` when there was none in force — never suspended, or past its end — and nothing was written.",
|
|
334
|
+
),
|
|
335
|
+
mailed: z
|
|
336
|
+
.boolean()
|
|
337
|
+
.describe(
|
|
338
|
+
"Whether the account-reinstated mail was enqueued. Always false for `unchanged`, and on the same rule as a suspension's otherwise.",
|
|
339
|
+
),
|
|
340
|
+
})
|
|
341
|
+
.describe("A reinstated account, and whether the person was told. Its revoked sessions stay revoked.");
|
|
342
|
+
export type AdminUserReinstateResponse = z.output<typeof AdminUserReinstateResponse>;
|
|
343
|
+
|
|
344
|
+
/** When the purge may erase a deleted account, ISO-8601. */
|
|
345
|
+
const PurgeAfter = z.iso
|
|
346
|
+
.datetime()
|
|
347
|
+
.describe(
|
|
348
|
+
"When the purge may erase the account, ISO-8601. It can be restored until then; a hard deletion's is the moment it was deleted.",
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* `DELETE {base}/admin/users/:userId` (#622).
|
|
353
|
+
*
|
|
354
|
+
* What the deletion left in force, how many sessions ended with it, whether the person was told, and what
|
|
355
|
+
* became of the purge. Not the reason: the caller wrote it and the trail keeps it.
|
|
356
|
+
*/
|
|
357
|
+
export const AdminUserDeleteResponse = z
|
|
358
|
+
.object({
|
|
359
|
+
userId: z.string().describe("The account deleted, as `pithy_auth_users.id` stores it."),
|
|
360
|
+
state: z.literal("deleted").describe("Where the account stands now. Every sign-in and refresh is refused."),
|
|
361
|
+
mode: z.enum(["soft", "hard"]).describe("The mode this call ran in — `soft` unless the caller named `hard`."),
|
|
362
|
+
outcome: z
|
|
363
|
+
.enum(["deleted", "brought_forward", "unchanged"])
|
|
364
|
+
.describe(
|
|
365
|
+
"`deleted` when this call deleted an account in good standing; `brought_forward` when a hard deletion moved an already-deleted account's purge to now; `unchanged` when it was already deleted and there was nothing to move.",
|
|
366
|
+
),
|
|
367
|
+
deletedAt: z.iso.datetime().describe("When the account was deleted, ISO-8601. Kept by a deletion brought forward."),
|
|
368
|
+
purgeAfter: PurgeAfter,
|
|
369
|
+
purge: z
|
|
370
|
+
.enum(["scheduled", "started", "pending"])
|
|
371
|
+
.describe(
|
|
372
|
+
"`scheduled`: the daily purge erases it once `purgeAfter` passes. `started`: the purge Workflow was started by this call. `pending`: the purge is due and this Worker binds no purge Workflow to start, so it runs once one is bound.",
|
|
373
|
+
),
|
|
374
|
+
sessionsRevoked: RevokedCount,
|
|
375
|
+
mailed: z
|
|
376
|
+
.boolean()
|
|
377
|
+
.describe(
|
|
378
|
+
"Whether the deletion-scheduled mail was enqueued. Always false for `hard`, whose mail the purge sends, for `notify: false`, and when the config turns it off.",
|
|
379
|
+
),
|
|
380
|
+
})
|
|
381
|
+
.describe("A deleted account: when, until when it can be restored, what became of the purge, and its sessions.");
|
|
382
|
+
export type AdminUserDeleteResponse = z.output<typeof AdminUserDeleteResponse>;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* `POST {base}/admin/users/:userId/restore` (#622). No session count: a restoration restores none.
|
|
386
|
+
*/
|
|
387
|
+
export const AdminUserRestoreResponse = z
|
|
388
|
+
.object({
|
|
389
|
+
userId: z.string().describe("The account restored, as `pithy_auth_users.id` stores it."),
|
|
390
|
+
state: z
|
|
391
|
+
.enum(["active", "suspended"])
|
|
392
|
+
.describe(
|
|
393
|
+
"Where the account stands now: `active`, or `suspended` when a suspension it was under before the deletion is still in force.",
|
|
394
|
+
),
|
|
395
|
+
outcome: z
|
|
396
|
+
.enum(["restored", "unchanged"])
|
|
397
|
+
.describe("`restored` when this call restored a deleted account; `unchanged` when it was not deleted."),
|
|
398
|
+
})
|
|
399
|
+
.describe("A restored account, inside its purge window. Its revoked sessions stay revoked.");
|
|
400
|
+
export type AdminUserRestoreResponse = z.output<typeof AdminUserRestoreResponse>;
|
|
401
|
+
|
|
402
|
+
/** One provider link an account holds, as an export carries it — no provider token. */
|
|
403
|
+
const AuthExportProvider = z
|
|
404
|
+
.object({
|
|
405
|
+
providerId: z.string().describe("The sign-in provider's slug — `google`, `apple`, `github`."),
|
|
406
|
+
createdAt: z.iso.datetime().describe("When the provider was linked, ISO-8601."),
|
|
407
|
+
})
|
|
408
|
+
.describe("One sign-in provider linked to the account. The provider's tokens are credentials and are not here.");
|
|
409
|
+
|
|
410
|
+
/** One transition in an account's history, as an export carries it — not who made it. */
|
|
411
|
+
const AuthExportTransition = z
|
|
412
|
+
.object({
|
|
413
|
+
action: z
|
|
414
|
+
.string()
|
|
415
|
+
.describe(
|
|
416
|
+
"What happened: `suspended`, `reinstated`, `deleted`, `restored`, `purge_step`, `purge_retained`, `purge_failed`, `purged`.",
|
|
417
|
+
),
|
|
418
|
+
actorType: z.string().describe("Who made it: `control-plane`, `user` (the account's holder), or `system`."),
|
|
419
|
+
reason: z.string().nullable().describe("The reason given, in the words of whoever made the transition, or null."),
|
|
420
|
+
suspendedUntil: z.iso.datetime().nullable().describe("For a suspension, when it ends by itself, ISO-8601."),
|
|
421
|
+
createdAt: z.iso.datetime().describe("When it happened, ISO-8601."),
|
|
422
|
+
})
|
|
423
|
+
.describe(
|
|
424
|
+
"One transition in the account's history. The operator's identity is theirs, not the person's, so it is not here.",
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* What `@pithy-sh/auth` holds about one account, as its purge contribution exports it (#622) — the `data` of
|
|
429
|
+
* the `auth` entry in an export.
|
|
430
|
+
*
|
|
431
|
+
* The person's own data and none of their credentials: no session token, no provider token, no push token.
|
|
432
|
+
* Every list is whole, because an export that stopped at a bound would answer an access request with part of
|
|
433
|
+
* an answer.
|
|
434
|
+
*/
|
|
435
|
+
export const AuthUserExport = z
|
|
436
|
+
.object({
|
|
437
|
+
user: AdminUserView.extend({
|
|
438
|
+
suspendedAt: z.iso.datetime().nullable().describe("When a suspension in force began, ISO-8601, or null."),
|
|
439
|
+
suspendedUntil: z.iso.datetime().nullable().describe("When that suspension ends by itself, ISO-8601, or null."),
|
|
440
|
+
deletedAt: z.iso.datetime().nullable().describe("When the account was deleted, ISO-8601, or null."),
|
|
441
|
+
purgeAfter: z.iso.datetime().nullable().describe("When the purge may erase it, ISO-8601, or null."),
|
|
442
|
+
}).describe("The account itself, with where it stands."),
|
|
443
|
+
sessions: z.array(AdminSessionView).describe("Every live session, newest first. Without the tokens."),
|
|
444
|
+
providers: z.array(AuthExportProvider).describe("Every linked sign-in provider."),
|
|
445
|
+
devices: z
|
|
446
|
+
.array(AdminDeviceView)
|
|
447
|
+
.describe("Every registered device, most recently seen first. Without push tokens."),
|
|
448
|
+
history: z.array(AuthExportTransition).describe("Every lifecycle transition, oldest first."),
|
|
449
|
+
verifications: z
|
|
450
|
+
.array(AdminVerificationView)
|
|
451
|
+
.optional()
|
|
452
|
+
.describe(
|
|
453
|
+
"Every sign-in link and code the verification ledger records for the account, newest first (#829). Absent from a Worker that predates the ledger.",
|
|
454
|
+
),
|
|
455
|
+
plugins: z
|
|
456
|
+
.record(z.string(), z.array(z.record(z.string(), z.unknown())))
|
|
457
|
+
.describe(
|
|
458
|
+
"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.",
|
|
459
|
+
),
|
|
460
|
+
})
|
|
461
|
+
.describe("Everything `@pithy-sh/auth` holds about one account, without a credential.");
|
|
462
|
+
export type AuthUserExport = z.output<typeof AuthUserExport>;
|
|
463
|
+
|
|
464
|
+
/** Fields every capability's export entry carries. */
|
|
465
|
+
const exportEntry = {
|
|
466
|
+
capability: z.string().describe("The capability whose rows these are — the purge step that erases or keeps them."),
|
|
467
|
+
summary: z.string().describe("What that capability's purge erases, anonymizes or keeps, in its own sentence."),
|
|
468
|
+
disposition: z
|
|
469
|
+
.enum(["erase", "retain"])
|
|
470
|
+
.optional()
|
|
471
|
+
.describe(
|
|
472
|
+
"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`.",
|
|
473
|
+
),
|
|
474
|
+
basis: z
|
|
475
|
+
.string()
|
|
476
|
+
.optional()
|
|
477
|
+
.describe(
|
|
478
|
+
"For a `retain` entry, why the rows are kept, in one sentence written for the person — `Kept for tax records.` Absent for `erase`.",
|
|
479
|
+
),
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
/** One capability's part of an export. */
|
|
483
|
+
const AdminUserExportEntry = z
|
|
484
|
+
.discriminatedUnion("state", [
|
|
485
|
+
z
|
|
486
|
+
.object({
|
|
487
|
+
...exportEntry,
|
|
488
|
+
state: z.literal("exported").describe("The capability answered."),
|
|
489
|
+
data: z
|
|
490
|
+
.record(z.string(), z.unknown())
|
|
491
|
+
.describe(
|
|
492
|
+
"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.",
|
|
493
|
+
),
|
|
494
|
+
})
|
|
495
|
+
.describe("A capability's rows about the account."),
|
|
496
|
+
z
|
|
497
|
+
.object({
|
|
498
|
+
...exportEntry,
|
|
499
|
+
state: z
|
|
500
|
+
.literal("not_exported")
|
|
501
|
+
.describe(
|
|
502
|
+
"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.",
|
|
503
|
+
),
|
|
504
|
+
})
|
|
505
|
+
.describe("A capability that holds rows it does not export. Ask its owner."),
|
|
506
|
+
z
|
|
507
|
+
.object({
|
|
508
|
+
...exportEntry,
|
|
509
|
+
state: z.literal("unavailable").describe("The capability's rows could not be read on this request."),
|
|
510
|
+
})
|
|
511
|
+
.describe("Nothing was established about this capability's rows. Deliberately empty — it is not 'none'."),
|
|
512
|
+
])
|
|
513
|
+
.describe("One capability's part of an export, behind a state, so an unread part cannot be taken for an empty one.");
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* `GET {base}/admin/users/:userId/export` (#622).
|
|
517
|
+
*
|
|
518
|
+
* Everything the kit holds about one account — the answer to an access request. One entry per composed
|
|
519
|
+
* capability that declares a purge contribution, in the order the purge runs them, each read on its own so
|
|
520
|
+
* one that will not read costs its own entry and not the document.
|
|
521
|
+
*/
|
|
522
|
+
export const AdminUserExportResponse = z
|
|
523
|
+
.object({
|
|
524
|
+
subject: z
|
|
525
|
+
.object({
|
|
526
|
+
type: z.literal("user").describe("The kind of subject: one person's account."),
|
|
527
|
+
id: z.string().describe("The account's id, as `pithy_auth_users.id` stores it."),
|
|
528
|
+
})
|
|
529
|
+
.describe("Who this export is about."),
|
|
530
|
+
exportedAt: z.iso.datetime().describe("When the export was read, ISO-8601."),
|
|
531
|
+
capabilities: z
|
|
532
|
+
.array(AdminUserExportEntry)
|
|
533
|
+
.describe("Every composed capability's part, in the order the purge erases them."),
|
|
534
|
+
})
|
|
535
|
+
.describe("Everything the kit holds about one account, from every composed capability, as one document.");
|
|
536
|
+
export type AdminUserExportResponse = z.output<typeof AdminUserExportResponse>;
|
|
537
|
+
|
|
201
538
|
/*
|
|
202
539
|
* The routes a signed-in person calls on their own account. These are not read across the management
|
|
203
540
|
* version boundary the admin schemas above are, but a client generated from the contract reads Workers on
|
|
@@ -209,17 +546,34 @@ export const TokenRotateResponse = z
|
|
|
209
546
|
.object({
|
|
210
547
|
accessToken: z
|
|
211
548
|
.string()
|
|
212
|
-
.describe(
|
|
549
|
+
.describe(
|
|
550
|
+
"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.",
|
|
551
|
+
),
|
|
213
552
|
refreshToken: z
|
|
214
553
|
.string()
|
|
215
554
|
.describe(
|
|
216
|
-
"The successor
|
|
555
|
+
"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.",
|
|
217
556
|
),
|
|
218
557
|
expiresAt: z.iso.datetime().describe("When the successor session lapses, ISO-8601."),
|
|
219
558
|
})
|
|
220
|
-
.describe(
|
|
559
|
+
.describe(
|
|
560
|
+
"The rotated credentials: the session token that replaces the one presented, and a JWT for outside verifiers.",
|
|
561
|
+
);
|
|
221
562
|
export type TokenRotateResponse = z.output<typeof TokenRotateResponse>;
|
|
222
563
|
|
|
564
|
+
/** `POST {base}/handoff`. */
|
|
565
|
+
export const HandoffExchangeResponse = z
|
|
566
|
+
.object({
|
|
567
|
+
token: z
|
|
568
|
+
.string()
|
|
569
|
+
.describe(
|
|
570
|
+
"The raw session token: the bearer credential for `Authorization: Bearer`, and the refresh credential `/token/rotate` takes. Hold it in secure storage.",
|
|
571
|
+
),
|
|
572
|
+
expiresAt: z.iso.datetime().describe("When the session lapses unless it is rotated first, ISO-8601."),
|
|
573
|
+
})
|
|
574
|
+
.describe("The session a redirect sign-in made, handed to the native app that started it.");
|
|
575
|
+
export type HandoffExchangeResponse = z.output<typeof HandoffExchangeResponse>;
|
|
576
|
+
|
|
223
577
|
/** One of the caller's own registered devices. */
|
|
224
578
|
export const MyDeviceView = z
|
|
225
579
|
.object({
|
|
@@ -251,3 +605,20 @@ export const MyDeviceRevokeResponse = z
|
|
|
251
605
|
.object({ revoked: RevokedCount })
|
|
252
606
|
.describe("How many of the device's sessions the revocation signed out. The device's row goes with them.");
|
|
253
607
|
export type MyDeviceRevokeResponse = z.output<typeof MyDeviceRevokeResponse>;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* `DELETE {base}/account` (#622) — the signed-in person deleted their own account. Always soft, on the
|
|
611
|
+
* configured window. Their sessions end with it, this one included.
|
|
612
|
+
*/
|
|
613
|
+
export const AccountDeleteResponse = z
|
|
614
|
+
.object({
|
|
615
|
+
state: z.literal("deleted").describe("The account is deleted. This session and every other one has ended."),
|
|
616
|
+
purgeAfter: PurgeAfter,
|
|
617
|
+
mailed: z
|
|
618
|
+
.boolean()
|
|
619
|
+
.describe(
|
|
620
|
+
"Whether the deletion-scheduled mail, with the purge date and how to ask for the account back, was sent.",
|
|
621
|
+
),
|
|
622
|
+
})
|
|
623
|
+
.describe("The caller's own account, deleted: when its data will be erased, and whether they were mailed.");
|
|
624
|
+
export type AccountDeleteResponse = z.output<typeof AccountDeleteResponse>;
|