Do not keep mnemonic or password (and variations) in logs

This commit is contained in:
Mark Sinclair
2023-04-18 11:56:23 +01:00
parent 48d0883b31
commit 1d8a931e0c
2 changed files with 9 additions and 3 deletions
+1 -2
View File
@@ -1,9 +1,8 @@
import { Account, Balance, AccountEntry } from '@nymproject/types';
import { invoke } from '@tauri-apps/api';
import { invokeWrapper } from './wrapper';
export const signInWithMnemonic = async (mnemonic: string): Promise<Account> =>
invoke('connect_with_mnemonic', { mnemonic });
invokeWrapper('connect_with_mnemonic', { mnemonic });
export const userBalance = async () => invokeWrapper<Balance>('get_balance');
+8 -1
View File
@@ -5,7 +5,14 @@ import { Console } from '../utils/console';
export async function invokeWrapper<T>(operationName: string, args?: any): Promise<T> {
const res = await invoke<T>(operationName, args);
if (config.LOG_TAURI_OPERATIONS) {
Console.log({ operationName, args, res });
const argsToLog: any = {};
Object.keys(args).forEach((key) => {
// check if the key should be excluded from logs
if (!['mnemonic', 'password', 'currentPassword', 'newPassword'].includes(key)) {
argsToLog[key] = args[key];
}
});
Console.log({ operationName, argsToLog, res });
}
return res;
}