@shivaedev/platform 0.31.0 → 0.33.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 (95) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +27 -45
  3. package/dist/rpc/identity.d.ts +1 -1
  4. package/dist/rpc/identity.d.ts.map +1 -1
  5. package/dist/rpc/middleware.d.ts +1 -1
  6. package/dist/rpc/middleware.d.ts.map +1 -1
  7. package/dist/rpc/middleware.js +1 -1
  8. package/dist/rpc/middleware.js.map +1 -1
  9. package/dist/rpc/requireAdmin.d.ts +1 -1
  10. package/dist/rpc/requireAdmin.d.ts.map +1 -1
  11. package/dist/rpc/requireAdmin.js +1 -1
  12. package/dist/rpc/requireAdmin.js.map +1 -1
  13. package/dist/rpc/userRoles.d.ts +36 -0
  14. package/dist/rpc/userRoles.d.ts.map +1 -0
  15. package/dist/rpc/userRoles.js +18 -0
  16. package/dist/rpc/userRoles.js.map +1 -0
  17. package/dist/server/appHostHttp.d.ts +39 -39
  18. package/dist/server/appHostHttp.d.ts.map +1 -1
  19. package/dist/server/appHostHttp.js +12 -13
  20. package/dist/server/appHostHttp.js.map +1 -1
  21. package/dist/server/better-auth/revokeUnadmitted.d.ts +1 -1
  22. package/dist/server/better-auth/revokeUnadmitted.d.ts.map +1 -1
  23. package/dist/server/better-auth/signInGate.d.ts +1 -1
  24. package/dist/server/better-auth/signInGate.d.ts.map +1 -1
  25. package/dist/server/better-auth/signInGate.js +1 -1
  26. package/dist/server/better-auth/signInGate.js.map +1 -1
  27. package/dist/server/better-auth/testing.d.ts +2 -45
  28. package/dist/server/better-auth/testing.d.ts.map +1 -1
  29. package/dist/server/better-auth/testing.js +0 -12
  30. package/dist/server/better-auth/testing.js.map +1 -1
  31. package/dist/server/better-auth/userProfiles.d.ts +1 -1
  32. package/dist/server/better-auth/userProfiles.d.ts.map +1 -1
  33. package/dist/server/better-auth/userProfiles.js +1 -1
  34. package/dist/server/better-auth/userProfiles.js.map +1 -1
  35. package/dist/server/better-auth/users.d.ts +24 -0
  36. package/dist/server/better-auth/users.d.ts.map +1 -0
  37. package/dist/server/better-auth/users.js +67 -0
  38. package/dist/server/better-auth/users.js.map +1 -0
  39. package/dist/server/hostOptions.d.ts +3 -1
  40. package/dist/server/hostOptions.d.ts.map +1 -1
  41. package/dist/server/hostTransport.d.ts +16 -0
  42. package/dist/server/hostTransport.d.ts.map +1 -0
  43. package/dist/server/hostTransport.js +16 -0
  44. package/dist/server/hostTransport.js.map +1 -0
  45. package/dist/server/nativeClientOrigins.d.ts +4 -0
  46. package/dist/server/nativeClientOrigins.d.ts.map +1 -0
  47. package/dist/server/nativeClientOrigins.js +38 -0
  48. package/dist/server/nativeClientOrigins.js.map +1 -0
  49. package/dist/server/rpc-server/adapters/betterAuthSessions.d.ts +1 -1
  50. package/dist/server/rpc-server/adapters/betterAuthSessions.d.ts.map +1 -1
  51. package/dist/server/rpc-server/adapters/betterAuthSessions.js +1 -1
  52. package/dist/server/rpc-server/adapters/betterAuthSessions.js.map +1 -1
  53. package/dist/server/rpc-server/local.d.ts +2 -1
  54. package/dist/server/rpc-server/local.d.ts.map +1 -1
  55. package/dist/server/rpc-server/local.js +12 -5
  56. package/dist/server/rpc-server/local.js.map +1 -1
  57. package/dist/server/rpc-server/revalidateStream.d.ts +1 -1
  58. package/dist/server/rpc-server/revalidateStream.d.ts.map +1 -1
  59. package/dist/server/rpc-server/revalidateStream.js +1 -1
  60. package/dist/server/rpc-server/revalidateStream.js.map +1 -1
  61. package/dist/server/rpc-server/roles.js +1 -1
  62. package/dist/server/rpc-server/roles.js.map +1 -1
  63. package/dist/server/rpc-server/session.d.ts +1 -1
  64. package/dist/server/rpc-server/session.d.ts.map +1 -1
  65. package/dist/server/rpc-server/session.js +1 -1
  66. package/dist/server/rpc-server/session.js.map +1 -1
  67. package/package.json +7 -7
  68. package/src/rpc/identity.ts +1 -1
  69. package/src/rpc/middleware.ts +1 -1
  70. package/src/rpc/requireAdmin.ts +1 -1
  71. package/src/rpc/userRoles.ts +20 -0
  72. package/src/server/appHostHttp.ts +14 -15
  73. package/src/server/better-auth/revokeUnadmitted.ts +1 -1
  74. package/src/server/better-auth/signInGate.ts +1 -1
  75. package/src/server/better-auth/testing.ts +2 -14
  76. package/src/server/better-auth/userProfiles.ts +1 -1
  77. package/src/server/better-auth/users.ts +69 -0
  78. package/src/server/hostOptions.ts +3 -1
  79. package/src/server/hostTransport.ts +26 -0
  80. package/src/server/nativeClientOrigins.ts +44 -0
  81. package/src/server/rpc-server/adapters/betterAuthSessions.ts +1 -1
  82. package/src/server/rpc-server/local.ts +16 -5
  83. package/src/server/rpc-server/revalidateStream.ts +1 -1
  84. package/src/server/rpc-server/roles.ts +1 -1
  85. package/src/server/rpc-server/session.ts +1 -1
  86. package/dist/errors/rejectedField.d.ts +0 -7
  87. package/dist/errors/rejectedField.d.ts.map +0 -1
  88. package/dist/errors/rejectedField.js +0 -7
  89. package/dist/errors/rejectedField.js.map +0 -1
  90. package/dist/errors/taxonomy.d.ts +0 -55
  91. package/dist/errors/taxonomy.d.ts.map +0 -1
  92. package/dist/errors/taxonomy.js +0 -24
  93. package/dist/errors/taxonomy.js.map +0 -1
  94. package/src/errors/rejectedField.ts +0 -10
  95. package/src/errors/taxonomy.ts +0 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.33.0 - 2026-10-26
