Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update credential card / details / add-edit to include passkeys (#520)

Leendert de Borst10c9478238c4
diff --git a/apps/browser-extension/src/entrypoints/popup/components/CredentialCard.tsx b/apps/browser-extension/src/entrypoints/popup/components/CredentialCard.tsx
index efad36d7b..e89cc182c 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/CredentialCard.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/CredentialCard.tsx
@@ -69,8 +69,24 @@ const CredentialCard: React.FC<CredentialCardProps> = ({ credential }) => {
target.src = '/assets/images/service-placeholder.webp';
}}
/>
- <div className="text-left">
- <p className="font-medium text-gray-900 dark:text-white">{getCredentialServiceName(credential)}</p>
+ <div className="text-left flex-1">
+ <div className="flex items-center gap-1.5">
+ <p className="font-medium text-gray-900 dark:text-white">{getCredentialServiceName(credential)}</p>
+ {credential.HasPasskey && (
+ <svg
+ className="w-3.5 h-3.5 text-gray-500 dark:text-gray-400"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ title="Has passkey"
+ >
+ <path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4" />
+ </svg>
+ )}
+ </div>
<p className="text-sm text-gray-600 dark:text-gray-400">{getDisplayText(credential)}</p>
</div>
</button>
diff --git a/apps/browser-extension/src/entrypoints/popup/components/CredentialDetails/LoginCredentialsBlock.tsx b/apps/browser-extension/src/entrypoints/popup/components/CredentialDetails/LoginCredentialsBlock.tsx
index 4077179ca..7b94ebf76 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/CredentialDetails/LoginCredentialsBlock.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/CredentialDetails/LoginCredentialsBlock.tsx
@@ -18,7 +18,7 @@ const LoginCredentialsBlock: React.FC<LoginCredentialsBlockProps> = ({ credentia
const username = credential.Username?.trim();
const password = credential.Password?.trim();
- if (!email && !username && !password) {
+ if (!email && !username && !password && !credential.HasPasskey) {
return null;
}
@@ -39,6 +39,45 @@ const LoginCredentialsBlock: React.FC<LoginCredentialsBlockProps> = ({ credentia
value={username}
/>
)}
+ {credential.HasPasskey && (
+ <div className="p-3 rounded bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700">
+ <div className="flex items-start gap-2">
+ <svg
+ className="w-5 h-5 text-gray-600 dark:text-gray-400 mt-0.5 flex-shrink-0"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4" />
+ </svg>
+ <div className="flex-1">
+ <div className="mb-1">
+ <span className="text-sm font-medium text-gray-900 dark:text-white">{t('passkeys.passkey')}</span>
+ </div>
+ <div className="space-y-1 mb-2">
+ {credential.PasskeyRpId && (
+ <div>
+ <span className="text-xs text-gray-500 dark:text-gray-400">{t('passkeys.site')}: </span>
+ <span className="text-sm text-gray-900 dark:text-white">{credential.PasskeyRpId}</span>
+ </div>
+ )}
+ {credential.PasskeyDisplayName && (
+ <div>
+ <span className="text-xs text-gray-500 dark:text-gray-400">{t('passkeys.displayName')}: </span>
+ <span className="text-sm text-gray-900 dark:text-white">{credential.PasskeyDisplayName}</span>
+ </div>
+ )}
+ </div>
+ <p className="text-xs text-gray-600 dark:text-gray-400">
+ {t('passkeys.helpText')}
+ </p>
+ </div>
+ </div>
+ </div>
+ )}
{password && (
<FormInputCopyToClipboard
id="password"
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialAddEdit.tsx b/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialAddEdit.tsx
index 4bdc11945..97f71415c 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialAddEdit.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialAddEdit.tsx
@@ -92,6 +92,7 @@ const CredentialAddEdit: React.FC = () => {
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [attachments, setAttachments] = useState<Attachment[]>([]);
const [originalAttachmentIds, setOriginalAttachmentIds] = useState<string[]>([]);
+ const [passkeyMarkedForDeletion, setPasskeyMarkedForDeletion] = useState(false);
const webApi = useWebApi();
// Track last generated values to avoid overwriting manual entries
@@ -550,6 +551,11 @@ const CredentialAddEdit: React.FC = () => {
if (isEditMode) {
await dbContext.sqliteClient!.updateCredentialById(data, originalAttachmentIds, attachments);
+
+ // Delete passkeys if marked for deletion
+ if (passkeyMarkedForDeletion) {
+ await dbContext.sqliteClient!.deletePasskeysByCredentialId(data.Id);
+ }
} else {
const credentialId = await dbContext.sqliteClient!.createCredential(data, attachments);
data.Id = credentialId.toString();
@@ -570,7 +576,7 @@ const CredentialAddEdit: React.FC = () => {
}
},
});
- }, [isEditMode, dbContext.sqliteClient, executeVaultMutation, navigate, mode, watch, generateRandomAlias, webApi, clearPersistedValues, originalAttachmentIds, attachments]);
+ }, [isEditMode, dbContext.sqliteClient, executeVaultMutation, navigate, mode, watch, generateRandomAlias, webApi, clearPersistedValues, originalAttachmentIds, attachments, passkeyMarkedForDeletion]);
// Set header buttons on mount and clear on unmount
useEffect((): (() => void) => {
@@ -695,30 +701,167 @@ const CredentialAddEdit: React.FC = () => {
<div className="bg-white dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700">
<h2 className="text-lg font-semibold mb-4 text-gray-900 dark:text-white">{t('credentials.loginCredentials')}</h2>
<div className="space-y-4">
- <EmailDomainField
- id="email"
- label={t('common.email')}
- value={watch('Alias.Email') ?? ''}
- onChange={(value: string) => setValue('Alias.Email', value)}
- error={errors.Alias?.Email?.message}
- />
- <UsernameField
- id="username"
- label={t('common.username')}
- value={watch('Username') ?? ''}
- onChange={(value) => setValue('Username', value)}
- error={errors.Username?.message}
- onRegenerate={generateRandomUsername}
- />
- <PasswordField
- id="password"
- label={t('common.password')}
- value={watch('Password') ?? ''}
- onChange={(value) => setValue('Password', value)}
- error={errors.Password?.message}
- showPassword={showPassword}
- onShowPasswordChange={setShowPassword}
- />
+ {watch('HasPasskey') ? (
+ <>
+ {/* When passkey exists: username, passkey, email, password */}
+ <UsernameField
+ id="username"
+ label={t('common.username')}
+ value={watch('Username') ?? ''}
+ onChange={(value) => setValue('Username', value)}
+ error={errors.Username?.message}
+ onRegenerate={generateRandomUsername}
+ />
+ {!passkeyMarkedForDeletion && (
+ <div className="p-3 rounded bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700">
+ <div className="flex items-start gap-2">
+ <svg
+ className="w-5 h-5 text-gray-600 dark:text-gray-400 mt-0.5 flex-shrink-0"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4" />
+ </svg>
+ <div className="flex-1">
+ <div className="mb-1 flex items-center justify-between">
+ <span className="text-sm font-medium text-gray-900 dark:text-white">{t('passkeys.passkey')}</span>
+ <button
+ type="button"
+ onClick={() => setPasskeyMarkedForDeletion(true)}
+ className="text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300"
+ title="Delete passkey"
+ >
+ <svg
+ className="w-4 h-4"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <polyline points="3 6 5 6 21 6" />
+ <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
+ <line x1="10" y1="11" x2="10" y2="17" />
+ <line x1="14" y1="11" x2="14" y2="17" />
+ </svg>
+ </button>
+ </div>
+ <div className="space-y-1 mb-2">
+ {watch('PasskeyRpId') && (
+ <div>
+ <span className="text-xs text-gray-500 dark:text-gray-400">{t('passkeys.site')}: </span>
+ <span className="text-sm text-gray-900 dark:text-white">{watch('PasskeyRpId')}</span>
+ </div>
+ )}
+ {watch('PasskeyDisplayName') && (
+ <div>
+ <span className="text-xs text-gray-500 dark:text-gray-400">{t('passkeys.displayName')}: </span>
+ <span className="text-sm text-gray-900 dark:text-white">{watch('PasskeyDisplayName')}</span>
+ </div>
+ )}
+ </div>
+ <p className="text-xs text-gray-600 dark:text-gray-400">
+ {t('passkeys.helpText')}
+ </p>
+ </div>
+ </div>
+ </div>
+ )}
+ {passkeyMarkedForDeletion && (
+ <div className="p-3 rounded bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800">
+ <div className="flex items-start gap-2">
+ <svg
+ className="w-5 h-5 text-red-600 dark:text-red-400 mt-0.5 flex-shrink-0"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4" />
+ </svg>
+ <div className="flex-1">
+ <div className="mb-1 flex items-center justify-between">
+ <span className="text-sm font-medium text-red-900 dark:text-red-100">{t('passkeys.passkeyMarkedForDeletion')}</span>
+ <button
+ type="button"
+ onClick={() => setPasskeyMarkedForDeletion(false)}
+ className="text-gray-600 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"
+ title="Undo"
+ >
+ <svg
+ className="w-4 h-4"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <path d="M3 7v6h6" />
+ <path d="M21 17a9 9 0 00-9-9 9 9 0 00-6 2.3L3 13" />
+ </svg>
+ </button>
+ </div>
+ <p className="text-xs text-red-800 dark:text-red-200">
+ {t('passkeys.passkeyWillBeDeleted')}
+ </p>
+ </div>
+ </div>
+ </div>
+ )}
+ <EmailDomainField
+ id="email"
+ label={t('common.email')}
+ value={watch('Alias.Email') ?? ''}
+ onChange={(value: string) => setValue('Alias.Email', value)}
+ error={errors.Alias?.Email?.message}
+ />
+ <PasswordField
+ id="password"
+ label={t('common.password')}
+ value={watch('Password') ?? ''}
+ onChange={(value) => setValue('Password', value)}
+ error={errors.Password?.message}
+ showPassword={showPassword}
+ onShowPasswordChange={setShowPassword}
+ />
+ </>
+ ) : (
+ <>
+ {/* When no passkey: email, username, password */}
+ <EmailDomainField
+ id="email"
+ label={t('common.email')}
+ value={watch('Alias.Email') ?? ''}
+ onChange={(value: string) => setValue('Alias.Email', value)}
+ error={errors.Alias?.Email?.message}
+ />
+ <UsernameField
+ id="username"
+ label={t('common.username')}
+ value={watch('Username') ?? ''}
+ onChange={(value) => setValue('Username', value)}
+ error={errors.Username?.message}
+ onRegenerate={generateRandomUsername}
+ />
+ <PasswordField
+ id="password"
+ label={t('common.password')}
+ value={watch('Password') ?? ''}
+ onChange={(value) => setValue('Password', value)}
+ error={errors.Password?.message}
+ showPassword={showPassword}
+ onShowPasswordChange={setShowPassword}
+ />
+ </>
+ )}
</div>
</div>
diff --git a/apps/browser-extension/src/i18n/locales/en.json b/apps/browser-extension/src/i18n/locales/en.json
index 3d6e8616f..c999ca9d6 100644
--- a/apps/browser-extension/src/i18n/locales/en.json
+++ b/apps/browser-extension/src/i18n/locales/en.json
@@ -360,6 +360,12 @@
}
},
"passkeys": {
+ "passkey": "Passkey",
+ "site": "Site",
+ "displayName": "Name",
+ "helpText": "Passkeys are created on the website when prompted. They cannot be manually edited. To remove this passkey, you can delete it from this credential. To replace this passkey or create a new one, visit the website and follow its prompts.",
+ "passkeyMarkedForDeletion": "Passkey marked for deletion",
+ "passkeyWillBeDeleted": "This passkey will be deleted when you save this credential.",
"authenticate": {
"title": "Sign in with Passkey",
"signInFor": "Sign in with passkey for",
diff --git a/apps/browser-extension/src/utils/SqliteClient.ts b/apps/browser-extension/src/utils/SqliteClient.ts
index 7cd57ed94..a79a027fc 100644
--- a/apps/browser-extension/src/utils/SqliteClient.ts
+++ b/apps/browser-extension/src/utils/SqliteClient.ts
@@ -216,7 +216,16 @@ export class SqliteClient {
a.BirthDate,
a.Gender,
a.Email,
- p.Value as Password
+ p.Value as Password,
+ CASE
+ WHEN EXISTS (
+ SELECT 1 FROM Passkeys pk
+ WHERE pk.CredentialId = c.Id AND pk.IsDeleted = 0
+ ) THEN 1
+ ELSE 0
+ END as HasPasskey,
+ (SELECT pk.RpId FROM Passkeys pk WHERE pk.CredentialId = c.Id AND pk.IsDeleted = 0 LIMIT 1) as PasskeyRpId,
+ (SELECT pk.DisplayName FROM Passkeys pk WHERE pk.CredentialId = c.Id AND pk.IsDeleted = 0 LIMIT 1) as PasskeyDisplayName
FROM Credentials c
LEFT JOIN Services s ON c.ServiceId = s.Id
LEFT JOIN Aliases a ON c.AliasId = a.Id
@@ -241,6 +250,9 @@ export class SqliteClient {
ServiceUrl: row.ServiceUrl,
Logo: row.Logo,
Notes: row.Notes,
+ HasPasskey: row.HasPasskey === 1,
+ PasskeyRpId: row.PasskeyRpId,
+ PasskeyDisplayName: row.PasskeyDisplayName,
Alias: {
FirstName: row.FirstName,
LastName: row.LastName,
@@ -272,7 +284,14 @@ export class SqliteClient {
a.BirthDate,
a.Gender,
a.Email,
- p.Value as Password
+ p.Value as Password,
+ CASE
+ WHEN EXISTS (
+ SELECT 1 FROM Passkeys pk
+ WHERE pk.CredentialId = c.Id AND pk.IsDeleted = 0
+ ) THEN 1
+ ELSE 0
+ END as HasPasskey
FROM Credentials c
LEFT JOIN Services s ON c.ServiceId = s.Id
LEFT JOIN Aliases a ON c.AliasId = a.Id
@@ -291,6 +310,7 @@ export class SqliteClient {
ServiceUrl: row.ServiceUrl,
Logo: row.Logo,
Notes: row.Notes,
+ HasPasskey: row.HasPasskey === 1,
Alias: {
FirstName: row.FirstName,
LastName: row.LastName,
@@ -1346,6 +1366,42 @@ export class SqliteClient {
}
}
+ /**
+ * Delete all passkeys for a specific credential (soft delete)
+ * @param credentialId - The ID of the credential
+ * @returns The number of rows updated
+ */
+ public async deletePasskeysByCredentialId(credentialId: string): Promise<number> {
+ if (!this.db) {
+ throw new Error('Database not initialized');
+ }
+
+ try {
+ this.beginTransaction();
+
+ const currentDateTime = new Date().toISOString()
+ .replace('T', ' ')
+ .replace('Z', '')
+ .substring(0, 23);
+
+ const query = `
+ UPDATE Passkeys
+ SET IsDeleted = 1,
+ UpdatedAt = ?
+ WHERE CredentialId = ?
+ `;
+
+ const result = this.executeUpdate(query, [currentDateTime, credentialId]);
+
+ await this.commitTransaction();
+ return result;
+ } catch (error) {
+ this.rollbackTransaction();
+ console.error('Error deleting passkeys for credential:', error);
+ throw error;
+ }
+ }
+
/**
* Update a passkey's display name
* @param passkeyId - The ID of the passkey to update
diff --git a/shared/models/src/vault/Credential.ts b/shared/models/src/vault/Credential.ts
index 22a4c15e3..987dd8af3 100644
--- a/shared/models/src/vault/Credential.ts
+++ b/shared/models/src/vault/Credential.ts
@@ -10,6 +10,12 @@ export type Credential = {
Logo?: Uint8Array | number[];
Notes?: string;
Alias: Alias;
+ /** Indicates if this credential has an associated passkey */
+ HasPasskey?: boolean;
+ /** The relying party ID (domain) of the associated passkey */
+ PasskeyRpId?: string;
+ /** The display name of the associated passkey */
+ PasskeyDisplayName?: string;
}
/**