Skip to content

Commit aa10bb6

Browse files
committed
feat(extension): fill TOTP/2FA codes
1 parent b917a6f commit aa10bb6

File tree

10 files changed

+208
-32
lines changed

10 files changed

+208
-32
lines changed

browser/chromium-extension/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ When pairing is enabled (default), request a pairing code from the popup and app
2929

3030
`persona bridge --approve-code <CODE>`
3131

32+
TOTP/2FA support:
33+
34+
- Create a TOTP credential with an associated URL (e.g. `persona totp setup --identity <name> --url https://github.com ...`)
35+
- On pages with 2FA inputs (e.g. GitHub), focus the code field and click the inline icon to fill the TOTP
36+
3237
For Native Messaging host installation and protocol details, see:
3338

3439
- `scripts/native-messaging/install-native-host.sh`

browser/chromium-extension/dist/background.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

browser/chromium-extension/dist/background.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

browser/chromium-extension/dist/content.js

Lines changed: 93 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

browser/chromium-extension/dist/content.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

browser/chromium-extension/dist/nativeBridge.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

browser/chromium-extension/dist/nativeBridge.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

browser/chromium-extension/src/background.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
9393

9494
// Get TOTP code
9595
if (message?.type === 'persona_get_totp') {
96-
handleGetTotp(message.origin, message.itemId).then(sendResponse);
96+
handleGetTotp(message.origin, message.itemId, message.userGesture).then(sendResponse);
9797
return true;
9898
}
9999

@@ -350,10 +350,11 @@ async function handleRequestFill(
350350
*/
351351
async function handleGetTotp(
352352
origin: string,
353-
itemId: string
353+
itemId: string,
354+
userGesture = true
354355
): Promise<AutofillResult<{ code: string; remaining_seconds: number; period: number }>> {
355356
try {
356-
const response = await getTotp(origin, itemId);
357+
const response = await getTotp(origin, itemId, userGesture);
357358

358359
if (!response.ok) {
359360
return {

0 commit comments

Comments
 (0)