Skip to content

Commit f9220ac

Browse files
authored
Merge pull request bitpay#3004 from kajoseph/feature/payId
PayId rework
2 parents ab6ee13 + e6a9dfb commit f9220ac

33 files changed

+7426
-941
lines changed

packages/bitcore-payid/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,24 @@ This is a library to assist [PayId](https://payid.org/) integration with Bitcore
1313
import Bitcore from 'bitcore-lib';
1414
import PayId from 'bitcore-payid';
1515

16+
// ...
17+
1618
const privKey = new Bitcore.HDPrivateKey(); // or Bitcore.PrivateKey() for a non-hierarchically derived private key
1719

18-
const signed = PayId.sign('alex$example.com', 'bitcoinaddress123', 'BTC', privKey.toString());
20+
const signed = await PayId.sign('alex$example.com', 'bitcoinaddress123', 'BTC', privKey.toString());
1921
```
2022

2123
* Node crypto key
2224
```javascript
2325
import crypto from 'crypto';
2426
import PayId from 'bitcore-payid';
2527

28+
// ...
29+
2630
const keys = crypto.generateKeyPair('ec'); // could be 'rsa' too
2731
const privKey = keys.privateKey.export({ format: 'pem', type: 'pkcs8' });
2832

29-
const signed = PayId.sign('alex$example.com', 'bitcoinaddress123', 'BTC', privKey);
33+
const signed = await PayId.sign('alex$example.com', 'bitcoinaddress123', 'BTC', privKey);
3034
```
3135

3236
* From file
@@ -35,9 +39,11 @@ const signed = PayId.sign('alex$example.com', 'bitcoinaddress123', 'BTC', privKe
3539
import fs from 'fs';
3640
import PayId from 'bitcore-payid';
3741

42+
// ...
43+
3844
const privKey = fs.readFileSync('/path/to/private/key');
3945

40-
const signed = PayId.sign('alex$example.com', 'bitcoinaddress123', 'BTC', privKey);
46+
const signed = await PayId.sign('alex$example.com', 'bitcoinaddress123', 'BTC', privKey);
4147
```
4248

4349
It is recommended to store the signed.signatures' `signatures` and `protected` properties. `protected` can be thought of as the public key to verify the signature because it contains the ingredients to build the public key as a JWK, but you could also discard the `protected` property if you intend to rebuild it at verification time.
@@ -52,6 +58,6 @@ import PayId from 'PayId';
5258

5359
// ...
5460

55-
const isValid = PayId.verify('alice$example.com', verifiableAddress);
61+
const isValid = await PayId.verify('alice$example.com', verifiableAddress);
5662
```
5763

packages/bitcore-payid/karma.conf.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Karma configuration
2+
// Generated on Wed Nov 04 2020 11:58:56 GMT-0500 (Eastern Standard Time)
3+
4+
module.exports = (config) => {
5+
config.set({
6+
7+
// base path that will be used to resolve all patterns (eg. files, exclude)
8+
basePath: '',
9+
10+
11+
// frameworks to use
12+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13+
frameworks: ['mocha', 'karma-typescript'],
14+
15+
16+
// list of files / patterns to load in the browser
17+
files: [
18+
'src/**/*.ts',
19+
'test/**/*.ts'
20+
],
21+
22+
23+
// list of files / patterns to exclude
24+
exclude: [
25+
],
26+
27+
28+
// preprocess matching files before serving them to the browser
29+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
30+
preprocessors: {
31+
'**/*.ts': 'karma-typescript'
32+
},
33+
34+
35+
// test results reporter to use
36+
// possible values: 'dots', 'progress'
37+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
38+
reporters: ['progress'],
39+
40+
41+
// web server port
42+
port: 9876,
43+
44+
45+
// enable / disable colors in the output (reporters and logs)
46+
colors: true,
47+
48+
49+
// level of logging
50+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
51+
logLevel: config.LOG_INFO,
52+
53+
54+
// enable / disable watching file and executing tests whenever any file changes
55+
autoWatch: true,
56+
57+
58+
// start these browsers
59+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
60+
browsers: [
61+
// 'Chrome',
62+
'ChromeDebugging',
63+
// 'Firefox'
64+
],
65+
66+
67+
// Continuous Integration mode
68+
// if true, Karma captures browsers, runs the tests and exits
69+
singleRun: false,
70+
71+
// Concurrency level
72+
// how many browser should be started simultaneous
73+
concurrency: Infinity,
74+
75+
karmaTypescriptConfig: {
76+
tsconfig: './tsconfig.json',
77+
bundlerOptions: {
78+
transforms: [
79+
require('karma-typescript-es6-transform')()
80+
],
81+
sourceMap: true
82+
},
83+
},
84+
85+
customLaunchers: {
86+
ChromeDebugging: {
87+
base: 'Chrome',
88+
flags: [ '--remote-debugging-port=9333' ]
89+
}
90+
},
91+
});
92+
};

0 commit comments

Comments
 (0)