Refactor: Remove passkey-related functionality and types

- Deleted passkey-related interfaces and types from index.ts and types.ts.
- Removed passkey handling from App component, including related state and functions.
- Cleaned up API calls in auth.ts, removing passkey registration and login functions.
- Updated vault and import formats to eliminate passkey references.
- Removed passkey support checks and UI elements from AuthViews and SettingsPage.
- Cleaned up unused passkey helper functions and constants.
- Adjusted related components and hooks to ensure consistent functionality without passkey support.
This commit is contained in:
shuaiplus
2026-04-06 00:46:13 +08:00
parent 90a7731351
commit 76623d7201
28 changed files with 28 additions and 1064 deletions
+1 -85
View File
@@ -1,4 +1,4 @@
import { User, Cipher, Folder, Attachment, Device, Invite, AuditLog, Send, TrustedDeviceTokenSummary, RefreshTokenRecord, PasskeyCredential } from '../types';
import { User, Cipher, Folder, Attachment, Device, Invite, AuditLog, Send, TrustedDeviceTokenSummary, RefreshTokenRecord } from '../types';
import { LIMITS } from '../config/limits';
import { ensureStorageSchema } from './storage-schema';
import {
@@ -590,90 +590,6 @@ export class StorageService {
return findStoredTrustedTokenUserId(this.db, this.trustedTwoFactorTokenKey.bind(this), token, deviceIdentifier);
}
// --- Passkeys ---
async createPasskeyChallenge(id: string, userId: string | null, challenge: string, action: 'register' | 'login', expiresAt: number): Promise<void> {
await this.db
.prepare('INSERT OR REPLACE INTO passkey_challenges(id, user_id, challenge, action, expires_at, created_at) VALUES(?, ?, ?, ?, ?, ?)')
.bind(id, userId, challenge, action, expiresAt, new Date().toISOString())
.run();
}
async consumePasskeyChallenge(id: string, action: 'register' | 'login'): Promise<{ challenge: string; userId: string | null } | null> {
const now = Date.now();
const row = await this.db
.prepare('SELECT challenge, user_id as userId FROM passkey_challenges WHERE id = ? AND action = ? AND expires_at > ?')
.bind(id, action, now)
.first<{ challenge: string; userId: string | null }>();
await this.db.prepare('DELETE FROM passkey_challenges WHERE id = ?').bind(id).run();
return row || null;
}
async listPasskeysByUserId(userId: string): Promise<PasskeyCredential[]> {
const rows = await this.db
.prepare('SELECT id, user_id, credential_id, public_key, counter, transports, name, wrapped_vault_keys, created_at, updated_at, last_used_at FROM passkey_credentials WHERE user_id = ? ORDER BY created_at ASC')
.bind(userId)
.all<Record<string, unknown>>();
return (rows.results || []).map((row) => ({
id: String(row.id),
userId: String(row.user_id),
credentialId: String(row.credential_id),
publicKey: String(row.public_key),
counter: Number(row.counter || 0),
transports: row.transports == null ? null : String(row.transports),
name: String(row.name || ''),
wrappedVaultKeys: String(row.wrapped_vault_keys || ''),
createdAt: String(row.created_at || ''),
updatedAt: String(row.updated_at || ''),
lastUsedAt: row.last_used_at == null ? null : String(row.last_used_at),
}));
}
async getPasskeyByCredentialId(credentialId: string): Promise<PasskeyCredential | null> {
const row = await this.db
.prepare('SELECT id, user_id, credential_id, public_key, counter, transports, name, wrapped_vault_keys, created_at, updated_at, last_used_at FROM passkey_credentials WHERE credential_id = ?')
.bind(credentialId)
.first<Record<string, unknown>>();
if (!row) return null;
return {
id: String(row.id),
userId: String(row.user_id),
credentialId: String(row.credential_id),
publicKey: String(row.public_key || ''),
counter: Number(row.counter || 0),
transports: row.transports == null ? null : String(row.transports),
name: String(row.name || ''),
wrappedVaultKeys: String(row.wrapped_vault_keys || ''),
createdAt: String(row.created_at || ''),
updatedAt: String(row.updated_at || ''),
lastUsedAt: row.last_used_at == null ? null : String(row.last_used_at),
};
}
async createPasskey(record: PasskeyCredential): Promise<void> {
await this.db
.prepare('INSERT INTO passkey_credentials(id, user_id, credential_id, public_key, counter, transports, name, wrapped_vault_keys, created_at, updated_at, last_used_at) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
.bind(record.id, record.userId, record.credentialId, record.publicKey, record.counter, record.transports, record.name, record.wrappedVaultKeys, record.createdAt, record.updatedAt, record.lastUsedAt)
.run();
}
async updatePasskeyName(userId: string, id: string, name: string): Promise<boolean> {
const result = await this.db
.prepare('UPDATE passkey_credentials SET name = ?, updated_at = ? WHERE id = ? AND user_id = ?')
.bind(name, new Date().toISOString(), id, userId)
.run();
return (result.meta?.changes || 0) > 0;
}
async deletePasskey(userId: string, id: string): Promise<boolean> {
const result = await this.db.prepare('DELETE FROM passkey_credentials WHERE id = ? AND user_id = ?').bind(id, userId).run();
return (result.meta?.changes || 0) > 0;
}
async touchPasskeyUsage(id: string): Promise<void> {
await this.db.prepare('UPDATE passkey_credentials SET last_used_at = ?, updated_at = ? WHERE id = ?').bind(new Date().toISOString(), new Date().toISOString(), id).run();
}
// --- Revision dates ---
async getRevisionDate(userId: string): Promise<string> {