New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@frontegg/react-hooks

Package Overview
Dependencies
Maintainers
1
Versions
1095
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frontegg/react-hooks - npm Package Compare versions

Comparing version 1.25.0-rescript to 1.26.0-rescript

index.es.js

253

index.js

@@ -1,18 +0,243 @@

import React, { useMemo } from 'react';
import { Provider } from 'react-redux';
import '@frontegg/redux-store/toolkit';
import '@frontegg/redux-store/auth';
import { ContextHolder } from '@frontegg/rest-api';
export { s as reloadProfileIfNeeded, h as useAcceptInvitationActions, g as useAcceptInvitationState, j as useActivateAccountActions, i as useActivateAccountState, l as useApiTokensActions, k as useApiTokensState, u as useAuth, a as useAuthActions, c as useAuthRoutes, B as useAuthTeamActions, A as useAuthTeamState, e as useAuthUser, f as useAuthUserOrNull, n as useForgotPasswordActions, m as useForgotPasswordState, d as useIsAuthenticated, p as useLoginActions, o as useLoginState, r as useMfaActions, q as useMfaState, b as useOnRedirectTo, v as useProfileActions, t as useProfileState, J as useRolesActions, I as useRolesState, D as useSSOActions, C as useSSOState, F as useSecurityPolicyActions, E as useSecurityPolicyState, x as useSignUpActions, w as useSignUpState, z as useSocialLoginActions, y as useSocialLoginState, H as useTenantsActions, G as useTenantsState } from './roles-5bbf40a8.js';
import '@frontegg/redux-store/audits';
export { c as useAuditLogsActions, b as useAuditLogsState, a as useAuditsActions, e as useAuditsMetadataActions, d as useAuditsMetadataState, u as useAuditsState } from './auditsMetadata-8b4c4824.js';
import { createFronteggStore } from '@frontegg/redux-store';
'use strict';
const FronteggProvider = ({ children }) => {
const context = ContextHolder.getContext();
const store = useMemo(() => createFronteggStore({ context }), []);
return React.createElement(Provider, { store: store }, children);
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var tslib = require('tslib');
var React = require('react');
var React__default = _interopDefault(React);
var reactRedux = require('react-redux');
var toolkit = require('@frontegg/redux-store/toolkit');
var audits = require('@frontegg/redux-store/audits');
var reduxStore = require('@frontegg/redux-store');
var auth = require('@frontegg/redux-store/auth');
var restApi = require('@frontegg/rest-api');
var useAuditsState = function (stateMapper) {
return reactRedux.useSelector(function (state) { var _a; return (_a = stateMapper === null || stateMapper === void 0 ? void 0 : stateMapper(state[audits.auditsStoreName])) !== null && _a !== void 0 ? _a : state[audits.auditsStoreName]; }, reactRedux.shallowEqual);
};
var useAuditsActions = function () {
var dispatch = reactRedux.useDispatch();
return React.useMemo(function () { return toolkit.bindActionCreators(audits.auditsActions, dispatch); }, [audits.auditsActions]);
};
/**
* hooks helpers
*/
var sliceReducerActionsBy = function (reducer) {
var reducerKeys = Object.keys(reducer);
var reducerActions = reducerKeys.map(function (key) {
var _a;
return (_a = {}, _a[key] = audits.auditsActions[key], _a);
});
return reducerActions.reduce(function (p, n) { return (tslib.__assign(tslib.__assign({}, p), n)); }, {});
};
var stateHookGenerator = function (stateMapper, subState) {
return reactRedux.useSelector(function (state) { var _a; return (_a = stateMapper === null || stateMapper === void 0 ? void 0 : stateMapper(state[audits.auditsStoreName][subState])) !== null && _a !== void 0 ? _a : state[audits.auditsStoreName][subState]; }, reactRedux.shallowEqual);
};
var reducerActionsGenerator = function (actions, reducers) {
var dispatch = reactRedux.useDispatch();
return React.useMemo(function () { return toolkit.bindActionCreators(tslib.__assign(tslib.__assign({}, actions), sliceReducerActionsBy(reducers)), dispatch); }, [dispatch]);
};
export { FronteggProvider };
var useAuditLogsState = function (stateMapper) { return stateHookGenerator(stateMapper, 'auditLogsState'); };
var useAuditLogsActions = function () { return reducerActionsGenerator(reduxStore.auditLogsActions, reduxStore.auditLogsReducers); };
var useAuditsMetadataState = function (stateMapper) { return stateHookGenerator(stateMapper, 'auditsMetadataState'); };
var useAuditsMetadataActions = function () {
return reducerActionsGenerator(audits.auditsMetadataActions, audits.auditsMetadataReducers);
};
var defaultMapper = {
state: function (state) { return state; },
actions: function (actions) { return actions; },
};
var useAuth = function (stateMapper) {
if (stateMapper === void 0) { stateMapper = defaultMapper.state; }
return reactRedux.useSelector(function (state) { return stateMapper(state[auth.authStoreName]); }, reactRedux.shallowEqual);
};
var useAuthActions = function () {
var dispatch = reactRedux.useDispatch();
return React.useMemo(function () { return toolkit.bindActionCreators(auth.authActions, dispatch); }, [auth.authActions]);
};
var useOnRedirectTo = function () { return restApi.ContextHolder.onRedirectTo; };
var useAuthRoutes = function () { return useAuth(function (state) { return (tslib.__assign({}, state.routes)); }); };
/**
* ```jsx
* export const MyFunctionComponent = () => {
* const isAuthenticated = useIsAuthenticated();
* return isAuthenticated ? <div>Hello User</div> : <Redirect to={'/login'}/>
* }
* ```
*
* use this frontegg hook function to get if user is "Authenticated"
*/
var useIsAuthenticated = function () {
return reactRedux.useSelector(function (_a) {
var _b = auth.authStoreName, isAuthenticated = _a[_b].isAuthenticated;
return isAuthenticated;
}, reactRedux.shallowEqual);
};
/**
* ```jsx
* export const MyFunctionComponent = () => {
* const user = useAuthUser();
* return user ? <div>Hello {user.name}!</div> : <div>Hello Guest!</div>
* }
* ```
*
* use this frontegg hook function to get the authenticated user
* the return user is null if not authenticated
*/
var useAuthUser = function () {
var routes = useAuthRoutes();
var onRedirectTo = useOnRedirectTo();
var user = useAuthUserOrNull();
if (user == null) {
onRedirectTo(routes.loginUrl, { refresh: true });
return {};
}
return user;
};
var useAuthUserOrNull = function () {
var user = reactRedux.useSelector(function (_a) {
var _b = auth.authStoreName, user = _a[_b].user;
return ({ user: user });
}, reactRedux.shallowEqual).user;
return user || null;
};
/**
* hooks helpers
*/
var sliceReducerActionsBy$1 = function (reducer) {
var reducerKeys = Object.keys(reducer);
var reducerActions = reducerKeys.map(function (key) {
var _a;
return (_a = {}, _a[key] = auth.authActions[key], _a);
});
return reducerActions.reduce(function (p, n) { return (tslib.__assign(tslib.__assign({}, p), n)); }, {});
};
var stateHookGenerator$1 = function (stateMapper, subState) {
return reactRedux.useSelector(function (state) { var _a; return (_a = stateMapper === null || stateMapper === void 0 ? void 0 : stateMapper(state[auth.authStoreName][subState])) !== null && _a !== void 0 ? _a : state[auth.authStoreName][subState]; }, reactRedux.shallowEqual);
};
var reducerActionsGenerator$1 = function (actions, reducers) {
var dispatch = reactRedux.useDispatch();
return React.useMemo(function () { return toolkit.bindActionCreators(tslib.__assign(tslib.__assign({}, actions), sliceReducerActionsBy$1(reducers)), dispatch); }, [dispatch]);
};
var useAcceptInvitationState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'acceptInvitationState'); };
var useAcceptInvitationActions = function () {
return reducerActionsGenerator$1(auth.acceptInvitationActions, auth.acceptInvitationReducers);
};
var useActivateAccountState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'activateState'); };
var useActivateAccountActions = function () {
return reducerActionsGenerator$1(auth.activateAccountActions, auth.activateAccountReducers);
};
var useApiTokensState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'apiTokensState'); };
var useApiTokensActions = function () { return reducerActionsGenerator$1(auth.apiTokensActions, auth.apiTokensReducers); };
var useForgotPasswordState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'forgotPasswordState'); };
var useForgotPasswordActions = function () {
return reducerActionsGenerator$1(auth.forgotPasswordActions, auth.forgotPasswordReducers);
};
var useLoginState = function (stateMapper) {
return stateHookGenerator$1(stateMapper, 'loginState');
};
var useLoginActions = function () { return reducerActionsGenerator$1(auth.loginActions, auth.loginReducers); };
var useMfaState = function (stateMapper) {
return stateHookGenerator$1(stateMapper, 'mfaState');
};
var useMfaActions = function () { return reducerActionsGenerator$1(auth.mfaActions, auth.mfaReducers); };
var reloadProfileIfNeeded = function () {
var loading = useProfileState().loading;
var loadProfile = useProfileActions().loadProfile;
React.useEffect(function () {
!loading && loadProfile();
}, []);
};
var useProfileState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'profileState'); };
var useProfileActions = function () { return reducerActionsGenerator$1(auth.profileActions, auth.profileReducers); };
var useSignUpState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'signUpState'); };
var useSignUpActions = function () { return reducerActionsGenerator$1(auth.signUpActions, auth.signUpReducers); };
var useSocialLoginState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'socialLoginState'); };
var useSocialLoginActions = function () {
return reducerActionsGenerator$1(auth.socialLoginsActions, auth.socialLoginsReducer);
};
var useAuthTeamState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'teamState'); };
var useAuthTeamActions = function () { return reducerActionsGenerator$1(auth.teamActions, auth.teamReducers); };
var useSSOState = function (stateMapper) {
return stateHookGenerator$1(stateMapper, 'ssoState');
};
var useSSOActions = function () { return reducerActionsGenerator$1(auth.ssoActions, auth.ssoReducers); };
var useSecurityPolicyState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'securityPolicyState'); };
var useSecurityPolicyActions = function () {
return reducerActionsGenerator$1(auth.securityPolicyActions, auth.securityPolicyReducers);
};
var useTenantsState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'tenantsState'); };
var useTenantsActions = function () { return reducerActionsGenerator$1(auth.tenantsActions, auth.tenantsReducers); };
var useRolesState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'rolesState'); };
var useRolesActions = function () { return reducerActionsGenerator$1(auth.rolesActions, auth.rolesReducers); };
var FronteggProvider = function (_a) {
var children = _a.children;
var context = restApi.ContextHolder.getContext();
var store = React.useMemo(function () { return reduxStore.createFronteggStore({ context: context }); }, []);
return React__default.createElement(reactRedux.Provider, { store: store }, children);
};
exports.FronteggProvider = FronteggProvider;
exports.reloadProfileIfNeeded = reloadProfileIfNeeded;
exports.useAcceptInvitationActions = useAcceptInvitationActions;
exports.useAcceptInvitationState = useAcceptInvitationState;
exports.useActivateAccountActions = useActivateAccountActions;
exports.useActivateAccountState = useActivateAccountState;
exports.useApiTokensActions = useApiTokensActions;
exports.useApiTokensState = useApiTokensState;
exports.useAuditLogsActions = useAuditLogsActions;
exports.useAuditLogsState = useAuditLogsState;
exports.useAuditsActions = useAuditsActions;
exports.useAuditsMetadataActions = useAuditsMetadataActions;
exports.useAuditsMetadataState = useAuditsMetadataState;
exports.useAuditsState = useAuditsState;
exports.useAuth = useAuth;
exports.useAuthActions = useAuthActions;
exports.useAuthRoutes = useAuthRoutes;
exports.useAuthTeamActions = useAuthTeamActions;
exports.useAuthTeamState = useAuthTeamState;
exports.useAuthUser = useAuthUser;
exports.useAuthUserOrNull = useAuthUserOrNull;
exports.useForgotPasswordActions = useForgotPasswordActions;
exports.useForgotPasswordState = useForgotPasswordState;
exports.useIsAuthenticated = useIsAuthenticated;
exports.useLoginActions = useLoginActions;
exports.useLoginState = useLoginState;
exports.useMfaActions = useMfaActions;
exports.useMfaState = useMfaState;
exports.useOnRedirectTo = useOnRedirectTo;
exports.useProfileActions = useProfileActions;
exports.useProfileState = useProfileState;
exports.useRolesActions = useRolesActions;
exports.useRolesState = useRolesState;
exports.useSSOActions = useSSOActions;
exports.useSSOState = useSSOState;
exports.useSecurityPolicyActions = useSecurityPolicyActions;
exports.useSecurityPolicyState = useSecurityPolicyState;
exports.useSignUpActions = useSignUpActions;
exports.useSignUpState = useSignUpState;
exports.useSocialLoginActions = useSocialLoginActions;
exports.useSocialLoginState = useSocialLoginState;
exports.useTenantsActions = useTenantsActions;
exports.useTenantsState = useTenantsState;
//# sourceMappingURL=index.js.map

9

package.json
{
"name": "@frontegg/react-hooks",
"libName": "FronteggReactHooks",
"version": "1.25.0-rescript",
"version": "1.26.0-rescript",
"author": "Frontegg LTD",
"main": "index.js",
"module": "index.js",
"module": "index.esm.js",
"es2015": "index.es.js",
"types": "index.d.ts",
"scripts": {
"build": "rm -rf dist && mkdir dist && rollup -c ./rollup.config.js",
"build": "rollup -c ../../scripts/rollup.config.js && echo DONE",
"build:watch": "rm -rf dist && mkdir dist && rollup -w -c ./rollup.config.js",

@@ -15,3 +16,3 @@ "test": "jest --runInBand --passWithNoTests -c ../../scripts/jest.config.json --rootDir ."

"dependencies": {
"@frontegg/redux-store": "1.25.0-rescript",
"@frontegg/redux-store": "^1.25.0-rescript",
"react-redux": "7.x"

@@ -18,0 +19,0 @@ },

Sorry, the diff of this file is not supported yet

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