diff --git a/src/nodes/NodeManager.ts b/src/nodes/NodeManager.ts index bfe57bace..c9da96208 100644 --- a/src/nodes/NodeManager.ts +++ b/src/nodes/NodeManager.ts @@ -48,6 +48,7 @@ import { MDNS, events as mdnsEvents, utils as mdnsUtils } from '@matrixai/mdns'; import * as nodesUtils from './utils'; import * as nodesEvents from './events'; import * as nodesErrors from './errors'; +import * as agentErrors from './agent/errors'; import NodeConnectionQueue from './NodeConnectionQueue'; import Token from '../tokens/Token'; import * as keysUtils from '../keys/utils'; @@ -1552,7 +1553,7 @@ class NodeManager { requestingNodeId: NodeId, input: AgentRPCRequestParams, tran?: DBTransaction, - ): Promise> { + ): Promise> { if (tran == null) { return this.db.withTransactionF((tran) => this.handleVerifyClaimNetwork(requestingNodeId, input, tran), @@ -1620,8 +1621,12 @@ class NodeManager { } } + if (!success) { + throw new agentErrors.ErrorNodesClaimNetworkVerificationFailed(); + } + return { - success: success, + success: true, } } diff --git a/src/nodes/agent/handlers/NodesClaimNetworkVerify.ts b/src/nodes/agent/handlers/NodesClaimNetworkVerify.ts index e5d64df63..d73bc5ef8 100644 --- a/src/nodes/agent/handlers/NodesClaimNetworkVerify.ts +++ b/src/nodes/agent/handlers/NodesClaimNetworkVerify.ts @@ -19,13 +19,13 @@ class NodesClaimNetworkVerify extends UnaryHandler< nodeManager: NodeManager; }, AgentRPCRequestParams, - AgentRPCResponseResult<{ success: boolean }> + AgentRPCResponseResult<{ success: true }> > { public handle = async ( input: AgentRPCRequestParams, _cancel, meta: Record | undefined, - ): Promise> => { + ): Promise> => { const requestingNodeId = agentUtils.nodeIdFromMeta(meta); if (requestingNodeId == null) { throw new agentErrors.ErrorAgentNodeIdMissing(); diff --git a/tests/nodes/agent/handlers/nodesNetworkVerifyClaim.test.ts b/tests/nodes/agent/handlers/nodesClaimNetworkVerify.test.ts similarity index 100% rename from tests/nodes/agent/handlers/nodesNetworkVerifyClaim.test.ts rename to tests/nodes/agent/handlers/nodesClaimNetworkVerify.test.ts