mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-25 13:45:52 +00:00
fix(cookie-store): defer encryption setup to prevent early macOS ‘Chr… (#5373)
This commit is contained in:
43
package-lock.json
generated
43
package-lock.json
generated
@@ -16311,7 +16311,6 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
||||
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"has-symbols": "^1.0.3"
|
||||
@@ -27124,6 +27123,22 @@
|
||||
"@popperjs/core": "^2.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tldts": {
|
||||
"version": "7.0.12",
|
||||
"resolved": "https://registry.npmjs.org/tldts/-/tldts-7.0.12.tgz",
|
||||
"integrity": "sha512-M9ZQBPp6FyqhMcl233vHYyYRkxXOA1SKGlnq13S0mJdUhRSwr2w6I8rlchPL73wBwRlyIZpFvpu2VcdSMWLYXw==",
|
||||
"dependencies": {
|
||||
"tldts-core": "^7.0.12"
|
||||
},
|
||||
"bin": {
|
||||
"tldts": "bin/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/tldts-core": {
|
||||
"version": "7.0.12",
|
||||
"resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.0.12.tgz",
|
||||
"integrity": "sha512-3K76aXywJFduGRsOYoY5JzINLs/WMlOkeDwPL+8OCPq2Rh39gkSDtWAxdJQlWjpun/xF/LHf29yqCi6VC/rHDA=="
|
||||
},
|
||||
"node_modules/tmp": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz",
|
||||
@@ -31288,6 +31303,9 @@
|
||||
"name": "@usebruno/common",
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tough-cookie": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.26.9",
|
||||
"@babel/preset-typescript": "^7.27.0",
|
||||
@@ -31854,6 +31872,17 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"packages/bruno-common/node_modules/tough-cookie": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.0.tgz",
|
||||
"integrity": "sha512-kXuRi1mtaKMrsLUxz3sQYvVl37B0Ns6MzfrtV5DvJceE9bPyspOqk9xxv7XbZWcfLWbFmm997vl83qUWVJA64w==",
|
||||
"dependencies": {
|
||||
"tldts": "^7.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"packages/bruno-common/node_modules/typescript": {
|
||||
"version": "5.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
||||
@@ -32018,6 +32047,7 @@
|
||||
"nanoid": "3.3.8",
|
||||
"qs": "^6.11.0",
|
||||
"socks-proxy-agent": "^8.0.2",
|
||||
"tough-cookie": "^6.0.0",
|
||||
"uuid": "^9.0.0",
|
||||
"yup": "^0.32.11"
|
||||
},
|
||||
@@ -33100,6 +33130,17 @@
|
||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
}
|
||||
},
|
||||
"packages/bruno-electron/node_modules/tough-cookie": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.0.tgz",
|
||||
"integrity": "sha512-kXuRi1mtaKMrsLUxz3sQYvVl37B0Ns6MzfrtV5DvJceE9bPyspOqk9xxv7XbZWcfLWbFmm997vl83qUWVJA64w==",
|
||||
"dependencies": {
|
||||
"tldts": "^7.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"packages/bruno-filestore": {
|
||||
"name": "@usebruno/filestore",
|
||||
"version": "0.1.0",
|
||||
|
||||
@@ -56,5 +56,8 @@
|
||||
},
|
||||
"overrides": {
|
||||
"rollup": "3.29.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"tough-cookie": "^6.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ const addCookieToJar = (setCookieHeader: string, requestUrl: string): void => {
|
||||
|
||||
const getCookiesForUrl = (url: string) => {
|
||||
return cookieJar.getCookiesSync(url, {
|
||||
secure: isPotentiallyTrustworthyOrigin(url)
|
||||
});
|
||||
secure: isPotentiallyTrustworthyOrigin(url),
|
||||
} as any);
|
||||
};
|
||||
|
||||
const getCookieStringForUrl = (url: string): string => {
|
||||
@@ -195,18 +195,20 @@ const cookieJarWrapper = () => {
|
||||
|
||||
if (callback) {
|
||||
// Callback mode
|
||||
return cookieJar.getCookies(url, (err: Error | null, cookies: Cookie[]) => {
|
||||
return cookieJar.getCookies(url, (err: Error | null, cookies?: Cookie[]) => {
|
||||
if (err) return callback(err);
|
||||
const cookie = cookies.find((c) => c.key === cookieName);
|
||||
const cookieList = cookies || [];
|
||||
const cookie = cookieList.find((c) => c.key === cookieName);
|
||||
callback(null, cookie || null);
|
||||
});
|
||||
}
|
||||
|
||||
// Promise mode
|
||||
return new Promise<Cookie | null>((resolve, reject) => {
|
||||
cookieJar.getCookies(url, (err: Error | null, cookies: Cookie[]) => {
|
||||
cookieJar.getCookies(url, (err: Error | null, cookies?: Cookie[]) => {
|
||||
if (err) return reject(err);
|
||||
const cookie = cookies.find((c) => c.key === cookieName);
|
||||
const cookieList = cookies || [];
|
||||
const cookie = cookieList.find((c) => c.key === cookieName);
|
||||
resolve(cookie || null);
|
||||
});
|
||||
});
|
||||
@@ -222,14 +224,14 @@ const cookieJarWrapper = () => {
|
||||
|
||||
if (callback) {
|
||||
// Callback mode
|
||||
return cookieJar.getCookies(url, callback);
|
||||
return cookieJar.getCookies(url, callback as any);
|
||||
}
|
||||
|
||||
// Promise mode
|
||||
return new Promise<Cookie[]>((resolve, reject) => {
|
||||
cookieJar.getCookies(url, (err: Error | null, cookies: Cookie[]) => {
|
||||
cookieJar.getCookies(url, (err: Error | null, cookies?: Cookie[]) => {
|
||||
if (err) return reject(err);
|
||||
resolve(cookies);
|
||||
resolve(cookies || []);
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -388,11 +390,12 @@ const cookieJarWrapper = () => {
|
||||
|
||||
if (callback) {
|
||||
// Callback mode
|
||||
return cookieJar.getCookies(url, (err: Error | null, cookies: Cookie[]) => {
|
||||
return cookieJar.getCookies(url, (err: Error | null, cookies?: Cookie[]) => {
|
||||
if (err) return callback(err);
|
||||
if (!cookies || !cookies.length) return callback(undefined);
|
||||
const cookieList = cookies || [];
|
||||
if (!cookieList.length) return callback(undefined);
|
||||
|
||||
let pending = cookies.length;
|
||||
let pending = cookieList.length;
|
||||
const done = (removeErr?: Error) => {
|
||||
if (removeErr) return callback(removeErr);
|
||||
if (--pending === 0) {
|
||||
@@ -400,7 +403,7 @@ const cookieJarWrapper = () => {
|
||||
}
|
||||
};
|
||||
|
||||
cookies.forEach((cookie) => {
|
||||
cookieList.forEach((cookie) => {
|
||||
(cookieJar as any).store.removeCookie(cookie.domain, cookie.path, cookie.key, done);
|
||||
});
|
||||
});
|
||||
@@ -408,11 +411,12 @@ const cookieJarWrapper = () => {
|
||||
|
||||
// Promise mode
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
cookieJar.getCookies(url, (err: Error | null, cookies: Cookie[]) => {
|
||||
cookieJar.getCookies(url, (err: Error | null, cookies?: Cookie[]) => {
|
||||
if (err) return reject(err);
|
||||
if (!cookies || !cookies.length) return resolve();
|
||||
const cookieList = cookies || [];
|
||||
if (!cookieList.length) return resolve();
|
||||
|
||||
let pending = cookies.length;
|
||||
let pending = cookieList.length;
|
||||
const done = (removeErr?: Error) => {
|
||||
if (removeErr) return reject(removeErr);
|
||||
if (--pending === 0) {
|
||||
@@ -420,7 +424,7 @@ const cookieJarWrapper = () => {
|
||||
}
|
||||
};
|
||||
|
||||
cookies.forEach((cookie) => {
|
||||
cookieList.forEach((cookie) => {
|
||||
(cookieJar as any).store.removeCookie(cookie.domain, cookie.path, cookie.key, done);
|
||||
});
|
||||
});
|
||||
@@ -435,11 +439,12 @@ const cookieJarWrapper = () => {
|
||||
}
|
||||
|
||||
const executeDelete = (callback: (err?: Error) => void) => {
|
||||
cookieJar.getCookies(url, (err: Error | null, cookies: Cookie[]) => {
|
||||
cookieJar.getCookies(url, (err: Error | null, cookies?: Cookie[]) => {
|
||||
if (err) return callback(err);
|
||||
|
||||
// Filter cookies matching key
|
||||
const matchingCookies = (cookies || []).filter((c) => c.key === cookieName);
|
||||
const cookieList = cookies || [];
|
||||
const matchingCookies = cookieList.filter((c) => c.key === cookieName);
|
||||
if (!matchingCookies.length) return callback(undefined);
|
||||
|
||||
const urlPath = new URL(url).pathname || '/';
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
"nanoid": "3.3.8",
|
||||
"qs": "^6.11.0",
|
||||
"socks-proxy-agent": "^8.0.2",
|
||||
"tough-cookie": "^6.0.0",
|
||||
"uuid": "^9.0.0",
|
||||
"yup": "^0.32.11"
|
||||
},
|
||||
|
||||
@@ -21,7 +21,6 @@ class CookiesStore {
|
||||
cookies: {}
|
||||
}
|
||||
});
|
||||
this.initializeEncryption();
|
||||
}
|
||||
|
||||
#generatePasskey() {
|
||||
@@ -116,6 +115,9 @@ class CookiesStore {
|
||||
|
||||
// Initialize cookies from store into cookie jar
|
||||
initializeCookies() {
|
||||
if (this.#passkey === null) {
|
||||
this.initializeEncryption();
|
||||
}
|
||||
try {
|
||||
const storedCookies = this.getCookies();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user