Skip to content

Commit 5513a6c

Browse files
committed
fix: fixes to VaultManager handling of efsDb
1 parent 96a7d27 commit 5513a6c

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

src/gestalts/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ type Gestalt = {
116116
identities: GestaltIdentities;
117117
};
118118

119-
type GestaltAction = typeof gestaltActions[number];
119+
type GestaltAction = (typeof gestaltActions)[number];
120120
type GestaltActions = Partial<Record<GestaltAction, null>>;
121121

122122
export { gestaltActions };

src/keys/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ for (const [key, code] of Object.entries(multihashCodes)) {
201201
}
202202

203203
type DigestFormats = keyof typeof multihashCodes;
204-
type DigestCode<K extends DigestFormats> = typeof multihashCodes[K];
204+
type DigestCode<K extends DigestFormats> = (typeof multihashCodes)[K];
205205
type Digest<K extends DigestFormats> = Opaque<K, Buffer>;
206206

207207
/**

src/vaults/VaultManager.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ type VaultMetadata = {
5454
remoteInfo?: RemoteInfo;
5555
};
5656

57-
// FIXME: The DB is not managed by the EFS anymore.
58-
5957
interface VaultManager extends CreateDestroyStartStop {}
6058
@CreateDestroyStartStop(
6159
new vaultsErrors.ErrorVaultManagerRunning(),
@@ -262,7 +260,28 @@ class VaultManager {
262260

263261
public async destroy(): Promise<void> {
264262
this.logger.info(`Destroying ${this.constructor.name}`);
263+
await this.efsDb.start({
264+
fresh: false,
265+
crypto: {
266+
key: this.vaultKey,
267+
ops: {
268+
encrypt: async (key, plainText) => {
269+
return keysUtils.encryptWithKey(
270+
utils.bufferWrap(key) as Key,
271+
utils.bufferWrap(plainText),
272+
);
273+
},
274+
decrypt: async (key, cipherText) => {
275+
return keysUtils.decryptWithKey(
276+
utils.bufferWrap(key) as Key,
277+
utils.bufferWrap(cipherText),
278+
);
279+
},
280+
},
281+
},
282+
});
265283
await this.efs.destroy();
284+
await this.efsDb.stop();
266285
await this.efsDb.destroy();
267286
// Clearing all vaults db data
268287
await this.db.clear(this.vaultsDbPath);

src/vaults/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Opaque } from '../types';
66

77
const vaultActions = ['clone', 'pull'] as const;
88

9-
type VaultAction = typeof vaultActions[number];
9+
type VaultAction = (typeof vaultActions)[number];
1010

1111
/**
1212
* Special tags that are managed by VaultInternal
@@ -20,7 +20,7 @@ const tagLast = 'last';
2020
*/
2121
const refs = ['HEAD', tagLast] as const;
2222

23-
type VaultRef = typeof refs[number];
23+
type VaultRef = (typeof refs)[number];
2424

2525
type CommitId = Opaque<'CommitId', string>;
2626

0 commit comments

Comments
 (0)