@webiny/app-security 5.43.3 → 6.0.0-alpha.1
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/Security.js +10 -17
- package/Security.js.map +1 -1
- package/components/HasPermission.js +18 -32
- package/components/HasPermission.js.map +1 -1
- package/components/SecureRoute.d.ts +1 -1
- package/components/SecureRoute.js +13 -16
- package/components/SecureRoute.js.map +1 -1
- package/components/SecureView.d.ts +2 -2
- package/components/SecureView.js +12 -16
- package/components/SecureView.js.map +1 -1
- package/components/index.js +3 -27
- package/components/index.js.map +1 -1
- package/contexts/Security.d.ts +3 -2
- package/contexts/Security.js +29 -54
- package/contexts/Security.js.map +1 -1
- package/hooks/usePermission.d.ts +1 -1
- package/hooks/usePermission.js +5 -10
- package/hooks/usePermission.js.map +1 -1
- package/hooks/useSecurity.js +5 -11
- package/hooks/useSecurity.js.map +1 -1
- package/index.js +6 -74
- package/index.js.map +1 -1
- package/package.json +5 -5
- package/types.d.ts +1 -1
- package/types.js +1 -5
- package/types.js.map +1 -1
package/Security.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.Security = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _app = require("@webiny/app");
|
|
10
|
-
var _Security = require("./contexts/Security");
|
|
11
1
|
// Importing from `app-core` and NOT from `app-admin`, to avoid circular dependency.
|
|
12
2
|
// This can be resolved in a different way, by changing the location of `AppInstaller` component (currently in `app-admin`).
|
|
13
3
|
// But this is a faster solution, as I'm really short on time :)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { Provider } from "@webiny/app";
|
|
6
|
+
import { SecurityProvider as ContextProvider } from "./contexts/Security";
|
|
7
|
+
const SecurityProviderHOC = Component => {
|
|
8
|
+
return function SecurityProvider({
|
|
9
|
+
children
|
|
10
|
+
}) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(ContextProvider, null, /*#__PURE__*/React.createElement(Component, null, children));
|
|
19
12
|
};
|
|
20
13
|
};
|
|
21
|
-
|
|
22
|
-
return /*#__PURE__*/
|
|
14
|
+
export const Security = () => {
|
|
15
|
+
return /*#__PURE__*/React.createElement(Provider, {
|
|
23
16
|
hoc: SecurityProviderHOC
|
|
24
17
|
});
|
|
25
18
|
};
|
package/Security.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","Provider","SecurityProvider","ContextProvider","SecurityProviderHOC","Component","children","createElement","Security","hoc"],"sources":["Security.tsx"],"sourcesContent":["// Importing from `app-core` and NOT from `app-admin`, to avoid circular dependency.\n// This can be resolved in a different way, by changing the location of `AppInstaller` component (currently in `app-admin`).\n// But this is a faster solution, as I'm really short on time :)\nimport React from \"react\";\nimport { Provider } from \"@webiny/app\";\nimport { SecurityProvider as ContextProvider } from \"./contexts/Security\";\n\ninterface SecurityProviderProps {\n children: React.ReactNode;\n}\n\nconst SecurityProviderHOC = (Component: React.ComponentType<SecurityProviderProps>) => {\n return function SecurityProvider({ children }: SecurityProviderProps) {\n return (\n <ContextProvider>\n <Component>{children}</Component>\n </ContextProvider>\n );\n };\n};\n\nexport const Security = () => {\n return <Provider hoc={SecurityProviderHOC} />;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,gBAAgB,IAAIC,eAAe;AAM5C,MAAMC,mBAAmB,GAAIC,SAAqD,IAAK;EACnF,OAAO,SAASH,gBAAgBA,CAAC;IAAEI;EAAgC,CAAC,EAAE;IAClE,oBACIN,KAAA,CAAAO,aAAA,CAACJ,eAAe,qBACZH,KAAA,CAAAO,aAAA,CAACF,SAAS,QAAEC,QAAoB,CACnB,CAAC;EAE1B,CAAC;AACL,CAAC;AAED,OAAO,MAAME,QAAQ,GAAGA,CAAA,KAAM;EAC1B,oBAAOR,KAAA,CAAAO,aAAA,CAACN,QAAQ;IAACQ,GAAG,EAAEL;EAAoB,CAAE,CAAC;AACjD,CAAC","ignoreList":[]}
|
|
@@ -1,42 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _useSecurity2 = require("../hooks/useSecurity");
|
|
12
|
-
var _excluded = ["children"];
|
|
13
|
-
var HasPermission = exports.HasPermission = function HasPermission(_ref) {
|
|
14
|
-
var children = _ref.children,
|
|
15
|
-
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
16
|
-
var _useSecurity = (0, _useSecurity2.useSecurity)(),
|
|
17
|
-
getPermissions = _useSecurity.getPermissions;
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { useSecurity } from "../hooks/useSecurity";
|
|
3
|
+
export const HasPermission = ({
|
|
4
|
+
children,
|
|
5
|
+
...props
|
|
6
|
+
}) => {
|
|
7
|
+
const {
|
|
8
|
+
getPermissions
|
|
9
|
+
} = useSecurity();
|
|
18
10
|
if (props.name) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
return /*#__PURE__*/
|
|
11
|
+
const permissionsCollections = getPermissions(props.name);
|
|
12
|
+
const hasPermission = permissionsCollections.length > 0;
|
|
13
|
+
if (hasPermission) {
|
|
14
|
+
return /*#__PURE__*/React.createElement(Fragment, null, children);
|
|
23
15
|
}
|
|
24
16
|
return null;
|
|
25
17
|
}
|
|
26
18
|
if (props.any && props.all) {
|
|
27
|
-
throw new Error(
|
|
19
|
+
throw new Error(`You can use either "any" or "all", but not both at the same time.`);
|
|
28
20
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
var hasPermission = props.any ? permissionsCollections.some(function (collection) {
|
|
34
|
-
return collection.length > 0;
|
|
35
|
-
}) : permissionsCollections.every(function (collection) {
|
|
36
|
-
return collection.length > 0;
|
|
37
|
-
});
|
|
21
|
+
const anyAllPermissions = props.any || props.all || [];
|
|
22
|
+
const permissionsCollections = anyAllPermissions.map(name => getPermissions(name));
|
|
23
|
+
const hasPermission = props.any ? permissionsCollections.some(collection => collection.length > 0) : permissionsCollections.every(collection => collection.length > 0);
|
|
38
24
|
if (hasPermission) {
|
|
39
|
-
return /*#__PURE__*/
|
|
25
|
+
return /*#__PURE__*/React.createElement(Fragment, null, children);
|
|
40
26
|
}
|
|
41
27
|
return null;
|
|
42
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","Fragment","useSecurity","HasPermission","children","props","getPermissions","name","permissionsCollections","hasPermission","length","createElement","any","all","Error","anyAllPermissions","map","some","collection","every"],"sources":["HasPermission.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport { useSecurity } from \"~/hooks/useSecurity\";\n\ninterface HasPermissionProps {\n any?: string[];\n all?: string[];\n name?: string;\n children: React.ReactNode;\n}\n\nexport const HasPermission = ({ children, ...props }: HasPermissionProps) => {\n const { getPermissions } = useSecurity();\n\n if (props.name) {\n const permissionsCollections = getPermissions(props.name);\n const hasPermission = permissionsCollections.length > 0;\n if (hasPermission) {\n return <Fragment>{children}</Fragment>;\n }\n\n return null;\n }\n\n if (props.any && props.all) {\n throw new Error(`You can use either \"any\" or \"all\", but not both at the same time.`);\n }\n\n const anyAllPermissions = props.any || props.all || [];\n\n const permissionsCollections = anyAllPermissions.map(name => getPermissions(name));\n\n const hasPermission = props.any\n ? permissionsCollections.some(collection => collection.length > 0)\n : permissionsCollections.every(collection => collection.length > 0);\n\n if (hasPermission) {\n return <Fragment>{children}</Fragment>;\n }\n\n return null;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,WAAW;AASpB,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC,QAAQ;EAAE,GAAGC;AAA0B,CAAC,KAAK;EACzE,MAAM;IAAEC;EAAe,CAAC,GAAGJ,WAAW,CAAC,CAAC;EAExC,IAAIG,KAAK,CAACE,IAAI,EAAE;IACZ,MAAMC,sBAAsB,GAAGF,cAAc,CAACD,KAAK,CAACE,IAAI,CAAC;IACzD,MAAME,aAAa,GAAGD,sBAAsB,CAACE,MAAM,GAAG,CAAC;IACvD,IAAID,aAAa,EAAE;MACf,oBAAOT,KAAA,CAAAW,aAAA,CAACV,QAAQ,QAAEG,QAAmB,CAAC;IAC1C;IAEA,OAAO,IAAI;EACf;EAEA,IAAIC,KAAK,CAACO,GAAG,IAAIP,KAAK,CAACQ,GAAG,EAAE;IACxB,MAAM,IAAIC,KAAK,CAAC,mEAAmE,CAAC;EACxF;EAEA,MAAMC,iBAAiB,GAAGV,KAAK,CAACO,GAAG,IAAIP,KAAK,CAACQ,GAAG,IAAI,EAAE;EAEtD,MAAML,sBAAsB,GAAGO,iBAAiB,CAACC,GAAG,CAACT,IAAI,IAAID,cAAc,CAACC,IAAI,CAAC,CAAC;EAElF,MAAME,aAAa,GAAGJ,KAAK,CAACO,GAAG,GACzBJ,sBAAsB,CAACS,IAAI,CAACC,UAAU,IAAIA,UAAU,CAACR,MAAM,GAAG,CAAC,CAAC,GAChEF,sBAAsB,CAACW,KAAK,CAACD,UAAU,IAAIA,UAAU,CAACR,MAAM,GAAG,CAAC,CAAC;EAEvE,IAAID,aAAa,EAAE;IACf,oBAAOT,KAAA,CAAAW,aAAA,CAACV,QAAQ,QAAEG,QAAmB,CAAC;EAC1C;EAEA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _plugins = require("@webiny/plugins");
|
|
9
|
-
var _default = exports.default = function _default(_ref) {
|
|
10
|
-
var children = _ref.children,
|
|
11
|
-
permission = _ref.permission;
|
|
12
|
-
var security = (0, _useSecurity.useSecurity)();
|
|
1
|
+
import { useSecurity } from "../hooks/useSecurity";
|
|
2
|
+
import { plugins } from "@webiny/plugins";
|
|
3
|
+
export default ({
|
|
4
|
+
children,
|
|
5
|
+
permission
|
|
6
|
+
}) => {
|
|
7
|
+
const security = useSecurity();
|
|
13
8
|
if (!security) {
|
|
14
9
|
return null;
|
|
15
10
|
}
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const {
|
|
12
|
+
identity,
|
|
13
|
+
getPermission
|
|
14
|
+
} = security;
|
|
18
15
|
if (!identity) {
|
|
19
16
|
return null;
|
|
20
17
|
}
|
|
21
|
-
|
|
18
|
+
let hasPermission = false;
|
|
22
19
|
if (identity) {
|
|
23
20
|
hasPermission = permission ? Boolean(getPermission(permission)) : true;
|
|
24
21
|
}
|
|
25
22
|
if (hasPermission) {
|
|
26
23
|
return children;
|
|
27
24
|
}
|
|
28
|
-
|
|
25
|
+
const plugin = plugins.byName("secure-route-error");
|
|
29
26
|
if (!plugin) {
|
|
30
27
|
return null;
|
|
31
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useSecurity","plugins","children","permission","security","identity","getPermission","hasPermission","Boolean","plugin","byName","render"],"sources":["SecureRoute.tsx"],"sourcesContent":["import type React from \"react\";\nimport { useSecurity } from \"~/hooks/useSecurity\";\nimport type { SecureRouteErrorPlugin } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface SecureRouteProps {\n children: React.ReactNode;\n permission?: string;\n}\nexport default ({ children, permission }: SecureRouteProps): React.ReactElement | null => {\n const security = useSecurity();\n\n if (!security) {\n return null;\n }\n\n const { identity, getPermission } = security;\n\n if (!identity) {\n return null;\n }\n\n let hasPermission = false;\n if (identity) {\n hasPermission = permission ? Boolean(getPermission(permission)) : true;\n }\n\n if (hasPermission) {\n return children as unknown as React.ReactElement;\n }\n\n const plugin = plugins.byName<SecureRouteErrorPlugin>(\"secure-route-error\");\n if (!plugin) {\n return null;\n }\n\n return plugin.render();\n};\n"],"mappings":"AACA,SAASA,WAAW;AAEpB,SAASC,OAAO,QAAQ,iBAAiB;AAMzC,eAAe,CAAC;EAAEC,QAAQ;EAAEC;AAA6B,CAAC,KAAgC;EACtF,MAAMC,QAAQ,GAAGJ,WAAW,CAAC,CAAC;EAE9B,IAAI,CAACI,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EAEA,MAAM;IAAEC,QAAQ;IAAEC;EAAc,CAAC,GAAGF,QAAQ;EAE5C,IAAI,CAACC,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EAEA,IAAIE,aAAa,GAAG,KAAK;EACzB,IAAIF,QAAQ,EAAE;IACVE,aAAa,GAAGJ,UAAU,GAAGK,OAAO,CAACF,aAAa,CAACH,UAAU,CAAC,CAAC,GAAG,IAAI;EAC1E;EAEA,IAAII,aAAa,EAAE;IACf,OAAOL,QAAQ;EACnB;EAEA,MAAMO,MAAM,GAAGR,OAAO,CAACS,MAAM,CAAyB,oBAAoB,CAAC;EAC3E,IAAI,CAACD,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,OAAOA,MAAM,CAACE,MAAM,CAAC,CAAC;AAC1B,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { SecurityPermission } from "../types";
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { SecurityPermission } from "../types";
|
|
3
3
|
interface ChildrenRenderFunctionArgs<T extends SecurityPermission> {
|
|
4
4
|
hasPermission: boolean;
|
|
5
5
|
permission: T | null;
|
package/components/SecureView.js
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _useSecurity = (0, _useSecurity2.useSecurity)(),
|
|
12
|
-
getPermission = _useSecurity.getPermission;
|
|
13
|
-
var hasPermission = false;
|
|
14
|
-
var matchedPermission = null;
|
|
1
|
+
import { useSecurity } from "../hooks/useSecurity";
|
|
2
|
+
function SecureView({
|
|
3
|
+
children,
|
|
4
|
+
permission
|
|
5
|
+
}) {
|
|
6
|
+
const {
|
|
7
|
+
getPermission
|
|
8
|
+
} = useSecurity();
|
|
9
|
+
let hasPermission = false;
|
|
10
|
+
let matchedPermission = null;
|
|
15
11
|
if (permission) {
|
|
16
12
|
matchedPermission = getPermission(permission);
|
|
17
13
|
hasPermission = Boolean(matchedPermission);
|
|
18
14
|
}
|
|
19
15
|
if (typeof children === "function") {
|
|
20
16
|
return children({
|
|
21
|
-
hasPermission
|
|
17
|
+
hasPermission,
|
|
22
18
|
permission: matchedPermission
|
|
23
19
|
});
|
|
24
20
|
}
|
|
25
21
|
return hasPermission ? children : null;
|
|
26
22
|
}
|
|
27
|
-
|
|
23
|
+
export default SecureView;
|
|
28
24
|
|
|
29
25
|
//# sourceMappingURL=SecureView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useSecurity","SecureView","children","permission","getPermission","hasPermission","matchedPermission","Boolean"],"sources":["SecureView.tsx"],"sourcesContent":["import type * as React from \"react\";\nimport { useSecurity } from \"~/hooks/useSecurity\";\nimport type { SecurityPermission } from \"~/types\";\n\ninterface ChildrenRenderFunctionArgs<T extends SecurityPermission> {\n hasPermission: boolean;\n permission: T | null;\n}\n\ninterface Props<T extends SecurityPermission> {\n children: ((args: ChildrenRenderFunctionArgs<T>) => React.ReactElement) | React.ReactElement;\n permission?: string;\n}\n\nfunction SecureView<T extends SecurityPermission>({\n children,\n permission\n}: Props<T>): React.ReactElement | null {\n const { getPermission } = useSecurity();\n\n let hasPermission = false;\n let matchedPermission: T | null = null;\n if (permission) {\n matchedPermission = getPermission<T>(permission);\n hasPermission = Boolean(matchedPermission);\n }\n\n if (typeof children === \"function\") {\n return children({\n hasPermission,\n permission: matchedPermission\n });\n }\n\n return hasPermission ? children : null;\n}\n\nexport default SecureView;\n"],"mappings":"AACA,SAASA,WAAW;AAapB,SAASC,UAAUA,CAA+B;EAC9CC,QAAQ;EACRC;AACM,CAAC,EAA6B;EACpC,MAAM;IAAEC;EAAc,CAAC,GAAGJ,WAAW,CAAC,CAAC;EAEvC,IAAIK,aAAa,GAAG,KAAK;EACzB,IAAIC,iBAA2B,GAAG,IAAI;EACtC,IAAIH,UAAU,EAAE;IACZG,iBAAiB,GAAGF,aAAa,CAAID,UAAU,CAAC;IAChDE,aAAa,GAAGE,OAAO,CAACD,iBAAiB,CAAC;EAC9C;EAEA,IAAI,OAAOJ,QAAQ,KAAK,UAAU,EAAE;IAChC,OAAOA,QAAQ,CAAC;MACZG,aAAa;MACbF,UAAU,EAAEG;IAChB,CAAC,CAAC;EACN;EAEA,OAAOD,aAAa,GAAGH,QAAQ,GAAG,IAAI;AAC1C;AAEA,eAAeD,UAAU","ignoreList":[]}
|
package/components/index.js
CHANGED
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "HasPermission", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function get() {
|
|
10
|
-
return _HasPermission.HasPermission;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "SecureRoute", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function get() {
|
|
16
|
-
return _SecureRoute.default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "SecureView", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function get() {
|
|
22
|
-
return _SecureView.default;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
var _SecureView = _interopRequireDefault(require("./SecureView"));
|
|
26
|
-
var _SecureRoute = _interopRequireDefault(require("./SecureRoute"));
|
|
27
|
-
var _HasPermission = require("./HasPermission");
|
|
1
|
+
export { default as SecureView } from "./SecureView";
|
|
2
|
+
export { default as SecureRoute } from "./SecureRoute";
|
|
3
|
+
export { HasPermission } from "./HasPermission";
|
|
28
4
|
|
|
29
5
|
//# sourceMappingURL=index.js.map
|
package/components/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["default","SecureView","SecureRoute","HasPermission"],"sources":["index.ts"],"sourcesContent":["export { default as SecureView } from \"./SecureView\";\nexport { default as SecureRoute } from \"./SecureRoute\";\nexport { HasPermission } from \"./HasPermission\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU;AAC9B,SAASD,OAAO,IAAIE,WAAW;AAC/B,SAASC,aAAa","ignoreList":[]}
|
package/contexts/Security.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { IdTokenProvider, SecurityIdentity, SecurityPermission } from "../types";
|
|
3
4
|
export interface SecurityContext {
|
|
4
5
|
identity: SecurityIdentity | null;
|
|
5
6
|
getIdentityId: () => string | null;
|
package/contexts/Security.js
CHANGED
|
@@ -1,38 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
var _minimatch = _interopRequireDefault(require("minimatch"));
|
|
12
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
var defaultIdTokenProvider = function defaultIdTokenProvider() {
|
|
14
|
-
return undefined;
|
|
15
|
-
};
|
|
16
|
-
var SecurityContext = exports.SecurityContext = /*#__PURE__*/_react.default.createContext(undefined);
|
|
17
|
-
var SecurityProvider = exports.SecurityProvider = function SecurityProvider(props) {
|
|
18
|
-
var _useState = (0, _react.useState)(null),
|
|
19
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
20
|
-
identity = _useState2[0],
|
|
21
|
-
setIdentity = _useState2[1];
|
|
22
|
-
var _useState3 = (0, _react.useState)(function () {
|
|
23
|
-
return defaultIdTokenProvider;
|
|
24
|
-
}),
|
|
25
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
26
|
-
idTokenProvider = _useState4[0],
|
|
27
|
-
_setIdTokenProvider = _useState4[1];
|
|
28
|
-
var getPermission = (0, _react.useCallback)(function (name, exact) {
|
|
1
|
+
import minimatch from "minimatch";
|
|
2
|
+
import React, { useCallback, useMemo, useState } from "react";
|
|
3
|
+
const defaultIdTokenProvider = () => undefined;
|
|
4
|
+
export const SecurityContext = /*#__PURE__*/React.createContext(undefined);
|
|
5
|
+
export const SecurityProvider = props => {
|
|
6
|
+
const [identity, setIdentity] = useState(null);
|
|
7
|
+
const [idTokenProvider, setIdTokenProvider] = useState(() => defaultIdTokenProvider);
|
|
8
|
+
const getPermission = useCallback((name, exact) => {
|
|
29
9
|
if (!identity) {
|
|
30
10
|
return null;
|
|
31
11
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return p.name === name;
|
|
35
|
-
});
|
|
12
|
+
const perms = identity.permissions || [];
|
|
13
|
+
const exactMatch = perms.find(p => p.name === name);
|
|
36
14
|
if (exactMatch) {
|
|
37
15
|
return exactMatch;
|
|
38
16
|
} else if (exact) {
|
|
@@ -40,50 +18,47 @@ var SecurityProvider = exports.SecurityProvider = function SecurityProvider(prop
|
|
|
40
18
|
}
|
|
41
19
|
|
|
42
20
|
// Try matching using patterns
|
|
43
|
-
return perms.find(
|
|
44
|
-
return (0, _minimatch.default)(name, p.name);
|
|
45
|
-
}) || null;
|
|
21
|
+
return perms.find(p => minimatch(name, p.name)) || null;
|
|
46
22
|
}, [identity]);
|
|
47
|
-
|
|
23
|
+
const getPermissions = useCallback(name => {
|
|
48
24
|
if (!identity) {
|
|
49
25
|
return [];
|
|
50
26
|
}
|
|
51
|
-
|
|
52
|
-
return permissions.filter(
|
|
53
|
-
|
|
27
|
+
const permissions = identity.permissions || [];
|
|
28
|
+
return permissions.filter(current => {
|
|
29
|
+
const exactMatch = current.name === name;
|
|
54
30
|
if (exactMatch) {
|
|
55
31
|
return true;
|
|
56
32
|
}
|
|
57
33
|
|
|
58
34
|
// Try matching using patterns.
|
|
59
|
-
return (
|
|
35
|
+
return minimatch(name, current.name);
|
|
60
36
|
});
|
|
61
37
|
}, [identity]);
|
|
62
|
-
|
|
38
|
+
const getIdentityId = useCallback(() => {
|
|
63
39
|
if (!identity) {
|
|
64
40
|
return null;
|
|
65
41
|
}
|
|
66
42
|
return identity.id || identity.login || null;
|
|
67
43
|
}, [identity]);
|
|
68
|
-
|
|
44
|
+
const value = useMemo(() => {
|
|
69
45
|
return {
|
|
70
|
-
identity: identity ?
|
|
46
|
+
identity: identity ? {
|
|
47
|
+
...identity,
|
|
71
48
|
// For backwards compatibility, expose the `getPermission` method on the `identity` object.
|
|
72
|
-
getPermission
|
|
73
|
-
}
|
|
74
|
-
getIdentityId
|
|
75
|
-
setIdentity
|
|
76
|
-
getPermission
|
|
77
|
-
getPermissions
|
|
49
|
+
getPermission
|
|
50
|
+
} : null,
|
|
51
|
+
getIdentityId,
|
|
52
|
+
setIdentity,
|
|
53
|
+
getPermission,
|
|
54
|
+
getPermissions,
|
|
78
55
|
getIdToken: idTokenProvider,
|
|
79
|
-
setIdTokenProvider:
|
|
80
|
-
|
|
81
|
-
return provider;
|
|
82
|
-
});
|
|
56
|
+
setIdTokenProvider: provider => {
|
|
57
|
+
setIdTokenProvider(() => provider);
|
|
83
58
|
}
|
|
84
59
|
};
|
|
85
60
|
}, [idTokenProvider, identity]);
|
|
86
|
-
return /*#__PURE__*/
|
|
61
|
+
return /*#__PURE__*/React.createElement(SecurityContext.Provider, {
|
|
87
62
|
value: value
|
|
88
63
|
}, props.children);
|
|
89
64
|
};
|
package/contexts/Security.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["minimatch","React","useCallback","useMemo","useState","defaultIdTokenProvider","undefined","SecurityContext","createContext","SecurityProvider","props","identity","setIdentity","idTokenProvider","setIdTokenProvider","getPermission","name","exact","perms","permissions","exactMatch","find","p","getPermissions","filter","current","getIdentityId","id","login","value","getIdToken","provider","createElement","Provider","children"],"sources":["Security.tsx"],"sourcesContent":["import minimatch from \"minimatch\";\nimport type { Dispatch, SetStateAction } from \"react\";\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport type { IdTokenProvider, SecurityIdentity, SecurityPermission } from \"~/types\";\n\nexport interface SecurityContext {\n identity: SecurityIdentity | null;\n getIdentityId: () => string | null;\n setIdentity: Dispatch<SetStateAction<SecurityIdentity | null>>;\n getPermission<T extends SecurityPermission = SecurityPermission>(\n name: string,\n exact?: boolean\n ): T | null;\n getPermissions<T extends SecurityPermission = SecurityPermission>(name: string): T[];\n setIdTokenProvider: (provider: IdTokenProvider) => void;\n getIdToken: IdTokenProvider;\n}\n\ninterface SecurityProviderProps {\n children: React.ReactNode;\n}\n\nconst defaultIdTokenProvider: IdTokenProvider = () => undefined;\n\nexport const SecurityContext = React.createContext<SecurityContext | undefined>(undefined);\n\nexport const SecurityProvider = (props: SecurityProviderProps) => {\n const [identity, setIdentity] = useState<SecurityIdentity | null>(null);\n const [idTokenProvider, setIdTokenProvider] = useState<IdTokenProvider>(\n () => defaultIdTokenProvider\n );\n\n const getPermission = useCallback(\n <T extends SecurityPermission = SecurityPermission>(\n name: string,\n exact?: boolean\n ): T | null => {\n if (!identity) {\n return null;\n }\n\n const perms = (identity.permissions || []) as T[];\n const exactMatch = perms.find(p => p.name === name);\n if (exactMatch) {\n return exactMatch as T;\n } else if (exact) {\n return null;\n }\n\n // Try matching using patterns\n return perms.find(p => minimatch(name, p.name)) || null;\n },\n [identity]\n );\n\n const getPermissions = useCallback(\n <T extends SecurityPermission = SecurityPermission>(name: string): Array<T> => {\n if (!identity) {\n return [];\n }\n\n const permissions = identity.permissions || [];\n\n return permissions.filter(current => {\n const exactMatch = current.name === name;\n if (exactMatch) {\n return true;\n }\n\n // Try matching using patterns.\n return minimatch(name, current.name);\n }) as T[];\n },\n [identity]\n );\n\n const getIdentityId = useCallback(() => {\n if (!identity) {\n return null;\n }\n return identity.id || identity.login || null;\n }, [identity]);\n\n const value: SecurityContext = useMemo(() => {\n return {\n identity: identity\n ? {\n ...identity,\n // For backwards compatibility, expose the `getPermission` method on the `identity` object.\n getPermission\n }\n : null,\n getIdentityId,\n setIdentity,\n getPermission,\n getPermissions,\n getIdToken: idTokenProvider,\n setIdTokenProvider: provider => {\n setIdTokenProvider(() => provider);\n }\n };\n }, [idTokenProvider, identity]);\n\n return <SecurityContext.Provider value={value}>{props.children}</SecurityContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,WAAW;AAEjC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAoB7D,MAAMC,sBAAuC,GAAGA,CAAA,KAAMC,SAAS;AAE/D,OAAO,MAAMC,eAAe,gBAAGN,KAAK,CAACO,aAAa,CAA8BF,SAAS,CAAC;AAE1F,OAAO,MAAMG,gBAAgB,GAAIC,KAA4B,IAAK;EAC9D,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGR,QAAQ,CAA0B,IAAI,CAAC;EACvE,MAAM,CAACS,eAAe,EAAEC,kBAAkB,CAAC,GAAGV,QAAQ,CAClD,MAAMC,sBACV,CAAC;EAED,MAAMU,aAAa,GAAGb,WAAW,CAC7B,CACIc,IAAY,EACZC,KAAe,KACJ;IACX,IAAI,CAACN,QAAQ,EAAE;MACX,OAAO,IAAI;IACf;IAEA,MAAMO,KAAK,GAAIP,QAAQ,CAACQ,WAAW,IAAI,EAAU;IACjD,MAAMC,UAAU,GAAGF,KAAK,CAACG,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACN,IAAI,KAAKA,IAAI,CAAC;IACnD,IAAII,UAAU,EAAE;MACZ,OAAOA,UAAU;IACrB,CAAC,MAAM,IAAIH,KAAK,EAAE;MACd,OAAO,IAAI;IACf;;IAEA;IACA,OAAOC,KAAK,CAACG,IAAI,CAACC,CAAC,IAAItB,SAAS,CAACgB,IAAI,EAAEM,CAAC,CAACN,IAAI,CAAC,CAAC,IAAI,IAAI;EAC3D,CAAC,EACD,CAACL,QAAQ,CACb,CAAC;EAED,MAAMY,cAAc,GAAGrB,WAAW,CACsBc,IAAY,IAAe;IAC3E,IAAI,CAACL,QAAQ,EAAE;MACX,OAAO,EAAE;IACb;IAEA,MAAMQ,WAAW,GAAGR,QAAQ,CAACQ,WAAW,IAAI,EAAE;IAE9C,OAAOA,WAAW,CAACK,MAAM,CAACC,OAAO,IAAI;MACjC,MAAML,UAAU,GAAGK,OAAO,CAACT,IAAI,KAAKA,IAAI;MACxC,IAAII,UAAU,EAAE;QACZ,OAAO,IAAI;MACf;;MAEA;MACA,OAAOpB,SAAS,CAACgB,IAAI,EAAES,OAAO,CAACT,IAAI,CAAC;IACxC,CAAC,CAAC;EACN,CAAC,EACD,CAACL,QAAQ,CACb,CAAC;EAED,MAAMe,aAAa,GAAGxB,WAAW,CAAC,MAAM;IACpC,IAAI,CAACS,QAAQ,EAAE;MACX,OAAO,IAAI;IACf;IACA,OAAOA,QAAQ,CAACgB,EAAE,IAAIhB,QAAQ,CAACiB,KAAK,IAAI,IAAI;EAChD,CAAC,EAAE,CAACjB,QAAQ,CAAC,CAAC;EAEd,MAAMkB,KAAsB,GAAG1B,OAAO,CAAC,MAAM;IACzC,OAAO;MACHQ,QAAQ,EAAEA,QAAQ,GACZ;QACI,GAAGA,QAAQ;QACX;QACAI;MACJ,CAAC,GACD,IAAI;MACVW,aAAa;MACbd,WAAW;MACXG,aAAa;MACbQ,cAAc;MACdO,UAAU,EAAEjB,eAAe;MAC3BC,kBAAkB,EAAEiB,QAAQ,IAAI;QAC5BjB,kBAAkB,CAAC,MAAMiB,QAAQ,CAAC;MACtC;IACJ,CAAC;EACL,CAAC,EAAE,CAAClB,eAAe,EAAEF,QAAQ,CAAC,CAAC;EAE/B,oBAAOV,KAAA,CAAA+B,aAAA,CAACzB,eAAe,CAAC0B,QAAQ;IAACJ,KAAK,EAAEA;EAAM,GAAEnB,KAAK,CAACwB,QAAmC,CAAC;AAC9F,CAAC","ignoreList":[]}
|
package/hooks/usePermission.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SecurityPermission } from "../types";
|
|
1
|
+
import type { SecurityPermission } from "../types";
|
|
2
2
|
export declare function usePermission<T extends SecurityPermission = SecurityPermission>(name: string): T | null;
|
package/hooks/usePermission.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.usePermission = usePermission;
|
|
7
|
-
var _useSecurity2 = require("./useSecurity");
|
|
8
|
-
function usePermission(name) {
|
|
9
|
-
var _useSecurity = (0, _useSecurity2.useSecurity)(),
|
|
10
|
-
getPermission = _useSecurity.getPermission;
|
|
1
|
+
import { useSecurity } from "./useSecurity";
|
|
2
|
+
export function usePermission(name) {
|
|
3
|
+
const {
|
|
4
|
+
getPermission
|
|
5
|
+
} = useSecurity();
|
|
11
6
|
return getPermission(name);
|
|
12
7
|
}
|
|
13
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useSecurity","usePermission","name","getPermission"],"sources":["usePermission.ts"],"sourcesContent":["import { useSecurity } from \"~/hooks/useSecurity\";\nimport type { SecurityPermission } from \"~/types\";\n\nexport function usePermission<T extends SecurityPermission = SecurityPermission>(name: string) {\n const { getPermission } = useSecurity();\n return getPermission<T>(name);\n}\n"],"mappings":"AAAA,SAASA,WAAW;AAGpB,OAAO,SAASC,aAAaA,CAAoDC,IAAY,EAAE;EAC3F,MAAM;IAAEC;EAAc,CAAC,GAAGH,WAAW,CAAC,CAAC;EACvC,OAAOG,aAAa,CAAID,IAAI,CAAC;AACjC","ignoreList":[]}
|
package/hooks/useSecurity.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.useSecurity = useSecurity;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _Security = require("../contexts/Security");
|
|
9
|
-
function useSecurity() {
|
|
10
|
-
var context = (0, _react.useContext)(_Security.SecurityContext);
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { SecurityContext } from "../contexts/Security";
|
|
3
|
+
export function useSecurity() {
|
|
4
|
+
const context = useContext(SecurityContext);
|
|
11
5
|
if (!context) {
|
|
12
|
-
throw Error(
|
|
6
|
+
throw Error(`Missing <SecurityProvider> in the component hierarchy!`);
|
|
13
7
|
}
|
|
14
8
|
return context;
|
|
15
9
|
}
|
package/hooks/useSecurity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useContext","SecurityContext","useSecurity","context","Error"],"sources":["useSecurity.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { SecurityContext } from \"~/contexts/Security\";\n\nexport function useSecurity() {\n const context = useContext(SecurityContext);\n\n if (!context) {\n throw Error(`Missing <SecurityProvider> in the component hierarchy!`);\n }\n\n return context;\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,eAAe;AAExB,OAAO,SAASC,WAAWA,CAAA,EAAG;EAC1B,MAAMC,OAAO,GAAGH,UAAU,CAACC,eAAe,CAAC;EAE3C,IAAI,CAACE,OAAO,EAAE;IACV,MAAMC,KAAK,CAAC,wDAAwD,CAAC;EACzE;EAEA,OAAOD,OAAO;AAClB","ignoreList":[]}
|
package/index.js
CHANGED
|
@@ -1,76 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
SecurityContext: true
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "SecurityContext", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function get() {
|
|
12
|
-
return _Security.SecurityContext;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
var _components = require("./components");
|
|
16
|
-
Object.keys(_components).forEach(function (key) {
|
|
17
|
-
if (key === "default" || key === "__esModule") return;
|
|
18
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
-
if (key in exports && exports[key] === _components[key]) return;
|
|
20
|
-
Object.defineProperty(exports, key, {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function get() {
|
|
23
|
-
return _components[key];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
var _Security = require("./contexts/Security");
|
|
28
|
-
Object.keys(_Security).forEach(function (key) {
|
|
29
|
-
if (key === "default" || key === "__esModule") return;
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
|
-
if (key in exports && exports[key] === _Security[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function get() {
|
|
35
|
-
return _Security[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _useSecurity = require("./hooks/useSecurity");
|
|
40
|
-
Object.keys(_useSecurity).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
43
|
-
if (key in exports && exports[key] === _useSecurity[key]) return;
|
|
44
|
-
Object.defineProperty(exports, key, {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function get() {
|
|
47
|
-
return _useSecurity[key];
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
var _usePermission = require("./hooks/usePermission");
|
|
52
|
-
Object.keys(_usePermission).forEach(function (key) {
|
|
53
|
-
if (key === "default" || key === "__esModule") return;
|
|
54
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
55
|
-
if (key in exports && exports[key] === _usePermission[key]) return;
|
|
56
|
-
Object.defineProperty(exports, key, {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function get() {
|
|
59
|
-
return _usePermission[key];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
var _Security2 = require("./Security");
|
|
64
|
-
Object.keys(_Security2).forEach(function (key) {
|
|
65
|
-
if (key === "default" || key === "__esModule") return;
|
|
66
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
67
|
-
if (key in exports && exports[key] === _Security2[key]) return;
|
|
68
|
-
Object.defineProperty(exports, key, {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function get() {
|
|
71
|
-
return _Security2[key];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
1
|
+
export * from "./components";
|
|
2
|
+
export * from "./contexts/Security";
|
|
3
|
+
export { SecurityContext } from "./contexts/Security";
|
|
4
|
+
export * from "./hooks/useSecurity";
|
|
5
|
+
export * from "./hooks/usePermission";
|
|
6
|
+
export * from "./Security";
|
|
75
7
|
|
|
76
8
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["SecurityContext"],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./contexts/Security\";\nexport { SecurityContext } from \"./contexts/Security\";\nexport * from \"./hooks/useSecurity\";\nexport * from \"./hooks/usePermission\";\nexport * from \"./Security\";\n"],"mappings":"AAAA;AACA;AACA,SAASA,eAAe;AACxB;AACA;AACA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-security",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
],
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webiny/app": "
|
|
17
|
-
"@webiny/plugins": "
|
|
16
|
+
"@webiny/app": "6.0.0-alpha.1",
|
|
17
|
+
"@webiny/plugins": "6.0.0-alpha.1",
|
|
18
18
|
"minimatch": "5.1.6",
|
|
19
19
|
"react": "18.2.0",
|
|
20
20
|
"react-dom": "18.2.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@emotion/babel-plugin": "11.11.0",
|
|
24
|
-
"@webiny/project-utils": "
|
|
24
|
+
"@webiny/project-utils": "6.0.0-alpha.1",
|
|
25
25
|
"rimraf": "6.0.1",
|
|
26
26
|
"typescript": "5.3.3"
|
|
27
27
|
},
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
]
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "9bd236cf5e689f209a11bec089207dcc2d41a53c"
|
|
44
44
|
}
|
package/types.d.ts
CHANGED
package/types.js
CHANGED
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/app/types\";\n\nexport type SecureRouteErrorPlugin = Plugin & {\n render(): React.ReactElement;\n};\n\nexport interface FullAccessPermission {\n name: \"*\";\n}\n\nexport interface SecurityPermission {\n name: string;\n [key: string]: any;\n}\n\nexport interface SecurityIdentity {\n id: string;\n type: string;\n displayName: string;\n permissions?: SecurityPermission[];\n /**\n * TODO @ts-refactor @pavel\n * Verify that login can be present in here.\n */\n login?: string;\n /**\n * TODO @ts-refactor @pavel\n * Verify that profile can be present in here.\n */\n profile?: {\n email?: string;\n firstName?: string;\n lastName?: string;\n avatar?: {\n src?: string;\n };\n gravatar?: string;\n };\n logout(): void;\n // For backwards compatibility, expose the `getPermission` method on the `identity` object.\n getPermission?<T extends SecurityPermission = SecurityPermission>(name: string): T | null;\n [key: string]: any;\n}\n\nexport type IdToken = string;\n\nexport type IdTokenProvider = () => Promise<IdToken | undefined> | IdToken | undefined;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/app/types\";\n\nexport type SecureRouteErrorPlugin = Plugin & {\n render(): React.ReactElement;\n};\n\nexport interface FullAccessPermission {\n name: \"*\";\n}\n\nexport interface SecurityPermission {\n name: string;\n [key: string]: any;\n}\n\nexport interface SecurityIdentity {\n id: string;\n type: string;\n displayName: string;\n permissions?: SecurityPermission[];\n /**\n * TODO @ts-refactor @pavel\n * Verify that login can be present in here.\n */\n login?: string;\n /**\n * TODO @ts-refactor @pavel\n * Verify that profile can be present in here.\n */\n profile?: {\n email?: string;\n firstName?: string;\n lastName?: string;\n avatar?: {\n src?: string;\n };\n gravatar?: string;\n };\n logout(): void;\n // For backwards compatibility, expose the `getPermission` method on the `identity` object.\n getPermission?<T extends SecurityPermission = SecurityPermission>(name: string): T | null;\n [key: string]: any;\n}\n\nexport type IdToken = string;\n\nexport type IdTokenProvider = () => Promise<IdToken | undefined> | IdToken | undefined;\n"],"mappings":"","ignoreList":[]}
|