From a401b0467d1daffa13e4c04e96a83589cb7da850 Mon Sep 17 00:00:00 2001 From: Amy Yan Date: Tue, 13 Aug 2024 15:02:35 +1000 Subject: [PATCH] wip --- src/nodes/NodeManager.ts | 6 ++++-- .../agent/handlers/NodesNetworkVerifyClaim.ts | 15 ++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/nodes/NodeManager.ts b/src/nodes/NodeManager.ts index 4b5ec7db1..7694240f9 100644 --- a/src/nodes/NodeManager.ts +++ b/src/nodes/NodeManager.ts @@ -1552,7 +1552,7 @@ class NodeManager { requestingNodeId: NodeId, input: AgentRPCRequestParams, tran?: DBTransaction, - ): Promise> { + ): Promise> { if (tran == null) { return this.db.withTransactionF((tran) => this.handleVerifyClaimNetwork(requestingNodeId, input, tran), @@ -1586,7 +1586,9 @@ class NodeManager { } } - throw new Error(); + return { + success: isAuthenticated, + } } /** diff --git a/src/nodes/agent/handlers/NodesNetworkVerifyClaim.ts b/src/nodes/agent/handlers/NodesNetworkVerifyClaim.ts index 76df808bf..55ab3f345 100644 --- a/src/nodes/agent/handlers/NodesNetworkVerifyClaim.ts +++ b/src/nodes/agent/handlers/NodesNetworkVerifyClaim.ts @@ -1,4 +1,5 @@ import type { + AgentClaimMessage, AgentRPCRequestParams, AgentRPCResponseResult, } from '../types'; @@ -13,7 +14,7 @@ import { never } from '../../../utils'; import * as keysUtils from '../../../keys/utils'; import * as ids from '../../../ids'; -class NodesNetworkAuthenticate extends UnaryHandler< +class NodesNetworkVerifyClaim extends UnaryHandler< { nodeManager: NodeManager; }, @@ -21,12 +22,16 @@ class NodesNetworkAuthenticate extends UnaryHandler< AgentRPCResponseResult<{}> > { public handle = async ( - input: AgentRPCRequestParams<{}>, + input: AgentRPCRequestParams, _cancel, meta: Record | undefined, - ): Promise> => { - return {}; + ): Promise> => { + const requestingNodeId = agentUtils.nodeIdFromMeta(meta); + if (requestingNodeId == null) { + throw new agentErrors.ErrorAgentNodeIdMissing(); + } + return this.container.nodeManager.handleVerifyClaimNetwork(requestingNodeId, input); }; } -export default NodesNetworkAuthenticate; +export default NodesNetworkVerifyClaim;