@ubaidbinwaris/linkedin 1.1.4 → 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 +1 -1
- package/src/auth/checkpoint.js +14 -2
- package/src/login/login.js +13 -2
package/package.json
CHANGED
package/src/auth/checkpoint.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const logger = require("../utils/logger");
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Detects if a checkpoint/verification is triggered.
|
|
3
5
|
* Returns true if intervention is needed.
|
|
@@ -52,6 +54,8 @@ async function handleMobileVerification(page) {
|
|
|
52
54
|
|
|
53
55
|
try {
|
|
54
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.
|
|
55
59
|
await page.waitForFunction(() => {
|
|
56
60
|
return window.location.href.includes("/feed") ||
|
|
57
61
|
document.querySelector('.global-nav__search');
|
|
@@ -59,8 +63,16 @@ async function handleMobileVerification(page) {
|
|
|
59
63
|
|
|
60
64
|
logger.info("Mobile verification successful! Resuming...");
|
|
61
65
|
return true; // Resolved
|
|
62
|
-
} catch (
|
|
63
|
-
|
|
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}`);
|
|
64
76
|
return false;
|
|
65
77
|
}
|
|
66
78
|
|
package/src/login/login.js
CHANGED
|
@@ -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
|
-
|
|
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 };
|