@shivaedev/server 0.9.1 → 0.9.3
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 +178 -0
- package/dist/RedactionPolicy.d.ts +5 -1
- package/dist/RedactionPolicy.d.ts.map +1 -1
- package/dist/RedactionPolicy.js +3 -0
- package/dist/RedactionPolicy.js.map +1 -1
- package/dist/hostChanges.js +1 -1
- package/dist/hostChanges.js.map +1 -1
- package/dist/hostRpcRoutes.d.ts.map +1 -1
- package/dist/hostRpcRoutes.js +4 -4
- package/dist/hostRpcRoutes.js.map +1 -1
- package/dist/redactingDiagnostics.d.ts +2 -1
- package/dist/redactingDiagnostics.d.ts.map +1 -1
- package/dist/redactingDiagnostics.js +15 -3
- package/dist/redactingDiagnostics.js.map +1 -1
- package/dist/redactingRpcSerialization.d.ts +1 -1
- package/dist/redactingRpcSerialization.d.ts.map +1 -1
- package/dist/redactingRpcSerialization.js +3 -3
- package/dist/redactingRpcSerialization.js.map +1 -1
- package/dist/redactingTracer.d.ts +2 -2
- package/dist/redactingTracer.d.ts.map +1 -1
- package/dist/redactingTracer.js +17 -3
- package/dist/redactingTracer.js.map +1 -1
- package/dist/rpcRequestTracing.d.ts +5 -0
- package/dist/rpcRequestTracing.d.ts.map +1 -0
- package/dist/rpcRequestTracing.js +8 -0
- package/dist/rpcRequestTracing.js.map +1 -0
- package/dist/safeOtlpSerialization.d.ts.map +1 -1
- package/dist/safeOtlpSerialization.js +20 -15
- package/dist/safeOtlpSerialization.js.map +1 -1
- package/dist/schemaSensitiveAst.d.ts +7 -0
- package/dist/schemaSensitiveAst.d.ts.map +1 -0
- package/dist/schemaSensitiveAst.js +102 -0
- package/dist/schemaSensitiveAst.js.map +1 -0
- package/dist/schemaSensitiveKeys.d.ts +1 -0
- package/dist/schemaSensitiveKeys.d.ts.map +1 -1
- package/dist/schemaSensitiveKeys.js +27 -123
- package/dist/schemaSensitiveKeys.js.map +1 -1
- package/package.json +11 -9
- package/src/RedactionPolicy.ts +7 -1
- package/src/hostChanges.ts +4 -2
- package/src/hostRpcRoutes.ts +4 -4
- package/src/redactingDiagnostics.ts +15 -3
- package/src/redactingRpcSerialization.ts +3 -2
- package/src/redactingTracer.ts +18 -4
- package/src/rpcRequestTracing.ts +12 -0
- package/src/safeOtlpSerialization.ts +20 -15
- package/src/schemaSensitiveAst.ts +106 -0
- package/src/schemaSensitiveKeys.ts +28 -127
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.9.3 - 2026-10-31
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Include `CHANGELOG.md` in published package contents so release notes are available in `node_modules`.
|
|
8
|
+
- Release checks reject published package `files` lists that omit `CHANGELOG.md`, naming the package and how to include it.
|
|
9
|
+
- Server RPC failures, request diagnostics and traces use the sensitive keys from their own RPC schemas, so registering another RPC cannot redact their public failure tags or messages.
|
|
10
|
+
- Admin Jobs schemas mark job payload and failure-detail containers sensitive without marking generic `_tag` or `message` fields sensitive.
|
|
11
|
+
- End hosted live subscriptions with `Unauthorized` when the original session is signed out, revoked or expired, whether detected during a change hint or periodic revalidation. Keep `QueryReadDenied` for a signed-in viewer whose query policy refuses the read.
|
|
12
|
+
- Batch shared socket session lookups with an Effect scheduler yield so advancing `TestClock` past `streamRevalidationInterval` completes revalidation without another clock advance.
|
|
13
|
+
- Preserve typed session-provider failures during hint-time authorization instead of reporting them as read-policy refusals.
|
|
14
|
+
|
|
15
|
+
## 0.9.2 - 2026-10-30
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Release with updated workspace dependencies.
|
|
20
|
+
|
|
21
|
+
## 0.9.1 - 2026-10-30
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Release with updated workspace dependencies.
|
|
26
|
+
|
|
27
|
+
## 0.9.0 - 2026-10-30
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- Queries can opt into `live: "rerun-and-compare"`. Hosted subscriptions rerun the authorized query as the subscribed viewer, hash its JSON-schema-encoded result with SHA-256, and push a typed `Result` only when it changes. Bound queries consume those results without a client refetch. Other queries keep hint-and-refetch delivery.
|
|
32
|
+
- Rerun subscriptions end with `QueryReadDenied` when access is denied. The host registers change listeners before its initial result read, and reconciliation reruns the query through the same read policy.
|
|
33
|
+
|
|
34
|
+
### Breaking
|
|
35
|
+
|
|
36
|
+
- `@shivaedev/contract`'s `ChangesClient` transport helper now covers result messages and erases query-specific stream failures. Consumers using that helper to read changes must use their contract's native AtomRpc client type instead; derive message and failure types with `Rpc.SuccessChunk` and `Rpc.ErrorExit` of the contract's `$changes` RPC. Contract-derived bound query types remain specific to their query.
|
|
37
|
+
|
|
38
|
+
## 0.8.0 - 2026-10-30
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- Live reads and change subscriptions preserve policy failures instead of reporting read denial. Generated starter apps report notes database connection failures as `ServiceUnavailable` during the owner's live read.
|
|
43
|
+
|
|
44
|
+
### Breaking
|
|
45
|
+
|
|
46
|
+
- Query read policies declare their error and service channels with `QueryReadPolicy<Payload, E, R>`. Declare policy errors in the query's `rejections` and provide policy services when building its handler Layer. Custom subscription adapters call `querySubscription(rpc, references, viewer)` instead of resolving requests themselves. Use the native RPC type when calling `authorizeReads` or `resolveChanges` so their inferred channels include policy requirements and errors. The generated change stream includes the queries' declared rejections and service requirements; consumers handling that stream must handle those errors too.
|
|
47
|
+
- Admin pages install their permission's read policy for every query, preserving additional query restrictions. Remove repeated page-grant policies from individual queries and supply the page's permission middleware with the handler Layers.
|
|
48
|
+
|
|
49
|
+
## 0.7.0 - 2026-10-30
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
|
|
53
|
+
- Identity exposes a socket-scoped session coordinator for hosts to share session rechecks within a batch and drive stream revalidation from one timer.
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
|
|
57
|
+
- Hosted live subscriptions on one socket share hint-time session lookups and periodic session revalidation while retaining per-query read-policy checks and typed revocation failures.
|
|
58
|
+
|
|
59
|
+
## 0.6.1 - 2026-10-30
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
- Release with updated workspace dependencies.
|
|
64
|
+
|
|
65
|
+
## 0.6.0 - 2026-10-30
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
|
|
69
|
+
- `@shivaedev/server`: Configure a direct or session-mode change listener with `config.listenDatabaseUrl` or `LISTEN_DATABASE_URL`, falling back to the application connection when unset.
|
|
70
|
+
- `@shivaedev/sql`: Supply `listenerClient` separately from the writing `client` to `postgresChanges`; set `connectionSetting` to identify that connection in diagnostics.
|
|
71
|
+
- `@shivaedev/sql/postgresLayer.ts` provides `postgresLayer(url, options)` with one native `PgPool` shared by `PgClient` and `SqlClient`. Reserved connections and client queries share `maxConnections`, and Layer shutdown waits for every socket to close.
|
|
72
|
+
- `appDatabase` and database-backed `appHost` expose the application's native `PgPool` service for packages that need reserved PostgreSQL connections.
|
|
73
|
+
|
|
74
|
+
### Fixed
|
|
75
|
+
|
|
76
|
+
- A denied per-hint session or query policy recheck ends the hosted live subscription with `QueryReadDenied` instead of silently dropping the hint. Custom consumers must handle this declared failure; automatic bound queries rerun their authorized read so the screen can show the denial.
|
|
77
|
+
- Retry worker-release heartbeat and poll failures on a bounded schedule, log their causes, and close the worker scope with the original cause when recovery fails. Heartbeats continue while jobs drain after a connection blip.
|
|
78
|
+
- Log change-listener loss and reconnect causes, and bound listener sub-scope cleanup without rewriting scope finalizers.
|
|
79
|
+
- Fail application database startup when its first PostgreSQL LISTEN or heartbeat fails, instead of waiting indefinitely.
|
|
80
|
+
- SQL decodes migration ledger, release ownership and change-coverage rows before using them. Malformed rows fail with `SchemaError` instead of being treated as current, pending or a different owner.
|
|
81
|
+
- SQL generates worker identities and change-listener heartbeat tokens through Effect's `Random` service.
|
|
82
|
+
|
|
83
|
+
### Breaking
|
|
84
|
+
|
|
85
|
+
- Listener startup deadlines now fail with `PostgresListenerError`, naming the connection setting, instead of `SqlError`. Consumers handling startup failures must also handle `PostgresListenerError` from `@shivaedev/sql/PostgresListenerError.ts`. Hosts using transaction-pooled application URLs must set `LISTEN_DATABASE_URL` or `config.listenDatabaseUrl` to a direct or session-mode connection to the same database. Native SQL startup failures still use `SqlError`.
|
|
86
|
+
- Server's PostgreSQL construction and address helpers move to sql. Consumers of `@shivaedev/server/adapters/postgresClient.ts` must compose `postgresLayer` from `@shivaedev/sql/postgresLayer.ts` and read the native `PgPool` or `PgClient` service instead. Address-only consumers import `databaseAddress` from `@shivaedev/sql/databaseAddress.ts` instead of `@shivaedev/server/databaseAddress.ts`.
|
|
87
|
+
- `postgresChanges` and `listenForChanges` now expose `SqlError` during acquisition. Consumers that required an infallible Layer or Effect must handle or propagate this error. `heartbeatTimeout` bounds the first LISTEN acquisition and its first heartbeat; retry startup at the application boundary if desired. Established listeners continue to reconnect.
|
|
88
|
+
- Schema component failures now reach SQL migration and readiness callers, server startup and test-sql migration helpers with their original error, tag and cause, and log the component name. Handle the component's own error instead of a wrapping `MigrationError` with kind `Failed`. When annotating migration options with fallible components, supply their error type as the second generic parameter; the default describes components that cannot fail.
|
|
89
|
+
- Declare `WorkerRelease` through `defineService`. Consumers using the old class as a type must use `Context.Service.Identifier<typeof WorkerRelease>`; yielding the service and providing its value stay the same.
|
|
90
|
+
|
|
91
|
+
## 0.5.0 - 2026-10-30
|
|
92
|
+
|
|
93
|
+
### Changed
|
|
94
|
+
|
|
95
|
+
- Require Effect 4.0.6 and align the Effect companion package peers and generated starter catalog to the same exact release. Install the 4.0.6 Effect stack together.
|
|
96
|
+
- The starter's Railway deployment supplies `TRUSTED_PROXY=100.64.0.0/10` and `AUTH_CLIENT_IP_HEADER=x-real-ip` through its shared proxy configuration. Generated deployment docs explain the automatic Railway settings and when a host refuses to boot.
|
|
97
|
+
|
|
98
|
+
### Fixed
|
|
99
|
+
|
|
100
|
+
- Register hosted RPC cache-control handling through Effect 4.0.6's request-scoped pre-response API so responses keep `private, no-store`.
|
|
101
|
+
- Accept native RPC's `application/x-ndjson` media type while preserving `application/ndjson` callers at the transport guard.
|
|
102
|
+
- Keep subscriptions open after their HTTP request body completes; closing the socket still cancels them.
|
|
103
|
+
|
|
104
|
+
### Breaking
|
|
105
|
+
|
|
106
|
+
- `@shivaedev/server` refuses to start a session host bound to a non-loopback address without proxy trust, with a typed `TrustedProxyRequired` error naming the missing setting. Set `TRUSTED_PROXY` to your proxy's peer IP addresses or CIDR ranges, set `config.trustedProxy`, or deploy with the starter's Railway configuration. Local loopback hosts keep working without it.
|
|
107
|
+
|
|
108
|
+
## 0.4.0 - 2026-10-29
|
|
109
|
+
|
|
110
|
+
### Added
|
|
111
|
+
|
|
112
|
+
- Forwarding proxy fixtures relay WebSocket upgrades, including the same origin and trusted proxy headers as HTTP requests. Existing proxy URLs also work for socket clients.
|
|
113
|
+
|
|
114
|
+
### Fixed
|
|
115
|
+
|
|
116
|
+
- Revoked bearer and cookie change subscriptions end with typed `Unauthorized` from session middleware, without racing a host-initiated socket close. Later protected calls on the shared socket reject the revoked session.
|
|
117
|
+
|
|
118
|
+
### Breaking
|
|
119
|
+
|
|
120
|
+
- Contract clients use Effect RPC over a shared WebSocket by default. Replace `httpClient`, `transformClient` and `serialization` client options with a native `protocol` Layer for custom transports. Node clients can supply upgrade `headers` and a `webSocketConstructor` Layer; browsers use their session cookie automatically.
|
|
121
|
+
- Mounting a bound query subscribes before its first authorized read; unmounting releases its subscription. Use `live: false` when binding an ordinary client without subscriptions. Query preparation alone no longer opens a change stream.
|
|
122
|
+
- Hosts serve live subscriptions on the WebSocket upgrade at the RPC path. Move HTTP `$changes` consumers to Effect RPC's socket protocol; the POST route serves ordinary RPC only. Configure development proxies to forward WebSocket upgrades.
|
|
123
|
+
- React session boundaries bind shared sockets to the identified session, so replacing an account upgrades with its current cookie. They also ask the auth owner to recheck when the live socket closes. Keep `recheck` safe to call after a network interruption; the auth owner still decides whether the session ends.
|
|
124
|
+
|
|
125
|
+
## 0.3.1 - 2026-10-29
|
|
126
|
+
|
|
127
|
+
### Fixed
|
|
128
|
+
|
|
129
|
+
- The application host constructs services, handlers and routes before listening, so startup connections are refused until requests can be answered.
|
|
130
|
+
- Server and HTTP modules import Node platform modules directly to avoid loading Redis during startup.
|
|
131
|
+
- Generated apps import Node platform modules directly, and deployment stories allow enough time for their sequential cold processes without a fixed timeout on each startup health probe.
|
|
132
|
+
|
|
133
|
+
## 0.3.0 - 2026-10-28
|
|
134
|
+
|
|
135
|
+
### Added
|
|
136
|
+
|
|
137
|
+
- Application HTTP routes registered through `appHost.routes` can use app services, with route construction errors and missing dependencies retained in the host's types. Generated apps register HTTP routes and static assets through this option.
|
|
138
|
+
- Application routes can answer foreign-origin preflights through native `HttpMiddleware.cors`. Host origin restrictions cover the configured RPC path and `/api/auth/*`, including `/api/auth`; other foreign origins still receive 403 there.
|
|
139
|
+
- Declare collection policies beside module contracts with `ModuleReadPolicies` and combine them with `mergeReadPolicies`. Unclaimed collections are denied. Each policy receives the request's optional viewer.
|
|
140
|
+
- The application host accepts a merged `readPolicy` and checks queries and live hints inside native session middleware, using its resolved identity without another session lookup. Policies can use application services and return `Forbidden` or `AuthUnavailable`.
|
|
141
|
+
- Query authorization and live-hint filtering check keys concurrently so native `Effect.request` resolvers can batch membership checks. Plain Effect policies remain supported.
|
|
142
|
+
- The application host provides Effect's native Crypto service during preflight and deferred construction as well as in application handlers, so commands can generate secure invite codes without ambient randomness.
|
|
143
|
+
- Story kits provide native TestCrypto with a fresh seed of 0 for each story, making generated invite codes reproducible. The application’s @effect/platform-node peer supplies its digest implementation.
|
|
144
|
+
- Ambient-randomness findings name Effect's Crypto service for secure values and Random for non-secure values.
|
|
145
|
+
|
|
146
|
+
### Fixed
|
|
147
|
+
|
|
148
|
+
- Enforce declared query read policies at the hosted RPC handler boundary, including contracts without identity middleware, whose viewer is anonymous. Query RPC error schemas include `QueryReadDenied` so native clients receive typed refusals before handlers run.
|
|
149
|
+
- Keep collection methods and untyped schema internals from making data parameters appear to carry callable services. Direct service implementations, nested dependency fields and service arrays remain subject to `effect/service-parameters`.
|
|
150
|
+
|
|
151
|
+
### Breaking
|
|
152
|
+
|
|
153
|
+
- Move key imports from `@shivaedev/contract/keys.ts` to `@shivaedev/changes/keys.ts`. Declare bucket fields with `collection(name, idSchema, fields)` and publish affected buckets alongside record keys.
|
|
154
|
+
- Replace collection policy maps, `mergeReadPolicies`, `ReadPolicy` and `ReadPolicyMemoWindow` with each query's `readPolicy(payload, viewer)`. Declare the same query's live scope with `reads(payload, viewer)`. Bound query atoms and subscriptions refuse missing policies with a declaration error; one-off query `run` calls remain available. Denied queries refuse the entire subscription. Server adapters replace `QueryReads` and `ChangesReads` with `QueryDefinition` and `ChangesQueries`. Custom middleware calls `authorizeReads(effect, request, viewer)` and declares `MissingReadPolicy` and `QueryReadDenied` errors.
|
|
155
|
+
- Custom subscription adapters yield `ChangesQueries.resolve(references)`, call `querySubscription(requests, viewer)` and pass the authorized result to `makeLiveServer.subscribe(subscription, context)`. Metadata values expose `QueryDefinition.definition` and `CommandInvalidation.invalidates` instead of bare definitions and callbacks. Yield the Effect returned by `queryKeys(queries, references)` when projecting keys for a custom stream. `resolveChanges` supplies the authorized subscription in hosted applications. Changed hints can carry query positions so bindings can rerun session-scoped reads without deriving session scopes in the browser.
|
|
156
|
+
- Remove `appHost`'s `readPolicy` option and module policy registration. Session and permission middleware apply query policies using the current session viewer. Handle the new typed policy errors in native clients, including `QueryReadDenied` on query RPCs without identity middleware; widen explicit query error annotations accordingly.
|
|
157
|
+
- Replace `sessionCommandChanges` with `commandChanges` for custom session middleware. Command invalidation callbacks can receive the session viewer as their third argument. Announce viewer buckets there; background writers must explicitly publish those bucket keys after commit.
|
|
158
|
+
- Built-in admin queries declare their permission policies alongside their schemas and read scopes. Consumers keep supplying the existing session and permission middleware layers.
|
|
159
|
+
- Local Work Board and Fleet queries declare their existing loopback read access explicitly so their generated live subscriptions remain available.
|
|
160
|
+
- `authorizeReads` now takes `(effect, request, policy, viewer, denied)`, and policies take `(key, viewer)`. Pass `Option.some(resolvedIdentity)` or `Option.none()` before the denial effect. Existing unary policy functions may ignore the new viewer argument. Apps using `appHost` can replace custom read middleware with its `readPolicy` option and merge their modules' policy maps.
|
|
161
|
+
|
|
162
|
+
## 0.2.0 - 2026-10-27
|
|
163
|
+
|
|
164
|
+
### Added
|
|
165
|
+
|
|
166
|
+
- Session hosts bound to a non-loopback address without proxy trust warn at startup to configure `TRUSTED_PROXY` or `config.trustedProxy` before forwarding RPC requests.
|
|
167
|
+
|
|
168
|
+
### Fixed
|
|
169
|
+
|
|
170
|
+
- Development auth accepts both `localhost` and `127.0.0.1` over HTTP on any port when `PUBLIC_URL` is unset. Explicit `baseURL` and `trustedOrigins` options replace those defaults.
|
|
171
|
+
- Auth rate limiting uses the connection peer address without a trusted proxy, separating client buckets and avoiding Better Auth's missing-client-IP warning. Trusted forwarding still takes precedence, and untrusted forwarding headers are ignored.
|
|
172
|
+
- Supply the host's body-size limit to application routes, so bounded body readers enforce the same limit as RPC.
|
|
173
|
+
|
|
174
|
+
## 0.1.0 - 2026-10-27
|
|
175
|
+
|
|
176
|
+
### Added
|
|
177
|
+
|
|
178
|
+
- First release of `@shivaedev/server`, the application host extracted from `@shivaedev/platform`: `appHost`, the database layer and migrations, health, OTLP export, the redacting tracer and RPC serialization, development mode, the Promise runtime (`runtime/`) and Node subscription signals (`node-http/`). Modules sit at the package root, so `@shivaedev/platform/server/appHost.ts` becomes `@shivaedev/server/appHost.ts`. The `AppChanges` and `RedactionPolicy` service ids now name the package.
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Context } from "effect";
|
|
2
2
|
import { type SensitiveKey } from "@shivaedev/errors/sensitive.ts";
|
|
3
|
-
export
|
|
3
|
+
export interface HostRedactionPolicy extends SensitiveKey {
|
|
4
|
+
readonly forRpc?: (tag: string | undefined) => SensitiveKey;
|
|
5
|
+
}
|
|
6
|
+
export declare function redactionForRpc(policy: HostRedactionPolicy, tag: unknown): SensitiveKey;
|
|
7
|
+
export declare const RedactionPolicy: Context.Reference<HostRedactionPolicy>;
|
|
4
8
|
//# sourceMappingURL=RedactionPolicy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedactionPolicy.d.ts","sourceRoot":"","sources":["../src/RedactionPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnF,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"RedactionPolicy.d.ts","sourceRoot":"","sources":["../src/RedactionPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnF,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,KAAK,YAAY,CAAC;CAC5D;AACD,wBAAgB,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,GAAG,EAAE,OAAO,GAAG,YAAY,CAEvF;AACD,eAAO,MAAM,eAAe,wCAAsH,CAAC"}
|
package/dist/RedactionPolicy.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Context } from "effect";
|
|
2
2
|
import { isSensitiveKey } from "@shivaedev/errors/sensitive.ts";
|
|
3
|
+
export function redactionForRpc(policy, tag) {
|
|
4
|
+
return policy.forRpc?.(typeof tag === "string" ? tag : undefined) ?? policy;
|
|
5
|
+
}
|
|
3
6
|
export const RedactionPolicy = Context.Reference("@shivaedev/server/RedactionPolicy", { defaultValue: () => isSensitiveKey });
|
|
4
7
|
//# sourceMappingURL=RedactionPolicy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedactionPolicy.js","sourceRoot":"","sources":["../src/RedactionPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,cAAc,EAAqB,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"RedactionPolicy.js","sourceRoot":"","sources":["../src/RedactionPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,cAAc,EAAqB,MAAM,gCAAgC,CAAC;AAKnF,MAAM,UAAU,eAAe,CAAC,MAA2B,EAAE,GAAY;IACxE,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC;AAC7E,CAAC;AACD,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,SAAS,CAAsB,mCAAmC,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC"}
|
package/dist/hostChanges.js
CHANGED
|
@@ -47,7 +47,7 @@ function authorizeSession(sessions, tag, viewer, policy) {
|
|
|
47
47
|
if (sessions === undefined) {
|
|
48
48
|
return policy;
|
|
49
49
|
}
|
|
50
|
-
return recheckSession(sessions, Headers.empty, tag).pipe(Effect.map((current) => Option.isNone(viewer) || (Option.isSome(current) && current.value.user.id === viewer.value.id)), Effect.
|
|
50
|
+
return recheckSession(sessions, Headers.empty, tag).pipe(Effect.map((current) => Option.isNone(viewer) || (Option.isSome(current) && current.value.user.id === viewer.value.id)), Effect.flatMap((allowed) => allowed ? policy : Effect.fail(new Unauthorized({ message: "Authentication required" }))));
|
|
51
51
|
}
|
|
52
52
|
function sessionRevoked(sessions, tag, id) {
|
|
53
53
|
return Effect.gen(function* () {
|
package/dist/hostChanges.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostChanges.js","sourceRoot":"","sources":["../src/hostChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAe,MAAM,mCAAmC,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAEhF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,WAAW,CAC1B,KAA2B,EAC3B,cAAiC,EACjC,QAAkC;IAElC,OAAO,KAAK,CAAC,aAAa,CACzB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAC5D,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAS,CAAC;QAChD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC5C,SAAS,SAAS,CAAC,GAAY,EAAE,OAAkC,EAAE,OAAsD;YAC1H,OAAO,MAAM,CAAC,MAAM,CACnB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;gBACnB,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;gBACtE,MAAM,MA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AC,CAAC,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC,CAAC;QACxE,CAAC;IACF,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,0BAA0B,IAAI,YAAY,CAAC,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostRpcRoutes.d.ts","sourceRoot":"","sources":["../src/hostRpcRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAmC,UAAU,EAAyC,MAAM,aAAa,CAAC;AAEjH,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAqC,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAE3G,OAAO,EAA+C,KAAK,YAAY,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"hostRpcRoutes.d.ts","sourceRoot":"","sources":["../src/hostRpcRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAmC,UAAU,EAAyC,MAAM,aAAa,CAAC;AAEjH,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAqC,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAE3G,OAAO,EAA+C,KAAK,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACvH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,wBAAgB,aAAa,CAAC,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,SAAS,YAAY,EACnH,OAAO,EAAE;IACR,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC;CACxC,GAAG,UAAU,CAAC,QAAQ,CAAC,EACxB,cAAc,EAAE,OAAO,UAAU,EACjC,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,EAC3F,SAAS,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC;;;;;;;;0CA6CjD"}
|
package/dist/hostRpcRoutes.js
CHANGED
|
@@ -4,18 +4,18 @@ import * as HttpStatus from "effect/http/HttpStatus";
|
|
|
4
4
|
import { RpcSerialization } from "effect/rpc";
|
|
5
5
|
import { localRpcGuard } from "@shivaedev/identity/server/local.ts";
|
|
6
6
|
import { authenticatedLayer, maybeAuthenticatedLayer } from "@shivaedev/identity/server/session.ts";
|
|
7
|
-
import { requestTracingLayer } from "@shivaedev/identity/server/tracing.ts";
|
|
8
7
|
import { boundedRpcRequest } from "#boundedRpcRequest.ts";
|
|
9
8
|
import { hostChanges } from "#hostChanges.ts";
|
|
10
9
|
import { hostRpc, rpcCacheControl } from "#hostRpc.ts";
|
|
11
10
|
import { redactingRpcSerialization } from "#redactingRpcSerialization.ts";
|
|
11
|
+
import { rpcRequestTracing } from "#rpcRequestTracing.ts";
|
|
12
12
|
import { socketRpc } from "#socketRpc.ts";
|
|
13
13
|
export function hostRpcRoutes(options, changesService, { bodySize, trustedProxy, nativeOrigins }, sensitive) {
|
|
14
14
|
const middleware = options.policy === "loopback"
|
|
15
|
-
?
|
|
16
|
-
: Layer.mergeAll(authenticatedLayer(options.sessions), maybeAuthenticatedLayer(options.sessions),
|
|
15
|
+
? rpcRequestTracing(sensitive)
|
|
16
|
+
: Layer.mergeAll(authenticatedLayer(options.sessions), maybeAuthenticatedLayer(options.sessions), rpcRequestTracing(sensitive));
|
|
17
17
|
return HttpRouter.use((router) => Effect.gen(function* () {
|
|
18
|
-
const wire = redactingRpcSerialization(yield* RpcSerialization.RpcSerialization, sensitive, sensitive.maskFailure);
|
|
18
|
+
const wire = redactingRpcSerialization(yield* RpcSerialization.RpcSerialization, sensitive, sensitive.maskFailure, sensitive.forRpc);
|
|
19
19
|
const httpGroup = options.group.omit(...[...options.group.requests.keys()].filter((tag) => tag.endsWith(".$changes")));
|
|
20
20
|
const handler = yield* hostRpc(httpGroup).pipe(Effect.provideService(RpcSerialization.RpcSerialization, wire));
|
|
21
21
|
const guarded = localRpcGuard(handler, trustedProxy, nativeOrigins);
|
|
@@ -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;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAqB,MAAM,uCAAuC,CAAC;
|
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AY,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAC/H,CAAC;QACF,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,IAAI,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAChE,OAAO,CAAC,IAAI,CACX,MAAM,CAAC,cAAc,CAAC,mBAAmB,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAChF,MAAM,CAAC,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,EACtF,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAC9D,UAAU,CAAC,sBAAsB,CAAC,eAAe,CAAC,CAClD,CACD,CAAC;IACH,CAAC,CAAC,CACF,CAAC,IAAI,CACL,KAAK,CAAC,OAAO,CACZ,KAAK,CAAC,KAAK,CACV,UAAU,EACV,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC5G,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CACpC,CACD,CACD,EACD,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAC3C,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
2
|
import type { SensitiveKey } from "@shivaedev/errors/sensitive.ts";
|
|
3
|
+
import { type HostRedactionPolicy } from "#RedactionPolicy.ts";
|
|
3
4
|
export declare function redactRecord(values: Readonly<Record<string, unknown>>, sensitive: SensitiveKey): Record<string, unknown>;
|
|
4
|
-
export declare function redactingDiagnostics(
|
|
5
|
+
export declare function redactingDiagnostics(policy: HostRedactionPolicy): Layer.Layer<never, never, never>;
|
|
5
6
|
//# sourceMappingURL=redactingDiagnostics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redactingDiagnostics.d.ts","sourceRoot":"","sources":["../src/redactingDiagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,EAAsB,MAAM,QAAQ,CAAC;AAGnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"redactingDiagnostics.d.ts","sourceRoot":"","sources":["../src/redactingDiagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,EAAsB,MAAM,QAAQ,CAAC;AAGnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,KAAK,mBAAmB,EAAmB,MAAM,qBAAqB,CAAC;AAEhF,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAExH;AAUD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,oCA0B/D"}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import { Context, Effect, ErrorReporter, Layer, Logger, References } from "effect";
|
|
2
2
|
import { redact } from "@shivaedev/errors/redact.ts";
|
|
3
3
|
import { redactDiagnosticCause, redactingErrorReporter } from "@shivaedev/errors/redactCause.ts";
|
|
4
|
+
import { redactionForRpc } from "#RedactionPolicy.ts";
|
|
4
5
|
export function redactRecord(values, sensitive) {
|
|
5
6
|
return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, sensitive(key) ? "<redacted>" : redact(value, sensitive)]));
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
function requestErrorReporter(reporter, policy) {
|
|
9
|
+
return {
|
|
10
|
+
[ErrorReporter.TypeId]: ErrorReporter.TypeId,
|
|
11
|
+
report: (options) => {
|
|
12
|
+
const sensitive = redactionForRpc(policy, options.fiber.getRef(References.CurrentLogAnnotations)["rpc.method"]);
|
|
13
|
+
return redactingErrorReporter(reporter, sensitive).report(options);
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function redactingDiagnostics(policy) {
|
|
8
18
|
return Layer.effectContext(Effect.gen(function* () {
|
|
9
19
|
const loggers = yield* Logger.CurrentLoggers;
|
|
10
20
|
const reporters = yield* ErrorReporter.CurrentErrorReporters;
|
|
11
21
|
const safeLoggers = new Set([...loggers].map((logger) => Logger.make((options) => {
|
|
12
22
|
const context = options.fiber.context;
|
|
13
|
-
const
|
|
23
|
+
const raw = options.fiber.getRef(References.CurrentLogAnnotations);
|
|
24
|
+
const sensitive = redactionForRpc(policy, raw["rpc.method"]);
|
|
25
|
+
const annotations = redactRecord(raw, sensitive);
|
|
14
26
|
options.fiber.setContext(Context.add(context, References.CurrentLogAnnotations, annotations));
|
|
15
27
|
try {
|
|
16
28
|
return logger.log({ ...options, cause: redactDiagnosticCause(options.cause, sensitive), message: redact(options.message, sensitive) });
|
|
@@ -19,7 +31,7 @@ export function redactingDiagnostics(sensitive) {
|
|
|
19
31
|
options.fiber.setContext(context);
|
|
20
32
|
}
|
|
21
33
|
})));
|
|
22
|
-
return Context.make(Logger.CurrentLoggers, safeLoggers).pipe(Context.add(ErrorReporter.CurrentErrorReporters, new Set([...reporters].map((reporter) =>
|
|
34
|
+
return Context.make(Logger.CurrentLoggers, safeLoggers).pipe(Context.add(ErrorReporter.CurrentErrorReporters, new Set([...reporters].map((reporter) => requestErrorReporter(reporter, policy)))));
|
|
23
35
|
}));
|
|
24
36
|
}
|
|
25
37
|
//# sourceMappingURL=redactingDiagnostics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redactingDiagnostics.js","sourceRoot":"","sources":["../src/redactingDiagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"redactingDiagnostics.js","sourceRoot":"","sources":["../src/redactingDiagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAEjG,OAAO,EAA4B,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEhF,MAAM,UAAU,YAAY,CAAC,MAAyC,EAAE,SAAuB;IAC9F,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1I,CAAC;AACD,SAAS,oBAAoB,CAAC,QAAqC,EAAE,MAA2B;IAC/F,OAAO;QACN,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM;QAC5C,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;YACnB,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,CA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,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;YACxI,CAAC;oBAAS,CAAC;gBACV,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YACnC,CAAC;QACF,CAAC,CAAC,CACF,CACD,CAAC;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,IAAI,CAC3D,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,qBAAqB,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CACnI,CAAC;IACH,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RpcSerialization } from "effect/rpc";
|
|
2
2
|
import { type SensitiveKey } from "@shivaedev/errors/sensitive.ts";
|
|
3
|
-
export declare function redactingRpcSerialization(wire: RpcSerialization.RpcSerialization["Service"], sensitive: SensitiveKey, maskFailure?: (tag: string | undefined, reason: "Fail" | "Die") => boolean): typeof wire;
|
|
3
|
+
export declare function redactingRpcSerialization(wire: RpcSerialization.RpcSerialization["Service"], sensitive: SensitiveKey, maskFailure?: (tag: string | undefined, reason: "Fail" | "Die") => boolean, sensitiveForRpc?: (tag: string | undefined) => SensitiveKey): typeof wire;
|
|
4
4
|
//# sourceMappingURL=redactingRpcSerialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redactingRpcSerialization.d.ts","sourceRoot":"","sources":["../src/redactingRpcSerialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAK7E,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAClD,SAAS,EAAE,YAAY,EACvB,WAAW,GAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,KAAK,OAAqB,
|
|
1
|
+
{"version":3,"file":"redactingRpcSerialization.d.ts","sourceRoot":"","sources":["../src/redactingRpcSerialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAK7E,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAClD,SAAS,EAAE,YAAY,EACvB,WAAW,GAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,KAAK,OAAqB,EACvF,eAAe,GAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,KAAK,YAA8B,GAC1E,OAAO,IAAI,CAwEb"}
|
|
@@ -4,9 +4,9 @@ import { REDACTED } from "@shivaedev/errors/sensitive.ts";
|
|
|
4
4
|
function isRequestId(value) {
|
|
5
5
|
return typeof value === "string" || typeof value === "number";
|
|
6
6
|
}
|
|
7
|
-
export function redactingRpcSerialization(wire, sensitive, maskFailure = () => false) {
|
|
7
|
+
export function redactingRpcSerialization(wire, sensitive, maskFailure = () => false, sensitiveForRpc = () => sensitive) {
|
|
8
8
|
function reason(value, tag) {
|
|
9
|
-
const redacted = redactWire(value,
|
|
9
|
+
const redacted = redactWire(value, sensitiveForRpc(tag));
|
|
10
10
|
if (Predicate.isObjectOrArray(redacted)) {
|
|
11
11
|
if (Predicate.isTagged(value, "Fail") && maskFailure(tag, "Fail")) {
|
|
12
12
|
return { ...redacted, _tag: "Fail", error: REDACTED };
|
|
@@ -23,7 +23,7 @@ export function redactingRpcSerialization(wire, sensitive, maskFailure = () => f
|
|
|
23
23
|
}
|
|
24
24
|
function exit(value, tag) {
|
|
25
25
|
if (Predicate.isTagged(value, "Failure") && Predicate.hasProperty(value, "cause")) {
|
|
26
|
-
const cause = Array.isArray(value.cause) ? value.cause.map((item) => reason(item, tag)) : redactWire(value.cause,
|
|
26
|
+
const cause = Array.isArray(value.cause) ? value.cause.map((item) => reason(item, tag)) : redactWire(value.cause, sensitiveForRpc(tag));
|
|
27
27
|
return { ...value, cause };
|
|
28
28
|
}
|
|
29
29
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redactingRpcSerialization.js","sourceRoot":"","sources":["../src/redactingRpcSerialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAqB,MAAM,gCAAgC,CAAC;AAE7E,SAAS,WAAW,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC/D,CAAC;AACD,MAAM,UAAU,yBAAyB,CACxC,IAAkD,EAClD,SAAuB,EACvB,WAAW,GAAiE,GAAG,EAAE,CAAC,KAAK;
|
|
1
|
+
{"version":3,"file":"redactingRpcSerialization.js","sourceRoot":"","sources":["../src/redactingRpcSerialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAqB,MAAM,gCAAgC,CAAC;AAE7E,SAAS,WAAW,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC/D,CAAC;AACD,MAAM,UAAU,yBAAyB,CACxC,IAAkD,EAClD,SAAuB,EACvB,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
1
|
import { Layer } from "effect";
|
|
2
|
-
import { type
|
|
3
|
-
export declare function redactingTracer(sensitive:
|
|
2
|
+
import { type HostRedactionPolicy } from "#RedactionPolicy.ts";
|
|
3
|
+
export declare function redactingTracer(sensitive: HostRedactionPolicy): Layer.Layer<never, never, never>;
|
|
4
4
|
//# sourceMappingURL=redactingTracer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redactingTracer.d.ts","sourceRoot":"","sources":["../src/redactingTracer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,
|
|
1
|
+
{"version":3,"file":"redactingTracer.d.ts","sourceRoot":"","sources":["../src/redactingTracer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAkB,MAAM,QAAQ,CAAC;AAI7D,OAAO,EAAE,KAAK,mBAAmB,EAAmB,MAAM,qBAAqB,CAAC;AA0BhF,wBAAgB,eAAe,CAAC,SAAS,EAAE,mBAAmB,oCAoB7D"}
|
package/dist/redactingTracer.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { Effect, Exit, Layer, Tracer } from "effect";
|
|
1
|
+
import { Effect, Exit, Layer, Option, Tracer } from "effect";
|
|
2
2
|
import { redact } from "@shivaedev/errors/redact.ts";
|
|
3
3
|
import { redactDiagnosticCause } from "@shivaedev/errors/redactCause.ts";
|
|
4
4
|
import { REDACTED } from "@shivaedev/errors/sensitive.ts";
|
|
5
|
+
import { redactionForRpc } from "#RedactionPolicy.ts";
|
|
5
6
|
import { redactRecord } from "#redactingDiagnostics.ts";
|
|
6
7
|
function redactLinks(values, sensitive) {
|
|
7
8
|
return values.map((link) => ({ ...link, attributes: redactRecord(link.attributes, sensitive) }));
|
|
8
9
|
}
|
|
9
|
-
function redactSpan(span,
|
|
10
|
+
function redactSpan(span, policy) {
|
|
10
11
|
const end = span.end.bind(span);
|
|
11
12
|
const attribute = span.attribute.bind(span);
|
|
12
13
|
const event = span.event.bind(span);
|
|
13
14
|
const addLinks = span.addLinks.bind(span);
|
|
15
|
+
function sensitive(key) {
|
|
16
|
+
return redactionForRpc(policy, span.attributes.get("rpc.method"))(key);
|
|
17
|
+
}
|
|
14
18
|
return Object.assign(span, {
|
|
15
19
|
addLinks: (values) => addLinks(redactLinks(values, sensitive)),
|
|
16
20
|
attribute: (key, value) => attribute(key, sensitive(key) ? REDACTED : redact(value, sensitive)),
|
|
@@ -26,7 +30,17 @@ function redactSpan(span, sensitive) {
|
|
|
26
30
|
export function redactingTracer(sensitive) {
|
|
27
31
|
return Layer.effect(Tracer.Tracer, Effect.map(Tracer.Tracer, (tracer) => Tracer.make({
|
|
28
32
|
...tracer,
|
|
29
|
-
span: (options) =>
|
|
33
|
+
span: (options) => {
|
|
34
|
+
const method = Option.match(options.parent, {
|
|
35
|
+
onNone: () => undefined,
|
|
36
|
+
onSome: (parent) => (parent._tag === "Span" ? parent.attributes.get("rpc.method") : undefined),
|
|
37
|
+
});
|
|
38
|
+
const span = tracer.span({ ...options, links: redactLinks(options.links, redactionForRpc(sensitive, method)) });
|
|
39
|
+
if (typeof method === "string") {
|
|
40
|
+
span.attribute("rpc.method", method);
|
|
41
|
+
}
|
|
42
|
+
return redactSpan(span, sensitive);
|
|
43
|
+
},
|
|
30
44
|
})));
|
|
31
45
|
}
|
|
32
46
|
//# sourceMappingURL=redactingTracer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redactingTracer.js","sourceRoot":"","sources":["../src/redactingTracer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"redactingTracer.js","sourceRoot":"","sources":["../src/redactingTracer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,MA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E,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;aAC9F,CAAC,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;YAChH,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAChC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YACtC,CAAC;YACD,OAAO,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACpC,CAAC;KACD,CAAC,CACF,CACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { RequestTracing } from "@shivaedev/identity/middleware.ts";
|
|
3
|
+
import { type HostRedactionPolicy } from "#RedactionPolicy.ts";
|
|
4
|
+
export declare function rpcRequestTracing(sensitive: HostRedactionPolicy): Layer.Layer<RequestTracing, never, never>;
|
|
5
|
+
//# sourceMappingURL=rpcRequestTracing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpcRequestTracing.d.ts","sourceRoot":"","sources":["../src/rpcRequestTracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,KAAK,mBAAmB,EAAmB,MAAM,qBAAqB,CAAC;AAEhF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,mBAAmB,6CAM/D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import { RequestTracing } from "@shivaedev/identity/middleware.ts";
|
|
3
|
+
import { requestTracingLayer } from "@shivaedev/identity/server/tracing.ts";
|
|
4
|
+
import { redactionForRpc } from "#RedactionPolicy.ts";
|
|
5
|
+
export function rpcRequestTracing(sensitive) {
|
|
6
|
+
return Layer.succeed(RequestTracing, (effect, request) => RequestTracing.use((tracing) => tracing(effect, request)).pipe(Effect.provide(requestTracingLayer({ sensitive: redactionForRpc(sensitive, request.rpc._tag) }))));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=rpcRequestTracing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpcRequestTracing.js","sourceRoot":"","sources":["../src/rpcRequestTracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAA4B,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEhF,MAAM,UAAU,iBAAiB,CAAC,SAA8B;IAC/D,OAAO,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CACxD,cAAc,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAC7D,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,SAAS,EAAE,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAChG,CACD,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safeOtlpSerialization.d.ts","sourceRoot":"","sources":["../src/safeOtlpSerialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAwC,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAOzG,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAK,EAAE,SAAS,GAAE,YAA6B,UAE/F;
|
|
1
|
+
{"version":3,"file":"safeOtlpSerialization.d.ts","sourceRoot":"","sources":["../src/safeOtlpSerialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAwC,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAOzG,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAK,EAAE,SAAS,GAAE,YAA6B,UAE/F;AAuDD,eAAO,MAAM,qBAAqB,8FAUjC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Layer } from "effect";
|
|
2
2
|
import { OtlpSerialization } from "effect/observability";
|
|
3
3
|
import { isSensitiveKey, REDACTED, redactText } from "@shivaedev/errors/sensitive.ts";
|
|
4
|
-
import { RedactionPolicy } from "#RedactionPolicy.ts";
|
|
4
|
+
import { RedactionPolicy, redactionForRpc } from "#RedactionPolicy.ts";
|
|
5
5
|
import { redactOtlpUrl } from "#redactOtlpUrl.ts";
|
|
6
6
|
function otlpSensitive(sensitive) {
|
|
7
7
|
return (key) => sensitive(key) || ["db.user", "db.user.name", "db.connection_string"].includes(key.toLowerCase());
|
|
@@ -33,32 +33,37 @@ function spanName(span) {
|
|
|
33
33
|
}
|
|
34
34
|
return span.name;
|
|
35
35
|
}
|
|
36
|
-
function redactTraces(data,
|
|
37
|
-
|
|
38
|
-
return redactOtlpText(value, "", sensitive);
|
|
39
|
-
}
|
|
36
|
+
function redactTraces(data, policy) {
|
|
37
|
+
const resourceSensitive = otlpSensitive(policy);
|
|
40
38
|
return {
|
|
41
39
|
...data,
|
|
42
40
|
resourceSpans: data.resourceSpans.map((resource) => ({
|
|
43
41
|
...resource,
|
|
44
|
-
resource: { ...resource.resource, attributes: attributes(resource.resource.attributes,
|
|
42
|
+
resource: { ...resource.resource, attributes: attributes(resource.resource.attributes, resourceSensitive) },
|
|
45
43
|
scopeSpans: resource.scopeSpans.map((scope) => ({
|
|
46
44
|
...scope,
|
|
47
|
-
spans: scope.spans.map((span) =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
spans: scope.spans.map((span) => {
|
|
46
|
+
const method = span.attributes.find(({ key }) => key === "rpc.method")?.value.stringValue;
|
|
47
|
+
const sensitive = otlpSensitive(redactionForRpc(policy, method));
|
|
48
|
+
function text(value) {
|
|
49
|
+
return redactOtlpText(value, "", sensitive);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
...span,
|
|
53
|
+
attributes: attributes(span.attributes, sensitive),
|
|
54
|
+
events: span.events.map((event) => ({ ...event, attributes: attributes(event.attributes, sensitive), name: text(event.name) })),
|
|
55
|
+
links: span.links.map((link) => ({ ...link, attributes: attributes(link.attributes, sensitive) })),
|
|
56
|
+
name: text(spanName(span)),
|
|
57
|
+
status: { ...span.status, ...(span.status.message === undefined ? {} : { message: text(span.status.message) }) },
|
|
58
|
+
};
|
|
59
|
+
}),
|
|
55
60
|
})),
|
|
56
61
|
})),
|
|
57
62
|
};
|
|
58
63
|
}
|
|
59
64
|
export const safeOtlpSerialization = Layer.effect(OtlpSerialization.OtlpSerialization, Effect.gen(function* () {
|
|
60
65
|
const serialization = yield* OtlpSerialization.OtlpSerialization;
|
|
61
|
-
const sensitive =
|
|
66
|
+
const sensitive = yield* RedactionPolicy;
|
|
62
67
|
return OtlpSerialization.OtlpSerialization.of({
|
|
63
68
|
...serialization,
|
|
64
69
|
traces: (data) => serialization.traces(redactTraces(data, sensitive)),
|