@frontegg/vue 2.0.9-alpha.3418147443 → 2.0.9-alpha.3444489179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -0
- package/dist/index.min.js +2 -2
- package/dist/index.ssr.js +28 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -510,6 +510,28 @@ const Frontegg = {
|
|
|
510
510
|
}
|
|
511
511
|
}, 10);
|
|
512
512
|
|
|
513
|
+
const isAuthRoutes = path => {
|
|
514
|
+
return Object.values(Vue.fronteggAuth.routes).filter(path => path != Vue.fronteggAuth.routes.authenticatedUrl).includes(path);
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
const authorizedContentGuard = _this => {
|
|
518
|
+
if (!_this.authorizedContent || isAuthRoutes(_this.$route.path)) {
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (!Vue.fronteggAuth.loading && !Vue.fronteggAuth.isAuthenticated) {
|
|
523
|
+
if (options === null || options === void 0 ? void 0 : options.hostedLoginBox) {
|
|
524
|
+
Vue.fronteggAuth.loginActions.requestHostedLoginAuthorize();
|
|
525
|
+
} else {
|
|
526
|
+
const {
|
|
527
|
+
loginUrl
|
|
528
|
+
} = Vue.fronteggAuth.routes;
|
|
529
|
+
|
|
530
|
+
_this.$router.push(loginUrl);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
|
|
513
535
|
if (!pluginRegistered) {
|
|
514
536
|
registerPlugins(Vue);
|
|
515
537
|
} // should be function not arrow to maintain this
|
|
@@ -540,6 +562,14 @@ const Frontegg = {
|
|
|
540
562
|
connectMapState(this);
|
|
541
563
|
},
|
|
542
564
|
|
|
565
|
+
updated() {
|
|
566
|
+
authorizedContentGuard(this);
|
|
567
|
+
},
|
|
568
|
+
|
|
569
|
+
mounted() {
|
|
570
|
+
authorizedContentGuard(this);
|
|
571
|
+
},
|
|
572
|
+
|
|
543
573
|
created() {
|
|
544
574
|
if (getStoreBinding(this)) {
|
|
545
575
|
setStoreUnsubscribe(this, store.subscribe(syncStateWithComponent(this, getStoreBinding(this))));
|
package/dist/index.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var FronteggCore=function(t,n,e,r,i,
|
|
1
|
+
var FronteggCore=function(t,n,e,r,o,i,u){"use strict";function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function c(t){if(t&&t.__esModule)return t;var n=Object.create(null);return t&&Object.keys(t).forEach((function(e){if("default"!==e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})}})),n.default=t,Object.freeze(n)}var s=a(e),f=a(r),l=c(o);function d(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function g(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,n,e){return n&&g(t.prototype,n),e&&g(t,e),t}function v(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function p(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(e.push(u.value),!n||e.length!==n);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return e}(t,n)||A(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(t,n){if(t){if("string"==typeof t)return b(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?b(t,n):void 0}}function b(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -13,4 +13,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
function S(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]])}return e}var y=function(t,n){var e;return t.FRONTEGG_STORE_KEY=null!==(e=t.FRONTEGG_STORE_KEY)&&void 0!==e?e:n},m=function(t){return t.FRONTEGG_STORE_KEY},O=function(t){return t.FRONTEGG_REDUX_BINDINGS},R=function(){function t(){d(this,t)}return h(t,null,[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}},{key:"setStore",value:function(n){t.getInstance().store=n}},{key:"getStore",value:function(){return t.getInstance().store}},{key:"setBasename",value:function(n){t.getInstance().baseName=n}},{key:"getBasename",value:function(){return t.getInstance().baseName}}]),t}(),I=function(t){return function(n){return f.default(n,t)}},E=function(t,n,e){return function(){var r,i=this,o=Object.keys(n),a=f.default(m(i).getState(),t),u=function(t,n,e,r,i){return e.reduce((function(e,o){return Object.assign({},e,v({},n,Object.assign(Object.assign({},e[n]),v({},o,function(t,n,e){return"function"==typeof n?n.bind(t):e(n)}(t,r[o],i)))))}),O(t)||{})}(i,t,o,n,e);return r=u,i.FRONTEGG_REDUX_BINDINGS=r,o.reduce((function(t,r){return Object.assign({},t,v({},r,function(t,n,e,r){return"function"==typeof n?n.call(t,r):e(n)(r)}(i,n[r],e,a)))}),{})}},T=function(){function t(){d(this,t)}return h(t,null,[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}},{key:"setActions",value:function(n){t.getInstance().actions=n}},{key:"getAction",value:function(n){return t.getInstance().actions[n]}}]),t}(),j=function(){function t(n){var e=this;d(this,t);var r=n.router,i=S(n,["router"]);this.state=a.authInitialState,this.userRef=void 0,this.init=function(t,n){e.store=n,Object.entries({loginActions:a.loginActions,socialLoginsActions:a.socialLoginsActions,activateAccountActions:a.activateAccountActions,acceptInvitationActions:a.acceptInvitationActions,forgotPasswordActions:a.forgotPasswordActions,signUpActions:a.signUpActions,profileActions:a.profileActions,ssoActions:a.ssoActions,mfaActions:a.mfaActions,teamActions:a.teamActions,apiTokensActions:a.apiTokensActions,securityPolicyActions:a.securityPolicyActions,tenantsActions:a.tenantsActions}).forEach((function(t){var n=p(t,2),r=n[0],i=n[1];Object.assign(e,v({},r,a.bindActionCreators(i,e.store.dispatch)))}));var r=a.bindActionCreators(a.authActions,e.store.dispatch);T.setActions(r),t.hostedLoginBox||e.store.subscribe(e.storeSubscriber)},this.storeSubscriber=function(){e.state=e.store.getState().auth;var t=!1;e.state.user!==e.userRef&&(e.userRef=e.state.user,t=!0),e.state.isAuthenticated!==e.isAuthenticatedRef&&(e.isAuthenticatedRef=e.state.isAuthenticated,t=!0),e.userRef&&e.state.isAuthenticated?t&&e.accessTokenUpdater():clearInterval(e.accessTokenUpdaterRef)},this.accessTokenUpdater=function(){var t,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(e.accessTokenUpdaterRef&&clearInterval(e.accessTokenUpdaterRef),n)e.loginActions.requestAuthorize(!0);else if(e.isAuthenticated){var r=1e3*((null===(t=e.user)||void 0===t?void 0:t.expiresIn)||20)*.8;e.accessTokenUpdaterRef=setInterval(e.loginActions.requestAuthorize,r)}},this._routes=Object.assign(Object.assign({},a.authInitialState.routes),i.routes),this.router=r}return h(t,[{key:"loading",get:function(){var t,n;return null===(n=null===(t=this.store)||void 0===t?void 0:t.getState().auth.isLoading)||void 0===n||n}},{key:"routes",get:function(){var t,n;return null!==(n=null===(t=this.store)||void 0===t?void 0:t.getState().auth.routes)&&void 0!==n?n:this._routes}},{key:"isAuthenticated",get:function(){var t,n;return null!==(n=null===(t=this.store)||void 0===t?void 0:t.getState().auth.isAuthenticated)&&void 0!==n&&n}},{key:"user",get:function(){var t;return null===(t=this.store)||void 0===t?void 0:t.getState().auth.user}}]),t}(),P=function(t,n){return function(){var e=v({},null!=n?n:t.substring("auth.".length),(function(t){return t}));return E(t,e,I).bind(this)()}},w=function(t){return P("auth","authState").bind(t)},k=function(t){return P("auth.loginState").bind(t)},_=function(t){return P("auth.acceptInvitationState").bind(t)},U=function(t){return P("auth.activateState").bind(t)},G=function(t){return P("auth.apiTokensState").bind(t)},N=function(t){return P("auth.forgotPasswordState").bind(t)},L=function(t){return P("auth.mfaState").bind(t)},C=function(t){return P("auth.profileState").bind(t)},F=function(t){return P("auth.securityPolicyState").bind(t)},B=function(t){return P("auth.signUpState").bind(t)},x=function(t){return P("auth.socialLoginState").bind(t)},D=function(t){return P("auth.ssoState").bind(t)},q=function(t){return P("auth.teamState").bind(t)},z=function(t){return P("auth.tenantsState").bind(t)},H=function(t){Object.assign(t,{mapAuthState:w(t),mapLoginState:k(t),mapAcceptInvitationState:_(t),mapActivateAccountState:U(t),mapApiTokensState:G(t),mapForgotPasswordState:N(t),mapMfaState:L(t),mapProfileState:C(t),mapSecurityPolicyState:F(t),mapSignUpState:B(t),mapSocialLoginState:x(t),mapSsoState:D(t),mapTeamState:q(t),mapTenantsState:z(t)})},M=function(t){return function(){return T.getAction(t).apply(void 0,arguments)}},W=null,V={install:function(t,e){var r,i=null!=e?e:{},a=i.router,u=S(i,["router"]),c=(null!=e?e:{}).contextOptions;if(null==c)throw Error("contextOptions must be passed to Vue.use(Frontegg, { /* OPTIONS */ })");c.requestCredentials=null!==(r=c.requestCredentials)&&void 0!==r?r:"include",n.ContextHolder.setContext(c);var d=!1,g=!1,h=new Set,v=a&&function(t){var e=t.options.base||"";R.setBasename(e);var r=function(n,r){var i=n;i.startsWith(e)&&"/"!==e&&(i=i.substring(e.length-1)),(null==r?void 0:r.refresh)?window.location.href=i:(null==r?void 0:r.replace)?t.replace(i):t.push(i)};return n.ContextHolder.setOnRedirectTo(r),r}(a),p=(W=o.initialize(Object.assign(Object.assign({},u),{onRedirectTo:v,basename:null==a?void 0:a.options.base}))).store;R.setStore(p),t.$fronteggApp=W,t.fronteggAuth||(t.fronteggAuth=new j({router:a}),function(t,n){var e;t.fronteggPlugins=null!==(e=t.fronteggPlugins)&&void 0!==e?e:[],t.fronteggPlugins.push(n)}(t,t.fronteggAuth));var b=function(){var n=(t.fronteggPlugins||[]).reduce((function(t,n){return t&&!n.loading}),!0);if(n!==g){g=n;var e,r=function(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=A(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(u)throw o}}}}(h);try{for(r.s();!(e=r.n()).done;){(0,e.value)()}}catch(t){r.e(t)}finally{r.f()}}};null==a||a.getRoutes().map((function(t){var n=t.beforeEnter;t.beforeEnter=function(t,e,r){var i=function(){n?n(t,e,r):r()};if(g)i();else var o=setInterval((function(){b(),g&&(clearInterval(o),i())}),1)}}));var I,E=setInterval((function(){b(),g&&clearInterval(E)}),10);function T(){this.$route.path.startsWith(t.fronteggAuth.routes.hostedLoginRedirectUrl)||(p.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.fronteggAuth.loginActions.requestHostedLoginAuthorize())}d||(I=t,d=!0,(t.fronteggPlugins||[]).forEach((function(t){return t.init(u,p)})),y(I,p),I.fronteggAuth=t.fronteggAuth,H(I)),t.mixin({data:function(){return{fronteggLoaded:g}},beforeCreate:function(){y(this,p),this.fronteggAuth=t.fronteggAuth,this.loginWithRedirect=T.bind(this),H(this)},created:function(){var t,n;O(this)&&function(t,n){t.FRONTEGG_UNSUBSCRIBE=n}(this,p.subscribe((t=this,n=O(this),function(){var e=m(t).getState();Object.keys(n).forEach((function(r){Object.keys(n[r]).forEach((function(i){var o=n[r][i];if(o){var a,u=o(f.default(e,r)),c=Object.assign({},l);c.default&&(a=2),c.version&&"3"===c.version[0]&&(a=3),3===a&&s.default(t.$data,i,u),2===a&&s.default(t._data,i,u)}}))}))}))),function(t,n){t.FRONTEGG_LOADER_UNSUBSCRIBE=n}(this,function(t){var n=function(){t.fronteggLoaded=g};return h.add(n),function(){return h.delete(n)}}(this))},beforeDestroy:function(){!function(t){var n;null===(n=t.FRONTEGG_UNSUBSCRIBE)||void 0===n||n.call(t)}(this),function(t){var n;null===(n=t.FRONTEGG_LOADER_UNSUBSCRIBE)||void 0===n||n.call(t)}(this)}})}};return Object.defineProperty(t,"AdminPortal",{enumerable:!0,get:function(){return o.AdminPortal}}),t.Frontegg=V,t.closeAdminPortal=function(){return o.AdminPortal.hide()},t.isAuthenticatedGuard=function(t,n,e){var r,i,o=function(){var n,r=R.getStore().getState().auth;if(r.isAuthenticated)e();else{var i=null!==(n=R.getBasename())&&void 0!==n?n:"",o=i.endsWith("/")?i.substring(0,i.length-1):"";localStorage.setItem("FRONTEGG_AFTER_AUTH_REDIRECT_URL","".concat(o).concat(t.fullPath)),e({path:r.routes.loginUrl,replace:!0})}},a=null===(i=null===(r=R.getStore())||void 0===r?void 0:r.getState())||void 0===i?void 0:i.auth;if(!a||(null==a?void 0:a.isLoading))var u=setInterval((function(){var t,n;(a=null===(n=null===(t=R.getStore())||void 0===t?void 0:t.getState())||void 0===n?void 0:n.auth)&&!(null==a?void 0:a.isLoading)&&(clearInterval(u),o())}),1);else o()},t.mapAcceptInvitationActions=function(t){return M(t)},t.mapActivateAccountActions=function(t){return M(t)},t.mapApiTokensActions=function(t){return M(t)},t.mapAuthActions=function(t){return M(t)},t.mapForgotPasswordActions=function(t){return M(t)},t.mapLoginActions=function(t){return M("loginWithRedirect"===t?"requestHostedLoginAuthorize":t)},t.mapMfaActions=function(t){return M(t)},t.mapProfileActions=function(t){return M(t)},t.mapSecurityPolicyActions=function(t){return M(t)},t.mapSignupActions=function(t){return M(t)},t.mapSocialLoginActions=function(t){return M(t)},t.mapSsoActions=function(t){return M(t)},t.mapTeamActions=function(t){return M(t)},t.openAdminPortal=function(){return o.AdminPortal.show()},Object.defineProperty(t,"__esModule",{value:!0}),t}({},fronteggRestApi,setValue,getValue,Vue,js,fronteggReduxStore);
|
|
16
|
+
function S(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e}var y=function(t,n){var e;return t.FRONTEGG_STORE_KEY=null!==(e=t.FRONTEGG_STORE_KEY)&&void 0!==e?e:n},m=function(t){return t.FRONTEGG_STORE_KEY},O=function(t){return t.FRONTEGG_REDUX_BINDINGS},R=function(){function t(){d(this,t)}return h(t,null,[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}},{key:"setStore",value:function(n){t.getInstance().store=n}},{key:"getStore",value:function(){return t.getInstance().store}},{key:"setBasename",value:function(n){t.getInstance().baseName=n}},{key:"getBasename",value:function(){return t.getInstance().baseName}}]),t}(),I=function(t){return function(n){return f.default(n,t)}},E=function(t,n,e){return function(){var r,o=this,i=Object.keys(n),u=f.default(m(o).getState(),t),a=function(t,n,e,r,o){return e.reduce((function(e,i){return Object.assign({},e,v({},n,Object.assign(Object.assign({},e[n]),v({},i,function(t,n,e){return"function"==typeof n?n.bind(t):e(n)}(t,r[i],o)))))}),O(t)||{})}(o,t,i,n,e);return r=a,o.FRONTEGG_REDUX_BINDINGS=r,i.reduce((function(t,r){return Object.assign({},t,v({},r,function(t,n,e,r){return"function"==typeof n?n.call(t,r):e(n)(r)}(o,n[r],e,u)))}),{})}},j=function(){function t(){d(this,t)}return h(t,null,[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}},{key:"setActions",value:function(n){t.getInstance().actions=n}},{key:"getAction",value:function(n){return t.getInstance().actions[n]}}]),t}(),T=function(){function t(n){var e=this;d(this,t);var r=n.router,o=S(n,["router"]);this.state=u.authInitialState,this.userRef=void 0,this.init=function(t,n){e.store=n,Object.entries({loginActions:u.loginActions,socialLoginsActions:u.socialLoginsActions,activateAccountActions:u.activateAccountActions,acceptInvitationActions:u.acceptInvitationActions,forgotPasswordActions:u.forgotPasswordActions,signUpActions:u.signUpActions,profileActions:u.profileActions,ssoActions:u.ssoActions,mfaActions:u.mfaActions,teamActions:u.teamActions,apiTokensActions:u.apiTokensActions,securityPolicyActions:u.securityPolicyActions,tenantsActions:u.tenantsActions}).forEach((function(t){var n=p(t,2),r=n[0],o=n[1];Object.assign(e,v({},r,u.bindActionCreators(o,e.store.dispatch)))}));var r=u.bindActionCreators(u.authActions,e.store.dispatch);j.setActions(r),t.hostedLoginBox||e.store.subscribe(e.storeSubscriber)},this.storeSubscriber=function(){e.state=e.store.getState().auth;var t=!1;e.state.user!==e.userRef&&(e.userRef=e.state.user,t=!0),e.state.isAuthenticated!==e.isAuthenticatedRef&&(e.isAuthenticatedRef=e.state.isAuthenticated,t=!0),e.userRef&&e.state.isAuthenticated?t&&e.accessTokenUpdater():clearInterval(e.accessTokenUpdaterRef)},this.accessTokenUpdater=function(){var t,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(e.accessTokenUpdaterRef&&clearInterval(e.accessTokenUpdaterRef),n)e.loginActions.requestAuthorize(!0);else if(e.isAuthenticated){var r=1e3*((null===(t=e.user)||void 0===t?void 0:t.expiresIn)||20)*.8;e.accessTokenUpdaterRef=setInterval(e.loginActions.requestAuthorize,r)}},this._routes=Object.assign(Object.assign({},u.authInitialState.routes),o.routes),this.router=r}return h(t,[{key:"loading",get:function(){var t,n;return null===(n=null===(t=this.store)||void 0===t?void 0:t.getState().auth.isLoading)||void 0===n||n}},{key:"routes",get:function(){var t,n;return null!==(n=null===(t=this.store)||void 0===t?void 0:t.getState().auth.routes)&&void 0!==n?n:this._routes}},{key:"isAuthenticated",get:function(){var t,n;return null!==(n=null===(t=this.store)||void 0===t?void 0:t.getState().auth.isAuthenticated)&&void 0!==n&&n}},{key:"user",get:function(){var t;return null===(t=this.store)||void 0===t?void 0:t.getState().auth.user}}]),t}(),P=function(t,n){return function(){var e=v({},null!=n?n:t.substring("auth.".length),(function(t){return t}));return E(t,e,I).bind(this)()}},w=function(t){return P("auth","authState").bind(t)},k=function(t){return P("auth.loginState").bind(t)},U=function(t){return P("auth.acceptInvitationState").bind(t)},_=function(t){return P("auth.activateState").bind(t)},G=function(t){return P("auth.apiTokensState").bind(t)},L=function(t){return P("auth.forgotPasswordState").bind(t)},N=function(t){return P("auth.mfaState").bind(t)},C=function(t){return P("auth.profileState").bind(t)},B=function(t){return P("auth.securityPolicyState").bind(t)},F=function(t){return P("auth.signUpState").bind(t)},x=function(t){return P("auth.socialLoginState").bind(t)},D=function(t){return P("auth.ssoState").bind(t)},z=function(t){return P("auth.teamState").bind(t)},q=function(t){return P("auth.tenantsState").bind(t)},H=function(t){Object.assign(t,{mapAuthState:w(t),mapLoginState:k(t),mapAcceptInvitationState:U(t),mapActivateAccountState:_(t),mapApiTokensState:G(t),mapForgotPasswordState:L(t),mapMfaState:N(t),mapProfileState:C(t),mapSecurityPolicyState:B(t),mapSignUpState:F(t),mapSocialLoginState:x(t),mapSsoState:D(t),mapTeamState:z(t),mapTenantsState:q(t)})},$=function(t){return function(){return j.getAction(t).apply(void 0,arguments)}},M=null,W={install:function(t,e){var r,o=null!=e?e:{},u=o.router,a=S(o,["router"]),c=(null!=e?e:{}).contextOptions;if(null==c)throw Error("contextOptions must be passed to Vue.use(Frontegg, { /* OPTIONS */ })");c.requestCredentials=null!==(r=c.requestCredentials)&&void 0!==r?r:"include",n.ContextHolder.setContext(c);var d=!1,g=!1,h=new Set,v=u&&function(t){var e=t.options.base||"";R.setBasename(e);var r=function(n,r){var o=n;o.startsWith(e)&&"/"!==e&&(o=o.substring(e.length-1)),(null==r?void 0:r.refresh)?window.location.href=o:(null==r?void 0:r.replace)?t.replace(o):t.push(o)};return n.ContextHolder.setOnRedirectTo(r),r}(u),p=(M=i.initialize(Object.assign(Object.assign({},a),{onRedirectTo:v,basename:null==u?void 0:u.options.base}))).store;R.setStore(p),t.$fronteggApp=M,t.fronteggAuth||(t.fronteggAuth=new T({router:u}),function(t,n){var e;t.fronteggPlugins=null!==(e=t.fronteggPlugins)&&void 0!==e?e:[],t.fronteggPlugins.push(n)}(t,t.fronteggAuth));var b=function(){var n=(t.fronteggPlugins||[]).reduce((function(t,n){return t&&!n.loading}),!0);if(n!==g){g=n;var e,r=function(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=A(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,a=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return u=t.done,t},e:function(t){a=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(a)throw i}}}}(h);try{for(r.s();!(e=r.n()).done;){(0,e.value)()}}catch(t){r.e(t)}finally{r.f()}}};null==u||u.getRoutes().map((function(t){var n=t.beforeEnter;t.beforeEnter=function(t,e,r){var o=function(){n?n(t,e,r):r()};if(g)o();else var i=setInterval((function(){b(),g&&(clearInterval(i),o())}),1)}}));var I,E=setInterval((function(){b(),g&&clearInterval(E)}),10),j=function(n){var r;if(n.authorizedContent&&(r=n.$route.path,!Object.values(t.fronteggAuth.routes).filter((function(n){return n!=t.fronteggAuth.routes.authenticatedUrl})).includes(r))&&(!t.fronteggAuth.loading&&!t.fronteggAuth.isAuthenticated))if(null==e?void 0:e.hostedLoginBox)t.fronteggAuth.loginActions.requestHostedLoginAuthorize();else{var o=t.fronteggAuth.routes.loginUrl;n.$router.push(o)}};function P(){this.$route.path.startsWith(t.fronteggAuth.routes.hostedLoginRedirectUrl)||(p.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.fronteggAuth.loginActions.requestHostedLoginAuthorize())}d||(I=t,d=!0,(t.fronteggPlugins||[]).forEach((function(t){return t.init(a,p)})),y(I,p),I.fronteggAuth=t.fronteggAuth,H(I)),t.mixin({data:function(){return{fronteggLoaded:g}},beforeCreate:function(){y(this,p),this.fronteggAuth=t.fronteggAuth,this.loginWithRedirect=P.bind(this),H(this)},updated:function(){j(this)},mounted:function(){j(this)},created:function(){var t,n;O(this)&&function(t,n){t.FRONTEGG_UNSUBSCRIBE=n}(this,p.subscribe((t=this,n=O(this),function(){var e=m(t).getState();Object.keys(n).forEach((function(r){Object.keys(n[r]).forEach((function(o){var i=n[r][o];if(i){var u,a=i(f.default(e,r)),c=Object.assign({},l);c.default&&(u=2),c.version&&"3"===c.version[0]&&(u=3),3===u&&s.default(t.$data,o,a),2===u&&s.default(t._data,o,a)}}))}))}))),function(t,n){t.FRONTEGG_LOADER_UNSUBSCRIBE=n}(this,function(t){var n=function(){t.fronteggLoaded=g};return h.add(n),function(){return h.delete(n)}}(this))},beforeDestroy:function(){!function(t){var n;null===(n=t.FRONTEGG_UNSUBSCRIBE)||void 0===n||n.call(t)}(this),function(t){var n;null===(n=t.FRONTEGG_LOADER_UNSUBSCRIBE)||void 0===n||n.call(t)}(this)}})}};return Object.defineProperty(t,"AdminPortal",{enumerable:!0,get:function(){return i.AdminPortal}}),t.Frontegg=W,t.closeAdminPortal=function(){return i.AdminPortal.hide()},t.isAuthenticatedGuard=function(t,n,e){var r,o,i=function(){var n,r=R.getStore().getState().auth;if(r.isAuthenticated)e();else{var o=null!==(n=R.getBasename())&&void 0!==n?n:"",i=o.endsWith("/")?o.substring(0,o.length-1):"";localStorage.setItem("FRONTEGG_AFTER_AUTH_REDIRECT_URL","".concat(i).concat(t.fullPath)),e({path:r.routes.loginUrl,replace:!0})}},u=null===(o=null===(r=R.getStore())||void 0===r?void 0:r.getState())||void 0===o?void 0:o.auth;if(!u||(null==u?void 0:u.isLoading))var a=setInterval((function(){var t,n;(u=null===(n=null===(t=R.getStore())||void 0===t?void 0:t.getState())||void 0===n?void 0:n.auth)&&!(null==u?void 0:u.isLoading)&&(clearInterval(a),i())}),1);else i()},t.mapAcceptInvitationActions=function(t){return $(t)},t.mapActivateAccountActions=function(t){return $(t)},t.mapApiTokensActions=function(t){return $(t)},t.mapAuthActions=function(t){return $(t)},t.mapForgotPasswordActions=function(t){return $(t)},t.mapLoginActions=function(t){return $("loginWithRedirect"===t?"requestHostedLoginAuthorize":t)},t.mapMfaActions=function(t){return $(t)},t.mapProfileActions=function(t){return $(t)},t.mapSecurityPolicyActions=function(t){return $(t)},t.mapSignupActions=function(t){return $(t)},t.mapSocialLoginActions=function(t){return $(t)},t.mapSsoActions=function(t){return $(t)},t.mapTeamActions=function(t){return $(t)},t.openAdminPortal=function(){return i.AdminPortal.show()},Object.defineProperty(t,"__esModule",{value:!0}),t}({},fronteggRestApi,setValue,getValue,Vue,js,fronteggReduxStore);
|
package/dist/index.ssr.js
CHANGED
|
@@ -755,6 +755,28 @@ var Frontegg = {
|
|
|
755
755
|
}
|
|
756
756
|
}, 10);
|
|
757
757
|
|
|
758
|
+
var isAuthRoutes = function isAuthRoutes(path) {
|
|
759
|
+
return Object.values(Vue.fronteggAuth.routes).filter(function (path) {
|
|
760
|
+
return path != Vue.fronteggAuth.routes.authenticatedUrl;
|
|
761
|
+
}).includes(path);
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
var authorizedContentGuard = function authorizedContentGuard(_this) {
|
|
765
|
+
if (!_this.authorizedContent || isAuthRoutes(_this.$route.path)) {
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
if (!Vue.fronteggAuth.loading && !Vue.fronteggAuth.isAuthenticated) {
|
|
770
|
+
if (options === null || options === void 0 ? void 0 : options.hostedLoginBox) {
|
|
771
|
+
Vue.fronteggAuth.loginActions.requestHostedLoginAuthorize();
|
|
772
|
+
} else {
|
|
773
|
+
var loginUrl = Vue.fronteggAuth.routes.loginUrl;
|
|
774
|
+
|
|
775
|
+
_this.$router.push(loginUrl);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
|
|
758
780
|
if (!pluginRegistered) {
|
|
759
781
|
registerPlugins(Vue);
|
|
760
782
|
} // should be function not arrow to maintain this
|
|
@@ -785,6 +807,12 @@ var Frontegg = {
|
|
|
785
807
|
this.loginWithRedirect = loginWithRedirect.bind(this);
|
|
786
808
|
connectMapState(this);
|
|
787
809
|
},
|
|
810
|
+
updated: function updated() {
|
|
811
|
+
authorizedContentGuard(this);
|
|
812
|
+
},
|
|
813
|
+
mounted: function mounted() {
|
|
814
|
+
authorizedContentGuard(this);
|
|
815
|
+
},
|
|
788
816
|
created: function created() {
|
|
789
817
|
if (getStoreBinding(this)) {
|
|
790
818
|
setStoreUnsubscribe(this, store.subscribe(syncStateWithComponent(this, getStoreBinding(this))));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/vue",
|
|
3
|
-
"version": "2.0.9-alpha.
|
|
3
|
+
"version": "2.0.9-alpha.3444489179",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.ssr.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"build:unpkg": "cross-env NODE_ENV=production rollup --config rollup.config.js --format iife"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@frontegg/js": "6.
|
|
25
|
+
"@frontegg/js": "6.42.0",
|
|
26
26
|
"get-value": "^3.0.1",
|
|
27
27
|
"set-value": "^4.0.1"
|
|
28
28
|
},
|