4
+
5
+ ### Added
6
+
7
+ - Add the admin Users page, native RPC handlers and React view for paginated app users and owner-managed roles. Register `UsersPage` with `usersHandlers` beside Jobs and mount `UsersView` using its bound query and role action.
8
+ - Add Platform auth user listing and transactional role changes on the existing Better Auth PostgreSQL schema, with typed owner-only and last-owner failures, change invalidation and actor/timestamp logs.
9
+ - Mount Users in the starter and generated apps. Existing apps receive the wiring with `pnpm dlx @shivaedev/create-app@latest update` after these packages are released; review template conflicts and install dependencies. Newly bootstrapped administrators also hold the owner role.
10
+ - Provide the shared expected failure schemas and `rejectedField` in `@shivaedev/effect-contract/errors/`, so browser-safe contract consumers can use them without depending on Platform. Tags, schema fields and RPC encoding remain the same.
11
+ - Run Fleet and Work Board together with `work-fleet up <board-dir>`, with exclusive board ownership, process and code-change restarts, combined logs, `up --status` and clean shutdown through `down`.
12
+ - Work Board coordinates command-line process ownership with Fleet supervision and refuses a hand-started server while `up` holds its directory.
13
+ - The HTTP host accepts Effect’s native `gracefulShutdownTimeout` so supervised processes can finish active requests before restarting.
14
+
15
+ ### Changed
16
+
17
+ - Require Better Auth 1.7.11, whose plugin types support `testUtils()` with `exactOptionalPropertyTypes` without a wrapper.
18
+
19
+ ### Breaking
20
+
21
+ - Remove `authTestUtils` from `@shivaedev/platform/server/better-auth/testing.ts`. Import `testUtils` from `better-auth/plugins` and call it with the same options instead. Keep importing `signedInUser` and `storedProviderAccounts` from Platform.
22
+ - Move all imports from `@shivaedev/platform/errors/taxonomy.ts` to `@shivaedev/effect-contract/errors/taxonomy.ts`, and from `@shivaedev/platform/errors/rejectedField.ts` to `@shivaedev/effect-contract/errors/rejectedField.ts`. The old modules are removed. Add a direct `@shivaedev/effect-contract` dependency if the consuming package does not already declare one. Admin, GitHub, Work Board and Work Fleet public failure types now refer to these shared classes.
23
+ - Generated apps use the new imports. The create-app updater applies the starter changes through its usual three-way patch; it does not rewrite imports in app-owned files. Replace both old import paths above in those files when upgrading existing apps.
24
+
25
+ ## 0.32.0 - 2026-10-25
26
+
27
+ ### Added
28
+
29
+ - Allow explicitly listed native origins through appHost RPC and auth routes with exact CORS responses and bearer-only cross-origin sessions. Native WebView fetch keeps incremental NDJSON delivery and cancellation while existing transport protections remain in place.
30
+
3
31
  ## 0.31.0 - 2026-10-25
4
32
 
5
33
  ### Added
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @shivaedev/platform
2
2
 
