fix: address review findings in auth flow#5
Merged
Dhravya merged 2 commits intofeat/browser-auth-flowfrom Apr 28, 2026
Merged
Conversation
added 2 commits
April 28, 2026 19:59
- test/unit.mjs: update skill tests to assert exit(1) + stderr matching /Supermemory is not authenticated/ — the PR intentionally changed skills from exit(0)+stdout to exit(1)+stderr when unconfigured - src/hooks/recall.ts: add mkdirSync before writeFileSync(.auth-attempted) so the 'only attempt auth once' guard actually works when ~/.codex/supermemory/ doesn't exist yet. Without this fix the sentinel file was silently dropped and every recall invocation retried the 25s browser timeout. - test/unit.mjs: isolate recall hook tests with HOME: tmpDir so the .auth-attempted file is writable; pre-create it in tests 4+5 to avoid the 25s auth timeout (reducing suite time from ~75s to ~25s) - src/cli.ts: status() now reads credentials.json via loadCredentials() so users who authenticated via the browser flow see '✓ set' instead of the misleading '✗ not set' - test/unit.mjs: add supermemory-login to install/uninstall skill coverage
- Add random state token to prevent local callback forgery (CSRF) - Clear setTimeout on successful auth to avoid 25s process hang - Set restrictive file permissions (0o700 dir, 0o600 file) on credentials
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes all four issues flagged in the PR #4 review.
Changes
1. Add state token to prevent local callback forgery -- High (
src/services/auth.ts)crypto.randomBytesstateparam in the browser URL sent toapp.supermemory.aistatedoes not match with a 403 response2. Clear timeout on successful auth -- Medium (
src/services/auth.ts)setTimeouthandle and callclearTimeout(timer)on both the resolve and server-error paths3. Restrict credentials file permissions -- Medium (
src/services/auth.ts)~/.codex/supermemory/with mode0o700(owner-only access)credentials.jsonwith mode0o600(owner read/write only)4. Fix
status()to use credential store -- Low (src/cli.ts)status()now callsloadCredentials()as a fallback when no env var is setTesting
npm testpasses: 29/29 tests, 0 failuresSession Details
(aside)to your comment to have me ignore it.