Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: put password in config.yaml #235

Merged
merged 2 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

> Electron Desktop app that helps you easily spin up and manage Swarm's Bee node

**Warning: Swarm Desktop is in Beta and currently includes the [Sentry](https://sentry.io/welcome/) application monitoring and bug reporting software which automatically collects data in order to help improve the software.**

**Warning: This project is in beta state. There might (and most probably will) be changes in the future to its API and working. Also, no guarantees can be made about its stability, efficiency, and security at this stage.**

Stay up to date by joining the [official Discord](https://discord.gg/GU22h2utj6) and by keeping an eye on the [releases tab](https://github.com/ethersphere/swarm-desktop/releases).
Expand Down
28 changes: 12 additions & 16 deletions src/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { mkdirSync, readFileSync, writeFileSync } from 'fs'
import fetch from 'node-fetch'
import { platform } from 'os'
import { join } from 'path'
import { v4 } from 'uuid'
import { writeConfigYaml } from './config-yaml'
import { rebuildElectronTray } from './electron'
import { BeeManager } from './lifecycle'
import { logger } from './logger'
Expand Down Expand Up @@ -37,7 +39,7 @@ export async function createInitialTransaction() {
const { address } = JSON.parse(readFileSync(getPath('data-dir/keys/swarm.key')).toString())
logger.info('Sending transaction to address', address)
const { transaction, blockHash } = await sendTransaction(address)
writeFileSync(getPath('config.yaml'), createConfiguration(transaction, blockHash))
createConfiguration(transaction, blockHash)
}
}

Expand All @@ -61,7 +63,7 @@ export async function runLauncher() {
const { address } = JSON.parse(readFileSync(getPath(join('data-dir', 'keys', 'swarm.key'))).toString())
logger.info('Sending transaction to address', address)
const { transaction, blockHash } = await sendTransaction(address)
writeFileSync(getPath('config.yaml'), createConfiguration(transaction, blockHash))
createConfiguration(transaction, blockHash)
}
BeeManager.setUserIntention(true)
const subprocess = launchBee(abortController).catch(reason => {
Expand Down Expand Up @@ -98,23 +100,21 @@ chain-enable: false
cors-allowed-origins: '*'
use-postage-snapshot: true
resolver-options: https://cloudflare-eth.com
data-dir: ${getPath('data-dir')}`
data-dir: ${getPath('data-dir')}
password: ${v4()}`
}

function createConfiguration(transaction: string, blockHash: string) {
return `${createStubConfiguration()}
transaction: ${transaction}
block-hash: ${blockHash}`
writeConfigYaml({
transaction,
'block-hash': blockHash,
})
}

async function initializeBee() {
const configPath = getPath('config.yaml')

return runProcess(
getPath(getBeeExecutable()),
['init', `--config=${configPath}`, `--password=Test`],
new AbortController(),
)
return runProcess(getPath(getBeeExecutable()), ['init', `--config=${configPath}`], new AbortController())
}

async function launchBee(abortController?: AbortController) {
Expand All @@ -123,11 +123,7 @@ async function launchBee(abortController?: AbortController) {
}
const configPath = getPath('config.yaml')

return runProcess(
getPath(getBeeExecutable()),
['start', `--config=${configPath}`, '--password=Test'],
abortController,
)
return runProcess(getPath(getBeeExecutable()), ['start', `--config=${configPath}`], abortController)
}

async function runProcess(command: string, args: string[], abortController: AbortController): Promise<number> {
Expand Down