Phase 1-3: Domain Layer Foundation - Add value objects: IdentityId, PermissionId, RelayId, WalletId, Nickname, NostrKeyPair - Add rich domain entities: Identity, Permission, Relay with behavior - Add domain events: IdentityCreated, IdentityRenamed, IdentitySelected, etc. - Add repository interfaces for Identity, Permission, Relay - Add infrastructure layer with repository implementations - Add EncryptionService abstraction Phase 4: Ubiquitous Language Cleanup - Rename BrowserSyncData → EncryptedVault (encrypted vault storage) - Rename BrowserSessionData → VaultSession (decrypted session state) - Rename SignerMetaData → ExtensionSettings (extension configuration) - Rename Identity_ENCRYPTED → StoredIdentity (storage DTO) - Rename Identity_DECRYPTED → IdentityData (session DTO) - Similar renames for Permission, Relay, NwcConnection, CashuMint - Add backwards compatibility aliases with @deprecated markers Test Coverage - Add comprehensive tests for all value objects - Add tests for domain entities and their behavior - Add tests for domain events - Fix PermissionChecker to prioritize kind-specific rules over blanket rules - Fix pre-existing component test issues (IconButton, Pubkey) All 113 tests pass. Both Chrome and Firefox builds succeed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
80 lines
2.2 KiB
TypeScript
80 lines
2.2 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
import {
|
|
EncryptedVault,
|
|
StoredCashuMint,
|
|
StoredIdentity,
|
|
StoredNwcConnection,
|
|
StoredPermission,
|
|
BrowserSyncHandler,
|
|
StoredRelay,
|
|
} from '@common';
|
|
import browser from 'webextension-polyfill';
|
|
|
|
/**
|
|
* Handles the browser sync operations when the browser sync is enabled.
|
|
* If it's not enabled, it behaves like the local extension storage (which is fine).
|
|
*/
|
|
export class FirefoxSyncNoHandler extends BrowserSyncHandler {
|
|
async loadUnmigratedData(): Promise<Partial<Record<string, any>>> {
|
|
const data = await browser.storage.local.get(null);
|
|
|
|
// Remove any available "ignore properties".
|
|
this.ignoreProperties.forEach((property) => {
|
|
delete data[property];
|
|
});
|
|
return data;
|
|
}
|
|
|
|
async saveAndSetFullData(data: EncryptedVault): Promise<void> {
|
|
await browser.storage.local.set(data as Record<string, any>);
|
|
this.setFullData(data);
|
|
}
|
|
|
|
async saveAndSetPartialData_Permissions(data: {
|
|
permissions: StoredPermission[];
|
|
}): Promise<void> {
|
|
await browser.storage.local.set(data);
|
|
this.setPartialData_Permissions(data);
|
|
}
|
|
|
|
async saveAndSetPartialData_Identities(data: {
|
|
identities: StoredIdentity[];
|
|
}): Promise<void> {
|
|
await browser.storage.local.set(data);
|
|
this.setPartialData_Identities(data);
|
|
}
|
|
|
|
async saveAndSetPartialData_SelectedIdentityId(data: {
|
|
selectedIdentityId: string | null;
|
|
}): Promise<void> {
|
|
await browser.storage.local.set(data);
|
|
this.setPartialData_SelectedIdentityId(data);
|
|
}
|
|
|
|
async saveAndSetPartialData_Relays(data: {
|
|
relays: StoredRelay[];
|
|
}): Promise<void> {
|
|
await browser.storage.local.set(data);
|
|
this.setPartialData_Relays(data);
|
|
}
|
|
|
|
async saveAndSetPartialData_NwcConnections(data: {
|
|
nwcConnections: StoredNwcConnection[];
|
|
}): Promise<void> {
|
|
await browser.storage.local.set(data);
|
|
this.setPartialData_NwcConnections(data);
|
|
}
|
|
|
|
async saveAndSetPartialData_CashuMints(data: {
|
|
cashuMints: StoredCashuMint[];
|
|
}): Promise<void> {
|
|
await browser.storage.local.set(data);
|
|
this.setPartialData_CashuMints(data);
|
|
}
|
|
|
|
async clearData(): Promise<void> {
|
|
const props = Object.keys(await this.loadUnmigratedData());
|
|
await browser.storage.local.remove(props);
|
|
}
|
|
}
|