Handle basic authorization flow #2
<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"54c4e71b8aa5eeefa9c1bf6e7d55c9ba8aa37bfc","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->
<details>
<summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-07T18:34:42.942478Z">2026-11-07T18:34:42.942478Z</relative-time> | 54c4e71 | PR opened |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
</details>
</details>
<sub><sub>!P2 Badge</sub></sub> Require credentials only when login is necessary
When the connected browser already has an authenticated session but USER_EMAIL or USER_PASSWORD is unset, this check aborts the scrape before inspecting the page. The browser setup explicitly reuses a running browser or the persistent .puppeteer profile, and the previous entry point allowed those existing sessions to work without credentials. Move this validation into the branch that actually performs login so authenticated users can continue without supplying their password again.
Useful? React with 👍 / 👎.
<!-- codex-code-review-finding:v1 -->
<!-- codex-review-receipt:v1 -->
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54c4e71b8a
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
PR Reviewer Guide 🔍
<!-- pr-agent:review:full -->
(Review updated until commit https://github.com/ailinykh/progress-dump/commit/8f356057e8caa6b705f7093ea74cf8e22c3d9b47)
Here are some key observations to aid the review process:
<table>
<tr><td>⏱️ <strong>Estimated effort to review</strong>: 3 🔵🔵🔵⚪⚪</td></tr>
<tr><td>🧪 <strong>No relevant tests</strong></td></tr>
<tr><td>🔒 <strong>No security concerns identified</strong></td></tr>
<tr><td>⚡ <strong>Recommended focus areas for review</strong><br><br>
<details><summary><a href='https://github.com/ailinykh/progress-dump/pull/2/files#diff-db7d77c1b6f12d7e61d44b4029d7b70c428ab3c83e8ddae0c6563b3ed05e33deR5-R12'><strong>Offscreen interactions</strong></a>
waitForSelector() and boundingBox() do not scroll an element into view. If a login field or submit button is below the viewport, these coordinates fall outside the visible page, so the mouse click misses; typing can target the wrong field or login can time out. safeType() has the same problem. Scroll each element into view before measuring its bounds, or use an element interaction that scrolls automatically.
</summary>
const button = await page.waitForSelector(selector);
const box = await button.boundingBox();
if (!box) throw `Element ${selector} not found`;
// 2. Pick a random point inside the button (not the exact center!)
const x = box.x + Math.floor(Math.random() * box.width);
const y = box.y + Math.floor(Math.random() * box.height);
</details>
</td></tr>
</table>
<!-- pr-agent-review-state:v1
{"findings":[{"body":"Offscreen interactions\n\nwaitForSelector() and boundingBox() do not scroll an element into view. If a login field or submit button is below the viewport, these coordinates fall outside the visible page, so the mouse click misses; typing can target the wrong field or login can time out. safeType() has the same problem. Scroll each element into view before measuring its bounds, or use an element interaction that scrolls automatically.","finding_id":"39b58bca7ebe","first_seen":"2026-11-07T18:34:40.748619Z","last_seen":"2026-11-07T18:46:20.615528Z","last_seen_head_sha":"8f356057e8caa6b705f7093ea74cf8e22c3d9b47","line_end":12,"line_start":5,"path":"src/api/browser/page.ts","state":"ACTIVE"}],"last_run":{"complete":true,"excluded_files":[],"head_sha":"8f356057e8caa6b705f7093ea74cf8e22c3d9b47","kind":"full","run_id":"https://github.com/ailinykh/progress-dump/commit/8f356057e8caa6b705f7093ea74cf8e22c3d9b47"},"schema_version":1}
-->
Suggestion: Wait for an authenticated UI state rather than requiring navigation. If login completes through an API request without changing the document or URL, waitForNavigation() times out despite successful authentication. [possible issue, importance: 6]
await Promise.all([
page.waitForSelector(".avatar-box", {
visible: true,
timeout: 30_000,
}),
safeClick(page, login_button),
]);
Suggestion: Wait for visibility and scroll the input into view before calculating mouse coordinates. boundingBox() can return coordinates outside the viewport, causing the click to miss and credentials to be typed into the wrong field or nowhere. [possible issue, importance: 7]
const input = await page.waitForSelector(selector, { visible: true });
if (!input) throw new Error(`Element ${selector} not found`);
await input.scrollIntoView();
const box = await input.boundingBox();
/review
chatgpt-codex-connector[bot]
ailinykh
<!-- pr-agent-generated -->
PR Type
Enhancement
___
Description
dotenv.___
<details> <summary><h3> File Walkthrough</h3></summary>
<table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>5 files</summary><table>
<tr>
<td>
<details>
<summary><strong>browser.ts</strong><dd><code>Add window resizing and relocate page lookup</code> </dd></summary>
<hr>
src/api/browser/browser.ts
<ul><li>Add <code>resizeBrowser</code> using CDP window bounds commands and detach the <br>session afterward.<br> <li> Move hostname-based <code>getPage</code> lookup here, retaining new-page fallback.</ul>
</details>
</td>
<td><a href="https://github.com/ailinykh/progress-dump/pull/2/files#diff-a9199e52c26bc574c0f2773bfd6e97cf5f9a2e7eb45a0efc42d1a07017959ce7">+36/-1</a> </td>
</tr>
<tr>
<td>
<details>
<summary><strong>index.ts</strong><dd><code>Expose browser sizing and interaction helper functions</code> </dd></summary>
<hr>
src/api/browser/index.ts
<ul><li>Export <code>resizeBrowser</code>, <code>safeClick</code>, and <code>safeType</code>.<br> <li> Update <code>getPage</code> import to its new location in <code>browser.ts</code>.</ul>
</details>
</td>
<td><a href="https://github.com/ailinykh/progress-dump/pull/2/files#diff-803f93335eb621b8cfe68d622dfa3d9dfd811ce2ce41945f66df61ea931008b4">+9/-3</a> </td>
</tr>
<tr>
<td>
<details>
<summary><strong>page.ts</strong><dd><code>Add randomized mouse and keyboard interaction helpers</code> </dd></summary>
<hr>
src/api/browser/page.ts
<ul><li>Replace page lookup with <code>safeClick</code> and <code>safeType</code> interaction helpers.<br> <li> Randomize click coordinates, mouse movement, and interaction delays.<br> <li> Clear existing input using platform-specific shortcuts before typing <br>characters individually.</ul>
</details>
</td>
<td><a href="https://github.com/ailinykh/progress-dump/pull/2/files#diff-db7d77c1b6f12d7e61d44b4029d7b70c428ab3c83e8ddae0c6563b3ed05e33de">+65/-15</a> </td>
</tr>
<tr>
<td>
<details>
<summary><strong>index.ts</strong><dd><code>Implement conditional ProgressMe login and readiness checks</code></dd></summary>
<hr>
src/api/progressme/index.ts
<ul><li>Add <code>handleLogin</code> with credential validation and target navigation.<br> <li> Detect the login button and conditionally submit credentials using <br>browser helpers.<br> <li> Coordinate clicking with navigation, revisit the target, and verify <br>the avatar after login.<br> <li> Wait for the requested content selector before returning.</ul>
</details>
</td>
<td><a href="https://github.com/ailinykh/progress-dump/pull/2/files#diff-f3736055e83a0eab8577a8bd95cac0849b7d3f559594dd58bdf4a9778c522a95">+54/-0</a> </td>
</tr>
<tr>
<td>
<details>
<summary><strong>index.ts</strong><dd><code>Integrate authentication and extract personal material metadata</code></dd></summary>
<hr>
src/index.ts
<ul><li>Load environment configuration and pass <code>USER_EMAIL</code> and <code>USER_PASSWORD</code> <br>to <code>handleLogin</code>.<br> <li> Replace viewport sizing with browser window resizing through CDP.<br> <li> Extract and log material IDs, image URLs, and titles from personal <br>material cards.<br> <li> Note scroll-based pagination as future work.</ul>
</details>
</td>
<td><a href="https://github.com/ailinykh/progress-dump/pull/2/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80">+34/-13</a> </td>
</tr>
</table></details></td></tr><tr><td><strong>Dependencies</strong></td><td><details><summary>2 files</summary><table>
<tr>
<td>
<details>
<summary><strong>package.json</strong><dd><code>Add dotenv dependency for environment configuration loading</code></dd></summary>
<hr>
package.json
dotenvat^18.0.9for environment configuration loading.</details>
</td>
<td><a href="https://github.com/ailinykh/progress-dump/pull/2/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519">+1/-0</a> </td>
</tr>
<tr>
<td>
<details>
<summary><strong>package-lock.json</strong><dd><code>Update dependency lockfile alongside dotenv dependency addition</code></dd></summary>
<hr>
package-lock.json
<ul><li>Lockfile changed alongside the dependency update; its diff was <br>omitted.</ul>
</details>
</td>
<td><a href=""></a></td>
</tr>
</table></details></td></tr></tr></tbody></table>
</details>
___