Skip to content

Commit b74a482

Browse files
committed
1.0.6 release
1 parent 8476eae commit b74a482

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+33038
-24857
lines changed

Gulpfile.js

+37-27
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const sass = require('gulp-sass');
88
const uglifycss = require('gulp-uglifycss');
99
const gettext = require('gulp-angular-gettext');
1010
const browserify = require('browserify');
11-
const rename = require('gulp-rename');
1211
const source = require('vinyl-source-stream');
1312
const buffer = require('vinyl-buffer');
1413
const sourcemaps = require('gulp-sourcemaps');
@@ -21,7 +20,7 @@ const execSync = require('child_process').execSync;
2120
const jeditor = require("gulp-json-editor");
2221

2322
/**************** WEBPACK START*/
24-
gulp.task('widget:button', [], () => {
23+
gulp.task('widget:button', gulp.series(() => {
2524
let b = browserify({
2625
entries: './app/widgets/donate-button/button.js',
2726
debug: process.env.NODE_ENV !== 'production',
@@ -39,32 +38,42 @@ gulp.task('widget:button', [], () => {
3938
.on('error', gutil.log)
4039
.pipe(sourcemaps.write('./'))
4140
.pipe(gulp.dest('app/widgets/donate-button/'));
42-
});
41+
}));
4342

44-
gulp.task('webpack:widget', [], (cb) => {
43+
gulp.task('webpack:widget', gulp.series((cb) => {
4544
exec('cd app/widgets && npm run build', function (err, stdout, stderr) {
4645
console.log(stdout);
4746
console.log(stderr);
4847
cb(err);
4948
});
50-
});
49+
}));
5150

52-
gulp.task('lib:distribution', [], (cb) => {
51+
gulp.task('lib:distribution', gulp.series((cb) => {
5352
exec('./node_modules/.bin/tsc app/lib/distribution.ts', function (err, stdout, stderr) {
5453
console.log(stdout);
5554
console.log(stderr);
5655
cb(err);
5756
});
58-
});
57+
}));
58+
59+
gulp.task('sass:widget', gulp.series(() => {
60+
return gulp.src([
61+
'app/sass/const.scss', 'app/sass/donate-button.scss', 'app/assets/fonts/fonts.css'
62+
])
63+
.pipe(sass().on('error', sass.logError))
64+
.pipe(concat('widget.css'))
65+
.pipe(uglifycss({ "maxLineLen": 80, "uglyComments": true }))
66+
.pipe(gulp.dest('app'));
67+
}));
5968

6069
// 'lib:distribution',
61-
gulp.task('webpack', ['sass:widget', 'lib:distribution', 'webpack:widget', 'widget:button']);
70+
gulp.task('webpack', gulp.series('sass:widget', 'lib:distribution', 'webpack:widget', 'widget:button'));
6271
/**************** WEBPACK END*/
6372

6473

6574

6675
/**************** TRANSLATE START*/
67-
gulp.task('translate:extract', () => {
76+
gulp.task('translate:extract', gulp.series(() => {
6877
return gulp.src([
6978
'app/components/**/*.html', 'app/components/**/*.ts',
7079
'app/shared/components/**/*.html', 'app/shared/components/**/*.ts',
@@ -89,35 +98,36 @@ gulp.task('translate:extract', () => {
8998
"requirejs": false
9099
}))
91100
.pipe(gulp.dest('po/'));
92-
});
101+
}));
93102

94-
gulp.task('translate:compile', () => {
103+
gulp.task('translate:compile', gulp.series(() => {
95104
return gulp.src('po/**/*.po')
96105
.pipe(gettext.compile({ format: 'json' }))
97106
.pipe(jeditor(json => {
98-
return json[Object.keys(json)[0]];
107+
/* This procedure gets inner context value, linearizing it for
108+
the gettext transformer */
109+
const res = {};
110+
json = json[Object.keys(json)[0]];
111+
112+
for (let o of Object.keys(json)) {
113+
let value = json[o];
114+
if (typeof(value) == 'object')
115+
value = json[o][Object.keys(json[o])[0]];
116+
res[o] = value;
117+
}
118+
119+
return res;
99120
}))
100121
.pipe(gulp.dest('app/assets/lang/'));
101-
});
122+
}));
102123

103-
gulp.task('translate', ['translate:extract', 'translate:compile']);
124+
gulp.task('translate', gulp.series('translate:extract', 'translate:compile'));
104125
/**************** TRANSLATE END*/
105126

106127

107128

108129

109-
gulp.task('sass:widget', () => {
110-
return gulp.src([
111-
'app/sass/const.scss', 'app/sass/donate-button.scss', 'app/assets/fonts/fonts.css'
112-
])
113-
.pipe(sass().on('error', sass.logError))
114-
.pipe(concat('widget.css'))
115-
.pipe(uglifycss({ "maxLineLen": 80, "uglyComments": true }))
116-
.pipe(gulp.dest('app'));
117-
});
118-
119-
120-
gulp.task('compress-images', () => {
130+
gulp.task('compress-images', gulp.series(() => {
121131
return gulp.src(['app/assets/media/**/*'])
122132
.pipe(imagemin([
123133
// imagemin.gifsicle({interlaced: true}),
@@ -131,5 +141,5 @@ gulp.task('compress-images', () => {
131141
})*/
132142
]))
133143
.pipe(gulp.dest('app/assets/media/'));
134-
});
144+
}));
135145

angular.json

+57-7
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,18 @@
7070
],
7171
"scripts": [
7272
"node_modules/intl-tel-input/build/js/intlTelInput.min.js"
73-
]
73+
],
74+
"serviceWorker": true,
75+
"ngswConfigPath": "app/ngsw-config.json"
7476
},
7577
"configurations": {
7678
"mainnet": {
79+
"budgets": [
80+
{
81+
"type": "anyComponentStyle",
82+
"maximumWarning": "6kb"
83+
}
84+
],
7785
"fileReplacements": [
7886
{
7987
"replace": "app/config.js",
@@ -91,6 +99,12 @@
9199
"buildOptimizer": true
92100
},
93101
"testnet": {
102+
"budgets": [
103+
{
104+
"type": "anyComponentStyle",
105+
"maximumWarning": "6kb"
106+
}
107+
],
94108
"fileReplacements": [
95109
{
96110
"replace": "app/config.js",
@@ -109,6 +123,12 @@
109123
"buildOptimizer": true
110124
},
111125
"mainnet-staging": {
126+
"budgets": [
127+
{
128+
"type": "anyComponentStyle",
129+
"maximumWarning": "6kb"
130+
}
131+
],
112132
"fileReplacements": [
113133
{
114134
"replace": "app/config.js",
@@ -125,7 +145,37 @@
125145
"vendorChunk": true,
126146
"buildOptimizer": true
127147
},
148+
"e2e": {
149+
"budgets": [
150+
{
151+
"type": "anyComponentStyle",
152+
"maximumWarning": "6kb"
153+
}
154+
],
155+
"fileReplacements": [
156+
{
157+
"replace": "app/config.js",
158+
"with": "app/config/e2e.js"
159+
}
160+
],
161+
"optimization": false,
162+
"outputHashing": "all",
163+
"sourceMap": false,
164+
"extractCss": false,
165+
"vendorSourceMap": false,
166+
"namedChunks": true,
167+
"aot": true,
168+
"extractLicenses": false,
169+
"vendorChunk": true,
170+
"buildOptimizer": false
171+
},
128172
"dev": {
173+
"budgets": [
174+
{
175+
"type": "anyComponentStyle",
176+
"maximumWarning": "6kb"
177+
}
178+
],
129179
"fileReplacements": [
130180
{
131181
"replace": "app/config.js",
@@ -153,6 +203,9 @@
153203
"configurations": {
154204
"dev": {
155205
"browserTarget": "helperbit:build:dev"
206+
},
207+
"e2e": {
208+
"browserTarget": "helperbit:build:e2e"
156209
}
157210
}
158211
},
@@ -197,11 +250,11 @@
197250
"builder": "@angular-devkit/build-angular:protractor",
198251
"options": {
199252
"protractorConfig": "e2e/protractor.conf.js",
200-
"devServerTarget": "helperbit:serve"
253+
"devServerTarget": "helperbit:serve:e2e"
201254
},
202255
"configurations": {
203256
"production": {
204-
"devServerTarget": "helperbit:serve:production"
257+
"devServerTarget": "helperbit:serve:e2e"
205258
}
206259
}
207260
},
@@ -215,10 +268,7 @@
215268
"configurations": {
216269
"dev": {
217270
"sourceMap": false,
218-
"optimization": {
219-
"scripts": false,
220-
"styles": true
221-
}
271+
"optimization": true
222272
}
223273
}
224274
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { decryptKeys, randomBytes, encryptKeys, randomKeys, toByteArray, toHexString, BackupFile, decryptBackup, checkBitcoinAddress } from "./bitcoin-helper";
2+
import { networks } from 'bitcoinjs-lib';
3+
4+
describe('Bitcoin keys encryption / decryption', () => {
5+
it('should return the same data after encryp => decrypt', () => {
6+
const key = randomKeys();
7+
const password = 'password';
8+
expect(decryptKeys(encryptKeys(key.private, password), password)).toEqual(key);
9+
});
10+
11+
it('should fail decryption', () => {
12+
expect(decryptKeys('castiglio', 'pino')).toBeNull();
13+
});
14+
15+
it('should decrypt backup and fail with wrong data', () => {
16+
const key = randomKeys();
17+
const password = 'password';
18+
const keyEnc = encryptKeys(key.private, password);
19+
const backup: BackupFile = {
20+
encprivkey: keyEnc,
21+
pubkey: key.public,
22+
address: '123',
23+
walletid: '123',
24+
label: '',
25+
organization: '',
26+
scripttype: 'p2sh',
27+
user: 'dakk',
28+
pubkeysrv: key.public
29+
};
30+
expect(decryptBackup(backup, password)).toEqual(key);
31+
expect(() => decryptBackup(null, password)).toThrow();
32+
expect(() => decryptBackup({ ...backup, ...{ encprivkey: undefined } }, password)).toThrow();
33+
expect(() => decryptBackup({ ...backup, ...{ pubkey: undefined } }, password)).toThrow();
34+
// expect(() => decryptBackup({ ...backup, ...{ address: undefined } }, password)).toThrow();
35+
// expect(() => decryptBackup({ ...backup, ...{ walletid: undefined } }, password, true)).toThrow();
36+
expect(() => decryptBackup({ ...backup, ...{ pubkey: 'ciao' } }, password, true)).toThrow();
37+
});
38+
});
39+
40+
describe('CheckBitcoinAddress()', () => {
41+
it('should detect valid address', () => {
42+
expect(checkBitcoinAddress('mtXWDB6k5yC5v7TcwKZHB89SUp85yCKshy', networks.testnet)).toBeTrue();
43+
expect(checkBitcoinAddress('tb1q9yqzjcywvuy9lz2vuvv6xmkhe7zg9kkp35mdrn', networks.testnet)).toBeTrue();
44+
});
45+
46+
it('should detect invalid address', () => {
47+
expect(checkBitcoinAddress('mtXWDB6k5yC5v7TcwKZHB89SUp85yCKsh1y', networks.testnet)).toBeFalse();
48+
});
49+
});
50+
51+
describe('RandomBytes()', () => {
52+
it('should fail on invalid size', () => {
53+
expect(() => randomBytes(65537)).toThrow();
54+
});
55+
56+
it('should generate correct size buffer', () => {
57+
expect(randomBytes(64).length).toBe(64);
58+
expect(randomBytes(64)).toBeInstanceOf(Buffer);
59+
})
60+
});
61+
62+
63+
describe('Hex strings conversion', () => {
64+
it('should transform hex string to buffer', () => {
65+
const data = toByteArray('caccac');
66+
expect(data).toBeInstanceOf(Buffer);
67+
expect(data.length).toBe(3);
68+
expect(data[0]).toBe(0xca);
69+
expect(data[1]).toBe(0xcc);
70+
expect(data[2]).toBe(0xac);
71+
});
72+
73+
it('should transform buffer to hex string', () => {
74+
const data = toHexString(Buffer.from([0xca, 0xcc, 0xac]));
75+
expect(data).toBeInstanceOf(String);
76+
expect(data.length).toBe(6);
77+
expect(data).toBe('caccac');
78+
});
79+
80+
it('should transform hex string to buffer and then to hex string', () => {
81+
expect(toHexString(toByteArray('c09fff'))).toBe('c09fff');
82+
});
83+
});

0 commit comments

Comments
 (0)