Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update webauthn keys (#520)
Leendert de Borst3c91103c3aa1
diff --git a/apps/browser-extension/src/entrypoints/background.ts b/apps/browser-extension/src/entrypoints/background.tsindex 7f9a9016b..1c0c85c38 100644--- a/apps/browser-extension/src/entrypoints/background.ts+++ b/apps/browser-extension/src/entrypoints/background.ts@@ -65,12 +65,12 @@ export default defineBackground({// Passkey/WebAuthn management messagesonMessage('GET_WEBAUTHN_SETTINGS', () => handleGetWebAuthnSettings());- onMessage('WEBAUTHN_CREATE', ({ data }) => handleWebAuthnCreate(data));- onMessage('WEBAUTHN_GET', ({ data }) => handleWebAuthnGet(data));- onMessage('STORE_PASSKEY', ({ data }) => handleStorePasskey(data));- onMessage('UPDATE_PASSKEY_LAST_USED', ({ data }) => handleUpdatePasskeyLastUsed(data));+ onMessage('WEBAUTHN_CREATE', ({ data }) => handleWebAuthnCreate(data as { publicKey: unknown; origin: string }));+ onMessage('WEBAUTHN_GET', ({ data }) => handleWebAuthnGet(data as { publicKey: { allowCredentials?: { id: string; }[] | undefined }; origin: string }));+ onMessage('STORE_PASSKEY', ({ data }) => handleStorePasskey(data as { rpId: string; credentialId: string; displayName: string; publicKey: unknown }));+ onMessage('UPDATE_PASSKEY_LAST_USED', ({ data }) => handleUpdatePasskeyLastUsed(data as { credentialId: string }));onMessage('CLEAR_ALL_PASSKEYS', () => handleClearAllPasskeys());- onMessage('PASSKEY_POPUP_RESPONSE', ({ data }) => handlePasskeyPopupResponse(data));+ onMessage('PASSKEY_POPUP_RESPONSE', ({ data }) => handlePasskeyPopupResponse(data as { requestId: string; credential?: any; fallback?: boolean; cancelled?: boolean }));// Initialize passkeys from storage TODO: remove this once proper vault integration is addedawait initializePasskeys();diff --git a/apps/browser-extension/src/entrypoints/background/PasskeyHandler.ts b/apps/browser-extension/src/entrypoints/background/PasskeyHandler.tsindex 82cb945c7..369fb4a06 100644--- a/apps/browser-extension/src/entrypoints/background/PasskeyHandler.ts+++ b/apps/browser-extension/src/entrypoints/background/PasskeyHandler.ts@@ -48,6 +48,10 @@ export async function handleWebAuthnCreate(data: {const { publicKey, origin } = data;const requestId = Math.random().toString(36).substr(2, 9);+ console.log('handleWebAuthnCreate: requestId', requestId);+ console.log('handleWebAuthnCreate: origin', origin);+ console.log('handleWebAuthnCreate: publicKey', publicKey);+// Create popup using main popup with hash navigationconst popupUrl = browser.runtime.getURL('/popup.html') + '#/passkeys/create?' + new URLSearchParams({request: encodeURIComponent(JSON.stringify({diff --git a/apps/browser-extension/src/entrypoints/contentScript/WebAuthnInterceptor.ts b/apps/browser-extension/src/entrypoints/contentScript/WebAuthnInterceptor.tsindex 6fb4c519f..ef2100d54 100644--- a/apps/browser-extension/src/entrypoints/contentScript/WebAuthnInterceptor.ts+++ b/apps/browser-extension/src/entrypoints/contentScript/WebAuthnInterceptor.ts@@ -19,7 +19,7 @@ export async function initializeWebAuthnInterceptor(_ctx: any): Promise<void> {}// Listen for WebAuthn create events from the page- window.addEventListener('aliasVault:webauthn:create', async (event: any) => {+ window.addEventListener('aliasvault:webauthn:create', async (event: any) => {const { requestId, publicKey, origin } = event.detail;console.log('[AliasVault] WebAuthnInterceptor: Received webauthn:create event', { requestId, origin });@@ -33,14 +33,14 @@ export async function initializeWebAuthnInterceptor(_ctx: any): Promise<void> {console.log('[AliasVault] WebAuthnInterceptor: Background response for create', result);// Send response back to page- window.dispatchEvent(new CustomEvent('aliasVault:webauthn:create:response', {+ window.dispatchEvent(new CustomEvent('aliasvault:webauthn:create:response', {detail: {requestId,...result}}));} catch (error: any) {- window.dispatchEvent(new CustomEvent('aliasVault:webauthn:create:response', {+ window.dispatchEvent(new CustomEvent('aliasvault:webauthn:create:response', {detail: {requestId,error: error.message@@ -50,7 +50,7 @@ export async function initializeWebAuthnInterceptor(_ctx: any): Promise<void> {});// Listen for WebAuthn get events from the page- window.addEventListener('aliasVault:webauthn:get', async (event: any) => {+ window.addEventListener('aliasvault:webauthn:get', async (event: any) => {const { requestId, publicKey, origin } = event.detail;try {@@ -61,14 +61,14 @@ export async function initializeWebAuthnInterceptor(_ctx: any): Promise<void> {}, 'background');// Send response back to page- window.dispatchEvent(new CustomEvent('aliasVault:webauthn:get:response', {+ window.dispatchEvent(new CustomEvent('aliasvault:webauthn:get:response', {detail: {requestId,...result}}));} catch (error: any) {- window.dispatchEvent(new CustomEvent('aliasVault:webauthn:get:response', {+ window.dispatchEvent(new CustomEvent('aliasvault:webauthn:get:response', {detail: {requestId,error: error.messagediff --git a/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsx b/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsxindex 06238ab25..c8d35f5f1 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsx@@ -30,6 +30,8 @@ const PasskeyCreate: React.FC = () => {const params = new URLSearchParams(hash.split('?')[1] || '');const requestData = params.get('request');+ console.log('PasskeyCreate: useEffect: requestData', requestData);+if (requestData) {try {const parsed = JSON.parse(decodeURIComponent(requestData));@@ -44,6 +46,7 @@ const PasskeyCreate: React.FC = () => {}// Mark initial loading as complete+ console.log('PasskeyCreate: useEffect: setIsInitialLoading(false)');setIsInitialLoading(false);}, [location, setIsInitialLoading]);diff --git a/apps/browser-extension/src/entrypoints/webauthn-inject.ts b/apps/browser-extension/src/entrypoints/webauthn-inject.tsindex 566e539d8..267951ada 100644--- a/apps/browser-extension/src/entrypoints/webauthn-inject.ts+++ b/apps/browser-extension/src/entrypoints/webauthn-inject.ts@@ -56,7 +56,7 @@ export default defineUnlistedScript(() => {// Send event to content scriptconst requestId = Math.random().toString(36).substr(2, 9);- const event = new CustomEvent('aliasVault:webauthn:create', {+ const event = new CustomEvent('aliasvault:webauthn:create', {detail: {requestId,publicKey: {@@ -90,7 +90,7 @@ export default defineUnlistedScript(() => {*/function cleanup() {clearTimeout(timeout);- window.removeEventListener('aliasVault:webauthn:create:response', handler);+ window.removeEventListener('aliasvault:webauthn:create:response', handler);}/**@@ -127,7 +127,7 @@ export default defineUnlistedScript(() => {}}- window.addEventListener('aliasVault:webauthn:create:response', handler);+ window.addEventListener('aliasvault:webauthn:create:response', handler);});};@@ -144,7 +144,7 @@ export default defineUnlistedScript(() => {// Send event to content scriptconst requestId = Math.random().toString(36).substr(2, 9);- const event = new CustomEvent('aliasVault:webauthn:get', {+ const event = new CustomEvent('aliasvault:webauthn:get', {detail: {requestId,publicKey: {@@ -174,7 +174,7 @@ export default defineUnlistedScript(() => {*/function cleanup() {clearTimeout(timeout);- window.removeEventListener('aliasVault:webauthn:get:response', handler);+ window.removeEventListener('aliasvault:webauthn:get:response', handler);}/**@@ -213,7 +213,7 @@ export default defineUnlistedScript(() => {}}- window.addEventListener('aliasVault:webauthn:get:response', handler);+ window.addEventListener('aliasvault:webauthn:get:response', handler);});};