Skip to content

Commit

Permalink
fix: WIP invoke not working in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Nov 3, 2020
1 parent 0ad9552 commit 1cd64c5
Show file tree
Hide file tree
Showing 10 changed files with 472 additions and 216 deletions.
6 changes: 4 additions & 2 deletions app/crypto/key-generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ export async function deriveArgon2Key({ pass, salt }: DeriveKeyArgs) {
}

export async function deriveKey({ pass, salt }: DeriveKeyArgs) {
ipcRenderer.send('derive-key', {
console.log('sending message');
return ipcRenderer.invoke('derive-key', {
pass,
salt,
});
return listenForKeyDerivation();
console.log('waiting response');
// return listenForKeyDerivation();
}

export function generateRandomHexString() {
Expand Down
20 changes: 9 additions & 11 deletions app/main.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ const installExtensions = async () => {
};

const createWindow = async () => {
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') {
await installExtensions();
}
// if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') {
// await installExtensions();
// }

const mainWindowState = windowState({
defaultWidth: 1024,
Expand All @@ -86,8 +86,8 @@ const createWindow = async () => {
nodeIntegration: true,
}
: {
nodeIntegration: false,
contextIsolation: false,
nodeIntegration: true,
contextIsolation: true,
webSecurity: true,
preload: path.join(__dirname, 'dist/renderer.prod.js'),
},
Expand Down Expand Up @@ -161,10 +161,8 @@ app.on('activate', () => {
if (mainWindow === null) void createWindow();
});

// Internally `argon2-browser` uses wasm which is prohibited by the renderer's CSP
ipcMain.on('derive-key', (event, { pass, salt }: Record<'pass' | 'salt', string>) => {
void (async () => {
const result = await deriveArgon2Key({ pass, salt });
event.reply('derive-key-listen', result);
})();
// // Internally `argon2-browser` uses wasm which is prohibited by the renderer's CSP

ipcMain.handle('derive-key', async (_event, { pass, salt }: Record<'pass' | 'salt', string>) => {
return deriveArgon2Key({ pass, salt });
});
4 changes: 3 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"@blockstack/keychain": "0.13.0-beta.2",
"@blockstack/stacks-transactions": "0.6.1-beta.2",
"@ledgerhq/hw-transport-node-hid": "5.23.2",
"bitcoinjs-lib": "^5.2.0"
"bitcoinjs-lib": "^5.2.0",
"bufferutil": "^4.0.1",
"utf-8-validate": "5.0.2"
}
}
4 changes: 2 additions & 2 deletions app/pages/onboarding/05-secret-key/secret-key.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const SecretKey: React.FC = () => {
<Text textStyle="body.small" mt="loose" mx="loose" lineHeight="20px" display="block">
{mnemonic}
</Text>
<Button variant="link" mt="tight">
<Text textStyle="caption.medium" fontSize="12px" onClick={onCopy}>
<Button variant="link" mt="tight" onClick={onCopy}>
<Text textStyle="caption.medium" fontSize="12px">
Copy to clipboard
</Text>
</Button>
Expand Down
19 changes: 19 additions & 0 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,13 @@ buffer@^5.5.0, buffer@^5.6.0:
base64-js "^1.0.2"
ieee754 "^1.1.4"

bufferutil@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.1.tgz#3a177e8e5819a1243fe16b63a199951a7ad8d4a7"
integrity sha512-xowrxvpxojqkagPcWRQVXZl0YXhRhAtBEIq3VoER1NH5Mw1n1o0ojdspp+GS2J//2gCVyrzQDApQ4unGF+QOoA==
dependencies:
node-gyp-build "~3.7.0"

c32check@^1.0.1, c32check@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/c32check/-/c32check-1.1.2.tgz#e84a66366bf9964ddf8d7b1f86d0e79281b8c8bd"
Expand Down Expand Up @@ -999,6 +1006,11 @@ node-fetch@2.6.0:
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==

node-gyp-build@~3.7.0:
version "3.7.0"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-3.7.0.tgz#daa77a4f547b9aed3e2aac779eaf151afd60ec8d"
integrity sha512-L/Eg02Epx6Si2NXmedx+Okg+4UHqmaf3TNcxd50SF9NQGcJaON3AtU++kax69XV7YWz4tUspqZSAsVofhFKG2w==

node-hid@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/node-hid/-/node-hid-1.3.0.tgz#346a468505cee13d69ccd760052cbaf749f66a41"
Expand Down Expand Up @@ -1461,6 +1473,13 @@ usb@^1.6.3:
nan "2.13.2"
prebuild-install "^5.3.3"

utf-8-validate@5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.2.tgz#63cfbccd85dc1f2b66cf7a1d0eebc08ed056bfb3"
integrity sha512-SwV++i2gTD5qh2XqaPzBnNX88N6HdyhQrNNRykvcS0QKvItV9u3vPEJr+X5Hhfb1JC0r0e1alL0iB09rY8+nmw==
dependencies:
node-gyp-build "~3.7.0"

util-deprecate@^1.0.1, util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
Expand Down
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ module.exports = api => {
[require('@babel/preset-react'), { development }],
],
plugins: [
[
'transform-runtime',
{
regenerator: true,
},
],
// Stage 0
require('@babel/plugin-proposal-function-bind'),

Expand Down
1 change: 0 additions & 1 deletion configs/webpack.config.main.prod.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default merge.smart(baseConfig, {
START_MINIMIZED: false,
E2E_BUILD: false,
SHA: process.env.SHA,
BUILD_DATE: process.env.BUILD_DATE,
}),
],

Expand Down
1 change: 0 additions & 1 deletion configs/webpack.config.renderer.prod.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export default merge.smart(baseConfig, {
STX_NETWORK: 'testnet',
E2E_BUILD: false,
SHA: process.env.SHA,
BUILD_DATE: process.env.BUILD_DATE,
}),

new BundleAnalyzerPlugin({
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@
"cross-spawn": "7.0.3",
"csstype": "3.0.4",
"detect-port": "1.3.0",
"electron": "8.3.1",
"electron-builder": "22.8.0",
"electron-devtools-installer": "3.0.0",
"electron-rebuild": "1.11.0",
"electron": "10.1.5",
"electron-builder": "22.9.1",
"electron-devtools-installer": "3.1.1",
"electron-rebuild": "2.3.2",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.5",
"enzyme-to-json": "3.5.0",
Expand Down Expand Up @@ -218,19 +218,21 @@
"@tippyjs/react": "4.2.0",
"@zondax/ledger-blockstack": "0.0.2",
"argon2-browser": "1.15.2",
"atob": "2.1.2",
"axios": "0.21.0",
"babel-plugin-transform-runtime": "^6.23.0",
"bignumber.js": "9.0.1",
"bip39": "3.0.2",
"bitcoin-address-validation": "1.0.2",
"bn.js": "5.1.3",
"buffer": "5.6.1",
"buffer": "5.7.0",
"c32check": "1.1.2",
"connected-react-router": "6.8.0",
"core-js": "3.6.5",
"dayjs": "1.9.4",
"devtron": "1.4.0",
"electron-debug": "3.1.0",
"electron-log": "4.2.2",
"electron-log": "4.2.4",
"electron-store": "6.0.1",
"electron-updater": "4.3.1",
"electron-window-state": "5.0.3",
Expand Down Expand Up @@ -264,9 +266,7 @@
"npm": ">=4.x",
"yarn": ">=0.21.3"
},
"browserslist": [
"extends browserslist-config-erb"
],
"browserslist": [],
"renovate": {
"extends": [
"bliss"
Expand Down
Loading

0 comments on commit 1cd64c5

Please sign in to comment.