1 | import keystore from 'keystore-idb';
|
2 | import { CryptoSystem } from 'keystore-idb/types';
|
3 | const KEYSTORE_CFG = { type: CryptoSystem.RSA };
|
4 | let ks = null;
|
5 | export const clear = async () => {
|
6 | ks = await get();
|
7 | await ks.destroy();
|
8 | ks = null;
|
9 | };
|
10 | export const create = async () => {
|
11 | return (await keystore.init(KEYSTORE_CFG));
|
12 | };
|
13 | export const set = async (userKeystore) => {
|
14 | ks = userKeystore;
|
15 | };
|
16 | export const get = async () => {
|
17 | if (ks)
|
18 | return ks;
|
19 | ks = (await keystore.init(KEYSTORE_CFG));
|
20 | return ks;
|
21 | };
|
22 |
|
\ | No newline at end of file |