types.ts

4.5 KB · raw

1export interface Canary {2  webhookUrl: string;3  label?: string;4  lastPinged?: number;5  pingCount?: number;6}78export interface VaultEntry {9  id: string; // crypto.randomUUID()10  type?: "login" | "note" | "passkey"; // defaults to "login" for existing entries11  title: string;12  username?: string; // only for login entries13  password?: string; // only for login entries14  url?: string; // only for login entries15  totp?: string; // base32 seed, stored encrypted — only for login entries16  notes?: string;17  breach?: number; // HIBP exposure count; 0 or undefined = clean — only for login entries18  canary?: Canary;19  createdAt: number; // Date.now()20  modifiedAt: number;21  deletedAt?: number;22  tags?: string[];23  rpId?: string;24  rpName?: string;25  credentialId?: string;26  publicKeyCose?: string;27  privateKeyJwk?: JsonWebKey;28  userHandle?: string;29  userName?: string;30  userDisplayName?: string;31  algorithm?: -7 | -8;32  signCount?: number;33  aaguid?: string;34  backupEligible?: boolean;35  backupState?: boolean;36  lastUsedAt?: number;37}3839export interface LegacyVaultEntry {40  id: string;41  title: string;42  username: string;43  password: string;44  url: string;45  totp?: string;46  notes?: string;47  breach?: number;48  created: number;49  updated: number;50  deletedAt?: number;51}5253export interface PasskeyEntry extends VaultEntry {54  type: "passkey";55  rpId: string;56  rpName: string;57  credentialId: string;58  publicKeyCose: string;59  privateKeyJwk: JsonWebKey;60  userHandle: string;61  userName: string;62  userDisplayName: string;63  algorithm: -7 | -8;64  signCount: number;65  aaguid: string;66  backupEligible: boolean;67  backupState: boolean;68  lastUsedAt?: number;69}7071export interface PendingPasskeyRequest {72  requestId: number;73  type: "create" | "get";74  rpId: string;75  rpName: string;76  userName: string;77  userDisplayName?: string;78}7980export interface PasskeyProviderState {81  supported: boolean;82  enabled: boolean;83  attached: boolean;84  browserLabel: string;85  statusLabel: string;86  conflict?: string;87}8889export interface StoredVault {90  version: 1; // AAD for AES-GCM --- prevents downgrade91  salt: string; // hex --- 16 bytes, CSPRNG, stored not secret92  nonce: string; // hex --- 12 bytes, CSPRNG, fresh per write93  ciphertext: string; // hex --- AES-256-GCM output94  tag: string; // hex --- 16-byte GCM auth tag95}9697// Background-bound message types — sent from popup/content scripts,98// handled in src/background/messages.ts. Everything in this group must99// have a matching case in that file's switch statement.100export type MessageType =101  | "UNLOCK"102  | "LOCK"103  | "IS_UNLOCKED"104  | "HAS_VAULT"105  | "GET_ENTRIES"106  | "ADD_ENTRY"107  | "BATCH_ADD_ENTRIES"108  | "RESTORE_ENTRIES"109  | "CLEAR_VAULT_ENTRIES"110  | "UPDATE_ENTRY"111  | "DELETE_ENTRY"112  | "AUTOFILL_QUERY"113  | "COPY"114  | "CREATE_VAULT"115  | "GET_ENTRY_FOR_FILL"116  | "CHECK_BREACH"117  | "CHECK_ALL_BREACHES"118  | "GET_SETTINGS"119  | "UPDATE_SETTINGS"120  | "FIRE_CANARY_PING"121  | "ACTIVATE_LICENSE"122  | "GET_LICENSE"123  | "IS_DURESS_ENABLED"124  | "SETUP_DURESS"125  | "DISABLE_DURESS"126  | "VERIFY_MAIN_PASSWORD"127  | "CHANGE_PASSWORD"128  | "GET_SITE_PASSWORD_POLICY"129  | "GET_SYNC_STATE"130  | "TRIGGER_SYNC"131  | "START_PAIRING"132  | "CANCEL_PAIRING"133  | "ACCEPT_PAIRING"134  | "REMOVE_PAIRED_DEVICE"135  | "REMOVE_TRUSTED_NETWORK"136  | "MARK_NETWORK_TRUSTED"137  | "GET_PENDING_PASSKEY"138  | "APPROVE_PASSKEY"139  | "DENY_PASSKEY"140  | "DELETE_PASSKEY"141  | "GET_PASSKEYS"142  | "GET_PASSKEY_PROVIDER_STATE"143  | "SET_PASSKEY_PROVIDER_ENABLED"144  | "GET_DELETED_ENTRIES"145  | "RESTORE_ENTRY"146  | "PURGE_ENTRY"147  | "PURGE_EXPIRED_TRASH"148  | "LIST_VAULT_SNAPSHOTS"149  | "RESTORE_VAULT_SNAPSHOT"150  | "COUNT_DUPLICATES"151  | "DEDUPLICATE_ENTRIES"152  // Content-script-bound message types — sent BY the background TO content153  // scripts. They never reach messages.ts's switch. Kept in this union so154  // existing call sites type-check; do not add cases for them in the155  // background handler.156  | "PING"            // background → content: liveness probe157  | "SUMMON_AUTOFILL" // background → content: open the in-page palette158  | "VAULT_LOCKED"    // background → content/popup: vault just locked159  | "VAULT_UNLOCKED"; // background → content/popup: vault just unlocked160161export interface PasswordPolicy {162  minLength?: number;163  maxLength?: number;164  requiresUppercase?: boolean;165  requiresLowercase?: boolean;166  requiresNumbers?: boolean;167  requiresSymbols?: boolean;168  forbidsSymbols?: boolean;169  allowedSymbols?: string;170}171172export interface Message {173  type: MessageType;174  payload?: unknown;175}176177export interface MessageResponse {178  ok: boolean;179  data?: unknown;180  error?: string;181}