/**
 * 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.
   */
  derivationPath: string;

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

  /**
   * Stringified JSON containing underlying key material.
   * 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 public key in hexadecimal format.
   */
  publicKeyHex: string;

  /**
   * The mnemonic passphrase for the account.
   */
  mnemonic: 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",
};
