-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.ts
31 lines (26 loc) · 1020 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import Dexie from 'dexie';
import { applyMiddlewareWithCustomEncryption } from './applyMiddleware';
import { encryptWithNacl, decryptWithNacl } from './encryptionMethods';
import { cryptoOptions, CryptoSettings } from './types';
export { cryptoOptions } from './types';
export const NON_INDEXED_FIELDS = cryptoOptions.NON_INDEXED_FIELDS;
export const ENCRYPT_LIST = cryptoOptions.ENCRYPT_LIST;
export const UNENCRYPTED_LIST = cryptoOptions.UNENCRYPTED_LIST;
export { clearAllTables, clearEncryptedTables } from './applyMiddleware';
export function applyEncryptionMiddleware<T extends Dexie>(
db: T,
encryptionKey: Uint8Array | Promise<Uint8Array>,
tableSettings: CryptoSettings<T>,
onKeyChange: (db: T) => Promise<any>,
_nonceOverrideForTesting?: Uint8Array
) {
applyMiddlewareWithCustomEncryption({
db,
encryptionKey,
tableSettings,
encrypt: encryptWithNacl,
decrypt: decryptWithNacl,
onKeyChange,
_nonceOverrideForTesting,
});
}