Skip to content

Commit

Permalink
fix: argon2 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Dec 22, 2020
1 parent fc5156d commit 8f61287
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 1 deletion.
96 changes: 96 additions & 0 deletions .github/workflows/debug-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Debug build

on: [pull_request]

jobs:
release:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
include:
- os: macos-latest
NPM_COMMAND: mac

- os: ubuntu-latest
NPM_COMMAND: linux

- os: windows-latest
NPM_COMMAND: win

steps:
- uses: lucasmotta/pull-request-sticky-header@1.0.0
# Only update it once per build
if: matrix.os == 'ubuntu-latest'
with:
header: '> _Currently building new release, please wait for the latest_&nbsp; <img src="https://user-images.githubusercontent.com/1618764/97873036-51dfb200-1d17-11eb-89f5-0a922dc3ac92.gif" width="12" />'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Check out Git repository
uses: actions/checkout@v1

- uses: FranzDiebold/github-env-vars-action@v1.2.1
- name: Print environment variables
run: |
echo "GITHUB_REPOSITORY_SLUG=$GITHUB_REPOSITORY_SLUG"
echo "GITHUB_REPOSITORY_OWNER=$GITHUB_REPOSITORY_OWNER"
echo "GITHUB_REPOSITORY_OWNER_SLUG=$GITHUB_REPOSITORY_OWNER_SLUG"
echo "GITHUB_REPOSITORY_NAME=$GITHUB_REPOSITORY_NAME"
echo "GITHUB_REPOSITORY_NAME_SLUG=$GITHUB_REPOSITORY_NAME_SLUG"
echo "GITHUB_REF_SLUG=$GITHUB_REF_SLUG"
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
echo "GITHUB_REF_NAME_SLUG=$GITHUB_REF_NAME_SLUG"
echo "GITHUB_SHA_SHORT=$GITHUB_SHA_SHORT"
echo "GITHUB_SHA=$GITHUB_SHA"
- name: Variables
id: vars
run: |
echo "::set-output name=version::$(cat package.json | jq -r .version)"
echo "::set-output name=branch_name::$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=pull_request_id::$(echo $GITHUB_REF)"
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 12

- name: Install packages
run: yarn

- name: Build releases
run: ./node_modules/.bin/cross-env DEBUG_PROD=true yarn package-${{ matrix.NPM_COMMAND }}
env:
SHA: ${{ github.event.pull_request.head.sha }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST: ${{ steps.vars.outputs.pull_request_id }}
BRANCH_NAME: ${{ steps.vars.outputs.branch_name }}

- uses: actions/upload-artifact@v2
name: Upload Windows build
if: matrix.os == 'windows-latest'
with:
name: stacks-wallet-${{ steps.vars.outputs.version }}-windows
path: |
release/**/*.exe
release/**/*.msi
- uses: actions/upload-artifact@v2
name: Upload MacOS build
if: matrix.os == 'macos-latest'
with:
name: stacks-wallet-${{ steps.vars.outputs.version }}-macos
path: release/**/*.dmg

- uses: actions/upload-artifact@v2
name: Upload Linux build
if: matrix.os == 'ubuntu-latest'
with:
name: stacks-wallet-${{ steps.vars.outputs.version }}-linux
path: |
release/**/*.deb
release/**/*.rpm
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@stacks/network": "1.0.0-beta.19",
"@stacks/stacking": "1.0.0-beta.19",
"@stacks/transactions": "1.0.0-beta.19",
"argon2-browser": "1.15.2",
"bitcoinjs-lib": "5.2.0",
"blockstack": "21.1.1"
}
Expand Down
16 changes: 15 additions & 1 deletion app/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const { contextBridge, ipcRenderer, app, shell } = require('electron');

const TransportNodeHid = require('@ledgerhq/hw-transport-node-hid').default;

const argon2 = require('argon2-browser');

const scriptsToLoad = [];

if (process.env.NODE_ENV === 'development') {
Expand All @@ -25,6 +27,18 @@ contextBridge.exposeInMainWorld('electron', {
__filename,
});

async function deriveKey({ pass, salt }) {
const result = await argon2.hash({
pass,
salt,
hashLen: 48,
time: 44,
mem: 1024 * 32,
type: argon2.ArgonType.Argon2id,
});
return { derivedKeyHash: result.hash };
}

contextBridge.exposeInMainWorld('process', { ...process });

contextBridge.exposeInMainWorld('api', {
Expand All @@ -39,7 +53,7 @@ contextBridge.exposeInMainWorld('api', {
},

deriveKey: async args => {
return ipcRenderer.invoke('derive-key', args);
return deriveKey(args);
},

windowEvents: {
Expand Down
5 changes: 5 additions & 0 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ are-we-there-yet@~1.1.2:
delegates "^1.0.0"
readable-stream "^2.0.6"

argon2-browser@1.15.2:
version "1.15.2"
resolved "https://registry.yarnpkg.com/argon2-browser/-/argon2-browser-1.15.2.tgz#1d37c0ef3eac357b6571297cbaf9958aa62eb0d6"
integrity sha512-kn9rs/+dZk0K4L9Vj8ZDdNw+s9vTYvmHCi8TT7z5OHeoFEwJnElZioICNLWXCve9sHc0d6TfeD0b1GKcscsuwg==

argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
Expand Down

0 comments on commit 8f61287

Please sign in to comment.