@ubaidbinwaris/linkedin 1.1.5 → 1.1.6

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": "@ubaidbinwaris/linkedin",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -54,6 +54,8 @@ async function handleMobileVerification(page) {
54
54
 
55
55
  try {
56
56
  // Poll for feed URL for 120 seconds
57
+ // Note: If navigation happens (user approves), this might throw "Execution context was destroyed"
58
+ // We handle that in the catch block by checking the URL.
57
59
  await page.waitForFunction(() => {
58
60
  return window.location.href.includes("/feed") ||
59
61
  document.querySelector('.global-nav__search');
@@ -61,8 +63,16 @@ async function handleMobileVerification(page) {
61
63
 
62
64
  logger.info("Mobile verification successful! Resuming...");
63
65
  return true; // Resolved
64
- } catch (timeoutErr) {
65
- logger.warn("Mobile verification timed out (No approval detected).");
66
+ } catch (err) {
67
+ // Check if we actually succeeded via navigation
68
+ try {
69
+ if (page.url().includes("/feed")) {
70
+ logger.info("Mobile verification successful (detected via navigation)! Resuming...");
71
+ return true;
72
+ }
73
+ } catch(e) {}
74
+
75
+ logger.warn(`Mobile verification wait ended: ${err.message}`);
66
76
  return false;
67
77
  }
68
78
 
@@ -92,9 +92,20 @@ async function loginToLinkedIn(options = {}, credentials = null) {
92
92
 
93
93
  // Now wait for success (Feed)
94
94
  logger.info("[Fallback] Waiting for user to complete login manually...");
95
- await visiblePage.waitForSelector(".global-nav__search", { timeout: 120000 });
96
95
 
97
- if (await isLoggedIn(visiblePage)) {
96
+ // Wait for URL OR Selector
97
+ // We loop to check both condition
98
+ try {
99
+ await visiblePage.waitForFunction(() => {
100
+ return window.location.href.includes("/feed") ||
101
+ document.querySelector(".global-nav__search");
102
+ }, { timeout: 120000 });
103
+ } catch(e) {
104
+ logger.warn(`[Fallback] Wait finished with error: ${e.message}`);
105
+ }
106
+
107
+ // Double check status
108
+ if (visiblePage.url().includes("/feed") || await isLoggedIn(visiblePage)) {
98
109
  logger.info(`[${email}] Manual Fallback Successful ✅`);
99
110
  await saveSession(visibleContext, email, true);
100
111
  return { browser: visibleBrowser, context: visibleContext, page: visiblePage };