types.ts

5.3 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 interface VaultEntry {15  id: string; // crypto.randomUUID()16  type?: "login" | "note" | "passkey"; // defaults to "login" for existing entries17  title: string;18  username?: string; // only for login entries19  password?: string; // only for login entries20  url?: string; // only for login entries21  totp?: string; // base32 seed, stored encrypted — only for login entries22  notes?: string;23  breach?: number; // HIBP exposure count; 0 or undefined = clean — only for login entries24  canary?: Canary;25  createdAt: number; // Date.now()26  modifiedAt: number;27  deletedAt?: number;28  tags?: string[];29  rpId?: string;30  rpName?: string;31  credentialId?: string;32  publicKeyCose?: string;33  privateKeyJwk?: JsonWebKey;34  userHandle?: string;35  userName?: string;36  userDisplayName?: string;37  algorithm?: -7 | -8;38  signCount?: number;39  aaguid?: string;40  backupEligible?: boolean;41  backupState?: boolean;42  lastUsedAt?: number;43}4445export interface LegacyVaultEntry {46  id: string;47  title: string;48  username: string;49  password: string;50  url: string;51  totp?: string;52  notes?: string;53  breach?: number;54  created: number;55  updated: number;56  deletedAt?: number;57}5859export interface PasskeyEntry extends VaultEntry {60  type: "passkey";61  rpId: string;62  rpName: string;63  credentialId: string;64  publicKeyCose: string;65  privateKeyJwk: JsonWebKey;66  userHandle: string;67  userName: string;68  userDisplayName: string;69  algorithm: -7 | -8;70  signCount: number;71  aaguid: string;72  backupEligible: boolean;73  backupState: boolean;74  lastUsedAt?: number;75}7677export interface PendingPasskeyRequest {78  requestId: number;79  type: "create" | "get";80  rpId: string;81  rpName: string;82  userName: string;83  userDisplayName?: string;84}8586export interface PasskeyProviderState {87  supported: boolean;88  enabled: boolean;89  attached: boolean;90  browserLabel: string;91  statusLabel: string;92  conflict?: string;93}9495export interface StoredVault {96  version: 1; // AAD for AES-GCM --- prevents downgrade97  salt: string; // hex --- 16 bytes, CSPRNG, stored not secret98  nonce: string; // hex --- 12 bytes, CSPRNG, fresh per write99  ciphertext: string; // hex --- AES-256-GCM output100  tag: string; // hex --- 16-byte GCM auth tag101}102103// Background-bound message types — sent from popup/content scripts,104// handled in src/background/messages.ts. Everything in this group must105// have a matching case in that file's switch statement.106export type MessageType =107  | "UNLOCK"108  | "LOCK"109  | "IS_UNLOCKED"110  | "HAS_VAULT"111  | "GET_ENTRIES"112  | "ADD_ENTRY"113  | "BATCH_ADD_ENTRIES"114  | "RESTORE_ENTRIES"115  | "CLEAR_VAULT_ENTRIES"116  | "UPDATE_ENTRY"117  | "DELETE_ENTRY"118  | "AUTOFILL_QUERY"119  | "COPY"120  | "CREATE_VAULT"121  | "GET_ENTRY_FOR_FILL"122  | "CHECK_BREACH"123  | "CHECK_ALL_BREACHES"124  | "GET_SETTINGS"125  | "UPDATE_SETTINGS"126  | "FIRE_CANARY_PING"127  | "ACTIVATE_LICENSE"128  | "GET_LICENSE"129  | "IS_DURESS_ENABLED"130  | "SETUP_DURESS"131  | "DISABLE_DURESS"132  | "VERIFY_MAIN_PASSWORD"133  | "CHANGE_PASSWORD"134  | "GET_SITE_PASSWORD_POLICY"135  | "GET_SYNC_STATE"136  | "TRIGGER_SYNC"137  | "START_PAIRING"138  | "CANCEL_PAIRING"139  | "ACCEPT_PAIRING"140  | "REMOVE_PAIRED_DEVICE"141  | "REMOVE_TRUSTED_NETWORK"142  | "MARK_NETWORK_TRUSTED"143  | "GET_PENDING_PASSKEY"144  | "APPROVE_PASSKEY"145  | "DENY_PASSKEY"146  | "DELETE_PASSKEY"147  | "GET_PASSKEYS"148  | "GET_PASSKEY_PROVIDER_STATE"149  | "SET_PASSKEY_PROVIDER_ENABLED"150  | "GET_DELETED_ENTRIES"151  | "RESTORE_ENTRY"152  | "PURGE_ENTRY"153  | "PURGE_EXPIRED_TRASH"154  | "LIST_VAULT_SNAPSHOTS"155  | "RESTORE_VAULT_SNAPSHOT"156  | "COUNT_DUPLICATES"157  | "DEDUPLICATE_ENTRIES"158  | "RECORD_MANUAL_SUMMON"159  // Content-script-bound message types — sent BY the background TO content160  // scripts. They never reach messages.ts's switch. Kept in this union so161  // existing call sites type-check; do not add cases for them in the162  // background handler.163  | "PING"            // background → content: liveness probe164  | "SUMMON_AUTOFILL" // background → content: open the in-page palette165  | "VAULT_LOCKED"    // background → content/popup: vault just locked166  | "VAULT_UNLOCKED"; // background → content/popup: vault just unlocked167168export const ACCENT_COLORS = [169  { name: "peach",    hex: "#E8956D" },170  { name: "rose",     hex: "#E8909A" },171  { name: "plum",     hex: "#C49AC8" },172  { name: "lavender", hex: "#9FA8D4" },173  { name: "sky",      hex: "#85BAD4" },174  { name: "mint",     hex: "#7EC8A4" },175  { name: "sage",     hex: "#9AB87A" },176  { name: "butter",   hex: "#D4B96A" },177  { name: "sand",     hex: "#C8A882" },178  { name: "clay",     hex: "#C4826A" },179  { name: "slate",    hex: "#8A9EAA" },180  { name: "stone",    hex: "#A89E92" },181] as const;182183export type AccentColorName = typeof ACCENT_COLORS[number]["name"];184185export interface PasswordPolicy {186  minLength?: number;187  maxLength?: number;188  requiresUppercase?: boolean;189  requiresLowercase?: boolean;190  requiresNumbers?: boolean;191  requiresSymbols?: boolean;192  forbidsSymbols?: boolean;193  allowedSymbols?: string;194}195196export interface Message {197  type: MessageType;198  payload?: unknown;199}200201export interface MessageResponse {202  ok: boolean;203  data?: unknown;204  error?: string;205}