Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@websanova/vue-auth

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@websanova/vue-auth - npm Package Compare versions

Comparing version 2.2.0-beta to 2.2.1-beta

test/test.js

3

2.x.demo/src/app.js

@@ -86,2 +86,5 @@ import App from './components/App.vue';

Vue.use(require('../../src/index.js'), {
auth: require('../../drivers/auth/bearer.js'),
http: require('../../drivers/http/vue-resource.1.x.js'),
router: require('../../drivers/router/vue-router.2.x.js'),
rolesVar: 'role',

@@ -88,0 +91,0 @@ facebookOauth2Data: {

@@ -67,9 +67,5 @@ /******/ (function(modules) { // webpackBootstrap

return function install(Vue, options) {
var auth,
driver = __webpack_require__(42);
driver.Vue = Vue;
var auth = new Auth(Vue, options);
auth = new Auth(options, driver);
var login = auth.login;

@@ -581,4 +577,4 @@ var fetch = auth.fetch;

var __utils = __webpack_require__(39),
__token = __webpack_require__(40),
__cookie = __webpack_require__(41);
__token = __webpack_require__(77),
__cookie = __webpack_require__(78);

@@ -601,3 +597,3 @@ module.exports = function () {

this.options._http.call(this, data);
this.options.http._http.call(this, data);
}

@@ -608,3 +604,3 @@

_auth.options[methodName + 'Perform'].call(_auth, _auth.options._bindData.call(_auth, data, this));
_auth.options[methodName + 'Perform'].call(_auth, _auth.options.router._bindData.call(_auth, data, this));
}

@@ -616,3 +612,3 @@

if (!this.watch.loaded && __token.get.call(this)) {
if (this.options.tokenExpired.call(this)) {
this.options.refreshPerform.call(this, {});

@@ -638,3 +634,3 @@ }

function _transitionEach(routeAuth, next) {
function _transitionEach(routeAuth, cb) {
routeAuth = __utils.toArray(routeAuth);

@@ -644,12 +640,12 @@

if (!this.check()) {
this.options._routerReplace.call(this, this.options.authRedirect);
} else if (routeAuth.constructor === Array && !__utils.compare(routeAuth, __utils.toArray(this.watch.data[this.options.rolesVar]))) {
this.options._routerReplace.call(this, this.options.forbiddenRedirect);
cb.call(this, this.options.authRedirect);
} else if (routeAuth.constructor === Array && !__utils.compare(routeAuth, this.watch.data[this.options.rolesVar])) {
cb.call(this, this.options.forbiddenRedirect);
} else {
return next();
return cb();
}
} else if (routeAuth === false && this.check()) {
this.options._routerReplace.call(this, this.options.notFoundRedirect);
cb.call(this, this.options.notFoundRedirect);
} else {
return next();
return cb();
}

@@ -662,11 +658,3 @@ }

if (token) {
if (this.options.authType === 'bearer') {
this.options._setHeaders.call(this, req, {
authorization: 'Bearer: ' + token
});
} else if (this.options.authType === 'basic') {
this.options._setHeaders.call(this, req, {
authorization: token
});
}
this.options.auth.request.call(this, req, token);
}

@@ -678,15 +666,12 @@

function _responseIntercept(res) {
var headers = this.options._getHeaders.call(this, res),
httpData = this.options._httpData.call(this, res);
var token;
if (headers.token) {
__token.set.call(this, null, headers.token);
if (this.options.http._invalidToken) {
this.options.http._invalidToken.call(this, res);
}
if (httpData[this.options.tokenVar]) {
__token.set.call(this, null, httpData[this.options.tokenVar]);
}
token = this.options.auth.response.call(this, res);
if (this.options._invalidToken) {
this.options._invalidToken.call(this, res);
if (token) {
__token.set.call(this, null, token);
}

@@ -700,3 +685,3 @@ }

function _check(role) {
if (this.watch.data !== null) {
if (this.watch.authenticated === true) {
if (role) {

@@ -712,2 +697,6 @@ return __utils.compare(role, this.watch.data[this.options.rolesVar]);

function _tokenExpired() {
return !this.watch.loaded && __token.get.call(this);
}
function _cookieDomain() {

@@ -735,3 +724,7 @@ return window.location.hostname;

__duckPunch.call(this, 'fetch', data);
if (this.watch.authenticated !== true && !this.options.loginData.fetchUser) {
_fetchProcess.call(this, {}, data);
} else {
__duckPunch.call(this, 'fetch', data);
}
}

@@ -741,3 +734,3 @@

this.watch.authenticated = true;
this.watch.data = this.options.parseUserData.call(this, this.options._httpData.call(this, res));
this.watch.data = this.options.parseUserData.call(this, this.options.http._httpData.call(this, res));
this.watch.loaded = true;

@@ -775,3 +768,3 @@

if (data.redirect) {
this.options._routerGo.call(this, data.redirect);
this.options.router._routerGo.call(this, data.redirect);
}

@@ -799,3 +792,3 @@ }

if (data.redirect && _this.options.check.call(_this)) {
_this.options._routerGo.call(_this, data.redirect);
_this.options.router._routerGo.call(_this, data.redirect);
}

@@ -822,3 +815,3 @@ }

this.authenticated = false;
this.watch.authenticated = false;
this.watch.data = null;

@@ -831,3 +824,3 @@

if (data.redirect) {
this.options._routerGo.call(this, data.redirect);
this.options.router._routerGo.call(this, data.redirect);
}

@@ -868,3 +861,3 @@ }

if (data.redirect && _this.options.check.call(_this)) {
_this.options._routerGo.call(_this, data.redirect);
_this.options.router._routerGo.call(_this, data.redirect);
}

@@ -895,3 +888,3 @@ }

if (data.redirect) {
this.options._routerGo.call(this, data.redirect);
this.options.router._routerGo.call(this, data.redirect);
}

@@ -903,12 +896,13 @@ }

function _oauth2Perform(data) {
var state,
params = '';
var state = {},
params = '',
query = {};
console.log(data);
if (data.code) {
if (data.code === true) {
data = __utils.extend(this.options[data.provider + 'Data'], [data]);
try {
state = JSON.parse(decodeURIComponent(this.options._getQuery.call(this)));
if (data.query.state) {
state = JSON.parse(decodeURIComponent(data.query.state));
}
} catch (e) {

@@ -919,6 +913,6 @@ console.error('vue-auth:error There was an issue retrieving the state data.');

console.log(data);
console.log(state);
data.rememberMe = state.rememberMe === true;
data.state = state;
// _login.call(this, this.getOption(type + 'Url'), data, state.rememberMe, state.redirect, options);
this.options.loginPerform.call(this, data);
} else {

@@ -932,6 +926,4 @@ data = __utils.extend(this.options[data.provider + 'Oauth2Data'], [data]);

console.log(data);
params = '?client_id=' + data.clientId + '&redirect_uri=' + data.redirect + '&scope=' + data.scope + '&response_type=code&state=' + encodeURIComponent((0, _stringify2.default)(data.state));
params = '?client_id=' + data.appId + '&redirect_uri=' + data.redirect + '&scope=' + data.scope + '&response_type=code&state=' + encodeURIComponent((0, _stringify2.default)(data.state));
window.location = data.url + params;

@@ -941,4 +933,2 @@ }

function _oauth2Process() {}
var defaultOptions = {

@@ -948,9 +938,5 @@

tokenVar: 'token',
rolesVar: 'roles',
tokenName: 'auth-token',
tokenHeader: 'Authorization',
authType: 'bearer',
rolesVar: 'roles',
// Objects

@@ -963,7 +949,7 @@

registerData: { url: 'auth/register', method: 'POST', redirect: '/login' },
loginData: { url: 'auth/login', method: 'POST', redirect: '/' },
loginData: { url: 'auth/login', method: 'POST', redirect: '/', fetchUser: true },
logoutData: { url: 'auth/logout', method: 'POST', redirect: '/', makeRequest: false },
oauth1Data: { url: 'auth/login', method: 'POST' },
fetchData: { url: 'auth/user', method: 'GET' },
refreshData: { url: 'auth/refresh', method: 'GET', atInit: true },
refreshData: { url: 'auth/refresh', method: 'GET' },
loginOtherData: { url: 'auth/login-other', method: 'POST', redirect: '/' },

@@ -980,3 +966,3 @@ logoutOtherData: { url: 'auth/logout-other', method: 'POST', redirect: '/admin', makeRequest: false },

},
appId: '',
clientId: '',
scope: 'email'

@@ -989,3 +975,3 @@ },

},
appId: '',
clientId: '',
scope: 'https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read'

@@ -999,7 +985,5 @@ },

parseUserData: _parseUserData,
tokenExpired: _tokenExpired,
check: _check,
// disableOther
// enableOther
transitionEach: _transitionEach,

@@ -1033,19 +1017,24 @@ routerBeforeEach: _routerBeforeEach,

oauth2Perform: _oauth2Perform,
oauth2Process: _oauth2Process
oauth2Perform: _oauth2Perform
};
function Auth(options, driver) {
function Auth(Vue, options) {
this.currentToken = null;
this.options = __utils.extend(defaultOptions, [driver || {}, options || {}]);
this.options = __utils.extend(defaultOptions, [options || {}]);
this.options.Vue = Vue;
this.watch = this.options._watch.call(this, {
data: null,
loaded: false,
authenticated: null
this.watch = new this.options.Vue({
data: function data() {
return {
data: null,
loaded: false,
authenticated: null
};
}
});
driver._init.call(this);
// Init interceptors.
this.options.router._beforeEach.call(this, this.options.routerBeforeEach, this.options.transitionEach);
this.options.http._interceptor.call(this, this.options.requestIntercept, this.options.responseIntercept);
}

@@ -1062,3 +1051,3 @@

return this.watch.data;
return this.watch.data || {};
};

@@ -1145,8 +1134,22 @@

/* 39 */
/***/ function(module, exports) {
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _typeof2 = __webpack_require__(40);
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = function () {
function isObject(val) {
if (val !== null && (typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val)) === 'object' && val.constructor !== Array) {
return true;
}
return false;
}
function toArray(val) {

@@ -1163,3 +1166,7 @@ return typeof val === 'string' ? [val] : val;

for (key in mainObj) {
data[key] = mainObj[key];
if (isObject(mainObj[key])) {
data[key] = extend(mainObj[key], {});
} else {
data[key] = mainObj[key];
}
}

@@ -1169,3 +1176,7 @@

for (key in appendObj[i]) {
data[key] = appendObj[i][key];
if (isObject(appendObj[i][key])) {
data[key] = extend(mainObj[key] || {}, [appendObj[i][key]]);
} else {
data[key] = appendObj[i][key];
}
}

@@ -1178,4 +1189,14 @@ }

function compare(one, two) {
var i, ii;
var i, ii, key;
if ((typeof one === 'undefined' ? 'undefined' : (0, _typeof3.default)(one)) === 'object' && (typeof two === 'undefined' ? 'undefined' : (0, _typeof3.default)(two)) === 'object') {
for (key in one) {
if (compare(one[key], two[key])) {
return true;
}
}
return false;
}
one = toArray(one);

@@ -1206,6 +1227,846 @@ two = toArray(two);

/* 40 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _iterator = __webpack_require__(41);
var _iterator2 = _interopRequireDefault(_iterator);
var _symbol = __webpack_require__(61);
var _symbol2 = _interopRequireDefault(_symbol);
var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default ? "symbol" : typeof obj; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
return typeof obj === "undefined" ? "undefined" : _typeof(obj);
} : function (obj) {
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
};
/***/ },
/* 41 */
/***/ function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(42), __esModule: true };
/***/ },
/* 42 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(43);
__webpack_require__(56);
module.exports = __webpack_require__(60).f('iterator');
/***/ },
/* 43 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var $at = __webpack_require__(44)(true);
// 21.1.3.27 String.prototype[@@iterator]()
__webpack_require__(45)(String, 'String', function(iterated){
this._t = String(iterated); // target
this._i = 0; // next index
// 21.1.5.2.1 %StringIteratorPrototype%.next()
}, function(){
var O = this._t
, index = this._i
, point;
if(index >= O.length)return {value: undefined, done: true};
point = $at(O, index);
this._i += point.length;
return {value: point, done: false};
});
/***/ },
/* 44 */
/***/ function(module, exports, __webpack_require__) {
var toInteger = __webpack_require__(30)
, defined = __webpack_require__(27);
// true -> String#at
// false -> String#codePointAt
module.exports = function(TO_STRING){
return function(that, pos){
var s = String(defined(that))
, i = toInteger(pos)
, l = s.length
, a, b;
if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
a = s.charCodeAt(i);
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
? TO_STRING ? s.charAt(i) : a
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
};
};
/***/ },
/* 45 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var LIBRARY = __webpack_require__(46)
, $export = __webpack_require__(5)
, redefine = __webpack_require__(47)
, hide = __webpack_require__(10)
, has = __webpack_require__(23)
, Iterators = __webpack_require__(48)
, $iterCreate = __webpack_require__(49)
, setToStringTag = __webpack_require__(52)
, getPrototypeOf = __webpack_require__(54)
, ITERATOR = __webpack_require__(53)('iterator')
, BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
, FF_ITERATOR = '@@iterator'
, KEYS = 'keys'
, VALUES = 'values';
var returnThis = function(){ return this; };
module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
$iterCreate(Constructor, NAME, next);
var getMethod = function(kind){
if(!BUGGY && kind in proto)return proto[kind];
switch(kind){
case KEYS: return function keys(){ return new Constructor(this, kind); };
case VALUES: return function values(){ return new Constructor(this, kind); };
} return function entries(){ return new Constructor(this, kind); };
};
var TAG = NAME + ' Iterator'
, DEF_VALUES = DEFAULT == VALUES
, VALUES_BUG = false
, proto = Base.prototype
, $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
, $default = $native || getMethod(DEFAULT)
, $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
, $anyNative = NAME == 'Array' ? proto.entries || $native : $native
, methods, key, IteratorPrototype;
// Fix native
if($anyNative){
IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
if(IteratorPrototype !== Object.prototype){
// Set @@toStringTag to native iterators
setToStringTag(IteratorPrototype, TAG, true);
// fix for some old engines
if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
}
}
// fix Array#{values, @@iterator}.name in V8 / FF
if(DEF_VALUES && $native && $native.name !== VALUES){
VALUES_BUG = true;
$default = function values(){ return $native.call(this); };
}
// Define iterator
if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
hide(proto, ITERATOR, $default);
}
// Plug for library
Iterators[NAME] = $default;
Iterators[TAG] = returnThis;
if(DEFAULT){
methods = {
values: DEF_VALUES ? $default : getMethod(VALUES),
keys: IS_SET ? $default : getMethod(KEYS),
entries: $entries
};
if(FORCED)for(key in methods){
if(!(key in proto))redefine(proto, key, methods[key]);
} else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
}
return methods;
};
/***/ },
/* 46 */
/***/ function(module, exports) {
module.exports = true;
/***/ },
/* 47 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(10);
/***/ },
/* 48 */
/***/ function(module, exports) {
module.exports = {};
/***/ },
/* 49 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var create = __webpack_require__(50)
, descriptor = __webpack_require__(19)
, setToStringTag = __webpack_require__(52)
, IteratorPrototype = {};
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
__webpack_require__(10)(IteratorPrototype, __webpack_require__(53)('iterator'), function(){ return this; });
module.exports = function(Constructor, NAME, next){
Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)});
setToStringTag(Constructor, NAME + ' Iterator');
};
/***/ },
/* 50 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
var anObject = __webpack_require__(12)
, dPs = __webpack_require__(20)
, enumBugKeys = __webpack_require__(35)
, IE_PROTO = __webpack_require__(32)('IE_PROTO')
, Empty = function(){ /* empty */ }
, PROTOTYPE = 'prototype';
// Create object with fake `null` prototype: use iframe Object with cleared prototype
var createDict = function(){
// Thrash, waste and sodomy: IE GC bug
var iframe = __webpack_require__(17)('iframe')
, i = enumBugKeys.length
, gt = '>'
, iframeDocument;
iframe.style.display = 'none';
__webpack_require__(51).appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write('<script>document.F=Object</script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
return createDict();
};
module.exports = Object.create || function create(O, Properties){
var result;
if(O !== null){
Empty[PROTOTYPE] = anObject(O);
result = new Empty;
Empty[PROTOTYPE] = null;
// add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = createDict();
return Properties === undefined ? result : dPs(result, Properties);
};
/***/ },
/* 51 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(6).document && document.documentElement;
/***/ },
/* 52 */
/***/ function(module, exports, __webpack_require__) {
var def = __webpack_require__(11).f
, has = __webpack_require__(23)
, TAG = __webpack_require__(53)('toStringTag');
module.exports = function(it, tag, stat){
if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});
};
/***/ },
/* 53 */
/***/ function(module, exports, __webpack_require__) {
var store = __webpack_require__(33)('wks')
, uid = __webpack_require__(34)
, Symbol = __webpack_require__(6).Symbol
, USE_SYMBOL = typeof Symbol == 'function';
var $exports = module.exports = function(name){
return store[name] || (store[name] =
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
};
$exports.store = store;
/***/ },
/* 54 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
var has = __webpack_require__(23)
, toObject = __webpack_require__(55)
, IE_PROTO = __webpack_require__(32)('IE_PROTO')
, ObjectProto = Object.prototype;
module.exports = Object.getPrototypeOf || function(O){
O = toObject(O);
if(has(O, IE_PROTO))return O[IE_PROTO];
if(typeof O.constructor == 'function' && O instanceof O.constructor){
return O.constructor.prototype;
} return O instanceof Object ? ObjectProto : null;
};
/***/ },
/* 55 */
/***/ function(module, exports, __webpack_require__) {
// 7.1.13 ToObject(argument)
var defined = __webpack_require__(27);
module.exports = function(it){
return Object(defined(it));
};
/***/ },
/* 56 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(57);
var global = __webpack_require__(6)
, hide = __webpack_require__(10)
, Iterators = __webpack_require__(48)
, TO_STRING_TAG = __webpack_require__(53)('toStringTag');
for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
var NAME = collections[i]
, Collection = global[NAME]
, proto = Collection && Collection.prototype;
if(proto && !proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
Iterators[NAME] = Iterators.Array;
}
/***/ },
/* 57 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var addToUnscopables = __webpack_require__(58)
, step = __webpack_require__(59)
, Iterators = __webpack_require__(48)
, toIObject = __webpack_require__(24);
// 22.1.3.4 Array.prototype.entries()
// 22.1.3.13 Array.prototype.keys()
// 22.1.3.29 Array.prototype.values()
// 22.1.3.30 Array.prototype[@@iterator]()
module.exports = __webpack_require__(45)(Array, 'Array', function(iterated, kind){
this._t = toIObject(iterated); // target
this._i = 0; // next index
this._k = kind; // kind
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
}, function(){
var O = this._t
, kind = this._k
, index = this._i++;
if(!O || index >= O.length){
this._t = undefined;
return step(1);
}
if(kind == 'keys' )return step(0, index);
if(kind == 'values')return step(0, O[index]);
return step(0, [index, O[index]]);
}, 'values');
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
Iterators.Arguments = Iterators.Array;
addToUnscopables('keys');
addToUnscopables('values');
addToUnscopables('entries');
/***/ },
/* 58 */
/***/ function(module, exports) {
module.exports = function(){ /* empty */ };
/***/ },
/* 59 */
/***/ function(module, exports) {
module.exports = function(done, value){
return {value: value, done: !!done};
};
/***/ },
/* 60 */
/***/ function(module, exports, __webpack_require__) {
exports.f = __webpack_require__(53);
/***/ },
/* 61 */
/***/ function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(62), __esModule: true };
/***/ },
/* 62 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(63);
__webpack_require__(74);
__webpack_require__(75);
__webpack_require__(76);
module.exports = __webpack_require__(7).Symbol;
/***/ },
/* 63 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
// ECMAScript 6 symbols shim
var global = __webpack_require__(6)
, has = __webpack_require__(23)
, DESCRIPTORS = __webpack_require__(15)
, $export = __webpack_require__(5)
, redefine = __webpack_require__(47)
, META = __webpack_require__(64).KEY
, $fails = __webpack_require__(16)
, shared = __webpack_require__(33)
, setToStringTag = __webpack_require__(52)
, uid = __webpack_require__(34)
, wks = __webpack_require__(53)
, wksExt = __webpack_require__(60)
, wksDefine = __webpack_require__(65)
, keyOf = __webpack_require__(66)
, enumKeys = __webpack_require__(67)
, isArray = __webpack_require__(70)
, anObject = __webpack_require__(12)
, toIObject = __webpack_require__(24)
, toPrimitive = __webpack_require__(18)
, createDesc = __webpack_require__(19)
, _create = __webpack_require__(50)
, gOPNExt = __webpack_require__(71)
, $GOPD = __webpack_require__(73)
, $DP = __webpack_require__(11)
, $keys = __webpack_require__(21)
, gOPD = $GOPD.f
, dP = $DP.f
, gOPN = gOPNExt.f
, $Symbol = global.Symbol
, $JSON = global.JSON
, _stringify = $JSON && $JSON.stringify
, PROTOTYPE = 'prototype'
, HIDDEN = wks('_hidden')
, TO_PRIMITIVE = wks('toPrimitive')
, isEnum = {}.propertyIsEnumerable
, SymbolRegistry = shared('symbol-registry')
, AllSymbols = shared('symbols')
, OPSymbols = shared('op-symbols')
, ObjectProto = Object[PROTOTYPE]
, USE_NATIVE = typeof $Symbol == 'function'
, QObject = global.QObject;
// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
var setSymbolDesc = DESCRIPTORS && $fails(function(){
return _create(dP({}, 'a', {
get: function(){ return dP(this, 'a', {value: 7}).a; }
})).a != 7;
}) ? function(it, key, D){
var protoDesc = gOPD(ObjectProto, key);
if(protoDesc)delete ObjectProto[key];
dP(it, key, D);
if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc);
} : dP;
var wrap = function(tag){
var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
sym._k = tag;
return sym;
};
var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){
return typeof it == 'symbol';
} : function(it){
return it instanceof $Symbol;
};
var $defineProperty = function defineProperty(it, key, D){
if(it === ObjectProto)$defineProperty(OPSymbols, key, D);
anObject(it);
key = toPrimitive(key, true);
anObject(D);
if(has(AllSymbols, key)){
if(!D.enumerable){
if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {}));
it[HIDDEN][key] = true;
} else {
if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
D = _create(D, {enumerable: createDesc(0, false)});
} return setSymbolDesc(it, key, D);
} return dP(it, key, D);
};
var $defineProperties = function defineProperties(it, P){
anObject(it);
var keys = enumKeys(P = toIObject(P))
, i = 0
, l = keys.length
, key;
while(l > i)$defineProperty(it, key = keys[i++], P[key]);
return it;
};
var $create = function create(it, P){
return P === undefined ? _create(it) : $defineProperties(_create(it), P);
};
var $propertyIsEnumerable = function propertyIsEnumerable(key){
var E = isEnum.call(this, key = toPrimitive(key, true));
if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false;
return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
};
var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){
it = toIObject(it);
key = toPrimitive(key, true);
if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return;
var D = gOPD(it, key);
if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
return D;
};
var $getOwnPropertyNames = function getOwnPropertyNames(it){
var names = gOPN(toIObject(it))
, result = []
, i = 0
, key;
while(names.length > i){
if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key);
} return result;
};
var $getOwnPropertySymbols = function getOwnPropertySymbols(it){
var IS_OP = it === ObjectProto
, names = gOPN(IS_OP ? OPSymbols : toIObject(it))
, result = []
, i = 0
, key;
while(names.length > i){
if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]);
} return result;
};
// 19.4.1.1 Symbol([description])
if(!USE_NATIVE){
$Symbol = function Symbol(){
if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!');
var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
var $set = function(value){
if(this === ObjectProto)$set.call(OPSymbols, value);
if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
setSymbolDesc(this, tag, createDesc(1, value));
};
if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set});
return wrap(tag);
};
redefine($Symbol[PROTOTYPE], 'toString', function toString(){
return this._k;
});
$GOPD.f = $getOwnPropertyDescriptor;
$DP.f = $defineProperty;
__webpack_require__(72).f = gOPNExt.f = $getOwnPropertyNames;
__webpack_require__(69).f = $propertyIsEnumerable;
__webpack_require__(68).f = $getOwnPropertySymbols;
if(DESCRIPTORS && !__webpack_require__(46)){
redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
}
wksExt.f = function(name){
return wrap(wks(name));
}
}
$export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol});
for(var symbols = (
// 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
).split(','), i = 0; symbols.length > i; )wks(symbols[i++]);
for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]);
$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
// 19.4.2.1 Symbol.for(key)
'for': function(key){
return has(SymbolRegistry, key += '')
? SymbolRegistry[key]
: SymbolRegistry[key] = $Symbol(key);
},
// 19.4.2.5 Symbol.keyFor(sym)
keyFor: function keyFor(key){
if(isSymbol(key))return keyOf(SymbolRegistry, key);
throw TypeError(key + ' is not a symbol!');
},
useSetter: function(){ setter = true; },
useSimple: function(){ setter = false; }
});
$export($export.S + $export.F * !USE_NATIVE, 'Object', {
// 19.1.2.2 Object.create(O [, Properties])
create: $create,
// 19.1.2.4 Object.defineProperty(O, P, Attributes)
defineProperty: $defineProperty,
// 19.1.2.3 Object.defineProperties(O, Properties)
defineProperties: $defineProperties,
// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
// 19.1.2.7 Object.getOwnPropertyNames(O)
getOwnPropertyNames: $getOwnPropertyNames,
// 19.1.2.8 Object.getOwnPropertySymbols(O)
getOwnPropertySymbols: $getOwnPropertySymbols
});
// 24.3.2 JSON.stringify(value [, replacer [, space]])
$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function(){
var S = $Symbol();
// MS Edge converts symbol values to JSON as {}
// WebKit converts symbol values to JSON as null
// V8 throws on boxed symbols
return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}';
})), 'JSON', {
stringify: function stringify(it){
if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined
var args = [it]
, i = 1
, replacer, $replacer;
while(arguments.length > i)args.push(arguments[i++]);
replacer = args[1];
if(typeof replacer == 'function')$replacer = replacer;
if($replacer || !isArray(replacer))replacer = function(key, value){
if($replacer)value = $replacer.call(this, key, value);
if(!isSymbol(value))return value;
};
args[1] = replacer;
return _stringify.apply($JSON, args);
}
});
// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
$Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(10)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
// 19.4.3.5 Symbol.prototype[@@toStringTag]
setToStringTag($Symbol, 'Symbol');
// 20.2.1.9 Math[@@toStringTag]
setToStringTag(Math, 'Math', true);
// 24.3.3 JSON[@@toStringTag]
setToStringTag(global.JSON, 'JSON', true);
/***/ },
/* 64 */
/***/ function(module, exports, __webpack_require__) {
var META = __webpack_require__(34)('meta')
, isObject = __webpack_require__(13)
, has = __webpack_require__(23)
, setDesc = __webpack_require__(11).f
, id = 0;
var isExtensible = Object.isExtensible || function(){
return true;
};
var FREEZE = !__webpack_require__(16)(function(){
return isExtensible(Object.preventExtensions({}));
});
var setMeta = function(it){
setDesc(it, META, {value: {
i: 'O' + ++id, // object ID
w: {} // weak collections IDs
}});
};
var fastKey = function(it, create){
// return primitive with prefix
if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
if(!has(it, META)){
// can't set metadata to uncaught frozen object
if(!isExtensible(it))return 'F';
// not necessary to add metadata
if(!create)return 'E';
// add missing metadata
setMeta(it);
// return object ID
} return it[META].i;
};
var getWeak = function(it, create){
if(!has(it, META)){
// can't set metadata to uncaught frozen object
if(!isExtensible(it))return true;
// not necessary to add metadata
if(!create)return false;
// add missing metadata
setMeta(it);
// return hash weak collections IDs
} return it[META].w;
};
// add metadata on freeze-family methods calling
var onFreeze = function(it){
if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it);
return it;
};
var meta = module.exports = {
KEY: META,
NEED: false,
fastKey: fastKey,
getWeak: getWeak,
onFreeze: onFreeze
};
/***/ },
/* 65 */
/***/ function(module, exports, __webpack_require__) {
var global = __webpack_require__(6)
, core = __webpack_require__(7)
, LIBRARY = __webpack_require__(46)
, wksExt = __webpack_require__(60)
, defineProperty = __webpack_require__(11).f;
module.exports = function(name){
var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)});
};
/***/ },
/* 66 */
/***/ function(module, exports, __webpack_require__) {
var getKeys = __webpack_require__(21)
, toIObject = __webpack_require__(24);
module.exports = function(object, el){
var O = toIObject(object)
, keys = getKeys(O)
, length = keys.length
, index = 0
, key;
while(length > index)if(O[key = keys[index++]] === el)return key;
};
/***/ },
/* 67 */
/***/ function(module, exports, __webpack_require__) {
// all enumerable object keys, includes symbols
var getKeys = __webpack_require__(21)
, gOPS = __webpack_require__(68)
, pIE = __webpack_require__(69);
module.exports = function(it){
var result = getKeys(it)
, getSymbols = gOPS.f;
if(getSymbols){
var symbols = getSymbols(it)
, isEnum = pIE.f
, i = 0
, key;
while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key);
} return result;
};
/***/ },
/* 68 */
/***/ function(module, exports) {
exports.f = Object.getOwnPropertySymbols;
/***/ },
/* 69 */
/***/ function(module, exports) {
exports.f = {}.propertyIsEnumerable;
/***/ },
/* 70 */
/***/ function(module, exports, __webpack_require__) {
// 7.2.2 IsArray(argument)
var cof = __webpack_require__(26);
module.exports = Array.isArray || function isArray(arg){
return cof(arg) == 'Array';
};
/***/ },
/* 71 */
/***/ function(module, exports, __webpack_require__) {
// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
var toIObject = __webpack_require__(24)
, gOPN = __webpack_require__(72).f
, toString = {}.toString;
var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
? Object.getOwnPropertyNames(window) : [];
var getWindowNames = function(it){
try {
return gOPN(it);
} catch(e){
return windowNames.slice();
}
};
module.exports.f = function getOwnPropertyNames(it){
return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
};
/***/ },
/* 72 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
var $keys = __webpack_require__(22)
, hiddenKeys = __webpack_require__(35).concat('length', 'prototype');
exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){
return $keys(O, hiddenKeys);
};
/***/ },
/* 73 */
/***/ function(module, exports, __webpack_require__) {
var pIE = __webpack_require__(69)
, createDesc = __webpack_require__(19)
, toIObject = __webpack_require__(24)
, toPrimitive = __webpack_require__(18)
, has = __webpack_require__(23)
, IE8_DOM_DEFINE = __webpack_require__(14)
, gOPD = Object.getOwnPropertyDescriptor;
exports.f = __webpack_require__(15) ? gOPD : function getOwnPropertyDescriptor(O, P){
O = toIObject(O);
P = toPrimitive(P, true);
if(IE8_DOM_DEFINE)try {
return gOPD(O, P);
} catch(e){ /* empty */ }
if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]);
};
/***/ },
/* 74 */
/***/ function(module, exports) {
/***/ },
/* 75 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(65)('asyncIterator');
/***/ },
/* 76 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(65)('observable');
/***/ },
/* 77 */
/***/ function(module, exports) {
'use strict';
module.exports = function () {

@@ -1244,2 +2105,6 @@

localStorage.removeItem(name);
},
expiring: function expiring() {
return false;
}

@@ -1250,3 +2115,3 @@ };

