@apitap/core 1.0.9 → 1.0.10
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/handoff.ts +9 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apitap/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Intercept web API traffic during browsing. Generate portable skill files so AI agents can call APIs directly instead of scraping.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
package/src/auth/handoff.ts
CHANGED
|
@@ -144,21 +144,26 @@ async function doHandoff(
|
|
|
144
144
|
// Navigate to login page
|
|
145
145
|
await page.goto(loginUrl, { waitUntil: 'domcontentloaded', timeout: 30_000 });
|
|
146
146
|
|
|
147
|
-
//
|
|
147
|
+
// Baseline: snapshot cookie names present BEFORE login so we can detect new ones
|
|
148
|
+
const baselineCookies = await context.cookies();
|
|
149
|
+
const baselineCookieNames = new Set(baselineCookies.map(c => c.name));
|
|
150
|
+
|
|
151
|
+
// Poll for login success: check for NEW session-like cookies
|
|
148
152
|
const startTime = Date.now();
|
|
149
153
|
let loginDetected = false;
|
|
150
154
|
|
|
151
155
|
while (Date.now() - startTime < timeout) {
|
|
152
156
|
await page.waitForTimeout(2000);
|
|
153
157
|
|
|
154
|
-
//
|
|
158
|
+
// Only trigger on NEW session-like cookies not present at page load
|
|
155
159
|
const cookies = await context.cookies();
|
|
156
|
-
const
|
|
160
|
+
const hasNewSessionCookie = cookies.some(c =>
|
|
161
|
+
!baselineCookieNames.has(c.name) &&
|
|
157
162
|
SESSION_COOKIE_PATTERNS.some(p => p.test(c.name)) &&
|
|
158
163
|
!TRACKING_COOKIE_PATTERNS.some(p => p.test(c.name))
|
|
159
164
|
);
|
|
160
165
|
|
|
161
|
-
if (
|
|
166
|
+
if (hasNewSessionCookie || authDetected) {
|
|
162
167
|
// Grace period: 4 additional polls at 2s each (~8s total)
|
|
163
168
|
// Allows time for MFA, CAPTCHAs, and post-login redirects
|
|
164
169
|
for (let grace = 0; grace < 4; grace++) {
|