types.ts

5.8 KB · raw

1export interface ManualSummonRecord {2  firstSummonedAt: number;3  summonCount: number;4  lastSummonedAt: number;5}67export interface Canary {8  webhookUrl: string;9  label?: string;10  lastPinged?: number;11  pingCount?: number;12}1314export type CardNetwork = "visa" | "mastercard" | "amex" | "discover" | "unknown";1516export interface VaultEntry {17  id: string; // crypto.randomUUID()18  type?: "login" | "note" | "passkey" | "card"; // defaults to "login" for existing entries19  title: string;20  username?: string; // only for login entries21  password?: string; // only for login entries22  url?: string; // only for login entries23  totp?: string; // base32 seed, stored encrypted — only for login entries24  notes?: string;25  breach?: number; // HIBP exposure count; 0 or undefined = clean — only for login entries26  canary?: Canary;27  createdAt: number; // Date.now()28  modifiedAt: number;29  deletedAt?: number;30  tags?: string[];31  rpId?: string;32  rpName?: string;33  credentialId?: string;34  publicKeyCose?: string;35  privateKeyJwk?: JsonWebKey;36  userHandle?: string;37  userName?: string;38  userDisplayName?: string;39  algorithm?: -7 | -8;40  signCount?: number;41  aaguid?: string;42  backupEligible?: boolean;43  backupState?: boolean;44  lastUsedAt?: number;45  // Card entry fields46  cardholderName?: string;47  cardNumber?: string;       // full PAN, stored encrypted in vault48  expMonth?: string;49  expYear?: string;50  cvc?: string;51  cardNickname?: string;52  network?: CardNetwork;53  last4?: string;54}5556export interface LegacyVaultEntry {57  id: string;58  title: string;59  username: string;60  password: string;61  url: string;62  totp?: string;63  notes?: string;64  breach?: number;65  created: number;66  updated: number;67  deletedAt?: number;68}6970export interface CardEntry extends VaultEntry {71  type: "card";72  cardholderName: string;73  cardNumber: string;74  expMonth: string;75  expYear: string;76  cvc: string;77}7879export interface PasskeyEntry extends VaultEntry {80  type: "passkey";81  rpId: string;82  rpName: string;83  credentialId: string;84  publicKeyCose: string;85  privateKeyJwk: JsonWebKey;86  userHandle: string;87  userName: string;88  userDisplayName: string;89  algorithm: -7 | -8;90  signCount: number;91  aaguid: string;92  backupEligible: boolean;93  backupState: boolean;94  lastUsedAt?: number;95}9697export interface PendingPasskeyRequest {98  requestId: number;99  type: "create" | "get";100  rpId: string;101  rpName: string;102  userName: string;103  userDisplayName?: string;104}105106export interface PasskeyProviderState {107  supported: boolean;108  enabled: boolean;109  attached: boolean;110  browserLabel: string;111  statusLabel: string;112  conflict?: string;113}114115export interface StoredVault {116  version: 1; // AAD for AES-GCM --- prevents downgrade117  salt: string; // hex --- 16 bytes, CSPRNG, stored not secret118  nonce: string; // hex --- 12 bytes, CSPRNG, fresh per write119  ciphertext: string; // hex --- AES-256-GCM output120  tag: string; // hex --- 16-byte GCM auth tag121}122123// Background-bound message types — sent from popup/content scripts,124// handled in src/background/messages.ts. Everything in this group must125// have a matching case in that file's switch statement.126export type MessageType =127  | "UNLOCK"128  | "LOCK"129  | "IS_UNLOCKED"130  | "HAS_VAULT"131  | "GET_ENTRIES"132  | "ADD_ENTRY"133  | "BATCH_ADD_ENTRIES"134  | "RESTORE_ENTRIES"135  | "CLEAR_VAULT_ENTRIES"136  | "UPDATE_ENTRY"137  | "DELETE_ENTRY"138  | "AUTOFILL_QUERY"139  | "COPY"140  | "CREATE_VAULT"141  | "GET_ENTRY_FOR_FILL"142  | "CHECK_BREACH"143  | "CHECK_ALL_BREACHES"144  | "GET_SETTINGS"145  | "UPDATE_SETTINGS"146  | "FIRE_CANARY_PING"147  | "ACTIVATE_LICENSE"148  | "GET_LICENSE"149  | "IS_DURESS_ENABLED"150  | "SETUP_DURESS"151  | "DISABLE_DURESS"152  | "VERIFY_MAIN_PASSWORD"153  | "CHANGE_PASSWORD"154  | "GET_SITE_PASSWORD_POLICY"155  | "GET_SYNC_STATE"156  | "TRIGGER_SYNC"157  | "START_PAIRING"158  | "CANCEL_PAIRING"159  | "ACCEPT_PAIRING"160  | "REMOVE_PAIRED_DEVICE"161  | "REMOVE_TRUSTED_NETWORK"162  | "MARK_NETWORK_TRUSTED"163  | "GET_PENDING_PASSKEY"164  | "APPROVE_PASSKEY"165  | "DENY_PASSKEY"166  | "DELETE_PASSKEY"167  | "GET_PASSKEYS"168  | "GET_PASSKEY_PROVIDER_STATE"169  | "SET_PASSKEY_PROVIDER_ENABLED"170  | "GET_DELETED_ENTRIES"171  | "RESTORE_ENTRY"172  | "PURGE_ENTRY"173  | "PURGE_EXPIRED_TRASH"174  | "LIST_VAULT_SNAPSHOTS"175  | "RESTORE_VAULT_SNAPSHOT"176  | "COUNT_DUPLICATES"177  | "DEDUPLICATE_ENTRIES"178  | "RECORD_MANUAL_SUMMON"179  | "DECLINE_CARD_SAVE"180  | "IS_CARD_DECLINED"181  // Content-script-bound message types — sent BY the background TO content182  // scripts. They never reach messages.ts's switch. Kept in this union so183  // existing call sites type-check; do not add cases for them in the184  // background handler.185  | "PING"            // background → content: liveness probe186  | "SUMMON_AUTOFILL" // background → content: open the in-page palette187  | "VAULT_LOCKED"    // background → content/popup: vault just locked188  | "VAULT_UNLOCKED"; // background → content/popup: vault just unlocked189190export const ACCENT_COLORS = [191  { name: "peach",    hex: "#E8956D" },192  { name: "rose",     hex: "#E8909A" },193  { name: "plum",     hex: "#C49AC8" },194  { name: "lavender", hex: "#9FA8D4" },195  { name: "sky",      hex: "#85BAD4" },196  { name: "mint",     hex: "#7EC8A4" },197  { name: "sage",     hex: "#9AB87A" },198  { name: "butter",   hex: "#D4B96A" },199  { name: "sand",     hex: "#C8A882" },200  { name: "clay",     hex: "#C4826A" },201  { name: "slate",    hex: "#8A9EAA" },202  { name: "stone",    hex: "#A89E92" },203] as const;204205export type AccentColorName = typeof ACCENT_COLORS[number]["name"];206207export interface PasswordPolicy {208  minLength?: number;209  maxLength?: number;210  requiresUppercase?: boolean;211  requiresLowercase?: boolean;212  requiresNumbers?: boolean;213  requiresSymbols?: boolean;214  forbidsSymbols?: boolean;215  allowedSymbols?: string;216}217218export interface Message {219  type: MessageType;220  payload?: unknown;221}222223export interface MessageResponse {224  ok: boolean;225  data?: unknown;226  error?: string;227}