/***/ },
/* 41 */
/* 78 */
/***/ function(module, exports) {

@@ -1280,125 +2145,3 @@

/***/ },
/* 42 */
/***/ function(module, exports) {
"use strict";
module.exports = {
// NOTE: Use underscore to denote a driver function (all are overrideable also).
_init: function _init() {
this.options._bind.call(this);
this.options._beforeEach.call(this, this.options.routerBeforeEach, this.options.transitionEach);
this.options._interceptor.call(this, this.options.requestIntercept, this.options.responseIntercept);
},
_bind: function _bind() {
this.options.http = this.options.http || this.options.Vue.http;
this.options.router = this.options.router || this.options.Vue.router;
},
_watch: function _watch(_data) {
return new this.options.Vue({
data: function data() {
return _data;
}
});
},
_getHeaders: function _getHeaders(res) {
return {
token: res.headers[this.options.tokenHeader]
};
},
_setHeaders: function _setHeaders(req, headers) {
if (headers.authorization) {
req.headers[this.options.tokenHeader] = headers.authorization;
}
},
_getQuery: function _getQuery() {
// return this.$route.query.state
return {};
},
_bindData: function _bindData(data, ctx) {
var error, success;
data = data || {};
error = data.error;
success = data.success;
if (data.success) {
data.success = function (res) {
success.call(ctx, res);
};
}
if (data.error) {
data.error = function (res) {
error.call(ctx, res);
};
}
return data;
},
_interceptor: function _interceptor(req, res) {
var _this = this;
this.options.http.interceptors.push(function (request, next) {
if (req) {
req.call(_this, request);
}
next(function (response) {
if (res) {
res.call(_this, response);
}
});
});
},
_beforeEach: function _beforeEach(routerBeforeEach, transitionEach) {
var _this = this;
this.options.router.beforeEach(function (transition) {
routerBeforeEach.call(_this, function () {
transitionEach.call(_this, transition.to.auth, function () {
transition.next();
});
});
});
},
_invalidToken: function _invalidToken(res) {
if (res.status === 401) {
this.logout();
}
},
_routerReplace: function _routerReplace(data) {
this.options.router.replace(data);
},
_routerGo: function _routerGo(data) {
this.options.router.go(data);
},
_httpData: function _httpData(res) {
return res.json();
},
_http: function _http(data) {
this.options.http(data).then(data.success, data.error);
}
};
/***/ }
/******/ ]);

