Skip to content

Commit

Permalink
ci: inject LOG_ENCRYPTION_PUBLIC_KEY from github env
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Aug 11, 2024
1 parent b2a73ed commit 0f60f16
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
3 changes: 3 additions & 0 deletions packages/neuron-wallet/src/services/log-encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default class LogEncryption {
static getInstance(): LogEncryption {
if (!LogEncryption.instance) {
const adminPublicKey = process.env.LOG_ENCRYPTION_PUBLIC_KEY ?? ''
logger.info('key start')
logger.info(adminPublicKey)
logger.info('key end')
if (!adminPublicKey) {
logger.warn('LOG_ENCRYPTION_PUBLIC_KEY is required to create LogEncryption instance')
}
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-wallet/src/services/settings.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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'))
}
}

Expand Down
7 changes: 3 additions & 4 deletions packages/neuron-wallet/src/services/sign-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ export default class SignMessage {
message: string
address?: string
}): Promise<string> {
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]
if (!addr) {
throw new AddressNotFound()
}

const encryption = LogEncryption.getInstance()
logger.error('------------')
logger.error(encryption.encrypt(message))

if (wallet.isHardware()) {
let device = HardwareWalletService.getInstance().getCurrent()
if (!device) {
Expand Down

1 comment on commit 0f60f16

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 10338898719

Please sign in to comment.