@zenalexa/unicli 0.217.3 → 0.218.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.
Files changed (149) hide show
  1. package/AGENTS.md +51 -194
  2. package/README.md +2 -2
  3. package/README.zh-CN.md +2 -2
  4. package/dist/bin/unicli-mcp.d.ts +10 -0
  5. package/dist/bin/unicli-mcp.d.ts.map +1 -0
  6. package/dist/bin/unicli-mcp.js +10 -0
  7. package/dist/bin/unicli-mcp.js.map +1 -0
  8. package/dist/cli.d.ts.map +1 -1
  9. package/dist/cli.js +12 -1
  10. package/dist/cli.js.map +1 -1
  11. package/dist/commands/auth.d.ts +1 -0
  12. package/dist/commands/auth.d.ts.map +1 -1
  13. package/dist/commands/auth.js +250 -0
  14. package/dist/commands/auth.js.map +1 -1
  15. package/dist/commands/dev.js +1 -0
  16. package/dist/commands/dev.js.map +1 -1
  17. package/dist/commands/health.d.ts.map +1 -1
  18. package/dist/commands/health.js +1 -0
  19. package/dist/commands/health.js.map +1 -1
  20. package/dist/commands/lint.d.ts.map +1 -1
  21. package/dist/commands/lint.js +15 -6
  22. package/dist/commands/lint.js.map +1 -1
  23. package/dist/commands/repair.d.ts +1 -0
  24. package/dist/commands/repair.d.ts.map +1 -1
  25. package/dist/commands/repair.js +103 -61
  26. package/dist/commands/repair.js.map +1 -1
  27. package/dist/engine/chromium-cookies-platform.d.ts +69 -0
  28. package/dist/engine/chromium-cookies-platform.d.ts.map +1 -0
  29. package/dist/engine/chromium-cookies-platform.js +315 -0
  30. package/dist/engine/chromium-cookies-platform.js.map +1 -0
  31. package/dist/engine/chromium-cookies-types.d.ts +26 -0
  32. package/dist/engine/chromium-cookies-types.d.ts.map +1 -0
  33. package/dist/engine/chromium-cookies-types.js +16 -0
  34. package/dist/engine/chromium-cookies-types.js.map +1 -0
  35. package/dist/engine/chromium-cookies.d.ts +56 -0
  36. package/dist/engine/chromium-cookies.d.ts.map +1 -0
  37. package/dist/engine/chromium-cookies.js +361 -0
  38. package/dist/engine/chromium-cookies.js.map +1 -0
  39. package/dist/engine/cookies.d.ts +13 -5
  40. package/dist/engine/cookies.d.ts.map +1 -1
  41. package/dist/engine/cookies.js +55 -9
  42. package/dist/engine/cookies.js.map +1 -1
  43. package/dist/engine/executor.d.ts +8 -0
  44. package/dist/engine/executor.d.ts.map +1 -1
  45. package/dist/engine/executor.js +1 -1
  46. package/dist/engine/executor.js.map +1 -1
  47. package/dist/engine/kernel/execute.d.ts.map +1 -1
  48. package/dist/engine/kernel/execute.js +1 -0
  49. package/dist/engine/kernel/execute.js.map +1 -1
  50. package/dist/engine/repair/quarantine-discovery.d.ts +25 -0
  51. package/dist/engine/repair/quarantine-discovery.d.ts.map +1 -0
  52. package/dist/engine/repair/quarantine-discovery.js +78 -0
  53. package/dist/engine/repair/quarantine-discovery.js.map +1 -0
  54. package/dist/engine/steps/navigate.d.ts +1 -1
  55. package/dist/engine/steps/navigate.d.ts.map +1 -1
  56. package/dist/engine/steps/navigate.js +5 -1
  57. package/dist/engine/steps/navigate.js.map +1 -1
  58. package/dist/engine/template.d.ts +14 -4
  59. package/dist/engine/template.d.ts.map +1 -1
  60. package/dist/engine/template.js +93 -65
  61. package/dist/engine/template.js.map +1 -1
  62. package/dist/engine/verify-row-shape.d.ts +17 -0
  63. package/dist/engine/verify-row-shape.d.ts.map +1 -0
  64. package/dist/engine/verify-row-shape.js +36 -0
  65. package/dist/engine/verify-row-shape.js.map +1 -0
  66. package/dist/fast-path/handlers/adapter.d.ts +15 -0
  67. package/dist/fast-path/handlers/adapter.d.ts.map +1 -0
  68. package/dist/fast-path/handlers/adapter.js +169 -0
  69. package/dist/fast-path/handlers/adapter.js.map +1 -0
  70. package/dist/fast-path/handlers/discovery.d.ts +14 -0
  71. package/dist/fast-path/handlers/discovery.d.ts.map +1 -0
  72. package/dist/fast-path/handlers/discovery.js +280 -0
  73. package/dist/fast-path/handlers/discovery.js.map +1 -0
  74. package/dist/fast-path/manifest.d.ts +47 -0
  75. package/dist/fast-path/manifest.d.ts.map +1 -0
  76. package/dist/fast-path/manifest.js +32 -0
  77. package/dist/fast-path/manifest.js.map +1 -0
  78. package/dist/fast-path/parsed-argv.d.ts +16 -0
  79. package/dist/fast-path/parsed-argv.d.ts.map +1 -0
  80. package/dist/fast-path/parsed-argv.js +6 -0
  81. package/dist/fast-path/parsed-argv.js.map +1 -0
  82. package/dist/fast-path/policy.d.ts +25 -0
  83. package/dist/fast-path/policy.d.ts.map +1 -0
  84. package/dist/fast-path/policy.js +96 -0
  85. package/dist/fast-path/policy.js.map +1 -0
  86. package/dist/fast-path/render.d.ts +26 -0
  87. package/dist/fast-path/render.d.ts.map +1 -0
  88. package/dist/fast-path/render.js +200 -0
  89. package/dist/fast-path/render.js.map +1 -0
  90. package/dist/fast-path.d.ts +8 -10
  91. package/dist/fast-path.d.ts.map +1 -1
  92. package/dist/fast-path.js +66 -810
  93. package/dist/fast-path.js.map +1 -1
  94. package/dist/manifest.json +7 -6
  95. package/dist/transport/adapters/cdp-browser.d.ts +6 -6
  96. package/dist/transport/adapters/cdp-browser.js +7 -7
  97. package/dist/transport/adapters/cdp-browser.js.map +1 -1
  98. package/dist/transport/adapters/subprocess.d.ts +4 -4
  99. package/dist/transport/adapters/subprocess.js +4 -4
  100. package/package.json +22 -8
  101. package/server.json +44 -0
  102. package/skills/README.md +39 -0
  103. package/skills/talk-normal/SKILL.md +25 -0
  104. package/skills/talk-normal/prompt.md +35 -0
  105. package/skills/unicli/SKILL.md +389 -0
  106. package/skills/unicli/references/auth.md +188 -0
  107. package/skills/unicli/references/output.md +238 -0
  108. package/skills/unicli/references/sites.md +259 -0
  109. package/skills/unicli-browser/SKILL.md +99 -0
  110. package/skills/unicli-claude-code/SKILL.md +172 -0
  111. package/skills/unicli-explorer/SKILL.md +90 -0
  112. package/skills/unicli-hermes/SKILL.md +83 -0
  113. package/skills/unicli-oneshot/SKILL.md +59 -0
  114. package/skills/unicli-operate/SKILL.md +113 -0
  115. package/skills/unicli-repair/SKILL.md +209 -0
  116. package/skills/unicli-repair/references/error-codes.md +149 -0
  117. package/skills/unicli-repair/references/yaml-patches.md +321 -0
  118. package/skills/unicli-smart-search/SKILL.md +80 -0
  119. package/skills/unicli-usage/SKILL.md +65 -0
  120. package/src/adapters/adguardhome/rules.yaml +1 -1
  121. package/src/adapters/adguardhome/stats.yaml +1 -1
  122. package/src/adapters/adguardhome/status.yaml +1 -1
  123. package/src/adapters/apple-music/rate-album.yaml +1 -2
  124. package/src/adapters/arxiv/trending.yaml +1 -1
  125. package/src/adapters/az/account.yaml +1 -1
  126. package/src/adapters/coupang/hot.yaml +2 -1
  127. package/src/adapters/ctrip/hot.yaml +2 -1
  128. package/src/adapters/ctrip/search.yaml +2 -1
  129. package/src/adapters/douban/top250.yaml +1 -1
  130. package/src/adapters/figma/export-selected.yaml +1 -2
  131. package/src/adapters/gcloud/projects.yaml +1 -1
  132. package/src/adapters/github-trending/developers.yaml +1 -1
  133. package/src/adapters/github-trending/weekly.yaml +1 -1
  134. package/src/adapters/homebrew/search.yaml +1 -1
  135. package/src/adapters/imdb/top.yaml +1 -1
  136. package/src/adapters/itch-io/popular.yaml +1 -1
  137. package/src/adapters/itch-io/top.yaml +1 -1
  138. package/src/adapters/mastodon/timeline.yaml +1 -1
  139. package/src/adapters/openrouter/search.yaml +1 -1
  140. package/src/adapters/pypi/search.yaml +2 -1
  141. package/src/adapters/sspai/hot.yaml +4 -1
  142. package/src/adapters/sspai/latest.yaml +3 -3
  143. package/src/adapters/tieba/hot.yaml +1 -1
  144. package/src/adapters/wikipedia/today.yaml +1 -1
  145. package/src/adapters/zoom/toggle-mute.yaml +1 -2
  146. package/dist/engine/yaml-runner.d.ts +0 -11
  147. package/dist/engine/yaml-runner.d.ts.map +0 -1
  148. package/dist/engine/yaml-runner.js +0 -18
  149. package/dist/engine/yaml-runner.js.map +0 -1