3
- Shared errors, request identity and server boundaries for Effect applications. A feature can say who called it and why it refused, while the application supplies its session policy once. The package also connects Effect services to Promise callers, Node subscriptions and optional Better Auth, Prisma and tRPC integrations.
3
+ Request identity and server boundaries for Effect applications. A feature can say who called it and why it refused, while the application supplies its session policy once. The package also connects Effect services to Promise callers, Node subscriptions and optional Better Auth, Prisma and tRPC integrations.
4
4
 
5
5
  ## Why you want this
6
6
 
@@ -19,7 +19,7 @@ const Handlers = Account.toLayer({
19
19
  });
20
20
  ```
21
21
 
22
- `Account` is a native RPC group with authenticated middleware. Its handler reads the identity for this invocation and decides whether that user may read the account. Platform supplies the common error classes and request services; feature code keeps the resource-ownership check. Concurrent requests receive their own identities, and a provider outage reaches the caller as `AuthUnavailable` instead of pretending the caller signed out.
22
+ `Account` is a native RPC group with authenticated middleware. Its handler reads the identity for this invocation and decides whether that user may read the account. Effect Contract supplies the common error classes, and Platform supplies request services; feature code keeps the resource-ownership check. Concurrent requests receive their own identities, and a provider outage reaches the caller as `AuthUnavailable` instead of pretending the caller signed out.
23
23
 
24
24
  ## Using it
25
25
 
@@ -27,7 +27,7 @@ const Handlers = Account.toLayer({
27
27
 
28
28
  There are three parts to a native RPC boundary:
29
29
 
30
- 1. **The shared contract** names Schema errors and middleware tags. The browser imports these declarations too, so `errors/` and `rpc/` contain browser-safe data and services.
30
+ 1. **The shared contract** names Schema errors and middleware tags. The browser imports these declarations too, so `effect-contract/errors/` and Platform's `rpc/` contain browser-safe data and services.
31
31
  2. **The server composition** implements the tags with Layers from `rpc-server/`. A session provider resolves a session; an Origin policy decides whether its request may reach that provider; tracing supplies a request id and diagnostic context.
32
32
  3. **The feature handler** reads `Identity`, `OptionalIdentity` or `RequestId` and runs application code. Authentication supplies a user id. Authorization still decides whether that user may perform this operation.
33
33
 
@@ -63,7 +63,7 @@ const Server = appHost({
63
63
  NodeRuntime.runMain(Layer.launch(Server));
64
64
  ```
65
65
 
66
- `app.ts` exports the application's contracts, native Layers, numbered `Migrator.Loader` and `SessionPolicy`. The host needs the optional peers `@effect/platform-node` and `@effect/sql-pg` at the workspace's Effect version; install both for this entry point. The `errors/`, `node-http/`, `rpc/`, `rpc-server/` and `runtime/` entries still work without them.
66
+ `app.ts` exports the application's contracts, native Layers, numbered `Migrator.Loader` and `SessionPolicy`. The host needs the optional peers `@effect/platform-node` and `@effect/sql-pg` at the workspace's Effect version; install both for this entry point. The `node-http/`, `rpc/`, `rpc-server/` and `runtime/` entries still work without them.
67
67
 
68
68
  Omit `services` when the app has no service Layer of its own. The host uses `Layer.empty`; handler requirements remain explicit, and a migrated host still provides its database services to handlers. Annotated options that declare service outputs, errors or requirements must supply a `services` Layer.
69
69
 
@@ -269,7 +269,7 @@ Declare the RPC group in a shared module:
269
269
  ```ts
270
270
  import { Effect, Schema } from "effect";
271
271
  import { Rpc, RpcGroup } from "effect/rpc";
272
- import { Forbidden } from "@shivaedev/platform/errors/taxonomy.ts";
272
+ import { Forbidden } from "@shivaedev/effect-contract/errors/taxonomy.ts";
273
273
  import { Identity } from "@shivaedev/platform/rpc/identity.ts";
274
274
  import { Authenticated } from "@shivaedev/platform/rpc/middleware.ts";
275
275
 
@@ -357,7 +357,7 @@ Pass Better Auth's account lookup as the second argument to `betterAuthSessions`
357
357
  ```ts
358
358
  import { SessionUserWithProviderAccounts } from "@shivaedev/platform/rpc/identity.ts";
359
359
  import { AuthenticatedUserWithProviderAccounts } from "@shivaedev/platform/rpc/middleware.ts";
360
- import { AuthUnavailable, Unauthorized } from "@shivaedev/platform/errors/taxonomy.ts";
360
+ import { AuthUnavailable, Unauthorized } from "@shivaedev/effect-contract/errors/taxonomy.ts";
361
361
  import { authenticatedUserWithProviderAccountsLayer } from "@shivaedev/platform/server/rpc-server/session.ts";
