@reticlehq/core 2.3.0 → 2.4.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/dist/constants.d.ts +0 -8
- package/dist/constants.js +0 -8
- package/dist/event-payloads.d.ts +2 -2
- package/dist/flow-types.d.ts +17 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/messages.d.ts +24 -0
- package/dist/messages.js +14 -0
- package/dist/redaction.d.ts +64 -0
- package/dist/redaction.js +118 -1
- package/dist/schema/hello-message.json +9 -0
- package/dist/schema/reticle-message.json +9 -0
- package/dist/source-constants.d.ts +26 -0
- package/dist/source-constants.js +26 -0
- package/dist/state-select.d.ts +10 -0
- package/dist/state-select.js +31 -14
- package/dist/types.d.ts +6 -6
- package/dist/verification-run.d.ts +10 -10
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -97,14 +97,6 @@ export declare const TRANSPORT_LIMITS: {
|
|
|
97
97
|
};
|
|
98
98
|
/** Replacement used when sensitive data is removed before crossing the bridge. */
|
|
99
99
|
export declare const REDACTED_VALUE = "[REDACTED]";
|
|
100
|
-
/**
|
|
101
|
-
* The attribute the build plugin stamps on JSX host elements as `file:line:column`, so the browser SDK
|
|
102
|
-
* and the React adapter can map a DOM node back to its source file (the source-pointer feature, needed
|
|
103
|
-
* on React 19 which dropped _debugSource). Read here by both packages — it was duplicated as a local
|
|
104
|
-
* const in dom/source.ts AND dom/query.ts and inlined as a literal in the React adapter. The stamper
|
|
105
|
-
* (@reticlehq/babel-plugin, separate build tooling) stamps this same literal and MUST match it.
|
|
106
|
-
*/
|
|
107
|
-
export declare const DATA_RETICLE_SOURCE_ATTR = "data-reticle-source";
|
|
108
100
|
/** Explicit opt-in argument required for potentially destructive actions. */
|
|
109
101
|
export declare const DANGEROUS_ACTION_CONFIRM_ARG = "confirmDangerous";
|
|
110
102
|
/** Schema version stamped onto compiled replay programs. */
|
package/dist/constants.js
CHANGED
|
@@ -99,14 +99,6 @@ export const TRANSPORT_LIMITS = {
|
|
|
99
99
|
};
|
|
100
100
|
/** Replacement used when sensitive data is removed before crossing the bridge. */
|
|
101
101
|
export const REDACTED_VALUE = '[REDACTED]';
|
|
102
|
-
/**
|
|
103
|
-
* The attribute the build plugin stamps on JSX host elements as `file:line:column`, so the browser SDK
|
|
104
|
-
* and the React adapter can map a DOM node back to its source file (the source-pointer feature, needed
|
|
105
|
-
* on React 19 which dropped _debugSource). Read here by both packages — it was duplicated as a local
|
|
106
|
-
* const in dom/source.ts AND dom/query.ts and inlined as a literal in the React adapter. The stamper
|
|
107
|
-
* (@reticlehq/babel-plugin, separate build tooling) stamps this same literal and MUST match it.
|
|
108
|
-
*/
|
|
109
|
-
export const DATA_RETICLE_SOURCE_ATTR = 'data-reticle-source';
|
|
110
102
|
/** Explicit opt-in argument required for potentially destructive actions. */
|
|
111
103
|
export const DANGEROUS_ACTION_CONFIRM_ARG = 'confirmDangerous';
|
|
112
104
|
/** Schema version stamped onto compiled replay programs. */
|
package/dist/event-payloads.d.ts
CHANGED
|
@@ -212,12 +212,12 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
|
|
|
212
212
|
value: z.ZodNumber;
|
|
213
213
|
at: z.ZodNumber;
|
|
214
214
|
}, "strip", z.ZodTypeAny, {
|
|
215
|
-
value: number;
|
|
216
215
|
at: number;
|
|
216
|
+
value: number;
|
|
217
217
|
metric: "lcp" | "cls" | "longtask";
|
|
218
218
|
}, {
|
|
219
|
-
value: number;
|
|
220
219
|
at: number;
|
|
220
|
+
value: number;
|
|
221
221
|
metric: "lcp" | "cls" | "longtask";
|
|
222
222
|
}>;
|
|
223
223
|
"route.change": z.ZodObject<{
|
package/dist/flow-types.d.ts
CHANGED
|
@@ -357,13 +357,29 @@ export interface SuiteFlowResult {
|
|
|
357
357
|
* failures carry detail (token-cheap). `status` is fail if any flow drifted or errored.
|
|
358
358
|
*/
|
|
359
359
|
export interface SuiteVerdict {
|
|
360
|
-
|
|
360
|
+
/**
|
|
361
|
+
* `unverifiable` means the suite contained flows that CANNOT FAIL, so "pass" would be a lie.
|
|
362
|
+
*
|
|
363
|
+
* A recorded flow with no steps, or one that asserts no observable consequence, replays green no
|
|
364
|
+
* matter what the app does. Reporting `pass` for it is a false green in the exact feature sold as
|
|
365
|
+
* the regression suite — measured: a flow saved as `{steps: [], intent: "..."}`, which `flow_save`
|
|
366
|
+
* had ALREADY graded assertion-free with a warning, came back "all 1 flow pass".
|
|
367
|
+
*/
|
|
368
|
+
status: 'pass' | 'fail' | 'unverifiable';
|
|
361
369
|
total: number;
|
|
362
370
|
passed: number;
|
|
363
371
|
failed: number;
|
|
364
372
|
summary: string;
|
|
365
373
|
/** Only the failing flows, with their decision (verdict, what changed, where, next action). */
|
|
366
374
|
failures: SuiteFlowResult[];
|
|
375
|
+
/**
|
|
376
|
+
* Flows that replayed without error but assert nothing, so their green means nothing. Counted
|
|
377
|
+
* apart from `passed` — a number that includes them is not a count of anything verified.
|
|
378
|
+
*/
|
|
379
|
+
unverifiable?: {
|
|
380
|
+
flow: string;
|
|
381
|
+
reason: string;
|
|
382
|
+
}[];
|
|
367
383
|
/**
|
|
368
384
|
* Flows that have both passed AND failed on UNCHANGED code — intermittent, not regressions.
|
|
369
385
|
*
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
// ── STABLE public surface: the wire/domain contract ──────────────────────────────────────────────
|
|
11
11
|
export * from './constants.js'; // EventType, ActionType, wire constants, TRANSPORT_LIMITS, …
|
|
12
|
+
export * from './source-constants.js'; // DATA_RETICLE_SOURCE_ATTR, RETICLE_ROOT_GLOBAL
|
|
12
13
|
export * from './verified-constants.js'; // Verified — the one field an agent gates on
|
|
13
14
|
export * from './session-constants.js';
|
|
14
15
|
export * from './messages.js'; // ReticleEvent + the message schemas
|
package/dist/messages.d.ts
CHANGED
|
@@ -179,6 +179,16 @@ export declare const HelloMessageSchema: z.ZodObject<{
|
|
|
179
179
|
token: z.ZodOptional<z.ZodString>;
|
|
180
180
|
/** Whether the app has advertised a capability registry (reticle.describe). */
|
|
181
181
|
hasCapabilities: z.ZodOptional<z.ZodBoolean>;
|
|
182
|
+
/**
|
|
183
|
+
* Extra key names this app declared sensitive via `connect({ redact: { keys } })`.
|
|
184
|
+
*
|
|
185
|
+
* Sent so the DRIVEN path redacts them too: a request body captured by the daemon from the network
|
|
186
|
+
* stack never passes through the SDK, so an app-declared credential would otherwise reach the
|
|
187
|
+
* journal in cleartext on exactly the path the user cannot see. Literal names only — a pattern
|
|
188
|
+
* compiled from the wire would be a ReDoS surface, and the exemption list is never sent because it
|
|
189
|
+
* is the only part of the config that could REMOVE redaction. See `wireRedactionKeys`.
|
|
190
|
+
*/
|
|
191
|
+
redactKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
182
192
|
}, "strip", z.ZodTypeAny, {
|
|
183
193
|
kind: "hello";
|
|
184
194
|
sessionId: string;
|
|
@@ -189,6 +199,7 @@ export declare const HelloMessageSchema: z.ZodObject<{
|
|
|
189
199
|
projectId?: string | undefined;
|
|
190
200
|
token?: string | undefined;
|
|
191
201
|
hasCapabilities?: boolean | undefined;
|
|
202
|
+
redactKeys?: string[] | undefined;
|
|
192
203
|
}, {
|
|
193
204
|
kind: "hello";
|
|
194
205
|
sessionId: string;
|
|
@@ -199,6 +210,7 @@ export declare const HelloMessageSchema: z.ZodObject<{
|
|
|
199
210
|
projectId?: string | undefined;
|
|
200
211
|
token?: string | undefined;
|
|
201
212
|
hasCapabilities?: boolean | undefined;
|
|
213
|
+
redactKeys?: string[] | undefined;
|
|
202
214
|
}>;
|
|
203
215
|
export type HelloMessage = z.infer<typeof HelloMessageSchema>;
|
|
204
216
|
/** Agent -> browser request, routed by the bridge with a correlation id. */
|
|
@@ -368,6 +380,16 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
|
|
|
368
380
|
token: z.ZodOptional<z.ZodString>;
|
|
369
381
|
/** Whether the app has advertised a capability registry (reticle.describe). */
|
|
370
382
|
hasCapabilities: z.ZodOptional<z.ZodBoolean>;
|
|
383
|
+
/**
|
|
384
|
+
* Extra key names this app declared sensitive via `connect({ redact: { keys } })`.
|
|
385
|
+
*
|
|
386
|
+
* Sent so the DRIVEN path redacts them too: a request body captured by the daemon from the network
|
|
387
|
+
* stack never passes through the SDK, so an app-declared credential would otherwise reach the
|
|
388
|
+
* journal in cleartext on exactly the path the user cannot see. Literal names only — a pattern
|
|
389
|
+
* compiled from the wire would be a ReDoS surface, and the exemption list is never sent because it
|
|
390
|
+
* is the only part of the config that could REMOVE redaction. See `wireRedactionKeys`.
|
|
391
|
+
*/
|
|
392
|
+
redactKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
371
393
|
}, "strip", z.ZodTypeAny, {
|
|
372
394
|
kind: "hello";
|
|
373
395
|
sessionId: string;
|
|
@@ -378,6 +400,7 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
|
|
|
378
400
|
projectId?: string | undefined;
|
|
379
401
|
token?: string | undefined;
|
|
380
402
|
hasCapabilities?: boolean | undefined;
|
|
403
|
+
redactKeys?: string[] | undefined;
|
|
381
404
|
}, {
|
|
382
405
|
kind: "hello";
|
|
383
406
|
sessionId: string;
|
|
@@ -388,6 +411,7 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
|
|
|
388
411
|
projectId?: string | undefined;
|
|
389
412
|
token?: string | undefined;
|
|
390
413
|
hasCapabilities?: boolean | undefined;
|
|
414
|
+
redactKeys?: string[] | undefined;
|
|
391
415
|
}>, z.ZodObject<{
|
|
392
416
|
kind: z.ZodLiteral<"command">;
|
|
393
417
|
id: z.ZodString;
|
package/dist/messages.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { EventAttribution, EventType, RETICLE_PROTOCOL_VERSION, MessageKind, TRANSPORT_LIMITS, } from './constants.js';
|
|
3
3
|
import { HumanControlKind, MarkAnchorStrategy } from './session-constants.js';
|
|
4
|
+
import { MAX_WIRE_REDACT_KEYS, MAX_WIRE_REDACT_KEY_LENGTH } from './redaction.js';
|
|
4
5
|
const sessionIdSchema = z.string().min(1).max(TRANSPORT_LIMITS.MAX_SESSION_ID_LENGTH);
|
|
5
6
|
const refSchema = z.string().max(TRANSPORT_LIMITS.MAX_REF_LENGTH);
|
|
6
7
|
/**
|
|
@@ -85,6 +86,19 @@ export const HelloMessageSchema = z.object({
|
|
|
85
86
|
token: z.string().max(TRANSPORT_LIMITS.MAX_TOKEN_LENGTH).optional(),
|
|
86
87
|
/** Whether the app has advertised a capability registry (reticle.describe). */
|
|
87
88
|
hasCapabilities: z.boolean().optional(),
|
|
89
|
+
/**
|
|
90
|
+
* Extra key names this app declared sensitive via `connect({ redact: { keys } })`.
|
|
91
|
+
*
|
|
92
|
+
* Sent so the DRIVEN path redacts them too: a request body captured by the daemon from the network
|
|
93
|
+
* stack never passes through the SDK, so an app-declared credential would otherwise reach the
|
|
94
|
+
* journal in cleartext on exactly the path the user cannot see. Literal names only — a pattern
|
|
95
|
+
* compiled from the wire would be a ReDoS surface, and the exemption list is never sent because it
|
|
96
|
+
* is the only part of the config that could REMOVE redaction. See `wireRedactionKeys`.
|
|
97
|
+
*/
|
|
98
|
+
redactKeys: z
|
|
99
|
+
.array(z.string().min(1).max(MAX_WIRE_REDACT_KEY_LENGTH))
|
|
100
|
+
.max(MAX_WIRE_REDACT_KEYS)
|
|
101
|
+
.optional(),
|
|
88
102
|
});
|
|
89
103
|
/** Agent -> browser request, routed by the bridge with a correlation id. */
|
|
90
104
|
export const CommandMessageSchema = z.object({
|
package/dist/redaction.d.ts
CHANGED
|
@@ -1,3 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in rule, always available and never configurable.
|
|
3
|
+
*
|
|
4
|
+
* Separate from `isSensitiveKey` on purpose: the driven path needs a floor that no page-supplied
|
|
5
|
+
* config can lower, and the conformance test needs something to compare an unconfigured policy
|
|
6
|
+
* against. Every existing caller wants `isSensitiveKey`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function defaultIsSensitiveKey(key: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* An app's additions to (and subtractions from) the default rule.
|
|
11
|
+
*
|
|
12
|
+
* Additive by construction: `keys` can only ever redact MORE, and `allow` only exempts from the
|
|
13
|
+
* DEFAULT rule. There is deliberately no way to replace the default set — a user who could would
|
|
14
|
+
* eventually ship an app that leaks, and Reticle would be the thing that recorded it.
|
|
15
|
+
*/
|
|
16
|
+
export interface RedactionConfig {
|
|
17
|
+
/**
|
|
18
|
+
* Extra keys to redact. A string matches a key name EXACTLY (case-insensitively) — `'code'` does
|
|
19
|
+
* not redact `codeOwner` — and a RegExp is tested against the key. Use a string unless you need a
|
|
20
|
+
* pattern: only strings cross the bridge (see `wireRedactionKeys`).
|
|
21
|
+
*/
|
|
22
|
+
keys?: ReadonlyArray<string | RegExp>;
|
|
23
|
+
/**
|
|
24
|
+
* Keys to exempt from the DEFAULT rule, for the false positives every app has its own version of
|
|
25
|
+
* (`designToken`, an internal `sessionId` that is not a credential). Exact, case-insensitive.
|
|
26
|
+
* Loses to `keys`: an explicit redact instruction beats an exemption.
|
|
27
|
+
*/
|
|
28
|
+
allow?: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
/** A resolved rule. An object rather than a bare function so a caller can hold one per session. */
|
|
31
|
+
export interface RedactionPolicy {
|
|
32
|
+
isSensitiveKey: (key: string) => boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a config into a rule.
|
|
36
|
+
*
|
|
37
|
+
* `onWarn` fires ONCE here, at build time, rather than per key: the check runs on every serialized
|
|
38
|
+
* key of every event, so a per-key warning would flood the console of the app it is trying to help.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildRedactionPolicy(config?: RedactionConfig, onWarn?: (message: string) => void): RedactionPolicy;
|
|
41
|
+
export declare function setActiveRedactionPolicy(policy: RedactionPolicy): void;
|
|
42
|
+
export declare function resetActiveRedactionPolicy(): void;
|
|
43
|
+
/** Whether a key carries a credential, under the policy in force. */
|
|
1
44
|
export declare function isSensitiveKey(key: string): boolean;
|
|
45
|
+
/** Cap on how many declared keys travel in a hello — a bound, not a limit anyone should reach. */
|
|
46
|
+
export declare const MAX_WIRE_REDACT_KEYS = 64;
|
|
47
|
+
/** Cap on one declared key's length, so a hello cannot be inflated by a pathological name. */
|
|
48
|
+
export declare const MAX_WIRE_REDACT_KEY_LENGTH = 128;
|
|
49
|
+
/**
|
|
50
|
+
* The part of a config that may cross the bridge, so the server redacts an app's own credentials on
|
|
51
|
+
* the driven path too — where request bodies are captured raw from the network stack and never pass
|
|
52
|
+
* through the SDK at all.
|
|
53
|
+
*
|
|
54
|
+
* Two deliberate exclusions, and both are the safe direction of the asymmetry:
|
|
55
|
+
*
|
|
56
|
+
* - **RegExp entries do not travel.** Compiling a pattern that arrived over a socket and running it
|
|
57
|
+
* against every key of every request body is a ReDoS surface handed to whatever is on the page.
|
|
58
|
+
* A dropped pattern means the driven path over-redacts relative to the config, never under.
|
|
59
|
+
* - **`allow` never travels.** It is the only part of the config that REMOVES redaction, so a page
|
|
60
|
+
* able to send it could quietly un-redact `password` in the daemon's journal for every session.
|
|
61
|
+
* The driven path keeps the default floor.
|
|
62
|
+
*
|
|
63
|
+
* Both limitations are documented for users in docs/usage.md ("Extending the redaction rules").
|
|
64
|
+
*/
|
|
65
|
+
export declare function wireRedactionKeys(config?: RedactionConfig): string[];
|
|
2
66
|
/** Redact high-confidence secret shapes anywhere in a text/value, independent of any surrounding key. */
|
|
3
67
|
export declare function scrubKnownSecrets(text: string): string;
|
package/dist/redaction.js
CHANGED
|
@@ -18,9 +18,126 @@ import { REDACTED_VALUE } from './constants.js';
|
|
|
18
18
|
// unredacted), NOT any key that merely contains the substring — `scopecookie`, `cookieConsent`,
|
|
19
19
|
// `cookiePolicy` are legitimate app values an agent may need to read, and stay visible.
|
|
20
20
|
const SENSITIVE_KEY = /password|passwd|passcode|secret|(?:(?:access|refresh|auth|bearer|api|id|session|csrf|client)[-_]?tokens?|(?:^|[-_])tokens?(?=$|[-_]))|session[-_]?id|(?:^|[-_])(?:sid|pwd|jwt)(?=$|[-_])|authorization|(?:^|[-_])(?:set[-_])?cookie(?=$|[-_])|api[-_]?key|access[-_]?key|private[-_]?key|client[-_]?secret|credit[-_]?card|card[-_]?number|cvv|cvc|ssn|(?:^|[-_])(?:signature|sig)$|(?:^|[-_])credential$|x-(?:amz|goog)-(?:signature|credential|security-token)$/i;
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The built-in rule, always available and never configurable.
|
|
23
|
+
*
|
|
24
|
+
* Separate from `isSensitiveKey` on purpose: the driven path needs a floor that no page-supplied
|
|
25
|
+
* config can lower, and the conformance test needs something to compare an unconfigured policy
|
|
26
|
+
* against. Every existing caller wants `isSensitiveKey`.
|
|
27
|
+
*/
|
|
28
|
+
export function defaultIsSensitiveKey(key) {
|
|
22
29
|
return SENSITIVE_KEY.test(key);
|
|
23
30
|
}
|
|
31
|
+
function normalizeNames(values) {
|
|
32
|
+
const out = new Set();
|
|
33
|
+
for (const value of values ?? []) {
|
|
34
|
+
const trimmed = value.trim().toLowerCase();
|
|
35
|
+
if (trimmed.length > 0)
|
|
36
|
+
out.add(trimmed);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a config into a rule.
|
|
42
|
+
*
|
|
43
|
+
* `onWarn` fires ONCE here, at build time, rather than per key: the check runs on every serialized
|
|
44
|
+
* key of every event, so a per-key warning would flood the console of the app it is trying to help.
|
|
45
|
+
*/
|
|
46
|
+
export function buildRedactionPolicy(config, onWarn) {
|
|
47
|
+
const literalKeys = normalizeNames(config?.keys?.filter((k) => typeof k === 'string'));
|
|
48
|
+
const patterns = (config?.keys ?? []).filter((k) => k instanceof RegExp);
|
|
49
|
+
const allowed = normalizeNames(config?.allow);
|
|
50
|
+
// Exempting a key the default rule calls a credential is a deliberate choice with a real blast
|
|
51
|
+
// radius: that value now reaches the agent transcript and the on-disk journal. Say it once, name
|
|
52
|
+
// the keys, and say nothing about the ordinary case — an exemption for a key the rule never
|
|
53
|
+
// matched is the false-positive fix this option exists for, and warning about it would train
|
|
54
|
+
// people to ignore the warning that matters.
|
|
55
|
+
const exemptedCredentials = [...allowed].filter((key) => defaultIsSensitiveKey(key) && !literalKeys.has(key));
|
|
56
|
+
if (exemptedCredentials.length > 0 && onWarn !== undefined) {
|
|
57
|
+
onWarn(`[reticle] redact.allow is exempting ${exemptedCredentials.join(', ')} from redaction. The ` +
|
|
58
|
+
`default rule treats ${exemptedCredentials.length === 1 ? 'that key' : 'those keys'} as a ` +
|
|
59
|
+
`credential, so ${exemptedCredentials.length === 1 ? 'its value' : 'their values'} will now ` +
|
|
60
|
+
`reach the agent transcript and the on-disk journal in cleartext.`);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
isSensitiveKey: (key) => {
|
|
64
|
+
const normalized = key.toLowerCase();
|
|
65
|
+
if (literalKeys.has(normalized))
|
|
66
|
+
return true;
|
|
67
|
+
for (const pattern of patterns) {
|
|
68
|
+
// `test` on a /g regex advances lastIndex between calls, so the same key alternates
|
|
69
|
+
// true/false. Reset it rather than trusting every caller to omit the flag.
|
|
70
|
+
pattern.lastIndex = 0;
|
|
71
|
+
if (pattern.test(key))
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (allowed.has(normalized))
|
|
75
|
+
return false;
|
|
76
|
+
return defaultIsSensitiveKey(key);
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The rule in force for THIS process.
|
|
82
|
+
*
|
|
83
|
+
* Ambient rather than threaded through the ~10 call sites that redact, so configuring it changes
|
|
84
|
+
* every one of them at once and adding a new one cannot accidentally opt out. Set by `connect()` in
|
|
85
|
+
* the browser, where one page means one config.
|
|
86
|
+
*
|
|
87
|
+
* The server deliberately does NOT set this. A daemon serves many sessions in one process, so an
|
|
88
|
+
* ambient policy there would let one app's config decide another app's redaction; the driven path
|
|
89
|
+
* holds its own policy per daemon instead, built only from what sessions declared as EXTRA keys.
|
|
90
|
+
*/
|
|
91
|
+
let activePolicy;
|
|
92
|
+
export function setActiveRedactionPolicy(policy) {
|
|
93
|
+
activePolicy = policy;
|
|
94
|
+
}
|
|
95
|
+
export function resetActiveRedactionPolicy() {
|
|
96
|
+
activePolicy = undefined;
|
|
97
|
+
}
|
|
98
|
+
/** Whether a key carries a credential, under the policy in force. */
|
|
99
|
+
export function isSensitiveKey(key) {
|
|
100
|
+
return activePolicy === undefined ? defaultIsSensitiveKey(key) : activePolicy.isSensitiveKey(key);
|
|
101
|
+
}
|
|
102
|
+
/** Cap on how many declared keys travel in a hello — a bound, not a limit anyone should reach. */
|
|
103
|
+
export const MAX_WIRE_REDACT_KEYS = 64;
|
|
104
|
+
/** Cap on one declared key's length, so a hello cannot be inflated by a pathological name. */
|
|
105
|
+
export const MAX_WIRE_REDACT_KEY_LENGTH = 128;
|
|
106
|
+
/**
|
|
107
|
+
* The part of a config that may cross the bridge, so the server redacts an app's own credentials on
|
|
108
|
+
* the driven path too — where request bodies are captured raw from the network stack and never pass
|
|
109
|
+
* through the SDK at all.
|
|
110
|
+
*
|
|
111
|
+
* Two deliberate exclusions, and both are the safe direction of the asymmetry:
|
|
112
|
+
*
|
|
113
|
+
* - **RegExp entries do not travel.** Compiling a pattern that arrived over a socket and running it
|
|
114
|
+
* against every key of every request body is a ReDoS surface handed to whatever is on the page.
|
|
115
|
+
* A dropped pattern means the driven path over-redacts relative to the config, never under.
|
|
116
|
+
* - **`allow` never travels.** It is the only part of the config that REMOVES redaction, so a page
|
|
117
|
+
* able to send it could quietly un-redact `password` in the daemon's journal for every session.
|
|
118
|
+
* The driven path keeps the default floor.
|
|
119
|
+
*
|
|
120
|
+
* Both limitations are documented for users in docs/usage.md ("Extending the redaction rules").
|
|
121
|
+
*/
|
|
122
|
+
export function wireRedactionKeys(config) {
|
|
123
|
+
const seen = new Set();
|
|
124
|
+
const out = [];
|
|
125
|
+
for (const key of config?.keys ?? []) {
|
|
126
|
+
if (typeof key !== 'string')
|
|
127
|
+
continue;
|
|
128
|
+
const trimmed = key.trim();
|
|
129
|
+
if (trimmed.length === 0 || trimmed.length > MAX_WIRE_REDACT_KEY_LENGTH)
|
|
130
|
+
continue;
|
|
131
|
+
const normalized = trimmed.toLowerCase();
|
|
132
|
+
if (seen.has(normalized))
|
|
133
|
+
continue;
|
|
134
|
+
seen.add(normalized);
|
|
135
|
+
out.push(trimmed);
|
|
136
|
+
if (out.length >= MAX_WIRE_REDACT_KEYS)
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
24
141
|
// High-confidence credential SHAPES, redacted regardless of key name — for scanning body/value text where
|
|
25
142
|
// a secret can sit under a benign key (`{"note":"<jwt>"}`, `<meta content="sk_live_…">`). Deliberately
|
|
26
143
|
// narrow (JWT, known provider prefixes) so it never corrupts legitimate prose the way a broad
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source mapping: how a DOM node is traced back to the line of code that rendered it.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `constants.ts` — these two are read by the build plugins, the browser SDK and the
|
|
5
|
+
* React adapter together, and they change for one reason (the source-pointer feature) rather than
|
|
6
|
+
* for the dozen reasons the wire contract does.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The attribute the build plugin stamps on JSX host elements as `file:line:column`, so the browser SDK
|
|
10
|
+
* and the React adapter can map a DOM node back to its source file (the source-pointer feature, needed
|
|
11
|
+
* on React 19 which dropped _debugSource). Read here by both packages — it was duplicated as a local
|
|
12
|
+
* const in dom/source.ts AND dom/query.ts and inlined as a literal in the React adapter. The stamper
|
|
13
|
+
* (@reticlehq/babel-plugin, separate build tooling) stamps this same literal and MUST match it.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DATA_RETICLE_SOURCE_ATTR = "data-reticle-source";
|
|
16
|
+
/**
|
|
17
|
+
* Compile-time global carrying the project root, so the SDK can report source paths RELATIVE to the
|
|
18
|
+
* repo.
|
|
19
|
+
*
|
|
20
|
+
* React's `_debugSource.fileName` is ABSOLUTE (`/Users/you/app/src/Counter.tsx`), while the babel
|
|
21
|
+
* stamp is repo-relative (`src/Counter.tsx`). Both reach the agent as `source`, so the same product
|
|
22
|
+
* emitted two different path shapes depending on which React version an app happened to be on —
|
|
23
|
+
* and an absolute path from someone else's machine is noise in a report, not a pointer. Defined by
|
|
24
|
+
* the build plugins, which are the only place that knows the root.
|
|
25
|
+
*/
|
|
26
|
+
export declare const RETICLE_ROOT_GLOBAL = "__RETICLE_ROOT__";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source mapping: how a DOM node is traced back to the line of code that rendered it.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `constants.ts` — these two are read by the build plugins, the browser SDK and the
|
|
5
|
+
* React adapter together, and they change for one reason (the source-pointer feature) rather than
|
|
6
|
+
* for the dozen reasons the wire contract does.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The attribute the build plugin stamps on JSX host elements as `file:line:column`, so the browser SDK
|
|
10
|
+
* and the React adapter can map a DOM node back to its source file (the source-pointer feature, needed
|
|
11
|
+
* on React 19 which dropped _debugSource). Read here by both packages — it was duplicated as a local
|
|
12
|
+
* const in dom/source.ts AND dom/query.ts and inlined as a literal in the React adapter. The stamper
|
|
13
|
+
* (@reticlehq/babel-plugin, separate build tooling) stamps this same literal and MUST match it.
|
|
14
|
+
*/
|
|
15
|
+
export const DATA_RETICLE_SOURCE_ATTR = 'data-reticle-source';
|
|
16
|
+
/**
|
|
17
|
+
* Compile-time global carrying the project root, so the SDK can report source paths RELATIVE to the
|
|
18
|
+
* repo.
|
|
19
|
+
*
|
|
20
|
+
* React's `_debugSource.fileName` is ABSOLUTE (`/Users/you/app/src/Counter.tsx`), while the babel
|
|
21
|
+
* stamp is repo-relative (`src/Counter.tsx`). Both reach the agent as `source`, so the same product
|
|
22
|
+
* emitted two different path shapes depending on which React version an app happened to be on —
|
|
23
|
+
* and an absolute path from someone else's machine is noise in a report, not a pointer. Defined by
|
|
24
|
+
* the build plugins, which are the only place that knows the root.
|
|
25
|
+
*/
|
|
26
|
+
export const RETICLE_ROOT_GLOBAL = '__RETICLE_ROOT__';
|
package/dist/state-select.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ export interface PathSelection {
|
|
|
11
11
|
value: unknown;
|
|
12
12
|
/** On a miss: the keys present at the deepest level reached (so the agent can correct the path). */
|
|
13
13
|
availableKeys?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* On a miss where `availableKeys` is a SAMPLE: how many keys were really there.
|
|
16
|
+
*
|
|
17
|
+
* Present only when the list was cut. `availableKeys` is capped, and without this a 10,000-key
|
|
18
|
+
* store answered a wrong path with 50 names and no sign there were more — so an agent reading it
|
|
19
|
+
* concludes the key it wants does not exist, when it is simply key 51. That reads as the strongest
|
|
20
|
+
* possible negative signal and it is a false one, which is the precise failure this near-miss
|
|
21
|
+
* payload was added to prevent.
|
|
22
|
+
*/
|
|
23
|
+
totalKeys?: number;
|
|
14
24
|
}
|
|
15
25
|
/** Walk `path` (e.g. "captionCache.v3.0.text") into `root`. Empty path returns root unchanged. */
|
|
16
26
|
export declare function selectPath(root: unknown, path: string): PathSelection;
|
package/dist/state-select.js
CHANGED
|
@@ -8,22 +8,39 @@
|
|
|
8
8
|
/** Cap on how many near-miss keys travel in a failed selection — a 10k-key store must not return a
|
|
9
9
|
* 10k-entry array in the error payload (that was the token blowup the near-miss exists to avoid). */
|
|
10
10
|
const MAX_AVAILABLE_KEYS = 50;
|
|
11
|
+
/** The keys at a level, as a bounded sample plus the true count when the sample is short. */
|
|
11
12
|
function keysOf(value) {
|
|
12
|
-
if (Array.isArray(value))
|
|
13
|
-
return
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
return {
|
|
15
|
+
keys: value.slice(0, MAX_AVAILABLE_KEYS).map((_, i) => String(i)),
|
|
16
|
+
total: value.length,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
14
19
|
if (value instanceof Map) {
|
|
15
|
-
const
|
|
20
|
+
const keys = [];
|
|
21
|
+
let total = 0;
|
|
16
22
|
for (const k of value.keys()) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
break;
|
|
23
|
+
total += 1;
|
|
24
|
+
if (typeof k === 'string' && keys.length < MAX_AVAILABLE_KEYS)
|
|
25
|
+
keys.push(k);
|
|
21
26
|
}
|
|
22
|
-
return
|
|
27
|
+
return { keys, total };
|
|
23
28
|
}
|
|
24
|
-
if (typeof value === 'object' && value !== null)
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
if (typeof value === 'object' && value !== null) {
|
|
30
|
+
const all = Object.keys(value);
|
|
31
|
+
return { keys: all.slice(0, MAX_AVAILABLE_KEYS), total: all.length };
|
|
32
|
+
}
|
|
33
|
+
return { keys: [], total: 0 };
|
|
34
|
+
}
|
|
35
|
+
/** A miss, with the sample of keys available where it stopped and the count when that sample is cut. */
|
|
36
|
+
function miss(value) {
|
|
37
|
+
const { keys, total } = keysOf(value);
|
|
38
|
+
return {
|
|
39
|
+
found: false,
|
|
40
|
+
value: null,
|
|
41
|
+
availableKeys: keys,
|
|
42
|
+
...(total > keys.length ? { totalKeys: total } : {}),
|
|
43
|
+
};
|
|
27
44
|
}
|
|
28
45
|
/** Walk `path` (e.g. "captionCache.v3.0.text") into `root`. Empty path returns root unchanged. */
|
|
29
46
|
export function selectPath(root, path) {
|
|
@@ -39,7 +56,7 @@ export function selectPath(root, path) {
|
|
|
39
56
|
index < 0 ||
|
|
40
57
|
String(index) !== segment ||
|
|
41
58
|
index >= current.length) {
|
|
42
|
-
return
|
|
59
|
+
return miss(current);
|
|
43
60
|
}
|
|
44
61
|
current = current[index];
|
|
45
62
|
continue;
|
|
@@ -49,7 +66,7 @@ export function selectPath(root, path) {
|
|
|
49
66
|
current = current.get(segment);
|
|
50
67
|
continue;
|
|
51
68
|
}
|
|
52
|
-
return
|
|
69
|
+
return miss(current);
|
|
53
70
|
}
|
|
54
71
|
// `Object.hasOwn`, not `in`: `in` walks the prototype, so a path segment of `constructor`,
|
|
55
72
|
// `__proto__`, or `toString` reported found:true and returned a function from Object.prototype —
|
|
@@ -59,7 +76,7 @@ export function selectPath(root, path) {
|
|
|
59
76
|
current = current[segment];
|
|
60
77
|
continue;
|
|
61
78
|
}
|
|
62
|
-
return
|
|
79
|
+
return miss(current);
|
|
63
80
|
}
|
|
64
81
|
return { found: true, value: current };
|
|
65
82
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -575,8 +575,8 @@ export declare const RunRecordSchema: z.ZodObject<{
|
|
|
575
575
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
576
576
|
}, "strip", z.ZodTypeAny, {
|
|
577
577
|
status: "pass" | "drift" | "error" | "fail";
|
|
578
|
-
kind: "flow_replay" | "manual";
|
|
579
578
|
at: number;
|
|
579
|
+
kind: "flow_replay" | "manual";
|
|
580
580
|
name: string;
|
|
581
581
|
durationMs?: number | undefined;
|
|
582
582
|
evidence?: {
|
|
@@ -587,8 +587,8 @@ export declare const RunRecordSchema: z.ZodObject<{
|
|
|
587
587
|
summary?: string | undefined;
|
|
588
588
|
}, {
|
|
589
589
|
status: "pass" | "drift" | "error" | "fail";
|
|
590
|
-
kind: "flow_replay" | "manual";
|
|
591
590
|
at: number;
|
|
591
|
+
kind: "flow_replay" | "manual";
|
|
592
592
|
name: string;
|
|
593
593
|
durationMs?: number | undefined;
|
|
594
594
|
evidence?: {
|
|
@@ -654,8 +654,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
|
|
|
654
654
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
655
655
|
}, "strip", z.ZodTypeAny, {
|
|
656
656
|
status: "pass" | "drift" | "error" | "fail";
|
|
657
|
-
kind: "flow_replay" | "manual";
|
|
658
657
|
at: number;
|
|
658
|
+
kind: "flow_replay" | "manual";
|
|
659
659
|
name: string;
|
|
660
660
|
durationMs?: number | undefined;
|
|
661
661
|
evidence?: {
|
|
@@ -666,8 +666,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
|
|
|
666
666
|
summary?: string | undefined;
|
|
667
667
|
}, {
|
|
668
668
|
status: "pass" | "drift" | "error" | "fail";
|
|
669
|
-
kind: "flow_replay" | "manual";
|
|
670
669
|
at: number;
|
|
670
|
+
kind: "flow_replay" | "manual";
|
|
671
671
|
name: string;
|
|
672
672
|
durationMs?: number | undefined;
|
|
673
673
|
evidence?: {
|
|
@@ -680,8 +680,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
|
|
|
680
680
|
}, "strip", z.ZodTypeAny, {
|
|
681
681
|
runs: {
|
|
682
682
|
status: "pass" | "drift" | "error" | "fail";
|
|
683
|
-
kind: "flow_replay" | "manual";
|
|
684
683
|
at: number;
|
|
684
|
+
kind: "flow_replay" | "manual";
|
|
685
685
|
name: string;
|
|
686
686
|
durationMs?: number | undefined;
|
|
687
687
|
evidence?: {
|
|
@@ -699,8 +699,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
|
|
|
699
699
|
}, {
|
|
700
700
|
runs: {
|
|
701
701
|
status: "pass" | "drift" | "error" | "fail";
|
|
702
|
-
kind: "flow_replay" | "manual";
|
|
703
702
|
at: number;
|
|
703
|
+
kind: "flow_replay" | "manual";
|
|
704
704
|
name: string;
|
|
705
705
|
durationMs?: number | undefined;
|
|
706
706
|
evidence?: {
|
|
@@ -378,12 +378,12 @@ export declare const VerificationEvidenceSchema: z.ZodObject<{
|
|
|
378
378
|
kind: z.ZodString;
|
|
379
379
|
summary: z.ZodString;
|
|
380
380
|
}, "strip", z.ZodTypeAny, {
|
|
381
|
-
kind: string;
|
|
382
381
|
at: number;
|
|
382
|
+
kind: string;
|
|
383
383
|
summary: string;
|
|
384
384
|
}, {
|
|
385
|
-
kind: string;
|
|
386
385
|
at: number;
|
|
386
|
+
kind: string;
|
|
387
387
|
summary: string;
|
|
388
388
|
}>, "many">>;
|
|
389
389
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -406,8 +406,8 @@ export declare const VerificationEvidenceSchema: z.ZodObject<{
|
|
|
406
406
|
actual?: unknown;
|
|
407
407
|
}[];
|
|
408
408
|
timeline: {
|
|
409
|
-
kind: string;
|
|
410
409
|
at: number;
|
|
410
|
+
kind: string;
|
|
411
411
|
summary: string;
|
|
412
412
|
}[];
|
|
413
413
|
}, {
|
|
@@ -430,8 +430,8 @@ export declare const VerificationEvidenceSchema: z.ZodObject<{
|
|
|
430
430
|
actual?: unknown;
|
|
431
431
|
}[] | undefined;
|
|
432
432
|
timeline?: {
|
|
433
|
-
kind: string;
|
|
434
433
|
at: number;
|
|
434
|
+
kind: string;
|
|
435
435
|
summary: string;
|
|
436
436
|
}[] | undefined;
|
|
437
437
|
}>;
|
|
@@ -808,12 +808,12 @@ export declare const ReticleVerificationRunSchema: z.ZodObject<{
|
|
|
808
808
|
kind: z.ZodString;
|
|
809
809
|
summary: z.ZodString;
|
|
810
810
|
}, "strip", z.ZodTypeAny, {
|
|
811
|
-
kind: string;
|
|
812
811
|
at: number;
|
|
812
|
+
kind: string;
|
|
813
813
|
summary: string;
|
|
814
814
|
}, {
|
|
815
|
-
kind: string;
|
|
816
815
|
at: number;
|
|
816
|
+
kind: string;
|
|
817
817
|
summary: string;
|
|
818
818
|
}>, "many">>;
|
|
819
819
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -836,8 +836,8 @@ export declare const ReticleVerificationRunSchema: z.ZodObject<{
|
|
|
836
836
|
actual?: unknown;
|
|
837
837
|
}[];
|
|
838
838
|
timeline: {
|
|
839
|
-
kind: string;
|
|
840
839
|
at: number;
|
|
840
|
+
kind: string;
|
|
841
841
|
summary: string;
|
|
842
842
|
}[];
|
|
843
843
|
}, {
|
|
@@ -860,8 +860,8 @@ export declare const ReticleVerificationRunSchema: z.ZodObject<{
|
|
|
860
860
|
actual?: unknown;
|
|
861
861
|
}[] | undefined;
|
|
862
862
|
timeline?: {
|
|
863
|
-
kind: string;
|
|
864
863
|
at: number;
|
|
864
|
+
kind: string;
|
|
865
865
|
summary: string;
|
|
866
866
|
}[] | undefined;
|
|
867
867
|
}>;
|
|
@@ -1009,8 +1009,8 @@ export declare const ReticleVerificationRunSchema: z.ZodObject<{
|
|
|
1009
1009
|
actual?: unknown;
|
|
1010
1010
|
}[];
|
|
1011
1011
|
timeline: {
|
|
1012
|
-
kind: string;
|
|
1013
1012
|
at: number;
|
|
1013
|
+
kind: string;
|
|
1014
1014
|
summary: string;
|
|
1015
1015
|
}[];
|
|
1016
1016
|
};
|
|
@@ -1104,8 +1104,8 @@ export declare const ReticleVerificationRunSchema: z.ZodObject<{
|
|
|
1104
1104
|
actual?: unknown;
|
|
1105
1105
|
}[] | undefined;
|
|
1106
1106
|
timeline?: {
|
|
1107
|
-
kind: string;
|
|
1108
1107
|
at: number;
|
|
1108
|
+
kind: string;
|
|
1109
1109
|
summary: string;
|
|
1110
1110
|
}[] | undefined;
|
|
1111
1111
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "The Reticle foundation: the shared wire contract — types, zod schemas, constants, messages, and the isomorphic kernel that every Reticle package (browser SDK, server, kits, test harness) imports. Depends only on zod.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|