feathers-authentication
Advanced tools
Comparing version 0.7.12 to 0.7.13
@@ -17,4 +17,3 @@ 'use strict'; | ||
// Check hook is being called on an allowable method | ||
if (!(hook.method === 'get' || hook.method === 'update' || hook.method === 'patch' || hook.method === 'remove')) { | ||
if (!hook.id) { | ||
throw new _feathersErrors2.default.MethodNotAllowed('The \'restrictToOwner\' hook should only be used on the \'get\', \'update\', \'patch\' and \'remove\' service methods.'); | ||
@@ -21,0 +20,0 @@ } |
@@ -7,4 +7,2 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
exports.default = function () { | ||
@@ -62,34 +60,28 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
} else { | ||
var _ret = function () { | ||
var secret = options.secret; | ||
var secret = options.secret; | ||
if (!secret) { | ||
throw new Error('You need to pass \'options.secret\' to the verifyToken() hook or set \'auth.token.secret\' it in your config.'); | ||
} | ||
if (!secret) { | ||
throw new Error('You need to pass \'options.secret\' to the verifyToken() hook or set \'auth.token.secret\' it in your config.'); | ||
} | ||
// Convert the algorithm value to an array | ||
if (options.algorithm) { | ||
options.algorithms = [options.algorithm]; | ||
delete options.algorithm; | ||
} | ||
// Convert the algorithm value to an array | ||
if (options.algorithm) { | ||
options.algorithms = [options.algorithm]; | ||
delete options.algorithm; | ||
} | ||
return { | ||
v: new Promise(function (resolve, reject) { | ||
_jsonwebtoken2.default.verify(token, secret, options, function (error, payload) { | ||
if (error) { | ||
// If the user is trying to add a token then it is better to throw and error than let the request go through with a restriction | ||
return reject(new _feathersErrors2.default.NotAuthenticated(error)); | ||
} | ||
return new Promise(function (resolve, reject) { | ||
_jsonwebtoken2.default.verify(token, secret, options, function (error, payload) { | ||
if (error) { | ||
// If the user is trying to add a token then it is better to throw and error than let the request go through with a restriction | ||
return reject(new _feathersErrors2.default.NotAuthenticated(error)); | ||
} | ||
// Attach our decoded token payload to the params | ||
hook.params.payload = payload; | ||
// Attach our decoded token payload to the params | ||
hook.params.payload = payload; | ||
resolve(hook); | ||
}); | ||
}) | ||
}; | ||
}(); | ||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; | ||
resolve(hook); | ||
}); | ||
}); | ||
} | ||
@@ -96,0 +88,0 @@ }; |
@@ -79,3 +79,4 @@ 'use strict'; | ||
algorithm: 'HS256', | ||
expiresIn: '1d' }; | ||
expiresIn: '1d' // 1 day | ||
}; | ||
@@ -158,3 +159,4 @@ /** | ||
var options = this.options; | ||
var data = params; | ||
var data = _defineProperty({}, options.idField, params.data[options.idField]); | ||
// Our before hook determined that we had a valid token or that this | ||
@@ -161,0 +163,0 @@ // was internally called so let's generate a new token with the user |
{ | ||
"name": "feathers-authentication", | ||
"description": "Add Authentication to your FeathersJS app.", | ||
"version": "0.7.12", | ||
"version": "0.7.13", | ||
"homepage": "https://github.com/feathersjs/feathers-authentication", | ||
@@ -35,8 +35,7 @@ "main": "lib/", | ||
"release:major": "npm version major && npm publish", | ||
"compile": "rimraf lib/ && babel -d lib/ src/ && mkdir lib/public/ && cp src/public/* lib/public/", | ||
"compile": "rm -rf lib/ && babel -d lib/ src/ && mkdir lib/public/ && cp src/public/* lib/public/", | ||
"watch": "babel --watch -d lib/ src/", | ||
"jshint": "jshint src/. test/. --config", | ||
"mocha": "mocha --opts mocha.opts", | ||
"test": "npm run compile && npm run jshint && npm run coverage && nsp check", | ||
"coverage": "istanbul cover node_modules/mocha/bin/_mocha -- --opts mocha.opts" | ||
"mocha": "mocha --recursive test/ --compilers js:babel-core/register", | ||
"test": "npm run compile && npm run jshint && npm run mocha && nsp check" | ||
}, | ||
@@ -61,3 +60,3 @@ "directories": { | ||
"babel-cli": "^6.1.18", | ||
"babel-core": "^6.18.2", | ||
"babel-core": "^6.1.21", | ||
"babel-plugin-add-module-exports": "^0.2.0", | ||
@@ -73,3 +72,2 @@ "babel-preset-es2015": "^6.1.18", | ||
"feathers-socketio": "^1.3.2", | ||
"istanbul": "^1.1.0-alpha.1", | ||
"jshint": "^2.8.0", | ||
@@ -84,3 +82,2 @@ "localstorage-memory": "^1.0.2", | ||
"request": "^2.69.0", | ||
"rimraf": "^2.5.4", | ||
"sinon": "^1.17.3", | ||
@@ -87,0 +84,0 @@ "sinon-chai": "^2.8.0", |
# feathers-authentication | ||
## v1.0.0 | ||
> __IMPORTANT:__ To see the feathers-authentication 1.0 documentation go to the [master branch](https://github.com/feathersjs/feathers-authentication/tree/master) and also have a look at the [migration guide](https://github.com/feathersjs/feathers-authentication/blob/master/docs/migrating.md). | ||
[![Build Status](https://travis-ci.org/feathersjs/feathers-authentication.png?branch=master)](https://travis-ci.org/feathersjs/feathers-authentication) | ||
[![Code Climate](https://codeclimate.com/github/feathersjs/feathers-authentication.png)](https://codeclimate.com/github/feathersjs/feathers-authentication) | ||
[![Test Coverage](https://codeclimate.com/github/feathersjs/feathers-authentication/badges/coverage.svg)](https://codeclimate.com/github/feathersjs/feathers-authentication/coverage) | ||
[![Dependency Status](https://img.shields.io/david/feathersjs/feathers-authentication.svg?style=flat-square)](https://david-dm.org/feathersjs/feathers-authentication) | ||
[![Download Status](https://img.shields.io/npm/dm/feathers-authentication.svg?style=flat-square)](https://www.npmjs.com/package/feathers-authentication) | ||
[![Slack Status](http://slack.feathersjs.com/badge.svg)](http://slack.feathersjs.com) | ||
@@ -86,3 +85,2 @@ > Add Authentication to your FeathersJS app. | ||
import socketio from 'feathers-socketio/client'; | ||
import localstorage from 'feathers-localstorage'; | ||
import authentication from 'feathers-authentication/client'; | ||
@@ -89,0 +87,0 @@ |
1889141
26
254
2753
109