@frontegg/vue 3.0.13 → 3.0.14
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/auth/entitlements.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.ssr.js +1 -1
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { EntitledToOptions
|
|
1
|
+
import { EntitledToOptions } from '@frontegg/types';
|
|
2
2
|
/**
|
|
3
3
|
@param key feature key
|
|
4
4
|
@param customAttributes consumer attributes
|
|
5
5
|
@returns if the user is entitled to the given feature. Attaching the justification if not
|
|
6
6
|
@throws when entitlement is not enabled via frontegg options
|
|
7
7
|
*/
|
|
8
|
-
export declare const useFeatureEntitlements: (key: string, customAttributes?: Record<string, string | number | boolean | Date> | undefined) =>
|
|
8
|
+
export declare const useFeatureEntitlements: (key: string, customAttributes?: Record<string, string | number | boolean | Date> | undefined) => any;
|
|
9
9
|
/**
|
|
10
10
|
@param key permission key
|
|
11
11
|
@param customAttributes consumer attributes
|
|
12
12
|
@returns if the user is entitled to the given permission. Attaching the justification if not
|
|
13
13
|
@throws when entitlement is not enabled via frontegg options
|
|
14
14
|
*/
|
|
15
|
-
export declare const usePermissionEntitlements: (key: string, customAttributes?: Record<string, string | number | boolean | Date> | undefined) =>
|
|
15
|
+
export declare const usePermissionEntitlements: (key: string, customAttributes?: Record<string, string | number | boolean | Date> | undefined) => any;
|
|
16
16
|
/**
|
|
17
17
|
@param entitledToOptions - including permission or feature key
|
|
18
18
|
@param customAttributes consumer attributes
|
|
19
19
|
@returns if the user is entitled to the given permission or feature. Attaching the justification if not
|
|
20
20
|
@throws when entitlement is not enabled via frontegg options
|
|
21
21
|
*/
|
|
22
|
-
export declare const useEntitlements: (entitledToOptions: EntitledToOptions, customAttributes?: Record<string, string | number | boolean | Date> | undefined) =>
|
|
22
|
+
export declare const useEntitlements: (entitledToOptions: EntitledToOptions, customAttributes?: Record<string, string | number | boolean | Date> | undefined) => any;
|
package/dist/index.js
CHANGED
package/dist/index.min.js
CHANGED
|
@@ -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 m(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 S=Symbol("fronteggLoade"),y=Symbol("authState"),O=Symbol("unsubscribeFronteggStore"),E=Symbol("fronteggAuth"),j=Symbol("loadEntitlements"),R=Symbol("router"),I=Symbol("fronteggOptions"),T=Symbol("fronteggStore"),P=function(t,e){var n;return t.FRONTEGG_STORE_KEY=null!==(n=t.FRONTEGG_STORE_KEY)&&void 0!==n?n:e},U=function(t){return t.FRONTEGG_STORE_KEY},F=function(t){return t.FRONTEGG_REDUX_BINDINGS},_=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)}},L=function(t,e,n){return function(){var r,o=this,i=Object.keys(e),u=f.default(U(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)))))}),F(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)))}),{})}},k=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}(),N=function(){function t(e){var n=this;d(this,t);var r=e.router,i=m(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);k.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}(),G=function(t,e){return function(){var n=v({},null!=e?e:t.substring("auth.".length),(function(t){return t}));return L(t,n,w).bind(this)()}},C=function(t){return G("auth","authState").bind(t)},B=function(t){return G("auth.loginState").bind(t)},x=function(t){return G("auth.acceptInvitationState").bind(t)},H=function(t){return G("auth.activateState").bind(t)},D=function(t){return G("auth.apiTokensState").bind(t)},V=function(t){return G("auth.forgotPasswordState").bind(t)},z=function(t){return G("auth.mfaState").bind(t)},q=function(t){return G("auth.profileState").bind(t)},M=function(t){return G("auth.securityPolicyState").bind(t)},W=function(t){return G("auth.signUpState").bind(t)},$=function(t){return G("auth.socialLoginState").bind(t)},K=function(t){return G("auth.ssoState").bind(t)},Y=function(t){return G("auth.teamState").bind(t)},X=function(t){return G("auth.tenantsState").bind(t)},Q=function(t){Object.assign(t,{mapAuthState:C(t),mapLoginState:B(t),mapAcceptInvitationState:x(t),mapActivateAccountState:H(t),mapApiTokensState:D(t),mapForgotPasswordState:V(t),mapMfaState:z(t),mapProfileState:q(t),mapSecurityPolicyState:M(t),mapSignUpState:W(t),mapSocialLoginState:$(t),mapSsoState:K(t),mapTeamState:Y(t),mapTenantsState:X(t)})},J=function(t){return function(){return k.getAction(t).apply(void 0,arguments)}},Z=function(){return e.inject(S)},tt=function(){return e.inject(O)},et=function(){return e.inject(y)},nt=function(){return e.inject(T)},rt=function(){return e.inject(E)},ot="3.0.13",it="2.6.12",ut=function(){var t,e;return p((t=[n.USE_ENTITLEMENTS_V2_ENDPOINT_FF],e=nt().appName,n.FeatureFlags.getFeatureFlags(t,e)),1)[0]},at=function(t){var n=e.inject(y).user;return{entitlements:null==n?void 0:n.entitlements,attributes:{custom:t,jwt:n},isV2:ut()}},st=null,ct={install:function(t,r){var i,a,s=null!=r?r:{},d=s.router,g=m(s,["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",h.metadataHeaders={framework:"".concat(n.FronteggFrameworks.Vuejs,"@").concat(it),fronteggSdkVersion:"@frontegg/vuejs@".concat(ot)},n.ContextHolder.setContext(h);var v,A=!1,w=!1,L="3"===t.version.charAt(0);L&&(v=e.ref(!1));var k=new Set,G=d&&function(t,e){var r=t.options.base||"";_.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),C=(st=u.initialize(Object.assign(Object.assign({},g),{onRedirectTo:G,basename:null==d?void 0:d.options.base}))).store;_.setStore(C),t.$fronteggApp=st,t.fronteggAuth||(t.fronteggAuth=new N({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 B=function(){var e=(t.fronteggPlugins||[]).reduce((function(t,e){return t&&!e.loading}),!0);if(e!==w){w=e,L&&(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}}}}(k);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(){B(),w&&(clearInterval(i),o())}),1)}}));var x,H=setInterval((function(){B(),w&&clearInterval(H)}),10),D=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 V(){this.$route.path.startsWith(t.fronteggAuth.routes.hostedLoginRedirectUrl)||(C.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.fronteggAuth.loginActions.requestHostedLoginAuthorize())}A||(x=t,A=!0,(t.fronteggPlugins||[]).forEach((function(t){return t.init(g,C)})),P(x,C),x.fronteggAuth=t.fronteggAuth,Q(x));var z=st.loadEntitlements.bind(st);if(L){t.provide(S,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}}(C),M=q.authState,W=q.unsubscribe,$=e.reactive(Object.assign({},t.fronteggAuth));t.provide(y,M),t.provide(O,W),t.provide(E,$),t.provide(R,d),t.provide(I,r),t.provide(T,C),t.provide(j,z)}t.mixin({data:function(){return{fronteggLoaded:w}},beforeCreate:function(){P(this,C),this.fronteggAuth=t.fronteggAuth,this.loginWithRedirect=V.bind(this),this.getFeatureEntitlements=function(t,e,n){return st.getFeatureEntitlements(e,n)},this.getPermissionEntitlements=function(t,e,n){return st.getPermissionEntitlements(e,n)},this.getEntitlements=function(t,e,n){return st.getEntitlements(e,n)},this.loadEntitlements=z,Q(this)},updated:function(){D(this)},mounted:function(){D(this)},created:function(){var t,e;F(this)&&function(t,e){t.FRONTEGG_UNSUBSCRIBE=e}(this,C.subscribe((t=this,e=F(this),function(){var n=U(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)),s=Object.assign({},c);s.default&&(u=2),s.version&&"3"===s.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 k.add(e),function(){return k.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=ct,t.closeAdminPortal=function(){return u.AdminPortal.hide()},t.isAuthenticatedGuard=function(t,e,n){var r,o,i=function(){var e,r=_.getStore().getState().auth;if(r.isAuthenticated)n();else{var o=null!==(e=_.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=_.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=_.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 u.AdminPortal.show()},t.useAuthState=et,t.useEntitlements=function(t,n){return e.computed((function(){var e=at(n),r=e.entitlements,i=e.attributes,u=e.isV2;return o.getEntitlements(r,t,i,u)}))},t.useFeatureEntitlements=function(t,n){return e.computed((function(){var e=at(n),r=e.entitlements,i=e.attributes,u=e.isV2;return o.getFeatureEntitlements(r,t,i,u)}))},t.useFrontegg=function(){var t=Z(),n=tt(),r=et(),o=rt(),i=e.inject(j),u=nt();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))||(u.dispatch({type:"auth/setState",payload:{isLoading:!0}}),o.loginActions.requestHostedLoginAuthorize())},loadEntitlements:i}},t.useFronteggAuthGuard=function(t){var n=(null!=t?t:{}).redirectUrl,r=rt(),i=e.inject(I),u=et(),a=e.inject(R),s=nt(),c=function(){var t,e,c;e=null===(t=r.router)||void 0===t?void 0:t.currentRoute.path,c=u.routes,Object.values(c).filter((function(t){return t!==c.authenticatedUrl})).includes(e)||u.isAuthenticated||u.isLoading||(i.hostedLoginBox?(s.dispatch({type:"auth/setState",payload:{isLoading:!0}}),n&&localStorage.setItem(o.FRONTEGG_AFTER_AUTH_REDIRECT_URL,n),r.loginActions.requestHostedLoginAuthorize()):a.push(u.routes.loginUrl))};e.onMounted(c),e.onUpdated(c)},t.useFronteggLoaded=Z,t.usePermissionEntitlements=function(t,n){return e.computed((function(){var e=at(n),r=e.entitlements,i=e.attributes,u=e.isV2;return o.getPermissionEntitlements(r,t,i,u)}))},t.useUnsubscribeFronteggStore=tt,Object.defineProperty(t,"__esModule",{value:!0}),t}({},Vue,fronteggRestApi,setValue,fronteggReduxStore,getValue,js);
|
|
16
|
+
function m(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 S=Symbol("fronteggLoade"),y=Symbol("authState"),O=Symbol("unsubscribeFronteggStore"),E=Symbol("fronteggAuth"),j=Symbol("loadEntitlements"),R=Symbol("router"),I=Symbol("fronteggOptions"),T=Symbol("fronteggStore"),P=function(t,e){var n;return t.FRONTEGG_STORE_KEY=null!==(n=t.FRONTEGG_STORE_KEY)&&void 0!==n?n:e},U=function(t){return t.FRONTEGG_STORE_KEY},F=function(t){return t.FRONTEGG_REDUX_BINDINGS},_=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)}},L=function(t,e,n){return function(){var r,o=this,i=Object.keys(e),u=f.default(U(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)))))}),F(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)))}),{})}},k=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}(),N=function(){function t(e){var n=this;d(this,t);var r=e.router,i=m(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);k.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}(),G=function(t,e){return function(){var n=v({},null!=e?e:t.substring("auth.".length),(function(t){return t}));return L(t,n,w).bind(this)()}},C=function(t){return G("auth","authState").bind(t)},B=function(t){return G("auth.loginState").bind(t)},x=function(t){return G("auth.acceptInvitationState").bind(t)},H=function(t){return G("auth.activateState").bind(t)},D=function(t){return G("auth.apiTokensState").bind(t)},V=function(t){return G("auth.forgotPasswordState").bind(t)},z=function(t){return G("auth.mfaState").bind(t)},q=function(t){return G("auth.profileState").bind(t)},M=function(t){return G("auth.securityPolicyState").bind(t)},W=function(t){return G("auth.signUpState").bind(t)},$=function(t){return G("auth.socialLoginState").bind(t)},K=function(t){return G("auth.ssoState").bind(t)},Y=function(t){return G("auth.teamState").bind(t)},X=function(t){return G("auth.tenantsState").bind(t)},Q=function(t){Object.assign(t,{mapAuthState:C(t),mapLoginState:B(t),mapAcceptInvitationState:x(t),mapActivateAccountState:H(t),mapApiTokensState:D(t),mapForgotPasswordState:V(t),mapMfaState:z(t),mapProfileState:q(t),mapSecurityPolicyState:M(t),mapSignUpState:W(t),mapSocialLoginState:$(t),mapSsoState:K(t),mapTeamState:Y(t),mapTenantsState:X(t)})},J=function(t){return function(){return k.getAction(t).apply(void 0,arguments)}},Z=function(){return e.inject(S)},tt=function(){return e.inject(O)},et=function(){return e.inject(y)},nt=function(){return e.inject(T)},rt=function(){return e.inject(E)},ot="3.0.14",it="2.6.12",ut=function(){var t,e;return p((t=[n.USE_ENTITLEMENTS_V2_ENDPOINT_FF],e=nt().appName,n.FeatureFlags.getFeatureFlags(t,e)),1)[0]},at=function(t){var n=e.inject(y).user;return{entitlements:null==n?void 0:n.entitlements,attributes:{custom:t,jwt:n},isV2:ut()}},st=null,ct={install:function(t,r){var i,a,s=null!=r?r:{},d=s.router,g=m(s,["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",h.metadataHeaders={framework:"".concat(n.FronteggFrameworks.Vuejs,"@").concat(it),fronteggSdkVersion:"@frontegg/vuejs@".concat(ot)},n.ContextHolder.setContext(h);var v,A=!1,w=!1,L="3"===t.version.charAt(0);L&&(v=e.ref(!1));var k=new Set,G=d&&function(t,e){var r=t.options.base||"";_.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),C=(st=u.initialize(Object.assign(Object.assign({},g),{onRedirectTo:G,basename:null==d?void 0:d.options.base}))).store;_.setStore(C),t.$fronteggApp=st,t.fronteggAuth||(t.fronteggAuth=new N({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 B=function(){var e=(t.fronteggPlugins||[]).reduce((function(t,e){return t&&!e.loading}),!0);if(e!==w){w=e,L&&(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}}}}(k);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(){B(),w&&(clearInterval(i),o())}),1)}}));var x,H=setInterval((function(){B(),w&&clearInterval(H)}),10),D=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 V(){this.$route.path.startsWith(t.fronteggAuth.routes.hostedLoginRedirectUrl)||(C.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.fronteggAuth.loginActions.requestHostedLoginAuthorize())}A||(x=t,A=!0,(t.fronteggPlugins||[]).forEach((function(t){return t.init(g,C)})),P(x,C),x.fronteggAuth=t.fronteggAuth,Q(x));var z=st.loadEntitlements.bind(st);if(L){t.provide(S,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}}(C),M=q.authState,W=q.unsubscribe,$=e.reactive(Object.assign({},t.fronteggAuth));t.provide(y,M),t.provide(O,W),t.provide(E,$),t.provide(R,d),t.provide(I,r),t.provide(T,C),t.provide(j,z)}t.mixin({data:function(){return{fronteggLoaded:w}},beforeCreate:function(){P(this,C),this.fronteggAuth=t.fronteggAuth,this.loginWithRedirect=V.bind(this),this.getFeatureEntitlements=function(t,e,n){return st.getFeatureEntitlements(e,n)},this.getPermissionEntitlements=function(t,e,n){return st.getPermissionEntitlements(e,n)},this.getEntitlements=function(t,e,n){return st.getEntitlements(e,n)},this.loadEntitlements=z,Q(this)},updated:function(){D(this)},mounted:function(){D(this)},created:function(){var t,e;F(this)&&function(t,e){t.FRONTEGG_UNSUBSCRIBE=e}(this,C.subscribe((t=this,e=F(this),function(){var n=U(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)),s=Object.assign({},c);s.default&&(u=2),s.version&&"3"===s.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 k.add(e),function(){return k.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=ct,t.closeAdminPortal=function(){return u.AdminPortal.hide()},t.isAuthenticatedGuard=function(t,e,n){var r,o,i=function(){var e,r=_.getStore().getState().auth;if(r.isAuthenticated)n();else{var o=null!==(e=_.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=_.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=_.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 u.AdminPortal.show()},t.useAuthState=et,t.useEntitlements=function(t,n){return e.computed((function(){var e=at(n),r=e.entitlements,i=e.attributes,u=e.isV2;return o.getEntitlements(r,t,i,u)}))},t.useFeatureEntitlements=function(t,n){return e.computed((function(){var e=at(n),r=e.entitlements,i=e.attributes,u=e.isV2;return o.getFeatureEntitlements(r,t,i,u)}))},t.useFrontegg=function(){var t=Z(),n=tt(),r=et(),o=rt(),i=e.inject(j),u=nt();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))||(u.dispatch({type:"auth/setState",payload:{isLoading:!0}}),o.loginActions.requestHostedLoginAuthorize())},loadEntitlements:i}},t.useFronteggAuthGuard=function(t){var n=(null!=t?t:{}).redirectUrl,r=rt(),i=e.inject(I),u=et(),a=e.inject(R),s=nt(),c=function(){var t,e,c;e=null===(t=r.router)||void 0===t?void 0:t.currentRoute.path,c=u.routes,Object.values(c).filter((function(t){return t!==c.authenticatedUrl})).includes(e)||u.isAuthenticated||u.isLoading||(i.hostedLoginBox?(s.dispatch({type:"auth/setState",payload:{isLoading:!0}}),n&&localStorage.setItem(o.FRONTEGG_AFTER_AUTH_REDIRECT_URL,n),r.loginActions.requestHostedLoginAuthorize()):a.push(u.routes.loginUrl))};e.onMounted(c),e.onUpdated(c)},t.useFronteggLoaded=Z,t.usePermissionEntitlements=function(t,n){return e.computed((function(){var e=at(n),r=e.entitlements,i=e.attributes,u=e.isV2;return o.getPermissionEntitlements(r,t,i,u)}))},t.useUnsubscribeFronteggStore=tt,Object.defineProperty(t,"__esModule",{value:!0}),t}({},Vue,fronteggRestApi,setValue,fronteggReduxStore,getValue,js);
|
package/dist/index.ssr.js
CHANGED
|
@@ -741,7 +741,7 @@ var useFronteggAuthGuard = function useFronteggAuthGuard(options) {
|
|
|
741
741
|
Vue.onMounted(checkGuard);
|
|
742
742
|
Vue.onUpdated(checkGuard);
|
|
743
743
|
};var sdkVersion = {
|
|
744
|
-
version: '3.0.
|
|
744
|
+
version: '3.0.14'
|
|
745
745
|
};var name = "vue";
|
|
746
746
|
var version = "2.6.12";
|
|
747
747
|
var description = "Reactive, component-oriented view layer for modern web interfaces.";
|