From 26f15e16c631c62fed86ed762cabb87de8d7a255 Mon Sep 17 00:00:00 2001 From: Youngone Lee Date: Tue, 28 Sep 2021 12:25:56 -0500 Subject: [PATCH] refactor: typecast to adapt to typescript v4.4 Signed-off-by: Youngone Lee --- .../admin-enroll-v1-endpoint.test.ts | 11 +-- .../dao-token/get-allowance-endpoint.ts | 2 +- .../enroll-admin-v1-endpoint.ts | 2 +- .../insert-bamboo-harvest-endpoint.ts | 2 +- .../web-services/insert-bookshelf-endpoint.ts | 2 +- .../web-services/insert-shipment-endpoint.ts | 2 +- .../list-bamboo-harvest-endpoint.ts | 2 +- .../web-services/list-bookshelf-endpoint.ts | 2 +- .../web-services/list-shipment-endpoint.ts | 2 +- .../typescript/plugin-object-store-ipfs.ts | 14 +++- .../web-services/get-object-endpoint-v1.ts | 2 +- .../web-services/has-object-endpoint-v1.ts | 2 +- .../web-services/set-object-endpoint-v1.ts | 2 +- package.json | 2 +- .../typescript/default-consortium-provider.ts | 2 +- .../default-consortium-provider.test.ts | 15 ++-- .../src/main/typescript/api-server.ts | 9 ++- .../main/typescript/config/config-service.ts | 4 +- .../watch-healthcheck-v1-endpoint.ts | 2 +- .../web-services/deploy-contract-endpoint.ts | 2 +- .../web-services/run-transaction-endpoint.ts | 2 +- .../unprotected-action-endpoint.ts | 2 +- ...t-endpoint-authz-scope-enforcement.test.ts | 14 ++-- .../src/main/typescript/servers.ts | 2 +- .../register-web-service-endpoint.ts | 2 +- .../get-consortium-jws-endpoint-v1.ts | 4 +- .../consortium/get-node-jws-endpoint-v1.ts | 4 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 4 +- .../get-single-status-endpoint.ts | 2 +- .../web-services/get-status-endpoint.ts | 2 +- .../web-services/initialize-endpoint.ts | 2 +- .../web-services/new-contract-endpoint.ts | 2 +- .../web-services/refund-endpoint.ts | 2 +- .../web-services/withdraw-endpoint.ts | 2 +- .../get-single-status-endpoint.ts | 2 +- .../web-services/get-status-endpoint.ts | 2 +- .../web-services/initialize-endpoint.ts | 2 +- .../web-services/new-contract-endpoint.ts | 2 +- .../web-services/refund-endpoint.ts | 2 +- .../web-services/withdraw-endpoint.ts | 2 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 4 +- .../main/typescript/plugin-keychain-vault.ts | 4 +- .../delete-keychain-entry-endpoint-v1.ts | 2 +- .../get-keychain-entry-endpoint-v1.ts | 2 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 4 +- .../has-keychain-entry-endpoint-v1.ts | 2 +- .../set-keychain-entry-endpoint-v1.ts | 2 +- .../openapi/openapi-validation.test.ts | 32 ++++----- ...loy-contract-solidity-bytecode-endpoint.ts | 2 +- .../web-services/get-balance-endpoint.ts | 2 +- .../get-besu-record-endpoint-v1.ts | 2 +- .../web-services/get-block-v1-endpoint-.ts | 2 +- .../web-services/get-past-logs-endpoint.ts | 2 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 4 +- .../web-services/get-transaction-endpoint.ts | 2 +- .../web-services/invoke-contract-endpoint.ts | 2 +- .../web-services/run-transaction-endpoint.ts | 2 +- .../sign-transaction-endpoint-v1.ts | 4 +- .../deploy-contract-jars-endpoint.ts | 4 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 4 +- .../invoke-contract-endpoint-v1.ts | 4 +- .../deploy-contract-go-source-endpoint-v1.ts | 4 +- .../deploy-contract-endpoint-v1.ts | 4 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 4 +- .../plugin-ledger-connector-fabric.ts | 12 ++-- .../run-transaction-endpoint-v1.ts | 4 +- .../plugin-ledger-connector-iroha.ts | 68 +++++++++---------- ...prometheus-exporter-metrics-endpoint-v1.ts | 4 +- .../web-services/run-transaction-endpoint.ts | 4 +- .../plugin-ledger-connector-quorum.ts | 2 +- ...-solidity-bytecode-endpoint-json-object.ts | 2 +- ...loy-contract-solidity-bytecode-endpoint.ts | 2 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 4 +- .../invoke-contract-endpoint-json-object.ts | 2 +- .../web-services/invoke-contract-endpoint.ts | 2 +- .../web-services/run-transaction-endpoint.ts | 2 +- .../openapi/openapi-validation.test.ts | 24 +++---- ...loy-contract-solidity-bytecode-endpoint.ts | 2 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 4 +- .../web-services/invoke-contract-endpoint.ts | 2 +- .../web-services/run-transaction-endpoint.ts | 2 +- .../openapi/openapi-validation.test.ts | 24 +++---- .../openapi/openapi-validation.test.ts | 8 +-- .../initialize-endpoint.test.ts | 2 +- .../new-contract-endpoint.test.ts | 2 +- .../refund-endpoint.test.ts | 2 +- .../withdraw-endpoint.test.ts | 2 +- ...get-single-status-endpoint-invalid.test.ts | 2 +- .../get-status-endpoint-invalid.test.ts | 2 +- .../new-contract-endpoint-invalid.test.ts | 2 +- .../refund-endpoint-invalid.test.ts | 2 +- .../withdraw-endpoint-invalid.test.ts | 2 +- .../sign-transaction-endpoint.test.ts | 8 ++- .../v21-sign-transaction-endpoint.test.ts | 8 ++- .../src/main/typescript/common/containers.ts | 9 ++- .../fabric/fabric-test-ledger-v1.ts | 10 +-- .../typescript/quorum/quorum-test-ledger.ts | 4 +- .../integration/common/containers.test.ts | 8 ++- yarn.lock | 5 ++ 99 files changed, 269 insertions(+), 216 deletions(-) diff --git a/examples/cactus-example-carbon-accounting-backend/src/test/typescript/integration/admin-enroll-v1-endpoint.test.ts b/examples/cactus-example-carbon-accounting-backend/src/test/typescript/integration/admin-enroll-v1-endpoint.test.ts index b6837462080..c00be6b4834 100644 --- a/examples/cactus-example-carbon-accounting-backend/src/test/typescript/integration/admin-enroll-v1-endpoint.test.ts +++ b/examples/cactus-example-carbon-accounting-backend/src/test/typescript/integration/admin-enroll-v1-endpoint.test.ts @@ -157,14 +157,17 @@ test(testCase, async (t: Test) => { t.fail("enroll admin response status === 403 FAIL"); } catch (out) { t.ok(out, "error thrown for forbidden endpoint truthy OK"); - t.ok(out.response, "enroll admin response truthy OK"); + t.ok((out as any).response, "enroll admin response truthy OK"); t.equal( - out.response.status, + (out as any).response.status, StatusCodes.FORBIDDEN, "enroll admin response status === 403 OK", ); - t.notok(out.response.data.data, "out.response.data.data falsy OK"); - t.notok(out.response.data.success, "out.response.data.success falsy OK"); + t.notok((out as any).response.data.data, "out.response.data.data falsy OK"); + t.notok( + (out as any).response.data.success, + "out.response.data.success falsy OK", + ); } t.end(); diff --git a/examples/cactus-example-carbon-accounting-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/dao-token/get-allowance-endpoint.ts b/examples/cactus-example-carbon-accounting-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/dao-token/get-allowance-endpoint.ts index 9d4c468e641..bc95eb0bb8a 100644 --- a/examples/cactus-example-carbon-accounting-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/dao-token/get-allowance-endpoint.ts +++ b/examples/cactus-example-carbon-accounting-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/dao-token/get-allowance-endpoint.ts @@ -84,7 +84,7 @@ export class GetAllowanceEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/examples/cactus-example-carbon-accounting-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/utility-emissions-channel/enroll-admin-v1-endpoint.ts b/examples/cactus-example-carbon-accounting-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/utility-emissions-channel/enroll-admin-v1-endpoint.ts index 7f5bb9dc987..42603fe41f3 100644 --- a/examples/cactus-example-carbon-accounting-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/utility-emissions-channel/enroll-admin-v1-endpoint.ts +++ b/examples/cactus-example-carbon-accounting-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/utility-emissions-channel/enroll-admin-v1-endpoint.ts @@ -78,7 +78,7 @@ export class EnrollAdminV1Endpoint implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-bamboo-harvest-endpoint.ts b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-bamboo-harvest-endpoint.ts index b398a17eac9..0cd8740d5e6 100644 --- a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-bamboo-harvest-endpoint.ts +++ b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-bamboo-harvest-endpoint.ts @@ -130,7 +130,7 @@ export class InsertBambooHarvestEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-bookshelf-endpoint.ts b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-bookshelf-endpoint.ts index 00bdc60c96c..24b2dc287e0 100644 --- a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-bookshelf-endpoint.ts +++ b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-bookshelf-endpoint.ts @@ -117,7 +117,7 @@ export class InsertBookshelfEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-shipment-endpoint.ts b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-shipment-endpoint.ts index 24fe108860e..881b0bd8eb0 100644 --- a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-shipment-endpoint.ts +++ b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/insert-shipment-endpoint.ts @@ -117,7 +117,7 @@ export class InsertShipmentEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bamboo-harvest-endpoint.ts b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bamboo-harvest-endpoint.ts index 246f9c6ce65..d750d040b1a 100644 --- a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bamboo-harvest-endpoint.ts +++ b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bamboo-harvest-endpoint.ts @@ -119,7 +119,7 @@ export class ListBambooHarvestEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bookshelf-endpoint.ts b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bookshelf-endpoint.ts index 06d6323c84b..0d5d0c3dc54 100644 --- a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bookshelf-endpoint.ts +++ b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bookshelf-endpoint.ts @@ -117,7 +117,7 @@ export class ListBookshelfEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-shipment-endpoint.ts b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-shipment-endpoint.ts index 0a08d7fc8b2..bf84ca09700 100644 --- a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-shipment-endpoint.ts +++ b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-shipment-endpoint.ts @@ -115,7 +115,7 @@ export class ListShipmentEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/plugin-object-store-ipfs.ts b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/plugin-object-store-ipfs.ts index d28a32d1a17..0afa40b6514 100644 --- a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/plugin-object-store-ipfs.ts +++ b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/plugin-object-store-ipfs.ts @@ -156,12 +156,17 @@ export class PluginObjectStoreIpfs implements IPluginObjectStore { this.log.debug(`StatResult for ${req.key}: %o`, statResult); return { key: req.key, checkedAt, isPresent: true }; } catch (ex) { - if (ex?.stack?.includes(K_IPFS_JS_HTTP_ERROR_FILE_DOES_NOT_EXIST)) { + if ( + (ex as Error)?.stack?.includes(K_IPFS_JS_HTTP_ERROR_FILE_DOES_NOT_EXIST) + ) { const msg = `Stat ${req.key} failed with error message containing phrase "${K_IPFS_JS_HTTP_ERROR_FILE_DOES_NOT_EXIST}" Returning isPresent=false ...`; this.log.debug(msg); return { key: req.key, checkedAt, isPresent: false }; } else { - throw new RuntimeError(`Checking presence of ${req.key} crashed:`, ex); + throw new RuntimeError( + `Checking presence of ${req.key} crashed:`, + ex as Error, + ); } } } @@ -176,7 +181,10 @@ export class PluginObjectStoreIpfs implements IPluginObjectStore { parents: true, }); } catch (ex) { - throw new RuntimeError(`Can't set object ${keyPath}. Write failed:`, ex); + throw new RuntimeError( + `Can't set object ${keyPath}. Write failed:`, + ex as Error, + ); } return { key: req.key, diff --git a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/get-object-endpoint-v1.ts b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/get-object-endpoint-v1.ts index 6003ffef6e7..6bef5239db5 100644 --- a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/get-object-endpoint-v1.ts +++ b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/get-object-endpoint-v1.ts @@ -94,7 +94,7 @@ export class GetObjectEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/has-object-endpoint-v1.ts b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/has-object-endpoint-v1.ts index c7ba9589303..8124069c20a 100644 --- a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/has-object-endpoint-v1.ts +++ b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/has-object-endpoint-v1.ts @@ -94,7 +94,7 @@ export class HasObjectEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/set-object-endpoint-v1.ts b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/set-object-endpoint-v1.ts index 2abae0dd400..d8e1b07014c 100644 --- a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/set-object-endpoint-v1.ts +++ b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/set-object-endpoint-v1.ts @@ -94,7 +94,7 @@ export class SetObjectEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/package.json b/package.json index 9bdc9ef6c6e..5e25d339735 100644 --- a/package.json +++ b/package.json @@ -134,7 +134,7 @@ "tape-promise": "4.0.0", "ts-loader": "9.2.5", "ts-node": "10.2.0", - "typescript": "4.3.5", + "typescript": "4.4.3", "webpack": "5.50.0", "webpack-bundle-analyzer": "4.4.2", "webpack-cli": "4.7.2" diff --git a/packages/cactus-api-client/src/main/typescript/default-consortium-provider.ts b/packages/cactus-api-client/src/main/typescript/default-consortium-provider.ts index bc2819efd01..9db359fff54 100644 --- a/packages/cactus-api-client/src/main/typescript/default-consortium-provider.ts +++ b/packages/cactus-api-client/src/main/typescript/default-consortium-provider.ts @@ -64,7 +64,7 @@ export class DefaultConsortiumProvider const res = await this.options.apiClient.getConsortiumJwsV1(); return this.parseConsortiumJws(res.data); } catch (ex) { - const innerException = (ex.toJSON && ex.toJSON()) || ex; + const innerException = ((ex as any).toJSON && (ex as any).toJSON()) || ex; this.log.error(`Request for Consortium JWS failed: `, innerException); throw ex; } diff --git a/packages/cactus-api-client/src/test/typescript/integration/default-consortium-provider.test.ts b/packages/cactus-api-client/src/test/typescript/integration/default-consortium-provider.test.ts index ba910ff1342..605fa89eebe 100644 --- a/packages/cactus-api-client/src/test/typescript/integration/default-consortium-provider.test.ts +++ b/packages/cactus-api-client/src/test/typescript/integration/default-consortium-provider.test.ts @@ -33,13 +33,16 @@ test("Reports failures with meaningful information", async (t: Test) => { t2.fail("Provider.get() did not throw despite API errors."); } catch (ex) { t2.ok(ex, "Thrown error truthy OK"); - t2.ok(ex.message, "Thrown error.message truthy OK"); + t2.ok((ex as Error).message, "Thrown error.message truthy OK"); t2.equal( - typeof ex.message, + typeof (ex as Error).message, "string", "Thrown error.message type string OK", ); - t2.true(ex.message.includes("timeout"), "Has timeout in msg OK"); + t2.true( + (ex as Error).message.includes("timeout"), + "Has timeout in msg OK", + ); } t2.end(); }); @@ -58,14 +61,14 @@ test("Reports failures with meaningful information", async (t: Test) => { t2.fail("Provider.get() did not throw despite API errors."); } catch (ex) { t2.ok(ex, "Thrown error truthy OK"); - t2.ok(ex.message, "Thrown error.message truthy OK"); + t2.ok((ex as Error).message, "Thrown error.message truthy OK"); t2.equal( - typeof ex.message, + typeof (ex as Error).message, "string", "Thrown error.message type string OK", ); t2.true( - ex.message.includes("status code 404"), + (ex as Error).message.includes("status code 404"), "Has Status Code in msg OK", ); } diff --git a/packages/cactus-cmd-api-server/src/main/typescript/api-server.ts b/packages/cactus-cmd-api-server/src/main/typescript/api-server.ts index 0757ada57b7..f4fcb12a754 100644 --- a/packages/cactus-cmd-api-server/src/main/typescript/api-server.ts +++ b/packages/cactus-cmd-api-server/src/main/typescript/api-server.ts @@ -216,7 +216,7 @@ export class ApiServer { return { addressInfoCockpit, addressInfoApi, addressInfoGrpc }; } catch (ex) { - const errorMessage = `Failed to start ApiServer: ${ex.stack}`; + const errorMessage = `Failed to start ApiServer: ${(ex as Error).stack}`; this.log.error(errorMessage); this.log.error(`Attempting shutdown...`); try { @@ -332,7 +332,7 @@ export class ApiServer { } catch (ex) { const errorMessage = "Could not create plugin installation directory, check the file-system permissions."; - throw new RuntimeError(errorMessage, ex); + throw new RuntimeError(errorMessage, ex as Error); } try { lmify.setPackageManager("npm"); @@ -355,7 +355,10 @@ export class ApiServer { } this.log.info(`Installed ${pkgName} OK`); } catch (ex) { - throw new RuntimeError(`${fnTag} plugin install fail: ${pkgName}`, ex); + throw new RuntimeError( + `${fnTag} plugin install fail: ${pkgName}`, + ex as Error, + ); } } diff --git a/packages/cactus-cmd-api-server/src/main/typescript/config/config-service.ts b/packages/cactus-cmd-api-server/src/main/typescript/config/config-service.ts index 63e9fff734c..38b31056f9b 100644 --- a/packages/cactus-cmd-api-server/src/main/typescript/config/config-service.ts +++ b/packages/cactus-cmd-api-server/src/main/typescript/config/config-service.ts @@ -624,7 +624,9 @@ export class ConfigService { try { JWS.verify(jws, keyPair); } catch (ex) { - throw new Error(`${fnTag} Invalid key pair PEM: ${ex && ex.stack}`); + throw new Error( + `${fnTag} Invalid key pair PEM: ${ex && (ex as Error).stack}`, + ); } } } diff --git a/packages/cactus-cmd-api-server/src/main/typescript/web-services/watch-healthcheck-v1-endpoint.ts b/packages/cactus-cmd-api-server/src/main/typescript/web-services/watch-healthcheck-v1-endpoint.ts index c6db12eea01..db6f5bc3cee 100644 --- a/packages/cactus-cmd-api-server/src/main/typescript/web-services/watch-healthcheck-v1-endpoint.ts +++ b/packages/cactus-cmd-api-server/src/main/typescript/web-services/watch-healthcheck-v1-endpoint.ts @@ -53,7 +53,7 @@ export class WatchHealthcheckV1Endpoint { socket.emit(WatchHealthcheckV1.Next, next); } catch (ex) { log.error(`Failed to construct health check response:`, ex); - socket.emit(WatchHealthcheckV1.Error, ex); + socket.emit(WatchHealthcheckV1.Error, ex as Error); clearInterval(timerId); } }, 1000); diff --git a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/deploy-contract-endpoint.ts b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/deploy-contract-endpoint.ts index a635c6cc8e8..dab841b1404 100644 --- a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/deploy-contract-endpoint.ts +++ b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/deploy-contract-endpoint.ts @@ -104,7 +104,7 @@ export class DeployContractEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/run-transaction-endpoint.ts b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/run-transaction-endpoint.ts index a65646909c3..372b3587edd 100644 --- a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/run-transaction-endpoint.ts +++ b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/run-transaction-endpoint.ts @@ -102,7 +102,7 @@ export class RunTransactionEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/unprotected-action-endpoint.ts b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/unprotected-action-endpoint.ts index 7b0b9d6b0bb..41a7699402b 100644 --- a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/unprotected-action-endpoint.ts +++ b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/unprotected-action-endpoint.ts @@ -108,7 +108,7 @@ export class UnprotectedActionEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-cmd-api-server/src/test/typescript/integration/jwt-endpoint-authz-scope-enforcement.test.ts b/packages/cactus-cmd-api-server/src/test/typescript/integration/jwt-endpoint-authz-scope-enforcement.test.ts index 1bb8aa70ce8..e2c4bff1165 100644 --- a/packages/cactus-cmd-api-server/src/test/typescript/integration/jwt-endpoint-authz-scope-enforcement.test.ts +++ b/packages/cactus-cmd-api-server/src/test/typescript/integration/jwt-endpoint-authz-scope-enforcement.test.ts @@ -143,14 +143,20 @@ test(testCase, async (t: Test) => { t.fail("deploy contract response status === 403 FAIL"); } catch (out) { t.ok(out, "error thrown for forbidden endpoint truthy OK"); - t.ok(out.response, "deploy contract response truthy OK"); + t.ok((out as any).response, "deploy contract response truthy OK"); t.equal( - out.response.status, + (out as any).response.status, StatusCodes.FORBIDDEN, "deploy contract response status === 403 OK", ); - t.notok(out.response.data.data, "out.response.data.data falsy OK"); - t.notok(out.response.data.success, "out.response.data.success falsy OK"); + t.notok( + (out as any).response.data.data, + "(out as any).response.data.data falsy OK", + ); + t.notok( + (out as any).response.data.success, + "(out as any).response.data.success falsy OK", + ); } t.end(); } catch (ex) { diff --git a/packages/cactus-common/src/main/typescript/servers.ts b/packages/cactus-common/src/main/typescript/servers.ts index 21ba40b4f36..2919a0c9c9e 100644 --- a/packages/cactus-common/src/main/typescript/servers.ts +++ b/packages/cactus-common/src/main/typescript/servers.ts @@ -90,7 +90,7 @@ export class Servers { return server; } catch (ex) { // if something else went wrong we still want to just give up - if (!ex.message.includes("EADDRINUSE")) { + if (ex instanceof Error && !ex.message.includes("EADDRINUSE")) { throw ex; } } diff --git a/packages/cactus-core/src/main/typescript/web-services/register-web-service-endpoint.ts b/packages/cactus-core/src/main/typescript/web-services/register-web-service-endpoint.ts index b6f7693aecd..029e2fbe583 100644 --- a/packages/cactus-core/src/main/typescript/web-services/register-web-service-endpoint.ts +++ b/packages/cactus-core/src/main/typescript/web-services/register-web-service-endpoint.ts @@ -32,7 +32,7 @@ export async function registerWebServiceEndpoint( } catch (ex) { throw new Error( `${fnTag} Express verb method ${httpVerb} threw ` + - ` while registering endpoint: ${ex.message}`, + ` while registering endpoint: ${(ex as Error).message}`, ); } } diff --git a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-consortium-jws-endpoint-v1.ts b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-consortium-jws-endpoint-v1.ts index ce630c1a7d5..db13f055d20 100644 --- a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-consortium-jws-endpoint-v1.ts +++ b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-consortium-jws-endpoint-v1.ts @@ -110,8 +110,8 @@ export class GetConsortiumEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-node-jws-endpoint-v1.ts b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-node-jws-endpoint-v1.ts index 0dc8bb71c18..06b540f307c 100644 --- a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-node-jws-endpoint-v1.ts +++ b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-node-jws-endpoint-v1.ts @@ -106,8 +106,8 @@ export class GetNodeJwsEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-prometheus-exporter-metrics-endpoint-v1.ts index 016a6f81c23..57ec073cd29 100644 --- a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -94,8 +94,8 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-single-status-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-single-status-endpoint.ts index b1a18c982ec..b78b1ad6e05 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-single-status-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-single-status-endpoint.ts @@ -96,7 +96,7 @@ export class GetSingleStatusEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(400).json({ message: "Bad request", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-status-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-status-endpoint.ts index 27e388a6de7..2bbc9262bfe 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-status-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-status-endpoint.ts @@ -99,7 +99,7 @@ export class GetStatusEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(400).json({ message: "Bad request", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/initialize-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/initialize-endpoint.ts index d874da9cbb3..a8a3eb156a3 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/initialize-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/initialize-endpoint.ts @@ -91,7 +91,7 @@ export class InitializeEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(400).json({ message: "Bad request", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/new-contract-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/new-contract-endpoint.ts index ec7a2731bb1..f3e729fdff3 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/new-contract-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/new-contract-endpoint.ts @@ -87,7 +87,7 @@ export class NewContractEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(400).json({ message: "Bad request", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/refund-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/refund-endpoint.ts index a838285823a..0cb9d816156 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/refund-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/refund-endpoint.ts @@ -87,7 +87,7 @@ export class RefundEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(400).json({ message: "Bad request", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/withdraw-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/withdraw-endpoint.ts index 2a0bad65605..c9a0c433c3f 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/withdraw-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/withdraw-endpoint.ts @@ -87,7 +87,7 @@ export class WithdrawEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(400).json({ message: "Bad request", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-single-status-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-single-status-endpoint.ts index 38980472de6..7af32d6cc24 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-single-status-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-single-status-endpoint.ts @@ -104,7 +104,7 @@ export class GetSingleStatusEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-status-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-status-endpoint.ts index df91fcdf3eb..f38b53e4e50 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-status-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-status-endpoint.ts @@ -104,7 +104,7 @@ export class GetStatusEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/initialize-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/initialize-endpoint.ts index 0bd31291e84..cd02e9a6e33 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/initialize-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/initialize-endpoint.ts @@ -96,7 +96,7 @@ export class InitializeEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/new-contract-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/new-contract-endpoint.ts index 9503c6e3d22..f6a93abd83e 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/new-contract-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/new-contract-endpoint.ts @@ -94,7 +94,7 @@ export class NewContractEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/refund-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/refund-endpoint.ts index 42876a41d1f..e85d023d8e8 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/refund-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/refund-endpoint.ts @@ -94,7 +94,7 @@ export class RefundEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/withdraw-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/withdraw-endpoint.ts index ee443d4f25f..edf53ea741c 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/withdraw-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/withdraw-endpoint.ts @@ -93,7 +93,7 @@ export class WithdrawEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-keychain-memory/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-keychain-memory/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts index 99be7a2e396..c13940b6642 100644 --- a/packages/cactus-plugin-keychain-memory/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-memory/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -94,8 +94,8 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts index b238d73ad33..9d99a346de1 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts @@ -233,7 +233,7 @@ export class PluginKeychainVault implements IPluginWebService, IPluginKeychain { } } catch (ex) { // FIXME: Throw if not found, detect it in the endpoint code, status=404 - if (ex?.response?.statusCode === HttpStatus.NOT_FOUND) { + if ((ex as any)?.response?.statusCode === HttpStatus.NOT_FOUND) { return (null as unknown) as string; } else { this.log.error(`Retrieval of "${key}" crashed:`, ex); @@ -260,7 +260,7 @@ export class PluginKeychainVault implements IPluginWebService, IPluginKeychain { // else being an unexpected exception that we do not want to // handle nor suppress under any circumstances since doing so // would lead to silent failures or worse. - if (ex?.response?.statusCode === HttpStatus.NOT_FOUND) { + if ((ex as any)?.response?.statusCode === HttpStatus.NOT_FOUND) { return false; } else { this.log.error(`Presence check of "${key}" crashed:`, ex); diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/delete-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/delete-keychain-entry-endpoint-v1.ts index 250a4fd2463..25dbfc9189c 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/delete-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/delete-keychain-entry-endpoint-v1.ts @@ -102,7 +102,7 @@ export class DeleteKeychainEntryEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-keychain-entry-endpoint-v1.ts index 1d2f22d67ff..670f8a21ffd 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-keychain-entry-endpoint-v1.ts @@ -103,7 +103,7 @@ export class GetKeychainEntryEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index 65a68e5dac2..7150fd08667 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -94,8 +94,8 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/has-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/has-keychain-entry-endpoint-v1.ts index 2af9d33d2f2..d17d0dcbbc8 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/has-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/has-keychain-entry-endpoint-v1.ts @@ -104,7 +104,7 @@ export class HasKeychainEntryEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/set-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/set-keychain-entry-endpoint-v1.ts index 2f4de99a243..0d4432371ae 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/set-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/set-keychain-entry-endpoint-v1.ts @@ -98,7 +98,7 @@ export class SetKeychainEntryEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); - res.json({ error: ex.stack }); + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/test/typescript/integration/openapi/openapi-validation.test.ts b/packages/cactus-plugin-keychain-vault/src/test/typescript/integration/openapi/openapi-validation.test.ts index 15f3456393f..598f4ad0219 100644 --- a/packages/cactus-plugin-keychain-vault/src/test/typescript/integration/openapi/openapi-validation.test.ts +++ b/packages/cactus-plugin-keychain-vault/src/test/typescript/integration/openapi/openapi-validation.test.ts @@ -144,11 +144,11 @@ test(`${testCase}`, async (t: Test) => { } as any) as SetKeychainEntryRequest); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fSet} without required key: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok(fields.includes("key"), "Rejected because key is required"); @@ -163,11 +163,11 @@ test(`${testCase}`, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fHas} without required key: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok(fields.includes("key"), "Rejected because key is required"); @@ -182,11 +182,11 @@ test(`${testCase}`, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fGet} without required key: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok(fields.includes("key"), "Rejected because key is required"); @@ -201,11 +201,11 @@ test(`${testCase}`, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fDelete} without required key: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok(fields.includes("key"), "Rejected because key is required"); @@ -222,11 +222,11 @@ test(`${testCase}`, async (t: Test) => { } as any) as SetKeychainEntryRequest); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fSet} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -245,11 +245,11 @@ test(`${testCase}`, async (t: Test) => { } as any) as HasKeychainEntryRequestV1); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fHas} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -268,11 +268,11 @@ test(`${testCase}`, async (t: Test) => { } as any) as GetKeychainEntryRequest); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fGet} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -291,11 +291,11 @@ test(`${testCase}`, async (t: Test) => { } as any) as GetKeychainEntryRequest); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fDelete} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts index cfd4b68349f..1a2023025bc 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts @@ -95,7 +95,7 @@ export class DeployContractSolidityBytecodeEndpoint this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-balance-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-balance-endpoint.ts index 34664ba566e..44e674507a6 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-balance-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-balance-endpoint.ts @@ -92,7 +92,7 @@ export class GetBalanceEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-besu-record-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-besu-record-endpoint-v1.ts index f40e93d2e91..47c658f69b4 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-besu-record-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-besu-record-endpoint-v1.ts @@ -95,7 +95,7 @@ export class GetBesuRecordEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-block-v1-endpoint-.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-block-v1-endpoint-.ts index 826723a7273..39653e060dc 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-block-v1-endpoint-.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-block-v1-endpoint-.ts @@ -92,7 +92,7 @@ export class GetBlockEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-past-logs-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-past-logs-endpoint.ts index 2537152b27c..33061512d93 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-past-logs-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-past-logs-endpoint.ts @@ -92,7 +92,7 @@ export class GetPastLogsEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index 55541efa1dc..2990d6ebc97 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -93,8 +93,8 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-transaction-endpoint.ts index 5c7f8960945..505fc4c9367 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-transaction-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-transaction-endpoint.ts @@ -92,7 +92,7 @@ export class GetTransactionEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/invoke-contract-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/invoke-contract-endpoint.ts index cf5e9aa3e1b..5829c39c164 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/invoke-contract-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/invoke-contract-endpoint.ts @@ -93,7 +93,7 @@ export class InvokeContractEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts index 6a5b05e20ac..3271ceefb3e 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts @@ -93,7 +93,7 @@ export class RunTransactionEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/sign-transaction-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/sign-transaction-endpoint-v1.ts index 7f9e0984c43..a1e5c442010 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/sign-transaction-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/sign-transaction-endpoint-v1.ts @@ -100,8 +100,8 @@ export class BesuSignTransactionEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/deploy-contract-jars-endpoint.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/deploy-contract-jars-endpoint.ts index 5a20a7479c2..be3040a9709 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/deploy-contract-jars-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/deploy-contract-jars-endpoint.ts @@ -133,9 +133,9 @@ export class DeployContractJarsEndpoint implements IWebServiceEndpoint { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); res.json({ - error: ex?.message, + error: (ex as Error)?.message, // FIXME do not include stack trace - errorStack: ex?.stack, + errorStack: (ex as Error)?.stack, }); } } diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index e1ba119bdc8..a0a84bf79ca 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -94,8 +94,8 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/invoke-contract-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/invoke-contract-endpoint-v1.ts index 24c5b3f77c8..da924875228 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/invoke-contract-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/invoke-contract-endpoint-v1.ts @@ -90,8 +90,8 @@ export class InvokeContractEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract-go-source/deploy-contract-go-source-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract-go-source/deploy-contract-go-source-endpoint-v1.ts index 18def8f1a5d..f475b7dac91 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract-go-source/deploy-contract-go-source-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract-go-source/deploy-contract-go-source-endpoint-v1.ts @@ -98,8 +98,8 @@ export class DeployContractGoSourceEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve contract deploy request`, ex); res.status(HttpStatus.INTERNAL_SERVER_ERROR); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract/deploy-contract-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract/deploy-contract-endpoint-v1.ts index 7d2f554bf3a..3500cf2e1ea 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract/deploy-contract-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract/deploy-contract-endpoint-v1.ts @@ -98,8 +98,8 @@ export class DeployContractEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve contract deploy request`, ex); res.status(HttpStatus.INTERNAL_SERVER_ERROR); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts index 4e6522d293a..7876ba8f7a0 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -93,8 +93,8 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts index 967031e5aac..5d9f658152c 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts @@ -1014,7 +1014,9 @@ export class PluginLedgerConnectorFabric } catch (ex) { this.log.error(`Building transient map crashed: `, ex); throw new Error( - `${fnTag} Unable to build the transient map: ${ex.message}`, + `${fnTag} Unable to build the transient map: ${ + (ex as Error).message + }`, ); } @@ -1047,7 +1049,9 @@ export class PluginLedgerConnectorFabric return res; } catch (ex) { this.log.error(`transact() crashed: `, ex); - throw new Error(`${fnTag} Unable to run transaction: ${ex.message}`); + throw new Error( + `${fnTag} Unable to run transaction: ${(ex as Error).message}`, + ); } } @@ -1072,7 +1076,7 @@ export class PluginLedgerConnectorFabric return new FabricCAServices(caUrl, tlsOptions, caName); } catch (ex) { this.log.error(`createCaClient() Failure:`, ex); - throw new Error(`${fnTag} Inner Exception: ${ex?.message}`); + throw new Error(`${fnTag} Inner Exception: ${(ex as Error)?.message}`); } } @@ -1108,7 +1112,7 @@ export class PluginLedgerConnectorFabric return [x509Identity, wallet]; } catch (ex) { this.log.error(`enrollAdmin() Failure:`, ex); - throw new Error(`${fnTag} Exception: ${ex?.message}`); + throw new Error(`${fnTag} Exception: ${(ex as Error)?.message}`); } } /** diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-transaction-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-transaction-endpoint-v1.ts index dcd016a6259..cafdc59ea0d 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-transaction-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-transaction-endpoint-v1.ts @@ -91,8 +91,8 @@ export class RunTransactionEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/plugin-ledger-connector-iroha.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/plugin-ledger-connector-iroha.ts index df19e76c16e..c3379c02eb7 100644 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/plugin-ledger-connector-iroha.ts +++ b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/plugin-ledger-connector-iroha.ts @@ -241,7 +241,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.SetAccountDetail: { @@ -253,7 +253,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.CompareAndSetAccountDetail: { @@ -269,7 +269,7 @@ export class PluginLedgerConnectorIroha ); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.CreateAsset: { @@ -282,7 +282,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.CreateDomain: { @@ -293,7 +293,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.SetAccountQuorum: { @@ -304,7 +304,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.AddAssetQuantity: { @@ -315,7 +315,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.SubtractAssetQuantity: { @@ -329,7 +329,7 @@ export class PluginLedgerConnectorIroha ); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.TransferAsset: { @@ -343,7 +343,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetSignatories: { @@ -353,7 +353,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: queryRes }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetAccount: { @@ -363,7 +363,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: queryRes }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetAccountDetail: { @@ -378,7 +378,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: queryRes }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetAssetInfo: { @@ -388,7 +388,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: queryRes }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetAccountAssets: { @@ -400,7 +400,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: queryRes }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.AddSignatory: { @@ -411,7 +411,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.RemoveSignatory: { @@ -422,7 +422,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetRoles: { @@ -430,7 +430,7 @@ export class PluginLedgerConnectorIroha const response = await queries.getRoles(queryOptions); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.CreateRole: { @@ -441,7 +441,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.AppendRole: { @@ -452,7 +452,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.DetachRole: { @@ -463,7 +463,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetRolePermissions: { @@ -473,7 +473,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.GrantPermission: { @@ -485,7 +485,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.RevokePermission: { @@ -497,7 +497,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.SetSettingValue: { @@ -510,7 +510,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetPendingTransactions: { @@ -521,7 +521,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetAccountTransactions: { @@ -533,7 +533,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetAccountAssetTransactions: { @@ -549,7 +549,7 @@ export class PluginLedgerConnectorIroha ); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetBlock: { @@ -559,7 +559,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.CallEngine: { @@ -572,7 +572,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetEngineReceipts: { @@ -582,7 +582,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.FetchCommits: { @@ -590,7 +590,7 @@ export class PluginLedgerConnectorIroha const response = await queries.fetchCommits(queryOptions); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.AddPeer: { @@ -601,7 +601,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaCommand.RemovePeer: { @@ -611,7 +611,7 @@ export class PluginLedgerConnectorIroha }); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } case IrohaQuery.GetPeers: { @@ -619,7 +619,7 @@ export class PluginLedgerConnectorIroha const response = await queries.getPeers(queryOptions); return { transactionReceipt: response }; } catch (err) { - throw new RuntimeError(err); + throw new RuntimeError(err as string); } } default: { diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index f1cbeb82661..c11dd17eda0 100644 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -87,8 +87,8 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/run-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/run-transaction-endpoint.ts index 53519852c42..10087eba459 100644 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/run-transaction-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/run-transaction-endpoint.ts @@ -103,7 +103,7 @@ export class RunTransactionEndpoint implements IWebServiceEndpoint { * "Error: Error: Command response error: expected=COMMITTED, actual=REJECTED" * @see https://iroha.readthedocs.io/en/main/develop/api/commands.html?highlight=CallEngine#id18 */ - if (ex.message.includes("Error: Command response error")) { + if ((ex as Error).message.includes("Error: Command response error")) { this.log.debug("Sending back HTTP400 Bad Request error."); res.status(400); res.json(ex); @@ -112,7 +112,7 @@ export class RunTransactionEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts index 3c078f67fdf..c908ab54ae2 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts @@ -479,7 +479,7 @@ export class PluginLedgerConnectorQuorum } catch (ex) { throw new Error( `${fnTag} Failed to invoke web3.eth.personal.sendTransaction(). ` + - `InnerException: ${ex.stack}`, + `InnerException: ${(ex as Error).stack}`, ); } } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts index 9b0e72c7d54..33d8dddf60f 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts @@ -102,7 +102,7 @@ export class DeployContractSolidityBytecodeJsonObjectEndpoint this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts index 14d348fffb8..d5217b8386a 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts @@ -95,7 +95,7 @@ export class DeployContractSolidityBytecodeEndpoint this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index 88b1eca0348..22b54ddd4c7 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -93,8 +93,8 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-json-object.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-json-object.ts index 00af8359ff4..4f6a80fd1bb 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-json-object.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-json-object.ts @@ -96,7 +96,7 @@ export class InvokeContractJsonObjectEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint.ts index a15ea9a8ef6..6bbf528e8dc 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint.ts @@ -94,7 +94,7 @@ export class InvokeContractEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/run-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/run-transaction-endpoint.ts index b26134087a8..efc70c366d1 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/run-transaction-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/run-transaction-endpoint.ts @@ -92,7 +92,7 @@ export class RunTransactionEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts index d8088b88452..953b60df71f 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts @@ -173,11 +173,11 @@ test(testCase, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fDeploy} without required contractName and bytecode: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -213,11 +213,11 @@ test(testCase, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fDeploy} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -274,11 +274,11 @@ test(testCase, async (t: Test) => { await apiClient.invokeContractV1(parameters as InvokeContractV1Request); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fInvoke} without required contractName and methodName: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -315,11 +315,11 @@ test(testCase, async (t: Test) => { await apiClient.invokeContractV1(parameters as InvokeContractV1Request); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fInvoke} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -366,11 +366,11 @@ test(testCase, async (t: Test) => { await apiClient.runTransactionV1(parameters as RunTransactionRequest); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fRun} without required transactionConfig: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -401,11 +401,11 @@ test(testCase, async (t: Test) => { await apiClient.runTransactionV1(parameters as RunTransactionRequest); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fRun} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts index 70e94a8f392..fd48271d692 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts @@ -95,7 +95,7 @@ export class DeployContractSolidityBytecodeEndpoint this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index ccac3b7803e..ca39a6e916d 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -93,8 +93,8 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + res.statusMessage = (ex as Error).message; + res.json({ error: (ex as Error).stack }); } } } diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/invoke-contract-endpoint.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/invoke-contract-endpoint.ts index ef93f648d34..08969e0f389 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/invoke-contract-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/invoke-contract-endpoint.ts @@ -92,7 +92,7 @@ export class InvokeContractEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/run-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/run-transaction-endpoint.ts index d25d2e35fea..7b3c66a4a16 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/run-transaction-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/run-transaction-endpoint.ts @@ -92,7 +92,7 @@ export class RunTransactionEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); res.status(500).json({ message: "Internal Server Error", - error: ex?.stack || ex?.message, + error: (ex as Error)?.stack || (ex as Error)?.message, }); } } diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation.test.ts b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation.test.ts index 4bd1c5c5f03..aa096959160 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation.test.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation.test.ts @@ -171,11 +171,11 @@ test(testCase, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fDeploy} without required keychainId: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -208,11 +208,11 @@ test(testCase, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fDeploy} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -267,11 +267,11 @@ test(testCase, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fInvoke} without required contractName: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -303,11 +303,11 @@ test(testCase, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fInvoke} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -366,11 +366,11 @@ test(testCase, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fRun} without required consistencyStrategy: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -408,11 +408,11 @@ test(testCase, async (t: Test) => { ); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fRun} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( diff --git a/packages/cactus-test-plugin-consortium-manual/src/test/typescript/integration/plugin-consortium-manual/openapi/openapi-validation.test.ts b/packages/cactus-test-plugin-consortium-manual/src/test/typescript/integration/plugin-consortium-manual/openapi/openapi-validation.test.ts index 88d76570610..34c2ddfbfb3 100644 --- a/packages/cactus-test-plugin-consortium-manual/src/test/typescript/integration/plugin-consortium-manual/openapi/openapi-validation.test.ts +++ b/packages/cactus-test-plugin-consortium-manual/src/test/typescript/integration/plugin-consortium-manual/openapi/openapi-validation.test.ts @@ -283,11 +283,11 @@ test(testCase, async (t: Test) => { await api.getNodeJwsV1({ fake: 4 }); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fGetNodeJwt} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( @@ -306,11 +306,11 @@ test(testCase, async (t: Test) => { await api.getConsortiumJwsV1({ fake: 4 }); } catch (e) { t2.equal( - e.response.status, + (e as any).response.status, 400, `Endpoint ${fGetConsortiumJws} with fake=4: response.status === 400 OK`, ); - const fields = e.response.data.map((param: any) => + const fields = (e as any).response.data.map((param: any) => param.path.replace(".body.", ""), ); t2.ok( diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/initialize-endpoint.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/initialize-endpoint.test.ts index a3531f34bf2..9811452b847 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/initialize-endpoint.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/initialize-endpoint.test.ts @@ -235,7 +235,7 @@ test("Test initialize function with invalid params", async (t: Test) => { const res = await api.initializeV1(request); t.equal(res.status, 400, "response status is 400"); } catch (error) { - t.equal(error.response.status, 400, "response status is 400"); + t.equal((error as any).response.status, 400, "response status is 400"); } t.end(); }); diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/new-contract-endpoint.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/new-contract-endpoint.test.ts index dfde2bb4c37..61ad6f585cb 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/new-contract-endpoint.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/new-contract-endpoint.test.ts @@ -403,7 +403,7 @@ test("Test new invalid contract with 0 inputAmount token for HTLC", async (t: Te const res = await api.newContractV1(request); t.equal(res.status, 400, "response status is 400"); } catch (error) { - t.equal(error.response.status, 400, "response status is 400"); + t.equal((error as any).response.status, 400, "response status is 400"); } t.end(); }); diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts index 2fc29594c0d..5d6b83bc950 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts @@ -585,7 +585,7 @@ test("Test invalid refund with invalid time", async (t: Test) => { const resRefund = await api.refundV1(refundRequest); t.equal(resRefund.status, 400, "response status is 400"); } catch (error) { - t.equal(error.response.status, 400, "response status is 400"); + t.equal((error as any).response.status, 400, "response status is 400"); } t.comment("Get balance of account"); diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/withdraw-endpoint.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/withdraw-endpoint.test.ts index e50cec948a4..644e0d0f52c 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/withdraw-endpoint.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/withdraw-endpoint.test.ts @@ -504,7 +504,7 @@ test("Test invalid withdraw with invalid id", async (t: Test) => { const resWithdraw = await api.withdrawV1(withdrawRequest); t.equal(resWithdraw.status, 400, "response status is 400"); } catch (error) { - t.equal(error.response.status, 400, "response status is 400"); + t.equal((error as any).response.status, 400, "response status is 400"); } t.comment("Get balance of receiver account"); const responseFinalBalance = await connector.invokeContract({ diff --git a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-single-status-endpoint-invalid.test.ts b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-single-status-endpoint-invalid.test.ts index b68dda96f54..11dd5788237 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-single-status-endpoint-invalid.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-single-status-endpoint-invalid.test.ts @@ -218,7 +218,7 @@ test(testCase, async (t: Test) => { ); t.equal(res.status, 500, "response status is 500"); } catch (e) { - t.equal(e.response.status, 500); + t.equal((e as any).response.status, 500); } t.end(); }); diff --git a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-status-endpoint-invalid.test.ts b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-status-endpoint-invalid.test.ts index c34a227dc60..9ae30655270 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-status-endpoint-invalid.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-status-endpoint-invalid.test.ts @@ -229,7 +229,7 @@ test(testCase, async (t: Test) => { ); t.equal(res.status, 500, "response status is 500"); } catch (e) { - t.equal(e.response.status, 500); + t.equal((e as any).response.status, 500); } t.end(); }); diff --git a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/new-contract-endpoint-invalid.test.ts b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/new-contract-endpoint-invalid.test.ts index 91a4ed60680..3d9572a2ff3 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/new-contract-endpoint-invalid.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/new-contract-endpoint-invalid.test.ts @@ -191,7 +191,7 @@ test(testCase, async (t: Test) => { t.ok(resp, "response newContract is OK"); t.equal(resp.status, 200, "response status newContract is OK"); } catch (error) { - t.equal(error.response.status, 500, "response status is 500"); + t.equal((error as any).response.status, 500, "response status is 500"); } t.end(); }); diff --git a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/refund-endpoint-invalid.test.ts b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/refund-endpoint-invalid.test.ts index c0ac9dbca78..b3ef950998c 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/refund-endpoint-invalid.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/refund-endpoint-invalid.test.ts @@ -231,7 +231,7 @@ test(testCase, async (t: Test) => { const refundResponse = await api.refundV1(refundRequest); t.equal(refundResponse.status, 200); } catch (error) { - t.equal(error.response.status, 500, "response status is 500"); + t.equal((error as any).response.status, 500, "response status is 500"); } t.end(); }); diff --git a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/withdraw-endpoint-invalid.test.ts b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/withdraw-endpoint-invalid.test.ts index f9f6720ff27..240e39db317 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/withdraw-endpoint-invalid.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/withdraw-endpoint-invalid.test.ts @@ -221,7 +221,7 @@ test(testCase, async (t: Test) => { t.equal(res.status, 200, "response status is 200 OK"); } catch (error) { - t.equal(error.response.status, 500, "response status is 500"); + t.equal((error as any).response.status, 500, "response status is 500"); } t.end(); }); diff --git a/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/sign-transaction-endpoint.test.ts b/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/sign-transaction-endpoint.test.ts index 8fd57b4ff67..6f144ab0cef 100644 --- a/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/sign-transaction-endpoint.test.ts +++ b/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/sign-transaction-endpoint.test.ts @@ -186,9 +186,13 @@ test(testCase, async (t: Test) => { }; await api.signTransactionV1(notFoundRequest); } catch (error) { - t.equal(error.response.status, 404, "HTTP response status are equal"); t.equal( - error.response.statusText, + (error as any).response.status, + 404, + "HTTP response status are equal", + ); + t.equal( + (error as any).response.statusText, "Transaction not found", "Response text are equal", ); diff --git a/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/v21-sign-transaction-endpoint.test.ts b/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/v21-sign-transaction-endpoint.test.ts index 81049557f65..cece3c40207 100644 --- a/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/v21-sign-transaction-endpoint.test.ts +++ b/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/v21-sign-transaction-endpoint.test.ts @@ -189,9 +189,13 @@ test(testCase, async (t: Test) => { }; await api.signTransactionV1(notFoundRequest); } catch (error) { - t.equal(error.response.status, 404, "HTTP response status are equal"); t.equal( - error.response.statusText, + (error as any).response.status, + 404, + "HTTP response status are equal", + ); + t.equal( + (error as any).response.statusText, "Transaction not found", "Response text are equal", ); diff --git a/packages/cactus-test-tooling/src/main/typescript/common/containers.ts b/packages/cactus-test-tooling/src/main/typescript/common/containers.ts index 2bda34099b6..798f88400aa 100644 --- a/packages/cactus-test-tooling/src/main/typescript/common/containers.ts +++ b/packages/cactus-test-tooling/src/main/typescript/common/containers.ts @@ -104,7 +104,10 @@ export class Containers { return response; } catch (ex) { log.error("Failed to get diagnostics of Docker daemon", ex); - throw new RuntimeError("Failed to get diagnostics of Docker daemon", ex); + throw new RuntimeError( + "Failed to get diagnostics of Docker daemon", + ex as Error, + ); } } /** @@ -530,7 +533,9 @@ export class Containers { // ); // } if (Date.now() >= startedAt + timeoutMs) { - throw new Error(`${fnTag} timed out (${timeoutMs}ms) -> ${ex.stack}`); + throw new Error( + `${fnTag} timed out (${timeoutMs}ms) -> ${(ex as Error).stack}`, + ); } reachable = false; } diff --git a/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts b/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts index 6dcd732a084..04a0b393642 100644 --- a/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts +++ b/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts @@ -137,7 +137,7 @@ export class FabricTestLedgerV1 implements ITestLedger { return new FabricCAServices(caUrl, tlsOptions, caName); } catch (ex) { this.log.error(`createCaClient() Failure:`, ex); - throw new Error(`${fnTag} Inner Exception: ${ex?.message}`); + throw new Error(`${fnTag} Inner Exception: ${(ex as Error)?.message}`); } } @@ -198,7 +198,7 @@ export class FabricTestLedgerV1 implements ITestLedger { return [x509Identity, wallet]; } catch (ex) { this.log.error(`enrollUser() Failure:`, ex); - throw new Error(`${fnTag} Exception: ${ex?.message}`); + throw new Error(`${fnTag} Exception: ${(ex as Error)?.message}`); } } @@ -229,7 +229,7 @@ export class FabricTestLedgerV1 implements ITestLedger { return [x509Identity, wallet]; } catch (ex) { this.log.error(`enrollAdmin() Failure:`, ex); - throw new Error(`${fnTag} Exception: ${ex?.message}`); + throw new Error(`${fnTag} Exception: ${(ex as Error)?.message}`); } } @@ -472,7 +472,9 @@ export class FabricTestLedgerV1 implements ITestLedger { } catch (ex) { reachable = false; if (Date.now() >= startedAt + timeoutMs) { - throw new Error(`${fnTag} timed out (${timeoutMs}ms) -> ${ex.stack}`); + throw new Error( + `${fnTag} timed out (${timeoutMs}ms) -> ${(ex as Error).stack}`, + ); } } await new Promise((resolve2) => setTimeout(resolve2, 1000)); diff --git a/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-test-ledger.ts b/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-test-ledger.ts index 3b0bbae70fe..3416e6c939c 100644 --- a/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-test-ledger.ts +++ b/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-test-ledger.ts @@ -272,7 +272,9 @@ export class QuorumTestLedger implements ITestLedger { } catch (ex) { reachable = false; if (Date.now() >= startedAt + timeoutMs) { - throw new Error(`${fnTag} timed out (${timeoutMs}ms) -> ${ex.stack}`); + throw new Error( + `${fnTag} timed out (${timeoutMs}ms) -> ${(ex as Error).stack}`, + ); } } await new Promise((resolve2) => setTimeout(resolve2, 100)); diff --git a/packages/cactus-test-tooling/src/test/typescript/integration/common/containers.test.ts b/packages/cactus-test-tooling/src/test/typescript/integration/common/containers.test.ts index f35cd4d7a09..5d0c3a985c1 100644 --- a/packages/cactus-test-tooling/src/test/typescript/integration/common/containers.test.ts +++ b/packages/cactus-test-tooling/src/test/typescript/integration/common/containers.test.ts @@ -116,9 +116,11 @@ test("Can report error if docker daemon is not accessable", async (t: Test) => { t.fail("Containers.getDiagnostics was supposed to fail but did not."); } catch (ex) { t.ok(ex, "exception thrown is truthy OK"); - t.ok(ex.cause, "ex.cause truthy OK"); - t.ok(ex.cause.message, "ex.cause.message truthy OK"); - const causeMsgIsInformative = ex.cause.message.includes(badSocketPath); + t.ok((ex as any).cause, "ex.cause truthy OK"); + t.ok((ex as any).cause.message, "ex.cause.message truthy OK"); + const causeMsgIsInformative = (ex as any).cause.message.includes( + badSocketPath, + ); t.true(causeMsgIsInformative, "causeMsgIsInformative"); } t.end(); diff --git a/yarn.lock b/yarn.lock index f43ed506c9b..505d37c9867 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22404,6 +22404,11 @@ typescript@4.3.5: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4" integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA== +typescript@4.4.3: + version "4.4.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324" + integrity sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA== + typescript@^3.9.3: version "3.9.10" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8"