feat: per-site preferences for autofill, save prompts, passkeys#60
Conversation
- 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 bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
|
Warning Review limit reached
Next review available in: 33 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| } catch (error) { | ||
| if (error && error.name === 'NotAllowedError') throw error; | ||
| // Storage lookup failure should not block passkey requests. |
There was a problem hiding this comment.
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.
| const settings = await getSettings(); | ||
| const all = settings[STORAGE_KEY] || {}; | ||
| const current = { ...(all[domain] || {}) }; | ||
| current[key] = value; | ||
| all[domain] = current; | ||
| await setSettings({ [STORAGE_KEY]: all }); |
There was a problem hiding this comment.
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.
| 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 }); | ||
| } |
There was a problem hiding this comment.
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
setSitePreferenceto ensure safe concurrent modifications.
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.disableAutofill,disableSavePrompt,disablePasskeys.www.extension/contentScript.jsfillLoginreturns early whendisableAutofillis set.maybePromptSaveLoginreturns early whendisableSavePromptis set.extension/background.jsonCreateRequestandonGetRequesthandlers.NotAllowedErrorwhendisablePasskeysis set for the resolved origin.tests/unit/site-preferences.test.mjs(new)Verification
npm test— 1024 tests passed (77 test files)npm run lint— clean