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 4.0.1 to 4.0.2

2

dist/drivers/auth/basic.common.js
/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -810,2 +810,8 @@ * Released under the MIT License.

if (registerData.autoLogin !== true) {
_setRemember(registerData.remember);
_setStaySignedIn(registerData.staySignedIn);
}
return new Promise(function (resolve, reject) {

@@ -812,0 +818,0 @@ __auth.drivers.http.http.call(__auth, registerData).then(function (res) {

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -808,2 +808,8 @@ * Released under the MIT License.

if (registerData.autoLogin !== true) {
_setRemember(registerData.remember);
_setStaySignedIn(registerData.staySignedIn);
}
return new Promise(function (resolve, reject) {

@@ -810,0 +816,0 @@ __auth.drivers.http.http.call(__auth, registerData).then(function (res) {

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -814,2 +814,8 @@ * Released under the MIT License.

if (registerData.autoLogin !== true) {
_setRemember(registerData.remember);
_setStaySignedIn(registerData.staySignedIn);
}
return new Promise(function (resolve, reject) {

@@ -816,0 +822,0 @@ __auth.drivers.http.http.call(__auth, registerData).then(function (res) {

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -7,2 +7,2 @@ * Released under the MIT License.

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueAuth=e()}(this,function(){"use strict";function a(t){return null!==t&&"object"==typeof t&&t.constructor!==Array}function s(t){return"string"==typeof t||"number"==typeof t?[t]:t}function c(t,e){var r,n,o,i={};for(o in e=e||{},t)a(t[o])&&"FormData"!==t[o].constructor.name?i[o]=c(t[o],{}):i[o]=t[o];for(e.constructor!==Array&&(e=[e]),r=0,n=e.length;r<n;r++)for(o in e[r])a(e[r][o])&&"FormData"!==e[r][o].constructor.name?i[o]=c(t[o]||{},[e[r][o]]):i[o]=e[r][o];return i}function u(t,e){var r,n,o;if("[object Object]"===Object.prototype.toString.call(t)&&"[object Object]"===Object.prototype.toString.call(e)){for(o in t)if(u(t[o],e[o]))return!0;return!1}if(t=s(t),e=s(e),!t||!e||t.constructor!==Array||e.constructor!==Array)return!1;for(r=0,n=t.length;r<n;r++)if(0<=e.indexOf(t[r]))return!0;return!1}function o(t,e,r){var n,o=t+"="+e+";";for(n in r)!1!==r[n]&&void 0!==r[n]&&(null===r[n]?this.options["getCookie"+n]&&(o+=" "+n+"="+this.options["getCookie"+n]()+";"):!0===r[n]?o+=" "+n+";":o+=" "+n+"="+r[n]+";");document.cookie=o}function i(t){return"string"!=typeof t&&null!=t?new Date((new Date).getTime()+t).toUTCString():t}function e(t){var e=Object.assign({},this.options.cookie);e.Expires=i(-12096e5),o.call(this,t,"",e)}var l=Object.freeze({get:function(t){for(var e=document.cookie,r=0,n=(e=e.replace(/;\s+/g,";").split(";").map(function(t){return t.replace(/\s+=\s+/g,"=").split("=")})).length;r<n;r++)if(e[r][0]&&e[r][0]===t)return e[r][1];return null},set:function(t,e,r){var n=this.options.cookie;n.Expires=!0===r?"":i(n.Expires),o.call(this,t,e,n)},remove:e});var p=Object.freeze({get:function(t){return sessionStorage.getItem(t)||localStorage.getItem(t)},set:function(t,e,r){r?sessionStorage.setItem(t,e):localStorage.setItem(t,e)},remove:function(t){localStorage.removeItem(t),sessionStorage.removeItem(t)}});function n(t,e,r,n){var o=0,i=this.options.stores,a=i.length,s=[function(t){return(t=t||this.currentToken)||(this.impersonating()?this.options.tokenImpersonateKey:this.options.tokenDefaultKey)}.call(this,e)];for("set"===t&&(s.push(r),s.push(!0===n));o<a;o++){if("storage"===i[o]&&function(){try{if(!window.localStorage)throw"exception";return localStorage.setItem("storage_test",1),localStorage.removeItem("storage_test"),1}catch(t){return}}()&&function(){try{if(!window.sessionStorage)throw"exception";return sessionStorage.setItem("storage_test",1),sessionStorage.removeItem("storage_test"),1}catch(t){return}}())return p[t].apply(this,s);if("cookie"===i[o])return l[t].apply(this,s)}}function d(t){return n.call(this,"get",t)}function f(t,e,r){return n.call(this,"set",t,e,r)}function h(t){return n.call(this,"remove",t)}var m=null,v={rolesKey:"roles",rememberKey:"auth_remember",staySignedInKey:"auth_stay_signed_in",tokenDefaultKey:"auth_token_default",tokenImpersonateKey:"auth_token_impersonate",stores:["storage","cookie"],cookie:{Path:"/",Domain:null,Secure:!0,Expires:12096e5,SameSite:"None"},authRedirect:{path:"/login"},forbiddenRedirect:{path:"/403"},notFoundRedirect:{path:"/404"},registerData:{url:"auth/register",method:"POST",redirect:"/login",autoLogin:!1},loginData:{url:"auth/login",method:"POST",redirect:"/",fetchUser:!0,staySignedIn:!0},logoutData:{url:"auth/logout",method:"POST",redirect:"/",makeRequest:!1},fetchData:{url:"auth/user",method:"GET",enabled:!0},refreshData:{url:"auth/refresh",method:"GET",enabled:!0,interval:30},impersonateData:{url:"auth/impersonate",method:"POST",redirect:"/",fetchUser:!0},unimpersonateData:{url:"auth/unimpersonate",method:"POST",redirect:"/admin",fetchUser:!0,makeRequest:!1},oauth2Data:{url:"auth/social",method:"POST",redirect:"/",fetchUser:!0},getUrl:b,getCookieDomain:function(){return window.location.hostname},parseUserData:function(t){return t.data||{}}};function t(t,e){return!0===m.$vm.state.authenticated&&(!t||u(t,function(t,e){var r=e.split(".");for(0;r.length;)t=t[r.shift()];return t}(m.$vm.state.data||{},e||m.options.rolesKey)))}function y(){return!d.call(m)}function g(t){var e,r;return t.to?e=t.to.auth:(r=t.matched.filter(function(t){return Object.prototype.hasOwnProperty.call(t.meta,"auth")})).length&&(e=r[r.length-1].meta.auth),e}function b(){var t=window.location.port;return window.location.protocol+"//"+window.location.hostname+(t?":"+t:"")}function k(t){m.$vm.state.loaded=!0,m.$vm.state.authenticated=t}function r(t){t?(f.call(m,m.options.rememberKey,t,!1),m.$vm.state.remember=t):(h.call(m,m.options.rememberKey),m.$vm.state.remember=null)}function D(t){m.transitionPrev=m.transitionThis,m.transitionThis=t}function w(t){return m.options.parseUserData(m.drivers.http.httpData(t))}function S(t){var e,r;return t&&t.ignoreVueAuth||(!1===t.impersonating&&m.impersonating()&&(r=m.options.tokenDefaultKey),(e=d.call(m,r))&&m.drivers.auth.request.call(m,t,e)),t}function I(t,e){var r;e&&e.ignoreVueAuth||(function(t,e){var r,n,o="",i=e&&e.path;if(i&&e.query){for(r in e.query)e.query[r]&&(o+="&"+r+"="+e.query[r]);i+="?"+o.substring(1)}if(!m.drivers.http.invalidToken||!m.drivers.http.invalidToken.call(m,t))return;e&&(n=g(e));n&&(i=n.redirect||m.options.authRedirect);P({redirect:i})}(t,m.transitionThis),(r=m.drivers.auth.response.call(m,t))&&f.call(m,null,r,!d.call(m,m.options.staySignedInKey)))}function T(t){var e=y();e&&m.$vm.state.authenticated&&P(),e||m.$vm.state.loaded||!m.options.refreshData.enabled?$(t):m.refresh().then(function(){$(t)})}function $(t){return null===m.$vm.state.authenticated&&d.call(m)?m.options.fetchData.enabled?void m.fetch().then(t,t):(R({}),t.call(m)):(m.$vm.state.loaded=!0,t.call(m))}function K(t,e,r){var n=(e||"").redirect||m.options.authRedirect,o=(e||"").forbiddenRedirect||(e||"").redirect||m.options.forbiddenRedirect,i=(e||"").notFoundRedirect||(e||"").redirect||m.options.notFoundRedirect;if((e=s(void 0!==(e||"").roles?e.roles:e))&&(!0===e||e.constructor===Array||a(e)))if(m.check()){if(e.constructor!==Array&&!a(e)||u(e,m.$vm.state.data[m.options.rolesKey]))return m.$vm.state.redirect=m.transitionRedirectType?{type:m.transitionRedirectType,from:m.transitionPrev,to:m.transitionThis}:null,m.transitionRedirectType=null,r();m.transitionRedirectType=403,"function"==typeof o&&(o=o(t)),r.call(m,o)}else m.transitionRedirectType=401,"function"==typeof n&&(n=n(t)),r.call(m,n);else{if(!1!==e||!m.check())return m.$vm.state.redirect=m.transitionRedirectType?{type:m.transitionRedirectType,from:m.transitionPrev,to:m.transitionThis}:null,m.transitionRedirectType=null,r();m.transitionRedirectType=404,"function"==typeof i&&(i=i(t)),r.call(m,i)}}function R(t,e){var r;r=t,m.$vm.state.data=r,k(!0),O(e)}function P(t){e.call(m,m.options.tokenImpersonateKey),e.call(m,m.options.tokenDefaultKey),h.call(m,m.options.tokenImpersonateKey),h.call(m,m.options.tokenDefaultKey),h.call(m,m.options.staySignedInKey),m.$vm.state.loaded=!0,m.$vm.state.authenticated=!1,m.$vm.state.data=null,O(t)}function O(t){t&&m.drivers.router.routerGo.call(m,t)}function U(t,e){var r;e=e||{},(m=this).plugins=e.plugins,this.drivers=e.drivers,this.options=c(v,e.options),delete e.plugins,delete e.drivers,delete e.options,this.currentToken=null,this.transitionPrev=null,this.transitionThis=null,this.transitionRedirectType=null,function(){for(var t=["auth","http","router"],e=0,r=t.length;e<r;e++){if(!m.drivers[t[e]])return console.error('Error (@websanova/vue-auth): "'+t[e]+'" driver must be set.');if(m.drivers[t[e]]._init&&(msg=m.drivers[t[e]]._init.call(m),msg))return console.error("Error (@websanova/vue-auth): "+msg)}}(),r=t,m.$vm=new r({data:function(){return{state:{data:null,loaded:!1,redirect:null,authenticated:null,impersonating:void 0,remember:void 0}}}}),m.options.refreshData.enabled&&0<m.options.refreshData.interval&&setInterval(function(){m.options.refreshData.enabled&&!y()&&m.refresh()},1e3*m.options.refreshData.interval*60),m.drivers.http.interceptor.call(m,S,I),m.drivers.router.beforeEach.call(m,T,K,D,g)}function _(t,e){t.auth=new U(t,e),Object.defineProperties(t.prototype,{$auth:{get:function(){return t.auth}}})}return U.prototype.ready=function(){return m.$vm.state.loaded},U.prototype.load=function(){return new Promise(function(t){var e=null,e=setInterval(function(){m.$vm.state.loaded&&(clearInterval(e),t())},50)})},U.prototype.redirect=function(){return m.$vm.state.redirect},U.prototype.user=function(t){return void 0!==t&&R(t),m.$vm.state.data},U.prototype.check=t,U.prototype.impersonating=function(){var t=!!d.call(m,m.options.tokenImpersonateKey);return void 0===m.$vm.state.impersonating&&(m.$vm.state.impersonating=t),m.$vm.state.impersonating},U.prototype.token=function(t,e,r){return void 0!==e&&(null===e?h.call(m,t):(r=!0===r||!1===r?r:!d.call(m,m.options.staySignedInKey),f.call(m,t,e,r))),d.call(m,t)},U.prototype.fetch=function(r){return r=c(m.options.fetchData,r),new Promise(function(e,t){m.drivers.http.http.call(m,r).then(function(t){R(w(t),r.redirect),e(t)},t)})},U.prototype.refresh=function(t){return t=c(m.options.refreshData,t),m.drivers.http.http.call(m,t)},U.prototype.register=function(o){var i=c(m.options.registerData,o);return new Promise(function(r,n){m.drivers.http.http.call(m,i).then(function(t){var e;i.autoLogin?(e=c(m.options.loginData,o),m.login(e).then(r,n)):(r(t),O(i.redirect))},n)})},U.prototype.login=function(n){return r((n=c(m.options.loginData,n)).remember),!0===n.staySignedIn?f.call(m,m.options.staySignedInKey,"true",!1):h.call(m,m.options.staySignedInKey),new Promise(function(e,r){m.drivers.http.http.call(m,n).then(function(t){n.fetchUser||void 0===n.fetchUser&&m.options.fetchData.enabled?m.fetch({redirect:n.redirect}).then(e,r):(R(w(t),n.redirect),e(t))},function(t){k(!1),r(t)})})},U.prototype.remember=function(t){t&&r(t);var e=d.call(m,m.options.rememberKey);return void 0===m.$vm.state.remember&&(m.$vm.state.remember=e),m.$vm.state.remember},U.prototype.unremember=function(){r(null)},U.prototype.logout=function(r){return r=c(m.options.logoutData,r),new Promise(function(e,t){r.makeRequest?m.drivers.http.http.call(m,r).then(function(t){P(r.redirect),e(t)},t):(P(r.redirect),e())})},U.prototype.impersonate=function(a){return a=c(m.options.impersonateData,a),new Promise(function(n,o){var i=m.token();m.drivers.http.http.call(m,a).then(function(t){var e,r;e=i,f.call(m,m.options.tokenImpersonateKey,m.token(),!d.call(m,m.options.staySignedInKey)),f.call(m,m.options.tokenDefaultKey,e,!d.call(m,m.options.staySignedInKey)),m.$vm.state.impersonating=!0,O(r),a.fetchUser||void 0===a.fetchUser&&m.options.fetchData.enabled?m.fetch({redirect:a.redirect}).then(n,o):(O(a.redirect),n(t))},o)})},U.prototype.unimpersonate=function(r){return r=c(m.options.unimpersonateData,r),new Promise(function(t,e){r.makeRequest?m.drivers.http.http.call(m,r).then(t,e):t()}).then(function(){return new Promise(function(t,e){h.call(m,m.options.tokenImpersonateKey),m.$vm.state.impersonating=!1,O(void 0),r.fetchUser||void 0===r.fetchUser&&m.options.fetchData.enabled?m.fetch({redirect:r.redirect}).then(t,e):(O(r.redirect),t())})})},U.prototype.oauth2=function(t,e){var r,n,o="";if(e.code){try{e.state&&(e.state=JSON.parse(decodeURIComponent(e.state)))}catch(t){console.error("vue-auth:error There was an issue retrieving the state data."),e.state=e.state||{}}return delete(e=c(m.options.oauth2Data,[e.state,e])).code,delete e.state,delete e.params,m.login(e)}for(r in(e=c(m.drivers.oauth2[t],e)).params.state=JSON.stringify(e.params.state||{}),e.params.redirect_uri=(n=e.params.redirect_uri,/^https?:\/\//.test(n=n||"")?n:b()+"/"+n.replace(/^\/|\/$/g,"")),e.params)o+="&"+r+"="+encodeURIComponent(e.params[r]);window.location=e.url+"?"+o.substring()},U.prototype.enableImpersonate=function(){m.impersonating()&&(m.currentToken=null)},U.prototype.disableImpersonate=function(){m.impersonating()&&(m.currentToken=m.options.tokenDefaultKey)},"undefined"!=typeof window&&window.Vue&&window.Vue.use(_),_});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueAuth=e()}(this,function(){"use strict";function a(t){return null!==t&&"object"==typeof t&&t.constructor!==Array}function s(t){return"string"==typeof t||"number"==typeof t?[t]:t}function c(t,e){var r,n,o,i={};for(o in e=e||{},t)a(t[o])&&"FormData"!==t[o].constructor.name?i[o]=c(t[o],{}):i[o]=t[o];for(e.constructor!==Array&&(e=[e]),r=0,n=e.length;r<n;r++)for(o in e[r])a(e[r][o])&&"FormData"!==e[r][o].constructor.name?i[o]=c(t[o]||{},[e[r][o]]):i[o]=e[r][o];return i}function u(t,e){var r,n,o;if("[object Object]"===Object.prototype.toString.call(t)&&"[object Object]"===Object.prototype.toString.call(e)){for(o in t)if(u(t[o],e[o]))return!0;return!1}if(t=s(t),e=s(e),!t||!e||t.constructor!==Array||e.constructor!==Array)return!1;for(r=0,n=t.length;r<n;r++)if(0<=e.indexOf(t[r]))return!0;return!1}function o(t,e,r){var n,o=t+"="+e+";";for(n in r)!1!==r[n]&&void 0!==r[n]&&(null===r[n]?this.options["getCookie"+n]&&(o+=" "+n+"="+this.options["getCookie"+n]()+";"):!0===r[n]?o+=" "+n+";":o+=" "+n+"="+r[n]+";");document.cookie=o}function i(t){return"string"!=typeof t&&null!=t?new Date((new Date).getTime()+t).toUTCString():t}function e(t){var e=Object.assign({},this.options.cookie);e.Expires=i(-12096e5),o.call(this,t,"",e)}var l=Object.freeze({get:function(t){for(var e=document.cookie,r=0,n=(e=e.replace(/;\s+/g,";").split(";").map(function(t){return t.replace(/\s+=\s+/g,"=").split("=")})).length;r<n;r++)if(e[r][0]&&e[r][0]===t)return e[r][1];return null},set:function(t,e,r){var n=this.options.cookie;n.Expires=!0===r?"":i(n.Expires),o.call(this,t,e,n)},remove:e});var p=Object.freeze({get:function(t){return sessionStorage.getItem(t)||localStorage.getItem(t)},set:function(t,e,r){r?sessionStorage.setItem(t,e):localStorage.setItem(t,e)},remove:function(t){localStorage.removeItem(t),sessionStorage.removeItem(t)}});function n(t,e,r,n){var o=0,i=this.options.stores,a=i.length,s=[function(t){return(t=t||this.currentToken)||(this.impersonating()?this.options.tokenImpersonateKey:this.options.tokenDefaultKey)}.call(this,e)];for("set"===t&&(s.push(r),s.push(!0===n));o<a;o++){if("storage"===i[o]&&function(){try{if(!window.localStorage)throw"exception";return localStorage.setItem("storage_test",1),localStorage.removeItem("storage_test"),1}catch(t){return}}()&&function(){try{if(!window.sessionStorage)throw"exception";return sessionStorage.setItem("storage_test",1),sessionStorage.removeItem("storage_test"),1}catch(t){return}}())return p[t].apply(this,s);if("cookie"===i[o])return l[t].apply(this,s)}}function d(t){return n.call(this,"get",t)}function f(t,e,r){return n.call(this,"set",t,e,r)}function h(t){return n.call(this,"remove",t)}var m=null,v={rolesKey:"roles",rememberKey:"auth_remember",staySignedInKey:"auth_stay_signed_in",tokenDefaultKey:"auth_token_default",tokenImpersonateKey:"auth_token_impersonate",stores:["storage","cookie"],cookie:{Path:"/",Domain:null,Secure:!0,Expires:12096e5,SameSite:"None"},authRedirect:{path:"/login"},forbiddenRedirect:{path:"/403"},notFoundRedirect:{path:"/404"},registerData:{url:"auth/register",method:"POST",redirect:"/login",autoLogin:!1},loginData:{url:"auth/login",method:"POST",redirect:"/",fetchUser:!0,staySignedIn:!0},logoutData:{url:"auth/logout",method:"POST",redirect:"/",makeRequest:!1},fetchData:{url:"auth/user",method:"GET",enabled:!0},refreshData:{url:"auth/refresh",method:"GET",enabled:!0,interval:30},impersonateData:{url:"auth/impersonate",method:"POST",redirect:"/",fetchUser:!0},unimpersonateData:{url:"auth/unimpersonate",method:"POST",redirect:"/admin",fetchUser:!0,makeRequest:!1},oauth2Data:{url:"auth/social",method:"POST",redirect:"/",fetchUser:!0},getUrl:b,getCookieDomain:function(){return window.location.hostname},parseUserData:function(t){return t.data||{}}};function t(t,e){return!0===m.$vm.state.authenticated&&(!t||u(t,function(t,e){var r=e.split(".");for(0;r.length;)t=t[r.shift()];return t}(m.$vm.state.data||{},e||m.options.rolesKey)))}function y(){return!d.call(m)}function g(t){var e,r;return t.to?e=t.to.auth:(r=t.matched.filter(function(t){return Object.prototype.hasOwnProperty.call(t.meta,"auth")})).length&&(e=r[r.length-1].meta.auth),e}function b(){var t=window.location.port;return window.location.protocol+"//"+window.location.hostname+(t?":"+t:"")}function k(t){m.$vm.state.loaded=!0,m.$vm.state.authenticated=t}function r(t){!0===t?f.call(m,m.options.staySignedInKey,"true",!1):h.call(m,m.options.staySignedInKey)}function D(t){t?(f.call(m,m.options.rememberKey,t,!1),m.$vm.state.remember=t):(h.call(m,m.options.rememberKey),m.$vm.state.remember=null)}function w(t){m.transitionPrev=m.transitionThis,m.transitionThis=t}function S(t){return m.options.parseUserData(m.drivers.http.httpData(t))}function I(t){var e,r;return t&&t.ignoreVueAuth||(!1===t.impersonating&&m.impersonating()&&(r=m.options.tokenDefaultKey),(e=d.call(m,r))&&m.drivers.auth.request.call(m,t,e)),t}function T(t,e){var r;e&&e.ignoreVueAuth||(function(t,e){var r,n,o="",i=e&&e.path;if(i&&e.query){for(r in e.query)e.query[r]&&(o+="&"+r+"="+e.query[r]);i+="?"+o.substring(1)}if(!m.drivers.http.invalidToken||!m.drivers.http.invalidToken.call(m,t))return;e&&(n=g(e));n&&(i=n.redirect||m.options.authRedirect);O({redirect:i})}(t,m.transitionThis),(r=m.drivers.auth.response.call(m,t))&&f.call(m,null,r,!d.call(m,m.options.staySignedInKey)))}function $(t){var e=y();e&&m.$vm.state.authenticated&&O(),e||m.$vm.state.loaded||!m.options.refreshData.enabled?K(t):m.refresh().then(function(){K(t)})}function K(t){return null===m.$vm.state.authenticated&&d.call(m)?m.options.fetchData.enabled?void m.fetch().then(t,t):(P({}),t.call(m)):(m.$vm.state.loaded=!0,t.call(m))}function R(t,e,r){var n=(e||"").redirect||m.options.authRedirect,o=(e||"").forbiddenRedirect||(e||"").redirect||m.options.forbiddenRedirect,i=(e||"").notFoundRedirect||(e||"").redirect||m.options.notFoundRedirect;if((e=s(void 0!==(e||"").roles?e.roles:e))&&(!0===e||e.constructor===Array||a(e)))if(m.check()){if(e.constructor!==Array&&!a(e)||u(e,m.$vm.state.data[m.options.rolesKey]))return m.$vm.state.redirect=m.transitionRedirectType?{type:m.transitionRedirectType,from:m.transitionPrev,to:m.transitionThis}:null,m.transitionRedirectType=null,r();m.transitionRedirectType=403,"function"==typeof o&&(o=o(t)),r.call(m,o)}else m.transitionRedirectType=401,"function"==typeof n&&(n=n(t)),r.call(m,n);else{if(!1!==e||!m.check())return m.$vm.state.redirect=m.transitionRedirectType?{type:m.transitionRedirectType,from:m.transitionPrev,to:m.transitionThis}:null,m.transitionRedirectType=null,r();m.transitionRedirectType=404,"function"==typeof i&&(i=i(t)),r.call(m,i)}}function P(t,e){var r;r=t,m.$vm.state.data=r,k(!0),U(e)}function O(t){e.call(m,m.options.tokenImpersonateKey),e.call(m,m.options.tokenDefaultKey),h.call(m,m.options.tokenImpersonateKey),h.call(m,m.options.tokenDefaultKey),h.call(m,m.options.staySignedInKey),m.$vm.state.loaded=!0,m.$vm.state.authenticated=!1,m.$vm.state.data=null,U(t)}function U(t){t&&m.drivers.router.routerGo.call(m,t)}function _(t,e){var r;e=e||{},(m=this).plugins=e.plugins,this.drivers=e.drivers,this.options=c(v,e.options),delete e.plugins,delete e.drivers,delete e.options,this.currentToken=null,this.transitionPrev=null,this.transitionThis=null,this.transitionRedirectType=null,function(){for(var t=["auth","http","router"],e=0,r=t.length;e<r;e++){if(!m.drivers[t[e]])return console.error('Error (@websanova/vue-auth): "'+t[e]+'" driver must be set.');if(m.drivers[t[e]]._init&&(msg=m.drivers[t[e]]._init.call(m),msg))return console.error("Error (@websanova/vue-auth): "+msg)}}(),r=t,m.$vm=new r({data:function(){return{state:{data:null,loaded:!1,redirect:null,authenticated:null,impersonating:void 0,remember:void 0}}}}),m.options.refreshData.enabled&&0<m.options.refreshData.interval&&setInterval(function(){m.options.refreshData.enabled&&!y()&&m.refresh()},1e3*m.options.refreshData.interval*60),m.drivers.http.interceptor.call(m,I,T),m.drivers.router.beforeEach.call(m,$,R,w,g)}function j(t,e){t.auth=new _(t,e),Object.defineProperties(t.prototype,{$auth:{get:function(){return t.auth}}})}return _.prototype.ready=function(){return m.$vm.state.loaded},_.prototype.load=function(){return new Promise(function(t){var e=null,e=setInterval(function(){m.$vm.state.loaded&&(clearInterval(e),t())},50)})},_.prototype.redirect=function(){return m.$vm.state.redirect},_.prototype.user=function(t){return void 0!==t&&P(t),m.$vm.state.data},_.prototype.check=t,_.prototype.impersonating=function(){var t=!!d.call(m,m.options.tokenImpersonateKey);return void 0===m.$vm.state.impersonating&&(m.$vm.state.impersonating=t),m.$vm.state.impersonating},_.prototype.token=function(t,e,r){return void 0!==e&&(null===e?h.call(m,t):(r=!0===r||!1===r?r:!d.call(m,m.options.staySignedInKey),f.call(m,t,e,r))),d.call(m,t)},_.prototype.fetch=function(r){return r=c(m.options.fetchData,r),new Promise(function(e,t){m.drivers.http.http.call(m,r).then(function(t){P(S(t),r.redirect),e(t)},t)})},_.prototype.refresh=function(t){return t=c(m.options.refreshData,t),m.drivers.http.http.call(m,t)},_.prototype.register=function(o){var i=c(m.options.registerData,o);return!0!==i.autoLogin&&(D(i.remember),r(i.staySignedIn)),new Promise(function(r,n){m.drivers.http.http.call(m,i).then(function(t){var e;i.autoLogin?(e=c(m.options.loginData,o),m.login(e).then(r,n)):(r(t),U(i.redirect))},n)})},_.prototype.login=function(n){return D((n=c(m.options.loginData,n)).remember),r(n.staySignedIn),new Promise(function(e,r){m.drivers.http.http.call(m,n).then(function(t){n.fetchUser||void 0===n.fetchUser&&m.options.fetchData.enabled?m.fetch({redirect:n.redirect}).then(e,r):(P(S(t),n.redirect),e(t))},function(t){k(!1),r(t)})})},_.prototype.remember=function(t){t&&D(t);var e=d.call(m,m.options.rememberKey);return void 0===m.$vm.state.remember&&(m.$vm.state.remember=e),m.$vm.state.remember},_.prototype.unremember=function(){D(null)},_.prototype.logout=function(r){return r=c(m.options.logoutData,r),new Promise(function(e,t){r.makeRequest?m.drivers.http.http.call(m,r).then(function(t){O(r.redirect),e(t)},t):(O(r.redirect),e())})},_.prototype.impersonate=function(a){return a=c(m.options.impersonateData,a),new Promise(function(n,o){var i=m.token();m.drivers.http.http.call(m,a).then(function(t){var e,r;e=i,f.call(m,m.options.tokenImpersonateKey,m.token(),!d.call(m,m.options.staySignedInKey)),f.call(m,m.options.tokenDefaultKey,e,!d.call(m,m.options.staySignedInKey)),m.$vm.state.impersonating=!0,U(r),a.fetchUser||void 0===a.fetchUser&&m.options.fetchData.enabled?m.fetch({redirect:a.redirect}).then(n,o):(U(a.redirect),n(t))},o)})},_.prototype.unimpersonate=function(r){return r=c(m.options.unimpersonateData,r),new Promise(function(t,e){r.makeRequest?m.drivers.http.http.call(m,r).then(t,e):t()}).then(function(){return new Promise(function(t,e){h.call(m,m.options.tokenImpersonateKey),m.$vm.state.impersonating=!1,U(void 0),r.fetchUser||void 0===r.fetchUser&&m.options.fetchData.enabled?m.fetch({redirect:r.redirect}).then(t,e):(U(r.redirect),t())})})},_.prototype.oauth2=function(t,e){var r,n,o="";if(e.code){try{e.state&&(e.state=JSON.parse(decodeURIComponent(e.state)))}catch(t){console.error("vue-auth:error There was an issue retrieving the state data."),e.state=e.state||{}}return delete(e=c(m.options.oauth2Data,[e.state,e])).code,delete e.state,delete e.params,m.login(e)}for(r in(e=c(m.drivers.oauth2[t],e)).params.state=JSON.stringify(e.params.state||{}),e.params.redirect_uri=(n=e.params.redirect_uri,/^https?:\/\//.test(n=n||"")?n:b()+"/"+n.replace(/^\/|\/$/g,"")),e.params)o+="&"+r+"="+encodeURIComponent(e.params[r]);window.location=e.url+"?"+o.substring()},_.prototype.enableImpersonate=function(){m.impersonating()&&(m.currentToken=null)},_.prototype.disableImpersonate=function(){m.impersonating()&&(m.currentToken=m.options.tokenDefaultKey)},"undefined"!=typeof window&&window.Vue&&window.Vue.use(j),j});
/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -814,2 +814,8 @@ * Released under the MIT License.

if (registerData.autoLogin !== true) {
_setRemember(registerData.remember);
_setStaySignedIn(registerData.staySignedIn);
}
return new Promise(function (resolve, reject) {

@@ -816,0 +822,0 @@ __auth.drivers.http.http.call(__auth, registerData).then(function (res) {

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -810,2 +810,8 @@ * Released under the MIT License.

if (registerData.autoLogin !== true) {
_setRemember(registerData.remember);
_setStaySignedIn(registerData.staySignedIn);
}
return new Promise(function (resolve, reject) {

@@ -812,0 +818,0 @@ __auth.drivers.http.http.call(__auth, registerData).then(function (res) {

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -814,2 +814,8 @@ * Released under the MIT License.

if (registerData.autoLogin !== true) {
_setRemember(registerData.remember);
_setStaySignedIn(registerData.staySignedIn);
}
return new Promise(function (resolve, reject) {

@@ -816,0 +822,0 @@ __auth.drivers.http.http.call(__auth, registerData).then(function (res) {

/*!
* @websanova/vue-auth v4.0.1
* @websanova/vue-auth v4.0.2
* https://websanova.com/docs/vue-auth

@@ -4,0 +4,0 @@ * Released under the MIT License.

{
"version": "4.0.1",
"version": "4.0.2",
"name": "@websanova/vue-auth",

@@ -4,0 +4,0 @@ "description": "A simple light-weight authentication library for Vue.js",

@@ -548,2 +548,7 @@ import * as __utils from './lib/utils.js';

if (registerData.autoLogin !== true) {
_setRemember(registerData.remember);
_setStaySignedIn(registerData.staySignedIn);
}
return new Promise(function(resolve, reject) {

@@ -550,0 +555,0 @@ __auth.drivers.http.http

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