@frontegg/react-hooks 6.143.0-alpha.4 → 6.143.0-alpha.6
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/auth/entitlements.d.ts +0 -7
- package/auth/entitlements.js +0 -12
- package/auth/index.d.ts +1 -0
- package/auth/index.js +2 -1
- package/auth/sms.d.ts +6 -0
- package/auth/sms.js +7 -0
- package/index.js +1 -1
- package/node/auth/entitlements.js +2 -15
- package/node/auth/index.js +12 -0
- package/node/auth/sms.js +15 -0
- package/node/index.js +1 -1
- package/package.json +3 -3
package/auth/entitlements.d.ts
CHANGED
|
@@ -14,10 +14,3 @@ export declare const usePermissionEntitlements: (key: string) => Entitlement;
|
|
|
14
14
|
@returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
|
|
15
15
|
*/
|
|
16
16
|
export declare const useEntitlements: (options: EntitledToOptions) => Entitlement;
|
|
17
|
-
/**
|
|
18
|
-
@param entitledToOptions including permission or feature key
|
|
19
|
-
@returns an action your can use to detect if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
|
|
20
|
-
*/
|
|
21
|
-
export declare const useEntitlementsActions: () => {
|
|
22
|
-
isEntitledTo: (options: EntitledToOptions) => Entitlement;
|
|
23
|
-
};
|
package/auth/entitlements.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getPermissionEntitlements, getFeatureEntitlements, getEntitlements } from '@frontegg/redux-store';
|
|
2
2
|
import { useAuth } from './hooks';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* @returns entitlemenets state as stored in the user
|
|
@@ -34,15 +33,4 @@ export const usePermissionEntitlements = key => {
|
|
|
34
33
|
export const useEntitlements = options => {
|
|
35
34
|
const entitlements = useEntitlementsState();
|
|
36
35
|
return getEntitlements(entitlements, options);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
@param entitledToOptions including permission or feature key
|
|
41
|
-
@returns an action your can use to detect if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
|
|
42
|
-
*/
|
|
43
|
-
export const useEntitlementsActions = () => {
|
|
44
|
-
const entitlements = useEntitlementsState();
|
|
45
|
-
return useMemo(() => ({
|
|
46
|
-
isEntitledTo: options => getEntitlements(entitlements, options)
|
|
47
|
-
}), [entitlements]);
|
|
48
36
|
};
|
package/auth/index.d.ts
CHANGED
package/auth/index.js
CHANGED
package/auth/sms.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SmsActions, SmsState } from '@frontegg/redux-store';
|
|
2
|
+
declare type AuthSmsStateMapper<S> = (state: SmsState) => S;
|
|
3
|
+
export declare function useSmsState(): SmsState;
|
|
4
|
+
export declare function useSmsState<S>(stateMapper: AuthSmsStateMapper<S>): S;
|
|
5
|
+
export declare const useSmsActions: () => SmsActions;
|
|
6
|
+
export {};
|
package/auth/sms.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { smsActions, smsReducers } from '@frontegg/redux-store';
|
|
2
|
+
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
+
const defaultMapper = state => state;
|
|
4
|
+
export function useSmsState(stateMapper = defaultMapper) {
|
|
5
|
+
return stateHookGenerator(stateMapper, 'smsState');
|
|
6
|
+
}
|
|
7
|
+
export const useSmsActions = () => reducerActionsGenerator(smsActions, smsReducers);
|
package/index.js
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.usePermissionEntitlements = exports.useFeatureEntitlements = exports.
|
|
6
|
+
exports.usePermissionEntitlements = exports.useFeatureEntitlements = exports.useEntitlements = void 0;
|
|
7
7
|
var _reduxStore = require("@frontegg/redux-store");
|
|
8
8
|
var _hooks = require("./hooks");
|
|
9
|
-
var _react = require("react");
|
|
10
9
|
/**
|
|
11
10
|
* @returns entitlemenets state as stored in the user
|
|
12
11
|
*/
|
|
@@ -42,16 +41,4 @@ const useEntitlements = options => {
|
|
|
42
41
|
const entitlements = useEntitlementsState();
|
|
43
42
|
return (0, _reduxStore.getEntitlements)(entitlements, options);
|
|
44
43
|
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
@param entitledToOptions including permission or feature key
|
|
48
|
-
@returns an action your can use to detect if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
|
|
49
|
-
*/
|
|
50
|
-
exports.useEntitlements = useEntitlements;
|
|
51
|
-
const useEntitlementsActions = () => {
|
|
52
|
-
const entitlements = useEntitlementsState();
|
|
53
|
-
return (0, _react.useMemo)(() => ({
|
|
54
|
-
isEntitledTo: options => (0, _reduxStore.getEntitlements)(entitlements, options)
|
|
55
|
-
}), [entitlements]);
|
|
56
|
-
};
|
|
57
|
-
exports.useEntitlementsActions = useEntitlementsActions;
|
|
44
|
+
exports.useEntitlements = useEntitlements;
|
package/node/auth/index.js
CHANGED
|
@@ -373,4 +373,16 @@ Object.keys(_securityCenter).forEach(function (key) {
|
|
|
373
373
|
return _securityCenter[key];
|
|
374
374
|
}
|
|
375
375
|
});
|
|
376
|
+
});
|
|
377
|
+
var _sms = require("./sms");
|
|
378
|
+
Object.keys(_sms).forEach(function (key) {
|
|
379
|
+
if (key === "default" || key === "__esModule") return;
|
|
380
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
381
|
+
if (key in exports && exports[key] === _sms[key]) return;
|
|
382
|
+
Object.defineProperty(exports, key, {
|
|
383
|
+
enumerable: true,
|
|
384
|
+
get: function () {
|
|
385
|
+
return _sms[key];
|
|
386
|
+
}
|
|
387
|
+
});
|
|
376
388
|
});
|
package/node/auth/sms.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSmsActions = void 0;
|
|
7
|
+
exports.useSmsState = useSmsState;
|
|
8
|
+
var _reduxStore = require("@frontegg/redux-store");
|
|
9
|
+
var _hooks = require("./hooks");
|
|
10
|
+
const defaultMapper = state => state;
|
|
11
|
+
function useSmsState(stateMapper = defaultMapper) {
|
|
12
|
+
return (0, _hooks.stateHookGenerator)(stateMapper, 'smsState');
|
|
13
|
+
}
|
|
14
|
+
const useSmsActions = () => (0, _hooks.reducerActionsGenerator)(_reduxStore.smsActions, _reduxStore.smsReducers);
|
|
15
|
+
exports.useSmsActions = useSmsActions;
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/react-hooks",
|
|
3
|
-
"version": "6.143.0-alpha.
|
|
3
|
+
"version": "6.143.0-alpha.6",
|
|
4
4
|
"main": "./node/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frontegg LTD",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/runtime": "^7.18.6",
|
|
9
|
-
"@frontegg/redux-store": "6.143.0-alpha.
|
|
10
|
-
"@frontegg/types": "6.143.0-alpha.
|
|
9
|
+
"@frontegg/redux-store": "6.143.0-alpha.6",
|
|
10
|
+
"@frontegg/types": "6.143.0-alpha.6",
|
|
11
11
|
"@types/react": "*",
|
|
12
12
|
"get-value": "^3.0.1",
|
|
13
13
|
"react-redux": "^7.x"
|