@krak-stack/auth 0.2.31 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +175 -1
  3. package/dist/access.d.ts +3 -1
  4. package/dist/admin/api.group.d.ts +41 -41
  5. package/dist/admin/schema.d.ts +23 -23
  6. package/dist/admin/schema.js +21 -19
  7. package/dist/api.d.ts +141 -81
  8. package/dist/auth/api.group.d.ts +37 -19
  9. package/dist/auth/api.group.js +17 -1
  10. package/dist/auth/schema.d.ts +61 -33
  11. package/dist/auth/schema.js +30 -18
  12. package/dist/components/account-deletion-request.d.ts +5 -0
  13. package/dist/components/account-deletion-request.js +7 -0
  14. package/dist/components/account-deletion.d.ts +8 -0
  15. package/dist/components/account-deletion.js +59 -0
  16. package/dist/components/admin-organization-form.js +2 -2
  17. package/dist/components/admin-organizations.js +9 -7
  18. package/dist/components/admin-users.js +6 -6
  19. package/dist/components/api-key-edit-form.js +19 -11
  20. package/dist/components/associated-projects-notice.d.ts +2 -1
  21. package/dist/components/associated-projects-notice.js +7 -3
  22. package/dist/components/auth-atoms.js +1 -2
  23. package/dist/components/auth-client-api.d.ts +94 -61
  24. package/dist/components/auth-forms.d.ts +1 -0
  25. package/dist/components/auth-forms.js +41 -56
  26. package/dist/components/auth-provider.d.ts +3 -1
  27. package/dist/components/deletion-visibility.d.ts +1 -0
  28. package/dist/components/deletion-visibility.js +3 -0
  29. package/dist/components/hooks.d.ts +2 -0
  30. package/dist/components/hooks.js +13 -6
  31. package/dist/components/index.d.ts +3 -0
  32. package/dist/components/index.js +2 -0
  33. package/dist/components/member-required.js +3 -5
  34. package/dist/components/oauth-consent.d.ts +22 -0
  35. package/dist/components/oauth-consent.js +79 -0
  36. package/dist/components/organization-deletion-request.d.ts +17 -0
  37. package/dist/components/organization-deletion-request.js +9 -0
  38. package/dist/components/organization-switcher.d.ts +1 -1
  39. package/dist/components/organization-switcher.js +113 -55
  40. package/dist/components/project-card-list.d.ts +6 -0
  41. package/dist/components/project-card-list.js +4 -0
  42. package/dist/components/user-button.d.ts +29 -1
  43. package/dist/components/user-button.js +145 -47
  44. package/dist/extra/api.group.d.ts +13 -1
  45. package/dist/extra/api.group.js +5 -1
  46. package/dist/extra/schema.d.ts +16 -1
  47. package/dist/extra/schema.js +13 -0
  48. package/dist/oauth/authorization.d.ts +3 -0
  49. package/dist/oauth/authorization.js +39 -0
  50. package/dist/oauth/schema.d.ts +24 -0
  51. package/dist/oauth/schema.js +12 -0
  52. package/dist/oauth/verify.d.ts +13 -0
  53. package/dist/oauth/verify.js +67 -0
  54. package/dist/schema.d.ts +35 -0
  55. package/dist/schema.js +26 -1
  56. package/dist/server/actor.js +2 -4
  57. package/dist/server/index.d.ts +4 -1
  58. package/dist/server/index.js +2 -0
  59. package/dist/server/mcp.d.ts +20 -0
  60. package/dist/server/mcp.js +66 -0
  61. package/dist/server/middleware.d.ts +15 -7
  62. package/dist/server/middleware.js +19 -6
  63. package/dist/server/webhook-layer.d.ts +6 -0
  64. package/dist/server/webhook-layer.js +41 -0
  65. package/dist/server/webhooks.d.ts +44 -0
  66. package/dist/server/webhooks.js +39 -0
  67. package/dist/service.d.ts +118 -46
  68. package/dist/service.js +56 -9
  69. package/package.json +8 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @krak-stack/auth
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cc882d8: Add shared OAuth consent and signed-query continuation components, MCP resource discovery and challenges, and resource-bound OAuth authentication with organization membership checks. Preserve API-key authentication and default OAuth API access to read-only methods.
8
+
9
+ Present translated consent permissions and require delegated write scope for exposed mutation methods without elevating the user's existing permissions.
10
+
11
+ ## 0.2.32
12
+
13
+ ### Patch Changes
14
+
15
+ - Require published Registry `0.1.61` or later for signed webhook-ID deduplication and the shared delivery table. Remove local Registry archive dependencies.
16
+ - Remove empty project-notice padding beneath user and organization menu headers.
17
+ - b497b8f: Require onDeleteUser when calling AuthMiddleware.layer. Projects provide their SQL cleanup callback; the middleware reads signing configuration, mounts the endpoint, and uses registry WebhooksReceiver for transactional deduplication. No separate auth-webhook service is needed. The layer now requires SQL; the former bare-auth-layer argument must be passed as authLayer in the options object.
18
+ - Temporarily hide account and organization deletion controls and dialogs in production builds, including admin organization deletion. Development builds retain these controls. Backend deletion authorization and cleanup remain unchanged.
19
+ - a46fb60: Add owner-confirmed organization deletion to the organization switcher and validated `organization.deletion_requested` cleanup webhooks, routed through the required `onDeleteOrganization` callback alongside `onDeleteUser`. Account deletion lists blocking organizations without deleting them. Unshared personal organizations are cleaned up with account deletion; standalone deletion remains protected.
20
+ - a46fb60: Use Registry's signed webhook-id for receiver deduplication and remove requestId and version from Auth webhook data. Requires the matching Registry signature protocol update on both sender and receiver.
21
+
3
22
  ## 0.2.31
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -57,6 +57,89 @@ const program = Effect.gen(function* () {
57
57
 
58
58
  Use `AuthMiddleware.layer()` to provide request headers and configuration in an Effect HttpApi application. See the [middleware guide](https://auth.krakstack.net/en/docs/middleware).
59
59
 
60
+ ### Auth webhooks
61
+
62
+ `AuthMiddleware.layer({ onDeleteUser, onDeleteOrganization })` requires both cleanup callbacks; there is no opt-out or default
63
+ successful cleanup. The SDK automatically mounts `POST /api/webhooks/auth`.
64
+ Every consuming project supplies only its application-specific SQL cleanup:
65
+
66
+ ```ts
67
+ import { AuthMiddleware } from "@krak-stack/auth/server";
68
+ import { Layer } from "effect";
69
+
70
+ const authentication = AuthMiddleware.layer({
71
+ onDeleteUser: ({ userId }) => eraseLocalUserData(userId),
72
+ onDeleteOrganization: ({ organizationId }) =>
73
+ eraseLocalOrganizationData(organizationId),
74
+ // Optional: handle other Auth events. Validate event-specific data here.
75
+ onWebhook: (webhook) => handleOtherAuthEvent(webhook),
76
+ }).pipe(Layer.provide(databaseLayer));
77
+ ```
78
+
79
+ Set server-only `KRAKSTACK_AUTH_WEBHOOK_SECRET` (at least 32 characters) and
80
+ `VITE_KRAKSTACK_AUTH_PROJECT_ID`, or pass explicit `webhookSecret: Redacted<string>` and
81
+ `projectId` options. Missing/invalid configuration fails setup. The cleanup must
82
+ use the same SQL pool as the receiver; it executes in the receipt transaction.
83
+ Do not perform external side effects or launch unawaited work in the callback.
84
+
85
+ The middleware uses `WebhooksReceiver` from `@krak-stack/registry/webhooks`.
86
+ Receiver migrations create only deduplication receipts, not delivery tables or
87
+ workers. Signed `user.deletion_requested` envelopes have data
88
+ fields `projectId`, `userId`, and `scope: "account"`. Requests are
89
+ HMAC-authenticated, project-validated, limited to 16 KiB, and acknowledged only
90
+ after commit. The timestamp window is five minutes. Duplicates return 204;
91
+ changed content under the same signed `webhook-id` returns 409.
92
+ `organization.deletion_requested` routes validated data (
93
+ `projectId`, `organizationId`, `scope: "organization"`) to `onDeleteOrganization`.
94
+ Neither deletion event routes to `onWebhook`. Other
95
+ events retain their event-specific JSON data and route to `onWebhook`; without a
96
+ handler they return 400, never a successful acknowledgement. Cleanup failures
97
+ roll back the receipt and return 500 so delivery can retry.
98
+
99
+ Signatures cover `${webhookId}.${timestamp}.${rawBody}`. Upgrade sender and receiver
100
+ together: legacy signatures over only timestamp/body are rejected. Neither `requestId`
101
+ nor `version` is required in webhook data.
102
+
103
+ Explicitly schedule `WebhooksReceiver.cleanup()` for receipts older than 30 days;
104
+ handlers must remain idempotent after expiry. Central Auth uses Better Auth's
105
+ native delete-user flow and durably notifies connected projects after the user
106
+ has been removed. Configure the project's **Webhook URL** and copy its **Signing
107
+ secret** into the receiving server. Platform admins and organization owners must
108
+ transfer their roles before self-deleting. This does not guarantee that a project's
109
+ callback covers all personal data. Inventory invitations, logs, exports,
110
+ processors, and backups before claiming complete erasure. Use
111
+ `@krak-stack/registry` `0.1.61` or later and upgrade sender and receiver together.
112
+ Account and organization deletion controls are temporarily hidden in production
113
+ builds, including admin organization deletion. Central Auth also rejects user
114
+ deletion (including admin removal) and organization deletion on the server unless
115
+ `NODE_ENV` is explicitly `development` or `test`. Missing configuration fails closed.
116
+ Webhook receivers remain available independently of this deletion rollout gate.
117
+
118
+ **Français :** `AuthMiddleware.layer({ onDeleteUser, onDeleteOrganization })` exige les deux fonctions de nettoyage et monte la route de
119
+ réception automatiquement. Chaque projet doit fournir son nettoyage SQL et le
120
+ secret de signature côté serveur ; une configuration absente empêche le
121
+ démarrage. Le reçu et le nettoyage sont validés dans la même transaction.
122
+ Un doublon retourne 204, un conflit de contenu 409 et un échec de nettoyage 500.
123
+ La réception seule ne démarre aucun travailleur d’envoi. Planifier le nettoyage
124
+ des reçus après 30 jours et conserver un traitement idempotent. Le parcours de
125
+ suppression central utilise Better Auth et notifie les projets après suppression
126
+ de l’utilisateur. Configurez l’URL du webhook et son secret de signature dans le
127
+ projet. Les administrateurs de plateforme et propriétaires d’organisation doivent
128
+ d’abord transférer leurs rôles. `onDeleteUser` reçoit les données validées de suppression du compte ;
129
+ `onDeleteOrganization` reçoit celles de suppression de l’organisation.
130
+ Le gestionnaire facultatif `onWebhook` reçoit les
131
+ autres événements avec leurs données JSON ; sans gestionnaire, ils retournent 400.
132
+ La déduplication utilise l’en-tête `webhook-id` signé. Aucun `requestId` n’est requis dans les données.
133
+ La signature couvre `${webhookId}.${timestamp}.${rawBody}`. Mettre à jour les deux côtés ensemble :
134
+ les anciennes signatures sont refusées. Aucun champ `version` n’est requis dans les données.
135
+ Ce mécanisme ne garantit pas, à lui seul, la conformité ou l’effacement complet.
136
+ Utilisez `@krak-stack/registry` `0.1.61` ou une version ultérieure et mettez à jour les deux côtés ensemble.
137
+ Les commandes de suppression de compte et d’organisation, y compris dans l’administration,
138
+ sont temporairement masquées en production. Le serveur central refuse également la
139
+ suppression d’utilisateur (y compris par un administrateur) et d’organisation sauf si
140
+ `NODE_ENV` vaut explicitement `development` ou `test`. Les récepteurs de webhooks
141
+ restent disponibles indépendamment de cette restriction.
142
+
60
143
  `AuthMiddleware` also annotates request logs and spans with verified user,
61
144
  organization, and actor IDs using its existing session lookup. Missing sessions
62
145
  are anonymous; auth service failures are not silently treated as anonymous.
@@ -85,9 +168,100 @@ without it, the middleware covers every route it is provided to. The router
85
168
  adapter uses the same auth configuration and organization-impersonation policy
86
169
  as `AuthMiddleware.layer()`. It does not grant permissions or provide `CurrentActor`.
87
170
 
171
+ ## MCP OAuth
172
+
173
+ Keep the OAuth provider and its database in KrakStack Auth. Consumer projects
174
+ provide resource discovery and verify resource-bound access tokens:
175
+
176
+ ```ts
177
+ import { AuthMiddleware, McpAuth } from "@krak-stack/auth/server";
178
+
179
+ const oauth = {
180
+ issuer: "https://learning.example.com/api/auth",
181
+ resource: "https://learning.example.com/api/mcp",
182
+ jwksUrl: "https://learning.example.com/api/auth/jwks",
183
+ requiredScopes: ["mcp:read"],
184
+ scopesSupported: ["mcp:read", "mcp:write", "offline_access"],
185
+ challengeScopes: ["mcp:read", "mcp:write", "offline_access"],
186
+ };
187
+
188
+ // Add this beside the existing MCP routes.
189
+ const metadata = McpAuth.metadataLayer(oauth);
190
+ // Provide this middleware to the MCP transport layer.
191
+ const mcpAuthentication = McpAuth.middleware(oauth).layer;
192
+ // Add `oauth` to the existing AuthMiddleware.layer({ ... }) configuration.
193
+ ```
194
+
195
+ Expose `/.well-known/$` to the HTTP router too. `McpAuth.discoveryRequest(request,
196
+ oauth)` accepts supported resource-metadata paths and rewrites the RFC 8414
197
+ authorization-server metadata path to the existing `/api/auth/*` proxy. It
198
+ returns `undefined` for unrelated paths. This helper assumes the consumer hosts
199
+ the issuer through its authenticated auth proxy; an independently hosted issuer
200
+ serves its own authorization metadata.
201
+
202
+ Use `OAuthConsent` from `@krak-stack/auth/components` in a thin `/consent` route.
203
+ Pass translated `messages` (`title`, `description({ clientName })`,
204
+ `requestedScopes`, `allow`, `deny`, `error`, `invalidRequest`). It reads the
205
+ provider's signed query, identifies the requesting client, submits the decision,
206
+ and navigates to the provider-validated callback. Do not put consent under a
207
+ guest-only layout. Guest-only sign-in guards should preserve authorization
208
+ requests identified by `getOAuthAuthorizationQuery(location.searchStr)`.
209
+ Provide the optional `messages.permissions` map to show translated permission
210
+ titles/descriptions instead of OAuth scope codes. Unknown scopes remain visible.
211
+ Keep app branding and locale switching in the shared auth-page layout.
212
+
213
+ Deployment prerequisites:
214
+
215
+ - Register the consumer host as an active project domain and authorize its
216
+ existing service key to proxy that project.
217
+ - In **Project → Settings → MCP**, enter the exact endpoint URL and enable it.
218
+ Choose **Read and write** under **Access** to allow `mcp:write`, or **Read only**
219
+ to restrict delegation. This persists the resource and automatically enables
220
+ PKCE-protected client registration. No MCP
221
+ environment variable or auth restart is required. The endpoint's host must
222
+ belong to an active domain of this project.
223
+ - Alternatively, pre-register each agent's OAuth client with its exact callback, PKCE enabled,
224
+ `mcp:read offline_access` scopes, and a link to the resource. The admin client
225
+ creation payload accepts `resources`, `publicClient`, and `nativeClient`.
226
+ Public clients use no client secret; native clients support loopback callbacks.
227
+ - Configure that client ID in the MCP client when using pre-registration.
228
+ The provider advertises anonymous DCR on the configured endpoint's host only.
229
+ New clients are linked only to that MCP resource and require PKCE. Scopes
230
+ restrict delegated access; they never elevate the authenticated user's role
231
+ or permissions. Clients must still obtain user
232
+ consent. Loopback HTTP callbacks without an explicit application type are
233
+ classified as native; HTTPS callbacks keep the provider's web-client policy.
234
+ Registration is rate-limited per auth instance; enforce shared ingress limits
235
+ for multi-instance deployments. Other auth hosts keep DCR disabled.
236
+ - Deploy the provider changes before connecting clients. The provider disables
237
+ session-JWT issuance at `/token` and binds MCP grants to the user's active
238
+ organization at consent. Existing identity-only tokens are not MCP tokens.
239
+
240
+ Bearer tokens take precedence over cookies and API keys and never downgrade on
241
+ failure. Verification checks the signature, issuer, audience, expiry, access-token
242
+ type, authorized client, scopes, and consented organization. The SDK rechecks
243
+ membership and user bans and ignores caller-supplied organization overrides.
244
+ `ActorRequired` continues to enforce ordinary tenant roles and domain policies.
245
+ OAuth API requests default to GET/HEAD only; explicitly configure `allowedMethods`
246
+ before exposing mutations. Non-GET/HEAD requests additionally require `mcp:write`
247
+ (override with `writeScope` for a different scope vocabulary), and normal user
248
+ authorization still applies. Project settings do not automatically expose new
249
+ tools or API methods in consumer applications. MCP transport POSTs
250
+ are authenticated separately and do not grant write access to the API.
251
+
252
+ Disabling or changing the endpoint disables its previous OAuth resource and
253
+ removes client/resource links. Clients must reconnect. Auth re-reads policy and
254
+ domain ownership on each request, so cached instances cannot keep advertising a
255
+ disabled configuration. Apply database migration 4 before deploying this feature.
256
+
257
+ This integration currently accepts bearer JWT access tokens, not opaque or
258
+ DPoP-bound tokens. JWT verification is local: revoking a grant does not immediately
259
+ invalidate an already-issued JWT before expiry. Keep access-token lifetimes short;
260
+ refresh and grant revocation remain provider-owned.
261
+
88
262
  ## React Components
89
263
 
90
- The component bundle uses the optional peer dependencies declared in `package.json` and Krakstack/shadcn UI primitives from `@krak-stack/registry`. Install the component peers used by your application; server-only consumers only need `effect`.
264
+ The component bundle uses the optional peer dependencies declared in `package.json` and Krakstack/shadcn UI primitives from `@krak-stack/registry`. Install the component peers used by your application. Server middleware needs `effect`, the matching registry package, and an SQL pool; React component peers are not needed for server-only use.
91
265
 
92
266
  When components are configured, register their Tailwind source:
93
267
 
package/dist/access.d.ts CHANGED
@@ -28,7 +28,9 @@ export type CurrentActor = {
28
28
  readonly permissions: ReadonlySet<string>;
29
29
  };
30
30
  export declare const CurrentActor: Context.Service<CurrentActor, CurrentActor>;
31
- declare const Forbidden_base: Schema.Class<Forbidden, Schema.TaggedStruct<"Forbidden", {}>, import("effect/Cause").YieldableError>;
31
+ declare const Forbidden_base: Schema.Class<Forbidden, Schema.TaggedStruct<"Forbidden", {}>, import("effect/Cause").YieldableError & {
32
+ readonly brand: unique symbol;
33
+ }>;
32
34
  export declare class Forbidden extends Forbidden_base {
33
35
  }
34
36
  export type Policy<E = never, R = never> = Effect.Effect<void, Forbidden | E, CurrentActor | R>;
@@ -35,7 +35,7 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
35
35
  readonly metadata: Schema.optional<Schema.NullOr<Schema.String>>;
36
36
  readonly userId: Schema.optional<Schema.NullOr<Schema.String>>;
37
37
  readonly parentId: Schema.optional<Schema.NullOr<Schema.String>>;
38
- readonly memberCount: Schema.optional<Schema.Number>;
38
+ readonly memberCount: Schema.optional<Schema.Finite>;
39
39
  readonly memberPreviews: Schema.optional<Schema.$Array<Schema.Struct<{
40
40
  readonly id: Schema.String;
41
41
  readonly name: Schema.String;
@@ -51,26 +51,26 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
51
51
  }>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"dashboardStats", "GET", "/admin/dashboard-stats", never, Schema.toCodecStringTree<Schema.Struct<{
52
52
  readonly days: Schema.optional<Schema.Union<readonly [Schema.Literal<"7">, Schema.Literal<"14">, Schema.Literal<"30">, Schema.Literal<"90">]>>;
53
53
  }>>, never, never, Schema.toCodecJson<Schema.Struct<{
54
- readonly totalUsers: Schema.Number;
55
- readonly totalOrganizations: Schema.Number;
56
- readonly totalProjects: Schema.Number;
57
- readonly totalDomains: Schema.Number;
58
- readonly totalApiKeys: Schema.Number;
59
- readonly totalOauthClients: Schema.Number;
60
- readonly dailyActiveUsers: Schema.Number;
54
+ readonly totalUsers: Schema.Finite;
55
+ readonly totalOrganizations: Schema.Finite;
56
+ readonly totalProjects: Schema.Finite;
57
+ readonly totalDomains: Schema.Finite;
58
+ readonly totalApiKeys: Schema.Finite;
59
+ readonly totalOauthClients: Schema.Finite;
60
+ readonly dailyActiveUsers: Schema.Finite;
61
61
  readonly dailyActiveUsersByDay: Schema.$Array<Schema.Struct<{
62
62
  readonly date: Schema.String;
63
- readonly count: Schema.Number;
63
+ readonly count: Schema.Finite;
64
64
  }>>;
65
65
  readonly signupsByDay: Schema.$Array<Schema.Struct<{
66
66
  readonly date: Schema.String;
67
- readonly count: Schema.Number;
67
+ readonly count: Schema.Finite;
68
68
  }>>;
69
69
  readonly projectConnections: Schema.$Array<Schema.Struct<{
70
70
  readonly projectId: Schema.String;
71
71
  readonly projectName: Schema.String;
72
- readonly users: Schema.Number;
73
- readonly organizations: Schema.Number;
72
+ readonly users: Schema.Finite;
73
+ readonly organizations: Schema.Finite;
74
74
  }>>;
75
75
  }>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"deleteApiKey", "DELETE", "/admin/api-keys/:id", Schema.toCodecStringTree<Schema.Struct<{
76
76
  readonly id: Schema.String;
@@ -83,10 +83,10 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
83
83
  readonly prefix: Schema.NullOr<Schema.String>;
84
84
  readonly enabled: Schema.Boolean;
85
85
  readonly rateLimitEnabled: Schema.Boolean;
86
- readonly rateLimitTimeWindow: Schema.NullOr<Schema.Number>;
87
- readonly rateLimitMax: Schema.NullOr<Schema.Number>;
88
- readonly requestCount: Schema.Number;
89
- readonly remaining: Schema.NullOr<Schema.Number>;
86
+ readonly rateLimitTimeWindow: Schema.NullOr<Schema.Finite>;
87
+ readonly rateLimitMax: Schema.NullOr<Schema.Finite>;
88
+ readonly requestCount: Schema.Finite;
89
+ readonly remaining: Schema.NullOr<Schema.Finite>;
90
90
  readonly lastRequest: Schema.NullOr<Schema.Date>;
91
91
  readonly expiresAt: Schema.NullOr<Schema.Date>;
92
92
  readonly referrers: Schema.$Array<Schema.String>;
@@ -120,7 +120,7 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
120
120
  readonly metadata: Schema.optional<Schema.NullOr<Schema.String>>;
121
121
  readonly userId: Schema.optional<Schema.NullOr<Schema.String>>;
122
122
  readonly parentId: Schema.optional<Schema.NullOr<Schema.String>>;
123
- readonly memberCount: Schema.optional<Schema.Number>;
123
+ readonly memberCount: Schema.optional<Schema.Finite>;
124
124
  readonly memberPreviews: Schema.optional<Schema.$Array<Schema.Struct<{
125
125
  readonly id: Schema.String;
126
126
  readonly name: Schema.String;
@@ -144,10 +144,10 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
144
144
  readonly prefix: Schema.NullOr<Schema.String>;
145
145
  readonly enabled: Schema.Boolean;
146
146
  readonly rateLimitEnabled: Schema.Boolean;
147
- readonly rateLimitTimeWindow: Schema.NullOr<Schema.Number>;
148
- readonly rateLimitMax: Schema.NullOr<Schema.Number>;
149
- readonly requestCount: Schema.Number;
150
- readonly remaining: Schema.NullOr<Schema.Number>;
147
+ readonly rateLimitTimeWindow: Schema.NullOr<Schema.Finite>;
148
+ readonly rateLimitMax: Schema.NullOr<Schema.Finite>;
149
+ readonly requestCount: Schema.Finite;
150
+ readonly remaining: Schema.NullOr<Schema.Finite>;
151
151
  readonly lastRequest: Schema.NullOr<Schema.Date>;
152
152
  readonly expiresAt: Schema.NullOr<Schema.Date>;
153
153
  readonly referrers: Schema.$Array<Schema.String>;
@@ -165,10 +165,10 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
165
165
  readonly prefix: Schema.NullOr<Schema.String>;
166
166
  readonly enabled: Schema.Boolean;
167
167
  readonly rateLimitEnabled: Schema.Boolean;
168
- readonly rateLimitTimeWindow: Schema.NullOr<Schema.Number>;
169
- readonly rateLimitMax: Schema.NullOr<Schema.Number>;
170
- readonly requestCount: Schema.Number;
171
- readonly remaining: Schema.NullOr<Schema.Number>;
168
+ readonly rateLimitTimeWindow: Schema.NullOr<Schema.Finite>;
169
+ readonly rateLimitMax: Schema.NullOr<Schema.Finite>;
170
+ readonly requestCount: Schema.Finite;
171
+ readonly remaining: Schema.NullOr<Schema.Finite>;
172
172
  readonly lastRequest: Schema.NullOr<Schema.Date>;
173
173
  readonly expiresAt: Schema.NullOr<Schema.Date>;
174
174
  readonly referrers: Schema.$Array<Schema.String>;
@@ -192,10 +192,10 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
192
192
  readonly prefix: Schema.NullOr<Schema.String>;
193
193
  readonly enabled: Schema.Boolean;
194
194
  readonly rateLimitEnabled: Schema.Boolean;
195
- readonly rateLimitTimeWindow: Schema.NullOr<Schema.Number>;
196
- readonly rateLimitMax: Schema.NullOr<Schema.Number>;
197
- readonly requestCount: Schema.Number;
198
- readonly remaining: Schema.NullOr<Schema.Number>;
195
+ readonly rateLimitTimeWindow: Schema.NullOr<Schema.Finite>;
196
+ readonly rateLimitMax: Schema.NullOr<Schema.Finite>;
197
+ readonly requestCount: Schema.Finite;
198
+ readonly remaining: Schema.NullOr<Schema.Finite>;
199
199
  readonly lastRequest: Schema.NullOr<Schema.Date>;
200
200
  readonly expiresAt: Schema.NullOr<Schema.Date>;
201
201
  readonly referrers: Schema.$Array<Schema.String>;
@@ -285,7 +285,7 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
285
285
  readonly metadata: Schema.optional<Schema.NullOr<Schema.String>>;
286
286
  readonly userId: Schema.optional<Schema.NullOr<Schema.String>>;
287
287
  readonly parentId: Schema.optional<Schema.NullOr<Schema.String>>;
288
- readonly memberCount: Schema.optional<Schema.Number>;
288
+ readonly memberCount: Schema.optional<Schema.Finite>;
289
289
  readonly memberPreviews: Schema.optional<Schema.$Array<Schema.Struct<{
290
290
  readonly id: Schema.String;
291
291
  readonly name: Schema.String;
@@ -405,10 +405,10 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
405
405
  readonly prefix: Schema.NullOr<Schema.String>;
406
406
  readonly enabled: Schema.Boolean;
407
407
  readonly rateLimitEnabled: Schema.Boolean;
408
- readonly rateLimitTimeWindow: Schema.NullOr<Schema.Number>;
409
- readonly rateLimitMax: Schema.NullOr<Schema.Number>;
410
- readonly requestCount: Schema.Number;
411
- readonly remaining: Schema.NullOr<Schema.Number>;
408
+ readonly rateLimitTimeWindow: Schema.NullOr<Schema.Finite>;
409
+ readonly rateLimitMax: Schema.NullOr<Schema.Finite>;
410
+ readonly requestCount: Schema.Finite;
411
+ readonly remaining: Schema.NullOr<Schema.Finite>;
412
412
  readonly lastRequest: Schema.NullOr<Schema.Date>;
413
413
  readonly expiresAt: Schema.NullOr<Schema.Date>;
414
414
  readonly referrers: Schema.$Array<Schema.String>;
@@ -421,8 +421,8 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
421
421
  readonly name: Schema.optional<Schema.NullOr<Schema.String>>;
422
422
  readonly enabled: Schema.optional<Schema.Boolean>;
423
423
  readonly rateLimitEnabled: Schema.optional<Schema.Boolean>;
424
- readonly rateLimitMax: Schema.optional<Schema.NullOr<Schema.Number>>;
425
- readonly rateLimitTimeWindow: Schema.optional<Schema.NullOr<Schema.Number>>;
424
+ readonly rateLimitMax: Schema.optional<Schema.NullOr<Schema.Finite>>;
425
+ readonly rateLimitTimeWindow: Schema.optional<Schema.NullOr<Schema.Finite>>;
426
426
  readonly referrers: Schema.optional<Schema.$Array<Schema.String>>;
427
427
  }>>, never, Schema.toCodecJson<Schema.Struct<{
428
428
  readonly id: Schema.String;
@@ -433,10 +433,10 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
433
433
  readonly prefix: Schema.NullOr<Schema.String>;
434
434
  readonly enabled: Schema.Boolean;
435
435
  readonly rateLimitEnabled: Schema.Boolean;
436
- readonly rateLimitTimeWindow: Schema.NullOr<Schema.Number>;
437
- readonly rateLimitMax: Schema.NullOr<Schema.Number>;
438
- readonly requestCount: Schema.Number;
439
- readonly remaining: Schema.NullOr<Schema.Number>;
436
+ readonly rateLimitTimeWindow: Schema.NullOr<Schema.Finite>;
437
+ readonly rateLimitMax: Schema.NullOr<Schema.Finite>;
438
+ readonly requestCount: Schema.Finite;
439
+ readonly remaining: Schema.NullOr<Schema.Finite>;
440
440
  readonly lastRequest: Schema.NullOr<Schema.Date>;
441
441
  readonly expiresAt: Schema.NullOr<Schema.Date>;
442
442
  readonly referrers: Schema.$Array<Schema.String>;
@@ -481,7 +481,7 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
481
481
  readonly metadata: Schema.optional<Schema.NullOr<Schema.String>>;
482
482
  readonly userId: Schema.optional<Schema.NullOr<Schema.String>>;
483
483
  readonly parentId: Schema.optional<Schema.NullOr<Schema.String>>;
484
- readonly memberCount: Schema.optional<Schema.Number>;
484
+ readonly memberCount: Schema.optional<Schema.Finite>;
485
485
  readonly memberPreviews: Schema.optional<Schema.$Array<Schema.Struct<{
486
486
  readonly id: Schema.String;
487
487
  readonly name: Schema.String;
@@ -275,7 +275,7 @@ export declare const AdminOrganization: Schema.Struct<{
275
275
  readonly metadata: Schema.optional<Schema.NullOr<Schema.String>>;
276
276
  readonly userId: Schema.optional<Schema.NullOr<Schema.String>>;
277
277
  readonly parentId: Schema.optional<Schema.NullOr<Schema.String>>;
278
- readonly memberCount: Schema.optional<Schema.Number>;
278
+ readonly memberCount: Schema.optional<Schema.Finite>;
279
279
  readonly memberPreviews: Schema.optional<Schema.$Array<Schema.Struct<{
280
280
  readonly id: Schema.String;
281
281
  readonly name: Schema.String;
@@ -304,10 +304,10 @@ export declare const AdminApiKey: Schema.Struct<{
304
304
  readonly prefix: Schema.NullOr<Schema.String>;
305
305
  readonly enabled: Schema.Boolean;
306
306
  readonly rateLimitEnabled: Schema.Boolean;
307
- readonly rateLimitTimeWindow: Schema.NullOr<Schema.Number>;
308
- readonly rateLimitMax: Schema.NullOr<Schema.Number>;
309
- readonly requestCount: Schema.Number;
310
- readonly remaining: Schema.NullOr<Schema.Number>;
307
+ readonly rateLimitTimeWindow: Schema.NullOr<Schema.Finite>;
308
+ readonly rateLimitMax: Schema.NullOr<Schema.Finite>;
309
+ readonly requestCount: Schema.Finite;
310
+ readonly remaining: Schema.NullOr<Schema.Finite>;
311
311
  readonly lastRequest: Schema.NullOr<Schema.Date>;
312
312
  readonly expiresAt: Schema.NullOr<Schema.Date>;
313
313
  readonly referrers: Schema.$Array<Schema.String>;
@@ -319,8 +319,8 @@ export declare const AdminUpdateApiKeyPayload: Schema.Struct<{
319
319
  readonly name: Schema.optional<Schema.NullOr<Schema.String>>;
320
320
  readonly enabled: Schema.optional<Schema.Boolean>;
321
321
  readonly rateLimitEnabled: Schema.optional<Schema.Boolean>;
322
- readonly rateLimitMax: Schema.optional<Schema.NullOr<Schema.Number>>;
323
- readonly rateLimitTimeWindow: Schema.optional<Schema.NullOr<Schema.Number>>;
322
+ readonly rateLimitMax: Schema.optional<Schema.NullOr<Schema.Finite>>;
323
+ readonly rateLimitTimeWindow: Schema.optional<Schema.NullOr<Schema.Finite>>;
324
324
  readonly referrers: Schema.optional<Schema.$Array<Schema.String>>;
325
325
  }>;
326
326
  export declare const AdminCreateOrganizationPayload: Schema.Struct<{
@@ -340,39 +340,39 @@ export declare const DashboardStatsQuery: Schema.Struct<{
340
340
  }>;
341
341
  export declare const DailyActiveUsersByDay: Schema.Struct<{
342
342
  readonly date: Schema.String;
343
- readonly count: Schema.Number;
343
+ readonly count: Schema.Finite;
344
344
  }>;
345
345
  export declare const SignupsByDay: Schema.Struct<{
346
346
  readonly date: Schema.String;
347
- readonly count: Schema.Number;
347
+ readonly count: Schema.Finite;
348
348
  }>;
349
349
  export declare const ProjectConnections: Schema.Struct<{
350
350
  readonly projectId: Schema.String;
351
351
  readonly projectName: Schema.String;
352
- readonly users: Schema.Number;
353
- readonly organizations: Schema.Number;
352
+ readonly users: Schema.Finite;
353
+ readonly organizations: Schema.Finite;
354
354
  }>;
355
355
  export declare const DashboardStatsResponse: Schema.Struct<{
356
- readonly totalUsers: Schema.Number;
357
- readonly totalOrganizations: Schema.Number;
358
- readonly totalProjects: Schema.Number;
359
- readonly totalDomains: Schema.Number;
360
- readonly totalApiKeys: Schema.Number;
361
- readonly totalOauthClients: Schema.Number;
362
- readonly dailyActiveUsers: Schema.Number;
356
+ readonly totalUsers: Schema.Finite;
357
+ readonly totalOrganizations: Schema.Finite;
358
+ readonly totalProjects: Schema.Finite;
359
+ readonly totalDomains: Schema.Finite;
360
+ readonly totalApiKeys: Schema.Finite;
361
+ readonly totalOauthClients: Schema.Finite;
362
+ readonly dailyActiveUsers: Schema.Finite;
363
363
  readonly dailyActiveUsersByDay: Schema.$Array<Schema.Struct<{
364
364
  readonly date: Schema.String;
365
- readonly count: Schema.Number;
365
+ readonly count: Schema.Finite;
366
366
  }>>;
367
367
  readonly signupsByDay: Schema.$Array<Schema.Struct<{
368
368
  readonly date: Schema.String;
369
- readonly count: Schema.Number;
369
+ readonly count: Schema.Finite;
370
370
  }>>;
371
371
  readonly projectConnections: Schema.$Array<Schema.Struct<{
372
372
  readonly projectId: Schema.String;
373
373
  readonly projectName: Schema.String;
374
- readonly users: Schema.Number;
375
- readonly organizations: Schema.Number;
374
+ readonly users: Schema.Finite;
375
+ readonly organizations: Schema.Finite;
376
376
  }>>;
377
377
  }>;
378
378
  export declare const PaginatedAdminUsers: Schema.Struct<{
@@ -415,7 +415,7 @@ export declare const PaginatedAdminOrganizations: Schema.Struct<{
415
415
  readonly metadata: Schema.optional<Schema.NullOr<Schema.String>>;
416
416
  readonly userId: Schema.optional<Schema.NullOr<Schema.String>>;
417
417
  readonly parentId: Schema.optional<Schema.NullOr<Schema.String>>;
418
- readonly memberCount: Schema.optional<Schema.Number>;
418
+ readonly memberCount: Schema.optional<Schema.Finite>;
419
419
  readonly memberPreviews: Schema.optional<Schema.$Array<Schema.Struct<{
420
420
  readonly id: Schema.String;
421
421
  readonly name: Schema.String;
@@ -121,7 +121,7 @@ export const AdminOrganization = Schema.Struct({
121
121
  metadata: Schema.optional(Schema.NullOr(Schema.String)),
122
122
  userId: Schema.optional(Schema.NullOr(Schema.String)),
123
123
  parentId: Schema.optional(Schema.NullOr(Schema.String)),
124
- memberCount: Schema.optional(Schema.Number),
124
+ memberCount: Schema.optional(Schema.Finite),
125
125
  memberPreviews: Schema.optional(Schema.Array(AdminOrganizationMember)),
126
126
  projects: Schema.optional(Schema.Array(AdminProjectPreview)),
127
127
  createdAt: Schema.Date,
@@ -172,10 +172,10 @@ export const AdminApiKey = Schema.Struct({
172
172
  prefix: Schema.NullOr(Schema.String),
173
173
  enabled: Schema.Boolean,
174
174
  rateLimitEnabled: Schema.Boolean,
175
- rateLimitTimeWindow: Schema.NullOr(Schema.Number),
176
- rateLimitMax: Schema.NullOr(Schema.Number),
177
- requestCount: Schema.Number,
178
- remaining: Schema.NullOr(Schema.Number),
175
+ rateLimitTimeWindow: Schema.NullOr(Schema.Finite),
176
+ rateLimitMax: Schema.NullOr(Schema.Finite),
177
+ requestCount: Schema.Finite,
178
+ remaining: Schema.NullOr(Schema.Finite),
179
179
  lastRequest: Schema.NullOr(Schema.Date),
180
180
  expiresAt: Schema.NullOr(Schema.Date),
181
181
  referrers: Schema.Array(Schema.String),
@@ -213,8 +213,8 @@ export const AdminUpdateApiKeyPayload = Schema.Struct({
213
213
  name: Schema.optional(Schema.NullOr(Schema.String)),
214
214
  enabled: Schema.optional(Schema.Boolean),
215
215
  rateLimitEnabled: Schema.optional(Schema.Boolean),
216
- rateLimitMax: Schema.optional(Schema.NullOr(Schema.Number)),
217
- rateLimitTimeWindow: Schema.optional(Schema.NullOr(Schema.Number)),
216
+ rateLimitMax: Schema.optional(Schema.NullOr(Schema.Finite)),
217
+ rateLimitTimeWindow: Schema.optional(Schema.NullOr(Schema.Finite)),
218
218
  referrers: Schema.optional(Schema.Array(Schema.String)),
219
219
  }).annotate({
220
220
  identifier: "AdminUpdateApiKeyPayload",
@@ -268,16 +268,16 @@ export const DashboardStatsQuery = Schema.Struct({
268
268
  });
269
269
  export const DailyActiveUsersByDay = Schema.Struct({
270
270
  date: Schema.String,
271
- count: Schema.Number,
271
+ count: Schema.Finite,
272
272
  }).annotate({
273
273
  identifier: "DailyActiveUsersByDay",
274
274
  title: "Daily active users by day",
275
- description: "Distinct authenticated users active on a calendar day.",
275
+ description: "Distinct users with recorded successful sign-ins or authenticated session checks on a UTC calendar day.",
276
276
  examples: [{ date: "2026-06-26", count: 18 }],
277
277
  });
278
278
  export const SignupsByDay = Schema.Struct({
279
279
  date: Schema.String,
280
- count: Schema.Number,
280
+ count: Schema.Finite,
281
281
  }).annotate({
282
282
  identifier: "SignupsByDay",
283
283
  title: "Signups by day",
@@ -287,8 +287,8 @@ export const SignupsByDay = Schema.Struct({
287
287
  export const ProjectConnections = Schema.Struct({
288
288
  projectId: Schema.String,
289
289
  projectName: Schema.String,
290
- users: Schema.Number,
291
- organizations: Schema.Number,
290
+ users: Schema.Finite,
291
+ organizations: Schema.Finite,
292
292
  }).annotate({
293
293
  identifier: "ProjectConnections",
294
294
  title: "Project connections",
@@ -303,13 +303,15 @@ export const ProjectConnections = Schema.Struct({
303
303
  ],
304
304
  });
305
305
  export const DashboardStatsResponse = Schema.Struct({
306
- totalUsers: Schema.Number,
307
- totalOrganizations: Schema.Number,
308
- totalProjects: Schema.Number,
309
- totalDomains: Schema.Number,
310
- totalApiKeys: Schema.Number,
311
- totalOauthClients: Schema.Number,
312
- dailyActiveUsers: Schema.Number,
306
+ totalUsers: Schema.Finite,
307
+ totalOrganizations: Schema.Finite,
308
+ totalProjects: Schema.Finite,
309
+ totalDomains: Schema.Finite,
310
+ totalApiKeys: Schema.Finite,
311
+ totalOauthClients: Schema.Finite,
312
+ dailyActiveUsers: Schema.Finite.annotate({
313
+ description: "Distinct users with recorded authentication activity today (UTC), not a rolling 24-hour window.",
314
+ }),
313
315
  dailyActiveUsersByDay: Schema.Array(DailyActiveUsersByDay),
314
316
  signupsByDay: Schema.Array(SignupsByDay),
315
317
  projectConnections: Schema.Array(ProjectConnections),