@frontegg/vue 3.0.23 → 3.0.24-alpha.8409641862
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 +9 -29
- package/dist/index.min.js +2 -2
- package/dist/index.ssr.js +10 -32
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Vue from 'vue';
|
|
2
2
|
import { inject, computed, onMounted, onUpdated, reactive, ref } from 'vue';
|
|
3
|
-
import { ContextHolder,
|
|
3
|
+
import { ContextHolder, FronteggFrameworks } from '@frontegg/rest-api';
|
|
4
4
|
export { ContextHolder } from '@frontegg/rest-api';
|
|
5
5
|
import set from 'set-value';
|
|
6
6
|
import { isAuthRoute, authInitialState, loginActions, socialLoginsActions, activateAccountActions, acceptInvitationActions, forgotPasswordActions, signUpActions, profileActions, ssoActions, mfaActions, teamActions, apiTokensActions, securityPolicyActions, tenantsActions, bindActionCreators, authActions, isSteppedUp, defaultFronteggRoutes, FRONTEGG_AFTER_AUTH_REDIRECT_URL, getFeatureEntitlements, getPermissionEntitlements, getEntitlements } from '@frontegg/redux-store';
|
|
@@ -499,12 +499,6 @@ const useIsSteppedUp = options => {
|
|
|
499
499
|
const useStepUp = () => {
|
|
500
500
|
return inject(stepUpKey);
|
|
501
501
|
};
|
|
502
|
-
const useFeatureFlag = keys => {
|
|
503
|
-
const {
|
|
504
|
-
appName
|
|
505
|
-
} = useFronteggStore();
|
|
506
|
-
return FeatureFlags.getFeatureFlags(keys, appName);
|
|
507
|
-
};
|
|
508
502
|
const useFrontegg = () => {
|
|
509
503
|
const fronteggLoaded = useFronteggLoaded();
|
|
510
504
|
const authState = useAuthState();
|
|
@@ -764,33 +758,22 @@ const useGetUserState$1 = () => {
|
|
|
764
758
|
const authState = inject(authStateKey);
|
|
765
759
|
return authState.user;
|
|
766
760
|
};
|
|
767
|
-
/**
|
|
768
|
-
* @returns true when need to use entitlements V2 API
|
|
769
|
-
*/
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
const useIsV2API = () => {
|
|
773
|
-
const [useEntitlementsV2] = useFeatureFlag([USE_ENTITLEMENTS_V2_ENDPOINT_FF]);
|
|
774
|
-
return useEntitlementsV2;
|
|
775
|
-
};
|
|
776
761
|
/**
|
|
777
762
|
* @param customAttributes consumer attributes
|
|
778
|
-
* @returns is entitled query data including:
|
|
763
|
+
* @returns is entitled query data including: entitlements state and final attributes (consumer and frontegg)
|
|
779
764
|
*/
|
|
780
765
|
|
|
781
766
|
|
|
782
767
|
const useEntitlementsQueryData = customAttributes => {
|
|
783
768
|
const user = useGetUserState$1();
|
|
784
769
|
const entitlements = user === null || user === void 0 ? void 0 : user.entitlements;
|
|
785
|
-
const isV2 = useIsV2API();
|
|
786
770
|
const attributes = {
|
|
787
771
|
custom: customAttributes,
|
|
788
772
|
jwt: user
|
|
789
773
|
};
|
|
790
774
|
return {
|
|
791
775
|
entitlements,
|
|
792
|
-
attributes
|
|
793
|
-
isV2
|
|
776
|
+
attributes
|
|
794
777
|
};
|
|
795
778
|
};
|
|
796
779
|
/**
|
|
@@ -805,10 +788,9 @@ const useFeatureEntitlements = (key, customAttributes) => {
|
|
|
805
788
|
return computed(() => {
|
|
806
789
|
const {
|
|
807
790
|
entitlements,
|
|
808
|
-
attributes
|
|
809
|
-
isV2
|
|
791
|
+
attributes
|
|
810
792
|
} = useEntitlementsQueryData(customAttributes);
|
|
811
|
-
return getFeatureEntitlements(entitlements, key, attributes,
|
|
793
|
+
return getFeatureEntitlements(entitlements, key, attributes, true);
|
|
812
794
|
});
|
|
813
795
|
};
|
|
814
796
|
/**
|
|
@@ -822,10 +804,9 @@ const usePermissionEntitlements = (key, customAttributes) => {
|
|
|
822
804
|
return computed(() => {
|
|
823
805
|
const {
|
|
824
806
|
entitlements,
|
|
825
|
-
attributes
|
|
826
|
-
isV2
|
|
807
|
+
attributes
|
|
827
808
|
} = useEntitlementsQueryData(customAttributes);
|
|
828
|
-
return getPermissionEntitlements(entitlements, key, attributes,
|
|
809
|
+
return getPermissionEntitlements(entitlements, key, attributes, true);
|
|
829
810
|
});
|
|
830
811
|
};
|
|
831
812
|
/**
|
|
@@ -839,10 +820,9 @@ const useEntitlements = (entitledToOptions, customAttributes) => {
|
|
|
839
820
|
return computed(() => {
|
|
840
821
|
const {
|
|
841
822
|
entitlements,
|
|
842
|
-
attributes
|
|
843
|
-
isV2
|
|
823
|
+
attributes
|
|
844
824
|
} = useEntitlementsQueryData(customAttributes);
|
|
845
|
-
return getEntitlements(entitlements, entitledToOptions, attributes,
|
|
825
|
+
return getEntitlements(entitlements, entitledToOptions, attributes, true);
|
|
846
826
|
});
|
|
847
827
|
};
|
|
848
828
|
|
package/dist/index.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var FronteggCore=function(t,e,n,r,i,
|
|
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 s(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 c=s(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 v(t,e,n){return e&&g(t.prototype,e),n&&g(t,n),t}function h(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 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 i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}var S=Symbol("fronteggLoade"),y=Symbol("authState"),O=Symbol("unsubscribeFronteggStore"),E=Symbol("fronteggAuth"),R=Symbol("loadEntitlements"),j=Symbol("router"),I=Symbol("fronteggOptions"),U=Symbol("fronteggStore"),T=Symbol("stepUp"),P=function(t,e){var n;return t.FRONTEGG_STORE_KEY=null!==(n=t.FRONTEGG_STORE_KEY)&&void 0!==n?n:e},w=function(t){return t.FRONTEGG_STORE_KEY},F=function(t){return t.FRONTEGG_REDUX_BINDINGS},L=function(){function t(){d(this,t)}return v(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}(),_=function(t){return function(e){return f.default(e,t)}},k=function(t,e,n){return function(){var r,i=this,o=Object.keys(e),u=f.default(w(i).getState(),t),a=function(t,e,n,r,i){return n.reduce((function(n,o){return Object.assign({},n,h({},e,Object.assign(Object.assign({},n[e]),h({},o,function(t,e,n){return"function"==typeof e?e.bind(t):n(e)}(t,r[o],i)))))}),F(t)||{})}(i,t,o,e,n);return r=a,i.FRONTEGG_REDUX_BINDINGS=r,o.reduce((function(t,r){return Object.assign({},t,h({},r,function(t,e,n,r){return"function"==typeof e?e.call(t,r):n(e)(r)}(i,e[r],n,u)))}),{})}},N=function(t){var e,n;return null!==(e=null==t?void 0:t.options.base)&&void 0!==e?e:null===(n=(null==t?void 0:t.options).history)||void 0===n?void 0:n.base},G=function(){function t(){d(this,t)}return v(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}(),C=function(){function t(e){var n=this;d(this,t);var r=e.router,o=m(e,["router"]);this.state=i.authInitialState,this.userRef=void 0,this.init=function(t,e){n.store=e,Object.entries({loginActions:i.loginActions,socialLoginsActions:i.socialLoginsActions,activateAccountActions:i.activateAccountActions,acceptInvitationActions:i.acceptInvitationActions,forgotPasswordActions:i.forgotPasswordActions,signUpActions:i.signUpActions,profileActions:i.profileActions,ssoActions:i.ssoActions,mfaActions:i.mfaActions,teamActions:i.teamActions,apiTokensActions:i.apiTokensActions,securityPolicyActions:i.securityPolicyActions,tenantsActions:i.tenantsActions}).forEach((function(t){var e=p(t,2),r=e[0],o=e[1];Object.assign(n,h({},r,i.bindActionCreators(o,n.store.dispatch)))}));var r=i.bindActionCreators(i.authActions,n.store.dispatch);G.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.getCurrentRoute=function(){var t,e,r,i,o,u,a,s,c,l,f="/";return(null===(e=null===(t=n.router)||void 0===t?void 0:t.currentRoute)||void 0===e?void 0:e.path)&&(f=null===(i=null===(r=n.router)||void 0===r?void 0:r.currentRoute)||void 0===i?void 0:i.path),(null===(a=null===(u=null===(o=n.router)||void 0===o?void 0:o.currentRoute)||void 0===u?void 0:u.value)||void 0===a?void 0:a.fullPath)&&(f=null===(l=null===(c=null===(s=n.router)||void 0===s?void 0:s.currentRoute)||void 0===c?void 0:c.value)||void 0===l?void 0:l.fullPath),f},this.isAuthRoutes=function(t){var e=new URL(t,window.location.origin).pathname;return Object.values(n.routes).filter((function(t){return t!=n.routes.authenticatedUrl})).includes(e)},this._routes=Object.assign(Object.assign({},i.authInitialState.routes),o.routes),this.router=r}return v(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}(),x=function(t,e){return function(){var n=h({},null!=e?e:t.substring("auth.".length),(function(t){return t}));return k(t,n,_).bind(this)()}},B=function(t){return x("auth","authState").bind(t)},H=function(t){return x("auth.loginState").bind(t)},D=function(t){return x("auth.acceptInvitationState").bind(t)},V=function(t){return x("auth.activateState").bind(t)},z=function(t){return x("auth.apiTokensState").bind(t)},q=function(t){return x("auth.forgotPasswordState").bind(t)},M=function(t){return x("auth.mfaState").bind(t)},W=function(t){return x("auth.profileState").bind(t)},$=function(t){return x("auth.securityPolicyState").bind(t)},K=function(t){return x("auth.signUpState").bind(t)},Y=function(t){return x("auth.socialLoginState").bind(t)},X=function(t){return x("auth.ssoState").bind(t)},Q=function(t){return x("auth.teamState").bind(t)},J=function(t){return x("auth.tenantsState").bind(t)},Z=function(t){Object.assign(t,{mapAuthState:B(t),mapLoginState:H(t),mapAcceptInvitationState:D(t),mapActivateAccountState:V(t),mapApiTokensState:z(t),mapForgotPasswordState:q(t),mapMfaState:M(t),mapProfileState:W(t),mapSecurityPolicyState:$(t),mapSignUpState:K(t),mapSocialLoginState:Y(t),mapSsoState:X(t),mapTeamState:Q(t),mapTenantsState:J(t)})},tt=function(t){return function(){return G.getAction(t).apply(void 0,arguments)}},et=function(){return e.inject(S)},nt=function(){return e.inject(y)},rt=function(){return e.inject(U)},it=function(){return e.inject(E)},ot="3.0.23",ut="2.6.12",at=function(){var t,e;return p((t=[n.USE_ENTITLEMENTS_V2_ENDPOINT_FF],e=rt().appName,n.FeatureFlags.getFeatureFlags(t,e)),1)[0]},st=function(t){var n=e.inject(y).user;return{entitlements:null==n?void 0:n.entitlements,attributes:{custom:t,jwt:n},isV2:at()}},ct=null,lt={install:function(t,r){var o,a,s=null!=r?r:{},d=s.router,g=m(s,["router"]),v=(null!=r?r:{}).contextOptions;if(null==v)throw Error("contextOptions must be passed to Vue.use(Frontegg, { /* OPTIONS */ })");v.requestCredentials=null!==(o=v.requestCredentials)&&void 0!==o?o:"include",v.metadataHeaders={framework:"".concat(n.FronteggFrameworks.Vuejs,"@").concat(ut),fronteggSdkVersion:"@frontegg/vuejs@".concat(ot)},n.ContextHolder.setContext(v);var h,A=!1,_=!1,k="3"===t.version.charAt(0);k&&(h=e.ref(!1));var G=new Set,x=d&&function(t,e){var r=N(t)||"";L.setBasename(r);var o=function(n,o){var u=n;u.startsWith(r)&&"/"!==r&&(u=u.substring(r.length-1)),((null==o?void 0:o.preserveQueryParams)||i.isAuthRoute(u,e))&&(u="".concat(u).concat(window.location.search)),(null==o?void 0:o.refresh)?window.location.href=u:(null==o?void 0:o.replace)?t.replace(u):t.push(u)};return n.ContextHolder.setOnRedirectTo(o),o}(d,null===(a=null==r?void 0:r.authOptions)||void 0===a?void 0:a.routes),B=(ct=u.initialize(Object.assign(Object.assign({},g),{onRedirectTo:x,basename:N(d)}))).store;L.setStore(B),t.$fronteggApp=ct,t.fronteggAuth||(t.fronteggAuth=new C({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 H=function(){var e=(t.fronteggPlugins||[]).reduce((function(t,e){return t&&!e.loading}),!0);if(e!==_){_=e,k&&(h.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,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,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,o=t},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw o}}}}(G);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 i=function(){e?e(t,n,r):r()};if(_)i();else var o=setInterval((function(){H(),_&&(clearInterval(o),i())}),1)}}));var D,V=setInterval((function(){H(),_&&clearInterval(V)}),10),z=function(e){if(e.authorizedContent&&!t.fronteggAuth.isAuthRoutes(e.$route.path)&&!t.fronteggAuth.loading&&!t.fronteggAuth.isAuthenticated)if(null==r?void 0:r.hostedLoginBox)t.fronteggAuth.loginActions.requestHostedLoginAuthorize();else{var n=t.fronteggAuth.routes.loginUrl;e.$router.push(n)}};function q(){this.$route.path.startsWith(t.fronteggAuth.routes.hostedLoginRedirectUrl)||(B.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.fronteggAuth.loginActions.requestHostedLoginAuthorize())}A||(D=t,A=!0,(t.fronteggPlugins||[]).forEach((function(t){return t.init(g,B)})),P(D,B),D.fronteggAuth=t.fronteggAuth,Z(D));var M=ct.loadEntitlements.bind(ct),W=ct.stepUp.bind(ct);if(k){t.provide(S,h);var $=function(t){var n=t.getState();if(t.subscribed)return{authState:t.previousAuthState,unsubscribe:t.previousUnsubscribe};var r=e.reactive(Object.assign({},n.auth)),i=t.subscribe((function(){t.subscribed=!0;var e=t.getState().auth;Object.entries(e).forEach((function(t){var n=p(t,2),i=n[0],o=n[1];r[i]!==e[i]&&(r[i]=o)}))})),o=function(){t.subscribed=!1,i()};return t.previousAuthState=r,t.previousUnsubscribe=o,{authState:r,unsubscribe:o}}(B),K=$.authState,Y=$.unsubscribe,X=e.reactive(Object.assign({},t.fronteggAuth));t.provide(y,K),t.provide(O,Y),t.provide(E,X),t.provide(j,d),t.provide(I,r),t.provide(U,B),t.provide(R,M),t.provide(T,W)}t.mixin({data:function(){return{fronteggLoaded:_}},beforeCreate:function(){P(this,B),this.fronteggAuth=t.fronteggAuth,this.loginWithRedirect=q.bind(this),this.getFeatureEntitlements=function(t,e,n){return ct.getFeatureEntitlements(e,n)},this.getPermissionEntitlements=function(t,e,n){return ct.getPermissionEntitlements(e,n)},this.getEntitlements=function(t,e,n){return ct.getEntitlements(e,n)},this.loadEntitlements=M,this.isSteppedUp=function(t){return ct.isSteppedUp()},Z(this)},updated:function(){z(this)},mounted:function(){z(this)},created:function(){var t,e;F(this)&&function(t,e){t.FRONTEGG_UNSUBSCRIBE=e}(this,B.subscribe((t=this,e=F(this),function(){var n=w(t).getState();Object.keys(e).forEach((function(r){Object.keys(e[r]).forEach((function(i){var o=e[r][i];if(o){var u,a=o(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,i,a),2===u&&l.default(t._data,i,a)}}))}))}))),function(t,e){t.FRONTEGG_LOADER_UNSUBSCRIBE=e}(this,function(t){var e=function(){t.fronteggLoaded=_};return G.add(e),function(){return G.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=lt,t.closeAdminPortal=function(){return u.AdminPortal.hide()},t.isAuthenticatedGuard=function(t,e,n){var r,i,o=function(){var e,r=L.getStore().getState().auth;if(r.isAuthenticated)n();else{var i=null!==(e=L.getBasename())&&void 0!==e?e:"",o=i.endsWith("/")?i.substring(0,i.length-1):"";localStorage.setItem("FRONTEGG_AFTER_AUTH_REDIRECT_URL","".concat(o).concat(t.fullPath)),n({path:r.routes.loginUrl,replace:!0})}},u=null===(i=null===(r=L.getStore())||void 0===r?void 0:r.getState())||void 0===i?void 0:i.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),o())}),1);else o()},t.mapAcceptInvitationActions=function(t){return tt(t)},t.mapActivateAccountActions=function(t){return tt(t)},t.mapApiTokensActions=function(t){return tt(t)},t.mapAuthActions=function(t){return tt(t)},t.mapForgotPasswordActions=function(t){return tt(t)},t.mapLoginActions=function(t){return tt("loginWithRedirect"===t?"requestHostedLoginAuthorize":t)},t.mapMfaActions=function(t){return tt(t)},t.mapProfileActions=function(t){return tt(t)},t.mapSecurityPolicyActions=function(t){return tt(t)},t.mapSignupActions=function(t){return tt(t)},t.mapSocialLoginActions=function(t){return tt(t)},t.mapSsoActions=function(t){return tt(t)},t.mapTeamActions=function(t){return tt(t)},t.openAdminPortal=function(){return u.AdminPortal.show()},t.useAuthState=nt,t.useEntitlements=function(t,n){return e.computed((function(){var e=st(n),r=e.entitlements,o=e.attributes,u=e.isV2;return i.getEntitlements(r,t,o,u)}))},t.useFeatureEntitlements=function(t,n){return e.computed((function(){var e=st(n),r=e.entitlements,o=e.attributes,u=e.isV2;return i.getFeatureEntitlements(r,t,o,u)}))},t.useFrontegg=function(){var t=et(),n=nt(),r=it(),o=e.inject(R),u=e.inject(T),a=rt();return{fronteggLoaded:t,authState:n,fronteggAuth:r,loginWithRedirect:function(){var t;r.getCurrentRoute().startsWith(null!==(t=n.routes.hostedLoginRedirectUrl)&&void 0!==t?t:i.defaultFronteggRoutes.hostedLoginRedirectUrl)||(a.dispatch({type:"auth/setState",payload:{isLoading:!0}}),r.loginActions.requestHostedLoginAuthorize())},loadEntitlements:o,stepUp:u}},t.useFronteggAuthGuard=function(t){var n=(null!=t?t:{}).redirectUrl,r=it(),o=e.inject(I),u=nt(),a=e.inject(j),s=rt(),c=function(){var t=r.getCurrentRoute();r.isAuthRoutes(t)||u.isAuthenticated||u.isLoading||(o.hostedLoginBox?(s.dispatch({type:"auth/setState",payload:{isLoading:!0}}),n&&localStorage.setItem(i.FRONTEGG_AFTER_AUTH_REDIRECT_URL,n),r.loginActions.requestHostedLoginAuthorize()):a.push(u.routes.loginUrl))};e.onMounted(c),e.onUpdated(c)},t.useFronteggLoaded=et,t.useIsSteppedUp=function(t){return e.computed((function(){var n=e.inject(y).user;return i.isSteppedUp(n,t)}))},t.usePermissionEntitlements=function(t,n){return e.computed((function(){var e=st(n),r=e.entitlements,o=e.attributes,u=e.isV2;return i.getPermissionEntitlements(r,t,o,u)}))},t.useUnsubscribeFronteggStore=function(){return e.inject(O)},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"),R=Symbol("fronteggAuth"),E=Symbol("loadEntitlements"),j=Symbol("router"),I=Symbol("fronteggOptions"),U=Symbol("fronteggStore"),P=Symbol("stepUp"),T=function(t,e){var n;return t.FRONTEGG_STORE_KEY=null!==(n=t.FRONTEGG_STORE_KEY)&&void 0!==n?n:e},w=function(t){return t.FRONTEGG_STORE_KEY},L=function(t){return t.FRONTEGG_REDUX_BINDINGS},k=function(){function t(){d(this,t)}return v(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}(),_=function(t){return function(e){return f.default(e,t)}},F=function(t,e,n){return function(){var r,o=this,i=Object.keys(e),u=f.default(w(o).getState(),t),a=function(t,e,n,r,o){return n.reduce((function(n,i){return Object.assign({},n,h({},e,Object.assign(Object.assign({},n[e]),h({},i,function(t,e,n){return"function"==typeof e?e.bind(t):n(e)}(t,r[i],o)))))}),L(t)||{})}(o,t,i,e,n);return r=a,o.FRONTEGG_REDUX_BINDINGS=r,i.reduce((function(t,r){return Object.assign({},t,h({},r,function(t,e,n,r){return"function"==typeof e?e.call(t,r):n(e)(r)}(o,e[r],n,u)))}),{})}},G=function(t){var e,n;return null!==(e=null==t?void 0:t.options.base)&&void 0!==e?e:null===(n=(null==t?void 0:t.options).history)||void 0===n?void 0:n.base},C=function(){function t(){d(this,t)}return v(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,h({},r,o.bindActionCreators(i,n.store.dispatch)))}));var r=o.bindActionCreators(o.authActions,n.store.dispatch);C.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.getCurrentRoute=function(){var t,e,r,o,i,u,a,s,c,l,f="/";return(null===(e=null===(t=n.router)||void 0===t?void 0:t.currentRoute)||void 0===e?void 0:e.path)&&(f=null===(o=null===(r=n.router)||void 0===r?void 0:r.currentRoute)||void 0===o?void 0:o.path),(null===(a=null===(u=null===(i=n.router)||void 0===i?void 0:i.currentRoute)||void 0===u?void 0:u.value)||void 0===a?void 0:a.fullPath)&&(f=null===(l=null===(c=null===(s=n.router)||void 0===s?void 0:s.currentRoute)||void 0===c?void 0:c.value)||void 0===l?void 0:l.fullPath),f},this.isAuthRoutes=function(t){var e=new URL(t,window.location.origin).pathname;return Object.values(n.routes).filter((function(t){return t!=n.routes.authenticatedUrl})).includes(e)},this._routes=Object.assign(Object.assign({},o.authInitialState.routes),i.routes),this.router=r}return v(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}(),x=function(t,e){return function(){var n=h({},null!=e?e:t.substring("auth.".length),(function(t){return t}));return F(t,n,_).bind(this)()}},B=function(t){return x("auth","authState").bind(t)},H=function(t){return x("auth.loginState").bind(t)},z=function(t){return x("auth.acceptInvitationState").bind(t)},D=function(t){return x("auth.activateState").bind(t)},q=function(t){return x("auth.apiTokensState").bind(t)},W=function(t){return x("auth.forgotPasswordState").bind(t)},M=function(t){return x("auth.mfaState").bind(t)},V=function(t){return x("auth.profileState").bind(t)},$=function(t){return x("auth.securityPolicyState").bind(t)},K=function(t){return x("auth.signUpState").bind(t)},Y=function(t){return x("auth.socialLoginState").bind(t)},X=function(t){return x("auth.ssoState").bind(t)},Q=function(t){return x("auth.teamState").bind(t)},J=function(t){return x("auth.tenantsState").bind(t)},Z=function(t){Object.assign(t,{mapAuthState:B(t),mapLoginState:H(t),mapAcceptInvitationState:z(t),mapActivateAccountState:D(t),mapApiTokensState:q(t),mapForgotPasswordState:W(t),mapMfaState:M(t),mapProfileState:V(t),mapSecurityPolicyState:$(t),mapSignUpState:K(t),mapSocialLoginState:Y(t),mapSsoState:X(t),mapTeamState:Q(t),mapTenantsState:J(t)})},tt=function(t){return function(){return C.getAction(t).apply(void 0,arguments)}},et=function(){return e.inject(S)},nt=function(){return e.inject(y)},rt=function(){return e.inject(U)},ot=function(){return e.inject(R)},it="3.0.23",ut="2.6.12",at=function(t){var n=e.inject(y).user;return{entitlements:null==n?void 0:n.entitlements,attributes:{custom:t,jwt:n}}},st=null,ct={install:function(t,r){var i,a,s=null!=r?r:{},d=s.router,g=m(s,["router"]),v=(null!=r?r:{}).contextOptions;if(null==v)throw Error("contextOptions must be passed to Vue.use(Frontegg, { /* OPTIONS */ })");v.requestCredentials=null!==(i=v.requestCredentials)&&void 0!==i?i:"include",v.metadataHeaders={framework:"".concat(n.FronteggFrameworks.Vuejs,"@").concat(ut),fronteggSdkVersion:"@frontegg/vuejs@".concat(it)},n.ContextHolder.setContext(v);var h,A=!1,_=!1,F="3"===t.version.charAt(0);F&&(h=e.ref(!1));var C=new Set,x=d&&function(t,e){var r=G(t)||"";k.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),B=(st=u.initialize(Object.assign(Object.assign({},g),{onRedirectTo:x,basename:G(d)}))).store;k.setStore(B),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 H=function(){var e=(t.fronteggPlugins||[]).reduce((function(t,e){return t&&!e.loading}),!0);if(e!==_){_=e,F&&(h.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}}}}(C);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(_)o();else var i=setInterval((function(){H(),_&&(clearInterval(i),o())}),1)}}));var z,D=setInterval((function(){H(),_&&clearInterval(D)}),10),q=function(e){if(e.authorizedContent&&!t.fronteggAuth.isAuthRoutes(e.$route.path)&&!t.fronteggAuth.loading&&!t.fronteggAuth.isAuthenticated)if(null==r?void 0:r.hostedLoginBox)t.fronteggAuth.loginActions.requestHostedLoginAuthorize();else{var n=t.fronteggAuth.routes.loginUrl;e.$router.push(n)}};function W(){this.$route.path.startsWith(t.fronteggAuth.routes.hostedLoginRedirectUrl)||(B.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.fronteggAuth.loginActions.requestHostedLoginAuthorize())}A||(z=t,A=!0,(t.fronteggPlugins||[]).forEach((function(t){return t.init(g,B)})),T(z,B),z.fronteggAuth=t.fronteggAuth,Z(z));var M=st.loadEntitlements.bind(st),V=st.stepUp.bind(st);if(F){t.provide(S,h);var $=function(t){var n=t.getState();if(t.subscribed)return{authState:t.previousAuthState,unsubscribe:t.previousUnsubscribe};var r=e.reactive(Object.assign({},n.auth)),o=t.subscribe((function(){t.subscribed=!0;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)}))})),i=function(){t.subscribed=!1,o()};return t.previousAuthState=r,t.previousUnsubscribe=i,{authState:r,unsubscribe:i}}(B),K=$.authState,Y=$.unsubscribe,X=e.reactive(Object.assign({},t.fronteggAuth));t.provide(y,K),t.provide(O,Y),t.provide(R,X),t.provide(j,d),t.provide(I,r),t.provide(U,B),t.provide(E,M),t.provide(P,V)}t.mixin({data:function(){return{fronteggLoaded:_}},beforeCreate:function(){T(this,B),this.fronteggAuth=t.fronteggAuth,this.loginWithRedirect=W.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=M,this.isSteppedUp=function(t){return st.isSteppedUp()},Z(this)},updated:function(){q(this)},mounted:function(){q(this)},created:function(){var t,e;L(this)&&function(t,e){t.FRONTEGG_UNSUBSCRIBE=e}(this,B.subscribe((t=this,e=L(this),function(){var n=w(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=_};return C.add(e),function(){return C.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=k.getStore().getState().auth;if(r.isAuthenticated)n();else{var o=null!==(e=k.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=k.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=k.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 tt(t)},t.mapActivateAccountActions=function(t){return tt(t)},t.mapApiTokensActions=function(t){return tt(t)},t.mapAuthActions=function(t){return tt(t)},t.mapForgotPasswordActions=function(t){return tt(t)},t.mapLoginActions=function(t){return tt("loginWithRedirect"===t?"requestHostedLoginAuthorize":t)},t.mapMfaActions=function(t){return tt(t)},t.mapProfileActions=function(t){return tt(t)},t.mapSecurityPolicyActions=function(t){return tt(t)},t.mapSignupActions=function(t){return tt(t)},t.mapSocialLoginActions=function(t){return tt(t)},t.mapSsoActions=function(t){return tt(t)},t.mapTeamActions=function(t){return tt(t)},t.openAdminPortal=function(){return u.AdminPortal.show()},t.useAuthState=nt,t.useEntitlements=function(t,n){return e.computed((function(){var e=at(n),r=e.entitlements,i=e.attributes;return o.getEntitlements(r,t,i,!0)}))},t.useFeatureEntitlements=function(t,n){return e.computed((function(){var e=at(n),r=e.entitlements,i=e.attributes;return o.getFeatureEntitlements(r,t,i,!0)}))},t.useFrontegg=function(){var t=et(),n=nt(),r=ot(),i=e.inject(E),u=e.inject(P),a=rt();return{fronteggLoaded:t,authState:n,fronteggAuth:r,loginWithRedirect:function(){var t;r.getCurrentRoute().startsWith(null!==(t=n.routes.hostedLoginRedirectUrl)&&void 0!==t?t:o.defaultFronteggRoutes.hostedLoginRedirectUrl)||(a.dispatch({type:"auth/setState",payload:{isLoading:!0}}),r.loginActions.requestHostedLoginAuthorize())},loadEntitlements:i,stepUp:u}},t.useFronteggAuthGuard=function(t){var n=(null!=t?t:{}).redirectUrl,r=ot(),i=e.inject(I),u=nt(),a=e.inject(j),s=rt(),c=function(){var t=r.getCurrentRoute();r.isAuthRoutes(t)||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=et,t.useIsSteppedUp=function(t){return e.computed((function(){var n=e.inject(y).user;return o.isSteppedUp(n,t)}))},t.usePermissionEntitlements=function(t,n){return e.computed((function(){var e=at(n),r=e.entitlements,i=e.attributes;return o.getPermissionEntitlements(r,t,i,!0)}))},t.useUnsubscribeFronteggStore=function(){return e.inject(O)},Object.defineProperty(t,"__esModule",{value:!0}),t}({},Vue,fronteggRestApi,setValue,fronteggReduxStore,getValue,js);
|
package/dist/index.ssr.js
CHANGED
|
@@ -737,12 +737,6 @@ var useIsSteppedUp = function useIsSteppedUp(options) {
|
|
|
737
737
|
var useStepUp = function useStepUp() {
|
|
738
738
|
return Vue.inject(stepUpKey);
|
|
739
739
|
};
|
|
740
|
-
var useFeatureFlag = function useFeatureFlag(keys) {
|
|
741
|
-
var _useFronteggStore = useFronteggStore(),
|
|
742
|
-
appName = _useFronteggStore.appName;
|
|
743
|
-
|
|
744
|
-
return restApi.FeatureFlags.getFeatureFlags(keys, appName);
|
|
745
|
-
};
|
|
746
740
|
var useFrontegg = function useFrontegg() {
|
|
747
741
|
var fronteggLoaded = useFronteggLoaded();
|
|
748
742
|
var authState = useAuthState();
|
|
@@ -987,7 +981,8 @@ var VuePkg = {
|
|
|
987
981
|
homepage: homepage,
|
|
988
982
|
devDependencies: devDependencies,
|
|
989
983
|
config: config
|
|
990
|
-
}
|
|
984
|
+
};// @ts-ignore
|
|
985
|
+
/**
|
|
991
986
|
* @returns user state
|
|
992
987
|
*/
|
|
993
988
|
|
|
@@ -995,36 +990,22 @@ var useGetUserState$1 = function useGetUserState() {
|
|
|
995
990
|
var authState = Vue.inject(authStateKey);
|
|
996
991
|
return authState.user;
|
|
997
992
|
};
|
|
998
|
-
/**
|
|
999
|
-
* @returns true when need to use entitlements V2 API
|
|
1000
|
-
*/
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
var useIsV2API = function useIsV2API() {
|
|
1004
|
-
var _useFeatureFlag = useFeatureFlag([restApi.USE_ENTITLEMENTS_V2_ENDPOINT_FF]),
|
|
1005
|
-
_useFeatureFlag2 = _slicedToArray(_useFeatureFlag, 1),
|
|
1006
|
-
useEntitlementsV2 = _useFeatureFlag2[0];
|
|
1007
|
-
|
|
1008
|
-
return useEntitlementsV2;
|
|
1009
|
-
};
|
|
1010
993
|
/**
|
|
1011
994
|
* @param customAttributes consumer attributes
|
|
1012
|
-
* @returns is entitled query data including:
|
|
995
|
+
* @returns is entitled query data including: entitlements state and final attributes (consumer and frontegg)
|
|
1013
996
|
*/
|
|
1014
997
|
|
|
1015
998
|
|
|
1016
999
|
var useEntitlementsQueryData = function useEntitlementsQueryData(customAttributes) {
|
|
1017
1000
|
var user = useGetUserState$1();
|
|
1018
1001
|
var entitlements = user === null || user === void 0 ? void 0 : user.entitlements;
|
|
1019
|
-
var isV2 = useIsV2API();
|
|
1020
1002
|
var attributes = {
|
|
1021
1003
|
custom: customAttributes,
|
|
1022
1004
|
jwt: user
|
|
1023
1005
|
};
|
|
1024
1006
|
return {
|
|
1025
1007
|
entitlements: entitlements,
|
|
1026
|
-
attributes: attributes
|
|
1027
|
-
isV2: isV2
|
|
1008
|
+
attributes: attributes
|
|
1028
1009
|
};
|
|
1029
1010
|
};
|
|
1030
1011
|
/**
|
|
@@ -1039,10 +1020,9 @@ var useFeatureEntitlements = function useFeatureEntitlements(key, customAttribut
|
|
|
1039
1020
|
return Vue.computed(function () {
|
|
1040
1021
|
var _useEntitlementsQuery = useEntitlementsQueryData(customAttributes),
|
|
1041
1022
|
entitlements = _useEntitlementsQuery.entitlements,
|
|
1042
|
-
attributes = _useEntitlementsQuery.attributes
|
|
1043
|
-
isV2 = _useEntitlementsQuery.isV2;
|
|
1023
|
+
attributes = _useEntitlementsQuery.attributes;
|
|
1044
1024
|
|
|
1045
|
-
return reduxStore.getFeatureEntitlements(entitlements, key, attributes,
|
|
1025
|
+
return reduxStore.getFeatureEntitlements(entitlements, key, attributes, true);
|
|
1046
1026
|
});
|
|
1047
1027
|
};
|
|
1048
1028
|
/**
|
|
@@ -1056,10 +1036,9 @@ var usePermissionEntitlements = function usePermissionEntitlements(key, customAt
|
|
|
1056
1036
|
return Vue.computed(function () {
|
|
1057
1037
|
var _useEntitlementsQuery2 = useEntitlementsQueryData(customAttributes),
|
|
1058
1038
|
entitlements = _useEntitlementsQuery2.entitlements,
|
|
1059
|
-
attributes = _useEntitlementsQuery2.attributes
|
|
1060
|
-
isV2 = _useEntitlementsQuery2.isV2;
|
|
1039
|
+
attributes = _useEntitlementsQuery2.attributes;
|
|
1061
1040
|
|
|
1062
|
-
return reduxStore.getPermissionEntitlements(entitlements, key, attributes,
|
|
1041
|
+
return reduxStore.getPermissionEntitlements(entitlements, key, attributes, true);
|
|
1063
1042
|
});
|
|
1064
1043
|
};
|
|
1065
1044
|
/**
|
|
@@ -1073,10 +1052,9 @@ var useEntitlements = function useEntitlements(entitledToOptions, customAttribut
|
|
|
1073
1052
|
return Vue.computed(function () {
|
|
1074
1053
|
var _useEntitlementsQuery3 = useEntitlementsQueryData(customAttributes),
|
|
1075
1054
|
entitlements = _useEntitlementsQuery3.entitlements,
|
|
1076
|
-
attributes = _useEntitlementsQuery3.attributes
|
|
1077
|
-
isV2 = _useEntitlementsQuery3.isV2;
|
|
1055
|
+
attributes = _useEntitlementsQuery3.attributes;
|
|
1078
1056
|
|
|
1079
|
-
return reduxStore.getEntitlements(entitlements, entitledToOptions, attributes,
|
|
1057
|
+
return reduxStore.getEntitlements(entitlements, entitledToOptions, attributes, true);
|
|
1080
1058
|
});
|
|
1081
1059
|
};var isAuthenticatedGuard = function isAuthenticatedGuard(_to, _from, next) {
|
|
1082
1060
|
var _a, _b;
|
package/package.json
CHANGED