@frontegg/vue 2.0.26-alpha.4702031390 → 2.0.26-alpha.4718860145

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/helpers.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RedirectOptions } from '@frontegg/rest-api';
2
- import { AuthState } from '@frontegg/redux-store';
2
+ import { AuthState, AuthPageRoutes } from '@frontegg/redux-store';
3
3
  import VueRouter from 'vue-router';
4
- export declare const setupOnRedirectTo: (router: VueRouter) => (_path: string, opts?: RedirectOptions | undefined) => void;
4
+ export declare const setupOnRedirectTo: (router: VueRouter, routes?: Partial<AuthPageRoutes> | undefined) => (_path: string, opts?: RedirectOptions | undefined) => void;
5
5
  export declare const syncStateWithComponent: (component: any, bindings: any) => () => void;
6
6
  export declare const defaultGetterGenerator: (prop: string) => (state: AuthState) => any;
7
7
  export declare const generateStoreBindingBySlices: (vueInstance: any, subState: string, slices: string[], obj: any, fallbackGetter: any) => any;
package/dist/index.js CHANGED
@@ -3,10 +3,10 @@ import { inject, onBeforeUnmount, onMounted, onUpdated, reactive, ref } from 'vu
3
3
  import { ContextHolder } from '@frontegg/rest-api';
4
4
  export { ContextHolder } from '@frontegg/rest-api';
5
5
  import set from 'set-value';
6
+ import { isAuthRoute, authInitialState, loginActions, socialLoginsActions, activateAccountActions, acceptInvitationActions, forgotPasswordActions, signUpActions, profileActions, ssoActions, mfaActions, teamActions, apiTokensActions, securityPolicyActions, tenantsActions, bindActionCreators, authActions } from '@frontegg/redux-store';
6
7
  import get from 'get-value';
7
8
  import { initialize, AdminPortal } from '@frontegg/js';
8
9
  export { AdminPortal } from '@frontegg/js';
9
- import { authInitialState, loginActions, socialLoginsActions, activateAccountActions, acceptInvitationActions, forgotPasswordActions, signUpActions, profileActions, ssoActions, mfaActions, teamActions, apiTokensActions, securityPolicyActions, tenantsActions, bindActionCreators, authActions } from '@frontegg/redux-store';
10
10
 
