@webiny/app-security 0.0.0-mt-2 → 0.0.0-unstable.5e7233243f
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.d.ts +2 -0
- package/Security.js +38 -0
- package/Security.js.map +1 -0
- package/components/HasPermission.d.ts +9 -0
- package/components/HasPermission.js +48 -0
- package/components/HasPermission.js.map +1 -0
- package/components/SecureRoute.d.ts +5 -4
- package/components/SecureRoute.js +28 -8
- package/components/SecureRoute.js.map +1 -0
- package/components/SecureView.d.ts +2 -2
- package/components/SecureView.js +14 -6
- package/components/SecureView.js.map +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +31 -2
- package/components/index.js.map +1 -0
- package/contexts/Security.d.ts +5 -5
- package/contexts/Security.js +42 -14
- package/contexts/Security.js.map +1 -0
- package/hooks/usePermission.d.ts +2 -0
- package/hooks/usePermission.js +15 -0
- package/hooks/usePermission.js.map +1 -0
- package/hooks/useSecurity.d.ts +2 -2
- package/hooks/useSecurity.js +13 -4
- package/hooks/useSecurity.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +84 -3
- package/index.js.map +1 -0
- package/package.json +17 -22
- package/types.d.ts +19 -1
- package/types.js +5 -1
- package/types.js.map +1 -0
package/Security.d.ts
ADDED
package/Security.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.Security = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _appAdminCore = require("@webiny/app-admin-core");
|
|
13
|
+
|
|
14
|
+
var _Security = require("./contexts/Security");
|
|
15
|
+
|
|
16
|
+
// Importing from `app-admin-core` and NOT from `app-admin`, to avoid circular dependency.
|
|
17
|
+
// This can be resolved in a different way, by changing the location of `AppInstaller` component (currently in `app-admin`).
|
|
18
|
+
// But this is a faster solution, as I'm really short on time :)
|
|
19
|
+
var SecurityProviderHOC = function SecurityProviderHOC(Component) {
|
|
20
|
+
return function SecurityProvider(_ref) {
|
|
21
|
+
var children = _ref.children;
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(_Security.SecurityProvider, null, /*#__PURE__*/_react.default.createElement(Component, null, children));
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var Security = function Security() {
|
|
27
|
+
/**
|
|
28
|
+
* TODO @ts-refactor somewhere down the line in Provider.
|
|
29
|
+
* Provider expects ComponentType and we are giving it the React.FC.
|
|
30
|
+
* It works, just the types are wrong.
|
|
31
|
+
*/
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement(_appAdminCore.Provider, {
|
|
34
|
+
hoc: SecurityProviderHOC
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.Security = Security;
|
package/Security.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SecurityProviderHOC","Component","SecurityProvider","children","Security"],"sources":["Security.tsx"],"sourcesContent":["// Importing from `app-admin-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-admin-core\";\nimport { SecurityProvider as ContextProvider } from \"./contexts/Security\";\n\nconst SecurityProviderHOC = (Component: React.FC<any>): React.FC<any> => {\n return function SecurityProvider({ children }) {\n return (\n <ContextProvider>\n <Component>{children}</Component>\n </ContextProvider>\n );\n };\n};\n\nexport const Security: React.FC = () => {\n /**\n * TODO @ts-refactor somewhere down the line in Provider.\n * Provider expects ComponentType and we are giving it the React.FC.\n * It works, just the types are wrong.\n */\n // @ts-ignore\n return <Provider hoc={SecurityProviderHOC} />;\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKA,IAAMA,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,SAAD,EAA6C;EACrE,OAAO,SAASC,gBAAT,OAAwC;IAAA,IAAZC,QAAY,QAAZA,QAAY;IAC3C,oBACI,6BAAC,0BAAD,qBACI,6BAAC,SAAD,QAAYA,QAAZ,CADJ,CADJ;EAKH,CAND;AAOH,CARD;;AAUO,IAAMC,QAAkB,GAAG,SAArBA,QAAqB,GAAM;EACpC;AACJ;AACA;AACA;AACA;EACI;EACA,oBAAO,6BAAC,sBAAD;IAAU,GAAG,EAAEJ;EAAf,EAAP;AACH,CARM"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface HasPermissionProps {
|
|
3
|
+
any?: string[];
|
|
4
|
+
all?: string[];
|
|
5
|
+
name?: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const HasPermission: ({ children, ...props }: HasPermissionProps) => JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.HasPermission = void 0;
|
|
11
|
+
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _useSecurity2 = require("../hooks/useSecurity");
|
|
19
|
+
|
|
20
|
+
var _excluded = ["children"];
|
|
21
|
+
|
|
22
|
+
var HasPermission = function HasPermission(_ref) {
|
|
23
|
+
var children = _ref.children,
|
|
24
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
25
|
+
|
|
26
|
+
var _useSecurity = (0, _useSecurity2.useSecurity)(),
|
|
27
|
+
getPermission = _useSecurity.getPermission;
|
|
28
|
+
|
|
29
|
+
if (props.any && props.all) {
|
|
30
|
+
throw new Error("You can use either \"any\" or \"all\", but not both at the same time.");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (props.name) {
|
|
34
|
+
return getPermission(props.name) ? /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children) : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var permissions = [].concat((0, _toConsumableArray2.default)(props.any || []), (0, _toConsumableArray2.default)(props.all || [])).map(function (name) {
|
|
38
|
+
return getPermission(name);
|
|
39
|
+
});
|
|
40
|
+
var hasPermission = props.any ? permissions.some(function (p) {
|
|
41
|
+
return Boolean(p);
|
|
42
|
+
}) : permissions.every(function (p) {
|
|
43
|
+
return Boolean(p);
|
|
44
|
+
});
|
|
45
|
+
return hasPermission ? /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children) : null;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.HasPermission = HasPermission;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["HasPermission","children","props","useSecurity","getPermission","any","all","Error","name","permissions","map","hasPermission","some","p","Boolean","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 { getPermission } = useSecurity();\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 if (props.name) {\n return getPermission(props.name) ? <Fragment>{children}</Fragment> : null;\n }\n\n const permissions = [...(props.any || []), ...(props.all || [])].map(name =>\n getPermission(name)\n );\n\n const hasPermission = props.any\n ? permissions.some(p => Boolean(p))\n : permissions.every(p => Boolean(p));\n\n return hasPermission ? <Fragment>{children}</Fragment> : null;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;;;AASO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,OAAgD;EAAA,IAA7CC,QAA6C,QAA7CA,QAA6C;EAAA,IAAhCC,KAAgC;;EACzE,mBAA0B,IAAAC,yBAAA,GAA1B;EAAA,IAAQC,aAAR,gBAAQA,aAAR;;EAEA,IAAIF,KAAK,CAACG,GAAN,IAAaH,KAAK,CAACI,GAAvB,EAA4B;IACxB,MAAM,IAAIC,KAAJ,yEAAN;EACH;;EAED,IAAIL,KAAK,CAACM,IAAV,EAAgB;IACZ,OAAOJ,aAAa,CAACF,KAAK,CAACM,IAAP,CAAb,gBAA4B,6BAAC,eAAD,QAAWP,QAAX,CAA5B,GAA8D,IAArE;EACH;;EAED,IAAMQ,WAAW,GAAG,2CAAKP,KAAK,CAACG,GAAN,IAAa,EAAlB,oCAA2BH,KAAK,CAACI,GAAN,IAAa,EAAxC,GAA6CI,GAA7C,CAAiD,UAAAF,IAAI;IAAA,OACrEJ,aAAa,CAACI,IAAD,CADwD;EAAA,CAArD,CAApB;EAIA,IAAMG,aAAa,GAAGT,KAAK,CAACG,GAAN,GAChBI,WAAW,CAACG,IAAZ,CAAiB,UAAAC,CAAC;IAAA,OAAIC,OAAO,CAACD,CAAD,CAAX;EAAA,CAAlB,CADgB,GAEhBJ,WAAW,CAACM,KAAZ,CAAkB,UAAAF,CAAC;IAAA,OAAIC,OAAO,CAACD,CAAD,CAAX;EAAA,CAAnB,CAFN;EAIA,OAAOF,aAAa,gBAAG,6BAAC,eAAD,QAAWV,QAAX,CAAH,GAAqC,IAAzD;AACH,CApBM"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
children:
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface SecureRouteProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
4
|
permission?: string;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
|
+
declare const _default: ({ children, permission }: SecureRouteProps) => React.ReactElement | null;
|
|
6
7
|
export default _default;
|
|
@@ -1,27 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _useSecurity = require("../hooks/useSecurity");
|
|
9
|
+
|
|
10
|
+
var _plugins = require("@webiny/plugins");
|
|
11
|
+
|
|
12
|
+
var _default = function _default(_ref) {
|
|
4
13
|
var children = _ref.children,
|
|
5
14
|
permission = _ref.permission;
|
|
15
|
+
var security = (0, _useSecurity.useSecurity)();
|
|
6
16
|
|
|
7
|
-
|
|
8
|
-
|
|
17
|
+
if (!security) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var identity = security.identity,
|
|
22
|
+
getPermission = security.getPermission;
|
|
23
|
+
|
|
24
|
+
if (!identity) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
9
27
|
|
|
10
28
|
var hasPermission = false;
|
|
11
29
|
|
|
12
30
|
if (identity) {
|
|
13
|
-
hasPermission = permission ? Boolean(
|
|
31
|
+
hasPermission = permission ? Boolean(getPermission(permission)) : true;
|
|
14
32
|
}
|
|
15
33
|
|
|
16
34
|
if (hasPermission) {
|
|
17
35
|
return children;
|
|
18
36
|
}
|
|
19
37
|
|
|
20
|
-
var plugin = plugins.byName("secure-route-error");
|
|
38
|
+
var plugin = _plugins.plugins.byName("secure-route-error");
|
|
21
39
|
|
|
22
40
|
if (!plugin) {
|
|
23
41
|
return null;
|
|
24
42
|
}
|
|
25
43
|
|
|
26
44
|
return plugin.render();
|
|
27
|
-
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["children","permission","security","useSecurity","identity","getPermission","hasPermission","Boolean","plugin","plugins","byName","render"],"sources":["SecureRoute.tsx"],"sourcesContent":["import React from \"react\";\nimport { useSecurity } from \"~/hooks/useSecurity\";\nimport { 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;;AAEA;;eAMe,wBAA2E;EAAA,IAAxEA,QAAwE,QAAxEA,QAAwE;EAAA,IAA9DC,UAA8D,QAA9DA,UAA8D;EACtF,IAAMC,QAAQ,GAAG,IAAAC,wBAAA,GAAjB;;EAEA,IAAI,CAACD,QAAL,EAAe;IACX,OAAO,IAAP;EACH;;EAED,IAAQE,QAAR,GAAoCF,QAApC,CAAQE,QAAR;EAAA,IAAkBC,aAAlB,GAAoCH,QAApC,CAAkBG,aAAlB;;EAEA,IAAI,CAACD,QAAL,EAAe;IACX,OAAO,IAAP;EACH;;EAED,IAAIE,aAAa,GAAG,KAApB;;EACA,IAAIF,QAAJ,EAAc;IACVE,aAAa,GAAGL,UAAU,GAAGM,OAAO,CAACF,aAAa,CAACJ,UAAD,CAAd,CAAV,GAAwC,IAAlE;EACH;;EAED,IAAIK,aAAJ,EAAmB;IACf,OAAON,QAAP;EACH;;EAED,IAAMQ,MAAM,GAAGC,gBAAA,CAAQC,MAAR,CAAuC,oBAAvC,CAAf;;EACA,IAAI,CAACF,MAAL,EAAa;IACT,OAAO,IAAP;EACH;;EAED,OAAOA,MAAM,CAACG,MAAP,EAAP;AACH,C"}
|
|
@@ -2,11 +2,11 @@ import * as React from "react";
|
|
|
2
2
|
import { SecurityPermission } from "../types";
|
|
3
3
|
interface ChildrenRenderFunctionArgs<T extends SecurityPermission> {
|
|
4
4
|
hasPermission: boolean;
|
|
5
|
-
permission: T;
|
|
5
|
+
permission: T | null;
|
|
6
6
|
}
|
|
7
7
|
interface Props<T extends SecurityPermission> {
|
|
8
8
|
children: ((args: ChildrenRenderFunctionArgs<T>) => React.ReactElement) | React.ReactElement;
|
|
9
9
|
permission?: string;
|
|
10
10
|
}
|
|
11
|
-
declare function SecureView<T extends SecurityPermission>({ children, permission }: Props<T>): React.ReactElement;
|
|
11
|
+
declare function SecureView<T extends SecurityPermission>({ children, permission }: Props<T>): React.ReactElement | null;
|
|
12
12
|
export default SecureView;
|
package/components/SecureView.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _useSecurity2 = require("../hooks/useSecurity");
|
|
2
9
|
|
|
3
10
|
function SecureView(_ref) {
|
|
4
11
|
var children = _ref.children,
|
|
5
12
|
permission = _ref.permission;
|
|
6
13
|
|
|
7
|
-
var _useSecurity = useSecurity(),
|
|
8
|
-
|
|
14
|
+
var _useSecurity = (0, _useSecurity2.useSecurity)(),
|
|
15
|
+
getPermission = _useSecurity.getPermission;
|
|
9
16
|
|
|
10
17
|
var hasPermission = false;
|
|
11
18
|
var matchedPermission = null;
|
|
12
19
|
|
|
13
|
-
if (
|
|
14
|
-
matchedPermission =
|
|
20
|
+
if (permission) {
|
|
21
|
+
matchedPermission = getPermission(permission);
|
|
15
22
|
hasPermission = Boolean(matchedPermission);
|
|
16
23
|
}
|
|
17
24
|
|
|
@@ -25,4 +32,5 @@ function SecureView(_ref) {
|
|
|
25
32
|
return hasPermission ? children : null;
|
|
26
33
|
}
|
|
27
34
|
|
|
28
|
-
|
|
35
|
+
var _default = SecureView;
|
|
36
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SecureView","children","permission","useSecurity","getPermission","hasPermission","matchedPermission","Boolean"],"sources":["SecureView.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useSecurity } from \"~/hooks/useSecurity\";\nimport { 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;;AAaA,SAASA,UAAT,OAGwC;EAAA,IAFpCC,QAEoC,QAFpCA,QAEoC;EAAA,IADpCC,UACoC,QADpCA,UACoC;;EACpC,mBAA0B,IAAAC,yBAAA,GAA1B;EAAA,IAAQC,aAAR,gBAAQA,aAAR;;EAEA,IAAIC,aAAa,GAAG,KAApB;EACA,IAAIC,iBAA2B,GAAG,IAAlC;;EACA,IAAIJ,UAAJ,EAAgB;IACZI,iBAAiB,GAAGF,aAAa,CAAIF,UAAJ,CAAjC;IACAG,aAAa,GAAGE,OAAO,CAACD,iBAAD,CAAvB;EACH;;EAED,IAAI,OAAOL,QAAP,KAAoB,UAAxB,EAAoC;IAChC,OAAOA,QAAQ,CAAC;MACZI,aAAa,EAAbA,aADY;MAEZH,UAAU,EAAEI;IAFA,CAAD,CAAf;EAIH;;EAED,OAAOD,aAAa,GAAGJ,QAAH,GAAc,IAAlC;AACH;;eAEcD,U"}
|
package/components/index.d.ts
CHANGED
package/components/index.js
CHANGED
|
@@ -1,2 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "HasPermission", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _HasPermission.HasPermission;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "SecureRoute", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _SecureRoute.default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "SecureView", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _SecureView.default;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
var _SecureView = _interopRequireDefault(require("./SecureView"));
|
|
28
|
+
|
|
29
|
+
var _SecureRoute = _interopRequireDefault(require("./SecureRoute"));
|
|
30
|
+
|
|
31
|
+
var _HasPermission = require("./HasPermission");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as SecureView } from \"./SecureView\";\nexport { default as SecureRoute } from \"./SecureRoute\";\nexport { HasPermission } from \"./HasPermission\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA"}
|
package/contexts/Security.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { Dispatch, SetStateAction } from "react";
|
|
2
2
|
import { SecurityIdentity, SecurityPermission } from "../types";
|
|
3
|
-
export
|
|
4
|
-
export interface SecurityContextValue {
|
|
3
|
+
export interface SecurityContext {
|
|
5
4
|
identity: SecurityIdentity | null;
|
|
6
|
-
setIdentity: Dispatch<SetStateAction<SecurityIdentity>>;
|
|
7
|
-
getPermission<T extends SecurityPermission = SecurityPermission>(name: string): T;
|
|
5
|
+
setIdentity: Dispatch<SetStateAction<SecurityIdentity | null>>;
|
|
6
|
+
getPermission<T extends SecurityPermission = SecurityPermission>(name: string): T | null;
|
|
8
7
|
}
|
|
9
|
-
export declare const
|
|
8
|
+
export declare const SecurityContext: React.Context<SecurityContext>;
|
|
9
|
+
export declare const SecurityProvider: React.FC;
|
package/contexts/Security.js
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.SecurityProvider = exports.SecurityContext = void 0;
|
|
11
|
+
|
|
12
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _minimatch = _interopRequireDefault(require("minimatch"));
|
|
17
|
+
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
|
|
20
|
+
var SecurityContext = /*#__PURE__*/_react.default.createContext({
|
|
21
|
+
identity: null,
|
|
22
|
+
setIdentity: function setIdentity() {
|
|
23
|
+
return void 0;
|
|
24
|
+
},
|
|
25
|
+
getPermission: function getPermission() {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
exports.SecurityContext = SecurityContext;
|
|
31
|
+
|
|
32
|
+
var SecurityProvider = function SecurityProvider(props) {
|
|
33
|
+
var _useState = (0, _react.useState)(null),
|
|
34
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
9
35
|
identity = _useState2[0],
|
|
10
36
|
setIdentity = _useState2[1];
|
|
11
37
|
|
|
12
|
-
var getPermission = useCallback(function (name) {
|
|
38
|
+
var getPermission = (0, _react.useCallback)(function (name) {
|
|
13
39
|
if (!identity) {
|
|
14
40
|
return null;
|
|
15
41
|
}
|
|
@@ -25,12 +51,12 @@ export var SecurityProvider = function SecurityProvider(props) {
|
|
|
25
51
|
|
|
26
52
|
|
|
27
53
|
return perms.find(function (p) {
|
|
28
|
-
return
|
|
54
|
+
return (0, _minimatch.default)(name, p.name);
|
|
29
55
|
});
|
|
30
56
|
}, [identity]);
|
|
31
|
-
var value = useMemo(function () {
|
|
57
|
+
var value = (0, _react.useMemo)(function () {
|
|
32
58
|
return {
|
|
33
|
-
identity: identity ?
|
|
59
|
+
identity: identity ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, identity), {}, {
|
|
34
60
|
// For backwards compatibility, expose the `getPermission` method on the `identity` object.
|
|
35
61
|
getPermission: getPermission
|
|
36
62
|
}) : null,
|
|
@@ -38,7 +64,9 @@ export var SecurityProvider = function SecurityProvider(props) {
|
|
|
38
64
|
getPermission: getPermission
|
|
39
65
|
};
|
|
40
66
|
}, [identity]);
|
|
41
|
-
return /*#__PURE__*/
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(SecurityContext.Provider, {
|
|
42
68
|
value: value
|
|
43
69
|
}, props.children);
|
|
44
|
-
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.SecurityProvider = SecurityProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SecurityContext","React","createContext","identity","setIdentity","getPermission","SecurityProvider","props","useState","useCallback","name","perms","permissions","exactMatch","find","p","minimatch","value","useMemo","children"],"sources":["Security.tsx"],"sourcesContent":["import minimatch from \"minimatch\";\nimport React, { useState, useMemo, Dispatch, SetStateAction, useCallback } from \"react\";\nimport { SecurityIdentity, SecurityPermission } from \"~/types\";\n\nexport interface SecurityContext {\n identity: SecurityIdentity | null;\n setIdentity: Dispatch<SetStateAction<SecurityIdentity | null>>;\n getPermission<T extends SecurityPermission = SecurityPermission>(name: string): T | null;\n}\n\nexport const SecurityContext = React.createContext<SecurityContext>({\n identity: null,\n setIdentity: () => {\n return void 0;\n },\n getPermission: () => {\n return null;\n }\n});\n\nexport const SecurityProvider: React.FC = props => {\n const [identity, setIdentity] = useState<SecurityIdentity | null>(null);\n\n const getPermission = useCallback(\n <T extends SecurityPermission = SecurityPermission>(name: string): T | null => {\n if (!identity) {\n return null;\n }\n\n const perms = identity.permissions || [];\n const exactMatch = perms.find(p => p.name === name);\n if (exactMatch) {\n return exactMatch as T;\n }\n\n // Try matching using patterns\n return perms.find(p => minimatch(name, p.name)) as any;\n },\n [identity]\n );\n\n const value = 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 setIdentity,\n getPermission\n };\n }, [identity]);\n\n return <SecurityContext.Provider value={value}>{props.children}</SecurityContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AASO,IAAMA,eAAe,gBAAGC,cAAA,CAAMC,aAAN,CAAqC;EAChEC,QAAQ,EAAE,IADsD;EAEhEC,WAAW,EAAE,uBAAM;IACf,OAAO,KAAK,CAAZ;EACH,CAJ+D;EAKhEC,aAAa,EAAE,yBAAM;IACjB,OAAO,IAAP;EACH;AAP+D,CAArC,CAAxB;;;;AAUA,IAAMC,gBAA0B,GAAG,SAA7BA,gBAA6B,CAAAC,KAAK,EAAI;EAC/C,gBAAgC,IAAAC,eAAA,EAAkC,IAAlC,CAAhC;EAAA;EAAA,IAAOL,QAAP;EAAA,IAAiBC,WAAjB;;EAEA,IAAMC,aAAa,GAAG,IAAAI,kBAAA,EAClB,UAAoDC,IAApD,EAA+E;IAC3E,IAAI,CAACP,QAAL,EAAe;MACX,OAAO,IAAP;IACH;;IAED,IAAMQ,KAAK,GAAGR,QAAQ,CAACS,WAAT,IAAwB,EAAtC;IACA,IAAMC,UAAU,GAAGF,KAAK,CAACG,IAAN,CAAW,UAAAC,CAAC;MAAA,OAAIA,CAAC,CAACL,IAAF,KAAWA,IAAf;IAAA,CAAZ,CAAnB;;IACA,IAAIG,UAAJ,EAAgB;MACZ,OAAOA,UAAP;IACH,CAT0E,CAW3E;;;IACA,OAAOF,KAAK,CAACG,IAAN,CAAW,UAAAC,CAAC;MAAA,OAAI,IAAAC,kBAAA,EAAUN,IAAV,EAAgBK,CAAC,CAACL,IAAlB,CAAJ;IAAA,CAAZ,CAAP;EACH,CAdiB,EAelB,CAACP,QAAD,CAfkB,CAAtB;EAkBA,IAAMc,KAAK,GAAG,IAAAC,cAAA,EAAQ,YAAM;IACxB,OAAO;MACHf,QAAQ,EAAEA,QAAQ,+DAELA,QAFK;QAGR;QACAE,aAAa,EAAbA;MAJQ,KAMZ,IAPH;MAQHD,WAAW,EAAXA,WARG;MASHC,aAAa,EAAbA;IATG,CAAP;EAWH,CAZa,EAYX,CAACF,QAAD,CAZW,CAAd;EAcA,oBAAO,6BAAC,eAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAEc;EAAjC,GAAyCV,KAAK,CAACY,QAA/C,CAAP;AACH,CApCM"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePermission = usePermission;
|
|
7
|
+
|
|
8
|
+
var _useSecurity2 = require("./useSecurity");
|
|
9
|
+
|
|
10
|
+
function usePermission(name) {
|
|
11
|
+
var _useSecurity = (0, _useSecurity2.useSecurity)(),
|
|
12
|
+
getPermission = _useSecurity.getPermission;
|
|
13
|
+
|
|
14
|
+
return getPermission(name);
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["usePermission","name","useSecurity","getPermission"],"sources":["usePermission.ts"],"sourcesContent":["import { useSecurity } from \"~/hooks/useSecurity\";\nimport { 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;;AAGO,SAASA,aAAT,CAA0EC,IAA1E,EAAwF;EAC3F,mBAA0B,IAAAC,yBAAA,GAA1B;EAAA,IAAQC,aAAR,gBAAQA,aAAR;;EACA,OAAOA,aAAa,CAAIF,IAAJ,CAApB;AACH"}
|
package/hooks/useSecurity.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function useSecurity():
|
|
1
|
+
import { SecurityContext } from "../contexts/Security";
|
|
2
|
+
export declare function useSecurity(): SecurityContext;
|
package/hooks/useSecurity.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSecurity = useSecurity;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _Security = require("../contexts/Security");
|
|
11
|
+
|
|
12
|
+
function useSecurity() {
|
|
13
|
+
return (0, _react.useContext)(_Security.SecurityContext);
|
|
5
14
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSecurity","useContext","SecurityContext"],"sources":["useSecurity.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { SecurityContext } from \"~/contexts/Security\";\n\nexport function useSecurity() {\n return useContext(SecurityContext);\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,SAASA,WAAT,GAAuB;EAC1B,OAAO,IAAAC,iBAAA,EAAWC,yBAAX,CAAP;AACH"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,3 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
SecurityContext: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "SecurityContext", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function get() {
|
|
12
|
+
return _Security.SecurityContext;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var _components = require("./components");
|
|
17
|
+
|
|
18
|
+
Object.keys(_components).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
21
|
+
if (key in exports && exports[key] === _components[key]) return;
|
|
22
|
+
Object.defineProperty(exports, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function get() {
|
|
25
|
+
return _components[key];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
var _Security = require("./contexts/Security");
|
|
31
|
+
|
|
32
|
+
Object.keys(_Security).forEach(function (key) {
|
|
33
|
+
if (key === "default" || key === "__esModule") return;
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
35
|
+
if (key in exports && exports[key] === _Security[key]) return;
|
|
36
|
+
Object.defineProperty(exports, key, {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _Security[key];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
var _useSecurity = require("./hooks/useSecurity");
|
|
45
|
+
|
|
46
|
+
Object.keys(_useSecurity).forEach(function (key) {
|
|
47
|
+
if (key === "default" || key === "__esModule") return;
|
|
48
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
49
|
+
if (key in exports && exports[key] === _useSecurity[key]) return;
|
|
50
|
+
Object.defineProperty(exports, key, {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function get() {
|
|
53
|
+
return _useSecurity[key];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
var _usePermission = require("./hooks/usePermission");
|
|
59
|
+
|
|
60
|
+
Object.keys(_usePermission).forEach(function (key) {
|
|
61
|
+
if (key === "default" || key === "__esModule") return;
|
|
62
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
63
|
+
if (key in exports && exports[key] === _usePermission[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function get() {
|
|
67
|
+
return _usePermission[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var _Security2 = require("./Security");
|
|
73
|
+
|
|
74
|
+
Object.keys(_Security2).forEach(function (key) {
|
|
75
|
+
if (key === "default" || key === "__esModule") return;
|
|
76
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
77
|
+
if (key in exports && exports[key] === _Security2[key]) return;
|
|
78
|
+
Object.defineProperty(exports, key, {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _Security2[key];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"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;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-security",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.5e7233243f",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,27 +13,27 @@
|
|
|
13
13
|
],
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webiny/app": "0.0.0-
|
|
17
|
-
"@webiny/
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"react
|
|
16
|
+
"@webiny/app": "0.0.0-unstable.5e7233243f",
|
|
17
|
+
"@webiny/app-admin-core": "0.0.0-unstable.5e7233243f",
|
|
18
|
+
"@webiny/plugins": "0.0.0-unstable.5e7233243f",
|
|
19
|
+
"minimatch": "3.1.2",
|
|
20
|
+
"react": "17.0.2",
|
|
21
|
+
"react-dom": "17.0.2"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"@babel/cli": "^7.
|
|
24
|
-
"@babel/core": "^7.
|
|
25
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
26
|
-
"@babel/preset-env": "^7.
|
|
27
|
-
"@babel/preset-react": "^7.
|
|
28
|
-
"@babel/preset-typescript": "^7.
|
|
29
|
-
"@webiny/cli": "^0.0.0-
|
|
30
|
-
"@webiny/project-utils": "^0.0.0-
|
|
24
|
+
"@babel/cli": "^7.16.0",
|
|
25
|
+
"@babel/core": "^7.16.0",
|
|
26
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
27
|
+
"@babel/preset-env": "^7.16.4",
|
|
28
|
+
"@babel/preset-react": "^7.16.0",
|
|
29
|
+
"@babel/preset-typescript": "^7.16.0",
|
|
30
|
+
"@webiny/cli": "^0.0.0-unstable.5e7233243f",
|
|
31
|
+
"@webiny/project-utils": "^0.0.0-unstable.5e7233243f",
|
|
31
32
|
"babel-plugin-emotion": "^9.2.8",
|
|
32
33
|
"babel-plugin-lodash": "^3.3.4",
|
|
33
|
-
"babel-plugin-named-asset-import": "^1.0.0-next.3e165448",
|
|
34
34
|
"rimraf": "^3.0.2",
|
|
35
35
|
"ttypescript": "^1.5.12",
|
|
36
|
-
"typescript": "
|
|
36
|
+
"typescript": "4.7.4"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public",
|
|
@@ -43,11 +43,6 @@
|
|
|
43
43
|
"build": "yarn webiny run build",
|
|
44
44
|
"watch": "yarn webiny run watch"
|
|
45
45
|
},
|
|
46
|
-
"svgo": {
|
|
47
|
-
"plugins": {
|
|
48
|
-
"removeViewBox": false
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
46
|
"adio": {
|
|
52
47
|
"ignore": {
|
|
53
48
|
"peerDependencies": [
|
|
@@ -55,5 +50,5 @@
|
|
|
55
50
|
]
|
|
56
51
|
}
|
|
57
52
|
},
|
|
58
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "995a4b337db9b8497c6615e335dcd206afe26f8f"
|
|
59
54
|
}
|
package/types.d.ts
CHANGED
|
@@ -15,7 +15,25 @@ export interface SecurityIdentity {
|
|
|
15
15
|
type: string;
|
|
16
16
|
displayName: string;
|
|
17
17
|
permissions?: SecurityPermission[];
|
|
18
|
+
/**
|
|
19
|
+
* TODO @ts-refactor @pavel
|
|
20
|
+
* Verify that login can be present in here.
|
|
21
|
+
*/
|
|
22
|
+
login?: string;
|
|
23
|
+
/**
|
|
24
|
+
* TODO @ts-refactor @pavel
|
|
25
|
+
* Verify that profile can be present in here.
|
|
26
|
+
*/
|
|
27
|
+
profile?: {
|
|
28
|
+
email?: string;
|
|
29
|
+
firstName?: string;
|
|
30
|
+
lastName?: string;
|
|
31
|
+
avatar?: {
|
|
32
|
+
src?: string;
|
|
33
|
+
};
|
|
34
|
+
gravatar?: string;
|
|
35
|
+
};
|
|
18
36
|
logout(): void;
|
|
19
|
-
getPermission?<T extends SecurityPermission = SecurityPermission>(name: string): T;
|
|
37
|
+
getPermission?<T extends SecurityPermission = SecurityPermission>(name: string): T | null;
|
|
20
38
|
[key: string]: any;
|
|
21
39
|
}
|
package/types.js
CHANGED
package/types.js.map
ADDED
|
@@ -0,0 +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"],"mappings":""}
|