From 0eecaaf185f14e7178b8509f5750cf960950a508 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Wed, 6 Jun 2018 12:33:49 +0200 Subject: [PATCH 1/7] Apply ans1.js patch automatically after apply:bitcoincom npm-command --- Gruntfile.js | 16 +++++++++++++++- app-template/package-template.json | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index b81f53f44..d41a2e2b0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,6 +3,7 @@ module.exports = function(grunt) { require('load-grunt-tasks')(grunt); + grunt.loadNpmTasks('grunt-patcher'); // Project Configuration grunt.initConfig({ @@ -266,7 +267,18 @@ module.exports = function(grunt) { 'bitcoin-cash-js/bitcoin-cash-js.js': ['bitcoin-cash-js/index.js'] }, } - } + }, + patch: { + asn1: { + options: { + patch: './patches/asn1-fix.patch' + }, + files: { + './node_modules/asn1.js-rfc5280/index.js': './node_modules/asn1.js-rfc5280/index.js' + } + } + + }, }); grunt.registerTask('default', ['nggettext_compile', 'exec:appConfig', 'exec:externalServices', 'browserify', 'sass', 'concat', 'copy:ionic_fonts', 'copy:ionic_js']); @@ -287,5 +299,7 @@ module.exports = function(grunt) { grunt.registerTask('android', ['exec:android']); grunt.registerTask('android-release', ['prod', 'exec:android', 'exec:androidsign']); grunt.registerTask('desktopsign', ['exec:desktopsign', 'exec:desktopverify']); + grunt.registerTask('apply-patches', ['patch:asn1']); + }; diff --git a/app-template/package-template.json b/app-template/package-template.json index 660063183..b91d9506d 100644 --- a/app-template/package-template.json +++ b/app-template/package-template.json @@ -113,7 +113,7 @@ "sign:android": "rm -f platforms/android/build/outputs/apk/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../bitcoin-com-release-key.jks -signedjar platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-unsigned.apk bitcoin-com && $ANDROID_HOME/build-tools/27.0.1/zipalign -v 4 platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-signed-aligned.apk", "apply:copay": "npm i fs-extra && cd app-template && node apply.js copay && npm i && cordova prepare", "apply:bitpay": "npm i fs-extra && cd app-template && node apply.js bitpay && npm i && cordova prepare", - "apply:bitcoincom": "npm i fs-extra && cd app-template && node apply.js bitcoincom && npm i && cordova prepare", + "apply:bitcoincom": "npm i fs-extra && cd app-template && node apply.js bitcoincom && npm i && grunt apply-patches && cordova prepare", "test": "echo \"no package tests configured\"", "clean": "trash platforms && trash plugins && cordova prepare", "unstage-package": "git reset package.json", @@ -122,6 +122,7 @@ "devDependencies": { "cordova": "^6.3.1", "grunt": "^1.0.1", + "grunt-patcher": "^1.0.0", "ionic": "^3.6.0", "trash-cli": "^1.4.0", "lodash": "^4.17.4", From 282eb6f5bb0c3326bb525c1d873493b4171311c0 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Wed, 6 Jun 2018 13:02:11 +0200 Subject: [PATCH 2/7] Also in the package.json stub file From 043fcae00542a658c5786c69e4e0702d16b13007 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Wed, 6 Jun 2018 13:08:32 +0200 Subject: [PATCH 3/7] Also in the package.json stub file From e1206a4f5583e1eb0f0642057f40009e1f33dcf3 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Wed, 6 Jun 2018 13:09:22 +0200 Subject: [PATCH 4/7] Also in the package.json stub file --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c1f37b2e6..7126112ee 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "postinstall": "npm run apply:copay && echo && echo \"Repo configured for standard Copay distribution. To switch to the BitPay distribution, run 'npm run apply:bitpay'.\" && echo", "start": "echo && echo \"Choose a distribution by running 'npm run apply:copay' or 'npm run apply:bitpay'.\" && echo", "apply:copay": "npm i fs-extra@0.30 && cd app-template && node apply.js copay && cd .. && npm i", - "apply:bitcoincom": "npm i fs-extra && cd app-template && node apply.js bitcoincom && npm i && cordova prepare", + "apply:bitcoincom": "npm i fs-extra && cd app-template && node apply.js bitcoincom && npm i && grunt apply-patches && cordova prepare", "apply:bitpay": "npm i fs-extra@0.30 && cd app-template && node apply.js bitpay && cd .. && npm i", "unstage-package": "git reset package.json", "clean-all": "git clean -dfx" From abfc33a7069a32aed4bb90ac982e41bff3ffbe80 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Wed, 6 Jun 2018 13:15:17 +0200 Subject: [PATCH 5/7] Added the asn1-patch file --- patches/asn1-fix.patch | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 patches/asn1-fix.patch diff --git a/patches/asn1-fix.patch b/patches/asn1-fix.patch new file mode 100644 index 000000000..c78e30712 --- /dev/null +++ b/patches/asn1-fix.patch @@ -0,0 +1,10 @@ +@@ -1,8 +1,4 @@ +-try { +- var asn1 = require('asn1.js'); +-} catch (e) { +- var asn1 = require('../..'); +-} ++var asn1 = require('asn1.js'); + + /** + * RFC5280 X509 and Extension Definitions From 677e653fccf6affc2138327e6046a19244243b8e Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Wed, 6 Jun 2018 13:23:19 +0200 Subject: [PATCH 6/7] Readme update --- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 56ae84eab..b0e8747a0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,16 @@ You don't need to run npm install, run apply:bitcoincom instead ```sh npm run apply:bitcoincom ``` -There is a bug when building the next step, you will need to go directly into one of the javascript files in node_modules + +#####asn1.js bug +If get the following error: +```sh +» +» ^ +» ParseError: Unexpected token +``` + +You will need to go directly into one of the javascript files in node_modules ```sh nano node_modules/asn1.js-rfc5280/index.js ``` @@ -39,12 +48,6 @@ Delete the whole try catch part at the top, replace it with only ``` var asn1 = require('asn1.js'); ``` -If you don't do this, you will get this error: -```sh -» -» ^ -» ParseError: Unexpected token -``` ## Testing in a Browser From 2b5f01e45c1f2c0ca37fbb312cdb2650918271c0 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Wed, 6 Jun 2018 13:24:41 +0200 Subject: [PATCH 7/7] Readme update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b0e8747a0..94b8d7605 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ You don't need to run npm install, run apply:bitcoincom instead npm run apply:bitcoincom ``` -#####asn1.js bug +#### asn1.js bug If get the following error: ```sh »