@shivaedev/server 0.35.1 → 0.36.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.36.0 - 2026-11-19
4
+
5
+ ### Added
6
+
7
+ - `appHost` masks the names of fields that a repository model marks sensitive (`sensitive: true` or a Redacted schema), and their encoded names, in every RPC's logs, error reports, failure frames and exported traces, as it masks `config.sensitiveKeys`. The policy is complete before the host serves its first request, so mark a sensitive value once, on the server's model.
8
+
3
9
  ## 0.35.1 - 2026-11-18
4
10
 
5
11
  ### Changed
package/README.md CHANGED
@@ -160,7 +160,7 @@ NodeRuntime.runMain(Layer.launch(Server));
160
160
 
161
161
  The `sessions` Layer provides one identity `SessionPolicy` to handler middleware, sockets, change subscriptions and application routes. Construct it with `Layer.succeed(SessionPolicy, { origin, provider, roles })`; policy readers take no policy argument.
162
162
 
163
- A session host also installs identity's subject resolver for contracts with `subject: selfSubject` or `subject: accountSubject(...)`. It resolves the session account or authorizes the delegated `x-platform-subject` transport header before the handler runs, supplies the branded `Subject` plus the actor's `Identity` and `SessionUser` to the request, and returns the declared typed refusal when delegation is denied. Business payloads do not carry an owner id. See [declared request subjects](https://github.com/ShivaeDev/platform/tree/main/packages/identity#declared-request-subjects) for declarations and session profile requirements.
163
+ A session host also installs identity's subject resolver for contracts with `subject: selfSubject` or `subject: accountSubject(...)`. It resolves the session account or authorizes the account a call names in its `x-platform-subject` message header, falling back to that header on the transport, before the handler runs and again at each stream recheck, supplies the branded `Subject` plus the actor's `Identity` and `SessionUser` to the request, and returns the declared typed refusal when delegation is denied. Business payloads do not carry an owner id. See [declared request subjects](https://github.com/ShivaeDev/platform/tree/main/packages/identity#declared-request-subjects) for declarations and session profile requirements.
164
164
 
165
165
  Omit `services` when the app has no service Layer of its own. The host uses `Layer.empty`; handler requirements remain explicit, and a migrated host still provides its database services to handlers. Annotated options that declare service outputs, errors or requirements must supply a `services` Layer.
166
166
 
@@ -397,7 +397,7 @@ Render inside the application's native registry provider. The query's `data` is
397
397
 
398
398
  Tracing logs declared failures with `RPC failure` and their tag, and defects with `RPC defect`. Interrupt-only causes emit `RPC interrupted` at debug instead, with `rpc.method`, `requestId`, the `rpc.duration` log span and the same redacted payload. The RPC trace span carries `rpc.interrupted: true`; Effect exports interruption with an unset span status. Completed and failed RPCs receive no interruption marker. The diagnostic payload masks nested credential-shaped keys and Effect `Redacted` values. Credential-shaped strings, such as bearer tokens, URL passwords and sensitive `key=value` text, are masked too. Strings retain at most 2,048 characters before a truncation marker; collections retain at most 50 entries with a marker for the remainder, and binary values become size summaries.
399
399
 
400
- `appHost` derives sensitive field names from the served RPC group's payload, success, error, defect and middleware error schemas, including nested schemas. Use `Schema.Redacted(...)`, `Schema.RedactedFromValue(...)`, or annotate a field with `sensitive: true`. The host applies each RPC's schema-derived names to that RPC's diagnostics and failures, even when a diagnostic contains an unwrapped value. Application-wide keys configured below apply to every RPC. Add other exact, case-sensitive names once in `config.sensitiveKeys`:
400
+ `appHost` derives sensitive field names from the served RPC group's payload, success, error, defect and middleware error schemas, including nested schemas. Use `Schema.Redacted(...)`, `Schema.RedactedFromValue(...)`, or annotate a field with `sensitive: true`. The host applies each RPC's schema-derived names to that RPC's diagnostics and failures, even when a diagnostic contains an unwrapped value. A defined module's success comes from its generated wire, which carries no annotation, so it takes no part: mark the field on the model instead. Every repository the host builds while it starts, through `makeRepository` or `makeOrderedChildren`, declares its model, and the names of the model's sensitive fields apply to every RPC and every diagnostic like `config.sensitiveKeys`, before the host serves its first request. A repository made inside a handler declares its model only when it runs, after the RPC failure masks are compiled; build repositories in Layers. Values no repository model describes, such as computed or third-party data, are covered only by the built-in name rules and `config.sensitiveKeys`. Application-wide keys configured below apply to every RPC. Add other exact, case-sensitive names once in `config.sensitiveKeys`:
401
401
 
402
402
  ```ts
403
403
  import { Schema } from "effect";
@@ -415,7 +415,7 @@ const Server = appHost({
415
415
  });
416
416
  ```
417
417
 
418
- Different methods can use `state` privately and publicly in the same group. Within one method, logs and traces do not retain schema identity, so startup refuses a sensitive field name that also appears as public data in that method's payload, success, error, defect or middleware error schemas. The error names both schema paths, including nested fields and encoded names. Rename one field or give both fields the same sensitivity before starting the host. This prevents redaction of a public literal-union failure field from breaking native client decoding.
418
+ Different methods can use `state` privately and publicly in the same group. Within one method, logs and traces do not retain schema identity, so startup refuses a sensitive field name that also appears as public data in that method's payload, success, error, defect or middleware error schemas. The error names both schema paths, including nested fields and encoded names. Rename one field or give both fields the same sensitivity before starting the host. Model names and a module's generated success take no part in this check; a module's payload can mark a name sensitive that its generated success also names. This prevents redaction of a public literal-union failure field from breaking native client decoding.
419
419
 
420
420
  Use `Contact` in `Api`'s RPC schemas. A `sensitive: true` annotation also applies to a checked schema, such as `Schema.String.check(Schema.isMinLength(1)).annotate({ sensitive: true })`, and to checks or groups nested inside other check groups. Values under the declared names become `<redacted>` in host log messages and annotations, failure and defect payloads sent to RPC clients, causes passed to installed error reporters, and exported trace attributes, events, links and resource attributes. Nested structured values follow the same policy before trace serialization. A field containing sensitive array items or record values is masked as a whole. `Schema.encodeKeys` and other schema encoders carry sensitivity to their declared output names, including chains of renamed fields. The host propagates encoded names and enclosing-field protection within each schema until its key set stops growing, then combines the policies for that method. Sensitivity is checked throughout each transformation's source subtree, including fields named in `config.sensitiveKeys`. Policy derivation does not execute encoder callbacks: their field provenance is unknown, so every declared output field of a sensitive source is treated as sensitive, including every union branch, otherwise public fields and error discriminators. When a sensitive source encodes to a scalar, its enclosing field is masked as a whole. Sensitive error tags are masked before tracing copies them into the `rpc.failure` log annotation. Native RPC protocol tags remain intact. An `Error` retains its message, stack and cause in redacted form. If `message` or `name` is sensitive, its stack is masked too, including stack headers encoded by `Schema.Defect({ includeStack: true })`. Successful RPC responses retain their application data. Error schemas consumed by native clients must accept the redaction marker for sensitive fields; a constrained string, numeric or collection field may otherwise fail client decoding after masking.
421
421