@shivaedev/server 0.41.2 → 0.42.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 +12 -0
- package/README.md +3 -3
- package/dist/appHostHttp.js +2 -2
- package/dist/appHostHttp.js.map +1 -1
- package/dist/hostOptions.d.ts +0 -1
- package/dist/hostOptions.d.ts.map +1 -1
- package/dist/hostRpcRoutes.d.ts +1 -1
- package/dist/hostRpcRoutes.d.ts.map +1 -1
- package/dist/hostRpcRoutes.js +3 -3
- package/dist/hostRpcRoutes.js.map +1 -1
- package/dist/hostTransport.d.ts +0 -2
- package/dist/hostTransport.d.ts.map +1 -1
- package/dist/hostTransport.js +1 -3
- package/dist/hostTransport.js.map +1 -1
- package/dist/nativeClientOrigins.d.ts +1 -3
- package/dist/nativeClientOrigins.d.ts.map +1 -1
- package/dist/nativeClientOrigins.js +10 -15
- package/dist/nativeClientOrigins.js.map +1 -1
- package/dist/socketRpc.d.ts +2 -2
- package/dist/socketRpc.d.ts.map +1 -1
- package/dist/socketRpc.js +3 -2
- package/dist/socketRpc.js.map +1 -1
- package/package.json +8 -8
- package/src/appHostHttp.ts +3 -3
- package/src/hostOptions.ts +0 -1
- package/src/hostRpcRoutes.ts +3 -3
- package/src/hostTransport.ts +1 -6
- package/src/nativeClientOrigins.ts +10 -25
- package/src/socketRpc.ts +2 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.42.0 - 2026-11-21
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `appHost` admits the origins in `SessionPolicy.nativeOrigins` through the RPC transport guard, the RPC socket upgrade and the auth routes, so an application no longer lists them for the host.
|
|
8
|
+
|
|
9
|
+
### Breaking
|
|
10
|
+
|
|
11
|
+
- `appHost`'s `nativeOrigins` option is removed; the host reads the list from `SessionPolicy.nativeOrigins`. Move the list to where the policy is made: with Better Auth, into `defineAuth({ nativeOrigins })` and spread `mounted.sessions` into the policy; for a local-owner host, into `localOwner({ nativeOrigins })` and use its `sessions`; for a hand-built `SessionPolicy`, set `nativeOrigins: yield* Schema.decodeUnknownEffect(NativeOrigins)(origins)` with `NativeOrigins` from `@shivaedev/identity/server/NativeOrigins.ts`. A host with `policy: "loopback"` has no session policy and admits no native origin.
|
|
12
|
+
- The transport value that `hostRpcRoutes` takes (the `hostTransport` result) no longer has `nativeOrigins`, and `socketRpc(handler, policy, trustedProxy)` lost its origin list parameter. Callers drop them.
|
|
13
|
+
- `NativeOrigins` from `@shivaedev/server/nativeClientOrigins.ts` moved to `@shivaedev/identity/server/NativeOrigins.ts`, and `nativeClientOrigins(trustedProxy, route, rpcPath?)` takes `"auth"` or `"rpc"` instead of an origin list and a mode.
|
|
14
|
+
|
|
3
15
|
## 0.41.2 - 2026-11-21
|
|
4
16
|
|
|
5
17
|
### Changed
|
package/README.md
CHANGED
|
@@ -206,7 +206,7 @@ const Routes = HttpRouter.add("*", "/.well-known/app", AppMetadata.pipe(Effect.m
|
|
|
206
206
|
const Server = appHost({ group: Api, handlers: Handlers, services: Services, routes: Routes, sessions });
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
`AppMetadata` is an app service supplied by `Services`. Register `OPTIONS` or `"*"` for a route whose native `HttpMiddleware.cors` must answer preflight. The host restricts foreign-origin preflights only on `rpcPath` (default `/rpc`) and `/api/auth/*`, including `/api/auth` itself. Application endpoints own their CORS policy.
|
|
209
|
+
`AppMetadata` is an app service supplied by `Services`. Register `OPTIONS` or `"*"` for a route whose native `HttpMiddleware.cors` must answer preflight. The host restricts foreign-origin preflights only on `rpcPath` (default `/rpc`) and `/api/auth/*`, including `/api/auth` itself. Application endpoints own their CORS policy. Bundled native-client origins come from `SessionPolicy.nativeOrigins`, which identity's auth mount fills from the auth declaration; the host admits them through its RPC, RPC socket and auth CORS policy. Browser sibling origins come from identity’s `trustedOrigins` policy on `SessionPolicy.origin`; other foreign origins receive 403 on those preflights.
|
|
210
210
|
|
|
211
211
|
To let a separate frontend call HTTP RPC with the user's session cookie, declare its exact origin through identity:
|
|
212
212
|
|
|
@@ -223,7 +223,7 @@ const sessions = Layer.succeed(SessionPolicy, {
|
|
|
223
223
|
const Server = appHost({ group: Api, handlers: Handlers, routes: mounted.routes, sessions });
|
|
224
224
|
```
|
|
225
225
|
|
|
226
|
-
Identity owns this list; the host uses it for transport admission, RPC CORS and mounted auth CORS, including preflights. Each listed origin receives its exact value in `Access-Control-Allow-Origin` and `Access-Control-Allow-Credentials: true`. Wildcards and patterns are not expanded. Reuse `browserOrigins` in Better Auth's `trustedOrigins` option to align provider CSRF checks. Browser fetch calls must use `credentials: "include"`. Application HTTP endpoints still own their CORS policy. `nativeOrigins`
|
|
226
|
+
Identity owns this list; the host uses it for transport admission, RPC CORS and mounted auth CORS, including preflights. Each listed origin receives its exact value in `Access-Control-Allow-Origin` and `Access-Control-Allow-Credentials: true`. Wildcards and patterns are not expanded. Reuse `browserOrigins` in Better Auth's `trustedOrigins` option to align provider CSRF checks. Browser fetch calls must use `credentials: "include"`. Application HTTP endpoints still own their CORS policy. Origins in `SessionPolicy.nativeOrigins` take precedence for bundled clients and keep their credential-free bearer behavior.
|
|
227
227
|
|
|
228
228
|
Cookie SameSite and Secure settings remain the application's choice. Same-site HTTPS sibling subdomains can keep their current attributes; a frontend on another registrable domain needs Better Auth's `advanced.defaultCookieAttributes: { sameSite: "none", secure: true }` and an HTTPS API for cross-site cookies. Browser third-party-cookie restrictions still apply.
|
|
229
229
|
|
|
@@ -256,7 +256,7 @@ For a native Node HTTP route outside RPC, read the request body with `readBounde
|
|
|
256
256
|
|
|
257
257
|
On TCP, ordinary POST RPC uses `localRpcGuard` from `@shivaedev/identity/server/adapters/local.ts`: it requires a loopback peer and Host, same-origin or absent Origin, and the NDJSON content type. The WebSocket upgrade uses the same loopback, origin and trusted-proxy checks without an HTTP body content type. Session lookup uses the upgrade's transport headers; RPC message headers cannot replace its cookie or Origin. Session middleware revalidates authenticated streams at `streamRevalidationInterval` and ends revoked subscriptions with typed `Unauthorized`. Cookie-authenticated sockets remain open; later protected calls use the same session checks. Automatic live subscriptions reload the session before each hint and use its current roles and grants for the query policy and any pushed query result. A policy denial keeps an established subscription open; delivery resumes on the next authorized hint. POST RPC refuses `$changes` subscriptions with the contract’s typed `WebSocketRequired` error and a message saying they need the WebSocket protocol. The host applies `RequestTracing` last to every served RPC, including loopback RPC, so it wraps authentication and handlers without a per-contract tracing declaration. Existing tracing declarations run once at that outermost boundary. With a session policy, contracts declare `Authenticated` and `MaybeAuthenticated` as needed; the host supplies their implementations. For `AuthenticatedUser`, merge `authenticatedUserLayer()` from `@shivaedev/identity/server/session.ts` beside the handlers. Declared errors retain their Schema types. Applications still own resource authorization and use `rpcBoundary` when they need to map unexpected failures.
|
|
258
258
|
|
|
259
|
-
Native clients that cannot set upgrade headers use `makeClient`'s `bearerToken` option from `@shivaedev/contract/makeClient.ts`. On session hosts, `GET /rpc?auth=frame` requires a first text frame shaped as `{"_tag":"Authenticate","token":"<credential>"}` within five seconds, with at most 8192 characters. The host consumes that frame before starting native RPC and supplies its bearer as the socket's transport Authorization header. The existing session provider, identity middleware, Origin policy and query read policies apply to every call and live read. RPC message headers cannot replace the authenticated credential.
|
|
259
|
+
Native clients that cannot set upgrade headers use `makeClient`'s `bearerToken` option from `@shivaedev/contract/makeClient.ts`. On session hosts, `GET /rpc?auth=frame` requires a first text frame shaped as `{"_tag":"Authenticate","token":"<credential>"}` within five seconds, with at most 8192 characters. The host consumes that frame before starting native RPC and supplies its bearer as the socket's transport Authorization header. The existing session provider, identity middleware, Origin policy and query read policies apply to every call and live read. RPC message headers cannot replace the authenticated credential. Bearer admission and the WebView Origin both come from the auth declaration's `nativeOrigins`, through the mount's `sessions`. A long-lived bearer is never placed in a URL.
|
|
260
260
|
|
|
261
261
|
Invalid, expired, malformed, oversized or missing first-frame credentials close the socket with code 1008 and reason `Authentication required`; session-provider failures close it with code 1011 and reason `Authentication unavailable`. The host checks the bearer socket's session at `streamRevalidationInterval`, including when no subscription is active, and closes it with code 1008 when the session is revoked, expires or changes identity. The session remains subject to the same per-call and per-hint checks as cookie sessions.
|
|
262
262
|
|
package/dist/appHostHttp.js
CHANGED
|
@@ -14,13 +14,13 @@ export function appHostHttp(options) {
|
|
|
14
14
|
const assets = options.assets === undefined ? Layer.empty : hostAssets(options.assets);
|
|
15
15
|
return redactedHost(options, (sensitive) => Layer.unwrap(Effect.gen(function* () {
|
|
16
16
|
const transport = yield* hostTransport(options);
|
|
17
|
-
const { bodySize, host, trustedProxy
|
|
17
|
+
const { bodySize, host, trustedProxy } = transport;
|
|
18
18
|
const routes = options.group === undefined ? Layer.empty : hostRpcRoutes(options, transport, sensitive);
|
|
19
19
|
const application = Layer.mergeAll(options.services ?? Layer.empty);
|
|
20
20
|
const sessions = Layer.mergeAll(Layer.empty, ...(options.sessions === undefined ? [] : [options.sessions]));
|
|
21
21
|
const server = nodeHttpServer(host, { ...options.config, maxBodySize: bodySize });
|
|
22
22
|
const applicationRoutes = hostApplicationRoutes(options.routes, bodySize);
|
|
23
|
-
const httpRoutes = Layer.mergeAll(routes, healthRoute, browserErrorRoute(trustedProxy, options.browserErrors), assets, applicationRoutes).pipe(Layer.provide(options.group === undefined ? Layer.empty : nativeClientOrigins(
|
|
23
|
+
const httpRoutes = Layer.mergeAll(routes, healthRoute, browserErrorRoute(trustedProxy, options.browserErrors), assets, applicationRoutes).pipe(Layer.provide(options.group === undefined ? Layer.empty : nativeClientOrigins(trustedProxy, "rpc", options.rpcPath)), Layer.provide(nativeClientOrigins(trustedProxy, "auth")));
|
|
24
24
|
return Layer.unwrap(HttpRouter.toHttpEffect(httpRoutes).pipe(
|
|
25
25
|
// Building the routes built every repository, so the policy is complete before the server takes a request.
|
|
26
26
|
Effect.tap(() => sensitive.complete), Effect.map((handler) => HttpServer.serve(handler).pipe(HttpServer.withLogAddress, Layer.provideMerge(server))))).pipe(Layer.provideMerge(application), Layer.provide(sessions), Layer.provideMerge(hostHttpServices));
|
package/dist/appHostHttp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appHostHttp.js","sourceRoot":"","sources":["../src/appHostHttp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,UAAU,WAAW,CAa1B,OAaW;IAEX,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvF,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,EAAE,CAC1C,KAAK,CAAC,MAAM,CACX,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,EAAE,QAAQ,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AAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,EACpC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAC9G,CACD,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACxG,CAAC,CAAC,CACF,CACD,CAAC;AACH,CAAC"}
|
package/dist/hostOptions.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export type HostCoreOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THa
|
|
|
20
20
|
readonly gracefulShutdownTimeout?: Duration.Input;
|
|
21
21
|
};
|
|
22
22
|
readonly requestServices?: Layer.Layer<TRequestServices, never, TRequestRequirements>;
|
|
23
|
-
readonly nativeOrigins?: readonly string[];
|
|
24
23
|
readonly rpcPath?: HttpRouter.PathInput;
|
|
25
24
|
} & ({
|
|
26
25
|
readonly group: RpcGroup.RpcGroup<TRpcs>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostOptions.d.ts","sourceRoot":"","sources":["../src/hostOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAm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GAAG,KAAK,IACzB,eAAe,CAClB,KAAK,EACL,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,CACpB,GACA,UAAU,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;AAE7C,MAAM,MAAM,UAAU,GACnB;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;CAAE,GAC9E;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC"}
|
package/dist/hostRpcRoutes.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare function hostRpcRoutes<TRpcs extends Rpc.Any, THandlers, TError,
|
|
|
20
20
|
readonly policy: "loopback";
|
|
21
21
|
}, transport: Effect.Success<ReturnType<typeof hostTransport>>, sensitive: Effect.Success<ReturnType<typeof schemaSensitiveKeys>>): Layer.Layer<Layer.Success<BuiltRoutes<TRpcs, THandlers, TError, TRequirements, TRequestServices, TRequestRequirements>>, Layer.Error<BuiltRoutes<TRpcs, THandlers, TError, TRequirements, TRequestServices, TRequestRequirements>>, Exclude<TRequirements, TRequestServices> | RequestRequirements<TRpcs, TRequestRequirements> | Exclude<Rpc.ServicesServer<TRpcs>, THandlers> | Exclude<Layer.Services<BuiltRoutes<TRpcs, THandlers, TError, TRequirements, TRequestServices, TRequestRequirements>>, SessionPolicy | HttpRouter.Request<"Requires", SessionPolicy> | TRequestServices | TRequestRequirements>>;
|
|
22
22
|
export declare function hostRpcRoutes<TRpcs extends Rpc.Any, THandlers, TError, TRequirements, TRequestServices = never, TRequestRequirements = never>(...args: Parameters<typeof buildRpcRoutes<TRpcs, THandlers, TError, TRequirements, TRequestServices, TRequestRequirements>>): Layer.Layer<Layer.Success<BuiltRoutes<TRpcs, THandlers, TError, TRequirements, TRequestServices, TRequestRequirements>>, Layer.Error<BuiltRoutes<TRpcs, THandlers, TError, TRequirements, TRequestServices, TRequestRequirements>>, Exclude<Layer.Services<BuiltRoutes<TRpcs, THandlers, TError, TRequirements, TRequestServices, TRequestRequirements>>, TRequestServices | TRequestRequirements> | Exclude<TRequirements, TRequestServices> | RequestRequirements<TRpcs, TRequestRequirements>>;
|
|
23
|
-
declare function buildRpcRoutes<TRpcs extends Rpc.Any, THandlers, TError, TRequirements, TRequestServices = never, TRequestRequirements = never>(options: RouteOptions<TRpcs, THandlers, TError, TRequirements, TRequestServices, TRequestRequirements>, { bodySize, trustedProxy
|
|
23
|
+
declare function buildRpcRoutes<TRpcs extends Rpc.Any, THandlers, TError, TRequirements, TRequestServices = never, TRequestRequirements = never>(options: RouteOptions<TRpcs, THandlers, TError, TRequirements, TRequestServices, TRequestRequirements>, { bodySize, trustedProxy }: Effect.Success<ReturnType<typeof hostTransport>>, sensitive: Effect.Success<ReturnType<typeof schemaSensitiveKeys>>): Layer.Layer<never, TError | import("./HandWrittenModuleHandlers.ts").HandWrittenModuleHandlers | import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicies | Effect.Error<(TRpcs extends {
|
|
24
24
|
readonly middlewares: ReadonlySet<infer TMiddleware>;
|
|
25
25
|
} ? Extract<TMiddleware, {
|
|
26
26
|
readonly "@shivaedev/contract/SubjectDeclaration": import("@shivaedev/contract/subject.ts").SubjectDeclaration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostRpcRoutes.d.ts","sourceRoot":"","sources":["../src/hostRpcRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,KAAK,E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,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,EAC5E,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qDA8DjE"}
|
package/dist/hostRpcRoutes.js
CHANGED
|
@@ -18,7 +18,7 @@ import { UnixSocketRequest } from "#UnixSocketRequest.ts";
|
|
|
18
18
|
export function hostRpcRoutes(...args) {
|
|
19
19
|
return buildRpcRoutes(...args);
|
|
20
20
|
}
|
|
21
|
-
function buildRpcRoutes(options, { bodySize, trustedProxy
|
|
21
|
+
function buildRpcRoutes(options, { bodySize, trustedProxy }, sensitive) {
|
|
22
22
|
const middleware = Layer.merge(subjectResolverLayer(), options.policy === "loopback"
|
|
23
23
|
? rpcRequestTracing(sensitive)
|
|
24
24
|
: Layer.mergeAll(authenticatedLayer(), maybeAuthenticatedLayer(), rpcRequestTracing(sensitive)));
|
|
@@ -39,12 +39,12 @@ function buildRpcRoutes(options, { bodySize, trustedProxy, nativeOrigins }, sens
|
|
|
39
39
|
};
|
|
40
40
|
const group = options.group;
|
|
41
41
|
const handler = yield* hostRpc(group, false, options.requestServices).pipe(Effect.provideService(RpcSerialization.RpcSerialization, httpWire));
|
|
42
|
-
const guarded = Effect.flatMap(UnixSocketRequest, (unix) => (unix ? handler : localRpcGuard(handler, trustedProxy
|
|
42
|
+
const guarded = Effect.flatMap(UnixSocketRequest, (unix) => (unix ? handler : localRpcGuard(handler, trustedProxy)));
|
|
43
43
|
const websocket = yield* hostRpc(group, true, options.requestServices).pipe(Effect.provideService(RpcSerialization.RpcSerialization, wire));
|
|
44
44
|
yield* router.add("OPTIONS", options.rpcPath ?? "/rpc", HttpServerResponse.text("Local same-origin requests only", {
|
|
45
45
|
status: HttpStatus.fromLiteral("Forbidden"),
|
|
46
46
|
}));
|
|
47
|
-
yield* router.add("GET", options.rpcPath ?? "/rpc", () => boundedRpcSocket(bodySize, options.rpcPath ?? "/rpc").pipe(Effect.flatMap((request) => socketRpc(websocket, options, trustedProxy
|
|
47
|
+
yield* router.add("GET", options.rpcPath ?? "/rpc", () => boundedRpcSocket(bodySize, options.rpcPath ?? "/rpc").pipe(Effect.flatMap((request) => socketRpc(websocket, options, trustedProxy).pipe(Effect.provideService(HttpServerRequest.HttpServerRequest, request), Effect.provideService(RpcSerialization.RpcSerialization, wire)))));
|
|
48
48
|
yield* router.add("POST", options.rpcPath ?? "/rpc", () => boundedRpcRequest().pipe(Effect.flatMap((request) => guarded.pipe(Effect.provideService(HttpIncomingMessage.MaxBodySize, ByteSize.bytes(bodySize)), Effect.provideService(HttpServerRequest.HttpServerRequest, request), Effect.provideService(RpcSerialization.RpcSerialization, wire), HttpEffect.withPreResponseHandler(rpcCacheControl)))));
|
|
49
49
|
})).pipe(Layer.provide(Layer.merge(middleware, servedHandlers(options.group, options.handlers, options.config?.buildVersion))), Layer.provide(RpcSerialization.layerNdjson));
|
|
50
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostRpcRoutes.js","sourceRoot":"","sources":["../src/hostRpcRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAA2B,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAE7E,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM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C,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACrH,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAC3C,CAAC;AACH,CAAC"}
|
package/dist/hostTransport.d.ts
CHANGED
|
@@ -8,13 +8,11 @@ interface Options {
|
|
|
8
8
|
readonly maxBodySize?: number;
|
|
9
9
|
readonly trustedProxy?: string;
|
|
10
10
|
};
|
|
11
|
-
readonly nativeOrigins?: readonly string[];
|
|
12
11
|
readonly policy?: "loopback" | undefined;
|
|
13
12
|
}
|
|
14
13
|
export declare const hostTransport: (options: Options) => Effect.Effect<{
|
|
15
14
|
bodySize: number;
|
|
16
15
|
host: string;
|
|
17
|
-
nativeOrigins: readonly string[];
|
|
18
16
|
trustedProxy: string | undefined;
|
|
19
17
|
}, Config.ConfigError | TrustedProxyRequired, never>;
|
|
20
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostTransport.d.ts","sourceRoot":"","sources":["../src/hostTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAA0B,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"hostTransport.d.ts","sourceRoot":"","sources":["../src/hostTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAA0B,MAAM,QAAQ,CAAC;AAGhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,UAAU,OAAO;IAChB,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;KAC/B,CAAC;IACF,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACzC;AACD,eAAO,MAAM,aAAa;;;;oDAwBxB,CAAC"}
|
package/dist/hostTransport.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Config, Effect, Option, Result, Schema } from "effect";
|
|
2
2
|
import * as NetAddress from "effect/net/NetAddress";
|
|
3
3
|
import { TrustedProxy } from "@shivaedev/identity/server/adapters/trustedProxy.ts";
|
|
4
|
-
import { NativeOrigins } from "#nativeClientOrigins.ts";
|
|
5
4
|
import { TrustedProxyRequired } from "#TrustedProxyRequired.ts";
|
|
6
5
|
export const hostTransport = Effect.fn("Platform.hostTransport")(function* (options) {
|
|
7
6
|
const maxBodySize = options.config?.maxBodySize ?? (yield* Config.Int("MAX_BODY_SIZE").pipe(Config.withDefault(1024 * 1024)));
|
|
@@ -22,7 +21,6 @@ export const hostTransport = Effect.fn("Platform.hostTransport")(function* (opti
|
|
|
22
21
|
if (!socketOnly && options.policy !== "loopback" && !loopback && trustedProxy === undefined) {
|
|
23
22
|
return yield* Effect.fail(new TrustedProxyRequired());
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
return { bodySize, host, nativeOrigins, trustedProxy };
|
|
24
|
+
return { bodySize, host, trustedProxy };
|
|
27
25
|
});
|
|
28
26
|
//# sourceMappingURL=hostTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostTransport.js","sourceRoot":"","sources":["../src/hostTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AACnF,OAAO,EAAE,
|
|
1
|
+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2
1
|
import { HttpRouter } from "effect/http";
|
|
3
|
-
export declare
|
|
4
|
-
export declare function nativeClientOrigins(origins: readonly string[], trustedProxy: string | undefined, auth?: boolean | "preflight", rpcPath?: HttpRouter.PathInput): import("effect/Layer").Layer<never, never, never>;
|
|
2
|
+
export declare function nativeClientOrigins(trustedProxy: string | undefined, route: "auth" | "rpc", rpcPath?: HttpRouter.PathInput): import("effect/Layer").Layer<never, never, never>;
|
|
5
3
|
//# sourceMappingURL=nativeClientOrigins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeClientOrigins.d.ts","sourceRoot":"","sources":["../src/nativeClientOrigins.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nativeClientOrigins.d.ts","sourceRoot":"","sources":["../src/nativeClientOrigins.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,UAAU,EAAyC,MAAM,aAAa,CAAC;AAKzG,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,GAAE,UAAU,CAAC,SAAkB,qDAsBlI"}
|
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
import { Effect, Option
|
|
1
|
+
import { Effect, Option } from "effect";
|
|
2
2
|
import { Headers, HttpMiddleware, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { localTransport } from "@shivaedev/identity/server/adapters/local.ts";
|
|
5
5
|
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
const url = new URL(origin);
|
|
11
|
-
const authority = url.origin === "null" ? `${url.protocol}//${url.host}` : url.origin;
|
|
12
|
-
return url.host !== "" && !origin.includes("*") && authority === origin;
|
|
13
|
-
})));
|
|
14
|
-
export function nativeClientOrigins(origins, trustedProxy, auth = false, rpcPath = "/rpc") {
|
|
6
|
+
export function nativeClientOrigins(trustedProxy, route, rpcPath = "/rpc") {
|
|
7
|
+
const auth = route === "auth";
|
|
15
8
|
const matchesPath = auth ? (path) => path === "/api/auth" || path.startsWith("/api/auth/") : (path) => path === rpcPath;
|
|
16
9
|
return HttpRouter.middleware((effect) => Effect.gen(function* () {
|
|
17
10
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
18
11
|
if (!matchesPath(request.url.split("?")[0] ?? "")) {
|
|
19
12
|
return yield* effect;
|
|
20
13
|
}
|
|
21
|
-
const policy = yield* Effect.serviceOption(SessionPolicy);
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
14
|
+
const policy = Option.getOrUndefined(yield* Effect.serviceOption(SessionPolicy));
|
|
15
|
+
const native = policy?.nativeOrigins ?? [];
|
|
16
|
+
const declared = policy?.origin.trustedOrigins ?? [];
|
|
17
|
+
const allowed = localTransport(trustedProxy, [...native, ...declared]);
|
|
18
|
+
const guarded = request.method === "OPTIONS" || (auth && policy?.nativeOrigins !== undefined);
|
|
19
|
+
if (guarded && !allowed(request)) {
|
|
25
20
|
return HttpServerResponse.text("Local same-origin requests only", {
|
|
26
21
|
status: HttpStatus.fromLiteral("Forbidden"),
|
|
27
22
|
});
|
|
28
23
|
}
|
|
29
|
-
return yield* withClientCors(effect,
|
|
24
|
+
return yield* withClientCors(effect, native, declared, auth);
|
|
30
25
|
})).layer;
|
|
31
26
|
}
|
|
32
27
|
const withClientCors = Effect.fnUntraced(function* (effect, nativeOrigins, declared, auth) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeClientOrigins.js","sourceRoot":"","sources":["../src/nativeClientOrigins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"nativeClientOrigins.js","sourceRoot":"","sources":["../src/nativeClientOrigins.ts"],"names":[],"m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AAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC5G,OAAO,KAAK,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC;QACjC,cAAc,EAAE,CAAC,eAAe,EAAE,cAAc,CAAC;QACjD,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACjD,cAAc,EAAE,CAAC,MAAM,CAAC;QACxB,WAAW,EAAE,YAAY;QACzB,cAAc,EAAE,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE;KACxD,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC,CAAC"}
|
package/dist/socketRpc.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
|
4
4
|
import type { HostPolicy } from "#hostOptions.ts";
|
|
5
5
|
export declare function socketRpc(handler: Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest | Scope.Scope>, policy: Extract<HostPolicy, {
|
|
6
6
|
readonly policy: "loopback";
|
|
7
|
-
}>, trustedProxy: string | undefined
|
|
8
|
-
export declare function socketRpc(handler: Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest | Scope.Scope>, policy: HostPolicy, trustedProxy: string | undefined
|
|
7
|
+
}>, trustedProxy: string | undefined): Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest | Scope.Scope>;
|
|
8
|
+
export declare function socketRpc(handler: Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest | Scope.Scope>, policy: HostPolicy, trustedProxy: string | undefined): Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest | Scope.Scope | SessionPolicy>;
|
|
9
9
|
//# sourceMappingURL=socketRpc.d.ts.map
|
package/dist/socketRpc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socketRpc.d.ts","sourceRoot":"","sources":["../src/socketRpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"socketRpc.d.ts","sourceRoot":"","sources":["../src/socketRpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAW,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAI7E,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAI5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,wBAAgB,SAAS,CACxB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,KAAK,CAAC,KAAK,CAAC,EACvH,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,EAC5D,YAAY,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;AAClH,wBAAgB,SAAS,CACxB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,KAAK,CAAC,KAAK,CAAC,EACvH,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC,CAAC"}
|
package/dist/socketRpc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
1
|
+
import { Effect, Option } from "effect";
|
|
2
2
|
import { Headers, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { isAuthUnavailable, isForbidden } from "@shivaedev/errors/taxonomy.ts";
|
|
@@ -8,9 +8,10 @@ import { resolveSession } from "@shivaedev/identity/server/session.ts";
|
|
|
8
8
|
import { makeSocketSession, SocketSession } from "@shivaedev/identity/server/socketSession.ts";
|
|
9
9
|
import { bearerSocketRpc } from "#bearerSocketRpc.ts";
|
|
10
10
|
import { UnixSocketRequest } from "#UnixSocketRequest.ts";
|
|
11
|
-
export function socketRpc(handler, policy, trustedProxy
|
|
11
|
+
export function socketRpc(handler, policy, trustedProxy) {
|
|
12
12
|
return Effect.gen(function* () {
|
|
13
13
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
14
|
+
const nativeOrigins = Option.getOrUndefined(yield* Effect.serviceOption(SessionPolicy))?.nativeOrigins;
|
|
14
15
|
if (!((yield* UnixSocketRequest) || localTransport(trustedProxy, nativeOrigins)(request))) {
|
|
15
16
|
return HttpServerResponse.text("Local same-origin requests only", { status: HttpStatus.fromLiteral("Forbidden") });
|
|
16
17
|
}
|
package/dist/socketRpc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socketRpc.js","sourceRoot":"","sources":["../src/socketRpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,E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
2
|
"name": "@shivaedev/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"description": "The Effect application host: HTTP and RPC serving, health, OTLP export, database and migrations, and development mode",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect"
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@shivaedev/changes": "0.14.1",
|
|
50
|
-
"@shivaedev/contract": "0.
|
|
50
|
+
"@shivaedev/contract": "0.58.0",
|
|
51
51
|
"@shivaedev/errors": "0.14.1",
|
|
52
52
|
"@shivaedev/http": "0.9.2",
|
|
53
|
-
"@shivaedev/identity": "0.
|
|
53
|
+
"@shivaedev/identity": "0.39.0",
|
|
54
54
|
"@shivaedev/local-postgres": "0.17.0",
|
|
55
55
|
"@shivaedev/sql": "0.54.0"
|
|
56
56
|
},
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"@effect/sql-pg": "4.1.4",
|
|
60
60
|
"@effect/vitest": "4.1.4",
|
|
61
61
|
"@shivaedev/access": "0.7.0",
|
|
62
|
-
"@shivaedev/admin": "0.29.
|
|
62
|
+
"@shivaedev/admin": "0.29.1",
|
|
63
63
|
"@shivaedev/jobs": "0.44.0",
|
|
64
|
-
"@shivaedev/quality": "0.83.
|
|
64
|
+
"@shivaedev/quality": "0.83.3",
|
|
65
65
|
"@shivaedev/rate-limit": "0.8.0",
|
|
66
66
|
"@shivaedev/service": "0.9.2",
|
|
67
|
-
"@shivaedev/test-kits": "0.16.
|
|
67
|
+
"@shivaedev/test-kits": "0.16.4",
|
|
68
68
|
"@shivaedev/test-sql": "0.26.0",
|
|
69
|
-
"@shivaedev/test-story": "0.52.
|
|
69
|
+
"@shivaedev/test-story": "0.52.4",
|
|
70
70
|
"@types/node": "24.19.2",
|
|
71
71
|
"better-auth": "1.7.23",
|
|
72
72
|
"effect": "4.1.4",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@effect/platform-node": "4.1.4",
|
|
79
79
|
"@effect/sql-pg": "4.1.4",
|
|
80
80
|
"@effect/vitest": "4.1.4",
|
|
81
|
-
"@shivaedev/admin": "0.29.
|
|
81
|
+
"@shivaedev/admin": "0.29.1",
|
|
82
82
|
"better-auth": "1.7.23",
|
|
83
83
|
"effect": "4.1.4"
|
|
84
84
|
},
|
package/src/appHostHttp.ts
CHANGED
|
@@ -46,7 +46,7 @@ export function appHostHttp<
|
|
|
46
46
|
Layer.unwrap(
|
|
47
47
|
Effect.gen(function* () {
|
|
48
48
|
const transport = yield* hostTransport(options);
|
|
49
|
-
const { bodySize, host, trustedProxy
|
|
49
|
+
const { bodySize, host, trustedProxy } = transport;
|
|
50
50
|
const routes = options.group === undefined ? Layer.empty : hostRpcRoutes(options, transport, sensitive);
|
|
51
51
|
const application = Layer.mergeAll(options.services ?? Layer.empty);
|
|
52
52
|
const sessions = Layer.mergeAll(Layer.empty, ...(options.sessions === undefined ? [] : [options.sessions]));
|
|
@@ -59,8 +59,8 @@ export function appHostHttp<
|
|
|
59
59
|
assets,
|
|
60
60
|
applicationRoutes,
|
|
61
61
|
).pipe(
|
|
62
|
-
Layer.provide(options.group === undefined ? Layer.empty : nativeClientOrigins(
|
|
63
|
-
Layer.provide(nativeClientOrigins(
|
|
62
|
+
Layer.provide(options.group === undefined ? Layer.empty : nativeClientOrigins(trustedProxy, "rpc", options.rpcPath)),
|
|
63
|
+
Layer.provide(nativeClientOrigins(trustedProxy, "auth")),
|
|
64
64
|
);
|
|
65
65
|
return Layer.unwrap(
|
|
66
66
|
HttpRouter.toHttpEffect(httpRoutes).pipe(
|
package/src/hostOptions.ts
CHANGED
|
@@ -32,7 +32,6 @@ export type HostCoreOptions<
|
|
|
32
32
|
readonly gracefulShutdownTimeout?: Duration.Input;
|
|
33
33
|
};
|
|
34
34
|
readonly requestServices?: Layer.Layer<TRequestServices, never, TRequestRequirements>;
|
|
35
|
-
readonly nativeOrigins?: readonly string[];
|
|
36
35
|
readonly rpcPath?: HttpRouter.PathInput;
|
|
37
36
|
} & (
|
|
38
37
|
| { readonly group: RpcGroup.RpcGroup<TRpcs>; readonly handlers: Layer.Layer<THandlers, THandlerError, THandlerRequirements> }
|
package/src/hostRpcRoutes.ts
CHANGED
|
@@ -67,7 +67,7 @@ export function hostRpcRoutes<TRpcs extends Rpc.Any, THandlers, TError, TRequire
|
|
|
67
67
|
|
|
68
68
|
function buildRpcRoutes<TRpcs extends Rpc.Any, THandlers, TError, TRequirements, TRequestServices = never, TRequestRequirements = never>(
|
|
69
69
|
options: RouteOptions<TRpcs, THandlers, TError, TRequirements, TRequestServices, TRequestRequirements>,
|
|
70
|
-
{ bodySize, trustedProxy
|
|
70
|
+
{ bodySize, trustedProxy }: Effect.Success<ReturnType<typeof hostTransport>>,
|
|
71
71
|
sensitive: Effect.Success<ReturnType<typeof schemaSensitiveKeys>>,
|
|
72
72
|
) {
|
|
73
73
|
const middleware = Layer.merge(
|
|
@@ -94,7 +94,7 @@ function buildRpcRoutes<TRpcs extends Rpc.Any, THandlers, TError, TRequirements,
|
|
|
94
94
|
};
|
|
95
95
|
const group = options.group;
|
|
96
96
|
const handler = yield* hostRpc(group, false, options.requestServices).pipe(Effect.provideService(RpcSerialization.RpcSerialization, httpWire));
|
|
97
|
-
const guarded = Effect.flatMap(UnixSocketRequest, (unix) => (unix ? handler : localRpcGuard(handler, trustedProxy
|
|
97
|
+
const guarded = Effect.flatMap(UnixSocketRequest, (unix) => (unix ? handler : localRpcGuard(handler, trustedProxy)));
|
|
98
98
|
const websocket = yield* hostRpc(group, true, options.requestServices).pipe(Effect.provideService(RpcSerialization.RpcSerialization, wire));
|
|
99
99
|
yield* router.add(
|
|
100
100
|
"OPTIONS",
|
|
@@ -106,7 +106,7 @@ function buildRpcRoutes<TRpcs extends Rpc.Any, THandlers, TError, TRequirements,
|
|
|
106
106
|
yield* router.add("GET", options.rpcPath ?? "/rpc", () =>
|
|
107
107
|
boundedRpcSocket(bodySize, options.rpcPath ?? "/rpc").pipe(
|
|
108
108
|
Effect.flatMap((request) =>
|
|
109
|
-
socketRpc(websocket, options, trustedProxy
|
|
109
|
+
socketRpc(websocket, options, trustedProxy).pipe(
|
|
110
110
|
Effect.provideService(HttpServerRequest.HttpServerRequest, request),
|
|
111
111
|
Effect.provideService(RpcSerialization.RpcSerialization, wire),
|
|
112
112
|
),
|
package/src/hostTransport.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Config, Effect, Option, Result, Schema } from "effect";
|
|
2
2
|
import * as NetAddress from "effect/net/NetAddress";
|
|
3
3
|
import { TrustedProxy } from "@shivaedev/identity/server/adapters/trustedProxy.ts";
|
|
4
|
-
import { NativeOrigins } from "#nativeClientOrigins.ts";
|
|
5
4
|
import { TrustedProxyRequired } from "#TrustedProxyRequired.ts";
|
|
6
5
|
|
|
7
6
|
interface Options {
|
|
@@ -12,7 +11,6 @@ interface Options {
|
|
|
12
11
|
readonly maxBodySize?: number;
|
|
13
12
|
readonly trustedProxy?: string;
|
|
14
13
|
};
|
|
15
|
-
readonly nativeOrigins?: readonly string[];
|
|
16
14
|
readonly policy?: "loopback" | undefined;
|
|
17
15
|
}
|
|
18
16
|
export const hostTransport = Effect.fn("Platform.hostTransport")(function* (options: Options) {
|
|
@@ -38,8 +36,5 @@ export const hostTransport = Effect.fn("Platform.hostTransport")(function* (opti
|
|
|
38
36
|
if (!socketOnly && options.policy !== "loopback" && !loopback && trustedProxy === undefined) {
|
|
39
37
|
return yield* Effect.fail(new TrustedProxyRequired());
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
Effect.mapError((cause) => new Config.ConfigError(cause)),
|
|
43
|
-
);
|
|
44
|
-
return { bodySize, host, nativeOrigins, trustedProxy };
|
|
39
|
+
return { bodySize, host, trustedProxy };
|
|
45
40
|
});
|
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
import { Effect, Option
|
|
1
|
+
import { Effect, Option } from "effect";
|
|
2
2
|
import { Headers, HttpMiddleware, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { localTransport } from "@shivaedev/identity/server/adapters/local.ts";
|
|
5
5
|
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
Schema.makeFilter((origin) => {
|
|
10
|
-
if (!URL.canParse(origin)) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
const url = new URL(origin);
|
|
14
|
-
const authority = url.origin === "null" ? `${url.protocol}//${url.host}` : url.origin;
|
|
15
|
-
return url.host !== "" && !origin.includes("*") && authority === origin;
|
|
16
|
-
}),
|
|
17
|
-
),
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export function nativeClientOrigins(
|
|
21
|
-
origins: readonly string[],
|
|
22
|
-
trustedProxy: string | undefined,
|
|
23
|
-
auth: boolean | "preflight" = false,
|
|
24
|
-
rpcPath: HttpRouter.PathInput = "/rpc",
|
|
25
|
-
) {
|
|
7
|
+
export function nativeClientOrigins(trustedProxy: string | undefined, route: "auth" | "rpc", rpcPath: HttpRouter.PathInput = "/rpc") {
|
|
8
|
+
const auth = route === "auth";
|
|
26
9
|
const matchesPath = auth ? (path: string) => path === "/api/auth" || path.startsWith("/api/auth/") : (path: string) => path === rpcPath;
|
|
27
10
|
return HttpRouter.middleware((effect) =>
|
|
28
11
|
Effect.gen(function* () {
|
|
@@ -30,15 +13,17 @@ export function nativeClientOrigins(
|
|
|
30
13
|
if (!matchesPath(request.url.split("?")[0] ?? "")) {
|
|
31
14
|
return yield* effect;
|
|
32
15
|
}
|
|
33
|
-
const policy = yield* Effect.serviceOption(SessionPolicy);
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
16
|
+
const policy = Option.getOrUndefined(yield* Effect.serviceOption(SessionPolicy));
|
|
17
|
+
const native = policy?.nativeOrigins ?? [];
|
|
18
|
+
const declared = policy?.origin.trustedOrigins ?? [];
|
|
19
|
+
const allowed = localTransport(trustedProxy, [...native, ...declared]);
|
|
20
|
+
const guarded = request.method === "OPTIONS" || (auth && policy?.nativeOrigins !== undefined);
|
|
21
|
+
if (guarded && !allowed(request)) {
|
|
37
22
|
return HttpServerResponse.text("Local same-origin requests only", {
|
|
38
23
|
status: HttpStatus.fromLiteral("Forbidden"),
|
|
39
24
|
});
|
|
40
25
|
}
|
|
41
|
-
return yield* withClientCors(effect,
|
|
26
|
+
return yield* withClientCors(effect, native, declared, auth);
|
|
42
27
|
}),
|
|
43
28
|
).layer;
|
|
44
29
|
}
|
package/src/socketRpc.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, type Scope } from "effect";
|
|
1
|
+
import { Effect, Option, type Scope } from "effect";
|
|
2
2
|
import { Headers, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { isAuthUnavailable, isForbidden } from "@shivaedev/errors/taxonomy.ts";
|
|
@@ -14,22 +14,20 @@ export function socketRpc(
|
|
|
14
14
|
handler: Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest | Scope.Scope>,
|
|
15
15
|
policy: Extract<HostPolicy, { readonly policy: "loopback" }>,
|
|
16
16
|
trustedProxy: string | undefined,
|
|
17
|
-
nativeOrigins: readonly string[],
|
|
18
17
|
): Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest | Scope.Scope>;
|
|
19
18
|
export function socketRpc(
|
|
20
19
|
handler: Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest | Scope.Scope>,
|
|
21
20
|
policy: HostPolicy,
|
|
22
21
|
trustedProxy: string | undefined,
|
|
23
|
-
nativeOrigins: readonly string[],
|
|
24
22
|
): Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest | Scope.Scope | SessionPolicy>;
|
|
25
23
|
export function socketRpc(
|
|
26
24
|
handler: Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest | Scope.Scope>,
|
|
27
25
|
policy: HostPolicy,
|
|
28
26
|
trustedProxy: string | undefined,
|
|
29
|
-
nativeOrigins: readonly string[],
|
|
30
27
|
) {
|
|
31
28
|
return Effect.gen(function* () {
|
|
32
29
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
30
|
+
const nativeOrigins = Option.getOrUndefined(yield* Effect.serviceOption(SessionPolicy))?.nativeOrigins;
|
|
33
31
|
if (!((yield* UnixSocketRequest) || localTransport(trustedProxy, nativeOrigins)(request))) {
|
|
34
32
|
return HttpServerResponse.text("Local same-origin requests only", { status: HttpStatus.fromLiteral("Forbidden") });
|
|
35
33
|
}
|