summaryrefslogtreecommitdiff
path: root/worker/secret/ivault.ts
blob: e101e56d0862582f738b7798f1fb716093c271b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import type { IEither } from "@emprespresso/pengueno";

export interface LoginItem {
  login: {
    username: string;
    password: string;
  };
}

export interface SecureNote {
  notes: string;
}

export type SecretItem = LoginItem | SecureNote;
export interface IVault<TClient, TKey, TItemId> {
  unlock: (client: TClient) => Promise<IEither<Error, TKey>>;
  lock: (client: TClient, key: TKey) => Promise<IEither<Error, TKey>>;

  fetchSecret: <T extends SecretItem>(
    client: TClient,
    key: TKey,
    item: TItemId,
  ) => Promise<IEither<Error, T>>;
}