Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit a8cecb2

Browse files
authored
Update to new plugin infrastructure (#37)
1 parent 7e1abf5 commit a8cecb2

20 files changed

Lines changed: 584 additions & 2632 deletions

.babelrc

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

.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ node_modules
2929
# Users Environment Variables
3030
.lock-wscript
3131

32-
# The compiled/babelified modules
33-
lib/
34-
35-
# Yarn lockfile
36-
yarn.lock
37-
/.vscode
32+
dist/

.istanbul.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
verbose: false
22
instrumentation:
3-
root: ./src/
4-
excludes:
5-
- lib/
3+
root: ./lib/
64
include-all-sources: true
75
reporting:
86
print: summary
@@ -14,4 +12,4 @@ reporting:
1412
statements: [50, 80]
1513
lines: [50, 80]
1614
functions: [50, 80]
17-
branches: [50, 80]
15+
branches: [50, 80]

.npmignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.istanbul.yml
55
.babelrc
66
.idea/
7-
src/
7+
.vscode/
88
test/
9-
!lib/
9+
coverage/
1010
.github/

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: node_js
22
node_js:
33
- node
44
- '6'
5-
- '4'
65
addons:
76
code_climate:
87
repo_token: e343c2f43b67fdeaad91aa90c6010f2330d9440595c8337d7d757d0aa6cd25ae

example/app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ app.configure(rest())
2525
.use('/users', memory())
2626
.use(errorHandler());
2727

28-
2928
// Authenticate the user using the default
3029
// email/password strategy and if successful
3130
// return a JWT.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import hasher from '../utils/hash';
2-
import merge from 'lodash.merge';
3-
import Debug from 'debug';
1+
const hasher = require('../utils/hash');
2+
const merge = require('lodash.merge');
3+
const Debug = require('debug');
44

55
const debug = Debug('feathers-authentication-local:hooks:hash-password');
66

7-
export default function hashPassword (options = {}) {
7+
module.exports = function hashPassword (options = {}) {
88
return function (hook) {
99
if (hook.type !== 'before') {
1010
return Promise.reject(new Error(`The 'hashPassword' hook should only be used as a 'before' hook.`));
@@ -72,4 +72,4 @@ export default function hashPassword (options = {}) {
7272
return Promise.resolve(hook);
7373
});
7474
};
75-
}
75+
};

lib/hooks/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const hashPassword = require('./hash-password');
2+
3+
module.exports = {
4+
hashPassword
5+
};

src/index.js renamed to lib/index.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import Debug from 'debug';
2-
import merge from 'lodash.merge';
3-
import omit from 'lodash.omit';
4-
import pick from 'lodash.pick';
5-
import hooks from './hooks';
6-
import DefaultVerifier from './verifier';
7-
import { Strategy as LocalStrategy } from 'passport-local';
1+
const Debug = require('debug');
2+
const merge = require('lodash.merge');
3+
const omit = require('lodash.omit');
4+
const pick = require('lodash.pick');
5+
const hooks = require('./hooks');
6+
const DefaultVerifier = require('./verifier');
7+
8+
const passportLocal = require('passport-local');
89

910
const debug = Debug('feathers-authentication-local');
1011
const defaults = {
@@ -20,8 +21,8 @@ const KEYS = [
2021
'session'
2122
];
2223

23-
export default function init(options = {}) {
24-
return function localAuth() {
24+
module.exports = function init (options = {}) {
25+
return function localAuth () {
2526
const app = this;
2627
const _super = app.setup;
2728

@@ -46,22 +47,22 @@ export default function init(options = {}) {
4647
let verifier = new Verifier(app, localSettings);
4748

4849
if (!verifier.verify) {
49-
throw new Error(`Your verifier must implement a 'verify' function. It should have the same signature as a local passport verify callback.`)
50+
throw new Error(`Your verifier must implement a 'verify' function. It should have the same signature as a local passport verify callback.`);
5051
}
5152

5253
// Register 'local' strategy with passport
5354
debug('Registering local authentication strategy with options:', localSettings);
54-
app.passport.use(localSettings.name, new LocalStrategy(localSettings, verifier.verify.bind(verifier)));
55+
app.passport.use(localSettings.name, new passportLocal.Strategy(localSettings, verifier.verify.bind(verifier)));
5556
app.passport.options(localSettings.name, localSettings);
56-
57+
5758
return result;
58-
}
59+
};
5960
};
60-
}
61+
};
6162

6263
// Exposed Modules
63-
Object.assign(init, {
64+
Object.assign(module.exports, {
6465
defaults,
6566
hooks,
6667
Verifier: DefaultVerifier
67-
});
68+
});
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import bcrypt from 'bcryptjs';
1+
const bcrypt = require('bcryptjs');
22

33
const BCRYPT_WORK_FACTOR_BASE = 12;
44
const BCRYPT_DATE_BASE = 1483228800000;
55
const BCRYPT_WORK_INCREASE_INTERVAL = 47300000000;
66

7-
export default function hasher (password) {
7+
module.exports = function hasher (password) {
88
return new Promise((resolve, reject) => {
99
let BCRYPT_CURRENT_DATE = new Date().getTime();
1010
let BCRYPT_WORK_INCREASE = Math.max(0, Math.floor((BCRYPT_CURRENT_DATE - BCRYPT_DATE_BASE) / BCRYPT_WORK_INCREASE_INTERVAL));
@@ -24,4 +24,4 @@ export default function hasher (password) {
2424
});
2525
});
2626
});
27-
}
27+
};

0 commit comments

Comments
 (0)