Skip to content

Commit 6bfe7df

Browse files
authored
Merge pull request #77 from cmgustavo/bug/fix-sign-input-02
fix(sign-input): invalid appIdentity for bp card
2 parents 944f09c + ffa22ee commit 6bfe7df

File tree

8 files changed

+64
-95
lines changed

8 files changed

+64
-95
lines changed

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,31 @@ node_modules
33
./bitauth.min.js
44
./tests.js
55

6+
# OSX
67

8+
.DS_Store
9+
.AppleDouble
10+
.LSOverride
11+
12+
# Thumbnails
13+
._*
14+
15+
# Files that might appear on external disk
16+
.Spotlight-V100
17+
.Trashes
18+
19+
# Directories potentially created on remote AFP share
20+
.AppleDB
21+
.AppleDesktop
22+
Network Trash Folder
23+
Temporary Items
24+
.apdisk
25+
26+
# VIM ignore
27+
28+
[._]*.s[a-w][a-z]
29+
[._]s[a-w][a-z]
30+
*.un~
31+
Session.vim
32+
.netrwhist
33+
*~

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ Install with Node.js:
1818
npm install bitauth
1919
```
2020

21-
To generate a browser bundle, you can then run:
22-
23-
```bash
24-
gulp browser
25-
```
26-
2721
## Advantages over other authentication mechanisms
2822

2923
* By signing each request, man in the middle attacks are impossible.
@@ -199,25 +193,3 @@ BitAuth exposes a connect middleware for use in connect or ExpressJS application
199193
var bitauth = require('bitauth');
200194
app.use( bitauth.middleware );
201195
```
202-
203-
## Development
204-
205-
To build a browser compatible version of BitAuth, run the following command from the project's root directory:
206-
207-
```bash
208-
gulp browser
209-
```
210-
211-
This will output `bitauth.min.js` to project directory. The script can be loaded using `require('bitauth')`.
212-
213-
To then run tests for a web browser:
214-
215-
```bash
216-
gulp test:browser
217-
```
218-
219-
To run tests for Node.js:
220-
221-
```bash
222-
gulp test:node
223-
```

bower.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

browserify.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

karma.conf.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = function(config) {
2+
config.set({
3+
basePath: './',
4+
frameworks: ['browserify', 'mocha'],
5+
files: [
6+
'test/*.js'
7+
],
8+
exclude: [
9+
],
10+
preprocessors: {
11+
'test/*.js': [ 'browserify' ]
12+
},
13+
browserify: {
14+
debug: true
15+
},
16+
reporters: ['progress'],
17+
port: 9876,
18+
colors: true,
19+
logLevel: config.LOG_INFO,
20+
autoWatch: false,
21+
browsers: ['Chrome'],
22+
singleRun: true
23+
})
24+
}

lib/bitauth-browserify.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ BitAuth._getPublicKeyFromPrivateKey = function(privkey) {
1919
} else {
2020
privKeyString = privkey;
2121
}
22-
const keys = ecdsa.keyPair(privkey, 'hex');
22+
const keys = ecdsa.keyFromPrivate(privKeyString, 'hex');
2323

2424
// compressed public key
2525
const pubKey = keys.getPublic();
@@ -36,12 +36,13 @@ BitAuth._getPublicKeyFromPrivateKey = function(privkey) {
3636
};
3737

3838
BitAuth._sign = function(hashBuffer, privkey) {
39-
const signature = ecdsa.sign(hashBuffer.toString('hex'), privkey);
39+
const keys = ecdsa.keyFromPrivate(privkey, 'hex');
40+
const signature = keys.sign(hashBuffer.toString('hex'));
4041
return signature.toDER('hex');
4142
};
4243

4344
BitAuth._verifySignature = function(hashBuffer, signatureBuffer, pubkey) {
44-
return ecdsa.verify(hashBuffer.toString('hex'), signatureBuffer, pubkey);
45+
return ecdsa.verify(hashBuffer.toString('hex'), signatureBuffer, pubkey, 'hex');
4546
};
4647

4748
module.exports = BitAuth;

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
}
2929
],
3030
"scripts": {
31-
"test": "mocha"
31+
"test": "mocha",
32+
"test-browser": "karma start karma.conf.js"
3233
},
3334
"main": "index.js",
3435
"version": "0.4.0",
@@ -38,8 +39,14 @@
3839
},
3940
"devDependencies": {
4041
"benchmark": "^2.1.4",
42+
"browserify": "^16.5.1",
4143
"chai": "^4.2.0",
42-
"mocha": "^6.2.2"
44+
"karma": "^4.4.1",
45+
"karma-browserify": "^7.0.0",
46+
"karma-chrome-launcher": "^3.1.0",
47+
"karma-mocha": "^1.3.0",
48+
"mocha": "^6.2.2",
49+
"watchify": "^3.11.1"
4350
},
4451
"license": "MIT"
4552
}

0 commit comments

Comments
 (0)