From c7c7162d650444a1f1fbe0df12d564a98e43274f Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Mon, 4 Sep 2023 16:00:11 +0100 Subject: [PATCH 1/2] feat: add handshake body checks on 'successful' handhshakes --- packages/core/src/lib/lit-core.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/core/src/lib/lit-core.ts b/packages/core/src/lib/lit-core.ts index 41b6e1a44b..ef937e4b0b 100644 --- a/packages/core/src/lib/lit-core.ts +++ b/packages/core/src/lib/lit-core.ts @@ -149,6 +149,21 @@ export class LitCore { networkPubKeySet: resp.networkPublicKeySet, }; + // -- validate returned keys + if ( + keys.serverPubKey === 'ERR' || + keys.subnetPubKey === 'ERR' || + keys.networkPubKey === 'ERR' || + keys.networkPubKeySet === 'ERR' + ) { + log('Error connecting to node ', url, keys); + throwError({ + message: `Error connecting to node ${url}`, + errorKind: LIT_ERROR.INVALID_ARGUMENT_EXCEPTION.kind, + errorCode: LIT_ERROR.INVALID_ARGUMENT_EXCEPTION.name, + }); + } + this.serverKeys[url] = keys; }) .catch((e: any) => { From 822beb6908ccf9560cf894ff4ef0a866a0e0bb36 Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Mon, 4 Sep 2023 17:02:36 +0100 Subject: [PATCH 2/2] fix: remove throwing error --- packages/core/src/lib/lit-core.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/core/src/lib/lit-core.ts b/packages/core/src/lib/lit-core.ts index ef937e4b0b..306b751339 100644 --- a/packages/core/src/lib/lit-core.ts +++ b/packages/core/src/lib/lit-core.ts @@ -156,12 +156,7 @@ export class LitCore { keys.networkPubKey === 'ERR' || keys.networkPubKeySet === 'ERR' ) { - log('Error connecting to node ', url, keys); - throwError({ - message: `Error connecting to node ${url}`, - errorKind: LIT_ERROR.INVALID_ARGUMENT_EXCEPTION.kind, - errorCode: LIT_ERROR.INVALID_ARGUMENT_EXCEPTION.name, - }); + log('Error connecting to node. Detected "ERR" in keys', url, keys); } this.serverKeys[url] = keys;