@tallyrow/safesignal 1.0.1-rc.1

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.
@@ -0,0 +1,167 @@
1
+ import { g as LoggerConfig, C as CreateLoggerOptions, f as Logger, R as RedactionRule, h as Redactor, i as ScrubUrlOptions, j as TransportFactory } from './types-D-xVvmvX.js';
2
+ export { A as AppIdentity, a as AttributeValue, b as Attributes, E as ErrorInfo, L as LevelMap, c as LogContext, d as LogEvent, e as LogLevel, M as ModuleIdentity, S as SanitizerLimits, T as Transport } from './types-D-xVvmvX.js';
3
+
4
+ /**
5
+ * Public logger factories and root configuration flow.
6
+ *
7
+ * - `configureLogging(config)` — install (or replace) the package's
8
+ * module-scoped configuration. Atomic: the new runtime is built
9
+ * and installed in a single slot swap, then the previously-active
10
+ * runtime is torn down in the background so existing logger
11
+ * references keep working without modification.
12
+ * - `createLogger(options?)` — return a `Logger` whose context layers
13
+ * on top of the current root configuration.
14
+ * - `getRootLogger()` — singleton root logger created on first access.
15
+ *
16
+ * Behavior before `configureLogging()` is called is identical to a
17
+ * `configureLogging({})` invocation: env-unknown defaults (`warn`+),
18
+ * a single `NoopTransport`, and direct transport fan-out from the
19
+ * dispatcher. All emissions return synchronously and never throw.
20
+ *
21
+ * Vendor-neutrality: this module imports no observability-vendor SDK.
22
+ * The dispatcher fans sanitized + redacted events directly to the
23
+ * `SafeTransport`-wrapped consumer transports stored on the active
24
+ * `ConfiguredRuntime`. There is no telemetry backend in the v1
25
+ * default path; future vendor adapters are peer transports.
26
+ */
27
+
28
+ /**
29
+ * Install or replace the package's configuration. Safe to call multiple
30
+ * times — the previous runtime's transports are flushed + shut down
31
+ * (fire-and-forget) and the new configuration is installed via an
32
+ * atomic active-runtime-slot swap, so existing logger references
33
+ * continue to work without re-acquisition.
34
+ *
35
+ * Per FR-031 / SC-012, the swap is observable to any subsequent emit
36
+ * from a retained `Logger` reference: emit reads through
37
+ * `getActiveRuntime()` at the time of the call, so the new runtime is
38
+ * live for the very next emission.
39
+ *
40
+ * Per FR-032 the call is the single explicit named API for installing
41
+ * a runtime. There is no implicit module-load side effect that
42
+ * replaces the runtime; only an explicit `configureLogging()`
43
+ * invocation can swap it.
44
+ */
45
+ declare function configureLogging(config: LoggerConfig): void;
46
+ /**
47
+ * Create a logger whose context layers on top of the current root
48
+ * configuration. The returned logger holds no captured state — every
49
+ * emission reads the *current* module-scoped configuration, so calling
50
+ * `configureLogging()` later affects loggers already created.
51
+ */
52
+ declare function createLogger(options?: CreateLoggerOptions): Logger;
53
+ /** Singleton root logger created on first access. */
54
+ declare function getRootLogger(): Logger;
55
+
56
+ /**
57
+ * Redactor — masks values whose **key** matches the default denylist
58
+ * (case-insensitive, immediate property name only, never a value
59
+ * substring) and values whose **shape** matches a documented sensitive
60
+ * pattern (JWT, Bearer-prefixed token). Runs in the pipeline AFTER the
61
+ * sanitizer and URL scrubber have normalized the event and BEFORE the
62
+ * control-char guard, freeze, and any transport.
63
+ *
64
+ * Contract: `contracts/redaction.md` (R-1..R-10).
65
+ *
66
+ * Two surfaces:
67
+ * - `redact` (pipeline stage): wraps `config.redactor` (or the
68
+ * default `createRedactor()` when not supplied), invokes it
69
+ * synchronously, and enforces the fail-closed contract:
70
+ * * If the redactor throws, the dispatcher's outer try/catch
71
+ * drops the event and routes the throw to `onInternalError`.
72
+ * * If the redactor returns `null`, the event is dropped (the
73
+ * pipeline contract for explicit drop).
74
+ * * If the redactor returns a value that is neither a LogEvent
75
+ * nor `null`, this stage throws a `PackageError('redactor_failed')`
76
+ * so the same fail-closed path applies.
77
+ * - `createRedactor(rules?)` (public, re-exported from
78
+ * `src/index.ts`): returns a `Redactor` configured with the
79
+ * default rules when called with no argument, or with the
80
+ * consumer's rule set (FULL replacement of defaults) when an
81
+ * array is supplied. An empty array is a valid no-op rule set.
82
+ *
83
+ * Match semantics (per contract):
84
+ * - **Key match**: a rule's `key` is tested against the immediate
85
+ * property name being inspected. String keys match via case-
86
+ * insensitive equality; RegExp keys match via `.test()`. A match
87
+ * replaces the entire value (including object/array subtrees)
88
+ * with `rule.replacement ?? '[REDACTED]'`. Recursion does not
89
+ * descend into a value whose key matched — the whole subtree is
90
+ * considered sensitive.
91
+ * - **Shape match**: a rule's `shape` (RegExp) is tested against
92
+ * leaf string values regardless of key context. A match replaces
93
+ * the value with `rule.replacement ?? '[REDACTED]'`. Shape rules
94
+ * do not match objects or arrays as containers — only leaf
95
+ * strings.
96
+ * - **Combination**: a rule with both `key` and `shape` matches
97
+ * when either matches.
98
+ *
99
+ * Scope per field:
100
+ * - `event.attributes` — recursive walk; key + shape rules apply.
101
+ * - `event.context.attributes` — same recursive walk.
102
+ * - `event.message` — string scan; shape rules only (no key context).
103
+ * - `event.error.name`, `event.error.message`, `event.error.stack` —
104
+ * string scan; shape rules only.
105
+ */
106
+
107
+ declare function createRedactor(rules?: RedactionRule[]): Redactor;
108
+
109
+ /**
110
+ * URL scrubber — strips sensitive query and fragment parameters from
111
+ * URL-shaped string values before any transport sees the event.
112
+ *
113
+ * Contract: `contracts/redaction.md` (URL-derived secrets) + plan.md
114
+ * "Security Architecture > URL scrubbing".
115
+ *
116
+ * Two surfaces:
117
+ * - `urlScrub` (pipeline stage): walks `event.message`,
118
+ * `event.attributes`, `event.context.attributes`, `event.error.*`
119
+ * and rewrites any string that parses as an http(s) URL,
120
+ * replacing sensitive query and (optionally) fragment param values
121
+ * with `'[REDACTED]'`. Runs upstream of the redactor.
122
+ * - `scrubUrl(url, options?)` (public helper, re-exported from
123
+ * `src/index.ts`): the same operation surfaced directly so consumers
124
+ * can pre-scrub URLs they want to log intentionally.
125
+ *
126
+ * Security invariants:
127
+ * - NEVER throws. Malformed URLs, throwing getters on plain objects
128
+ * (already collapsed by the sanitizer upstream), and pathological
129
+ * fragments all fall through to "return input unchanged".
130
+ * - Returns input unchanged for any string that is not a parseable
131
+ * http(s) URL. Path segments, host, and authority are NOT modified
132
+ * — only query and fragment parameter VALUES are replaced. Param
133
+ * names are preserved.
134
+ * - Operates on names (case-insensitive), never on value substrings —
135
+ * the package never inspects a URL value's content for sensitive
136
+ * shapes (that is the redactor's job, applied later in the pipeline).
137
+ */
138
+
139
+ declare function scrubUrl(url: string, options?: ScrubUrlOptions): string;
140
+
141
+ /**
142
+ * Built-in `ConsoleTransport`. Passes events to `console[level]` with the
143
+ * event message as the first argument and the **structured `LogEvent`
144
+ * object as the second argument** — never interpolated into a single
145
+ * string. Falls back to `console.log` only when `console[level]` is not a
146
+ * function (the modern browser console always defines all four levels).
147
+ *
148
+ * This is the only built-in delivery path that produces visible output.
149
+ * Console output preserves the structured-only invariant (FR-016, plan
150
+ * §Log-injection & output safety).
151
+ */
152
+
153
+ declare const ConsoleTransport: TransportFactory;
154
+
155
+ /**
156
+ * Built-in `NoopTransport`. Silently swallows every event.
157
+ *
158
+ * This is the automatic fallback when `LoggerConfig.transports` is
159
+ * undefined or empty (per `contracts/logger-config.md` LC default
160
+ * resolution). Useful in tests, in environments where logging is
161
+ * deliberately disabled, and as a placeholder during incremental
162
+ * configuration.
163
+ */
164
+
165
+ declare const NoopTransport: TransportFactory;
166
+
167
+ export { ConsoleTransport, CreateLoggerOptions, Logger, LoggerConfig, NoopTransport, RedactionRule, Redactor, ScrubUrlOptions, TransportFactory, configureLogging, createLogger, createRedactor, getRootLogger, scrubUrl };