@frontegg/vue 2.0.12 → 2.0.13-alpha.3705679739
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/mapAuthState.d.ts +20 -2
- package/dist/constants.d.ts +7 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +149 -2
- package/dist/index.min.js +2 -2
- package/dist/index.ssr.js +168 -20
- package/package.json +3 -3
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { AcceptInvitationActions, ActivateAccountActions, ApiTokensActions, ForgotPasswordActions, LoginActions, MfaActions, ProfileActions, SecurityPolicyActions, SignUpActions, SocialLoginActions, SSOActions, TeamActions, TenantsActions, AuthActions } from '@frontegg/redux-store';
|
|
2
|
+
import { AuthState, EnhancedStore } from '@frontegg/redux-store';
|
|
3
|
+
import { FronteggAuthService } from './service';
|
|
2
4
|
export declare const mapAuthState: (_this: any) => () => {};
|
|
3
5
|
export declare const mapLoginState: (_this: any) => () => {};
|
|
4
6
|
export declare const mapAcceptInvitationState: (_this: any) => () => {};
|
|
@@ -15,9 +17,9 @@ export declare const mapTeamState: (_this: any) => () => {};
|
|
|
15
17
|
export declare const mapTenantsState: (_this: any) => () => {};
|
|
16
18
|
export declare const connectMapState: (_this: any) => void;
|
|
17
19
|
declare type MapLoginActions = LoginActions & {
|
|
18
|
-
|
|
20
|
+
loginWithRedirect: LoginActions['requestHostedLoginAuthorize'];
|
|
19
21
|
};
|
|
20
|
-
export declare const mapAuthActions: <K extends "requestHostedLoginAuthorize" | "setState" | "resetState" | "setUser" | "setLoginState" | "resetLoginState" | "requestAuthorize" | "requestAuthorizeSSR" | "handleHostedLoginCallback" | "afterAuthNavigation" | "preLogin" | "postLogin" | "login" | "loginWithMfa" | "recoverMfa" | "logout" | "silentLogout" | "checkIfAllowToRememberMfaDevice" | "changePhoneNumberWithVerification" | "verifyChangePhoneNumber" | "quickSmsPasswordlessPreLogin" | "passwordlessPreLogin" | "passwordlessPostLogin" | "verifyInviteToken" | "webAuthnPrelogin" | "webAuthnPostLogin" | "webAuthnCreateNewDeviceSession" | "webAuthnVerifyNewDeviceSession" | "getUserIP" | "preEnrollMFAWebAuthnForLogin" | "enrollMFAWebAuthnForLogin" | "enrollMFAAuthenticatorAppForLogin" | "preEnrollMFASMSForLogin" | "enrollMFASMSForLogin" | "preVerifyMFAWebAuthnForLogin" | "verifyMFAWebAuthnForLogin" | "preVerifyMFASMSForLogin" | "verifyMFASMSForLogin" | "setSocialLoginsState" | "resetSocialLoginsState" | "loadSocialLoginsConfiguration" | "loadSocialLoginsConfigurationV2" | "loginViaSocialLogin" | "setSocialLoginError" | "setActivateState" | "resetActivateState" | "setActivateStrategyState" | "activateAccount" | "preActivateAccount" | "resendActivationEmail" | "getActivateAccountStrategy" | "setAcceptInvitationState" | "resetAcceptInvitationState" | "acceptInvitation" | "setForgotPasswordState" | "resetForgotPasswordState" | "forgotPassword" | "resetPassword" | "loadPasswordConfig" | "setResetPhoneNumberState" | "resetResetPhoneNumberState" | "resetPhoneNumber" | "verifyResetPhoneNumber" | "changePhoneNumber" | "setSignUpState" | "resetSignUpState" | "signUpUser" | "resetSignUpStateSoft" | "setProfileState" | "resetProfileState" | "loadProfile" | "saveProfile" | "changePassword" | "loadSSOConfigurationsV2" | "saveSSOConfigurationV2" | "updateSSOConfiguration" | "deleteSSOConfiguration" | "deleteSSODomain" | "saveSSODomain" | "validateSSODomainV2" | "setSSODefaultRoles" | "setSSOGroups" | "updateSSOGroups" | "saveSSOConfigurationByMetadata" | "updateSSOConfigurationByMetadata" | "setSSOLoader" | "setSSOError" | "setSSOState" | "resetSSOState" | "loadSSOConfigurations" | "loadSSOAuthorizationRoles" | "saveSSOConfigurations" | "saveSSOConfigurationsFile" | "saveSSOConfigurationsFileWithCallback" | "validateSSODomain" | "updateSSOAuthorizationRoles" | "deleteSamlGroup" | "createSamlGroup" | "oidcPostlogin" | "setMfaState" | "resetMfaState" | "enrollMfa" | "getMFADevices" | "getMFAStrategies" | "verifyMfa" | "verifyMfaAfterForce" | "disableMfa" | "preDisableMfaSms" | "disableMfaSms" | "preEnrollMfaSms" | "enrollMfaSms" | "preEnrollMfaWebAuthn" | "enrollMfaWebAuthn" | "preDisableMfaWebAuthn" | "disableMfaWebAuthn" | "setTeamLoader" | "setTeamError" | "setTeamState" | "resetTeamState" | "loadUsers" | "loadAllSubTenantsUsers" | "loadRoles" | "addUsersBulk" | "addUser" | "addUserToSubTenants" | "setUserRolesForSubTenants" | "updateUser" | "deleteUser" | "deleteUserFromSubTenants" | "lockUser" | "resendActivationLink" | "resendInvitationLink" | "resendInvitationEmail" | "resendInvitationLinkToAllSubTenants" | "getInvitationLink" | "createInvitationLink" | "updateInvitationLink" | "deleteInvitationLink" | "openAddUserDialog" | "closeAddUserDialog" | "openDeleteUserDialog" | "closeDeleteUserDialog" | "openLockUserDialog" | "closeLockUserDialog" | "setApiTokensLoader" | "setApiTokensError" | "setApiTokensState" | "resetApiTokensState" | "loadApiTokens" | "loadUserApiTokens" | "loadTenantApiTokens" | "initApiTokensData" | "addTenantApiToken" | "addUserApiToken" | "deleteUserApiToken" | "deleteTenantApiToken" | "setSecurityPolicyState" | "setSecurityPolicyGlobalState" | "setSecurityPolicyPublicState" | "setSecurityPolicyMfaState" | "setSecurityPolicyVendorMfaState" | "setSecurityPolicyLockoutState" | "setSecurityPolicyCaptchaState" | "setSecurityPolicyPasswordHistoryState" | "resetSecurityPolicyState" | "setSecurityPolicyPasswordState" | "setSecurityPolicyAuthStrategyPublicState" | "loadSecurityPolicy" | "loadPublicSecurityPolicy" | "loadVendorPasswordConfig" | "loadSecurityPolicyMfa" | "loadSecurityPolicyVendorMfa" | "saveSecurityPolicyMfa" | "loadSecurityPolicyLockout" | "saveSecurityPolicyLockout" | "loadSecurityPolicyCaptcha" | "loadSecurityPolicyPasswordHistory" | "saveSecurityPolicyPasswordHistory" | "loadPublicAuthStrategiesPolicy" | "setAccountSettingsState" | "resetAccountSettingsState" | "loadAccountSettings" | "saveAccountSettings" | "setTenantsState" | "resetTenantsState" | "switchTenant" | "loadTenants" | "loadSubTenants" | "loadSubTenantsTree" | "setRolesState" | "resetRolesState" | "loadRolesAndPermissions" | "addRole" | "updateRole" | "deleteRole" | "attachPermissionsToRole" | "attachPermissionToRoles" | "loadUserSessions" | "loadCurrentUserSession" | "setSessionsState" | "resetSessionsState" | "deleteUserSession" | "deleteAllUserSessions" | "revokeUserSessions" | "setRestrictionsState" | "setIpRestrictionsState" | "loadIpRestrictions" | "saveIpRestriction" | "saveIpRestrictionsConfig" | "deleteIpRestriction" | "checkIfUserIpValid" | "addCurrentUserIpAndActivate" | "setEmailDomainRestrictionsState" | "loadEmailDomainRestrictions" | "saveEmailDomainRestriction" | "saveEmailDomainRestrictionsConfig" | "deleteEmailDomainRestriction">(action: K) => AuthActions[K];
|
|
22
|
+
export declare const mapAuthActions: <K extends "requestHostedLoginAuthorize" | "setState" | "resetState" | "setUser" | "setLoginState" | "resetLoginState" | "requestAuthorize" | "requestAuthorizeSSR" | "handleHostedLoginCallback" | "afterAuthNavigation" | "preLogin" | "postLogin" | "login" | "loginWithMfa" | "recoverMfa" | "logout" | "silentLogout" | "checkIfAllowToRememberMfaDevice" | "changePhoneNumberWithVerification" | "verifyChangePhoneNumber" | "quickSmsPasswordlessPreLogin" | "passwordlessPreLogin" | "passwordlessPostLogin" | "verifyInviteToken" | "webAuthnPrelogin" | "webAuthnPostLogin" | "webAuthnCreateNewDeviceSession" | "webAuthnVerifyNewDeviceSession" | "getUserIP" | "preEnrollMFAWebAuthnForLogin" | "enrollMFAWebAuthnForLogin" | "enrollMFAAuthenticatorAppForLogin" | "preEnrollMFASMSForLogin" | "enrollMFASMSForLogin" | "preVerifyMFAWebAuthnForLogin" | "verifyMFAWebAuthnForLogin" | "preVerifyMFASMSForLogin" | "verifyMFASMSForLogin" | "setSocialLoginsState" | "resetSocialLoginsState" | "loadSocialLoginsConfiguration" | "loadSocialLoginsConfigurationV2" | "loginViaSocialLogin" | "setSocialLoginError" | "setActivateState" | "resetActivateState" | "setActivateStrategyState" | "activateAccount" | "preActivateAccount" | "resendActivationEmail" | "getActivateAccountStrategy" | "setAcceptInvitationState" | "resetAcceptInvitationState" | "acceptInvitation" | "setForgotPasswordState" | "resetForgotPasswordState" | "forgotPassword" | "resetPassword" | "loadPasswordConfig" | "setResetPhoneNumberState" | "resetResetPhoneNumberState" | "resetPhoneNumber" | "verifyResetPhoneNumber" | "changePhoneNumber" | "setSignUpState" | "resetSignUpState" | "signUpUser" | "resetSignUpStateSoft" | "setProfileState" | "resetProfileState" | "loadProfile" | "saveProfile" | "changePassword" | "loadSSOConfigurationsV2" | "saveSSOConfigurationV2" | "updateSSOConfiguration" | "deleteSSOConfiguration" | "deleteSSODomain" | "saveSSODomain" | "validateSSODomainV2" | "setSSODefaultRoles" | "setSSOGroups" | "updateSSOGroups" | "saveSSOConfigurationByMetadata" | "updateSSOConfigurationByMetadata" | "setSSOLoader" | "setSSOError" | "setSSOState" | "resetSSOState" | "loadSSOConfigurations" | "loadSSOAuthorizationRoles" | "saveSSOConfigurations" | "saveSSOConfigurationsFile" | "saveSSOConfigurationsFileWithCallback" | "validateSSODomain" | "updateSSOAuthorizationRoles" | "deleteSamlGroup" | "createSamlGroup" | "oidcPostlogin" | "setMfaState" | "resetMfaState" | "enrollMfa" | "getMFADevices" | "getMFAStrategies" | "verifyMfa" | "verifyMfaAfterForce" | "disableMfa" | "preDisableMfaSms" | "disableMfaSms" | "preEnrollMfaSms" | "enrollMfaSms" | "preEnrollMfaWebAuthn" | "enrollMfaWebAuthn" | "preDisableMfaWebAuthn" | "disableMfaWebAuthn" | "setTeamLoader" | "setTeamError" | "setTeamState" | "resetTeamState" | "loadUsers" | "loadAllSubTenantsUsers" | "loadRoles" | "addUsersBulk" | "addUser" | "addUserToSubTenants" | "setUserRolesForSubTenants" | "updateUser" | "deleteUser" | "deleteUserFromSubTenants" | "lockUser" | "resendActivationLink" | "resendInvitationLink" | "resendInvitationEmail" | "resendInvitationLinkToAllSubTenants" | "getInvitationLink" | "createInvitationLink" | "updateInvitationLink" | "deleteInvitationLink" | "openAddUserDialog" | "closeAddUserDialog" | "openDeleteUserDialog" | "closeDeleteUserDialog" | "openLockUserDialog" | "closeLockUserDialog" | "setApiTokensLoader" | "setApiTokensError" | "setApiTokensState" | "resetApiTokensState" | "loadApiTokens" | "loadUserApiTokens" | "loadTenantApiTokens" | "initApiTokensData" | "addTenantApiToken" | "addUserApiToken" | "deleteUserApiToken" | "deleteTenantApiToken" | "setSecurityPolicyState" | "setSecurityPolicyGlobalState" | "setSecurityPolicyPublicState" | "setSecurityPolicyMfaState" | "setSecurityPolicyVendorMfaState" | "setSecurityPolicyLockoutState" | "setSecurityPolicyCaptchaState" | "setSecurityPolicyPasswordHistoryState" | "resetSecurityPolicyState" | "setSecurityPolicyPasswordState" | "setSecurityPolicyAuthStrategyPublicState" | "loadSecurityPolicy" | "loadPublicSecurityPolicy" | "loadVendorPasswordConfig" | "loadSecurityPolicyMfa" | "loadSecurityPolicyVendorMfa" | "saveSecurityPolicyMfa" | "loadSecurityPolicyLockout" | "saveSecurityPolicyLockout" | "loadSecurityPolicyCaptcha" | "loadSecurityPolicyPasswordHistory" | "saveSecurityPolicyPasswordHistory" | "loadPublicAuthStrategiesPolicy" | "setAccountSettingsState" | "resetAccountSettingsState" | "loadAccountSettings" | "saveAccountSettings" | "setTenantsState" | "resetTenantsState" | "switchTenant" | "loadTenants" | "loadSubTenants" | "loadSubTenantsTree" | "setRolesState" | "resetRolesState" | "loadRolesAndPermissions" | "addRole" | "updateRole" | "deleteRole" | "attachPermissionsToRole" | "attachPermissionToRoles" | "loadUserSessions" | "loadCurrentUserSession" | "setSessionsState" | "resetSessionsState" | "deleteUserSession" | "deleteAllUserSessions" | "revokeUserSessions" | "setRestrictionsState" | "setIpRestrictionsState" | "loadIpRestrictions" | "saveIpRestriction" | "saveIpRestrictionsConfig" | "deleteIpRestriction" | "checkIfUserIpValid" | "addCurrentUserIpAndActivate" | "setEmailDomainRestrictionsState" | "loadEmailDomainRestrictions" | "saveEmailDomainRestriction" | "saveEmailDomainRestrictionsConfig" | "deleteEmailDomainRestriction" | "setProvisioningState" | "resetProvisioningState" | "loadProvisionConnections" | "createProvisionConnection" | "deleteProvisionConnection" | "updateProvisionConnection">(action: K) => AuthActions[K];
|
|
21
23
|
export declare const mapLoginActions: <K extends "requestHostedLoginAuthorize" | "setLoginState" | "resetLoginState" | "requestAuthorize" | "requestAuthorizeSSR" | "handleHostedLoginCallback" | "afterAuthNavigation" | "preLogin" | "postLogin" | "login" | "loginWithMfa" | "recoverMfa" | "logout" | "silentLogout" | "checkIfAllowToRememberMfaDevice" | "changePhoneNumberWithVerification" | "verifyChangePhoneNumber" | "quickSmsPasswordlessPreLogin" | "passwordlessPreLogin" | "passwordlessPostLogin" | "verifyInviteToken" | "webAuthnPrelogin" | "webAuthnPostLogin" | "webAuthnCreateNewDeviceSession" | "webAuthnVerifyNewDeviceSession" | "getUserIP" | "preEnrollMFAWebAuthnForLogin" | "enrollMFAWebAuthnForLogin" | "enrollMFAAuthenticatorAppForLogin" | "preEnrollMFASMSForLogin" | "enrollMFASMSForLogin" | "preVerifyMFAWebAuthnForLogin" | "verifyMFAWebAuthnForLogin" | "preVerifyMFASMSForLogin" | "verifyMFASMSForLogin" | "loginWithRedirect">(action: K) => MapLoginActions[K];
|
|
22
24
|
export declare const mapAcceptInvitationActions: <K extends "setAcceptInvitationState" | "resetAcceptInvitationState" | "acceptInvitation">(action: K) => {
|
|
23
25
|
setAcceptInvitationState: (state: Partial<import("@frontegg/redux-store").AcceptInvitationState>) => void;
|
|
@@ -268,4 +270,20 @@ export declare const mapTenantsActions: <K extends "setTenantsState" | "resetTen
|
|
|
268
270
|
callback?: ((data: boolean | null, error?: string | undefined) => void) | undefined;
|
|
269
271
|
} | undefined) => void;
|
|
270
272
|
}[K];
|
|
273
|
+
export declare const connectFronteggStoreV3: (store: EnhancedStore) => {
|
|
274
|
+
authState: any;
|
|
275
|
+
unsubscribe: import("redux").Unsubscribe;
|
|
276
|
+
};
|
|
277
|
+
export declare const useFronteggLoaded: () => boolean;
|
|
278
|
+
export declare const useUnsubscribeFronteggStore: () => () => void;
|
|
279
|
+
export declare const useAuthState: () => AuthState;
|
|
280
|
+
export declare const useFronteggStore: () => any;
|
|
281
|
+
export declare const useFronteggAuth: () => FronteggAuthService;
|
|
282
|
+
export declare const useFrontegg: () => {
|
|
283
|
+
fronteggLoaded: boolean;
|
|
284
|
+
authState: AuthState;
|
|
285
|
+
fronteggAuth: FronteggAuthService;
|
|
286
|
+
loginWithRedirect: () => void;
|
|
287
|
+
};
|
|
288
|
+
export declare const useFronteggAuthGuard: () => void;
|
|
271
289
|
export {};
|
package/dist/constants.d.ts
CHANGED
|
@@ -3,3 +3,10 @@ export declare const FRONTEGG_ACTIONS_KEY = "FRONTEGG_ACTIONS_KEY";
|
|
|
3
3
|
export declare const FRONTEGG_REDUX_BINDINGS = "FRONTEGG_REDUX_BINDINGS";
|
|
4
4
|
export declare const FRONTEGG_UNSUBSCRIBE = "FRONTEGG_UNSUBSCRIBE";
|
|
5
5
|
export declare const FRONTEGG_LOADER_UNSUBSCRIBE = "FRONTEGG_LOADER_UNSUBSCRIBE";
|
|
6
|
+
export declare const fronteggLoadedKey: unique symbol;
|
|
7
|
+
export declare const authStateKey: unique symbol;
|
|
8
|
+
export declare const unsubscribeFronteggStoreKey: unique symbol;
|
|
9
|
+
export declare const fronteggAuthKey: unique symbol;
|
|
10
|
+
export declare const routerKey: unique symbol;
|
|
11
|
+
export declare const fronteggOptionsKey: unique symbol;
|
|
12
|
+
export declare const fronteggStoreKey: unique symbol;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { PluginObject } from 'vue';
|
|
2
2
|
import { PluginOptions } from './interfaces';
|
|
3
3
|
import { AdminPortal } from '@frontegg/js';
|
|
4
|
+
import { ContextHolder } from '@frontegg/rest-api';
|
|
4
5
|
export * from './types';
|
|
5
|
-
export { mapAuthActions, mapLoginActions, mapAcceptInvitationActions, mapActivateAccountActions, mapApiTokensActions, mapForgotPasswordActions, mapMfaActions, mapProfileActions, mapSecurityPolicyActions, mapSignupActions, mapSocialLoginActions, mapSsoActions, mapTeamActions, } from './auth/mapAuthState';
|
|
6
|
+
export { mapAuthActions, mapLoginActions, mapAcceptInvitationActions, mapActivateAccountActions, mapApiTokensActions, mapForgotPasswordActions, mapMfaActions, mapProfileActions, mapSecurityPolicyActions, mapSignupActions, mapSocialLoginActions, mapSsoActions, mapTeamActions, useAuthState, useUnsubscribeFronteggStore, useFronteggLoaded, useFrontegg, useFronteggAuthGuard, } from './auth/mapAuthState';
|
|
6
7
|
export * from './auth/interfaces';
|
|
7
8
|
export * from './auth/guards';
|
|
8
9
|
declare const Frontegg: PluginObject<PluginOptions> | any;
|
|
@@ -20,4 +21,4 @@ declare const openAdminPortal: () => void;
|
|
|
20
21
|
* AdminPortal.hide()
|
|
21
22
|
*/
|
|
22
23
|
declare const closeAdminPortal: () => void;
|
|
23
|
-
export { Frontegg, AdminPortal, openAdminPortal, closeAdminPortal, };
|
|
24
|
+
export { Frontegg, AdminPortal, openAdminPortal, closeAdminPortal, ContextHolder };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import * as Vue from 'vue';
|
|
2
|
+
import { inject, onBeforeUnmount, onMounted, onUpdated, reactive, ref } from 'vue';
|
|
1
3
|
import { ContextHolder } from '@frontegg/rest-api';
|
|
4
|
+
export { ContextHolder } from '@frontegg/rest-api';
|
|
2
5
|
import set from 'set-value';
|
|
3
6
|
import get from 'get-value';
|
|
4
|
-
import * as Vue from 'vue';
|
|
5
7
|
import { initialize, AdminPortal } from '@frontegg/js';
|
|
6
8
|
export { AdminPortal } from '@frontegg/js';
|
|
7
9
|
import { authInitialState, loginActions, socialLoginsActions, activateAccountActions, acceptInvitationActions, forgotPasswordActions, signUpActions, profileActions, ssoActions, mfaActions, teamActions, apiTokensActions, securityPolicyActions, tenantsActions, bindActionCreators, authActions } from '@frontegg/redux-store';
|
|
@@ -37,6 +39,13 @@ const FRONTEGG_STORE_KEY = 'FRONTEGG_STORE_KEY';
|
|
|
37
39
|
const FRONTEGG_REDUX_BINDINGS = 'FRONTEGG_REDUX_BINDINGS';
|
|
38
40
|
const FRONTEGG_UNSUBSCRIBE = 'FRONTEGG_UNSUBSCRIBE';
|
|
39
41
|
const FRONTEGG_LOADER_UNSUBSCRIBE = 'FRONTEGG_LOADER_UNSUBSCRIBE';
|
|
42
|
+
const fronteggLoadedKey = Symbol('fronteggLoade');
|
|
43
|
+
const authStateKey = Symbol('authState');
|
|
44
|
+
const unsubscribeFronteggStoreKey = Symbol('unsubscribeFronteggStore');
|
|
45
|
+
const fronteggAuthKey = Symbol('fronteggAuth');
|
|
46
|
+
const routerKey = Symbol('router');
|
|
47
|
+
const fronteggOptionsKey = Symbol('fronteggOptions');
|
|
48
|
+
const fronteggStoreKey = Symbol('fronteggStore');
|
|
40
49
|
|
|
41
50
|
const setStoreKey = (instance, store) => {
|
|
42
51
|
var _a;
|
|
@@ -300,6 +309,8 @@ class FronteggAuthService {
|
|
|
300
309
|
|
|
301
310
|
}
|
|
302
311
|
|
|
312
|
+
// @ts-ignore
|
|
313
|
+
|
|
303
314
|
const mapSubState = (statePrefix, propertyName) => function () {
|
|
304
315
|
const obj = {
|
|
305
316
|
[propertyName !== null && propertyName !== void 0 ? propertyName : statePrefix.substring('auth.'.length)]: state => state
|
|
@@ -362,6 +373,109 @@ const mapSignupActions = action => actionGetter(action);
|
|
|
362
373
|
const mapSocialLoginActions = action => actionGetter(action);
|
|
363
374
|
const mapSsoActions = action => actionGetter(action);
|
|
364
375
|
const mapTeamActions = action => actionGetter(action);
|
|
376
|
+
const connectFronteggStoreV3 = store => {
|
|
377
|
+
const initialState = store.getState();
|
|
378
|
+
const authState = reactive(Object.assign({}, initialState.auth));
|
|
379
|
+
const unsubscribe = store.subscribe(() => {
|
|
380
|
+
const state = store.getState().auth;
|
|
381
|
+
Object.entries(state).forEach(([key, value]) => {
|
|
382
|
+
if (authState[key] !== state[key]) {
|
|
383
|
+
authState[key] = value;
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
return {
|
|
388
|
+
authState,
|
|
389
|
+
unsubscribe
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
const useFronteggLoaded = () => {
|
|
393
|
+
const fronteggLoaded = inject(fronteggLoadedKey);
|
|
394
|
+
return fronteggLoaded;
|
|
395
|
+
};
|
|
396
|
+
const useUnsubscribeFronteggStore = () => {
|
|
397
|
+
const unsubscribeFronteggStore = inject(unsubscribeFronteggStoreKey);
|
|
398
|
+
return unsubscribeFronteggStore;
|
|
399
|
+
};
|
|
400
|
+
const useAuthState = () => {
|
|
401
|
+
const authState = inject(authStateKey);
|
|
402
|
+
return authState;
|
|
403
|
+
};
|
|
404
|
+
const useFronteggStore = () => {
|
|
405
|
+
const fronteggStore = inject(fronteggStoreKey);
|
|
406
|
+
return fronteggStore;
|
|
407
|
+
};
|
|
408
|
+
const useFronteggAuth = () => {
|
|
409
|
+
const fronteggAuth = inject(fronteggAuthKey);
|
|
410
|
+
return fronteggAuth;
|
|
411
|
+
};
|
|
412
|
+
const useFrontegg = () => {
|
|
413
|
+
const fronteggLoaded = useFronteggLoaded();
|
|
414
|
+
const unsubscribeFronteggStore = useUnsubscribeFronteggStore();
|
|
415
|
+
const authState = useAuthState();
|
|
416
|
+
const fronteggAuth = useFronteggAuth();
|
|
417
|
+
const fronteggStore = useFronteggStore();
|
|
418
|
+
|
|
419
|
+
const loginWithRedirect = () => {
|
|
420
|
+
var _a; // @ts-ignore
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
if (!((_a = fronteggAuth.router) === null || _a === void 0 ? void 0 : _a.currentRoute.path.startsWith(authState.routes.hostedLoginRedirectUrl))) {
|
|
424
|
+
fronteggStore.dispatch({
|
|
425
|
+
type: 'auth/setState',
|
|
426
|
+
payload: {
|
|
427
|
+
isLoading: true
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
fronteggAuth.loginActions.requestHostedLoginAuthorize();
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
onBeforeUnmount(() => {
|
|
435
|
+
unsubscribeFronteggStore();
|
|
436
|
+
});
|
|
437
|
+
return {
|
|
438
|
+
fronteggLoaded,
|
|
439
|
+
authState,
|
|
440
|
+
fronteggAuth,
|
|
441
|
+
loginWithRedirect
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
|
+
const useFronteggAuthGuard = () => {
|
|
445
|
+
const fronteggAuth = useFronteggAuth();
|
|
446
|
+
const fronteggOptions = inject(fronteggOptionsKey);
|
|
447
|
+
const authState = useAuthState();
|
|
448
|
+
const router = inject(routerKey);
|
|
449
|
+
const fronteggStore = useFronteggStore();
|
|
450
|
+
|
|
451
|
+
const isAuthRoutes = path => {
|
|
452
|
+
const {
|
|
453
|
+
routes
|
|
454
|
+
} = authState;
|
|
455
|
+
return Object.values(routes).filter(path => path !== routes.authenticatedUrl).includes(path);
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
const checkGuard = () => {
|
|
459
|
+
var _a;
|
|
460
|
+
|
|
461
|
+
if (!isAuthRoutes((_a = fronteggAuth.router) === null || _a === void 0 ? void 0 : _a.currentRoute.path) && !authState.isAuthenticated && !authState.isLoading) {
|
|
462
|
+
if (fronteggOptions.hostedLoginBox) {
|
|
463
|
+
fronteggStore.dispatch({
|
|
464
|
+
type: 'auth/setState',
|
|
465
|
+
payload: {
|
|
466
|
+
isLoading: true
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
fronteggAuth.loginActions.requestHostedLoginAuthorize();
|
|
470
|
+
} else {
|
|
471
|
+
router.push(authState.routes.loginUrl);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
onMounted(checkGuard);
|
|
477
|
+
onUpdated(checkGuard);
|
|
478
|
+
};
|
|
365
479
|
|
|
366
480
|
const isAuthenticatedGuard = function (_to, _from, next) {
|
|
367
481
|
var _a, _b;
|
|
@@ -427,6 +541,13 @@ const Frontegg = {
|
|
|
427
541
|
let pluginRegistered = false; // frontegg loader subscription
|
|
428
542
|
|
|
429
543
|
let fronteggLoaded = false;
|
|
544
|
+
const isVue3 = Vue.version.charAt(0) === '3';
|
|
545
|
+
let fronteggLoadedV3;
|
|
546
|
+
|
|
547
|
+
if (isVue3) {
|
|
548
|
+
fronteggLoadedV3 = ref(false);
|
|
549
|
+
}
|
|
550
|
+
|
|
430
551
|
const fronteggLoadedSubscribes = new Set();
|
|
431
552
|
|
|
432
553
|
const fronteggLoadedSubscribe = instance => {
|
|
@@ -469,6 +590,10 @@ const Frontegg = {
|
|
|
469
590
|
if (_fronteggLoaded !== fronteggLoaded) {
|
|
470
591
|
fronteggLoaded = _fronteggLoaded;
|
|
471
592
|
|
|
593
|
+
if (isVue3) {
|
|
594
|
+
fronteggLoadedV3.value = _fronteggLoaded;
|
|
595
|
+
}
|
|
596
|
+
|
|
472
597
|
for (const subscriber of fronteggLoadedSubscribes) {
|
|
473
598
|
subscriber();
|
|
474
599
|
}
|
|
@@ -553,6 +678,28 @@ const Frontegg = {
|
|
|
553
678
|
}
|
|
554
679
|
}
|
|
555
680
|
|
|
681
|
+
if (isVue3) {
|
|
682
|
+
// @ts-ignore - provide will exist only in vue 3 app
|
|
683
|
+
Vue.provide(fronteggLoadedKey, fronteggLoadedV3);
|
|
684
|
+
const {
|
|
685
|
+
authState,
|
|
686
|
+
unsubscribe
|
|
687
|
+
} = connectFronteggStoreV3(store);
|
|
688
|
+
const fronteggAuthReactive = reactive(Object.assign({}, Vue.fronteggAuth)); // @ts-ignore
|
|
689
|
+
|
|
690
|
+
Vue.provide(authStateKey, authState); // @ts-ignore
|
|
691
|
+
|
|
692
|
+
Vue.provide(unsubscribeFronteggStoreKey, unsubscribe); // @ts-ignore
|
|
693
|
+
|
|
694
|
+
Vue.provide(fronteggAuthKey, fronteggAuthReactive); // @ts-ignore
|
|
695
|
+
|
|
696
|
+
Vue.provide(routerKey, router); // @ts-ignore
|
|
697
|
+
|
|
698
|
+
Vue.provide(fronteggOptionsKey, options); // @ts-ignore
|
|
699
|
+
|
|
700
|
+
Vue.provide(fronteggStoreKey, store);
|
|
701
|
+
}
|
|
702
|
+
|
|
556
703
|
Vue.mixin({
|
|
557
704
|
data: () => ({
|
|
558
705
|
fronteggLoaded
|
|
@@ -608,4 +755,4 @@ const openAdminPortal = () => AdminPortal.show();
|
|
|
608
755
|
|
|
609
756
|
const closeAdminPortal = () => AdminPortal.hide();
|
|
610
757
|
|
|
611
|
-
export { Frontegg, closeAdminPortal, isAuthenticatedGuard, mapAcceptInvitationActions, mapActivateAccountActions, mapApiTokensActions, mapAuthActions, mapForgotPasswordActions, mapLoginActions, mapMfaActions, mapProfileActions, mapSecurityPolicyActions, mapSignupActions, mapSocialLoginActions, mapSsoActions, mapTeamActions, openAdminPortal };
|
|
758
|
+
export { Frontegg, closeAdminPortal, isAuthenticatedGuard, mapAcceptInvitationActions, mapActivateAccountActions, mapApiTokensActions, mapAuthActions, mapForgotPasswordActions, mapLoginActions, mapMfaActions, mapProfileActions, mapSecurityPolicyActions, mapSignupActions, mapSocialLoginActions, mapSsoActions, mapTeamActions, openAdminPortal, useAuthState, useFrontegg, useFronteggAuthGuard, useFronteggLoaded, useUnsubscribeFronteggStore };
|
package/dist/index.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var FronteggCore=function(t,n,
|
|
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}
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -13,4 +13,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
function S(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e}var y=function(t,n){var e;return t.FRONTEGG_STORE_KEY=null!==(e=t.FRONTEGG_STORE_KEY)&&void 0!==e?e:n},m=function(t){return t.FRONTEGG_STORE_KEY},O=function(t){return t.FRONTEGG_REDUX_BINDINGS},R=function(){function t(){d(this,t)}return h(t,null,[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}},{key:"setStore",value:function(n){t.getInstance().store=n}},{key:"getStore",value:function(){return t.getInstance().store}},{key:"setBasename",value:function(n){t.getInstance().baseName=n}},{key:"getBasename",value:function(){return t.getInstance().baseName}}]),t}(),I=function(t){return function(n){return f.default(n,t)}},E=function(t,n,e){return function(){var r,o=this,i=Object.keys(n),u=f.default(m(o).getState(),t),a=function(t,n,e,r,o){return e.reduce((function(e,i){return Object.assign({},e,v({},n,Object.assign(Object.assign({},e[n]),v({},i,function(t,n,e){return"function"==typeof n?n.bind(t):e(n)}(t,r[i],o)))))}),O(t)||{})}(o,t,i,n,e);return r=a,o.FRONTEGG_REDUX_BINDINGS=r,i.reduce((function(t,r){return Object.assign({},t,v({},r,function(t,n,e,r){return"function"==typeof n?n.call(t,r):e(n)(r)}(o,n[r],e,u)))}),{})}},j=function(){function t(){d(this,t)}return h(t,null,[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}},{key:"setActions",value:function(n){t.getInstance().actions=n}},{key:"getAction",value:function(n){return t.getInstance().actions[n]}}]),t}(),T=function(){function t(n){var e=this;d(this,t);var r=n.router,o=S(n,["router"]);this.state=u.authInitialState,this.userRef=void 0,this.init=function(t,n){e.store=n,Object.entries({loginActions:u.loginActions,socialLoginsActions:u.socialLoginsActions,activateAccountActions:u.activateAccountActions,acceptInvitationActions:u.acceptInvitationActions,forgotPasswordActions:u.forgotPasswordActions,signUpActions:u.signUpActions,profileActions:u.profileActions,ssoActions:u.ssoActions,mfaActions:u.mfaActions,teamActions:u.teamActions,apiTokensActions:u.apiTokensActions,securityPolicyActions:u.securityPolicyActions,tenantsActions:u.tenantsActions}).forEach((function(t){var n=p(t,2),r=n[0],o=n[1];Object.assign(e,v({},r,u.bindActionCreators(o,e.store.dispatch)))}));var r=u.bindActionCreators(u.authActions,e.store.dispatch);j.setActions(r),t.hostedLoginBox||e.store.subscribe(e.storeSubscriber)},this.storeSubscriber=function(){e.state=e.store.getState().auth;var t=!1;e.state.user!==e.userRef&&(e.userRef=e.state.user,t=!0),e.state.isAuthenticated!==e.isAuthenticatedRef&&(e.isAuthenticatedRef=e.state.isAuthenticated,t=!0),e.userRef&&e.state.isAuthenticated?t&&e.accessTokenUpdater():clearInterval(e.accessTokenUpdaterRef)},this.accessTokenUpdater=function(){var t,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(e.accessTokenUpdaterRef&&clearInterval(e.accessTokenUpdaterRef),n)e.loginActions.requestAuthorize(!0);else if(e.isAuthenticated){var r=1e3*((null===(t=e.user)||void 0===t?void 0:t.expiresIn)||20)*.8;e.accessTokenUpdaterRef=setInterval(e.loginActions.requestAuthorize,r)}},this._routes=Object.assign(Object.assign({},u.authInitialState.routes),o.routes),this.router=r}return h(t,[{key:"loading",get:function(){var t,n;return null===(n=null===(t=this.store)||void 0===t?void 0:t.getState().auth.isLoading)||void 0===n||n}},{key:"routes",get:function(){var t,n;return null!==(n=null===(t=this.store)||void 0===t?void 0:t.getState().auth.routes)&&void 0!==n?n:this._routes}},{key:"isAuthenticated",get:function(){var t,n;return null!==(n=null===(t=this.store)||void 0===t?void 0:t.getState().auth.isAuthenticated)&&void 0!==n&&n}},{key:"user",get:function(){var t;return null===(t=this.store)||void 0===t?void 0:t.getState().auth.user}}]),t}(),P=function(t,n){return function(){var e=v({},null!=n?n:t.substring("auth.".length),(function(t){return t}));return E(t,e,I).bind(this)()}},w=function(t){return P("auth","authState").bind(t)},k=function(t){return P("auth.loginState").bind(t)},U=function(t){return P("auth.acceptInvitationState").bind(t)},_=function(t){return P("auth.activateState").bind(t)},G=function(t){return P("auth.apiTokensState").bind(t)},L=function(t){return P("auth.forgotPasswordState").bind(t)},N=function(t){return P("auth.mfaState").bind(t)},C=function(t){return P("auth.profileState").bind(t)},B=function(t){return P("auth.securityPolicyState").bind(t)},F=function(t){return P("auth.signUpState").bind(t)},x=function(t){return P("auth.socialLoginState").bind(t)},D=function(t){return P("auth.ssoState").bind(t)},z=function(t){return P("auth.teamState").bind(t)},q=function(t){return P("auth.tenantsState").bind(t)},H=function(t){Object.assign(t,{mapAuthState:w(t),mapLoginState:k(t),mapAcceptInvitationState:U(t),mapActivateAccountState:_(t),mapApiTokensState:G(t),mapForgotPasswordState:L(t),mapMfaState:N(t),mapProfileState:C(t),mapSecurityPolicyState:B(t),mapSignUpState:F(t),mapSocialLoginState:x(t),mapSsoState:D(t),mapTeamState:z(t),mapTenantsState:q(t)})},$=function(t){return function(){return j.getAction(t).apply(void 0,arguments)}},M=null,W={install:function(t,e){var r,o=null!=e?e:{},u=o.router,a=S(o,["router"]),c=(null!=e?e:{}).contextOptions;if(null==c)throw Error("contextOptions must be passed to Vue.use(Frontegg, { /* OPTIONS */ })");c.requestCredentials=null!==(r=c.requestCredentials)&&void 0!==r?r:"include",n.ContextHolder.setContext(c);var d=!1,g=!1,h=new Set,v=u&&function(t){var e=t.options.base||"";R.setBasename(e);var r=function(n,r){var o=n;o.startsWith(e)&&"/"!==e&&(o=o.substring(e.length-1)),(null==r?void 0:r.refresh)?window.location.href=o:(null==r?void 0:r.replace)?t.replace(o):t.push(o)};return n.ContextHolder.setOnRedirectTo(r),r}(u),p=(M=i.initialize(Object.assign(Object.assign({},a),{onRedirectTo:v,basename:null==u?void 0:u.options.base}))).store;R.setStore(p),t.$fronteggApp=M,t.fronteggAuth||(t.fronteggAuth=new T({router:u}),function(t,n){var e;t.fronteggPlugins=null!==(e=t.fronteggPlugins)&&void 0!==e?e:[],t.fronteggPlugins.push(n)}(t,t.fronteggAuth));var b=function(){var n=(t.fronteggPlugins||[]).reduce((function(t,n){return t&&!n.loading}),!0);if(n!==g){g=n;var e,r=function(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=A(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,a=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return u=t.done,t},e:function(t){a=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(a)throw i}}}}(h);try{for(r.s();!(e=r.n()).done;){(0,e.value)()}}catch(t){r.e(t)}finally{r.f()}}};null==u||u.getRoutes().map((function(t){var n=t.beforeEnter;t.beforeEnter=function(t,e,r){var o=function(){n?n(t,e,r):r()};if(g)o();else var i=setInterval((function(){b(),g&&(clearInterval(i),o())}),1)}}));var I,E=setInterval((function(){b(),g&&clearInterval(E)}),10),j=function(n){var r,o;if(n.authorizedContent&&(r=n.$route.path,o=t.fronteggAuth.routes,!Object.values(o).filter((function(t){return t!=o.authenticatedUrl})).includes(r))&&(!t.fronteggAuth.loading&&!t.fronteggAuth.isAuthenticated))if(null==e?void 0:e.hostedLoginBox)t.fronteggAuth.loginActions.requestHostedLoginAuthorize();else{var i=t.fronteggAuth.routes.loginUrl;n.$router.push(i)}};function P(){this.$route.path.startsWith(t.fronteggAuth.routes.hostedLoginRedirectUrl)||(p.dispatch({type:"auth/setState",payload:{isLoading:!0}}),t.fronteggAuth.loginActions.requestHostedLoginAuthorize())}d||(I=t,d=!0,(t.fronteggPlugins||[]).forEach((function(t){return t.init(a,p)})),y(I,p),I.fronteggAuth=t.fronteggAuth,H(I)),t.mixin({data:function(){return{fronteggLoaded:g}},beforeCreate:function(){y(this,p),this.fronteggAuth=t.fronteggAuth,this.loginWithRedirect=P.bind(this),H(this)},updated:function(){j(this)},mounted:function(){j(this)},created:function(){var t,n;O(this)&&function(t,n){t.FRONTEGG_UNSUBSCRIBE=n}(this,p.subscribe((t=this,n=O(this),function(){var e=m(t).getState();Object.keys(n).forEach((function(r){Object.keys(n[r]).forEach((function(o){var i=n[r][o];if(i){var u,a=i(f.default(e,r)),c=Object.assign({},l);c.default&&(u=2),c.version&&"3"===c.version[0]&&(u=3),3===u&&s.default(t.$data,o,a),2===u&&s.default(t._data,o,a)}}))}))}))),function(t,n){t.FRONTEGG_LOADER_UNSUBSCRIBE=n}(this,function(t){var n=function(){t.fronteggLoaded=g};return h.add(n),function(){return h.delete(n)}}(this))},beforeDestroy:function(){!function(t){var n;null===(n=t.FRONTEGG_UNSUBSCRIBE)||void 0===n||n.call(t)}(this),function(t){var n;null===(n=t.FRONTEGG_LOADER_UNSUBSCRIBE)||void 0===n||n.call(t)}(this)}})}};return Object.defineProperty(t,"AdminPortal",{enumerable:!0,get:function(){return i.AdminPortal}}),t.Frontegg=W,t.closeAdminPortal=function(){return i.AdminPortal.hide()},t.isAuthenticatedGuard=function(t,n,e){var r,o,i=function(){var n,r=R.getStore().getState().auth;if(r.isAuthenticated)e();else{var o=null!==(n=R.getBasename())&&void 0!==n?n:"",i=o.endsWith("/")?o.substring(0,o.length-1):"";localStorage.setItem("FRONTEGG_AFTER_AUTH_REDIRECT_URL","".concat(i).concat(t.fullPath)),e({path:r.routes.loginUrl,replace:!0})}},u=null===(o=null===(r=R.getStore())||void 0===r?void 0:r.getState())||void 0===o?void 0:o.auth;if(!u||(null==u?void 0:u.isLoading))var a=setInterval((function(){var t,n;(u=null===(n=null===(t=R.getStore())||void 0===t?void 0:t.getState())||void 0===n?void 0:n.auth)&&!(null==u?void 0:u.isLoading)&&(clearInterval(a),i())}),1);else i()},t.mapAcceptInvitationActions=function(t){return $(t)},t.mapActivateAccountActions=function(t){return $(t)},t.mapApiTokensActions=function(t){return $(t)},t.mapAuthActions=function(t){return $(t)},t.mapForgotPasswordActions=function(t){return $(t)},t.mapLoginActions=function(t){return $("loginWithRedirect"===t?"requestHostedLoginAuthorize":t)},t.mapMfaActions=function(t){return $(t)},t.mapProfileActions=function(t){return $(t)},t.mapSecurityPolicyActions=function(t){return $(t)},t.mapSignupActions=function(t){return $(t)},t.mapSocialLoginActions=function(t){return $(t)},t.mapSsoActions=function(t){return $(t)},t.mapTeamActions=function(t){return $(t)},t.openAdminPortal=function(){return i.AdminPortal.show()},Object.defineProperty(t,"__esModule",{value:!0}),t}({},fronteggRestApi,setValue,getValue,Vue,js,fronteggReduxStore);
|
|
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);
|
package/dist/index.ssr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var restApi=require('@frontegg/rest-api'),set=require('set-value'),get=require('get-value'),
|
|
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) {
|
|
2
2
|
if (!(instance instanceof Constructor)) {
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
@@ -174,7 +174,14 @@ function __rest(s, e) {
|
|
|
174
174
|
}var FRONTEGG_STORE_KEY = 'FRONTEGG_STORE_KEY';
|
|
175
175
|
var FRONTEGG_REDUX_BINDINGS = 'FRONTEGG_REDUX_BINDINGS';
|
|
176
176
|
var FRONTEGG_UNSUBSCRIBE = 'FRONTEGG_UNSUBSCRIBE';
|
|
177
|
-
var FRONTEGG_LOADER_UNSUBSCRIBE = 'FRONTEGG_LOADER_UNSUBSCRIBE';
|
|
177
|
+
var FRONTEGG_LOADER_UNSUBSCRIBE = 'FRONTEGG_LOADER_UNSUBSCRIBE';
|
|
178
|
+
var fronteggLoadedKey = Symbol('fronteggLoade');
|
|
179
|
+
var authStateKey = Symbol('authState');
|
|
180
|
+
var unsubscribeFronteggStoreKey = Symbol('unsubscribeFronteggStore');
|
|
181
|
+
var fronteggAuthKey = Symbol('fronteggAuth');
|
|
182
|
+
var routerKey = Symbol('router');
|
|
183
|
+
var fronteggOptionsKey = Symbol('fronteggOptions');
|
|
184
|
+
var fronteggStoreKey = Symbol('fronteggStore');var setStoreKey = function setStoreKey(instance, store) {
|
|
178
185
|
var _a;
|
|
179
186
|
|
|
180
187
|
return instance[FRONTEGG_STORE_KEY] = (_a = instance[FRONTEGG_STORE_KEY]) !== null && _a !== void 0 ? _a : store;
|
|
@@ -597,6 +604,113 @@ var mapSsoActions = function mapSsoActions(action) {
|
|
|
597
604
|
};
|
|
598
605
|
var mapTeamActions = function mapTeamActions(action) {
|
|
599
606
|
return actionGetter(action);
|
|
607
|
+
};
|
|
608
|
+
var connectFronteggStoreV3 = function connectFronteggStoreV3(store) {
|
|
609
|
+
var initialState = store.getState();
|
|
610
|
+
var authState = Vue.reactive(Object.assign({}, initialState.auth));
|
|
611
|
+
var unsubscribe = store.subscribe(function () {
|
|
612
|
+
var state = store.getState().auth;
|
|
613
|
+
Object.entries(state).forEach(function (_ref) {
|
|
614
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
615
|
+
key = _ref2[0],
|
|
616
|
+
value = _ref2[1];
|
|
617
|
+
|
|
618
|
+
if (authState[key] !== state[key]) {
|
|
619
|
+
authState[key] = value;
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
return {
|
|
624
|
+
authState: authState,
|
|
625
|
+
unsubscribe: unsubscribe
|
|
626
|
+
};
|
|
627
|
+
};
|
|
628
|
+
var useFronteggLoaded = function useFronteggLoaded() {
|
|
629
|
+
var fronteggLoaded = Vue.inject(fronteggLoadedKey);
|
|
630
|
+
return fronteggLoaded;
|
|
631
|
+
};
|
|
632
|
+
var useUnsubscribeFronteggStore = function useUnsubscribeFronteggStore() {
|
|
633
|
+
var unsubscribeFronteggStore = Vue.inject(unsubscribeFronteggStoreKey);
|
|
634
|
+
return unsubscribeFronteggStore;
|
|
635
|
+
};
|
|
636
|
+
var useAuthState = function useAuthState() {
|
|
637
|
+
var authState = Vue.inject(authStateKey);
|
|
638
|
+
return authState;
|
|
639
|
+
};
|
|
640
|
+
var useFronteggStore = function useFronteggStore() {
|
|
641
|
+
var fronteggStore = Vue.inject(fronteggStoreKey);
|
|
642
|
+
return fronteggStore;
|
|
643
|
+
};
|
|
644
|
+
var useFronteggAuth = function useFronteggAuth() {
|
|
645
|
+
var fronteggAuth = Vue.inject(fronteggAuthKey);
|
|
646
|
+
return fronteggAuth;
|
|
647
|
+
};
|
|
648
|
+
var useFrontegg = function useFrontegg() {
|
|
649
|
+
var fronteggLoaded = useFronteggLoaded();
|
|
650
|
+
var unsubscribeFronteggStore = useUnsubscribeFronteggStore();
|
|
651
|
+
var authState = useAuthState();
|
|
652
|
+
var fronteggAuth = useFronteggAuth();
|
|
653
|
+
var fronteggStore = useFronteggStore();
|
|
654
|
+
|
|
655
|
+
var loginWithRedirect = function loginWithRedirect() {
|
|
656
|
+
var _a; // @ts-ignore
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
if (!((_a = fronteggAuth.router) === null || _a === void 0 ? void 0 : _a.currentRoute.path.startsWith(authState.routes.hostedLoginRedirectUrl))) {
|
|
660
|
+
fronteggStore.dispatch({
|
|
661
|
+
type: 'auth/setState',
|
|
662
|
+
payload: {
|
|
663
|
+
isLoading: true
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
fronteggAuth.loginActions.requestHostedLoginAuthorize();
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
Vue.onBeforeUnmount(function () {
|
|
671
|
+
unsubscribeFronteggStore();
|
|
672
|
+
});
|
|
673
|
+
return {
|
|
674
|
+
fronteggLoaded: fronteggLoaded,
|
|
675
|
+
authState: authState,
|
|
676
|
+
fronteggAuth: fronteggAuth,
|
|
677
|
+
loginWithRedirect: loginWithRedirect
|
|
678
|
+
};
|
|
679
|
+
};
|
|
680
|
+
var useFronteggAuthGuard = function useFronteggAuthGuard() {
|
|
681
|
+
var fronteggAuth = useFronteggAuth();
|
|
682
|
+
var fronteggOptions = Vue.inject(fronteggOptionsKey);
|
|
683
|
+
var authState = useAuthState();
|
|
684
|
+
var router = Vue.inject(routerKey);
|
|
685
|
+
var fronteggStore = useFronteggStore();
|
|
686
|
+
|
|
687
|
+
var isAuthRoutes = function isAuthRoutes(path) {
|
|
688
|
+
var routes = authState.routes;
|
|
689
|
+
return Object.values(routes).filter(function (path) {
|
|
690
|
+
return path !== routes.authenticatedUrl;
|
|
691
|
+
}).includes(path);
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
var checkGuard = function checkGuard() {
|
|
695
|
+
var _a;
|
|
696
|
+
|
|
697
|
+
if (!isAuthRoutes((_a = fronteggAuth.router) === null || _a === void 0 ? void 0 : _a.currentRoute.path) && !authState.isAuthenticated && !authState.isLoading) {
|
|
698
|
+
if (fronteggOptions.hostedLoginBox) {
|
|
699
|
+
fronteggStore.dispatch({
|
|
700
|
+
type: 'auth/setState',
|
|
701
|
+
payload: {
|
|
702
|
+
isLoading: true
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
fronteggAuth.loginActions.requestHostedLoginAuthorize();
|
|
706
|
+
} else {
|
|
707
|
+
router.push(authState.routes.loginUrl);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
Vue.onMounted(checkGuard);
|
|
713
|
+
Vue.onUpdated(checkGuard);
|
|
600
714
|
};var isAuthenticatedGuard = function isAuthenticatedGuard(_to, _from, next) {
|
|
601
715
|
var _a, _b;
|
|
602
716
|
|
|
@@ -637,7 +751,7 @@ var mapTeamActions = function mapTeamActions(action) {
|
|
|
637
751
|
}, 1);
|
|
638
752
|
};var fronteggApp = null;
|
|
639
753
|
var Frontegg = {
|
|
640
|
-
install: function install(Vue, options) {
|
|
754
|
+
install: function install(Vue$1, options) {
|
|
641
755
|
var _a;
|
|
642
756
|
|
|
643
757
|
var _b = options !== null && options !== void 0 ? options : {},
|
|
@@ -656,6 +770,13 @@ var Frontegg = {
|
|
|
656
770
|
var pluginRegistered = false; // frontegg loader subscription
|
|
657
771
|
|
|
658
772
|
var fronteggLoaded = false;
|
|
773
|
+
var isVue3 = Vue$1.version.charAt(0) === '3';
|
|
774
|
+
var fronteggLoadedV3;
|
|
775
|
+
|
|
776
|
+
if (isVue3) {
|
|
777
|
+
fronteggLoadedV3 = Vue.ref(false);
|
|
778
|
+
}
|
|
779
|
+
|
|
659
780
|
var fronteggLoadedSubscribes = new Set();
|
|
660
781
|
|
|
661
782
|
var fronteggLoadedSubscribe = function fronteggLoadedSubscribe(instance) {
|
|
@@ -677,33 +798,37 @@ var Frontegg = {
|
|
|
677
798
|
var store = fronteggApp.store;
|
|
678
799
|
StoreHolder.setStore(store); // @ts-ignore
|
|
679
800
|
|
|
680
|
-
Vue.$fronteggApp = fronteggApp;
|
|
801
|
+
Vue$1.$fronteggApp = fronteggApp;
|
|
681
802
|
|
|
682
|
-
if (!Vue.fronteggAuth) {
|
|
683
|
-
Vue.fronteggAuth = new FronteggAuthService({
|
|
803
|
+
if (!Vue$1.fronteggAuth) {
|
|
804
|
+
Vue$1.fronteggAuth = new FronteggAuthService({
|
|
684
805
|
router: router
|
|
685
806
|
});
|
|
686
|
-
registerFronteggPlugin(Vue, Vue.fronteggAuth);
|
|
807
|
+
registerFronteggPlugin(Vue$1, Vue$1.fronteggAuth);
|
|
687
808
|
}
|
|
688
809
|
|
|
689
810
|
var registerPlugins = function registerPlugins(instance) {
|
|
690
811
|
pluginRegistered = true;
|
|
691
|
-
(Vue.fronteggPlugins || []).forEach(function (plugin) {
|
|
812
|
+
(Vue$1.fronteggPlugins || []).forEach(function (plugin) {
|
|
692
813
|
return plugin.init(rest, store);
|
|
693
814
|
});
|
|
694
815
|
setStoreKey(instance, store);
|
|
695
|
-
instance.fronteggAuth = Vue.fronteggAuth;
|
|
816
|
+
instance.fronteggAuth = Vue$1.fronteggAuth;
|
|
696
817
|
connectMapState(instance);
|
|
697
818
|
};
|
|
698
819
|
|
|
699
820
|
var checkIfPluginsLoaded = function checkIfPluginsLoaded() {
|
|
700
|
-
var _fronteggLoaded = (Vue.fronteggPlugins || []).reduce(function (loaded, plugin) {
|
|
821
|
+
var _fronteggLoaded = (Vue$1.fronteggPlugins || []).reduce(function (loaded, plugin) {
|
|
701
822
|
return loaded && !plugin.loading;
|
|
702
823
|
}, true);
|
|
703
824
|
|
|
704
825
|
if (_fronteggLoaded !== fronteggLoaded) {
|
|
705
826
|
fronteggLoaded = _fronteggLoaded;
|
|
706
827
|
|
|
828
|
+
if (isVue3) {
|
|
829
|
+
fronteggLoadedV3.value = _fronteggLoaded;
|
|
830
|
+
}
|
|
831
|
+
|
|
707
832
|
var _iterator = _createForOfIteratorHelper(fronteggLoadedSubscribes),
|
|
708
833
|
_step;
|
|
709
834
|
|
|
@@ -756,7 +881,7 @@ var Frontegg = {
|
|
|
756
881
|
}, 10);
|
|
757
882
|
|
|
758
883
|
var isAuthRoutes = function isAuthRoutes(path) {
|
|
759
|
-
var routes = Vue.fronteggAuth.routes;
|
|
884
|
+
var routes = Vue$1.fronteggAuth.routes;
|
|
760
885
|
return Object.values(routes).filter(function (path) {
|
|
761
886
|
return path != routes.authenticatedUrl;
|
|
762
887
|
}).includes(path);
|
|
@@ -767,11 +892,11 @@ var Frontegg = {
|
|
|
767
892
|
return;
|
|
768
893
|
}
|
|
769
894
|
|
|
770
|
-
if (!Vue.fronteggAuth.loading && !Vue.fronteggAuth.isAuthenticated) {
|
|
895
|
+
if (!Vue$1.fronteggAuth.loading && !Vue$1.fronteggAuth.isAuthenticated) {
|
|
771
896
|
if (options === null || options === void 0 ? void 0 : options.hostedLoginBox) {
|
|
772
|
-
Vue.fronteggAuth.loginActions.requestHostedLoginAuthorize();
|
|
897
|
+
Vue$1.fronteggAuth.loginActions.requestHostedLoginAuthorize();
|
|
773
898
|
} else {
|
|
774
|
-
var loginUrl = Vue.fronteggAuth.routes.loginUrl;
|
|
899
|
+
var loginUrl = Vue$1.fronteggAuth.routes.loginUrl;
|
|
775
900
|
|
|
776
901
|
_this.$router.push(loginUrl);
|
|
777
902
|
}
|
|
@@ -779,24 +904,47 @@ var Frontegg = {
|
|
|
779
904
|
};
|
|
780
905
|
|
|
781
906
|
if (!pluginRegistered) {
|
|
782
|
-
registerPlugins(Vue);
|
|
907
|
+
registerPlugins(Vue$1);
|
|
783
908
|
} // should be function not arrow to maintain this
|
|
784
909
|
|
|
785
910
|
|
|
786
911
|
function loginWithRedirect() {
|
|
787
912
|
// @ts-ignore
|
|
788
|
-
if (!this.$route.path.startsWith(Vue.fronteggAuth.routes.hostedLoginRedirectUrl)) {
|
|
913
|
+
if (!this.$route.path.startsWith(Vue$1.fronteggAuth.routes.hostedLoginRedirectUrl)) {
|
|
789
914
|
store.dispatch({
|
|
790
915
|
type: 'auth/setState',
|
|
791
916
|
payload: {
|
|
792
917
|
isLoading: true
|
|
793
918
|
}
|
|
794
919
|
});
|
|
795
|
-
Vue.fronteggAuth.loginActions.requestHostedLoginAuthorize();
|
|
920
|
+
Vue$1.fronteggAuth.loginActions.requestHostedLoginAuthorize();
|
|
796
921
|
}
|
|
797
922
|
}
|
|
798
923
|
|
|
799
|
-
|
|
924
|
+
if (isVue3) {
|
|
925
|
+
// @ts-ignore - provide will exist only in vue 3 app
|
|
926
|
+
Vue$1.provide(fronteggLoadedKey, fronteggLoadedV3);
|
|
927
|
+
|
|
928
|
+
var _connectFronteggStore = connectFronteggStoreV3(store),
|
|
929
|
+
authState = _connectFronteggStore.authState,
|
|
930
|
+
unsubscribe = _connectFronteggStore.unsubscribe;
|
|
931
|
+
|
|
932
|
+
var fronteggAuthReactive = Vue.reactive(Object.assign({}, Vue$1.fronteggAuth)); // @ts-ignore
|
|
933
|
+
|
|
934
|
+
Vue$1.provide(authStateKey, authState); // @ts-ignore
|
|
935
|
+
|
|
936
|
+
Vue$1.provide(unsubscribeFronteggStoreKey, unsubscribe); // @ts-ignore
|
|
937
|
+
|
|
938
|
+
Vue$1.provide(fronteggAuthKey, fronteggAuthReactive); // @ts-ignore
|
|
939
|
+
|
|
940
|
+
Vue$1.provide(routerKey, router); // @ts-ignore
|
|
941
|
+
|
|
942
|
+
Vue$1.provide(fronteggOptionsKey, options); // @ts-ignore
|
|
943
|
+
|
|
944
|
+
Vue$1.provide(fronteggStoreKey, store);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
Vue$1.mixin({
|
|
800
948
|
data: function data() {
|
|
801
949
|
return {
|
|
802
950
|
fronteggLoaded: fronteggLoaded
|
|
@@ -804,7 +952,7 @@ var Frontegg = {
|
|
|
804
952
|
},
|
|
805
953
|
beforeCreate: function beforeCreate() {
|
|
806
954
|
setStoreKey(this, store);
|
|
807
|
-
this.fronteggAuth = Vue.fronteggAuth;
|
|
955
|
+
this.fronteggAuth = Vue$1.fronteggAuth;
|
|
808
956
|
this.loginWithRedirect = loginWithRedirect.bind(this);
|
|
809
957
|
connectMapState(this);
|
|
810
958
|
},
|
|
@@ -848,4 +996,4 @@ var openAdminPortal = function openAdminPortal() {
|
|
|
848
996
|
|
|
849
997
|
var closeAdminPortal = function closeAdminPortal() {
|
|
850
998
|
return js.AdminPortal.hide();
|
|
851
|
-
};Object.defineProperty(exports,'AdminPortal',{enumerable:true,get:function(){return js.AdminPortal;}});exports.Frontegg=Frontegg;exports.closeAdminPortal=closeAdminPortal;exports.isAuthenticatedGuard=isAuthenticatedGuard;exports.mapAcceptInvitationActions=mapAcceptInvitationActions;exports.mapActivateAccountActions=mapActivateAccountActions;exports.mapApiTokensActions=mapApiTokensActions;exports.mapAuthActions=mapAuthActions;exports.mapForgotPasswordActions=mapForgotPasswordActions;exports.mapLoginActions=mapLoginActions;exports.mapMfaActions=mapMfaActions;exports.mapProfileActions=mapProfileActions;exports.mapSecurityPolicyActions=mapSecurityPolicyActions;exports.mapSignupActions=mapSignupActions;exports.mapSocialLoginActions=mapSocialLoginActions;exports.mapSsoActions=mapSsoActions;exports.mapTeamActions=mapTeamActions;exports.openAdminPortal=openAdminPortal;
|
|
999
|
+
};Object.defineProperty(exports,'ContextHolder',{enumerable:true,get:function(){return restApi.ContextHolder;}});Object.defineProperty(exports,'AdminPortal',{enumerable:true,get:function(){return js.AdminPortal;}});exports.Frontegg=Frontegg;exports.closeAdminPortal=closeAdminPortal;exports.isAuthenticatedGuard=isAuthenticatedGuard;exports.mapAcceptInvitationActions=mapAcceptInvitationActions;exports.mapActivateAccountActions=mapActivateAccountActions;exports.mapApiTokensActions=mapApiTokensActions;exports.mapAuthActions=mapAuthActions;exports.mapForgotPasswordActions=mapForgotPasswordActions;exports.mapLoginActions=mapLoginActions;exports.mapMfaActions=mapMfaActions;exports.mapProfileActions=mapProfileActions;exports.mapSecurityPolicyActions=mapSecurityPolicyActions;exports.mapSignupActions=mapSignupActions;exports.mapSocialLoginActions=mapSocialLoginActions;exports.mapSsoActions=mapSsoActions;exports.mapTeamActions=mapTeamActions;exports.openAdminPortal=openAdminPortal;exports.useAuthState=useAuthState;exports.useFrontegg=useFrontegg;exports.useFronteggAuthGuard=useFronteggAuthGuard;exports.useFronteggLoaded=useFronteggLoaded;exports.useUnsubscribeFronteggStore=useUnsubscribeFronteggStore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/vue",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13-alpha.3705679739",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.ssr.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"build:unpkg": "cross-env NODE_ENV=production rollup --config rollup.config.js --format iife"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@frontegg/js": "6.
|
|
25
|
+
"@frontegg/js": "6.51.0",
|
|
26
26
|
"get-value": "^3.0.1",
|
|
27
27
|
"set-value": "^4.0.1"
|
|
28
28
|
},
|
|
@@ -61,4 +61,4 @@
|
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=12"
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|