Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,31 @@ node_modules
./bitauth.min.js
./tests.js

# OSX

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# VIM ignore

[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ Install with Node.js:
npm install bitauth
```

To generate a browser bundle, you can then run:

```bash
gulp browser
```

## Advantages over other authentication mechanisms

* By signing each request, man in the middle attacks are impossible.
Expand Down Expand Up @@ -199,25 +193,3 @@ BitAuth exposes a connect middleware for use in connect or ExpressJS application
var bitauth = require('bitauth');
app.use( bitauth.middleware );
```

## Development

To build a browser compatible version of BitAuth, run the following command from the project's root directory:

```bash
gulp browser
```

This will output `bitauth.min.js` to project directory. The script can be loaded using `require('bitauth')`.

To then run tests for a web browser:

```bash
gulp test:browser
```

To run tests for Node.js:

```bash
gulp test:node
```
29 changes: 0 additions & 29 deletions bower.json

This file was deleted.

14 changes: 0 additions & 14 deletions browserify.js

This file was deleted.

24 changes: 24 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = function(config) {
config.set({
basePath: './',
frameworks: ['browserify', 'mocha'],
files: [
'test/*.js'
],
exclude: [
],
preprocessors: {
'test/*.js': [ 'browserify' ]
},
browserify: {
debug: true
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['Chrome'],
singleRun: true
})
}
7 changes: 4 additions & 3 deletions lib/bitauth-browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BitAuth._getPublicKeyFromPrivateKey = function(privkey) {
} else {
privKeyString = privkey;
}
const keys = ecdsa.keyPair(privkey, 'hex');
const keys = ecdsa.keyFromPrivate(privKeyString, 'hex');

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

BitAuth._sign = function(hashBuffer, privkey) {
const signature = ecdsa.sign(hashBuffer.toString('hex'), privkey);
const keys = ecdsa.keyFromPrivate(privkey, 'hex');
const signature = keys.sign(hashBuffer.toString('hex'));
return signature.toDER('hex');
};

BitAuth._verifySignature = function(hashBuffer, signatureBuffer, pubkey) {
return ecdsa.verify(hashBuffer.toString('hex'), signatureBuffer, pubkey);
return ecdsa.verify(hashBuffer.toString('hex'), signatureBuffer, pubkey, 'hex');
};

module.exports = BitAuth;
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
}
],
"scripts": {
"test": "mocha"
"test": "mocha",
"test-browser": "karma start karma.conf.js"
},
"main": "index.js",
"version": "0.4.0",
Expand All @@ -38,8 +39,14 @@
},
"devDependencies": {
"benchmark": "^2.1.4",
"browserify": "^16.5.1",
"chai": "^4.2.0",
"mocha": "^6.2.2"
"karma": "^4.4.1",
"karma-browserify": "^7.0.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^1.3.0",
"mocha": "^6.2.2",
"watchify": "^3.11.1"
},
"license": "MIT"
}