@lightcone-ai/daemon 0.9.39 → 0.9.40

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightcone-ai/daemon",
3
- "version": "0.9.39",
3
+ "version": "0.9.40",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -17,18 +17,27 @@ 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
+ sessionCookies: [{ name: 'web_session', domain: '.xiaohongshu.com' }],
20
21
  },
21
22
  douyin: {
22
23
  loginUrl: 'https://www.douyin.com',
23
24
  isLoggedIn: (cookies) => cookies.some(c =>
24
25
  (c.name === 'sessionid' || c.name === 'sid_guard') && c.value?.length > 0
25
26
  ),
27
+ sessionCookies: [
28
+ { name: 'sessionid', domain: '.douyin.com' },
29
+ { name: 'sid_guard', domain: '.douyin.com' },
30
+ ],
26
31
  },
27
32
  kuaishou: {
28
33
  loginUrl: 'https://www.kuaishou.com',
29
34
  isLoggedIn: (cookies) => cookies.some(c =>
30
35
  (c.name === 'userId' || c.name === 'passToken') && c.value?.length > 0
31
36
  ),
37
+ sessionCookies: [
38
+ { name: 'userId', domain: '.kuaishou.com' },
39
+ { name: 'passToken', domain: '.kuaishou.com' },
40
+ ],
32
41
  },
33
42
  };
34
43
 
@@ -159,6 +168,10 @@ export class BrowserLoginSession {
159
168
  await this.send('Page.addScriptToEvaluateOnNewDocument', {
160
169
  source: `Object.defineProperty(navigator, 'webdriver', { get: () => undefined });`,
161
170
  });
171
+
172
+ // Clear the session cookie so we only detect a *fresh* login, not stale cached cookies
173
+ await this._clearSessionCookies();
174
+
162
175
  await this.send('Page.navigate', { url: this._config.loginUrl });
163
176
 
164
177
  this._startPolling(connection);
@@ -239,6 +252,15 @@ export class BrowserLoginSession {
239
252
  }, LOGIN_CHECK_INTERVAL_MS);
240
253
  }
241
254
 
255
+ async _clearSessionCookies() {
256
+ const cookies = this._config.sessionCookies ?? [];
257
+ for (const { name, domain } of cookies) {
258
+ try {
259
+ await this.send('Network.deleteCookies', { name, domain });
260
+ } catch {}
261
+ }
262
+ }
263
+
242
264
  _stopTimers() {
243
265
  if (this._screenshotTimer) { clearInterval(this._screenshotTimer); this._screenshotTimer = null; }
244
266
  if (this._loginCheckTimer) { clearInterval(this._loginCheckTimer); this._loginCheckTimer = null; }