@shivaedev/platform 0.8.0 → 0.10.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/CHANGELOG.md +13 -0
- package/README.md +34 -4
- package/dist/rpc/identity.d.ts +7 -0
- package/dist/rpc/identity.d.ts.map +1 -1
- package/dist/rpc/identity.js +2 -0
- package/dist/rpc/identity.js.map +1 -1
- package/dist/rpc/middleware.d.ts +4 -1
- package/dist/rpc/middleware.d.ts.map +1 -1
- package/dist/rpc/middleware.js +4 -0
- package/dist/rpc/middleware.js.map +1 -1
- package/dist/server/appHost.d.ts +7 -7
- package/dist/server/appHost.d.ts.map +1 -1
- package/dist/server/appHost.js.map +1 -1
- package/dist/server/appHostHttp.d.ts.map +1 -1
- package/dist/server/appHostHttp.js +3 -2
- package/dist/server/appHostHttp.js.map +1 -1
- package/dist/server/hostOptions.d.ts +4 -2
- package/dist/server/hostOptions.d.ts.map +1 -1
- package/dist/server/rpc-server/session.d.ts +6 -1
- package/dist/server/rpc-server/session.d.ts.map +1 -1
- package/dist/server/rpc-server/session.js +13 -2
- package/dist/server/rpc-server/session.js.map +1 -1
- package/package.json +3 -3
- package/src/rpc/identity.ts +5 -0
- package/src/rpc/middleware.ts +9 -1
- package/src/server/appHost.ts +39 -31
- package/src/server/appHostHttp.ts +3 -2
- package/src/server/hostOptions.ts +5 -3
- package/src/server/rpc-server/session.ts +22 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0 - 2026-10-16
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `appHost` and its options types accept an omitted `services` Layer for apps without services of their own. Annotated options require a Layer when they declare service outputs, errors or requirements. Existing service Layers keep their behavior, and migrated hosts still provide database services to handlers.
|
|
8
|
+
- Signed-in handlers can read the current user's id, name and email: declare `AuthenticatedUser`, read `SessionUser`, and merge `authenticatedUserLayer(sessions)` beside the handlers. `Identity` keeps its `{ id }` shape.
|
|
9
|
+
|
|
10
|
+
## 0.9.0 - 2026-10-16
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `SessionUser` and `SessionUserValue` expose the signed-in user’s id, name and email beside the unchanged `Identity`. `AuthenticatedUser` and `authenticatedUserLayer` provide both services from a `UserSessionShape` provider, with typed authentication failures and request-local profiles.
|
|
15
|
+
|
|
3
16
|
## 0.8.0 - 2026-10-14
|
|
4
17
|
|
|
5
18
|
### Breaking
|
package/README.md
CHANGED
|
@@ -59,13 +59,15 @@ NodeRuntime.runMain(Layer.launch(Server));
|
|
|
59
59
|
|
|
60
60
|
`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.
|
|
61
61
|
|
|
62
|
+
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.
|
|
63
|
+
|
|
62
64
|
`assets` accepts a directory string or native `HttpStaticServer.layer` options. For a browser app whose routes must also work on direct navigation or reload, use `{ root: "dist", spa: true }` or merge `HttpStaticServer.layer({ root: "dist", spa: true })` from `effect/http` alongside the handler Layer. Native route Layers can register additional endpoints in that same composition; `routes` also accepts a native `Layer<never, never, HttpRouter>` for endpoints on the same listener. The [starter](https://github.com/ShivaeDev/platform/tree/main/examples/starter) uses it for static assets and Better Auth at `/api/auth/*`, with provider-owned cookies and the host's RPC session middleware.
|
|
63
65
|
|
|
64
66
|
The listener uses `HOST` or `127.0.0.1`, uses `PORT` or 3000, and reads `DATABASE_URL`. Set overrides in the one `config` object: `host`, `port` (0 selects an ephemeral port), `trustedProxy`, `maxBodySize`, `databaseUrl` (an Effect `Redacted<string>`), `applicationName`, and optional `changes`. Migration options accept `table` and `lockTimeout` (default `effect_sql_migrations` and five seconds). Native Layer failures remain in the build error channel; missing application dependencies remain in the requirement type.
|
|
65
67
|
|
|
66
68
|
RPC request bodies are limited to 1 MiB by default. Set `MAX_BODY_SIZE` to a byte count or override it with `config.maxBodySize`, a nonnegative safe integer. An oversized NDJSON body returns a 4xx before any RPC handler runs; real HTTP tests cover fixed-length and chunked requests, byte counting, and configuration precedence. This limit applies to the host's RPC route.
|
|
67
69
|
|
|
68
|
-
RPC uses the existing `localRpcGuard`: it requires a loopback peer and Host, same-origin or absent Origin, and the NDJSON content type. Session lookup uses transport headers. With a session policy, contracts declare `Authenticated`, `MaybeAuthenticated` and `RequestTracing` as needed; the host supplies their implementations. Declared errors retain their Schema types. Applications still own resource authorization and use `rpcBoundary` when they need to map unexpected failures.
|
|
70
|
+
RPC uses the existing `localRpcGuard`: it requires a loopback peer and Host, same-origin or absent Origin, and the NDJSON content type. Session lookup uses transport headers. With a session policy, contracts declare `Authenticated`, `MaybeAuthenticated` and `RequestTracing` as needed; the host supplies their implementations. For `AuthenticatedUser`, merge `authenticatedUserLayer(sessions)` beside the handlers as shown below. Declared errors retain their Schema types. Applications still own resource authorization and use `rpcBoundary` when they need to map unexpected failures.
|
|
69
71
|
|
|
70
72
|
For local tools, use `policy: "loopback"` with contracts that do not use session middleware to serve RPC without a session provider. The guard requires a loopback peer and Host, absent or same-origin Origin, and NDJSON content type. This policy does not use `TRUSTED_PROXY` or `config.trustedProxy`. Set `rpcPath` to choose another native RPC route; `/rpc` remains the default.
|
|
71
73
|
|
|
@@ -129,6 +131,34 @@ export const sessions = {
|
|
|
129
131
|
|
|
130
132
|
The application's `auth` owns its storage and session configuration. A null lookup becomes a missing session. A thrown or rejected lookup is logged in redacted form and fails with the generic `AuthUnavailable` message. It remains a failure even on an RPC with optional authentication.
|
|
131
133
|
|
|
134
|
+
### Reading the signed-in user
|
|
135
|
+
|
|
136
|
+
When a handler needs the current user's name and email, declare `AuthenticatedUser` and read `SessionUser`. `Identity` keeps its `{ id }` shape; the new middleware supplies both services for that invocation. Its provider must return `user: { id, name, email }`, described by `UserSessionShape`.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { Effect, Layer, Schema } from "effect";
|
|
140
|
+
import { Rpc, RpcGroup } from "effect/rpc";
|
|
141
|
+
import { SessionUser } from "@shivaedev/platform/rpc/identity.ts";
|
|
142
|
+
import { AuthenticatedUser } from "@shivaedev/platform/rpc/middleware.ts";
|
|
143
|
+
import { authenticatedUserLayer } from "@shivaedev/platform/rpc-server/session.ts";
|
|
144
|
+
|
|
145
|
+
export const Account = RpcGroup.make(
|
|
146
|
+
Rpc.make("Whoami", {
|
|
147
|
+
success: Schema.Struct({ id: Schema.String, name: Schema.String, email: Schema.String }),
|
|
148
|
+
}),
|
|
149
|
+
).middleware(AuthenticatedUser);
|
|
150
|
+
|
|
151
|
+
export const AccountHandlers = Account.toLayer({
|
|
152
|
+
Whoami: () => Effect.map(SessionUser, (user) => user),
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
export const AccountServer = Layer.merge(AccountHandlers, authenticatedUserLayer(sessions));
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Here `sessions` is the application's policy from the previous example, with a Better Auth lookup that returns all three user fields. Merge `authenticatedUserLayer(sessions)` alongside the handler Layer when using `appHost`; the host continues to supply its id-only and optional middleware. A missing session fails with typed `Unauthorized`; rejected origins fail with `Forbidden`, and provider failures remain `AuthUnavailable`. The profile contains only id, name and email, without exposing the rest of the provider's user record. Handlers do not query the provider's user table.
|
|
159
|
+
|
|
160
|
+
The starter's `notes.whoami` query returns this profile, and its note handlers use `SessionUser.id` for ownership. Its PostgreSQL/HTTP test checks concurrent users, anonymous requests and sign-out revocation.
|
|
161
|
+
|
|
132
162
|
### Transport headers and request ids
|
|
133
163
|
|
|
134
164
|
Session resolution reads `HttpServerRequest`: the HTTP POST or WebSocket upgrade request. Credentials and Origin supplied inside an RPC message cannot replace those transport headers. An application-owned middleware can use `transportHeaders(rpcHeaders)` for the same source of headers.
|
|
@@ -368,10 +398,10 @@ Import the module that defines the name; there is no package-root entry. Paths b
|
|
|
368
398
|
| `appHost.ts` | `appHost({ group, handlers, services, migrations?, sessions?, policy?, rpcPath?, assets?, routes?, config? })`, `appDatabase({ migrations, config? })`, `AppChanges`, `AppHostOptions`, `AppHttpHostOptions`, `AppLocalHostOptions`, `AppDatabaseOptions`: scoped HTTP and PostgreSQL composition with loopback defaults and optional proxy trust. |
|
|
369
399
|
| `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`. |
|
|
370
400
|
| `errors/rejected-field.ts` | `rejectedField(unknown): Option<RejectedField>`; `RejectedField` is `{ field: string, message: string }`. |
|
|
371
|
-
| `rpc/identity.ts` | `RequestId`: string service. `Identity`: `IdentityValue`, `{ id: string }`. `OptionalIdentity`: `Option<IdentityValue>`. |
|
|
372
|
-
| `rpc/middleware.ts` | `RequestTracing`, `Authenticated`, `MaybeAuthenticated`: native RPC middleware declarations. |
|
|
401
|
+
| `rpc/identity.ts` | `RequestId`: string service. `Identity`: `IdentityValue`, `{ id: string }`. `OptionalIdentity`: `Option<IdentityValue>`. `SessionUser`: `SessionUserValue`, `{ id, name, email }`. |
|
|
402
|
+
| `rpc/middleware.ts` | `RequestTracing`, `Authenticated`, `AuthenticatedUser`, `MaybeAuthenticated`: native RPC middleware declarations. |
|
|
373
403
|
| `rpc-server/boundary.ts` | `rpcBoundary(schema, { unexpected, message? })`; `RpcBoundaryOptions<Error>`: declared failures pass through, unexpected failures become one declared rejection. |
|
|
374
|
-
| `rpc-server/session.ts` | `authenticatedLayer(policy)`, `maybeAuthenticatedLayer(policy)`, `resolveSession(policy, headers, rpc)`; `SessionShape`, `SessionProvider<Session>`, `SessionPolicy<Session>`. |
|
|
404
|
+
| `rpc-server/session.ts` | `authenticatedLayer(policy)`, `maybeAuthenticatedLayer(policy)`, `resolveSession(policy, headers, rpc)`; `SessionShape`, `SessionProvider<Session>`, `SessionPolicy<Session>`. `authenticatedUserLayer(policy)` requires `UserSessionShape` and implements `AuthenticatedUser`. |
|
|
375
405
|
| `rpc-server/adapters/better-auth-sessions.ts` | `betterAuthSessions(getSession)`; `GetSession<Session>` is a Promise lookup returning `Session \| null`. |
|
|
376
406
|
| `rpc-server/origin.ts` | `trustedOrigins({ allow, missing })`, `originRequest(headers, rpc)`; `OriginPolicy`, `OriginRequest`, `TrustedOriginsOptions`. |
|
|
377
407
|
| `rpc-server/local.ts` | `localRpcGuard(effect)`: HTTP RPC guard using native request and serialization services; `loopbackOnly(handler)`, `sameOrigin(request)`. |
|
package/dist/rpc/identity.d.ts
CHANGED
|
@@ -11,5 +11,12 @@ export declare class Identity extends Identity_base {
|
|
|
11
11
|
declare const OptionalIdentity_base: Context.ServiceClass<OptionalIdentity, "@shivaedev/platform/rpc/OptionalIdentity", Option.Option<IdentityValue>>;
|
|
12
12
|
export declare class OptionalIdentity extends OptionalIdentity_base {
|
|
13
13
|
}
|
|
14
|
+
export interface SessionUserValue extends IdentityValue {
|
|
15
|
+
readonly email: string;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
}
|
|
18
|
+
declare const SessionUser_base: Context.ServiceClass<SessionUser, "@shivaedev/platform/rpc/SessionUser", SessionUserValue>;
|
|
19
|
+
export declare class SessionUser extends SessionUser_base {
|
|
20
|
+
}
|
|
14
21
|
export {};
|
|
15
22
|
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -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,MAAM,QAAQ,CAAC;;AAC9C,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"}
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/rpc/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;;AAC9C,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,gBAAiB,SAAQ,aAAa;IACtD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;;AACD,qBAAa,WAAY,SAAQ,gBAAuF;CAAG"}
|
package/dist/rpc/identity.js
CHANGED
|
@@ -5,4 +5,6 @@ export class Identity extends Context.Service()("@shivaedev/platform/rpc/Identit
|
|
|
5
5
|
}
|
|
6
6
|
export class OptionalIdentity extends Context.Service()("@shivaedev/platform/rpc/OptionalIdentity") {
|
|
7
7
|
}
|
|
8
|
+
export class SessionUser extends Context.Service()("@shivaedev/platform/rpc/SessionUser") {
|
|
9
|
+
}
|
|
8
10
|
//# sourceMappingURL=identity.js.map
|
package/dist/rpc/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/rpc/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,QAAQ,CAAC;AAC9C,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAAqB,CAAC,mCAAmC,CAAC;CAAG;AAI3G,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,OAAO,EAA2B,CAAC,kCAAkC,CAAC;CAAG;AAC/G,MAAM,OAAO,gBAAiB,SAAQ,OAAO,CAAC,OAAO,EAAkD,CAAC,0CAA0C,CAAC;CAAG"}
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/rpc/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,QAAQ,CAAC;AAC9C,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAAqB,CAAC,mCAAmC,CAAC;CAAG;AAI3G,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,OAAO,EAA2B,CAAC,kCAAkC,CAAC;CAAG;AAC/G,MAAM,OAAO,gBAAiB,SAAQ,OAAO,CAAC,OAAO,EAAkD,CAAC,0CAA0C,CAAC;CAAG;AAKtJ,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAAiC,CAAC,qCAAqC,CAAC;CAAG"}
|
package/dist/rpc/middleware.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { RpcMiddleware } from "effect/rpc";
|
|
3
3
|
import { AuthUnavailable, Forbidden, Unauthorized } from "#errors/taxonomy.ts";
|
|
4
|
-
import type { Identity, OptionalIdentity, RequestId } from "./identity.ts";
|
|
4
|
+
import type { Identity, OptionalIdentity, RequestId, SessionUser } 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 {
|
|
7
7
|
}
|
|
@@ -11,5 +11,8 @@ export declare class Authenticated extends Authenticated_base {
|
|
|
11
11
|
declare const MaybeAuthenticated_base: RpcMiddleware.ServiceClass<MaybeAuthenticated, "@shivaedev/platform/rpc/MaybeAuthenticated", OptionalIdentity, Schema.Union<readonly [typeof AuthUnavailable, typeof Forbidden]>, never, never, false>;
|
|
12
12
|
export declare class MaybeAuthenticated extends MaybeAuthenticated_base {
|
|
13
13
|
}
|
|
14
|
+
declare const AuthenticatedUser_base: RpcMiddleware.ServiceClass<AuthenticatedUser, "@shivaedev/platform/rpc/AuthenticatedUser", Identity | SessionUser, Schema.Union<readonly [typeof Unauthorized, typeof AuthUnavailable, typeof Forbidden]>, never, never, false>;
|
|
15
|
+
export declare class AuthenticatedUser extends AuthenticatedUser_base {
|
|
16
|
+
}
|
|
14
17
|
export {};
|
|
15
18
|
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -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,MAAM,eAAe,CAAC;;
|
|
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,MAAM,eAAe,CAAC;;AACxF,qBAAa,cAAe,SAAQ,mBAKS;CAAG;;AAChD,qBAAa,aAAc,SAAQ,kBAOjC;CAAG;;AACL,qBAAa,kBAAmB,SAAQ,uBAKgE;CAAG;;AAC3G,qBAAa,iBAAkB,SAAQ,sBAOrC;CAAG"}
|
package/dist/rpc/middleware.js
CHANGED
|
@@ -9,4 +9,8 @@ export class Authenticated extends RpcMiddleware.Service()("@shivaedev/platform/
|
|
|
9
9
|
}
|
|
10
10
|
export class MaybeAuthenticated extends RpcMiddleware.Service()("@shivaedev/platform/rpc/MaybeAuthenticated", { error: Schema.Union([AuthUnavailable, Forbidden]) }) {
|
|
11
11
|
}
|
|
12
|
+
export class AuthenticatedUser extends RpcMiddleware.Service()("@shivaedev/platform/rpc/AuthenticatedUser", {
|
|
13
|
+
error: Schema.Union([Unauthorized, AuthUnavailable, Forbidden]),
|
|
14
|
+
}) {
|
|
15
|
+
}
|
|
12
16
|
//# sourceMappingURL=middleware.js.map
|
|
@@ -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,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE/E,MAAM,OAAO,cAAe,SAAQ,aAAa,CAAC,OAAO,EAKtD,CAAC,wCAAwC,CAAC;CAAG;AAChD,MAAM,OAAO,aAAc,SAAQ,aAAa,CAAC,OAAO,EAKrD,CAAC,uCAAuC,EAAE;IAC5C,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,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;CAAG"}
|
|
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,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE/E,MAAM,OAAO,cAAe,SAAQ,aAAa,CAAC,OAAO,EAKtD,CAAC,wCAAwC,CAAC;CAAG;AAChD,MAAM,OAAO,aAAc,SAAQ,aAAa,CAAC,OAAO,EAKrD,CAAC,uCAAuC,EAAE;IAC5C,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,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;CAAG;AAC3G,MAAM,OAAO,iBAAkB,SAAQ,aAAa,CAAC,OAAO,EAKzD,CAAC,2CAA2C,EAAE;IAChD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;CAC/D,CAAC;CAAG"}
|
package/dist/server/appHost.d.ts
CHANGED
|
@@ -37,25 +37,25 @@ export interface AppDatabaseOptions<R = never> {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
export declare function appDatabase<R>(options: AppDatabaseOptions<R>): import("effect/Layer").Layer<AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient, import("effect/Config").ConfigError | Migrator.MigrationError | import("effect/sql/SqlError").SqlError, Exclude<Exclude<R, import("effect/Scope").Scope>, import("@effect/sql-pg/PgClient").PgClient | import("effect/sql/SqlClient").SqlClient>>;
|
|
40
|
-
export
|
|
40
|
+
export type AppHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TSession extends SessionShape = SessionShape> = HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & {
|
|
41
41
|
readonly migrations: AppDatabaseOptions<TMigrations>["migrations"];
|
|
42
42
|
readonly policy?: undefined;
|
|
43
43
|
readonly sessions: SessionPolicy<TSession>;
|
|
44
|
-
}
|
|
45
|
-
export type AppLocalHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations> = HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & {
|
|
44
|
+
};
|
|
45
|
+
export type AppLocalHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never> = HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & {
|
|
46
46
|
readonly migrations: AppDatabaseOptions<TMigrations>["migrations"];
|
|
47
47
|
readonly policy: "loopback";
|
|
48
48
|
readonly sessions?: never;
|
|
49
49
|
};
|
|
50
|
-
export type AppHttpHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession extends SessionShape> = HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostPolicy<TSession> & {
|
|
50
|
+
export type AppHttpHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TSession extends SessionShape = SessionShape> = HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostPolicy<TSession> & {
|
|
51
51
|
readonly migrations?: undefined;
|
|
52
52
|
};
|
|
53
|
-
export declare function appHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession extends SessionShape>(options: AppHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession> | AppLocalHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations>): ReturnType<typeof migratedHost<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession>>;
|
|
54
|
-
export declare function appHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements>(options: HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & {
|
|
53
|
+
export declare function appHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TSession extends SessionShape = SessionShape>(options: AppHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession> | AppLocalHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations>): ReturnType<typeof migratedHost<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession>>;
|
|
54
|
+
export declare function appHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never>(options: HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & {
|
|
55
55
|
readonly policy: "loopback";
|
|
56
56
|
readonly sessions?: never;
|
|
57
57
|
readonly migrations?: undefined;
|
|
58
58
|
}): ReturnType<typeof appHostHttp<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, SessionShape>>;
|
|
59
|
-
export declare function appHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession extends SessionShape>(options: AppHttpHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession>): ReturnType<typeof appHostHttp<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession>>;
|
|
59
|
+
export declare function appHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TSession extends SessionShape = SessionShape>(options: AppHttpHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession>): ReturnType<typeof appHostHttp<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession>>;
|
|
60
60
|
export {};
|
|
61
61
|
//# sourceMappingURL=appHost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appHost.d.ts","sourceRoot":"","sources":["../../src/server/appHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;;;;;;;;;;;;;;;;;AAEhE,qBAAa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oBAAoB,GAAG,KAAK,EAC5B,QAAQ,SAAS,YAAY,GAAG,YAAY,EAE5C,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,QAAQ,CAAC,GAC1I,UAAU,CAAC,OAAO,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appHost.js","sourceRoot":"","sources":["../../src/server/appHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA6C,MAAM,QAAQ,CAAC;AAM5E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,MAAM,OAAO,UAAW,SAAQ,OAAO,CAAC,OAAO,EAAqD,CAAC,gCAAgC,CAAC;CAAG;AAezI,MAAM,UAAU,WAAW,CAAI,OAA8B;IAC5D,OAAO,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAC3C,CAAC;
|
|
1
|
+
{"version":3,"file":"appHost.js","sourceRoot":"","sources":["../../src/server/appHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA6C,MAAM,QAAQ,CAAC;AAM5E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,MAAM,OAAO,UAAW,SAAQ,OAAO,CAAC,OAAO,EAAqD,CAAC,gCAAgC,CAAC;CAAG;AAezI,MAAM,UAAU,WAAW,CAAI,OAA8B;IAC5D,OAAO,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAC3C,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Q,SAAS,YAAY,EAE7B,OAAO,EAAE,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,u3QA0DlJ;AAED,wBAAgB,YAAY,CAC3B,KAAK,SAAS,GAAG,CAAC,GAAG,EACrB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,QAAQ,SAAS,YAAY,EAE7B,OAAO,EACJ,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,WAAW,EAAE,QAAQ,CAAC,GAC5I,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,WAAW,CAAC,EAC1I,QAAQ,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,WAAW,CAAC,CAAC,26YAIvD"}
|
|
@@ -30,7 +30,7 @@ export function appHostHttp(options) {
|
|
|
30
30
|
const assets = options.assets === undefined
|
|
31
31
|
? Layer.empty
|
|
32
32
|
: HttpStaticServer.layer(typeof options.assets === "string" ? { root: options.assets } : options.assets);
|
|
33
|
-
const application = options.services;
|
|
33
|
+
const application = Layer.mergeAll(options.services ?? Layer.empty);
|
|
34
34
|
const server = Layer.unwrap(Effect.gen(function* () {
|
|
35
35
|
const port = options.config?.port ?? (yield* Config.Int("PORT").pipe(Config.withDefault(3000)));
|
|
36
36
|
const host = options.config?.host ?? (yield* Config.String("HOST").pipe(Config.withDefault("127.0.0.1")));
|
|
@@ -46,6 +46,7 @@ export function appHostHttp(options) {
|
|
|
46
46
|
}));
|
|
47
47
|
}
|
|
48
48
|
export function migratedHost(options, database) {
|
|
49
|
-
|
|
49
|
+
const services = Layer.mergeAll(options.services ?? Layer.empty);
|
|
50
|
+
return appHostHttp({ ...options, services: services.pipe(Layer.provideMerge(database)) });
|
|
50
51
|
}
|
|
51
52
|
//# sourceMappingURL=appHostHttp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appHostHttp.js","sourceRoot":"","sources":["../../src/server/appHostHttp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAY,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAqB,MAAM,wBAAwB,CAAC;AACxG,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,MAAM,UAAU,WAAW,CAU1B,OAAkJ;IAElJ,OAAO,KAAK,CAAC,MAAM,CAClB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,WAAW,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9H,MAAM,QAAQ,GAAG,KAAK,CA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HttpRouter, HttpStaticServer } from "effect/http";
|
|
|
3
3
|
import type { Rpc, RpcGroup } from "effect/rpc";
|
|
4
4
|
import type { SessionPolicy, SessionShape } from "#rpc-server/session.ts";
|
|
5
5
|
import type { AppDatabaseOptions } from "./appHost.ts";
|
|
6
|
-
export
|
|
6
|
+
export type HostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> = {
|
|
7
7
|
readonly assets?: string | Parameters<typeof HttpStaticServer.layer>[0];
|
|
8
8
|
readonly config?: AppDatabaseOptions["config"] & {
|
|
9
9
|
readonly port?: number;
|
|
@@ -16,8 +16,10 @@ export interface HostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, TH
|
|
|
16
16
|
readonly handlers: Layer.Layer<THandlers, THandlerError, THandlerRequirements>;
|
|
17
17
|
readonly routes?: Layer.Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Error", unknown>>;
|
|
18
18
|
readonly rpcPath?: HttpRouter.PathInput;
|
|
19
|
+
readonly services?: Layer.Layer<TServices, TServiceError, TServiceRequirements>;
|
|
20
|
+
} & ([TServices | TServiceError | TServiceRequirements] extends [never] ? unknown : {
|
|
19
21
|
readonly services: Layer.Layer<TServices, TServiceError, TServiceRequirements>;
|
|
20
|
-
}
|
|
22
|
+
});
|
|
21
23
|
export type HostPolicy<TSession extends SessionShape> = {
|
|
22
24
|
readonly policy?: undefined;
|
|
23
25
|
readonly sessions: SessionPolicy<TSession>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostOptions.d.ts","sourceRoot":"","sources":["../../src/server/hostOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OA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Q,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1G,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;CAChF,GAAG,CAAC,CAAC,SAAS,GAAG,aAAa,GAAG,oBAAoB,CAAC,SAAS,CAAC,KAAK,CAAC,GACpE,OAAO,GACP;IAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAA;CAAE,CAAC,CAAC;AAEvF,MAAM,MAAM,UAAU,CAAC,QAAQ,SAAS,YAAY,IACjD;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;CAAE,GAC3E;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Effect, Layer, Option } from "effect";
|
|
2
2
|
import type { Headers } from "effect/http";
|
|
3
3
|
import { type AuthUnavailable, Forbidden } from "#errors/taxonomy.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { type SessionUserValue } from "#rpc/identity.ts";
|
|
5
|
+
import { Authenticated, AuthenticatedUser, MaybeAuthenticated } from "#rpc/middleware.ts";
|
|
5
6
|
import { type OriginPolicy } from "./origin.ts";
|
|
6
7
|
export interface SessionShape {
|
|
7
8
|
readonly user: {
|
|
@@ -18,4 +19,8 @@ export interface SessionPolicy<TSession extends SessionShape> {
|
|
|
18
19
|
export declare const resolveSession: <TSession extends SessionShape>(policy: SessionPolicy<TSession>, headers: Headers.Headers, rpc: string) => Effect.Effect<Option.Option<TSession>, AuthUnavailable | Forbidden>;
|
|
19
20
|
export declare function authenticatedLayer<TSession extends SessionShape>(policy: SessionPolicy<TSession>): Layer.Layer<Authenticated>;
|
|
20
21
|
export declare function maybeAuthenticatedLayer<TSession extends SessionShape>(policy: SessionPolicy<TSession>): Layer.Layer<MaybeAuthenticated>;
|
|
22
|
+
export interface UserSessionShape extends SessionShape {
|
|
23
|
+
readonly user: SessionUserValue;
|
|
24
|
+
}
|
|
25
|
+
export declare function authenticatedUserLayer<TSession extends UserSessionShape>(policy: SessionPolicy<TSession>): Layer.Layer<AuthenticatedUser>;
|
|
21
26
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/server/rpc-server/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,eAAe,EAAE,SAAS,EAAgB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/server/rpc-server/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,eAAe,EAAE,SAAS,EAAgB,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAA2C,KAAK,gBAAgB,E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Q,YAAY;IACrD,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;CAChC;AACD,wBAAgB,sBAAsB,CAAC,QAAQ,SAAS,gBAAgB,EAAE,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAgBzI"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Layer, Option } from "effect";
|
|
2
2
|
import { Forbidden, Unauthorized } from "#errors/taxonomy.ts";
|
|
3
|
-
import { Identity, OptionalIdentity } from "#rpc/identity.ts";
|
|
4
|
-
import { Authenticated, MaybeAuthenticated } from "#rpc/middleware.ts";
|
|
3
|
+
import { Identity, OptionalIdentity, SessionUser } from "#rpc/identity.ts";
|
|
4
|
+
import { Authenticated, AuthenticatedUser, MaybeAuthenticated } from "#rpc/middleware.ts";
|
|
5
5
|
import { originRequest } from "./origin.js";
|
|
6
6
|
import { transportHeaders } from "./transportHeaders.js";
|
|
7
7
|
export const resolveSession = Effect.fn("PlatformRpc.resolveSession")(function* (policy, headers, rpc) {
|
|
@@ -34,4 +34,15 @@ export function maybeAuthenticatedLayer(policy) {
|
|
|
34
34
|
return yield* effect.pipe(Effect.provideService(OptionalIdentity, Option.some({ id })), Effect.annotateLogs({ userId: id }));
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
|
+
export function authenticatedUserLayer(policy) {
|
|
38
|
+
return Layer.succeed(AuthenticatedUser, (effect, { headers, rpc }) => Effect.gen(function* () {
|
|
39
|
+
const session = yield* resolveSession(policy, headers, rpc._tag);
|
|
40
|
+
if (Option.isNone(session)) {
|
|
41
|
+
return yield* new Unauthorized({ message: "Authentication required" });
|
|
42
|
+
}
|
|
43
|
+
const { name, email } = session.value.user;
|
|
44
|
+
const id = yield* identified(session.value.user.id);
|
|
45
|
+
return yield* effect.pipe(Effect.provideService(Identity, { id }), Effect.provideService(SessionUser, { email, id, name }), Effect.annotateLogs({ userId: id }));
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
37
48
|
//# sourceMappingURL=session.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/server/rpc-server/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,EAAwB,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/server/rpc-server/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,EAAwB,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAyB,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAqB,aAAa,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAazD,MAAM,CAAC,MAAM,cAAc,GAIgD,MAAM,CAAC,EAAE,CAAC,4BAA4B,CAAC,CAAC,QAAQ,CAAC,EAE1H,MAA+B,EAAE,OAAwB,EAAE,GAAW;IACvE,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC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AAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;QAC3C,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACxB,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,CAAC,EACvC,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EACvD,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACnC,CAAC;IACH,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/platform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Opinionated Effect application infrastructure for ShivaeDev services",
|
|
5
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/platform#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
"dependencies": {
|
|
328
328
|
"@shivaedev/effect-contract": "0.5.0",
|
|
329
329
|
"@shivaedev/effect-sql": "0.3.0",
|
|
330
|
-
"@shivaedev/types": "0.2.
|
|
330
|
+
"@shivaedev/types": "0.2.1"
|
|
331
331
|
},
|
|
332
332
|
"devDependencies": {
|
|
333
333
|
"@effect/platform-node": "4.0.4",
|
|
@@ -341,7 +341,7 @@
|
|
|
341
341
|
"@prisma-next/target-postgres": "0.16.0",
|
|
342
342
|
"@shivaedev/effect-prisma": "0.9.0",
|
|
343
343
|
"@shivaedev/effect-trpc": "0.7.0",
|
|
344
|
-
"@shivaedev/quality": "0.
|
|
344
|
+
"@shivaedev/quality": "0.21.0",
|
|
345
345
|
"@trpc/client": "11.19.0",
|
|
346
346
|
"@trpc/server": "11.19.0",
|
|
347
347
|
"@types/node": "24.19.1",
|
package/src/rpc/identity.ts
CHANGED
|
@@ -5,3 +5,8 @@ export interface IdentityValue {
|
|
|
5
5
|
}
|
|
6
6
|
export class Identity extends Context.Service<Identity, IdentityValue>()("@shivaedev/platform/rpc/Identity") {}
|
|
7
7
|
export class OptionalIdentity extends Context.Service<OptionalIdentity, Option.Option<IdentityValue>>()("@shivaedev/platform/rpc/OptionalIdentity") {}
|
|
8
|
+
export interface SessionUserValue extends IdentityValue {
|
|
9
|
+
readonly email: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
}
|
|
12
|
+
export class SessionUser extends Context.Service<SessionUser, SessionUserValue>()("@shivaedev/platform/rpc/SessionUser") {}
|
package/src/rpc/middleware.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { RpcMiddleware } from "effect/rpc";
|
|
3
3
|
import { AuthUnavailable, Forbidden, Unauthorized } from "#errors/taxonomy.ts";
|
|
4
|
-
import type { Identity, OptionalIdentity, RequestId } from "./identity.ts";
|
|
4
|
+
import type { Identity, OptionalIdentity, RequestId, SessionUser } from "./identity.ts";
|
|
5
5
|
export class RequestTracing extends RpcMiddleware.Service<
|
|
6
6
|
RequestTracing,
|
|
7
7
|
{
|
|
@@ -22,3 +22,11 @@ export class MaybeAuthenticated extends RpcMiddleware.Service<
|
|
|
22
22
|
provides: OptionalIdentity;
|
|
23
23
|
}
|
|
24
24
|
>()("@shivaedev/platform/rpc/MaybeAuthenticated", { error: Schema.Union([AuthUnavailable, Forbidden]) }) {}
|
|
25
|
+
export class AuthenticatedUser extends RpcMiddleware.Service<
|
|
26
|
+
AuthenticatedUser,
|
|
27
|
+
{
|
|
28
|
+
provides: Identity | SessionUser;
|
|
29
|
+
}
|
|
30
|
+
>()("@shivaedev/platform/rpc/AuthenticatedUser", {
|
|
31
|
+
error: Schema.Union([Unauthorized, AuthUnavailable, Forbidden]),
|
|
32
|
+
}) {}
|
package/src/server/appHost.ts
CHANGED
|
@@ -27,31 +27,31 @@ export function appDatabase<R>(options: AppDatabaseOptions<R>) {
|
|
|
27
27
|
return databaseLayer(options, AppChanges);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export
|
|
30
|
+
export type AppHostOptions<
|
|
31
31
|
TRpcs extends Rpc.Any,
|
|
32
32
|
THandlers,
|
|
33
33
|
THandlerError,
|
|
34
34
|
THandlerRequirements,
|
|
35
|
-
TServices,
|
|
36
|
-
TServiceError,
|
|
37
|
-
TServiceRequirements,
|
|
38
|
-
TMigrations,
|
|
39
|
-
TSession extends SessionShape,
|
|
40
|
-
>
|
|
35
|
+
TServices = never,
|
|
36
|
+
TServiceError = never,
|
|
37
|
+
TServiceRequirements = never,
|
|
38
|
+
TMigrations = never,
|
|
39
|
+
TSession extends SessionShape = SessionShape,
|
|
40
|
+
> = HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & {
|
|
41
41
|
readonly migrations: AppDatabaseOptions<TMigrations>["migrations"];
|
|
42
42
|
readonly policy?: undefined;
|
|
43
43
|
readonly sessions: SessionPolicy<TSession>;
|
|
44
|
-
}
|
|
44
|
+
};
|
|
45
45
|
|
|
46
46
|
export type AppLocalHostOptions<
|
|
47
47
|
TRpcs extends Rpc.Any,
|
|
48
48
|
THandlers,
|
|
49
49
|
THandlerError,
|
|
50
50
|
THandlerRequirements,
|
|
51
|
-
TServices,
|
|
52
|
-
TServiceError,
|
|
53
|
-
TServiceRequirements,
|
|
54
|
-
TMigrations,
|
|
51
|
+
TServices = never,
|
|
52
|
+
TServiceError = never,
|
|
53
|
+
TServiceRequirements = never,
|
|
54
|
+
TMigrations = never,
|
|
55
55
|
> = HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & {
|
|
56
56
|
readonly migrations: AppDatabaseOptions<TMigrations>["migrations"];
|
|
57
57
|
readonly policy: "loopback";
|
|
@@ -63,10 +63,10 @@ export type AppHttpHostOptions<
|
|
|
63
63
|
THandlers,
|
|
64
64
|
THandlerError,
|
|
65
65
|
THandlerRequirements,
|
|
66
|
-
TServices,
|
|
67
|
-
TServiceError,
|
|
68
|
-
TServiceRequirements,
|
|
69
|
-
TSession extends SessionShape,
|
|
66
|
+
TServices = never,
|
|
67
|
+
TServiceError = never,
|
|
68
|
+
TServiceRequirements = never,
|
|
69
|
+
TSession extends SessionShape = SessionShape,
|
|
70
70
|
> = HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> &
|
|
71
71
|
HostPolicy<TSession> & { readonly migrations?: undefined };
|
|
72
72
|
|
|
@@ -75,11 +75,11 @@ export function appHost<
|
|
|
75
75
|
THandlers,
|
|
76
76
|
THandlerError,
|
|
77
77
|
THandlerRequirements,
|
|
78
|
-
TServices,
|
|
79
|
-
TServiceError,
|
|
80
|
-
TServiceRequirements,
|
|
81
|
-
TMigrations,
|
|
82
|
-
TSession extends SessionShape,
|
|
78
|
+
TServices = never,
|
|
79
|
+
TServiceError = never,
|
|
80
|
+
TServiceRequirements = never,
|
|
81
|
+
TMigrations = never,
|
|
82
|
+
TSession extends SessionShape = SessionShape,
|
|
83
83
|
>(
|
|
84
84
|
options:
|
|
85
85
|
| AppHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession>
|
|
@@ -87,7 +87,15 @@ export function appHost<
|
|
|
87
87
|
): ReturnType<
|
|
88
88
|
typeof migratedHost<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession>
|
|
89
89
|
>;
|
|
90
|
-
export function appHost<
|
|
90
|
+
export function appHost<
|
|
91
|
+
TRpcs extends Rpc.Any,
|
|
92
|
+
THandlers,
|
|
93
|
+
THandlerError,
|
|
94
|
+
THandlerRequirements,
|
|
95
|
+
TServices = never,
|
|
96
|
+
TServiceError = never,
|
|
97
|
+
TServiceRequirements = never,
|
|
98
|
+
>(
|
|
91
99
|
options: HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & {
|
|
92
100
|
readonly policy: "loopback";
|
|
93
101
|
readonly sessions?: never;
|
|
@@ -101,10 +109,10 @@ export function appHost<
|
|
|
101
109
|
THandlers,
|
|
102
110
|
THandlerError,
|
|
103
111
|
THandlerRequirements,
|
|
104
|
-
TServices,
|
|
105
|
-
TServiceError,
|
|
106
|
-
TServiceRequirements,
|
|
107
|
-
TSession extends SessionShape,
|
|
112
|
+
TServices = never,
|
|
113
|
+
TServiceError = never,
|
|
114
|
+
TServiceRequirements = never,
|
|
115
|
+
TSession extends SessionShape = SessionShape,
|
|
108
116
|
>(
|
|
109
117
|
options: AppHttpHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession>,
|
|
110
118
|
): ReturnType<typeof appHostHttp<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession>>;
|
|
@@ -113,11 +121,11 @@ export function appHost<
|
|
|
113
121
|
THandlers,
|
|
114
122
|
THandlerError,
|
|
115
123
|
THandlerRequirements,
|
|
116
|
-
TServices,
|
|
117
|
-
TServiceError,
|
|
118
|
-
TServiceRequirements,
|
|
119
|
-
TMigrations,
|
|
120
|
-
TSession extends SessionShape,
|
|
124
|
+
TServices = never,
|
|
125
|
+
TServiceError = never,
|
|
126
|
+
TServiceRequirements = never,
|
|
127
|
+
TMigrations = never,
|
|
128
|
+
TSession extends SessionShape = SessionShape,
|
|
121
129
|
>(
|
|
122
130
|
options:
|
|
123
131
|
| AppHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession>
|
|
@@ -58,7 +58,7 @@ export function appHostHttp<
|
|
|
58
58
|
options.assets === undefined
|
|
59
59
|
? Layer.empty
|
|
60
60
|
: HttpStaticServer.layer(typeof options.assets === "string" ? { root: options.assets } : options.assets);
|
|
61
|
-
const application = options.services;
|
|
61
|
+
const application = Layer.mergeAll(options.services ?? Layer.empty);
|
|
62
62
|
const server = Layer.unwrap(
|
|
63
63
|
Effect.gen(function* () {
|
|
64
64
|
const port = options.config?.port ?? (yield* Config.Int("PORT").pipe(Config.withDefault(3000)));
|
|
@@ -97,5 +97,6 @@ export function migratedHost<
|
|
|
97
97
|
| AppLocalHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations>,
|
|
98
98
|
database: ReturnType<typeof databaseLayer<TMigrations>>,
|
|
99
99
|
) {
|
|
100
|
-
|
|
100
|
+
const services = Layer.mergeAll(options.services ?? Layer.empty);
|
|
101
|
+
return appHostHttp({ ...options, services: services.pipe(Layer.provideMerge(database)) });
|
|
101
102
|
}
|
|
@@ -4,7 +4,7 @@ import type { Rpc, RpcGroup } from "effect/rpc";
|
|
|
4
4
|
import type { SessionPolicy, SessionShape } from "#rpc-server/session.ts";
|
|
5
5
|
import type { AppDatabaseOptions } from "./appHost.ts";
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export type HostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> = {
|
|
8
8
|
readonly assets?: string | Parameters<typeof HttpStaticServer.layer>[0];
|
|
9
9
|
readonly config?: AppDatabaseOptions["config"] & {
|
|
10
10
|
readonly port?: number;
|
|
@@ -17,8 +17,10 @@ export interface HostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, TH
|
|
|
17
17
|
readonly handlers: Layer.Layer<THandlers, THandlerError, THandlerRequirements>;
|
|
18
18
|
readonly routes?: Layer.Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Error", unknown>>;
|
|
19
19
|
readonly rpcPath?: HttpRouter.PathInput;
|
|
20
|
-
readonly services
|
|
21
|
-
}
|
|
20
|
+
readonly services?: Layer.Layer<TServices, TServiceError, TServiceRequirements>;
|
|
21
|
+
} & ([TServices | TServiceError | TServiceRequirements] extends [never]
|
|
22
|
+
? unknown
|
|
23
|
+
: { readonly services: Layer.Layer<TServices, TServiceError, TServiceRequirements> });
|
|
22
24
|
|
|
23
25
|
export type HostPolicy<TSession extends SessionShape> =
|
|
24
26
|
| { readonly policy?: undefined; readonly sessions: SessionPolicy<TSession> }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Effect, Layer, Option } from "effect";
|
|
2
2
|
import type { Headers } from "effect/http";
|
|
3
3
|
import { type AuthUnavailable, Forbidden, Unauthorized } from "#errors/taxonomy.ts";
|
|
4
|
-
import { Identity, OptionalIdentity } from "#rpc/identity.ts";
|
|
5
|
-
import { Authenticated, MaybeAuthenticated } from "#rpc/middleware.ts";
|
|
4
|
+
import { Identity, OptionalIdentity, SessionUser, type SessionUserValue } from "#rpc/identity.ts";
|
|
5
|
+
import { Authenticated, AuthenticatedUser, MaybeAuthenticated } from "#rpc/middleware.ts";
|
|
6
6
|
import { type OriginPolicy, originRequest } from "./origin.ts";
|
|
7
7
|
import { transportHeaders } from "./transportHeaders.ts";
|
|
8
8
|
export interface SessionShape {
|
|
@@ -57,3 +57,23 @@ export function maybeAuthenticatedLayer<TSession extends SessionShape>(policy: S
|
|
|
57
57
|
}),
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
+
export interface UserSessionShape extends SessionShape {
|
|
61
|
+
readonly user: SessionUserValue;
|
|
62
|
+
}
|
|
63
|
+
export function authenticatedUserLayer<TSession extends UserSessionShape>(policy: SessionPolicy<TSession>): Layer.Layer<AuthenticatedUser> {
|
|
64
|
+
return Layer.succeed(AuthenticatedUser, (effect, { headers, rpc }) =>
|
|
65
|
+
Effect.gen(function* () {
|
|
66
|
+
const session = yield* resolveSession(policy, headers, rpc._tag);
|
|
67
|
+
if (Option.isNone(session)) {
|
|
68
|
+
return yield* new Unauthorized({ message: "Authentication required" });
|
|
69
|
+
}
|
|
70
|
+
const { name, email } = session.value.user;
|
|
71
|
+
const id = yield* identified(session.value.user.id);
|
|
72
|
+
return yield* effect.pipe(
|
|
73
|
+
Effect.provideService(Identity, { id }),
|
|
74
|
+
Effect.provideService(SessionUser, { email, id, name }),
|
|
75
|
+
Effect.annotateLogs({ userId: id }),
|
|
76
|
+
);
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
}
|