362
362
 
363
363
  const sessions = {
@@ -509,34 +509,7 @@ The same module exports `loopbackOnly(handler)` for local page routes and `sameO
509
509
 
510
510
  `trustedProxyRanges(trustedProxy?)` returns the equivalent IP addresses and CIDR ranges used by that matcher. Mapped IPv6 addresses and CIDRs become IPv4 entries: `::ffff:127.0.0.0/104` becomes `127.0.0.0/8`, including hexadecimal mapped forms. Broader IPv6 ranges retain both native IPv6 and mapped IPv4 coverage. Missing or malformed configuration returns an empty list. Pass these ranges to a forwarded-header integration after checking the transport with `trustedProxyPeer`.
511
511
 
512
- Declare expected refusals in the RPC's error schema:
513
-
514
- ```ts
515
- import { Schema } from "effect";
516
- import { Rpc } from "effect/rpc";
517
- import { BadRequest, Conflict } from "@shivaedev/platform/errors/taxonomy.ts";
518
-
519
- export const Rename = Rpc.make("Rename", {
520
- error: Schema.Union([BadRequest, Conflict]),
521
- payload: { name: Schema.String },
522
- success: Schema.String,
523
- });
524
- ```
525
-
526
- A handler fails with `new Conflict({ field: "name", message: "Name is taken" })`. Native RPC JSON decodes the rejection back to the error instance with its field. Taxonomy errors can be declared on an RPC with no authentication middleware. `rejectedField` reads either that instance or tagged JSON:
527
-
528
- ```ts
529
- import { rejectedField } from "@shivaedev/platform/errors/rejectedField.ts";
530
- import { Conflict } from "@shivaedev/platform/errors/taxonomy.ts";
531
-
532
- const field = rejectedField(
533
- new Conflict({ field: "name", message: "Name is taken" }),
534
- );
535
- ```
536
-
537
- `field` is `Option.some({ field: "name", message: "Name is taken" })`. Any value with string `_tag`, `field` and `message` qualifies, including an application's own tagged error. An untagged object, a missing field or a non-string field yields `Option.none()`.
538
-
539
- For tRPC, use these classes with the rejection schema and formatter from [effect-trpc](https://github.com/ShivaeDev/platform/tree/main/packages/effect-trpc). The composed HTTP boundary carries rejection data and maps statuses, including `TooManyRequests` as 429 and `AuthUnavailable` as 503.
512
+ Declare expected refusals with the shared tagged error schemas from [effect-contract](https://github.com/ShivaeDev/platform/tree/main/packages/effect-contract#expected-failures). They work with native RPC without authentication middleware. For tRPC, use the rejection schema and formatter from [effect-trpc](https://github.com/ShivaeDev/platform/tree/main/packages/effect-trpc); that HTTP boundary owns status mapping.
540
513
 
541
514
  ### Handling unexpected failures
542
515
 
@@ -544,7 +517,7 @@ At the handler edge, `rpcBoundary(schema, options)` keeps declared rejections an
544
517
 
545
518
  ```ts
546
519
  import { Schema } from "effect";
547
- import { Conflict, InternalServerError } from "@shivaedev/platform/errors/taxonomy.ts";
520
+ import { Conflict, InternalServerError } from "@shivaedev/effect-contract/errors/taxonomy.ts";
548
521
  import { rpcBoundary } from "@shivaedev/platform/server/rpc-server/boundary.ts";
549
522
 
550
523
  const Rejection = Schema.Union([Conflict, InternalServerError]);
@@ -724,16 +697,20 @@ const sessions = {
724
697
  origin: trustedOrigins({ allow: [publicOrigin, ...nativeOrigins], missing: "allow" }),
725
698
  provider: betterAuthSessions(mounted.admittedSessions((headers) => mounted.auth.api.getSession({ headers }))),
726
699
  };
727
- const host = appHost({ group, handlers, routes: mounted.routes, sessions });
700
+ const host = appHost({ group, handlers, routes: mounted.routes, sessions, nativeOrigins });
728
701
  ```
729
702
 
730
- Always wrap the session lookup in `admittedSessions`, even without a sign-in policy: it applies the mount's credential selection to the same request-local identity, profile and role middleware used by cookies. A request carrying the session cookie uses only that cookie, even if invalid or revoked; its bearer header cannot switch accounts or rescue it. Otherwise the signed bearer is resolved by Better Auth. Missing, unsigned, tampered, expired and revoked bearer sessions produce `Unauthorized` at protected RPCs.
703
+ Always wrap the session lookup in `admittedSessions`, even without a sign-in policy: it applies the mount's credential selection to the same request-local identity, profile and role middleware used by cookies. A same-origin request or a request without an Origin carrying the session cookie uses only that cookie, even if invalid or revoked; its bearer header cannot switch accounts or rescue it. Otherwise the signed bearer is resolved by Better Auth. Missing, unsigned, tampered, expired and revoked bearer sessions produce `Unauthorized` at protected RPCs.
731
704
 
732
705
  A native client signs in through `/api/auth/sign-in/email` with `credentials: "omit"` and its bundled Origin, reads the signed credential from the `set-auth-token` response header, and sends that exact value as `Authorization: Bearer <credential>` with `credentials: "omit"` on later auth and RPC requests. Persist it only in OS-backed secure storage, such as iOS Keychain or Android Keystore-backed storage; never use localStorage, sessionStorage or IndexedDB. Browser responses keep HttpOnly cookies and omit the plugin's token header and JSON token fields. Clients without a bundled Origin receive cookie responses.
733
706
 
734
707
  Native sign-out revokes the stored session. Signing in again while sending the current bearer replaces it and revokes the old session after successful sign-in. Streams keep their original request headers, so the old session ends with `Unauthorized` on the next revalidation; it never adopts the replacement. Keep cookie caching disabled for database-backed revocation and choose `streamRevalidationInterval` for the required delivery window.
735
708
 
736
- This option does not change `appHost`'s RPC transport guard: bundled cross-origin RPC requests still require transport support. Native HTTP callers without an Origin can exercise bearer RPC with an origin policy that explicitly permits missing Origins. Better Auth's trusted origins and CORS configuration remain application policy.
709
+ `appHost`'s `nativeOrigins` option admits those exact origins through the RPC transport guard and the auth routes. Wildcards, patterns and URLs with paths are rejected at startup. Keep the list aligned with `bearerSessions.origins`, Better Auth's `trustedOrigins` and the RPC session origin policy: the later origin policies alone cannot open the transport guard. Omit the option to keep the existing same-origin transport policy.
710
+
711
+ The host answers native preflights with POST for RPC, GET and POST for auth, and only `Authorization` and `Content-Type` headers. Native responses echo the allowed origin exactly with `Vary: Origin`; auth responses expose `set-auth-token`. The host never enables CORS credentials. It strips cookies from admitted native requests before auth or RPC session resolution, so only the signed bearer session can authenticate them. This prevents native access from opening a cookie CSRF path, even if a caller sends a cookie. Resource authorization remains app-owned.
712
+
713
+ Use the WebView's own fetch with `credentials: "omit"` for incremental NDJSON change streams and abort its request to release server work. A buffering native HTTP bridge cannot deliver that streaming behavior. The host still validates trusted proxy peers and forwarded authority, enforces NDJSON and body limits, uses only transport credentials, redacts diagnostics and authorizes sessions. Native HTTP callers without an Origin can exercise bearer RPC with an origin policy that explicitly permits missing Origins.
737
714
 
738
715
  ### Decide who may sign in
739
716
 
@@ -775,17 +752,18 @@ Without `signIn`, the mount installs no sign-in policy hooks and `revokeUnadmitt
775
752
 
776
753
  ### Signed-in story preconditions
777
754
 
778
- Use `authTestUtils()` from `@shivaedev/platform/server/better-auth/testing.ts` in a test-only Better Auth instance with the host's database, secret and cookie policy. The wrapper preserves the plugin's typed `$context.test` under `exactOptionalPropertyTypes`. Keep the plugin out of production auth options.
755
+ Use `testUtils()` from `better-auth/plugins` in a test-only Better Auth instance with the host's database, secret and cookie policy. Keep the plugin out of production auth options.
779
756
 
780
757
  Use `authTestDatabase(pool)` from `@shivaedev/platform/server/better-auth/testDatabase.ts` when a story needs observations or faults in the default Better Auth PostgreSQL schema. It returns Effect readouts `users` (IDs and emails) and `sessions` (IDs, user IDs and emails), plus the test-only faults `expireSessions` and `omitImageColumn`. It never returns tokens, password hashes or provider credentials. These fixtures assume the default table and column mappings and operate on the supplied pool; use only an isolated test database. Application stories keep their auth SQL in this provider-owned boundary.
781
758
 
782
759
  ```ts
783
760
  import { betterAuth } from "better-auth";
784
- import { authTestUtils, signedInUser } from "@shivaedev/platform/server/better-auth/testing.ts";
761
+ import { testUtils } from "better-auth/plugins";
762
+ import { signedInUser } from "@shivaedev/platform/server/better-auth/testing.ts";
785
763
 
786
764
  const testAuth = betterAuth({
787
765
  ...options,
788
- plugins: [...(options.plugins ?? []), authTestUtils()],
766
+ plugins: [...(options.plugins ?? []), testUtils()],
789
767
  });
790
768
  const { user, headers, cookies } = await signedInUser(testAuth, {
791
769
  email: "member@example.test",
@@ -901,8 +879,6 @@ Import the module that defines the name; there is no package-root entry. Paths b
901
879
 
902
880
  | Module | Names and purpose |
903
881
  | --- | --- |
904
- | `errors/taxonomy.ts` | `NotFound`, `Unauthorized`, `Forbidden`, `BadRequest`, `Conflict`, `PreconditionFailed`, `TooManyRequests`, `AuthUnavailable`, `InternalServerError`, `ServiceUnavailable`: Schema tagged error classes with a `message`; `BadRequest` and `Conflict` also accept an optional `field`. |
905
- | `errors/rejectedField.ts` | `rejectedField(unknown)`: the field and message of a field rejection. |
906
882
  | `rpc/identity.ts` | `RequestId`, `Identity`, `OptionalIdentity`, `SessionUser`, `SessionUserWithProviderAccounts`: request-local services. |
907
883
  | `rpc/middleware.ts` | `RequestTracing`, `Authenticated`, `AuthenticatedUser`, `AuthenticatedUserWithProviderAccounts`, `AuthenticatedAdmin`, `AuthenticatedOwner`, `MaybeAuthenticated`: native RPC middleware declarations. |
908
884
  | `rpc/hasRole.ts` | `hasRole(user, role)`: whether a user's comma-separated role list includes a role; browser-safe. |
@@ -928,17 +904,23 @@ Import the module that defines the name; there is no package-root entry. Paths b
928
904
  | `server/better-auth/signInGate.ts` | `SignInPolicy`: the `accounts`, `rule` and `recheckInterval` of a sign-in policy. |
929
905
  | `server/better-auth/revokeUnadmitted.ts` | `RevokedSessions`: the `{ users, sessions }` counts of a revocation. |
930
906
  | `server/better-auth/testDatabase.ts` | `authTestDatabase(pool)`: test-only identity/session readouts and faults for the default PostgreSQL auth schema. |
931
- | `server/better-auth/testing.ts` | `authTestUtils(options?)`, `signedInUser(auth, fields)`: test-only typed Better Auth helpers and minted user sessions. |
907
+ | `server/better-auth/testing.ts` | `signedInUser(auth, fields)`, `storedProviderAccounts(auth, userId)`: test-only minted user sessions and credential storage observations. |
932
908
  | `server/better-auth/adapter.ts` | `effectPrismaAdapter(Database, runtime, options?)`: a Better Auth adapter over Effect Prisma; `modelName` maps model names. |
933
909
  | `server/testing/makePlatformIt.ts` | `makePlatformIt(Database)({ adapter, createCaller, layer, extend? })`. |
934
910
 
911
+ ### Manage app users
912
+
913
+ `server/better-auth/users.ts` provides `listUsers({ limit, cursor? })` and `changeUserRole({ userId, role, grant })` using the existing Effect SQL client and Better Auth's default PostgreSQL user table with its admin plugin. Browser-safe schemas, Platform roles (`user`, `admin`, `owner`) and the typed `LastOwner` failure live in `rpc/userRoles.ts`. The admin package supplies the protected contract and React view.
914
+
915
+ Role writes require an owner `SessionUser`, serialize role changes in a transaction, and reject removal of the final owner. They preserve unrelated roles and publish the `admin.users` invalidation after commit. Successful changes emit structured Effect logs with actor, target, role, action and UTC timestamp. Platform has no durable audit-history store. The host must use the same database as authentication; custom Better Auth table names and columns need their own integration.
916
+
935
917
  ### Install, setup and limits
936
918
 
937
919
  ```sh
938
920
  pnpm add @shivaedev/platform effect@4.0.5
939
921
  ```
940
922
 
941
- Effect is the only required peer. The peer-free implementation lives in the shared `errors/` and `rpc/` folders and the `server/node-http/`, `server/rpc-server/` and `server/runtime/` folders; a module's import path is its path under `src/`. The core errors, RPC declarations, server middleware, runtime and Node HTTP modules can be imported without the optional peers, including the Promise-based `betterAuthSessions` function. The runtime uses Node's `AsyncLocalStorage`; browser consumers import the shared `errors/` and `rpc/` modules.
923
+ Effect is the only required peer. The peer-free implementation lives in the shared `rpc/` folder and the `server/node-http/`, `server/rpc-server/` and `server/runtime/` folders; a module's import path is its path under `src/`. The core RPC declarations, server middleware, runtime and Node HTTP modules can be imported without the optional peers, including the Promise-based `betterAuthSessions` function. The runtime uses Node's `AsyncLocalStorage`; browser consumers import the shared `rpc/` modules and the error schemas from `@shivaedev/effect-contract/errors/taxonomy.ts`.
942
924
 
943
925
  Install the optional peers for the selected integration:
944
926
 
@@ -1,5 +1,5 @@
1
1
  import { Context, type Effect, type Option } from "effect";
2
- import type { AuthUnavailable, Unauthorized } from "#errors/taxonomy.ts";
2
+ import type { AuthUnavailable, Unauthorized } from "@shivaedev/effect-contract/errors/taxonomy.ts";
3
3
  declare const RequestId_base: Context.ServiceClass<RequestId, "@shivaedev/platform/rpc/RequestId", string>;
4
4
  export declare class RequestId extends RequestId_base {
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/rpc/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;;AACzE,qBAAa,SAAU,SAAQ,cAAyE;CAAG;AAC3G,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACpB;;AACD,qBAAa,QAAS,SAAQ,aAA8E;CAAG;;AAC/G,qBAAa,gBAAiB,SAAQ,qBAA6G;CAAG;AACtJ,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,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C1C;;AACD,qBAAa,WAAY,SAAQ,gBAAuF;CAAG;AAC3H,MAAM,WAAW,oCAAqC,SAAQ,gBAAgB;IAC7E,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,oBAAoB,EAAE,EAAE,eAAe,GAAG,YAAY,CAAC,CAAC;CAC1G;;AACD,qBAAa,+BAAgC,SAAQ,oCAEpD;CAAG"}
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { RpcMiddleware } from "effect/rpc";
3
- import { AuthUnavailable, Forbidden, Unauthorized } from "#errors/taxonomy.ts";
3
+ import { AuthUnavailable, Forbidden, Unauthorized } from "@shivaedev/effect-contract/errors/taxonomy.ts";
4
4
  import type { Identity, OptionalIdentity, RequestId, SessionUser, SessionUserWithProviderAccounts } from "./identity.ts";
5
5
  declare const RequestTracing_base: RpcMiddleware.ServiceClass<RequestTracing, "@shivaedev/platform/rpc/RequestTracing", RequestId, Schema.Never, never, never, false>;
6
6
  export declare class RequestTracing extends RequestTracing_base {
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/rpc/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;;AACzH,qBAAa,cAAe,SAAQ,mBAKS;CAAG;;AAChD,qBAAa,aAAc,SAAQ,kBAOjC;CAAG;;AACL,qBAAa,kBAAmB,SAAQ,uBAK8E;CAAG;;AACzH,qBAAa,iBAAkB,SAAQ,sBAOrC;CAAG;;AACL,qBAAa,qCAAsC,SAAQ,0CAKzD;CAAG;;AACL,qBAAa,kBAAmB,SAAQ,uBAOtC;CAAG;;AACL,qBAAa,kBAAmB,SAAQ,uBAOtC;CAAG"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/rpc/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AACzG,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;;AACzH,qBAAa,cAAe,SAAQ,mBAKS;CAAG;;AAChD,qBAAa,aAAc,SAAQ,kBAOjC;CAAG;;AACL,qBAAa,kBAAmB,SAAQ,uBAK8E;CAAG;;AACzH,qBAAa,iBAAkB,SAAQ,sBAOrC;CAAG;;AACL,qBAAa,qCAAsC,SAAQ,0CAKzD;CAAG;;AACL,qBAAa,kBAAmB,SAAQ,uBAOtC;CAAG;;AACL,qBAAa,kBAAmB,SAAQ,uBAOtC;CAAG"}
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { RpcMiddleware } from "effect/rpc";
3
- import { AuthUnavailable, Forbidden, Unauthorized } from "#errors/taxonomy.ts";
3
+ import { AuthUnavailable, Forbidden, Unauthorized } from "@shivaedev/effect-contract/errors/taxonomy.ts";
4
4
  export class RequestTracing extends RpcMiddleware.Service()("@shivaedev/platform/rpc/RequestTracing") {
5
5
  }
6
6
  export class Authenticated extends RpcMiddleware.Service()("@shivaedev/platform/rpc/Authenticated", {
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/rpc/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAA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AE;IACjD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;CAC/D,CAAC;CAAG;AACL,MAAM,OAAO,kBAAmB,SAAQ,aAAa,CAAC,OAAO,EAK1D,CAAC,4CAA4C,EAAE;IACjD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;CAC/D,CAAC;CAAG"}
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import { Forbidden } from "#errors/taxonomy.ts";
2
+ import { Forbidden } from "@shivaedev/effect-contract/errors/taxonomy.ts";
3
3
  import { SessionUser, type SessionUserValue } from "./identity.ts";
4
4
  export declare const requireAdmin: Effect.Effect<SessionUserValue, Forbidden, SessionUser>;
5
5
  //# sourceMappingURL=requireAdmin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"requireAdmin.d.ts","sourceRoot":"","sources":["../../src/rpc/requireAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEnE,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,SAAS,EAAE,WAAW,CAM/E,CAAC"}
1
+ {"version":3,"file":"requireAdmin.d.ts","sourceRoot":"","sources":["../../src/rpc/requireAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEnE,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,SAAS,EAAE,WAAW,CAM/E,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import { Forbidden } from "#errors/taxonomy.ts";
2
+ import { Forbidden } from "@shivaedev/effect-contract/errors/taxonomy.ts";
3
3
  import { hasRole } from "./hasRole.js";
4
4
  import { SessionUser } from "./identity.js";
5
5
  export const requireAdmin = Effect.gen(function* () {
@@ -1 +1 @@
1
- {"version":3,"file":"requireAdmin.js","sourceRoot":"","sources":["../../src/rpc/requireAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAyB,MAAM,eAAe,CAAC;AAEnE,MAAM,CAAC,MAAM,YAAY,GAA4D,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACxG,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;IAChC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"requireAdmin.js","sourceRoot":"","sources":["../../src/rpc/requireAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAyB,MAAM,eAAe,CAAC;AAEnE,MAAM,CAAC,MAAM,YAAY,GAA4D,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACxG,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;IAChC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { Schema } from "effect";
2
+ export declare const UserRole: Schema.Literals<readonly ["user", "admin", "owner"]>;
3
+ export type UserRole = typeof UserRole.Type;
4
+ export declare const AppUser: Schema.Struct<{
5
+ readonly createdAt: Schema.DateTimeUtcFromString;
6
+ readonly email: Schema.String;
7
+ readonly id: Schema.String;
8
+ readonly name: Schema.String;
9
+ readonly roles: Schema.$Array<Schema.String>;
10
+ }>;
11
+ export declare const UserListInput: Schema.Struct<{
12
+ readonly cursor: Schema.optionalKey<Schema.String>;
13
+ readonly limit: Schema.Number;
14
+ }>;
15
+ export declare const UserList: Schema.Struct<{
16
+ readonly next: Schema.OptionFromNullOr<Schema.String>;
17
+ readonly users: Schema.$Array<Schema.Struct<{
18
+ readonly createdAt: Schema.DateTimeUtcFromString;
19
+ readonly email: Schema.String;
20
+ readonly id: Schema.String;
21
+ readonly name: Schema.String;
22
+ readonly roles: Schema.$Array<Schema.String>;
23
+ }>>;
24
+ }>;
25
+ export declare const ChangeRoleInput: Schema.Struct<{
26
+ readonly grant: Schema.Boolean;
27
+ readonly role: Schema.Literals<readonly ["user", "admin", "owner"]>;
28
+ readonly userId: Schema.String;
29
+ }>;
30
+ declare const LastOwner_base: Schema.Class<LastOwner, Schema.TaggedStruct<"LastOwner", {
31
+ readonly userId: Schema.String;
32
+ }>, import("effect/Cause").YieldableError>;
33
+ export declare class LastOwner extends LastOwner_base {
34
+ }
35
+ export {};
36
+ //# sourceMappingURL=userRoles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userRoles.d.ts","sourceRoot":"","sources":["../../src/rpc/userRoles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,QAAQ,sDAA8C,CAAC;AACpE,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C,eAAO,MAAM,OAAO;;;;;;EAMlB,CAAC;AAEH,eAAO,MAAM,aAAa;;;EAGxB,CAAC;AACH,eAAO,MAAM,QAAQ;;;;;;;;;EAAgG,CAAC;AACtH,eAAO,MAAM,eAAe;;;;EAAkF,CAAC;;;;AAC/G,qBAAa,SAAU,SAAQ,cAAuE;CAAG"}
@@ -0,0 +1,18 @@
1
+ import { Schema } from "effect";
2
+ export const UserRole = Schema.Literals(["user", "admin", "owner"]);
3
+ export const AppUser = Schema.Struct({
4
+ createdAt: Schema.DateTimeUtcFromString,
5
+ email: Schema.String,
6
+ id: Schema.String,
7
+ name: Schema.String,
8
+ roles: Schema.Array(Schema.String),
9
+ });
10
+ export const UserListInput = Schema.Struct({
11
+ cursor: Schema.optionalKey(Schema.String),
12
+ limit: Schema.Number.check(Schema.isInt(), Schema.isBetween({ maximum: 100, minimum: 1 })),
13
+ });
14
+ export const UserList = Schema.Struct({ next: Schema.OptionFromNullOr(Schema.String), users: Schema.Array(AppUser) });
15
+ export const ChangeRoleInput = Schema.Struct({ grant: Schema.Boolean, role: UserRole, userId: Schema.String });
16
+ export class LastOwner extends Schema.TaggedError()("LastOwner", { userId: Schema.String }) {
17
+ }
18
+ //# sourceMappingURL=userRoles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userRoles.js","sourceRoot":"","sources":["../../src/rpc/userRoles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,EAA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