@frontegg/react-hooks 6.0.1-alpha.6 → 6.0.3-alpha.2

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.
@@ -1,13 +1,15 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
3
  const _excluded = ["authenticatedUrl", "signUpSuccessUrl"];
3
4
  import React, { useEffect, useMemo, useRef, useState } from 'react';
4
- import { Provider } from 'react-redux';
5
+ import { Provider as ReduxProvider } from 'react-redux';
5
6
  import { createFronteggStore } from '@frontegg/redux-store';
6
7
  import { ContextHolder } from '@frontegg/rest-api';
7
8
  import { useAuth, useAuthRoutes } from './auth';
8
9
  import { FronteggStoreContext } from './FronteggStoreContext';
9
10
  import { Fragment as _Fragment } from "react/jsx-runtime";
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
+ const Provider = ReduxProvider;
11
13
 
12
14
  const setLoading = loading => {
13
15
  const isSSR = typeof document === 'undefined' || typeof window === 'undefined';
@@ -110,7 +112,7 @@ const FronteggContent = ({
110
112
  };
111
113
 
112
114
  export const FronteggStoreProvider = props => {
113
- var _app$options$contextO, _app$options4, _app$options$previewM, _app$options5, _app$options$authOpti, _app$options6;
115
+ var _app$options$contextO, _app$options4, _app$options$previewM, _app$options5, _app$options6, _app$options7;
114
116
 
115
117
  const {
116
118
  children,
@@ -120,7 +122,11 @@ export const FronteggStoreProvider = props => {
120
122
  } = props;
121
123
  const context = (_app$options$contextO = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.contextOptions) != null ? _app$options$contextO : contextOptions;
122
124
  const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options5 = app.options) == null ? void 0 : _app$options5.previewMode) != null ? _app$options$previewM : false;
123
- const authOptions = (_app$options$authOpti = app == null ? void 0 : (_app$options6 = app.options) == null ? void 0 : _app$options6.authOptions) != null ? _app$options$authOpti : {};
125
+ const authOptions = app != null && (_app$options6 = app.options) != null && _app$options6.authOptions ? _extends({}, app.options.authOptions, {
126
+ hostedLoginBox: app.options.hostedLoginBox
127
+ }) : {
128
+ hostedLoginBox: app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.hostedLoginBox
129
+ };
124
130
  ContextHolder.setContext(context);
125
131
  const store = useMemo(() => createFronteggStore({
126
132
  context: context
package/auth/index.d.ts CHANGED
@@ -14,3 +14,5 @@ export * from './sso';
14
14
  export * from './securityPolicy';
15
15
  export * from './tenants';
16
16
  export * from './roles';
17
+ export * from './sessions';
18
+ export * from './sessionsPolicy';
package/auth/index.js CHANGED
@@ -13,4 +13,6 @@ export * from './team';
13
13
  export * from './sso';
14
14
  export * from './securityPolicy';
15
15
  export * from './tenants';
16
- export * from './roles';
16
+ export * from './roles';
17
+ export * from './sessions';
18
+ export * from './sessionsPolicy';
@@ -9,3 +9,9 @@ export declare const usePublicPolicySettings: (loadOnMount?: boolean) => {
9
9
  error: any;
10
10
  policy: import("@frontegg/rest-api").IVendorConfig | undefined;
11
11
  };
12
+ export declare const usePublicAuthStrategiesPolicySettings: (loadOnMount?: boolean) => {
13
+ loading: boolean;
14
+ saving: boolean | undefined;
15
+ error: any;
16
+ policy: import("@frontegg/rest-api").IAuthStrategiesConfig | undefined;
17
+ };
@@ -22,4 +22,24 @@ export const usePublicPolicySettings = (loadOnMount = false) => {
22
22
  error,
23
23
  policy
24
24
  };
25
+ };
26
+ export const usePublicAuthStrategiesPolicySettings = (loadOnMount = false) => {
27
+ const {
28
+ loading,
29
+ policy,
30
+ saving,
31
+ error
32
+ } = useSecurityPolicyState(state => state.publicAuthStrategyPolicy);
33
+ const {
34
+ loadPublicAuthStrategiesPolicy
35
+ } = useSecurityPolicyActions();
36
+ useEffect(() => {
37
+ (loadOnMount || !policy) && loadPublicAuthStrategiesPolicy();
38
+ }, [loadOnMount, loadPublicAuthStrategiesPolicy]);
39
+ return {
40
+ loading,
41
+ saving,
42
+ error,
43
+ policy
44
+ };
25
45
  };
@@ -0,0 +1,5 @@
1
+ import { SessionsState, SessionsActions } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare type SessionsStateMapper<S extends object> = (state: SessionsState) => S;
4
+ export declare const useSessionsState: StateHookFunction<SessionsState>;
5
+ export declare const useSessionsActions: () => SessionsActions;
@@ -0,0 +1,4 @@
1
+ import { sessionsActions, sessionsReducers } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useSessionsState = stateMapper => stateHookGenerator(stateMapper, 'sessionsState');
4
+ export const useSessionsActions = () => reducerActionsGenerator(sessionsActions, sessionsReducers);
@@ -0,0 +1,6 @@
1
+ import { SessionsPolicyActions } from '@frontegg/redux-store';
2
+ import { SessionsPolicyState } from '@frontegg/redux-store/auth/SessionsPolicyState/interfaces';
3
+ import { StateHookFunction } from './hooks';
4
+ export declare type SessionsPolicyStateMapper<S extends object> = (state: SessionsPolicyState) => S;
5
+ export declare const useSessionsPolicyState: StateHookFunction<SessionsPolicyState>;
6
+ export declare const useSessionsPolicyActions: () => SessionsPolicyActions;
@@ -0,0 +1,4 @@
1
+ import { sessionsPolicyActions, sessionsPolicyReducers } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useSessionsPolicyState = stateMapper => stateHookGenerator(stateMapper, 'sessionsPolicyState');
4
+ export const useSessionsPolicyActions = () => reducerActionsGenerator(sessionsPolicyActions, sessionsPolicyReducers);
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.0.1-alpha.6
1
+ /** @license Frontegg v6.0.3-alpha.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.FronteggStoreProvider = void 0;
9
9
 
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
10
12
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
13
 
12
14
  var _react = _interopRequireWildcard(require("react"));
@@ -29,6 +31,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
29
31
 
30
32
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
33
 
34
+ const Provider = _reactRedux.Provider;
35
+
32
36
  const setLoading = loading => {
33
37
  const isSSR = typeof document === 'undefined' || typeof window === 'undefined';
34
38
 
@@ -129,7 +133,7 @@ const FronteggContent = ({
129
133
  };
130
134
 
131
135
  const FronteggStoreProvider = props => {
132
- var _app$options$contextO, _app$options4, _app$options$previewM, _app$options5, _app$options$authOpti, _app$options6;
136
+ var _app$options$contextO, _app$options4, _app$options$previewM, _app$options5, _app$options6, _app$options7;
133
137
 
134
138
  const {
135
139
  children,
@@ -139,14 +143,18 @@ const FronteggStoreProvider = props => {
139
143
  } = props;
140
144
  const context = (_app$options$contextO = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.contextOptions) != null ? _app$options$contextO : contextOptions;
141
145
  const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options5 = app.options) == null ? void 0 : _app$options5.previewMode) != null ? _app$options$previewM : false;
142
- const authOptions = (_app$options$authOpti = app == null ? void 0 : (_app$options6 = app.options) == null ? void 0 : _app$options6.authOptions) != null ? _app$options$authOpti : {};
146
+ const authOptions = app != null && (_app$options6 = app.options) != null && _app$options6.authOptions ? (0, _extends2.default)({}, app.options.authOptions, {
147
+ hostedLoginBox: app.options.hostedLoginBox
148
+ }) : {
149
+ hostedLoginBox: app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.hostedLoginBox
150
+ };
143
151
 
144
152
  _restApi.ContextHolder.setContext(context);
145
153
 
146
154
  const store = (0, _react.useMemo)(() => (0, _reduxStore.createFronteggStore)({
147
155
  context: context
148
156
  }, app, previewMode, authOptions), [app, previewMode]);
149
- return (0, _jsxRuntime.jsx)(_reactRedux.Provider, {
157
+ return (0, _jsxRuntime.jsx)(Provider, {
150
158
  context: _FronteggStoreContext.FronteggStoreContext,
151
159
  store: store,
152
160
  children: (0, _jsxRuntime.jsx)(FronteggContent, {
@@ -272,4 +272,32 @@ Object.keys(_roles).forEach(function (key) {
272
272
  return _roles[key];
273
273
  }
274
274
  });
275
+ });
276
+
277
+ var _sessions = require("./sessions");
278
+
279
+ Object.keys(_sessions).forEach(function (key) {
280
+ if (key === "default" || key === "__esModule") return;
281
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
282
+ if (key in exports && exports[key] === _sessions[key]) return;
283
+ Object.defineProperty(exports, key, {
284
+ enumerable: true,
285
+ get: function () {
286
+ return _sessions[key];
287
+ }
288
+ });
289
+ });
290
+
291
+ var _sessionsPolicy = require("./sessionsPolicy");
292
+
293
+ Object.keys(_sessionsPolicy).forEach(function (key) {
294
+ if (key === "default" || key === "__esModule") return;
295
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
296
+ if (key in exports && exports[key] === _sessionsPolicy[key]) return;
297
+ Object.defineProperty(exports, key, {
298
+ enumerable: true,
299
+ get: function () {
300
+ return _sessionsPolicy[key];
301
+ }
302
+ });
275
303
  });
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useSecurityPolicyState = exports.useSecurityPolicyActions = exports.usePublicPolicySettings = void 0;
6
+ exports.useSecurityPolicyState = exports.useSecurityPolicyActions = exports.usePublicPolicySettings = exports.usePublicAuthStrategiesPolicySettings = void 0;
7
7
 
8
8
  var _reduxStore = require("@frontegg/redux-store");
9
9
 
@@ -40,4 +40,27 @@ const usePublicPolicySettings = (loadOnMount = false) => {
40
40
  };
41
41
  };
42
42
 
43
- exports.usePublicPolicySettings = usePublicPolicySettings;
43
+ exports.usePublicPolicySettings = usePublicPolicySettings;
44
+
45
+ const usePublicAuthStrategiesPolicySettings = (loadOnMount = false) => {
46
+ const {
47
+ loading,
48
+ policy,
49
+ saving,
50
+ error
51
+ } = useSecurityPolicyState(state => state.publicAuthStrategyPolicy);
52
+ const {
53
+ loadPublicAuthStrategiesPolicy
54
+ } = useSecurityPolicyActions();
55
+ (0, _react.useEffect)(() => {
56
+ (loadOnMount || !policy) && loadPublicAuthStrategiesPolicy();
57
+ }, [loadOnMount, loadPublicAuthStrategiesPolicy]);
58
+ return {
59
+ loading,
60
+ saving,
61
+ error,
62
+ policy
63
+ };
64
+ };
65
+
66
+ exports.usePublicAuthStrategiesPolicySettings = usePublicAuthStrategiesPolicySettings;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSessionsState = exports.useSessionsActions = void 0;
7
+
8
+ var _reduxStore = require("@frontegg/redux-store");
9
+
10
+ var _hooks = require("./hooks");
11
+
12
+ const useSessionsState = stateMapper => (0, _hooks.stateHookGenerator)(stateMapper, 'sessionsState');
13
+
14
+ exports.useSessionsState = useSessionsState;
15
+
16
+ const useSessionsActions = () => (0, _hooks.reducerActionsGenerator)(_reduxStore.sessionsActions, _reduxStore.sessionsReducers);
17
+
18
+ exports.useSessionsActions = useSessionsActions;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSessionsPolicyState = exports.useSessionsPolicyActions = void 0;
7
+
8
+ var _reduxStore = require("@frontegg/redux-store");
9
+
10
+ var _hooks = require("./hooks");
11
+
12
+ const useSessionsPolicyState = stateMapper => (0, _hooks.stateHookGenerator)(stateMapper, 'sessionsPolicyState');
13
+
14
+ exports.useSessionsPolicyState = useSessionsPolicyState;
15
+
16
+ const useSessionsPolicyActions = () => (0, _hooks.reducerActionsGenerator)(_reduxStore.sessionsPolicyActions, _reduxStore.sessionsPolicyReducers);
17
+
18
+ exports.useSessionsPolicyActions = useSessionsPolicyActions;
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.0.1-alpha.6
1
+ /** @license Frontegg v6.0.3-alpha.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useSubscriptionRenewal = exports.useSubscriptionCancellation = exports.useSubscriptionActions = exports.useSubscription = exports.useStripeState = exports.useStripeActions = exports.usePlansActions = exports.usePlans = exports.usePaymentProviderActions = exports.usePaymentProvider = exports.usePaymentMethodActions = exports.usePaymentMethod = exports.useInvoicesActions = exports.useInvoices = exports.useCheckoutActions = exports.useCheckout = exports.useBillingInformationActions = exports.useBillingInformation = void 0;
6
+ exports.useVendorPublicConfigActions = exports.useVendorPublicConfig = exports.useSubscriptionRenewal = exports.useSubscriptionCancellation = exports.useSubscriptionActions = exports.useSubscription = exports.useStripeState = exports.useStripeActions = exports.usePlansActions = exports.usePlans = exports.usePaymentProviderActions = exports.usePaymentProvider = exports.usePaymentMethodActions = exports.usePaymentMethod = exports.useInvoicesActions = exports.useInvoices = exports.useCheckoutActions = exports.useCheckout = exports.useBillingInformationActions = exports.useBillingInformation = void 0;
7
7
 
8
8
  var _reduxStore = require("@frontegg/redux-store");
9
9
 
@@ -128,4 +128,22 @@ const useSubscriptionActions = () => {
128
128
  return (0, _react.useMemo)(() => (0, _reduxStore.bindActionCreators)(_reduxStore.subscriptionActions.billing.subscription, dispatch), [dispatch]);
129
129
  };
130
130
 
131
- exports.useSubscriptionActions = useSubscriptionActions;
131
+ exports.useSubscriptionActions = useSubscriptionActions;
132
+
133
+ const useVendorPublicConfig = () => {
134
+ return (0, _FronteggStoreContext.useSelector)(state => {
135
+ const {
136
+ vendorPublicConfig
137
+ } = getSubscriptionState(state);
138
+ return vendorPublicConfig;
139
+ }, _reactRedux.shallowEqual);
140
+ };
141
+
142
+ exports.useVendorPublicConfig = useVendorPublicConfig;
143
+
144
+ const useVendorPublicConfigActions = () => {
145
+ const dispatch = (0, _FronteggStoreContext.useDispatch)();
146
+ return (0, _react.useMemo)(() => (0, _reduxStore.bindActionCreators)(_reduxStore.subscriptionActions.vendorPublicConfig, dispatch), [dispatch]);
147
+ };
148
+
149
+ exports.useVendorPublicConfigActions = useVendorPublicConfigActions;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/react-hooks",
3
- "version": "6.0.1-alpha.6",
3
+ "version": "6.0.3-alpha.2",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
+ "author": "Frontegg LTD",
6
7
  "dependencies": {
7
8
  "@babel/runtime": "^7.17.2",
8
- "@frontegg/redux-store": "6.0.1-alpha.6",
9
- "@frontegg/types": "6.0.1-alpha.6",
9
+ "@frontegg/redux-store": "6.0.3-alpha.2",
10
+ "@frontegg/types": "6.0.3-alpha.2",
10
11
  "@types/react": "^17.0.0 || ^18.0.0",
11
12
  "react-redux": "^7.x"
12
13
  },
@@ -1,4 +1,4 @@
1
- import { CheckoutActions, CheckoutState, PaymentProviderConfigActions, PaymentProviderConfigState, PlansActions, PlansState, StripeActions, StripeState, SubscriptionActions, SubscriptionState } from '@frontegg/redux-store';
1
+ import { CheckoutActions, CheckoutState, PaymentProviderConfigActions, PaymentProviderConfigState, PlansActions, PlansState, StripeActions, StripeState, SubscriptionActions, SubscriptionState, VendorPublicConfigurationActions, VendorPublicConfigurationState } from '@frontegg/redux-store';
2
2
  export declare const usePaymentProvider: () => PaymentProviderConfigState;
3
3
  export declare const usePaymentProviderActions: () => PaymentProviderConfigActions;
4
4
  export declare const usePlans: () => PlansState;
@@ -17,3 +17,5 @@ export declare const useSubscriptionCancellation: () => SubscriptionState['cance
17
17
  export declare const useSubscriptionRenewal: () => SubscriptionState['renewal'];
18
18
  export declare const useSubscription: () => SubscriptionState;
19
19
  export declare const useSubscriptionActions: () => SubscriptionActions;
20
+ export declare const useVendorPublicConfig: () => VendorPublicConfigurationState;
21
+ export declare const useVendorPublicConfigActions: () => VendorPublicConfigurationActions;
@@ -66,4 +66,16 @@ export const useSubscription = () => {
66
66
  export const useSubscriptionActions = () => {
67
67
  const dispatch = useDispatch();
68
68
  return useMemo(() => bindActionCreators(subscriptionActions.billing.subscription, dispatch), [dispatch]);
69
+ };
70
+ export const useVendorPublicConfig = () => {
71
+ return useSelector(state => {
72
+ const {
73
+ vendorPublicConfig
74
+ } = getSubscriptionState(state);
75
+ return vendorPublicConfig;
76
+ }, shallowEqual);
77
+ };
78
+ export const useVendorPublicConfigActions = () => {
79
+ const dispatch = useDispatch();
80
+ return useMemo(() => bindActionCreators(subscriptionActions.vendorPublicConfig, dispatch), [dispatch]);
69
81
  };