Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@frontegg/redux-store

Package Overview
Dependencies
Maintainers
3
Versions
1087
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frontegg/redux-store - npm Package Compare versions

Comparing version 7.15.0 to 7.16.0-alpha.0

3

auth/AcceptInvitationState/actions.d.ts
import { FronteggState, RestApi, SharedActions } from '../../interfaces';
import { AcceptInvitationState } from './interfaces';
import { IAcceptInvitation } from '@frontegg/rest-api';
import { IAcceptInvitation, IAcceptInvitationWithOTC } from '@frontegg/rest-api';
declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {

@@ -8,3 +8,4 @@ setAcceptInvitationState: (state: Partial<AcceptInvitationState>) => void;

acceptInvitation: (payload: IAcceptInvitation) => Promise<void>;
acceptInvitationWithOTC: (payload: IAcceptInvitationWithOTC) => Promise<void>;
};
export default _default;

@@ -36,7 +36,32 @@ import { AcceptInvitationStep } from './interfaces';

};
const acceptInvitationWithOTC = async payload => {
if (!payload.token || !payload.userId || !payload.code) {
setAcceptInvitationState({
error: undefined,
step: AcceptInvitationStep.invalid
});
return;
}
try {
setAcceptInvitationState({
error: undefined,
step: AcceptInvitationStep.pending
});
await api.auth.acceptInvitationWithOTC(payload);
setAcceptInvitationState({
step: AcceptInvitationStep.success
});
} catch (e) {
setAcceptInvitationState({
step: AcceptInvitationStep.failed,
error: errorHandler(e)
});
}
};
return {
setAcceptInvitationState,
resetAcceptInvitationState,
acceptInvitation
acceptInvitation,
acceptInvitationWithOTC
};
});
import { FronteggState, WithCallback, SharedActions, RestApi } from '../../interfaces';
import { IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse, IResendActivationEmail } from '@frontegg/rest-api';
import { ActivateAccountState, IActivateAccountPayload, IPreActivateAccount } from './interfaces';
import { ActivateAccountState, IActivateAccountPayload, IActivateAccountWithOTCPayload, IPreActivateAccount } from './interfaces';
declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {

@@ -12,3 +12,4 @@ setActivateState: (state: Partial<ActivateAccountState>) => void;

resendActivationEmail: (payload: WithCallback<IResendActivationEmail>) => Promise<void>;
activateAccountWithCode: (_payload: WithCallback<IActivateAccountWithOTCPayload>) => Promise<void>;
};
export default _default;
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["callback", "events"],
_excluded2 = ["user"],
_excluded3 = ["callback"],
_excluded4 = ["callback"];
const _excluded = ["user"],
_excluded2 = ["callback", "events"],
_excluded3 = ["user"],
_excluded4 = ["callback", "events"],
_excluded5 = ["user"],
_excluded6 = ["callback"],
_excluded7 = ["callback"];
import { initialState } from './state';

