@lightcone-ai/daemon 0.9.39 → 0.9.41
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/package.json +1 -1
- package/src/browser-login.js +30 -0
package/package.json
CHANGED
package/src/browser-login.js
CHANGED
|
@@ -17,18 +17,35 @@ export const PLATFORM_CONFIGS = {
|
|
|
17
17
|
xhs: {
|
|
18
18
|
loginUrl: 'https://www.xiaohongshu.com',
|
|
19
19
|
isLoggedIn: (cookies) => cookies.some(c => c.name === 'web_session' && c.value?.length > 0),
|
|
20
|
+
// Both domain variants to cover host-only and domain cookies
|
|
21
|
+
sessionCookies: [
|
|
22
|
+
{ name: 'web_session', domain: '.xiaohongshu.com' },
|
|
23
|
+
{ name: 'web_session', domain: 'www.xiaohongshu.com' },
|
|
24
|
+
],
|
|
20
25
|
},
|
|
21
26
|
douyin: {
|
|
22
27
|
loginUrl: 'https://www.douyin.com',
|
|
23
28
|
isLoggedIn: (cookies) => cookies.some(c =>
|
|
24
29
|
(c.name === 'sessionid' || c.name === 'sid_guard') && c.value?.length > 0
|
|
25
30
|
),
|
|
31
|
+
sessionCookies: [
|
|
32
|
+
{ name: 'sessionid', domain: '.douyin.com' },
|
|
33
|
+
{ name: 'sessionid', domain: 'www.douyin.com' },
|
|
34
|
+
{ name: 'sid_guard', domain: '.douyin.com' },
|
|
35
|
+
{ name: 'sid_guard', domain: 'www.douyin.com' },
|
|
36
|
+
],
|
|
26
37
|
},
|
|
27
38
|
kuaishou: {
|
|
28
39
|
loginUrl: 'https://www.kuaishou.com',
|
|
29
40
|
isLoggedIn: (cookies) => cookies.some(c =>
|
|
30
41
|
(c.name === 'userId' || c.name === 'passToken') && c.value?.length > 0
|
|
31
42
|
),
|
|
43
|
+
sessionCookies: [
|
|
44
|
+
{ name: 'userId', domain: '.kuaishou.com' },
|
|
45
|
+
{ name: 'userId', domain: 'www.kuaishou.com' },
|
|
46
|
+
{ name: 'passToken', domain: '.kuaishou.com' },
|
|
47
|
+
{ name: 'passToken', domain: 'www.kuaishou.com' },
|
|
48
|
+
],
|
|
32
49
|
},
|
|
33
50
|
};
|
|
34
51
|
|
|
@@ -159,6 +176,10 @@ export class BrowserLoginSession {
|
|
|
159
176
|
await this.send('Page.addScriptToEvaluateOnNewDocument', {
|
|
160
177
|
source: `Object.defineProperty(navigator, 'webdriver', { get: () => undefined });`,
|
|
161
178
|
});
|
|
179
|
+
|
|
180
|
+
// Clear the session cookie so we only detect a *fresh* login, not stale cached cookies
|
|
181
|
+
await this._clearSessionCookies();
|
|
182
|
+
|
|
162
183
|
await this.send('Page.navigate', { url: this._config.loginUrl });
|
|
163
184
|
|
|
164
185
|
this._startPolling(connection);
|
|
@@ -239,6 +260,15 @@ export class BrowserLoginSession {
|
|
|
239
260
|
}, LOGIN_CHECK_INTERVAL_MS);
|
|
240
261
|
}
|
|
241
262
|
|
|
263
|
+
async _clearSessionCookies() {
|
|
264
|
+
const cookies = this._config.sessionCookies ?? [];
|
|
265
|
+
for (const { name, domain } of cookies) {
|
|
266
|
+
try {
|
|
267
|
+
await this.send('Network.deleteCookies', { name, domain });
|
|
268
|
+
} catch {}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
242
272
|
_stopTimers() {
|
|
243
273
|
if (this._screenshotTimer) { clearInterval(this._screenshotTimer); this._screenshotTimer = null; }
|
|
244
274
|
if (this._loginCheckTimer) { clearInterval(this._loginCheckTimer); this._loginCheckTimer = null; }
|