@@ -2,94 +2,136 @@
2
2
  * Repair command — self-repair broken adapters using AI.
3
3
  *
4
4
  * unicli repair <site> [command] [options]
5
+ * unicli repair --quarantined (enumerate quarantine list)
5
6
  */
6
7
  import { readFileSync } from "node:fs";
7
8
  import chalk from "chalk";
8
- import { buildDefaultConfig } from "../engine/repair/config.js";
9
+ import { buildDefaultConfig, } from "../engine/repair/config.js";
9
10
  import { runRepairLoop } from "../engine/repair/engine.js";
10
11
  import { runEval } from "../engine/repair/eval.js";
12
+ import { discoverQuarantinedAdapters } from "../engine/repair/quarantine-discovery.js";
11
13
  import { format, detectFormat } from "../output/formatter.js";
12
14
  import { makeCtx } from "../output/envelope.js";
13
15
  import { errorTypeToCode, mapErrorToExitCode } from "../output/error-map.js";
16
+ function emitQuarantinedList(rctx) {
17
+ const { adapters, parse_errors } = discoverQuarantinedAdapters();
18
+ const data = {
19
+ mode: "quarantined-list",
20
+ count: adapters.length,
21
+ adapters: adapters.map((q) => ({
22
+ site: q.site,
23
+ command: q.name,
24
+ reason: q.reason,
25
+ adapter_path: q.adapter_path,
26
+ quarantined_since: q.quarantined_since ?? null,
27
+ next_action: `unicli repair ${q.site} ${q.name}`,
28
+ })),
29
+ parse_errors,
30
+ };
31
+ rctx.ctx.duration_ms = Date.now() - rctx.startedAt;
32
+ console.log(format(data, undefined, rctx.fmt, rctx.ctx));
33
+ console.error(chalk.dim(`\n ${adapters.length} quarantined adapter(s)` +
34
+ (parse_errors.length > 0
35
+ ? `, ${parse_errors.length} parse error(s) — see parse_errors`
36
+ : "") +
37
+ `. Iterate with "unicli repair <site> <command>" or pipe through xargs.`));
38
+ return 0;
39
+ }
40
+ function emitDryRun(rctx, site, command, config) {
41
+ const data = {
42
+ mode: "dry-run",
43
+ site,
44
+ command: command ?? null,
45
+ config: { ...config, metricPattern: config.metricPattern.source },
46
+ };
47
+ rctx.ctx.duration_ms = Date.now() - rctx.startedAt;
48
+ console.log(format(data, undefined, rctx.fmt, rctx.ctx));
49
+ console.error(chalk.dim(`\n Dry run — no repairs executed. Max ${config.maxIterations} iterations.`));
50
+ }
51
+ function runEvalSuite(rctx, site, command, evalPath) {
52
+ const raw = readFileSync(evalPath, "utf-8");
53
+ const tasks = JSON.parse(raw);
54
+ const result = runEval(tasks);
55
+ const data = {
56
+ mode: "eval",
57
+ site,
58
+ command: command ?? null,
59
+ score: result.score,
60
+ total: result.total,
61
+ passed: result.score === result.total,
62
+ };
63
+ rctx.ctx.duration_ms = Date.now() - rctx.startedAt;
64
+ console.log(format(data, undefined, rctx.fmt, rctx.ctx));
65
+ console.error(chalk.dim(`\n Eval: ${result.score}/${result.total} passed`));
66
+ return result.score === result.total ? 0 : 1;
67
+ }
68
+ async function runOnceOrLoop(rctx, site, command, config, loop) {
69
+ // Single-repair default wraps one iteration; --loop uses the
70
+ // user-supplied max. Progress output from the loop streams to stderr
71
+ // (Scene-6 pattern); the envelope carries the final summary.
72
+ if (!loop)
73
+ config.maxIterations = 1;
74
+ const result = await runRepairLoop(config);
75
+ const data = {
76
+ mode: loop ? "loop" : "once",
77
+ site,
78
+ command: command ?? null,
79
+ iterations: result.iterations,
80
+ best_metric: result.bestMetric,
81
+ improved: result.improved,
82
+ };
83
+ rctx.ctx.duration_ms = Date.now() - rctx.startedAt;
84
+ console.log(format(data, undefined, rctx.fmt, rctx.ctx));
85
+ console.error(chalk.dim(`\n Repair ${result.improved ? chalk.green("improved") : chalk.yellow("no-improvement")} — ` +
86
+ `${result.iterations} iteration(s), best ${result.bestMetric}`));
87
+ return result.improved ? 0 : 1;
88
+ }
14
89
  export function registerRepairCommand(program) {
15
90
  program
16
- .command("repair <site> [command]")
91
+ .command("repair [site] [command]")
17
92
  .description("Self-repair broken adapters using AI")
18
93
  .option("--loop", "Enable autonomous repair loop")
19
94
  .option("--max <n>", "Max iterations", "20")
20
95
  .option("--timeout <s>", "Per-iteration timeout (seconds)", "90")
21
96
  .option("--eval <file>", "Run eval suite from JSON file")
22
97
  .option("--dry-run", "Show plan without executing")
98
+ .option("--quarantined", "Enumerate every quarantined adapter (ignores <site>/<command>)")
23
99
  .action(async (site, command, opts) => {
24
100
  const startedAt = Date.now();
25
101
  const ctx = makeCtx("repair.run", startedAt);
26
102
  const programOpts = program.opts();
27
103
  const fmt = detectFormat(programOpts.format);
28
- // Declared outside try/catch because the success-path process.exit()
29
- // must NOT be re-caught and remapped by the error handler (doing so
30
- // turns exit(0) into exit(1) when tests stub process.exit to throw).
104
+ const rctx = { ctx, fmt, startedAt };
105
+ // Compute exit code at the end so the success-path process.exit()
106
+ // doesn't pass through the error handler's catch (test harnesses
107
+ // stub process.exit to throw, which would remap exit 0 to 1).
31
108
  let successExitCode = null;
32
109
  try {
33
- const config = buildDefaultConfig(site, command);
34
- config.maxIterations = parseInt(opts.max ?? "", 10) || 20;
35
- config.timeout = (parseInt(opts.timeout ?? "", 10) || 90) * 1000;
36
- const isDryRun = opts["dry-run"] !== undefined ||
37
- opts.dryRun !== undefined ||
38
- programOpts["dry-run"] !== undefined ||
39
- programOpts.dryRun !== undefined;
40
- if (isDryRun) {
41
- const data = {
42
- mode: "dry-run",
43
- site,
44
- command: command ?? null,
45
- config: {
46
- ...config,
47
- metricPattern: config.metricPattern.source,
48
- },
49
- };
50
- ctx.duration_ms = Date.now() - startedAt;
51
- console.log(format(data, undefined, fmt, ctx));
52
- console.error(chalk.dim(`\n Dry run — no repairs executed. Max ${config.maxIterations} iterations.`));
53
- return;
110
+ if (opts.quarantined === true) {
111
+ successExitCode = emitQuarantinedList(rctx);
54
112
  }
55
- if (opts.eval) {
56
- const raw = readFileSync(opts.eval, "utf-8");
57
- const tasks = JSON.parse(raw);
58
- const result = runEval(tasks);
59
- const data = {
60
- mode: "eval",
61
- site,
62
- command: command ?? null,
63
- score: result.score,
64
- total: result.total,
65
- passed: result.score === result.total,
66
- };
67
- ctx.duration_ms = Date.now() - startedAt;
68
- console.log(format(data, undefined, fmt, ctx));
69
- console.error(chalk.dim(`\n Eval: ${result.score}/${result.total} passed`));
70
- successExitCode = result.score === result.total ? 0 : 1;
113
+ else if (!site) {
114
+ console.error(chalk.red("error: missing required argument 'site' (use --quarantined to enumerate the quarantine list)"));
115
+ process.exit(2);
71
116
  }
72
117
  else {
73
- // Single-repair default wraps one iteration; --loop uses the
74
- // user-supplied max. Progress output from the loop streams to
75
- // stderr (Scene-6 pattern); the envelope carries the final summary.
76
- if (opts.loop === undefined) {
77
- config.maxIterations = 1;
118
+ const config = buildDefaultConfig(site, command);
119
+ config.maxIterations = parseInt(opts.max ?? "", 10) || 20;
120
+ config.timeout = (parseInt(opts.timeout ?? "", 10) || 90) * 1000;
121
+ const isDryRun = opts["dry-run"] !== undefined ||
122
+ opts.dryRun !== undefined ||
123
+ programOpts["dry-run"] !== undefined ||
124
+ programOpts.dryRun !== undefined;
125
+ if (isDryRun) {
126
+ emitDryRun(rctx, site, command, config);
127
+ return;
128
+ }
129
+ if (opts.eval) {
130
+ successExitCode = runEvalSuite(rctx, site, command, opts.eval);
131
+ }
132
+ else {
133
+ successExitCode = await runOnceOrLoop(rctx, site, command, config, opts.loop !== undefined);
78
134
  }
79
- const result = await runRepairLoop(config);
80
- const data = {
81
- mode: opts.loop !== undefined ? "loop" : "once",
82
- site,
83
- command: command ?? null,
84
- iterations: result.iterations,
85
- best_metric: result.bestMetric,
86
- improved: result.improved,
87
- };
88
- ctx.duration_ms = Date.now() - startedAt;
89
- console.log(format(data, undefined, fmt, ctx));
90
- console.error(chalk.dim(`\n Repair ${result.improved ? chalk.green("improved") : chalk.yellow("no-improvement")} — ` +
91
- `${result.iterations} iteration(s), best ${result.bestMetric}`));
92
- successExitCode = result.improved ? 0 : 1;
93
135
  }
94
136
  }
95
137
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"repair.js","sourceRoot":"","sources":["../../src/commands/repair.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,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AAI,CAAC,IAAI,CAAC,CAAC;gBACjE,CAAC;qBAAM,CAAC;oBACN,eAAe,GAAG,MAAM,aAAa,CACnC,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,MAAM,EACN,IAAI,CAAC,IAAI,KAAK,SAAS,CACxB,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,GAAG,CAAC,KAAK,GAAG;gBACV,IAAI,EAAE,eAAe,CAAC,GAAG,CAAC;gBAC1B,OAAO;gBACP,UAAU,EACR,qEAAqE;gBACvE,SAAS,EAAE,KAAK;aACjB,CAAC;YACF,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACzC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,eAAe,KAAK,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC9D,CAAC,CACF,CAAC;AACN,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Per-platform Chromium cookie key derivation, keystore lookup, and decrypt.
3
+ *
4
+ * The three platforms diverge meaningfully:
5
+ *
6
+ * macOS — Keychain `security` CLI → password (≤24 ASCII chars)
7
+ * PBKDF2-SHA1(saltysalt, 1003, 16) → 16-byte AES key
8
+ * v10/v11 prefix + AES-128-CBC + IV=16×0x20 + PKCS7
9
+ * 32-byte SHA256 integrity prefix on plaintext (M122+)
10
+ *
11
+ * Linux — libsecret/KWallet via `secret-tool` → password
12
+ * fallback to literal "peanuts" if no keyring (Chromium HEAD)
13
+ * PBKDF2-SHA1(saltysalt, **1**, 16) → 16-byte AES key (CRITICAL)
14
+ * v10/v11 prefix + AES-128-CBC + IV=16×0x20 + PKCS7
15
+ * NO integrity prefix
16
+ *
17
+ * Windows — `Local State` → os_crypt.encrypted_key (base64)
18
+ * strip "DPAPI" 5-byte prefix
19
+ * CryptUnprotectData(CurrentUser) via PowerShell → 32-byte master
20
+ * v10 prefix + 12-byte nonce + AES-256-GCM(ct + 16-byte tag, master)
21
+ * 32-byte SHA256 integrity prefix on plaintext
22
+ * v20 (Chrome 127+ App-Bound Encryption) is BLOCKED for external
23
+ * processes by design; we surface encryption_unsupported and
24
+ * suggest CDP fallback rather than ship a brittle bypass.
25
+ *
26
+ * All three platforms validate the prefix bytes to detect format drift early.
27
+ */
28
+ import { type BrowserId } from "./chromium-cookies-types.js";
29
+ export type Platform = "darwin" | "linux" | "win32";
30
+ export declare function currentPlatform(): Platform;
31
+ interface KeystoreSpec {
32
+ /** macOS: Keychain service labels to probe in order. */
33
+ macLabels?: readonly string[];
34
+ /** macOS: Keychain account candidates per label. */
35
+ macAccounts?: readonly string[];
36
+ /** Linux: secret-tool `application` attribute. */
37
+ linuxApp?: string;
38
+ /** Linux: secret-tool xdg:schema attribute. */
39
+ linuxSchema?: string;
40
+ /**
41
+ * Windows: Local State path relative to the user-data root. Each browser
42
+ * stores its master key here; we read it once and feed DPAPI.
43
+ */
44
+ winLocalStateRel?: string;
45
+ }
46
+ export declare function _resetSecretCache(): void;
47
+ export declare function getEncryptionSecret(browser: BrowserId, platform: Platform, spec: KeystoreSpec, userDataRoot: string): Buffer | string;
48
+ /**
49
+ * Derive the AES key from the platform secret. macOS uses 1003 PBKDF2
50
+ * iterations; Linux uses **1** iteration (Chromium's
51
+ * `kEncryptionIterations = 1` for `freedesktop_secret_key_provider.cc`).
52
+ * Windows passes through — DPAPI already returned a 32-byte master.
53
+ */
54
+ export declare function deriveKey(secret: Buffer | string, platform: Platform): Buffer;
55
+ /**
56
+ * Decrypt a single Chromium-encrypted cookie value.
57
+ *
58
+ * • Empty buffer → empty string
59
+ * • No `vNN` prefix → raw bytes (legacy unencrypted)
60
+ * • `v10`/`v11` macOS → AES-128-CBC, strip 32-byte SHA256 prefix when present
61
+ * • `v10`/`v11` Linux → AES-128-CBC, NO integrity prefix
62
+ * • `v10` Win → AES-256-GCM with 12-byte nonce + 16-byte tag,
63
+ * strip 32-byte SHA256 prefix
64
+ * • `v20` Win → encryption_unsupported (App-Bound Encryption)
65
+ */
66
+ export declare function decryptValue(encrypted: Buffer, key: Buffer, platform: Platform): string;
67
+ export declare const KEYSTORE_SPECS: Record<BrowserId, KeystoreSpec>;
68
+ export {};
69
+ //# sourceMappingURL=chromium-cookies-platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chromium-cookies-platform.d.ts","sourceRoot":"","sources":["../../src/engine/chromium-cookies-platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAEpD,wBAAgB,eAAe,IAAI,QAAQ,CAQ1C;AAMD,UAAU,YAAY;IACpB,wDAAwD;IACxD,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,oDAAoD;IACpD,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAcD,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,MAAM,CAkBjB;AAgJD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAsB7E;AASD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAmCR;AAkDD,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,CAwC1D,CAAC"}
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Per-platform Chromium cookie key derivation, keystore lookup, and decrypt.
3
+ *
4
+ * The three platforms diverge meaningfully:
5
+ *
6
+ * macOS — Keychain `security` CLI → password (≤24 ASCII chars)
7
+ * PBKDF2-SHA1(saltysalt, 1003, 16) → 16-byte AES key
8
+ * v10/v11 prefix + AES-128-CBC + IV=16×0x20 + PKCS7
9
+ * 32-byte SHA256 integrity prefix on plaintext (M122+)
10
+ *
11
+ * Linux — libsecret/KWallet via `secret-tool` → password
12
+ * fallback to literal "peanuts" if no keyring (Chromium HEAD)
13
+ * PBKDF2-SHA1(saltysalt, **1**, 16) → 16-byte AES key (CRITICAL)
14
+ * v10/v11 prefix + AES-128-CBC + IV=16×0x20 + PKCS7
15
+ * NO integrity prefix
16
+ *
17
+ * Windows — `Local State` → os_crypt.encrypted_key (base64)
18
+ * strip "DPAPI" 5-byte prefix
19
+ * CryptUnprotectData(CurrentUser) via PowerShell → 32-byte master
20
+ * v10 prefix + 12-byte nonce + AES-256-GCM(ct + 16-byte tag, master)
21
+ * 32-byte SHA256 integrity prefix on plaintext
22
+ * v20 (Chrome 127+ App-Bound Encryption) is BLOCKED for external
23
+ * processes by design; we surface encryption_unsupported and
24
+ * suggest CDP fallback rather than ship a brittle bypass.
25
+ *
26
+ * All three platforms validate the prefix bytes to detect format drift early.
27
+ */
28
+ import { execFileSync } from "node:child_process";
29
+ import { existsSync, readFileSync } from "node:fs";
30
+ import { join } from "node:path";
31
+ import { createDecipheriv, pbkdf2Sync } from "node:crypto";
32
+ import { ChromiumCookieError, } from "./chromium-cookies-types.js";
33
+ export function currentPlatform() {
34
+ const p = process.platform;
35
+ if (p === "darwin" || p === "linux" || p === "win32")
36
+ return p;
37
+ throw new ChromiumCookieError("encryption_unsupported", `unsupported platform: ${p}`, "Direct cookie reads work on macOS, Linux, and Windows. Use CDP fallback elsewhere.");
38
+ }
39
+ /**
40
+ * Look up a browser's encryption secret. Returns either a passphrase string
41
+ * (macOS / Linux) or a 32-byte master key Buffer (Windows). The caller's
42
+ * `deriveKey` knows which to expect based on the platform.
43
+ *
44
+ * Result is memoized per (browser, platform, userDataRoot) for the lifetime
45
+ * of the process — Keychain prompts and DPAPI calls cost ~30-100 ms each, so
46
+ * an audit walking 135 adapters with the same browser would otherwise spend
47
+ * seconds re-fetching the same secret. Tests can clear via `_resetSecretCache`.
48
+ */
49
+ const secretCache = new Map();
50
+ export function _resetSecretCache() {
51
+ secretCache.clear();
52
+ }
53
+ export function getEncryptionSecret(browser, platform, spec, userDataRoot) {
54
+ const cacheKey = `${platform}:${browser}:${userDataRoot}`;
55
+ const cached = secretCache.get(cacheKey);
56
+ if (cached)
57
+ return cached;
58
+ let secret;
59
+ switch (platform) {
60
+ case "darwin":
61
+ secret = macSecurityLookup(browser, spec);
62
+ break;
63
+ case "linux":
64
+ secret = linuxSecretLookup(browser, spec);
65
+ break;
66
+ case "win32":
67
+ secret = winDpapiLookup(browser, spec, userDataRoot);
68
+ break;
69
+ }
70
+ secretCache.set(cacheKey, secret);
71
+ return secret;
72
+ }
73
+ /* macOS ------------------------------------------------------------------- */
74
+ function macSecurityLookup(browser, spec) {
75
+ const labels = spec.macLabels ?? [];
76
+ const accounts = spec.macAccounts ?? [];
77
+ let lastError = "";
78
+ for (const label of labels) {
79
+ for (const account of accounts) {
80
+ try {
81
+ const args = ["find-generic-password", "-w", "-s", label];
82
+ if (account)
83
+ args.push("-a", account);
84
+ const out = execFileSync("/usr/bin/security", args, {
85
+ encoding: "utf8",
86
+ stdio: ["ignore", "pipe", "pipe"],
87
+ });
88
+ const trimmed = out.trim();
89
+ if (trimmed)
90
+ return trimmed;
91
+ }
92
+ catch (err) {
93
+ lastError = err.message;
94
+ }
95
+ }
96
+ }
97
+ throw new ChromiumCookieError("keychain_denied", `no Safe Storage password for ${browser}: ${lastError || "not found"}`, `Try: security find-generic-password -wa "${accounts[0] ?? browser}" -s "${labels[0] ?? `${browser} Safe Storage`}"`);
98
+ }
99
+ /* Linux ------------------------------------------------------------------- */
100
+ function linuxSecretLookup(_browser, spec) {
101
+ const app = spec.linuxApp;
102
+ const schema = spec.linuxSchema ?? "chrome_libsecret_os_crypt_password_v2";
103
+ if (app) {
104
+ try {
105
+ const out = execFileSync("secret-tool", ["lookup", "application", app, "xdg:schema", schema], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
106
+ const trimmed = out.trim();
107
+ if (trimmed)
108
+ return trimmed;
109
+ }
110
+ catch {
111
+ // Fall through to peanuts — secret-tool missing or no entry.
112
+ }
113
+ }
114
+ // Chromium HEAD `posix_key_provider.cc` literal: when no keyring backend is
115
+ // available, the v10 password is the ASCII string "peanuts". That gives us
116
+ // best-effort access on headless boxes / containers without a keyring.
117
+ return "peanuts";
118
+ }
119
+ /* Windows ----------------------------------------------------------------- */
120
+ function winDpapiLookup(browser, spec, userDataRoot) {
121
+ const localStateRel = spec.winLocalStateRel ?? "Local State";
122
+ const localStatePath = join(userDataRoot, localStateRel);
123
+ if (!existsSync(localStatePath)) {
124
+ throw new ChromiumCookieError("keychain_denied", `${browser}: Local State not found at ${localStatePath}`, "Open the browser at least once so it writes its master key, then retry.");
125
+ }
126
+ let parsed;
127
+ try {
128
+ parsed = JSON.parse(readFileSync(localStatePath, "utf8"));
129
+ }
130
+ catch (err) {
131
+ throw new ChromiumCookieError("keychain_denied", `${browser}: cannot parse Local State: ${err.message}`, "Local State is corrupt; close the browser and retry, or reset the profile.");
132
+ }
133
+ const enc = parsed.os_crypt?.encrypted_key;
134
+ if (!enc) {
135
+ throw new ChromiumCookieError("keychain_denied", `${browser}: Local State has no os_crypt.encrypted_key`, "The browser hasn't written a v10 master key. Sign into a site once, then retry.");
136
+ }
137
+ const wrapped = Buffer.from(enc, "base64");
138
+ // Strip "DPAPI" (5-byte prefix added since M55).
139
+ if (wrapped.length < 5 ||
140
+ wrapped.subarray(0, 5).toString("ascii") !== "DPAPI") {
141
+ throw new ChromiumCookieError("encryption_unsupported", `${browser}: encrypted_key missing DPAPI prefix`, "Likely an app-bound (v20) install. Use CDP via `unicli browser start`.");
142
+ }
143
+ const ciphertext = wrapped.subarray(5);
144
+ return dpapiUnprotect(ciphertext);
145
+ }
146
+ /**
147
+ * Run DPAPI CryptUnprotectData(CurrentUser) without a native module.
148
+ * Shells PowerShell to call `[System.Security.Cryptography.ProtectedData]`.
149
+ * Slow (~80 ms) but zero-install.
150
+ */
151
+ function dpapiUnprotect(ciphertext) {
152
+ const b64 = ciphertext.toString("base64");
153
+ const ps = [
154
+ "$ErrorActionPreference='Stop'",
155
+ "Add-Type -AssemblyName System.Security",
156
+ `$b=[Convert]::FromBase64String('${b64}')`,
157
+ "$p=[System.Security.Cryptography.ProtectedData]::Unprotect($b,$null,'CurrentUser')",
158
+ "[Convert]::ToBase64String($p)",
159
+ ].join(";");
160
+ let out;
161
+ try {
162
+ out = execFileSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", ps], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
163
+ }
164
+ catch (err) {
165
+ throw new ChromiumCookieError("decrypt_failed", `DPAPI unprotect failed: ${err.message}`, "Run as the same user that owns the profile. Cross-user DPAPI is intentionally blocked.");
166
+ }
167
+ return Buffer.from(out.trim(), "base64");
168
+ }
169
+ /* -------------------------------------------------------------------------- */
170
+ /* Key derivation */
171
+ /* -------------------------------------------------------------------------- */
172
+ const SALT = "saltysalt";
173
+ const KEY_LEN_128 = 16;
174
+ const KEY_LEN_256 = 32;
175
+ /**
176
+ * Derive the AES key from the platform secret. macOS uses 1003 PBKDF2
177
+ * iterations; Linux uses **1** iteration (Chromium's
178
+ * `kEncryptionIterations = 1` for `freedesktop_secret_key_provider.cc`).
179
+ * Windows passes through — DPAPI already returned a 32-byte master.
180
+ */
181
+ export function deriveKey(secret, platform) {
182
+ if (platform === "win32") {
183
+ if (typeof secret === "string") {
184
+ throw new ChromiumCookieError("decrypt_failed", "Windows expects a 32-byte master key, got a string", "This is an internal bug; report it.");
185
+ }
186
+ if (secret.length !== KEY_LEN_256) {
187
+ throw new ChromiumCookieError("decrypt_failed", `Windows master key has unexpected length ${secret.length} (want 32)`, "Likely a corrupted Local State; reset the browser profile.");
188
+ }
189
+ return secret;
190
+ }
191
+ const password = typeof secret === "string" ? secret : secret.toString("utf8");
192
+ const iterations = platform === "darwin" ? 1003 : 1;
193
+ return pbkdf2Sync(password, SALT, iterations, KEY_LEN_128, "sha1");
194
+ }
195
+ /* -------------------------------------------------------------------------- */
196
+ /* Decrypt */
197
+ /* -------------------------------------------------------------------------- */
198
+ const IV_CBC = Buffer.alloc(16, 0x20);
199
+ const INTEGRITY_PREFIX_LEN = 32;
200
+ /**
201
+ * Decrypt a single Chromium-encrypted cookie value.
202
+ *
203
+ * • Empty buffer → empty string
204
+ * • No `vNN` prefix → raw bytes (legacy unencrypted)
205
+ * • `v10`/`v11` macOS → AES-128-CBC, strip 32-byte SHA256 prefix when present
206
+ * • `v10`/`v11` Linux → AES-128-CBC, NO integrity prefix
207
+ * • `v10` Win → AES-256-GCM with 12-byte nonce + 16-byte tag,
208
+ * strip 32-byte SHA256 prefix
209
+ * • `v20` Win → encryption_unsupported (App-Bound Encryption)
210
+ */
211
+ export function decryptValue(encrypted, key, platform) {
212
+ if (encrypted.length === 0)
213
+ return "";
214
+ const prefix = encrypted.subarray(0, 3).toString("ascii");
215
+ if (prefix !== "v10" && prefix !== "v11") {
216
+ if (/^v\d/.test(prefix)) {
217
+ throw new ChromiumCookieError("encryption_unsupported", `unsupported cookie encryption version "${prefix}"` +
218
+ (prefix === "v20"
219
+ ? " (Chrome 127+ App-Bound Encryption blocks external decrypt)"
220
+ : ""), prefix === "v20"
221
+ ? "Use CDP: `unicli browser start` then `unicli auth import` once Chrome is logged in."
222
+ : "Open the site in your browser and try CDP fallback, or downgrade the browser.");
223
+ }
224
+ return encrypted.toString("utf8");
225
+ }
226
+ const body = encrypted.subarray(3);
227
+ const plain = platform === "win32" ? decryptGcm(body, key) : decryptCbc(body, key);
228
+ // macOS + Windows prepend a 32-byte SHA256 integrity hash before the value.
229
+ // Linux does not. Heuristic: if the first 32 bytes contain any non-printable
230
+ // byte (the SHA256 of any value almost always does), strip them. ASCII-only
231
+ // first 32 bytes are almost surely real cookie content.
232
+ if (platform !== "linux" &&
233
+ plain.length >= INTEGRITY_PREFIX_LEN &&
234
+ hasNonPrintable(plain.subarray(0, INTEGRITY_PREFIX_LEN))) {
235
+ return plain.subarray(INTEGRITY_PREFIX_LEN).toString("utf8");
236
+ }
237
+ return plain.toString("utf8");
238
+ }
239
+ function decryptCbc(ciphertext, key) {
240
+ const decipher = createDecipheriv("aes-128-cbc", key, IV_CBC);
241
+ try {
242
+ return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
243
+ }
244
+ catch (err) {
245
+ throw new ChromiumCookieError("decrypt_failed", `AES-128-CBC decrypt failed: ${err.message}`, "The Keychain key may be wrong; revoke and re-grant Keychain access.");
246
+ }
247
+ }
248
+ function decryptGcm(ciphertext, key) {
249
+ if (ciphertext.length < 12 + 16) {
250
+ throw new ChromiumCookieError("decrypt_failed", `GCM ciphertext too short (${ciphertext.length} bytes)`, "Cookie blob is malformed; the Cookies DB may be corrupt.");
251
+ }
252
+ const nonce = ciphertext.subarray(0, 12);
253
+ const tag = ciphertext.subarray(ciphertext.length - 16);
254
+ const ct = ciphertext.subarray(12, ciphertext.length - 16);
255
+ const decipher = createDecipheriv("aes-256-gcm", key, nonce);
256
+ decipher.setAuthTag(tag);
257
+ try {
258
+ return Buffer.concat([decipher.update(ct), decipher.final()]);
259
+ }
260
+ catch (err) {
261
+ throw new ChromiumCookieError("decrypt_failed", `AES-256-GCM decrypt failed: ${err.message}`, "The DPAPI master key may be wrong (cross-user DPAPI is blocked) or this is a v20 cookie.");
262
+ }
263
+ }
264
+ function hasNonPrintable(buf) {
265
+ for (const b of buf) {
266
+ if (b < 0x20 || b > 0x7e)
267
+ return true;
268
+ }
269
+ return false;
270
+ }
271
+ /* -------------------------------------------------------------------------- */
272
+ /* Per-browser keystore specs */
273
+ /* -------------------------------------------------------------------------- */
274
+ export const KEYSTORE_SPECS = {
275
+ chrome: {
276
+ macLabels: ["Chrome Safe Storage"],
277
+ macAccounts: ["Chrome"],
278
+ linuxApp: "chrome",
279
+ winLocalStateRel: "Local State",
280
+ },
281
+ brave: {
282
+ macLabels: ["Brave Safe Storage"],
283
+ macAccounts: ["Brave"],
284
+ linuxApp: "brave",
285
+ winLocalStateRel: "Local State",
286
+ },
287
+ edge: {
288
+ macLabels: ["Microsoft Edge Safe Storage"],
289
+ macAccounts: ["Microsoft Edge"],
290
+ linuxApp: "microsoft-edge",
291
+ winLocalStateRel: "Local State",
292
+ },
293
+ arc: {
294
+ macLabels: ["Arc Safe Storage"],
295
+ macAccounts: ["Arc"],
296
+ // No Linux/Windows Arc build as of 2026-05.
297
+ winLocalStateRel: "Local State",
298
+ },
299
+ dia: {
300
+ macLabels: ["Dia Safe Storage"],
301
+ macAccounts: ["Dia"],
302
+ winLocalStateRel: "Local State",
303
+ },
304
+ atlas: {
305
+ macLabels: [
306
+ "Atlas Safe Storage",
307
+ "ChatGPT Atlas Safe Storage",
308
+ "OpenAI Atlas Safe Storage",
309
+ "ChatGPT Safe Storage",
310
+ ],
311
+ macAccounts: ["Atlas", "ChatGPT", "OpenAI"],
312
+ winLocalStateRel: "Local State",
313
+ },
314
+ };
315
+ //# sourceMappingURL=chromium-cookies-platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chromium-cookies-platform.js","sourceRoot":"","sources":["../../src/engine/chromium-cookies-platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,mBAAmB,GAEpB,MAAM,6BAA6B,CAAC;AAIrC,MAAM,UAAU,eAAe;IAC7B,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAC3B,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,CAAC,CAAC;IAC/D,MAAM,IAAI,mBAAmB,CAC3B,wBAAwB,EACxB,yBAAyB,CAAC,EAAE,EAC5B,oFAAoF,CACrF,CAAC;AACJ,CAAC;AAsBD;;;;;;;;;GASG;AACH,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEvD,MAAM,UAAU,iBAAiB;IAC/B,WAAW,CAAC,KAAK,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,OAAkB,EAClB,QAAkB,EAClB,IAAkB,EAClB,YAAoB;IAEpB,MAAM,QAAQ,GAAG,GAAG,QAAQ,IAAI,OAAO,IAAI,YAAY,EAAE,CAAC;IAC1D,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,IAAI,MAAuB,CAAC;IAC5B,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ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