@@ -62,2 +65,51 @@ import { ContextHolder } from '@frontegg/rest-api';

};
const handleActivationResponse = async ({
loginResponse,
events,
onRedirectTo,
routes
}) => {
const {
user
} = loginResponse,
rest = _objectWithoutPropertiesLoose(loginResponse, _excluded);
if (user.redirectLocation) {
window.location.href = user.redirectLocation;
return;
}
if (isMfaRequired(user, store.root.appName)) {
setActivateState({
step: ActivateAccountStep.success
});
const mfaRequiredState = await actions.getMfaRequiredState(user);
actions.setAuthState(mfaRequiredState);
await delay(1000);
onRedirectTo(routes.loginUrl, {
preserveQueryParams: true
});
} else {
var _events$userVerified;
setActivateState({
step: ActivateAccountStep.success
});
const userVerifiedPayload = {
email: user.email,
origin: UserVeirifedOriginTypes.ACTIVATION_LINK,
id: user.id,
tenantId: user.tenantId,
name: user.name,
createdAt: new Date()
};
events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, userVerifiedPayload);
reportGTMEvent(GTMEventAction.USER_VERIFIED, userVerifiedPayload);
actions.afterAuthenticationStateUpdate(_extends({
user
}, rest), {
isAuthenticated: true
});
await delay(1000);
await actions.afterAuthNavigation();
resetActivateState();
}
};
const activateAccount = async _payload => {

@@ -68,3 +120,3 @@ const {

} = _payload,
payload = _objectWithoutPropertiesLoose(_payload, _excluded);
payload = _objectWithoutPropertiesLoose(_payload, _excluded2);
setActivateState({

@@ -80,41 +132,11 @@ loading: true

} = _await$api$auth$activ,
rest = _objectWithoutPropertiesLoose(_await$api$auth$activ, _excluded2);
if (user.redirectLocation) {
window.location.href = user.redirectLocation;
return;
}
if (isMfaRequired(user, store.root.appName)) {
setActivateState({
step: ActivateAccountStep.success
});
const mfaRequiredState = await actions.getMfaRequiredState(user);
actions.setAuthState(mfaRequiredState);
await delay(1000);
onRedirectTo(routes.loginUrl, {
preserveQueryParams: true
});
} else {
var _events$userVerified;
setActivateState({
step: ActivateAccountStep.success
});
const userVerifiedPayload = {
email: user.email,
origin: UserVeirifedOriginTypes.ACTIVATION_LINK,
id: user.id,
tenantId: user.tenantId,
name: user.name,
createdAt: new Date()
};
events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, userVerifiedPayload);
reportGTMEvent(GTMEventAction.USER_VERIFIED, userVerifiedPayload);
await actions.afterAuthenticationStateUpdate(_extends({
rest = _objectWithoutPropertiesLoose(_await$api$auth$activ, _excluded3);
await handleActivationResponse({
loginResponse: _extends({
user
}, rest), {
isAuthenticated: true
});
await delay(1000);
await actions.afterAuthNavigation();
resetActivateState();
}
}, rest),
events,
onRedirectTo,
routes
});
callback == null ? void 0 : callback(true);

@@ -128,2 +150,35 @@ } catch (e) {

};
const activateAccountWithCode = async _payload => {
const {
callback,
events
} = _payload,
payload = _objectWithoutPropertiesLoose(_payload, _excluded4);
setActivateState({
loading: true
});
try {
const onRedirectTo = ContextHolder.for(store.root.appName).onRedirectTo;
const routes = store.auth.routes;
const _await$api$auth$activ2 = await api.auth.activateAccountWithOTC(payload),
{
user
} = _await$api$auth$activ2,
rest = _objectWithoutPropertiesLoose(_await$api$auth$activ2, _excluded5);
await handleActivationResponse({
loginResponse: _extends({
user
}, rest),
events,
onRedirectTo,
routes
});
callback == null ? void 0 : callback(true);
} catch (e) {
setActivateState({
loading: false,
error: errorHandler(e)
});
}
};
const getActivateAccountStrategy = async payload => {

@@ -133,3 +188,3 @@ const {

} = payload,
params = _objectWithoutPropertiesLoose(payload, _excluded3);
params = _objectWithoutPropertiesLoose(payload, _excluded6);
setActivateStrategyState({

@@ -157,3 +212,3 @@ loading: true

} = payload,
body = _objectWithoutPropertiesLoose(payload, _excluded4);
body = _objectWithoutPropertiesLoose(payload, _excluded7);
actions.setTeamLoader({

@@ -194,4 +249,5 @@ key: TeamStateKeys.RESEND_ACTIVATE_LINK,

getActivateAccountStrategy,
resendActivationEmail
resendActivationEmail,
activateAccountWithCode
};
});

@@ -24,4 +24,7 @@ import { IActivateAccount, IGetActivateAccountStrategyResponse } from '@frontegg/rest-api';

}
export interface IActivateAccountWithOTCPayload extends IActivateAccountPayload {
code: string;
}
export type ActivateAccountStrategyState = WithStatus & {
strategy?: IGetActivateAccountStrategyResponse;
};

@@ -133,2 +133,6 @@ import type { AcceptInvitationState } from './AcceptInvitationState/interfaces';

/**
* the page whither need to redirect in the case when a user want to activate his account with code
*/
activateWithOTCUrl: string;
/**
* the page whither need to redirect in the case when a user want to impersonate another user

@@ -142,2 +146,6 @@ */

/**
* the page whether you need to redirect in the case when a user wants to accept invite to tenant with OTC
*/
acceptInvitationWithOTCUrl: string;
/**
* the page in the case a user forgot his account password

@@ -144,0 +152,0 @@ */

