@sagentlab/navarch-runtime 0.1.188 → 0.1.189

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/redact.cjs CHANGED
@@ -5,22 +5,11 @@
5
5
  // session; scrub from report_summary, transcripts, and event payloads before
6
6
  // persistence" — WP-07 owns the runtime-side half of that contract).
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.SecretRegistry = void 0;
8
+ exports.SecretRegistry = exports.SECRET_PATTERNS = void 0;
9
9
  exports.redactText = redactText;
10
- // Keep in sync with lib/navarch/redaction.ts's SECRET_SHAPE_PATTERNS — the
11
- // hosted Pi executor (worker/hosted-pi) shares these shapes for its own
12
- // transcript/progress scrubbing.
13
- const SECRET_PATTERNS = [
14
- /gh[pousr]_[A-Za-z0-9]{20,}/g, // GitHub PAT / OAuth / user-to-server / refresh tokens
15
- /github_pat_[A-Za-z0-9_]{20,}/g, // GitHub fine-grained PAT
16
- /\bpt-[A-Za-z0-9_-]{20,}/g, // Codeup PAT; \b excludes opt-in, {20,} excludes Tailwind pt-4 and locale pt-BR
17
- /nfr_[A-Za-z0-9_-]{43}/g, // Dedicated Figma relay bearer
18
- /nvg_[A-Za-z0-9_-]{20,}(?:\.[A-Za-z0-9_-]{20,})?/g, // Navarch git grant: nvg_<payload>.<sig>
19
- /sk-[A-Za-z0-9-]{20,}/g, // OpenAI-compatible secret keys, incl. DeepSeek `sk-…` (hosted Pi provider)
20
- /\/\/[^/\s:@]+:[^/\s@]+@/g, // basic-auth userinfo in URLs (e.g. x-access-token:…@github.com clones)
21
- /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]+?-----END [A-Z0-9 ]*PRIVATE KEY-----/g,
22
- ];
23
- const REDACTED = "[REDACTED]";
10
+ const redaction_matches_js_1 = require("./redaction-matches.js");
11
+ var redaction_matches_js_2 = require("./redaction-matches.js");
12
+ Object.defineProperty(exports, "SECRET_PATTERNS", { enumerable: true, get: function () { return redaction_matches_js_2.SECRET_PATTERNS; } });
24
13
  /**
25
14
  * Registry of secret values actually issued to a session, populated as soon
26
15
  * as the broker returns them. Kept separate from redactText() so callers can
@@ -50,19 +39,5 @@ exports.SecretRegistry = SecretRegistry;
50
39
  * report_summary, transcripts, event payloads.
51
40
  */
52
41
  function redactText(text, knownSecrets = []) {
53
- let result = text;
54
- for (const value of knownSecrets) {
55
- if (!value)
56
- continue;
57
- result = splitJoin(result, value, REDACTED);
58
- }
59
- for (const pattern of SECRET_PATTERNS) {
60
- result = result.replace(pattern, REDACTED);
61
- }
62
- return result;
63
- }
64
- function splitJoin(haystack, needle, replacement) {
65
- if (!needle)
66
- return haystack;
67
- return haystack.split(needle).join(replacement);
42
+ return (0, redaction_matches_js_1.redactMatches)(text, knownSecrets, true);
68
43
  }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SECRET_PATTERNS = void 0;
4
+ exports.redactMatches = redactMatches;
5
+ // Shared with the App. The Runtime package compiles this .ts module to CommonJS.
6
+ const REDACTED = "[REDACTED]";
7
+ const BASIC_AUTH = /\/\/[^/\s:@]+:[^/\s@]+@/g;
8
+ const PRIVATE_KEY = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]+?-----END [A-Z0-9 ]*PRIVATE KEY-----/g;
9
+ const SHAPES = [
10
+ {
11
+ pattern: /(?<![A-Za-z0-9_-])eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,
12
+ resumeOffset: (match) => match.indexOf(".") + 1,
13
+ },
14
+ {
15
+ pattern: /gh[pousr]_[A-Za-z0-9]{20,}/g,
16
+ // A GitHub token body can end in the letters of another token's prefix.
17
+ resumeOffset: (match) => match.length - 3,
18
+ },
19
+ { pattern: /github_pat_[A-Za-z0-9_]{20,}/g },
20
+ { pattern: /\bpt-[A-Za-z0-9_-]{20,}/g }, // Excludes opt-in, pt-4 and pt-BR
21
+ { pattern: /nfr_[A-Za-z0-9_-]{43}/g, resumeOffset: () => 1 },
22
+ {
23
+ pattern: /nvg_[A-Za-z0-9_-]{20,}(?:\.[A-Za-z0-9_-]{20,})?/g,
24
+ // A grant that starts in the second segment can have its own signature.
25
+ resumeOffset: (match) => match.includes(".") ? match.indexOf(".") + 1 : match.length,
26
+ },
27
+ { pattern: /sk-[A-Za-z0-9_-]{20,}/g }, // API keys and Claude setup tokens
28
+ { pattern: BASIC_AUTH },
29
+ {
30
+ pattern: PRIVATE_KEY,
31
+ // Nested blocks share the same closing delimiter, except when the last
32
+ // opening delimiter touches it and needs a later end to match a body.
33
+ resumeOffset: (match) => Math.max(1, match.lastIndexOf("-----BEGIN ")),
34
+ },
35
+ ];
36
+ exports.SECRET_PATTERNS = SHAPES.map(({ pattern }) => pattern);
37
+ function appendSpan(spans, previous, start, end) {
38
+ if (previous && start < previous.end) {
39
+ previous.end = Math.max(previous.end, end);
40
+ return previous;
41
+ }
42
+ const span = { start, end };
43
+ spans.push(span);
44
+ return span;
45
+ }
46
+ function redactMatches(text, literals, includeShapes, preserveBasicAuthDelimiters = false) {
47
+ const spans = [];
48
+ for (const literal of literals) {
49
+ if (!literal)
50
+ continue;
51
+ let previous;
52
+ for (let start = text.indexOf(literal); start !== -1; start = text.indexOf(literal, start + 1)) {
53
+ previous = appendSpan(spans, previous, start, start + literal.length);
54
+ }
55
+ }
56
+ if (includeShapes) {
57
+ for (const { pattern, resumeOffset } of SHAPES) {
58
+ const scanner = new RegExp(pattern);
59
+ const preserveDelimiters = preserveBasicAuthDelimiters && pattern === BASIC_AUTH;
60
+ let previous;
61
+ for (let match = scanner.exec(text); match; match = scanner.exec(text)) {
62
+ previous = appendSpan(spans, previous, match.index + (preserveDelimiters ? 2 : 0), scanner.lastIndex - (preserveDelimiters ? 1 : 0));
63
+ if (resumeOffset)
64
+ scanner.lastIndex = match.index + resumeOffset(match[0]);
65
+ }
66
+ }
67
+ }
68
+ spans.sort((a, b) => a.start - b.start);
69
+ const merged = [];
70
+ let previous;
71
+ for (const { start, end } of spans) {
72
+ previous = appendSpan(merged, previous, start, end);
73
+ }
74
+ let result = "";
75
+ let offset = 0;
76
+ for (const { start, end } of merged) {
77
+ result += text.slice(offset, start) + REDACTED;
78
+ offset = end;
79
+ }
80
+ return result + text.slice(offset);
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sagentlab/navarch-runtime",
3
- "version": "0.1.188",
3
+ "version": "0.1.189",
4
4
  "description": "Navarch machine-side session manager: claims delivery tasks and runs them through local coding agents.",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",