From 427a80f7759e029222119cf815a866fe9899a170 Mon Sep 17 00:00:00 2001 From: Jim Ezesinachi Date: Wed, 23 Nov 2022 05:32:09 +0100 Subject: [PATCH] fix: remove sensitive information from agent config toJSON() method (#1112) Signed-off-by: Jim Ezesinachi --- packages/core/src/agent/AgentConfig.ts | 12 ++++++++++-- packages/core/src/wallet/WalletApi.ts | 9 ++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/core/src/agent/AgentConfig.ts b/packages/core/src/agent/AgentConfig.ts index 3b6297341b..5e20051ff8 100644 --- a/packages/core/src/agent/AgentConfig.ts +++ b/packages/core/src/agent/AgentConfig.ts @@ -191,8 +191,16 @@ export class AgentConfig { public toJSON() { return { ...this.initConfig, - logger: this.logger !== undefined, - agentDependencies: this.agentDependencies != undefined, + walletConfig: { + ...this.walletConfig, + key: this.walletConfig?.key ? '[*****]' : undefined, + storage: { + ...this.walletConfig?.storage, + credentials: this.walletConfig?.storage?.credentials ? '[*****]' : undefined, + }, + }, + logger: this.logger.logLevel, + agentDependencies: Boolean(this.agentDependencies), label: this.label, } } diff --git a/packages/core/src/wallet/WalletApi.ts b/packages/core/src/wallet/WalletApi.ts index a845123160..548df623cf 100644 --- a/packages/core/src/wallet/WalletApi.ts +++ b/packages/core/src/wallet/WalletApi.ts @@ -43,7 +43,14 @@ export class WalletApi { } public async initialize(walletConfig: WalletConfig): Promise { - this.logger.info(`Initializing wallet '${walletConfig.id}'`, walletConfig) + this.logger.info(`Initializing wallet '${walletConfig.id}'`, { + ...walletConfig, + key: walletConfig?.key ? '[*****]' : undefined, + storage: { + ...walletConfig?.storage, + credentials: walletConfig?.storage?.credentials ? '[*****]' : undefined, + }, + }) if (this.isInitialized) { throw new WalletError(