@@ -35,3 +35,5 @@ /**

unlockAccountUrl: '/account/unlock',
activateWithOTCUrl: '/account/activate/code',
acceptInvitationWithOTCUrl: '/account/invitation/code',
mfaMobileAuthenticator: '/account/mfa-mobile-authenticator'
};

@@ -1,2 +0,2 @@

/** @license Frontegg v7.15.0
/** @license Frontegg v7.16.0-alpha.0
*

@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the

@@ -6,3 +6,4 @@ import { FronteggState, RestApi, SharedActions } from '../../interfaces';

acceptInvitation: (payload: import("@frontegg/rest-api").IAcceptInvitation) => Promise<void>;
acceptInvitationWithOTC: (payload: import("@frontegg/rest-api").IAcceptInvitationWithOTC) => Promise<void>;
};
export default _default;

@@ -10,3 +10,4 @@ import { FronteggState, RestApi, SharedActions } from '../../interfaces';

resendActivationEmail: (payload: import("../../interfaces").WithCallback<import("@frontegg/rest-api").IResendActivationEmail>) => Promise<void>;
activateAccountWithCode: (_payload: import("../../interfaces").WithCallback<import("../..").IActivateAccountWithOTCPayload>) => Promise<void>;
};
export default _default;

@@ -42,8 +42,33 @@ "use strict";

};
const acceptInvitationWithOTC = async payload => {
if (!payload.token || !payload.userId || !payload.code) {
setAcceptInvitationState({
error: undefined,
step: _interfaces.AcceptInvitationStep.invalid
});
return;
}
try {
setAcceptInvitationState({
error: undefined,
step: _interfaces.AcceptInvitationStep.pending
});
await api.auth.acceptInvitationWithOTC(payload);
setAcceptInvitationState({
step: _interfaces.AcceptInvitationStep.success
});
} catch (e) {
setAcceptInvitationState({
step: _interfaces.AcceptInvitationStep.failed,
error: (0, _helpers.errorHandler)(e)
});
}
};
return {
setAcceptInvitationState,
resetAcceptInvitationState,
acceptInvitation
acceptInvitation,
acceptInvitationWithOTC
};
};
exports.default = _default;

@@ -18,6 +18,9 @@ "use strict";

var _interfaces3 = require("../TeamState/interfaces");
const _excluded = ["callback", "events"],
_excluded2 = ["user"],
_excluded3 = ["callback"],
_excluded4 = ["callback"];
const _excluded = ["user"],
_excluded2 = ["callback", "events"],
_excluded3 = ["user"],
_excluded4 = ["callback", "events"],
_excluded5 = ["user"],
_excluded6 = ["callback"],
_excluded7 = ["callback"];
var _default = (store, api, sharedActions) => {

@@ -70,2 +73,51 @@ const actions = sharedActions;

};
const handleActivationResponse = async ({
loginResponse,
events,
onRedirectTo,
routes
}) => {
const {
user
} = loginResponse,
rest = (0, _objectWithoutPropertiesLoose2.default)(loginResponse, _excluded);
if (user.redirectLocation) {
window.location.href = user.redirectLocation;
return;
}
if ((0, _helpers2.isMfaRequired)(user, store.root.appName)) {
setActivateState({
step: _interfaces.ActivateAccountStep.success
});
const mfaRequiredState = await actions.getMfaRequiredState(user);
actions.setAuthState(mfaRequiredState);
await (0, _helpers.delay)(1000);
onRedirectTo(routes.loginUrl, {
preserveQueryParams: true
});
} else {
var _events$userVerified;
setActivateState({
step: _interfaces.ActivateAccountStep.success
});
const userVerifiedPayload = {
email: user.email,
origin: _interfaces2.UserVeirifedOriginTypes.ACTIVATION_LINK,
id: user.id,
tenantId: user.tenantId,
name: user.name,
createdAt: new Date()
};
events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, userVerifiedPayload);
(0, _gtm.reportGTMEvent)(_gtm.GTMEventAction.USER_VERIFIED, userVerifiedPayload);
actions.afterAuthenticationStateUpdate((0, _extends2.default)({
user
}, rest), {
isAuthenticated: true
});
await (0, _helpers.delay)(1000);
await actions.afterAuthNavigation();
resetActivateState();
}
};
const activateAccount = async _payload => {

@@ -76,3 +128,3 @@ const {

} = _payload,
payload = (0, _objectWithoutPropertiesLoose2.default)(_payload, _excluded);
payload = (0, _objectWithoutPropertiesLoose2.default)(_payload, _excluded2);
setActivateState({

@@ -88,41 +140,11 @@ loading: true

} = _await$api$auth$activ,
rest = (0, _objectWithoutPropertiesLoose2.default)(_await$api$auth$activ, _excluded2);
if (user.redirectLocation) {
window.location.href = user.redirectLocation;
return;
}
if ((0, _helpers2.isMfaRequired)(user, store.root.appName)) {
setActivateState({
step: _interfaces.ActivateAccountStep.success
});
const mfaRequiredState = await actions.getMfaRequiredState(user);
actions.setAuthState(mfaRequiredState);
await (0, _helpers.delay)(1000);
onRedirectTo(routes.loginUrl, {
preserveQueryParams: true
});
} else {
var _events$userVerified;
setActivateState({
step: _interfaces.ActivateAccountStep.success
});
const userVerifiedPayload = {
email: user.email,
origin: _interfaces2.UserVeirifedOriginTypes.ACTIVATION_LINK,
id: user.id,
tenantId: user.tenantId,
name: user.name,
createdAt: new Date()
};
events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, userVerifiedPayload);
(0, _gtm.reportGTMEvent)(_gtm.GTMEventAction.USER_VERIFIED, userVerifiedPayload);
await actions.afterAuthenticationStateUpdate((0, _extends2.default)({
rest = (0, _objectWithoutPropertiesLoose2.default)(_await$api$auth$activ, _excluded3);
await handleActivationResponse({
loginResponse: (0, _extends2.default)({
user
}, rest), {
isAuthenticated: true
});
await (0, _helpers.delay)(1000);
await actions.afterAuthNavigation();
resetActivateState();
}
}, rest),
events,
onRedirectTo,
routes
});
callback == null ? void 0 : callback(true);

@@ -136,2 +158,35 @@ } catch (e) {

};
const activateAccountWithCode = async _payload => {
const {
callback,
events
} = _payload,
payload = (0, _objectWithoutPropertiesLoose2.default)(_payload, _excluded4);
setActivateState({
loading: true
});
try {
const onRedirectTo = _restApi.ContextHolder.for(store.root.appName).onRedirectTo;
const routes = store.auth.routes;
const _await$api$auth$activ2 = await api.auth.activateAccountWithOTC(payload),
{
user
} = _await$api$auth$activ2,
rest = (0, _objectWithoutPropertiesLoose2.default)(_await$api$auth$activ2, _excluded5);
await handleActivationResponse({
loginResponse: (0, _extends2.default)({
user
}, rest),
events,
onRedirectTo,
routes
});
callback == null ? void 0 : callback(true);
} catch (e) {
setActivateState({
loading: false,
error: (0, _helpers.errorHandler)(e)
});
}
};
const getActivateAccountStrategy = async payload => {

@@ -141,3 +196,3 @@ const {

} = payload,
params = (0, _objectWithoutPropertiesLoose2.default)(payload, _excluded3);
params = (0, _objectWithoutPropertiesLoose2.default)(payload, _excluded6);
setActivateStrategyState({

@@ -165,3 +220,3 @@ loading: true

} = payload,
body = (0, _objectWithoutPropertiesLoose2.default)(payload, _excluded4);
body = (0, _objectWithoutPropertiesLoose2.default)(payload, _excluded7);
actions.setTeamLoader({

@@ -202,5 +257,6 @@ key: _interfaces3.TeamStateKeys.RESEND_ACTIVATE_LINK,

getActivateAccountStrategy,
resendActivationEmail
resendActivationEmail,
activateAccountWithCode
};
};
exports.default = _default;

@@ -43,4 +43,6 @@ "use strict";

unlockAccountUrl: '/account/unlock',
activateWithOTCUrl: '/account/activate/code',
acceptInvitationWithOTCUrl: '/account/invitation/code',
mfaMobileAuthenticator: '/account/mfa-mobile-authenticator'
};
exports.defaultFronteggRoutes = defaultFronteggRoutes;

@@ -1,2 +0,2 @@

/** @license Frontegg v7.15.0
/** @license Frontegg v7.16.0-alpha.0
*

@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the

{
"name": "@frontegg/redux-store",
"version": "7.15.0",
"version": "7.16.0-alpha.0",
"main": "./node/index.js",

@@ -10,3 +10,3 @@ "license": "MIT",

"@frontegg/entitlements-javascript-commons": "1.1.2",
"@frontegg/rest-api": "3.2.1",
"@frontegg/rest-api": "3.2.2",
"fast-deep-equal": "3.1.3",

@@ -13,0 +13,0 @@ "get-value": "^3.0.1",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc