Skip to content

feat: per-site preferences for autofill, save prompts, passkeys#60

Merged
hieuck merged 1 commit into
mainfrom
feature/per-site-preferences
Jul 8, 2026
Merged

feat: per-site preferences for autofill, save prompts, passkeys#60
hieuck merged 1 commit into
mainfrom
feature/per-site-preferences

Conversation

@hieuck

@hieuck hieuck commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Add per-site preferences so users can disable autofill, save/update prompts, and passkeys per domain.

Closes #59

Changes

  • extension/shared/site-preferences.js (new)

    • getSitePreference, setSitePreference, clearSitePreferences, getAllSitePreferences.
    • Valid keys: disableAutofill, disableSavePrompt, disablePasskeys.
    • Domain normalization strips protocol, port, path, and www.
  • extension/contentScript.js

    • Loads site preferences on startup.
    • fillLogin returns early when disableAutofill is set.
    • maybePromptSaveLogin returns early when disableSavePrompt is set.
  • extension/background.js

    • Wraps passkey onCreateRequest and onGetRequest handlers.
    • Rejects passkey requests with NotAllowedError when disablePasskeys is set for the resolved origin.
  • tests/unit/site-preferences.test.mjs (new)

    • 7 tests covering normalization, storage, invalid keys, clearing, and listing.

Verification

  • npm test — 1024 tests passed (77 test files)
  • npm run lint — clean

- Add extension/shared/site-preferences.js with get/set/clear/list.
- contentScript.js respects disableAutofill and disableSavePrompt.
- background.js wraps passkey handlers to reject when disablePasskeys is set.
- Add unit tests for site-preferences module.

Closes #59
@ecc-tools

ecc-tools Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@hieuck, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 33 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f915d6c2-1fb1-4aac-8d15-9328fac7ffb4

📥 Commits

Reviewing files that changed from the base of the PR and between a235a15 and 67bda5a.

📒 Files selected for processing (4)
  • extension/background.js
  • extension/contentScript.js
  • extension/shared/site-preferences.js
  • tests/unit/site-preferences.test.mjs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/per-site-preferences

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread extension/background.js
Comment on lines +565 to +567
} catch (error) {
if (error && error.name === 'NotAllowedError') throw error;
// Storage lookup failure should not block passkey requests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent Error Swallowing in Passkey Handler Wrapper

In the wrapPasskeyHandler function, the catch block (lines 565-567) silently ignores all errors except for NotAllowedError. While this prevents storage lookup failures from blocking passkey requests, it also means that unexpected errors (e.g., programming errors, permission issues) are swallowed without logging or reporting, making debugging more difficult and potentially masking real issues.

Recommendation:
Log unexpected errors to the console for visibility, while still allowing passkey requests to proceed. For example:

} catch (error) {
  if (error && error.name === 'NotAllowedError') throw error;
  console.error('Unexpected error in getSitePreference:', error);
  // Storage lookup failure should not block passkey requests.
}

This ensures that unexpected issues are at least visible during development and troubleshooting.

Comment on lines +37 to +42
const settings = await getSettings();
const all = settings[STORAGE_KEY] || {};
const current = { ...(all[domain] || {}) };
current[key] = value;
all[domain] = current;
await setSettings({ [STORAGE_KEY]: all });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential Data Race in Settings Update

The setSitePreference function performs a read-modify-write sequence on the settings object. If multiple calls to this function occur concurrently, there is a risk of race conditions leading to lost updates. For example, two parallel invocations could both read the same initial state, modify it independently, and then overwrite each other's changes when writing back.

Recommendation:

  • Implement a locking mechanism or use atomic update operations if supported by the underlying storage to ensure consistency.
  • Alternatively, consider refactoring to use a transactional update pattern if available.

Comment on lines +46 to +55
export async function clearSitePreferences(domainOrUrl) {
const domain = normalizeDomain(domainOrUrl);
if (!domain) return;
const settings = await getSettings();
const all = settings[STORAGE_KEY] || {};
if (!(domain in all)) return;
const { [domain]: _removed, ...rest } = all;
void _removed;
await setSettings({ [STORAGE_KEY]: rest });
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-Atomic Deletion in clearSitePreferences

The clearSitePreferences function also performs a read-modify-write operation on the settings object, which is susceptible to the same race condition as described above. Concurrent deletions or updates could result in inconsistent state or lost data.

Recommendation:

  • Apply the same atomic update or locking strategy as suggested for setSitePreference to ensure safe concurrent modifications.

@hieuck hieuck merged commit d949dfe into main Jul 8, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add per-site preferences / exceptions

1 participant