rechrome 1.43.0 → 1.43.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.
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.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/snomiao/rechrome.git"