Skip to content

Commit 08f6c00

Browse files
committed
General fixes
1 parent 4f45490 commit 08f6c00

6 files changed

Lines changed: 17 additions & 18 deletions

File tree

src/client/service/vaultsClone.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as grpc from '@grpc/grpc-js';
55
import * as grpcUtils from '../../grpc/utils';
66
import * as utilsPB from '../../proto/js/polykey/v1/utils/utils_pb';
77
import * as validationUtils from '../../validation/utils';
8+
import * as vaultsUtils from '../../vaults/utils';
89

910
function vaultsClone({
1011
authenticate,
@@ -35,8 +36,8 @@ function vaultsClone({
3536
// Vault id
3637
let vaultId;
3738
const vaultNameOrId = vaultMessage.getNameOrId();
38-
vaultId = vaultManager.getVaultId(vaultNameOrId);
39-
vaultId = vaultId ?? validationUtils.parseVaultId(vaultId);
39+
vaultId = vaultsUtils.decodeVaultId(vaultNameOrId);
40+
vaultId = vaultId ?? vaultNameOrId;
4041
// Node id
4142
const nodeId = validationUtils.parseNodeId(nodeMessage.getNodeId());
4243
await vaultManager.cloneVault(nodeId, vaultId);

src/client/service/vaultsPermissionGet.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { Authenticate } from '../types';
2-
import type { VaultManager } from '../../vaults';
2+
import type VaultManager from '../../vaults/VaultManager';
33
import type { VaultName } from '../../vaults/types';
44
import type * as grpc from '@grpc/grpc-js';
55
import type { VaultActions } from '../../vaults/types';
66
import type ACL from '../../acl/ACL';
77
import type { NodeId, NodeIdEncoded } from 'nodes/types';
88
import { IdInternal } from '@matrixai/id';
9-
import { utils as grpcUtils } from '../../grpc';
9+
import * as grpcUtils from '../../grpc/utils';
1010
import * as nodesPB from '../../proto/js/polykey/v1/nodes/nodes_pb';
1111
import * as vaultsPB from '../../proto/js/polykey/v1/vaults/vaults_pb';
1212
import * as validationUtils from '../../validation/utils';
@@ -37,7 +37,7 @@ function vaultsPermissionGet({
3737
// Getting permissions
3838
const rawPermissions = await acl.getVaultPerm(vaultId);
3939
const permissionList: Record<NodeIdEncoded, VaultActions> = {};
40-
// Getting the relevant information.
40+
// Getting the relevant information
4141
for (const nodeId in rawPermissions) {
4242
permissionList[nodeId] = rawPermissions[nodeId].vaults[vaultId];
4343
}
@@ -46,7 +46,7 @@ function vaultsPermissionGet({
4646
vaultPermissionsMessage.setVault(vaultMessage);
4747
const nodeMessage = new nodesPB.Node();
4848

49-
// Constructing the message.
49+
// Constructing the message
5050
for (const nodeIdString in permissionList) {
5151
const nodeId = IdInternal.fromString<NodeId>(nodeIdString);
5252
nodeMessage.setNodeId(nodesUtils.encodeNodeId(nodeId));

src/client/service/vaultsPermissionSet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Authenticate } from '../types';
22
import type { VaultName } from '../../vaults/types';
3-
import type { VaultManager } from '../../vaults';
3+
import type VaultManager from '../../vaults/VaultManager';
44
import type GestaltGraph from '../../gestalts/GestaltGraph';
55
import type ACL from '../../acl/ACL';
66
import type NotificationsManager from '../../notifications/NotificationsManager';
@@ -10,7 +10,7 @@ import * as grpc from '@grpc/grpc-js';
1010
import * as vaultsUtils from '../../vaults/utils';
1111
import * as vaultsErrors from '../../vaults/errors';
1212
import * as validationUtils from '../../validation/utils';
13-
import { utils as grpcUtils } from '../../grpc';
13+
import * as grpcUtils from '../../grpc/utils';
1414
import * as utilsPB from '../../proto/js/polykey/v1/utils/utils_pb';
1515

1616
function vaultsPermissionSet({

src/client/service/vaultsPermissionUnset.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type { Authenticate } from '../types';
22
import type { VaultName } from '../../vaults/types';
3-
import type { VaultManager } from '../../vaults';
3+
import type VaultManager from '../../vaults/VaultManager';
44
import type GestaltGraph from '../../gestalts/GestaltGraph';
55
import type ACL from '../../acl/ACL';
66
import type * as vaultsPB from '../../proto/js/polykey/v1/vaults/vaults_pb';
77
import * as grpc from '@grpc/grpc-js';
88
import * as vaultsErrors from '../../vaults/errors';
99
import * as validationUtils from '../../validation/utils';
10-
import { utils as grpcUtils } from '../../grpc';
10+
import * as grpcUtils from '../../grpc/utils';
1111
import * as utilsPB from '../../proto/js/polykey/v1/utils/utils_pb';
1212

1313
function vaultsPermissionUnset({
@@ -54,7 +54,7 @@ function vaultsPermissionUnset({
5454
for (const action of actions) {
5555
await acl.unsetVaultAction(vaultId, nodeId, action);
5656
}
57-
// We need to check if there are still shared vaults.
57+
// We need to check if there are still shared vaults
5858
const nodePermissions = await acl.getNodePerm(nodeId);
5959
// Remove scan permissions if no more shared vaults
6060
if (nodePermissions != null) {

src/vaults/VaultManager.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,7 @@ class VaultManager {
744744
/**
745745
* Returns all the shared vaults for a NodeId.
746746
*/
747-
public async *handleScanVaults(
748-
nodeId: NodeId,
749-
): AsyncGenerator<{
747+
public async *handleScanVaults(nodeId: NodeId): AsyncGenerator<{
750748
vaultId: VaultId;
751749
vaultName: VaultName;
752750
vaultPermissions: VaultAction[];

tests/vaults/VaultManager.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ describe('VaultManager', () => {
463463
await vaultManager?.destroy();
464464
}
465465
});
466-
describe.skip('With remote agents', () => {
466+
describe('With remote agents', () => {
467467
let allDataDir: string;
468468
let keyManager: KeyManager;
469469
let fwdProxy: ForwardProxy;
@@ -1388,7 +1388,7 @@ describe('VaultManager', () => {
13881388
// No permissions for vault3
13891389

13901390
// scanning vaults
1391-
const gen = vaultManager.handleScanVaults(nodeId1, acl);
1391+
const gen = vaultManager.handleScanVaults(nodeId1);
13921392
const vaults: Record<VaultId, [VaultName, VaultAction[]]> = {};
13931393
for await (const vault of gen) {
13941394
vaults[vault.vaultId] = [vault.vaultName, vault.vaultPermissions];
@@ -1399,14 +1399,14 @@ describe('VaultManager', () => {
13991399

14001400
// Should throw due to no permission
14011401
await expect(async () => {
1402-
for await (const _ of vaultManager.handleScanVaults(nodeId2, acl)) {
1402+
for await (const _ of vaultManager.handleScanVaults(nodeId2)) {
14031403
// Should throw
14041404
}
14051405
}).rejects.toThrow(vaultsErrors.ErrorVaultsPermissionDenied);
14061406
// Should throw due to lack of scan permission
14071407
await gestaltGraph.setGestaltActionByNode(nodeId2, 'notify');
14081408
await expect(async () => {
1409-
for await (const _ of vaultManager.handleScanVaults(nodeId2, acl)) {
1409+
for await (const _ of vaultManager.handleScanVaults(nodeId2)) {
14101410
// Should throw
14111411
}
14121412
}).rejects.toThrow(vaultsErrors.ErrorVaultsPermissionDenied);

0 commit comments

Comments
 (0)