Skip to content

Commit

Permalink
fixes for #305
Browse files Browse the repository at this point in the history
  • Loading branch information
tegefaulkes committed Feb 28, 2022
1 parent 81cffaa commit 2523d70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions src/agent/service/vaultsGitInfoGet.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import type { VaultName } from '../../vaults/types';
import type { VaultManager } from '../../vaults';
import type { ACL } from '../../acl';
import type { ConnectionInfoGetter } from '../../agent/types';
import type { ConnectionInfoGet } from '../../agent/types';
import * as grpc from '@grpc/grpc-js';
import { utils as grpcUtils } from '../../grpc';
import { utils as vaultsUtils, errors as vaultsErrors } from '../../vaults';
import * as vaultsPB from '../../proto/js/polykey/v1/vaults/vaults_pb';
import * as validationUtils from '../../validation/utils';
import * as nodesUtils from '../../nodes/utils';
import { never } from '../../utils/utils';
import * as agentErrors from '../errors';

function vaultsGitInfoGet({
vaultManager,
acl,
connectionInfoGetter,
connectionInfoGet,
}: {
vaultManager: VaultManager;
acl: ACL;
connectionInfoGetter: ConnectionInfoGetter;
connectionInfoGet: ConnectionInfoGet;
}) {
return async (
call: grpc.ServerWritableStream<vaultsPB.InfoRequest, vaultsPB.PackChunk>,
Expand All @@ -43,10 +43,12 @@ function vaultsGitInfoGet({
}
}
// Getting the NodeId from the ReverseProxy connection info
const connectionInfo = connectionInfoGetter(call.getPeer());
const connectionInfo = connectionInfoGet(call);
// If this is getting run the connection exists
// It SHOULD exist here
if (connectionInfo == null) never();
if (connectionInfo == null) {
throw new agentErrors.ErrorConnectionInfoMissing();
}
const nodeId = connectionInfo.nodeId;
const nodeIdEncoded = nodesUtils.encodeNodeId(nodeId);
const actionType = validationUtils.parseVaultAction(request.getAction());
Expand Down
14 changes: 8 additions & 6 deletions src/agent/service/vaultsGitPackGet.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import type * as grpc from '@grpc/grpc-js';
import type { VaultName } from '../../vaults/types';
import type { VaultManager } from '../../vaults';
import type { ConnectionInfoGetter } from '../../agent/types';
import type { ConnectionInfoGet } from '../../agent/types';
import type ACL from '../../acl/ACL';
import { never } from '../../utils/utils';
import * as nodesUtils from '../../nodes/utils';
import { errors as grpcErrors, utils as grpcUtils } from '../../grpc';
import { utils as vaultsUtils, errors as vaultsErrors } from '../../vaults';
import * as vaultsPB from '../../proto/js/polykey/v1/vaults/vaults_pb';
import * as validationUtils from '../../validation/utils';
import * as agentErrors from '../errors';

function vaultsGitPackGet({
vaultManager,
acl,
connectionInfoGetter,
connectionInfoGet,
}: {
vaultManager: VaultManager;
acl: ACL;
connectionInfoGetter: ConnectionInfoGetter;
connectionInfoGet: ConnectionInfoGet;
}) {
return async (
call: grpc.ServerDuplexStream<vaultsPB.PackChunk, vaultsPB.PackChunk>,
Expand All @@ -29,10 +29,12 @@ function vaultsGitPackGet({
const body = Buffer.concat(clientBodyBuffers);
const meta = call.metadata;
// Getting the NodeId from the ReverseProxy connection info
const connectionInfo = connectionInfoGetter(call.getPeer());
const connectionInfo = connectionInfoGet(call);
// If this is getting run the connection exists
// It SHOULD exist here
if (connectionInfo == null) never();
if (connectionInfo == null) {
throw new agentErrors.ErrorConnectionInfoMissing();
}
const nodeId = connectionInfo.nodeId;
const nodeIdEncoded = nodesUtils.encodeNodeId(nodeId);
// Getting vaultId
Expand Down

0 comments on commit 2523d70

Please sign in to comment.