11
11
  /*! *****************************************************************************
12
12
  Copyright (c) Microsoft Corporation.
@@ -102,7 +102,7 @@ class StoreHolder {
102
102
 
103
103
  }
104
104
 
105
- const setupOnRedirectTo = router => {
105
+ const setupOnRedirectTo = (router, routes) => {
106
106
  const baseName = router.options.base || '';
107
107
  StoreHolder.setBasename(baseName);
108
108
 
@@ -113,6 +113,10 @@ const setupOnRedirectTo = router => {
113
113
  path = path.substring(baseName.length - 1);
114
114
  }
115
115
 
116
+ if ((opts === null || opts === void 0 ? void 0 : opts.preserveQueryParams) || isAuthRoute(path, routes)) {
117
+ path = `${path}${window.location.search}`;
118
+ }
119
+
116
120
  if (opts === null || opts === void 0 ? void 0 : opts.refresh) {
117
121
  window.location.href = path;
118
122
  } else {
@@ -520,13 +524,13 @@ const isAuthenticatedGuard = function (_to, _from, next) {
520
524
  let fronteggApp = null;
521
525
  const Frontegg = {
522
526
  install(Vue, options) {
523
- var _a;
527
+ var _a, _b;
524
528
 
525
- const _b = options !== null && options !== void 0 ? options : {},
529
+ const _c = options !== null && options !== void 0 ? options : {},
526
530
  {
527
531
  router
528
- } = _b,
529
- rest = __rest(_b, ["router"]);
532
+ } = _c,
533
+ rest = __rest(_c, ["router"]);
530
534
 
531
535
  const {
532
536
  contextOptions
@@ -559,7 +563,7 @@ const Frontegg = {
559
563
  return () => fronteggLoadedSubscribes.delete(func);
560
564
  };
561
565
 
562
- const onRedirectTo = router && setupOnRedirectTo(router);
566
+ const onRedirectTo = router && setupOnRedirectTo(router, (_b = options === null || options === void 0 ? void 0 : options.authOptions) === null || _b === void 0 ? void 0 : _b.routes);
563
567
  fronteggApp = initialize(Object.assign(Object.assign({}, rest), {
564
568
  onRedirectTo,
565
569
  basename: router === null || router === void 0 ? void 0 : router.options.base
package/dist/index.min.js CHANGED
@@ -1,4 +1,4 @@
1
- var FronteggCore=function(t,e,n,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 e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var s=c(e),f=a(r),l=a(o);function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function g(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,e,n){return e&&g(t.prototype,e),n&&g(t,n),t}function v(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function p(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(t,e)||b(t,e)||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 b(t,e){if(t){if("string"==typeof t)return A(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(t,e):void 0}}function A(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}
1
+ var FronteggCore=function(t,e,n,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 e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var s=c(e),l=a(r),f=a(i);function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function g(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,e,n){return e&&g(t.prototype,e),n&&g(t,n),t}function v(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function p(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(t,e)||b(t,e)||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 b(t,e){if(t){if("string"==typeof t)return A(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(t,e):void 0}}function A(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];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,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}var y=Symbol("fronteggLoade"),m=Symbol("authState"),O=Symbol("unsubscribeFronteggStore"),j=Symbol("fronteggAuth"),R=Symbol("router"),I=Symbol("fronteggOptions"),E=Symbol("fronteggStore"),T=function(t,e){var n;return t.FRONTEGG_STORE_KEY=null!==(n=t.FRONTEGG_STORE_KEY)&&void 0!==n?n:e},P=function(t){return t.FRONTEGG_STORE_KEY},U=function(t){return t.FRONTEGG_REDUX_BINDINGS},L=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(e){t.getInstance().store=e}},{key:"getStore",value:function(){return t.getInstance().store}},{key:"setBasename",value:function(e){t.getInstance().baseName=e}},{key:"getBasename",value:function(){return t.getInstance().baseName}}]),t}(),w=function(t){return function(e){return l.default(e,t)}},k=function(t,e,n){return function(){var r,o=this,i=Object.keys(e),u=l.default(P(o).getState(),t),a=function(t,e,n,r,o){return n.reduce((function(n,i){return Object.assign({},n,v({},e,Object.assign(Object.assign({},n[e]),v({},i,function(t,e,n){return"function"==typeof e?e.bind(t):n(e)}(t,r[i],o)))))}),U(t)||{})}(o,t,i,e,n);return r=a,o.FRONTEGG_REDUX_BINDINGS=r,i.reduce((function(t,r){return Object.assign({},t,v({},r,function(t,e,n,r){return"function"==typeof e?e.call(t,r):n(e)(r)}(o,e[r],n,u)))}),{})}},_=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(e){t.getInstance().actions=e}},{key:"getAction",value:function(e){return t.getInstance().actions[e]}}]),t}(),G=function(){function t(e){var n=this;d(this,t);var r=e.router,o=S(e,["router"]);this.state=u.authInitialState,this.userRef=void 0,this.init=function(t,e){n.store=e,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 e=p(t,2),r=e[0],o=e[1];Object.assign(n,v({},r,u.bindActionCreators(o,n.store.dispatch)))}));var r=u.bindActionCreators(u.authActions,n.store.dispatch);_.setActions(r),t.hostedLoginBox||n.store.subscribe(n.storeSubscriber)},this.storeSubscriber=function(){n.state=n.store.getState().auth;var t=!1;n.state.user!==n.userRef&&(n.userRef=n.state.user,t=!0),n.state.isAuthenticated!==n.isAuthenticatedRef&&(n.isAuthenticatedRef=n.state.isAuthenticated,t=!0),n.userRef&&n.state.isAuthenticated?t&&n.accessTokenUpdater():clearInterval(n.accessTokenUpdaterRef)},this.accessTokenUpdater=function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(n.accessTokenUpdaterRef&&clearInterval(n.accessTokenUpdaterRef),e)n.loginActions.requestAuthorize(!0);else if(n.isAuthenticated){var r=1e3*((null===(t=n.user)||void 0===t?void 0:t.expiresIn)||20)*.8;n.accessTokenUpdaterRef=setInterval(n.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,e;return null===(e=null===(t=this.store)||void 0===t?void 0:t.getState().auth.isLoading)||void 0===e||e}},{key:"routes",get:function(){var t,e;return null!==(e=null===(t=this.store)||void 0===t?void 0:t.getState().auth.routes)&&void 0!==e?e:this._routes}},{key:"isAuthenticated",get:function(){var t,e;return null!==(e=null===(t=this.store)||void 0===t?void 0:t.getState().auth.isAuthenticated)&&void 0!==e&&e}},{key:"user",get:function(){var t;return null===(t=this.store)||void 0===t?void 0:t.getState().auth.user}}]),t}(),F=function(t,e){return function(){var n=v({},null!=e?e:t.substring("auth.".length),(function(t){return t}));return k(t,n,w).bind(this)()}},N=function(t){return F("auth","authState").bind(t)},C=function(t){return F("auth.loginState").bind(t)},B=function(t){return F("auth.acceptInvitationState").bind(t)},x=function(t){return F("auth.activateState").bind(t)},z=function(t){return F("auth.apiTokensState").bind(t)},H=function(t){return F("auth.forgotPasswordState").bind(t)},q=function(t){return F("auth.mfaState").bind(t)},D=function(t){return F("auth.profileState").bind(t)},W=function(t){return F("auth.securityPolicyState").bind(t)},M=function(t){return F("auth.signUpState").bind(t)},$=function(t){return F("auth.socialLoginState").bind(t)},V=function(t){return F("auth.ssoState").bind(t)},K=function(t){return F("auth.teamState").bind(t)},Y=function(t){return F("auth.tenantsState").bind(t)},X=function(t){Object.assign(t,{mapAuthState:N(t),mapLoginState:C(t),mapAcceptInvitationState:B(t),mapActivateAccountState:x(t),mapApiTokensState:z(t),mapForgotPasswordState:H(t),mapMfaState:q(t),mapProfileState:D(t),mapSecurityPolicyState:W(t),mapSignUpState:M(t),mapSocialLoginState:$(t),mapSsoState:V(t),mapTeamState:K(t),mapTenantsState:Y(t)})},J=function(t){return function(){return _.getAction(t).apply(void 0,arguments)}},Q=function(){return e.inject(y)},Z=function(){return e.inject(O)},tt=function(){return e.inject(m)},et=function(){return e.inject(E)},nt=function(){return e.inject(j)},rt=null,ot={install:function(t,r){var o,u=null!=r?r:{},a=u.router,c=S(u,["router"]),d=(null!=r?r:{}).contextOptions;if(null==d)throw Error("contextOptions must be passed to Vue.use(Frontegg, { /* OPTIONS */ })");d.requestCredentials=null!==(o=d.requestCredentials)&&void 0!==o?o:"include",n.ContextHolder.setContext(d);var g,h=!1,v=!1,A="3"===t.version.charAt(0);A&&(g=e.ref(!1));var w=new Set,k=a&&function(t){var e=t.options.base||"";L.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}(a),_=(rt=i.initialize(Object.assign(Object.assign({},c),{onRedirectTo:k,basename:null==a?void 0:a.options.base}))).store;L.setStore(_),t.$fronteggApp=rt,t.fronteggAuth||(t.fronteggAuth=new G({router:a}),function(t,e){var n;t.fronteggPlugins=null!==(n=t.fronteggPlugins)&&void 0!==n?n:[],t.fronteggPlugins.push(e)}(t,t.fronteggAuth));var F=function(){var e=(t.fronteggPlugins||[]).reduce((function(t,e){return t&&!e.loading}),!0);if(e!==v){v=e,A&&(g.value=e);var n,r=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=b(t))||e&&t&&"number"==typeof t.length){n&&(t=n);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(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return u=t.done,t},e:function(t){a=!0,i=t},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw i}}}}(w);try{for(r.s();!(n=r.n()).done;){(0,n.value)()}}catch(t){r.e(t)}finally{r.f()}}};null==a||a.getRoutes().map((function(t){var e=t.beforeEnter;t.beforeEnter=function(t,n,r){var o=function(){e?e(t,n,r):r()};if(v)o();else var i=setInterval((function(){F(),v&&(clearInterval(i),o())}),1)}}));var N,C=setInterval((function(){F(),v&&clearInterval(C)}),10),B=function(e){var n,o;if(e.authorizedContent&&(n=e.$route.path,o=t.fronteggAuth.routes,!Object.values(o).filter((function(t){return t!=o.authenticatedUrl})).includes(n))&&(!t.fronteggAuth.loading&&!t.fronteggAuth.isAuthenticated))if(null==r?void 0:r.hostedLoginBox)t.fronteggAuth.loginActions.requestHostedLoginAuthorize();else{var i=t.fronteggAuth.routes.loginUrl;e.$router.push(i)}};function x(){this.$route.path.startsWith(t.fronteggAuth.routes.hostedLoginRedirectUrl)||(_.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.fronteggAuth.loginActions.requestHostedLoginAuthorize())}if(h||(N=t,h=!0,(t.fronteggPlugins||[]).forEach((function(t){return t.init(c,_)})),T(N,_),N.fronteggAuth=t.fronteggAuth,X(N)),A){t.provide(y,g);var z=function(t){var n=t.getState(),r=e.reactive(Object.assign({},n.auth)),o=t.subscribe((function(){var e=t.getState().auth;Object.entries(e).forEach((function(t){var n=p(t,2),o=n[0],i=n[1];r[o]!==e[o]&&(r[o]=i)}))}));return{authState:r,unsubscribe:o}}(_),H=z.authState,q=z.unsubscribe,D=e.reactive(Object.assign({},t.fronteggAuth));t.provide(m,H),t.provide(O,q),t.provide(j,D),t.provide(R,a),t.provide(I,r),t.provide(E,_)}t.mixin({data:function(){return{fronteggLoaded:v}},beforeCreate:function(){T(this,_),this.fronteggAuth=t.fronteggAuth,this.loginWithRedirect=x.bind(this),X(this)},updated:function(){B(this)},mounted:function(){B(this)},created:function(){var t,e;U(this)&&function(t,e){t.FRONTEGG_UNSUBSCRIBE=e}(this,_.subscribe((t=this,e=U(this),function(){var n=P(t).getState();Object.keys(e).forEach((function(r){Object.keys(e[r]).forEach((function(o){var i=e[r][o];if(i){var u,a=i(l.default(n,r)),c=Object.assign({},s);c.default&&(u=2),c.version&&"3"===c.version[0]&&(u=3),3===u&&f.default(t.$data,o,a),2===u&&f.default(t._data,o,a)}}))}))}))),function(t,e){t.FRONTEGG_LOADER_UNSUBSCRIBE=e}(this,function(t){var e=function(){t.fronteggLoaded=v};return w.add(e),function(){return w.delete(e)}}(this))},beforeDestroy:function(){!function(t){var e;null===(e=t.FRONTEGG_UNSUBSCRIBE)||void 0===e||e.call(t)}(this),function(t){var e;null===(e=t.FRONTEGG_LOADER_UNSUBSCRIBE)||void 0===e||e.call(t)}(this)}})}};return Object.defineProperty(t,"ContextHolder",{enumerable:!0,get:function(){return n.ContextHolder}}),Object.defineProperty(t,"AdminPortal",{enumerable:!0,get:function(){return i.AdminPortal}}),t.Frontegg=ot,t.closeAdminPortal=function(){return i.AdminPortal.hide()},t.isAuthenticatedGuard=function(t,e,n){var r,o,i=function(){var e,r=L.getStore().getState().auth;if(r.isAuthenticated)n();else{var o=null!==(e=L.getBasename())&&void 0!==e?e:"",i=o.endsWith("/")?o.substring(0,o.length-1):"";localStorage.setItem("FRONTEGG_AFTER_AUTH_REDIRECT_URL","".concat(i).concat(t.fullPath)),n({path:r.routes.loginUrl,replace:!0})}},u=null===(o=null===(r=L.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,e;(u=null===(e=null===(t=L.getStore())||void 0===t?void 0:t.getState())||void 0===e?void 0:e.auth)&&!(null==u?void 0:u.isLoading)&&(clearInterval(a),i())}),1);else i()},t.mapAcceptInvitationActions=function(t){return J(t)},t.mapActivateAccountActions=function(t){return J(t)},t.mapApiTokensActions=function(t){return J(t)},t.mapAuthActions=function(t){return J(t)},t.mapForgotPasswordActions=function(t){return J(t)},t.mapLoginActions=function(t){return J("loginWithRedirect"===t?"requestHostedLoginAuthorize":t)},t.mapMfaActions=function(t){return J(t)},t.mapProfileActions=function(t){return J(t)},t.mapSecurityPolicyActions=function(t){return J(t)},t.mapSignupActions=function(t){return J(t)},t.mapSocialLoginActions=function(t){return J(t)},t.mapSsoActions=function(t){return J(t)},t.mapTeamActions=function(t){return J(t)},t.openAdminPortal=function(){return i.AdminPortal.show()},t.useAuthState=tt,t.useFrontegg=function(){var t=Q(),n=Z(),r=tt(),o=nt(),i=et();return e.onBeforeUnmount((function(){n()})),{fronteggLoaded:t,authState:r,fronteggAuth:o,loginWithRedirect:function(){var t;(null===(t=o.router)||void 0===t?void 0:t.currentRoute.path.startsWith(r.routes.hostedLoginRedirectUrl))||(i.dispatch({type:"auth/setState",payload:{isLoading:!0}}),o.loginActions.requestHostedLoginAuthorize())}}},t.useFronteggAuthGuard=function(){var t=nt(),n=e.inject(I),r=tt(),o=e.inject(R),i=et(),u=function(){var e,u,a;u=null===(e=t.router)||void 0===e?void 0:e.currentRoute.path,a=r.routes,Object.values(a).filter((function(t){return t!==a.authenticatedUrl})).includes(u)||r.isAuthenticated||r.isLoading||(n.hostedLoginBox?(i.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.loginActions.requestHostedLoginAuthorize()):o.push(r.routes.loginUrl))};e.onMounted(u),e.onUpdated(u)},t.useFronteggLoaded=Q,t.useUnsubscribeFronteggStore=Z,Object.defineProperty(t,"__esModule",{value:!0}),t}({},Vue,fronteggRestApi,setValue,getValue,js,fronteggReduxStore);
16
+ function S(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}var y=Symbol("fronteggLoade"),m=Symbol("authState"),O=Symbol("unsubscribeFronteggStore"),j=Symbol("fronteggAuth"),R=Symbol("router"),I=Symbol("fronteggOptions"),E=Symbol("fronteggStore"),P=function(t,e){var n;return t.FRONTEGG_STORE_KEY=null!==(n=t.FRONTEGG_STORE_KEY)&&void 0!==n?n:e},T=function(t){return t.FRONTEGG_STORE_KEY},U=function(t){return t.FRONTEGG_REDUX_BINDINGS},L=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(e){t.getInstance().store=e}},{key:"getStore",value:function(){return t.getInstance().store}},{key:"setBasename",value:function(e){t.getInstance().baseName=e}},{key:"getBasename",value:function(){return t.getInstance().baseName}}]),t}(),w=function(t){return function(e){return f.default(e,t)}},k=function(t,e,n){return function(){var r,o=this,i=Object.keys(e),u=f.default(T(o).getState(),t),a=function(t,e,n,r,o){return n.reduce((function(n,i){return Object.assign({},n,v({},e,Object.assign(Object.assign({},n[e]),v({},i,function(t,e,n){return"function"==typeof e?e.bind(t):n(e)}(t,r[i],o)))))}),U(t)||{})}(o,t,i,e,n);return r=a,o.FRONTEGG_REDUX_BINDINGS=r,i.reduce((function(t,r){return Object.assign({},t,v({},r,function(t,e,n,r){return"function"==typeof e?e.call(t,r):n(e)(r)}(o,e[r],n,u)))}),{})}},_=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(e){t.getInstance().actions=e}},{key:"getAction",value:function(e){return t.getInstance().actions[e]}}]),t}(),G=function(){function t(e){var n=this;d(this,t);var r=e.router,i=S(e,["router"]);this.state=o.authInitialState,this.userRef=void 0,this.init=function(t,e){n.store=e,Object.entries({loginActions:o.loginActions,socialLoginsActions:o.socialLoginsActions,activateAccountActions:o.activateAccountActions,acceptInvitationActions:o.acceptInvitationActions,forgotPasswordActions:o.forgotPasswordActions,signUpActions:o.signUpActions,profileActions:o.profileActions,ssoActions:o.ssoActions,mfaActions:o.mfaActions,teamActions:o.teamActions,apiTokensActions:o.apiTokensActions,securityPolicyActions:o.securityPolicyActions,tenantsActions:o.tenantsActions}).forEach((function(t){var e=p(t,2),r=e[0],i=e[1];Object.assign(n,v({},r,o.bindActionCreators(i,n.store.dispatch)))}));var r=o.bindActionCreators(o.authActions,n.store.dispatch);_.setActions(r),t.hostedLoginBox||n.store.subscribe(n.storeSubscriber)},this.storeSubscriber=function(){n.state=n.store.getState().auth;var t=!1;n.state.user!==n.userRef&&(n.userRef=n.state.user,t=!0),n.state.isAuthenticated!==n.isAuthenticatedRef&&(n.isAuthenticatedRef=n.state.isAuthenticated,t=!0),n.userRef&&n.state.isAuthenticated?t&&n.accessTokenUpdater():clearInterval(n.accessTokenUpdaterRef)},this.accessTokenUpdater=function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(n.accessTokenUpdaterRef&&clearInterval(n.accessTokenUpdaterRef),e)n.loginActions.requestAuthorize(!0);else if(n.isAuthenticated){var r=1e3*((null===(t=n.user)||void 0===t?void 0:t.expiresIn)||20)*.8;n.accessTokenUpdaterRef=setInterval(n.loginActions.requestAuthorize,r)}},this._routes=Object.assign(Object.assign({},o.authInitialState.routes),i.routes),this.router=r}return h(t,[{key:"loading",get:function(){var t,e;return null===(e=null===(t=this.store)||void 0===t?void 0:t.getState().auth.isLoading)||void 0===e||e}},{key:"routes",get:function(){var t,e;return null!==(e=null===(t=this.store)||void 0===t?void 0:t.getState().auth.routes)&&void 0!==e?e:this._routes}},{key:"isAuthenticated",get:function(){var t,e;return null!==(e=null===(t=this.store)||void 0===t?void 0:t.getState().auth.isAuthenticated)&&void 0!==e&&e}},{key:"user",get:function(){var t;return null===(t=this.store)||void 0===t?void 0:t.getState().auth.user}}]),t}(),F=function(t,e){return function(){var n=v({},null!=e?e:t.substring("auth.".length),(function(t){return t}));return k(t,n,w).bind(this)()}},N=function(t){return F("auth","authState").bind(t)},C=function(t){return F("auth.loginState").bind(t)},B=function(t){return F("auth.acceptInvitationState").bind(t)},x=function(t){return F("auth.activateState").bind(t)},z=function(t){return F("auth.apiTokensState").bind(t)},H=function(t){return F("auth.forgotPasswordState").bind(t)},q=function(t){return F("auth.mfaState").bind(t)},D=function(t){return F("auth.profileState").bind(t)},W=function(t){return F("auth.securityPolicyState").bind(t)},M=function(t){return F("auth.signUpState").bind(t)},$=function(t){return F("auth.socialLoginState").bind(t)},V=function(t){return F("auth.ssoState").bind(t)},K=function(t){return F("auth.teamState").bind(t)},Y=function(t){return F("auth.tenantsState").bind(t)},X=function(t){Object.assign(t,{mapAuthState:N(t),mapLoginState:C(t),mapAcceptInvitationState:B(t),mapActivateAccountState:x(t),mapApiTokensState:z(t),mapForgotPasswordState:H(t),mapMfaState:q(t),mapProfileState:D(t),mapSecurityPolicyState:W(t),mapSignUpState:M(t),mapSocialLoginState:$(t),mapSsoState:V(t),mapTeamState:K(t),mapTenantsState:Y(t)})},Q=function(t){return function(){return _.getAction(t).apply(void 0,arguments)}},J=function(){return e.inject(y)},Z=function(){return e.inject(O)},tt=function(){return e.inject(m)},et=function(){return e.inject(E)},nt=function(){return e.inject(j)},rt=null,ot={install:function(t,r){var i,a,c=null!=r?r:{},d=c.router,g=S(c,["router"]),h=(null!=r?r:{}).contextOptions;if(null==h)throw Error("contextOptions must be passed to Vue.use(Frontegg, { /* OPTIONS */ })");h.requestCredentials=null!==(i=h.requestCredentials)&&void 0!==i?i:"include",n.ContextHolder.setContext(h);var v,A=!1,w=!1,k="3"===t.version.charAt(0);k&&(v=e.ref(!1));var _=new Set,F=d&&function(t,e){var r=t.options.base||"";L.setBasename(r);var i=function(n,i){var u=n;u.startsWith(r)&&"/"!==r&&(u=u.substring(r.length-1)),((null==i?void 0:i.preserveQueryParams)||o.isAuthRoute(u,e))&&(u="".concat(u).concat(window.location.search)),(null==i?void 0:i.refresh)?window.location.href=u:(null==i?void 0:i.replace)?t.replace(u):t.push(u)};return n.ContextHolder.setOnRedirectTo(i),i}(d,null===(a=null==r?void 0:r.authOptions)||void 0===a?void 0:a.routes),N=(rt=u.initialize(Object.assign(Object.assign({},g),{onRedirectTo:F,basename:null==d?void 0:d.options.base}))).store;L.setStore(N),t.$fronteggApp=rt,t.fronteggAuth||(t.fronteggAuth=new G({router:d}),function(t,e){var n;t.fronteggPlugins=null!==(n=t.fronteggPlugins)&&void 0!==n?n:[],t.fronteggPlugins.push(e)}(t,t.fronteggAuth));var C=function(){var e=(t.fronteggPlugins||[]).reduce((function(t,e){return t&&!e.loading}),!0);if(e!==w){w=e,k&&(v.value=e);var n,r=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=b(t))||e&&t&&"number"==typeof t.length){n&&(t=n);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(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return u=t.done,t},e:function(t){a=!0,i=t},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw i}}}}(_);try{for(r.s();!(n=r.n()).done;){(0,n.value)()}}catch(t){r.e(t)}finally{r.f()}}};null==d||d.getRoutes().map((function(t){var e=t.beforeEnter;t.beforeEnter=function(t,n,r){var o=function(){e?e(t,n,r):r()};if(w)o();else var i=setInterval((function(){C(),w&&(clearInterval(i),o())}),1)}}));var B,x=setInterval((function(){C(),w&&clearInterval(x)}),10),z=function(e){var n,o;if(e.authorizedContent&&(n=e.$route.path,o=t.fronteggAuth.routes,!Object.values(o).filter((function(t){return t!=o.authenticatedUrl})).includes(n))&&(!t.fronteggAuth.loading&&!t.fronteggAuth.isAuthenticated))if(null==r?void 0:r.hostedLoginBox)t.fronteggAuth.loginActions.requestHostedLoginAuthorize();else{var i=t.fronteggAuth.routes.loginUrl;e.$router.push(i)}};function H(){this.$route.path.startsWith(t.fronteggAuth.routes.hostedLoginRedirectUrl)||(N.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.fronteggAuth.loginActions.requestHostedLoginAuthorize())}if(A||(B=t,A=!0,(t.fronteggPlugins||[]).forEach((function(t){return t.init(g,N)})),P(B,N),B.fronteggAuth=t.fronteggAuth,X(B)),k){t.provide(y,v);var q=function(t){var n=t.getState(),r=e.reactive(Object.assign({},n.auth)),o=t.subscribe((function(){var e=t.getState().auth;Object.entries(e).forEach((function(t){var n=p(t,2),o=n[0],i=n[1];r[o]!==e[o]&&(r[o]=i)}))}));return{authState:r,unsubscribe:o}}(N),D=q.authState,W=q.unsubscribe,M=e.reactive(Object.assign({},t.fronteggAuth));t.provide(m,D),t.provide(O,W),t.provide(j,M),t.provide(R,d),t.provide(I,r),t.provide(E,N)}t.mixin({data:function(){return{fronteggLoaded:w}},beforeCreate:function(){P(this,N),this.fronteggAuth=t.fronteggAuth,this.loginWithRedirect=H.bind(this),X(this)},updated:function(){z(this)},mounted:function(){z(this)},created:function(){var t,e;U(this)&&function(t,e){t.FRONTEGG_UNSUBSCRIBE=e}(this,N.subscribe((t=this,e=U(this),function(){var n=T(t).getState();Object.keys(e).forEach((function(r){Object.keys(e[r]).forEach((function(o){var i=e[r][o];if(i){var u,a=i(f.default(n,r)),c=Object.assign({},s);c.default&&(u=2),c.version&&"3"===c.version[0]&&(u=3),3===u&&l.default(t.$data,o,a),2===u&&l.default(t._data,o,a)}}))}))}))),function(t,e){t.FRONTEGG_LOADER_UNSUBSCRIBE=e}(this,function(t){var e=function(){t.fronteggLoaded=w};return _.add(e),function(){return _.delete(e)}}(this))},beforeDestroy:function(){!function(t){var e;null===(e=t.FRONTEGG_UNSUBSCRIBE)||void 0===e||e.call(t)}(this),function(t){var e;null===(e=t.FRONTEGG_LOADER_UNSUBSCRIBE)||void 0===e||e.call(t)}(this)}})}};return Object.defineProperty(t,"ContextHolder",{enumerable:!0,get:function(){return n.ContextHolder}}),Object.defineProperty(t,"AdminPortal",{enumerable:!0,get:function(){return u.AdminPortal}}),t.Frontegg=ot,t.closeAdminPortal=function(){return u.AdminPortal.hide()},t.isAuthenticatedGuard=function(t,e,n){var r,o,i=function(){var e,r=L.getStore().getState().auth;if(r.isAuthenticated)n();else{var o=null!==(e=L.getBasename())&&void 0!==e?e:"",i=o.endsWith("/")?o.substring(0,o.length-1):"";localStorage.setItem("FRONTEGG_AFTER_AUTH_REDIRECT_URL","".concat(i).concat(t.fullPath)),n({path:r.routes.loginUrl,replace:!0})}},u=null===(o=null===(r=L.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,e;(u=null===(e=null===(t=L.getStore())||void 0===t?void 0:t.getState())||void 0===e?void 0:e.auth)&&!(null==u?void 0:u.isLoading)&&(clearInterval(a),i())}),1);else i()},t.mapAcceptInvitationActions=function(t){return Q(t)},t.mapActivateAccountActions=function(t){return Q(t)},t.mapApiTokensActions=function(t){return Q(t)},t.mapAuthActions=function(t){return Q(t)},t.mapForgotPasswordActions=function(t){return Q(t)},t.mapLoginActions=function(t){return Q("loginWithRedirect"===t?"requestHostedLoginAuthorize":t)},t.mapMfaActions=function(t){return Q(t)},t.mapProfileActions=function(t){return Q(t)},t.mapSecurityPolicyActions=function(t){return Q(t)},t.mapSignupActions=function(t){return Q(t)},t.mapSocialLoginActions=function(t){return Q(t)},t.mapSsoActions=function(t){return Q(t)},t.mapTeamActions=function(t){return Q(t)},t.openAdminPortal=function(){return u.AdminPortal.show()},t.useAuthState=tt,t.useFrontegg=function(){var t=J(),n=Z(),r=tt(),o=nt(),i=et();return e.onBeforeUnmount((function(){n()})),{fronteggLoaded:t,authState:r,fronteggAuth:o,loginWithRedirect:function(){var t;(null===(t=o.router)||void 0===t?void 0:t.currentRoute.path.startsWith(r.routes.hostedLoginRedirectUrl))||(i.dispatch({type:"auth/setState",payload:{isLoading:!0}}),o.loginActions.requestHostedLoginAuthorize())}}},t.useFronteggAuthGuard=function(){var t=nt(),n=e.inject(I),r=tt(),o=e.inject(R),i=et(),u=function(){var e,u,a;u=null===(e=t.router)||void 0===e?void 0:e.currentRoute.path,a=r.routes,Object.values(a).filter((function(t){return t!==a.authenticatedUrl})).includes(u)||r.isAuthenticated||r.isLoading||(n.hostedLoginBox?(i.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.loginActions.requestHostedLoginAuthorize()):o.push(r.routes.loginUrl))};e.onMounted(u),e.onUpdated(u)},t.useFronteggLoaded=J,t.useUnsubscribeFronteggStore=Z,Object.defineProperty(t,"__esModule",{value:!0}),t}({},Vue,fronteggRestApi,setValue,fronteggReduxStore,getValue,js);
package/dist/index.ssr.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var Vue=require('vue'),restApi=require('@frontegg/rest-api'),set=require('set-value'),get=require('get-value'),js=require('@frontegg/js'),reduxStore=require('@frontegg/redux-store');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k];}});}});}n['default']=e;return Object.freeze(n);}var Vue__namespace=/*#__PURE__*/_interopNamespace(Vue);var set__default=/*#__PURE__*/_interopDefaultLegacy(set);var get__default=/*#__PURE__*/_interopDefaultLegacy(get);function _classCallCheck(instance, Constructor) {
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var Vue=require('vue'),restApi=require('@frontegg/rest-api'),set=require('set-value'),reduxStore=require('@frontegg/redux-store'),get=require('get-value'),js=require('@frontegg/js');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k];}});}});}n['default']=e;return Object.freeze(n);}var Vue__namespace=/*#__PURE__*/_interopNamespace(Vue);var set__default=/*#__PURE__*/_interopDefaultLegacy(set);var get__default=/*#__PURE__*/_interopDefaultLegacy(get);function _classCallCheck(instance, Constructor) {
2
2
  if (!(instance instanceof Constructor)) {
3
3
  throw new TypeError("Cannot call a class as a function");
4
4
  }
@@ -254,7 +254,7 @@ var registerFronteggPlugin = function registerFronteggPlugin(Vue, plugin) {
254
254
  }]);