4

package.json

@@ -17,3 +17,3 @@ {

"version": "2.2.0-beta",
"version": "2.2.1-beta",

@@ -28,3 +28,3 @@ "repository": {

"dependencies": {
"@websanova/vue-auth": "2.2.0-beta"
"@websanova/vue-auth": "2.2.1-beta"
},

@@ -31,0 +31,0 @@

@@ -9,2 +9,3 @@ # Vue Auth

* [Demo](https://github.com/websanova/vue-auth#demo)
* [Auth Flow](https://github.com/websanova/vue-auth#auth-flow)
* [User Data](https://github.com/websanova/vue-auth#user-data)

@@ -55,4 +56,4 @@ * [Authentication](https://github.com/websanova/vue-auth#authentication)

auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
http: require('@websanova/vue-auth/drivers/http/resource.1.x.js'),
router: require('@websanova/vue-auth/drivers/router/router.2.x.js'),
http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'),
router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
...

@@ -123,2 +124,26 @@ rolesVar: 'type'

## Auth Flow
The best way to see the code in action is to see the code samples in the `1.x.demo` and `2.x.demo` folders. However it still helps to understand what exactly the workflow is.
* The plugin has two sets of interceptors. One for routing and one for http requests.
### Routing
* From the front end we can't really do any "real" authentication. It's simply a check to see it users role and the routes roles match up. From there we can allow the route to process or we can redirect accordingly.
* This is done by intercepting each route and checking if the user is already logged in. This is done by simply checking if a token exists.
* If a token exists a few things can happen. But by default there will be two requests sent. One is to refresh the token (this is based on best practice). Second is to fetch the user.
* Typically a user will be fetched each time to make sure we have the latest user data.
* After the user is fetched the plugin will process into a "loaded" state. This should be checked via the "$auth.ready()" method. At this point we will know if we have a valid token and user.
* From here we can use the `$auth.check()` function to show hide various parts of our interface.
### HTTP
* The http part is much simpler. Essentially the plugin will automatically parse some authentication data (based on driver) into each request the app makes.
* This parsing will be done on each `request` and `response` of your http (ajax) calls.
* For the request it will simply append the auth data in the header or body (depending on your auth driver).
* For the response it will parse the auth data from the header or response data (depending on your auth driver).
## User Data

@@ -671,27 +696,34 @@

These are all function related directly to Vue that sort of acts like a driver. It makes it easier to deal with incompatibilities between Vue versions.
These are driver methods for `router`, `http` and `auth`. If creating a driver it's best to check some of the existing files for samples.
* `_init`
* `_bind`
* `_watch`
* `_getHeaders`
* `_setHeaders`
### Router
* `_bindData`
* `_interceptor`
* `_beforeEach`
* `_invalidToken`
* `_routerReplace`
* `_routerGo`
### Http
* `_interceptor`
* `_invalidToken`
* `_httpData`
* `_http`
* `_getHeaders`
* `_setHeaders`
### Auth
* `request`
* `response`
## Change Log
### v2.0.x-beta
### v2.2.x-beta
Vue has been in such a volatile state, especially between versions and 1 and 2. There have been many breaking changes as well as [removing vue-resource as the officially recommended package](https://medium.com/the-vue-point/retiring-vue-resource-871a82880af4) for Vue.
Because of all these changes and potential breaking changes the package has been changed to a much more driver centric model for "router", "resource" and "authentication" . Due to the nature of Vue and the current eco-system with Webpack, to avoid bloat this means the drivers will need to be passed in manually.
Because of all these changes and potential breaking changes the package has been changed to a much more driver centric model for "router", "resource" and "authentication" . Due to the nature of Vue and the current eco-system with Webpack, to avoid bloat **this means the drivers will need to be passed in manually**. Check the install section for more info.

@@ -698,0 +730,0 @@ We will see some ugly `require` code when including the plugin. But as a trade off it will reduce bloat and allow the plugin to much better support different versions of Vue as well as different "router", "resource" and "authentication" modules.

@@ -12,3 +12,3 @@ module.exports = (function (){

function toArray(val) {
return (typeof val) === 'string' ? [val] : val;
return (typeof val) === 'string' || (typeof val) === 'number' ? [val] : val;
}

@@ -45,3 +45,3 @@

if (typeof one === 'object' && typeof two === 'object') {
if (Object.prototype.toString.call(one) === '[object Object]' && Object.prototype.toString.call(two) === '[object Object]') {
for (key in one) {

@@ -77,2 +77,2 @@ if (compare(one[key], two[key])) {

};
})();
})();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc