/**
 * Represents an account stored in the database.
 */
export type Account = {
  /**
   * Auto-generated ID by Dexie
   */
  id?: number;

  /**
   * The date the account was created
   */
  dateCreated: string;

  /**
   * The derivation path for the account, if this is from a mnemonic
   */
  derivationPath?: string;

  /**
   * Decentralized Identifier (DID) for the account
   */
  did: string;

  /**
   * Stringified JSON containing underlying key material, if generated from a mnemonic
   * Based on the IIdentifier type from Veramo
   * @see {@link https://github.com/uport-project/veramo/blob/next/packages/core-types/src/types/IIdentifier.ts}
   */
  identity?: string;

  /**
   * The mnemonic phrase for the account, if this is from a mnemonic
   */
  mnemonic?: string;

  /**
   * The Webauthn credential ID in hex, if this is from a passkey
   */
  passkeyCredIdHex?: string;

  /**
   * The public key in hexadecimal format
   */
  publicKeyHex: string;
};

/**
 * Schema for the accounts table in the database.
 * Fields starting with a $ character are encrypted.
 * @see {@link https://github.com/PVermeer/dexie-addon-suite-monorepo/tree/master/packages/dexie-encrypted-addon}
 */
export const AccountsSchema = {
  accounts:
    "++id, dateCreated, derivationPath, did, $identity, $mnemonic, publicKeyHex",
};
