Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

Commit

Permalink
Publishing client to sparkswap-desktop: v0.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparkswap committed Jan 15, 2020
1 parent 737abb3 commit a02d5ad
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Sparkswap <dev@sparkswap.com> (https://github.com/sparkswap)",
"description": "Sparkswap Desktop: the only way to buy Bitcoin instantly",
"productName": "Sparkswap",
"version": "0.3.7",
"version": "0.3.8",
"license": "MIT",
"private": true,
"main": "./build/electron.js",
Expand Down
3 changes: 2 additions & 1 deletion scripts/electron-wait-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const tryConnection = () => client.connect({port: ELECTRON_DEV_PORT}, () => {

if(!electron) {
console.info('Starting electron...')
electron = spawn('npm', ['run', 'electron'])
const cmd = /^win/.test(process.platform) ? 'npm.cmd' : 'npm'
electron = spawn(cmd, ['run', 'electron'])
electron.stdout.on('data', data => console.log(data.toString()))
electron.stderr.on('data', data => console.error(data.toString()))
electron.on('close', code => console.info(`electron exited with code ${code}`))
Expand Down
8 changes: 5 additions & 3 deletions src/node/electron-security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { App } from 'electron'
import { injectContentSecurityPolicies } from './content-security-policies'
import { IS_PRODUCTION } from '../common/config'

const WEBVIEW_PRELOAD = `file://${path.join(__dirname, 'webview-preload.js')}`
export const WEBVIEW_PRELOAD_PATH = url.pathToFileURL(path.join(__dirname, 'webview-preload.js')).toString()

const WEBVIEW_URL_WHITELIST = IS_PRODUCTION
? ['https://portal.anchorusd.com']
Expand Down Expand Up @@ -45,10 +45,12 @@ function secureApp (app: App): void {
// Best practices for webviews (see: https://electronjs.org/docs/tutorial/security#11-verify-webview-options-before-creation)

// Strip away preload scripts if not our explicit preload script
if (webPreferences.preload !== WEBVIEW_PRELOAD) {
if (webPreferences.preload !== WEBVIEW_PRELOAD_PATH) {
logger.warn(`Removing unauthorized webview preload: ${webPreferences.preload}`)
delete webPreferences.preload
}
if (webPreferences.preloadURL !== WEBVIEW_PRELOAD) {
if (webPreferences.preloadURL !== WEBVIEW_PRELOAD_PATH) {
logger.warn(`Removing unauthorized webview preload: ${webPreferences.preloadURL}`)
delete webPreferences.preloadURL
}

Expand Down
4 changes: 2 additions & 2 deletions src/node/router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as path from 'path'
import { App } from 'electron'
import logger from '../global-shared/logger'
import { listen, listenSync, close as closeListeners } from './main-listener'
Expand All @@ -18,6 +17,7 @@ import { openLink, showNotification } from './util'
import { delay } from '../global-shared/util'
import { getNetworkTime } from './data/ntp'
import { payInvoice } from '../global-shared/lnd-engine'
import { WEBVIEW_PRELOAD_PATH } from './electron-security'

const RETRY_TRADE_DELAY = 10000

Expand Down Expand Up @@ -136,7 +136,7 @@ export class Router {
listen('trade:getTrade', ({ id }: { id: number }) => store.getTrade(this.db, id))
listen('auth:getAuth', () => getAuth())
listen('anchor:startDeposit', () => this.anchorClient.startDeposit())
listenSync('getWebviewPreloadPath', () => path.join(__dirname, 'webview-preload.js'))
listenSync('getWebviewPreloadPath', () => WEBVIEW_PRELOAD_PATH)
listen('ntp:getTime', () => getNetworkTime())
listen('pok:hasShown', () => store.hasShownProofOfKeys(this.db))
listen('pok:markShown', () => store.markProofOfKeysShown(this.db))
Expand Down
2 changes: 1 addition & 1 deletion src/web/ui/onboarding/deposit-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export class DepositDialog extends React.Component<DepositDialogProps, DepositDi
ref={this.webviewRef}
partition={ANCHOR_PARTITION}
src={urlWithPostMessage}
preload={`file://${WEBVIEW_PRELOAD_PATH}`}
preload={WEBVIEW_PRELOAD_PATH}
/>
</div>
{this.state.isDone
Expand Down

0 comments on commit a02d5ad

Please sign in to comment.