rechrome 1.43.0 → 1.43.2

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/README.md CHANGED
@@ -126,7 +126,8 @@ browser into an auth tool:
126
126
  rech read-cookie d acme.slack.com --allow-domain acme.slack.com | slack auth cookie
127
127
  ```
128
128
 
129
- - Reads via Playwright's `context.cookies()`, so `HttpOnly` cookies are included.
129
+ - Reads via Playwright's `context.cookies()`, so `HttpOnly` cookies are included. It works over the
130
+ extension bridge too: the relay answers the browser-level cookie query through an attached tab.
130
131
  - `--allow-domain` is required, and the cookie's own domain must match it.
131
132
  - Same pipe-only, never-logged, masked-afterwards rules as `read-secret`.
132
133
  - On a shared (scoped) listener it is off until the host runs
package/fill-secret.js CHANGED
@@ -505,13 +505,15 @@ function buildReadCookieCode(name, domain, allowDomains) {
505
505
  const dom = ${JSON.stringify(domain.toLowerCase())}.replace(/^\\./, "");
506
506
  if (!allowed.some(p => new RegExp(p, "i").test(dom)))
507
507
  throw new Error("read-cookie refused: domain " + JSON.stringify(dom) + " is not allowed by --allow-domain");
508
- const url = "https://" + dom + "/";
509
- const cookies = await page.context().cookies([url]);
510
- const match = cookies.filter(c => c.name === ${JSON.stringify(name)} && dom === String(c.domain).replace(/^\\./, "").toLowerCase());
508
+ // All cookies, any path (a URL filter would drop /app-scoped ones). Domain-match per RFC6265:
509
+ // the cookie's own domain is dom, or a parent of dom (a ".slack.com" cookie serves a subdomain).
510
+ const cookies = await page.context().cookies();
511
+ const domainMatches = cd => { cd = String(cd).replace(/^\\./, "").toLowerCase(); return dom === cd || dom.endsWith("." + cd); };
512
+ const match = cookies.filter(c => c.name === ${JSON.stringify(name)} && domainMatches(c.domain));
511
513
  if (!match.length) throw new Error("read-cookie: no cookie " + JSON.stringify(${JSON.stringify(name)}) + " for " + dom + " (is this profile signed in?)");
512
- let value;
513
- try { value = String(match[0].value); } catch { throw new Error("read-cookie: could not read the cookie"); }
514
- return JSON.stringify({ domain: dom, value });
514
+ const values = [...new Set(match.map(c => { try { return String(c.value); } catch { return null; } }))];
515
+ if (values.length !== 1 || values[0] == null) throw new Error("read-cookie: " + match.length + " cookies named " + JSON.stringify(${JSON.stringify(name)}) + " for " + dom + " disagree; narrow the domain");
516
+ return JSON.stringify({ domain: dom, value: values[0] });
515
517
  }`;
516
518
  }
517
519
  async function readCookieOnSession(opts) {
package/fill-secret.ts CHANGED
@@ -512,13 +512,15 @@ export function buildReadCookieCode(name: string, domain: string, allowDomains:
512
512
  const dom = ${JSON.stringify(domain.toLowerCase())}.replace(/^\\./, "");
513
513
  if (!allowed.some(p => new RegExp(p, "i").test(dom)))
514
514
  throw new Error("read-cookie refused: domain " + JSON.stringify(dom) + " is not allowed by --allow-domain");
515
- const url = "https://" + dom + "/";
516
- const cookies = await page.context().cookies([url]);
517
- const match = cookies.filter(c => c.name === ${JSON.stringify(name)} && dom === String(c.domain).replace(/^\\./, "").toLowerCase());
515
+ // All cookies, any path (a URL filter would drop /app-scoped ones). Domain-match per RFC6265:
516
+ // the cookie's own domain is dom, or a parent of dom (a ".slack.com" cookie serves a subdomain).
517
+ const cookies = await page.context().cookies();
518
+ const domainMatches = cd => { cd = String(cd).replace(/^\\./, "").toLowerCase(); return dom === cd || dom.endsWith("." + cd); };
519
+ const match = cookies.filter(c => c.name === ${JSON.stringify(name)} && domainMatches(c.domain));
518
520
  if (!match.length) throw new Error("read-cookie: no cookie " + JSON.stringify(${JSON.stringify(name)}) + " for " + dom + " (is this profile signed in?)");
519
- let value;
520
- try { value = String(match[0].value); } catch { throw new Error("read-cookie: could not read the cookie"); }
521
- return JSON.stringify({ domain: dom, value });
521
+ const values = [...new Set(match.map(c => { try { return String(c.value); } catch { return null; } }))];
522
+ if (values.length !== 1 || values[0] == null) throw new Error("read-cookie: " + match.length + " cookies named " + JSON.stringify(${JSON.stringify(name)}) + " for " + dom + " disagree; narrow the domain");
523
+ return JSON.stringify({ domain: dom, value: values[0] });
522
524
  }`;
523
525
  }
524
526
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rechrome",
3
- "version": "1.43.0",
3
+ "version": "1.43.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/snomiao/rechrome.git"
@@ -65837,6 +65837,10 @@ var init_browserModel = __esm({
65837
65837
  await this._sendToExtension("chrome.tabs.remove", [tabSession.tabId]);
65838
65838
  return { success: true };
65839
65839
  }
65840
+ // Any attached tab's relay sessionId, for browser-level commands the tab debugger can serve.
65841
+ anyAttachedSessionId() {
65842
+ return this._findTabSession(() => true)?.sessionId;
65843
+ }
65840
65844
  getTargetInfo(sessionId) {
65841
65845
  if (!sessionId)
65842
65846
  return void 0;
@@ -65974,6 +65978,14 @@ var init_cdpRelayV2 = __esm({
65974
65978
  return { result: await this._model.closeTarget(params2?.targetId) };
65975
65979
  case "Target.getTargetInfo":
65976
65980
  return { result: this._model.getTargetInfo(sessionId) };
65981
+ case "Storage.getCookies": {
65982
+ if (sessionId)
65983
+ return void 0;
65984
+ const tabSessionId = this._model.anyAttachedSessionId();
65985
+ if (!tabSessionId)
65986
+ throw new Error("Storage.getCookies: no tab is attached yet; open a page first");
65987
+ return { result: await this._model.sendCommand(tabSessionId, "Storage.getCookies", params2) };
65988
+ }
65977
65989
  }
65978
65990
  return void 0;
65979
65991
  }