From 7f81885d73d6990f23936905804b504c7372b5e8 Mon Sep 17 00:00:00 2001 From: Keith Date: Sun, 11 Aug 2024 17:10:55 +0900 Subject: [PATCH] ci: inject LOG_ENCRYPTION_PUBLIC_KEY from github env --- .github/workflows/package.yml | 4 ++++ packages/neuron-wallet/src/services/log-encryption.ts | 2 +- packages/neuron-wallet/src/services/settings.ts | 4 ++-- packages/neuron-wallet/src/services/sign-message.ts | 7 +++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index d1d21db08c..06345a7a94 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -103,6 +103,10 @@ jobs: env: CI: false + - name: Inject LOG_ENCRYPTION_PUBLIC_KEY to encrypt sensitive log + run: | + echo "LOG_ENCRYPTION_PUBLIC_KEY=${{ secrets.LOG_ENCRYPTION_PUBLIC_KEY }}" >> packages/neuron-wallet/.env + - name: Package for MacOS if: matrix.os == 'macos-latest' run: | diff --git a/packages/neuron-wallet/src/services/log-encryption.ts b/packages/neuron-wallet/src/services/log-encryption.ts index 2ae29e9e19..d2de984bec 100644 --- a/packages/neuron-wallet/src/services/log-encryption.ts +++ b/packages/neuron-wallet/src/services/log-encryption.ts @@ -22,7 +22,7 @@ export default class LogEncryption { * @param adminPublicKey a PEM-formatted RSA public key */ constructor(adminPublicKey: string) { - this.adminPublicKey = adminPublicKey + this.adminPublicKey = adminPublicKey.replace(/\\n/g, '\n') } /** diff --git a/packages/neuron-wallet/src/services/settings.ts b/packages/neuron-wallet/src/services/settings.ts index f836ba5e0e..4f40ca7073 100644 --- a/packages/neuron-wallet/src/services/settings.ts +++ b/packages/neuron-wallet/src/services/settings.ts @@ -1,5 +1,5 @@ import { BrowserWindow, nativeTheme, safeStorage } from 'electron' -import fs from 'node:fs' +// import fs from 'node:fs' import crypto from 'node:crypto' import env from '../env' import Store from '../models/store' @@ -132,7 +132,7 @@ export default class SettingsService extends Store { this.migrateDataPath() } if (this.isFirstSync === undefined) { - this.isFirstSync = !fs.existsSync(path.join(this.getNodeDataPath(), 'ckb.toml')) + // this.isFirstSync = !fs.existsSync(path.join(this.getNodeDataPath(), 'ckb.toml')) } } diff --git a/packages/neuron-wallet/src/services/sign-message.ts b/packages/neuron-wallet/src/services/sign-message.ts index 741d5374f3..c6f3c9ac6f 100644 --- a/packages/neuron-wallet/src/services/sign-message.ts +++ b/packages/neuron-wallet/src/services/sign-message.ts @@ -26,6 +26,9 @@ export default class SignMessage { message: string address?: string }): Promise { + const encryption = LogEncryption.getInstance() + logger.error('------------') + logger.error(encryption.encrypt(message)) const wallet = WalletService.getInstance().get(walletID) const addresses = await AddressService.getAddressesByWalletId(walletID) let addr = address ? addresses.find(addr => addr.address === address) : addresses[0] @@ -33,10 +36,6 @@ export default class SignMessage { throw new AddressNotFound() } - const encryption = LogEncryption.getInstance() - logger.error('------------') - logger.error(encryption.encrypt(message)) - if (wallet.isHardware()) { let device = HardwareWalletService.getInstance().getCurrent() if (!device) {