255
255
 
256
256
  return StoreHolder;
257
- }();var setupOnRedirectTo = function setupOnRedirectTo(router) {
257
+ }();var setupOnRedirectTo = function setupOnRedirectTo(router, routes) {
258
258
  var baseName = router.options.base || '';
259
259
  StoreHolder.setBasename(baseName);
260
260
 
@@ -265,6 +265,10 @@ var registerFronteggPlugin = function registerFronteggPlugin(Vue, plugin) {
265
265
  path = path.substring(baseName.length - 1);
266
266
  }
267
267
 
268
+ if ((opts === null || opts === void 0 ? void 0 : opts.preserveQueryParams) || reduxStore.isAuthRoute(path, routes)) {
269
+ path = "".concat(path).concat(window.location.search);
270
+ }
271
+
268
272
  if (opts === null || opts === void 0 ? void 0 : opts.refresh) {
269
273
  window.location.href = path;
270
274
  } else {
@@ -752,11 +756,11 @@ var useFronteggAuthGuard = function useFronteggAuthGuard() {
752
756
  };var fronteggApp = null;
753
757
  var Frontegg = {
754
758
  install: function install(Vue$1, options) {
755
- var _a;
759
+ var _a, _b;
756
760
 
757
- var _b = options !== null && options !== void 0 ? options : {},
758
- router = _b.router,
759
- rest = __rest(_b, ["router"]);
761
+ var _c = options !== null && options !== void 0 ? options : {},
762
+ router = _c.router,
763
+ rest = __rest(_c, ["router"]);
760
764
 
761
765
  var _ref = options !== null && options !== void 0 ? options : {},
762
766
  contextOptions = _ref.contextOptions;
@@ -790,7 +794,7 @@ var Frontegg = {
790
794
  };
791
795
  };
792
796
 
793
- var onRedirectTo = router && setupOnRedirectTo(router);
797
+ var onRedirectTo = router && setupOnRedirectTo(router, (_b = options === null || options === void 0 ? void 0 : options.authOptions) === null || _b === void 0 ? void 0 : _b.routes);
794
798
  fronteggApp = js.initialize(Object.assign(Object.assign({}, rest), {
795
799
  onRedirectTo: onRedirectTo,
796
800
  basename: router === null || router === void 0 ? void 0 : router.options.base
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontegg/vue",
3
- "version": "2.0.26-alpha.4702031390",
3
+ "version": "2.0.26-alpha.4718860145",
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.86.0",
25
+ "@frontegg/js": "6.88.0",
26
26
  "get-value": "^3.0.1",
27
27
  "set-value": "^4.0.1"
28
28
  },