@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 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
- var SecurityProviderHOC = function SecurityProviderHOC(Component) {
16
- return function SecurityProvider(_ref) {
17
- var children = _ref.children;
18
- return /*#__PURE__*/_react.default.createElement(_Security.SecurityProvider, null, /*#__PURE__*/_react.default.createElement(Component, null, children));
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
- var Security = exports.Security = function Security() {
22
- return /*#__PURE__*/_react.default.createElement(_app.Provider, {
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":["_react","_interopRequireDefault","require","_app","_Security","SecurityProviderHOC","Component","SecurityProvider","_ref","children","default","createElement","Security","exports","Provider","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":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AALA;AACA;AACA;;AASA,IAAMG,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,SAAqD,EAAK;EACnF,OAAO,SAASC,gBAAgBA,CAAAC,IAAA,EAAsC;IAAA,IAAnCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACvC,oBACIT,MAAA,CAAAU,OAAA,CAAAC,aAAA,CAACP,SAAA,CAAAG,gBAAe,qBACZP,MAAA,CAAAU,OAAA,CAAAC,aAAA,CAACL,SAAS,QAAEG,QAAoB,CACnB,CAAC;EAE1B,CAAC;AACL,CAAC;AAEM,IAAMG,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG,SAAXA,QAAQA,CAAA,EAAS;EAC1B,oBAAOZ,MAAA,CAAAU,OAAA,CAAAC,aAAA,CAACR,IAAA,CAAAW,QAAQ;IAACC,GAAG,EAAEV;EAAoB,CAAE,CAAC;AACjD,CAAC","ignoreList":[]}
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
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.HasPermission = void 0;
9
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
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
- var _permissionsCollections = getPermissions(props.name);
20
- var _hasPermission = _permissionsCollections.length > 0;
21
- if (_hasPermission) {
22
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children);
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("You can use either \"any\" or \"all\", but not both at the same time.");
19
+ throw new Error(`You can use either "any" or "all", but not both at the same time.`);
28
20
  }
29
- var anyAllPermissions = props.any || props.all || [];
30
- var permissionsCollections = anyAllPermissions.map(function (name) {
31
- return getPermissions(name);
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__*/_react.default.createElement(_react.Fragment, null, children);
25
+ return /*#__PURE__*/React.createElement(Fragment, null, children);
40
26
  }
41
27
  return null;
42
28
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_useSecurity2","_excluded","HasPermission","exports","_ref","children","props","_objectWithoutProperties2","default","_useSecurity","useSecurity","getPermissions","name","permissionsCollections","hasPermission","length","createElement","Fragment","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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAAkD,IAAAE,SAAA;AAS3C,IAAMC,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CAAAE,IAAA,EAAmD;EAAA,IAA7CC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAKC,KAAK,OAAAC,yBAAA,CAAAC,OAAA,EAAAJ,IAAA,EAAAH,SAAA;EAC9C,IAAAQ,YAAA,GAA2B,IAAAC,yBAAW,EAAC,CAAC;IAAhCC,cAAc,GAAAF,YAAA,CAAdE,cAAc;EAEtB,IAAIL,KAAK,CAACM,IAAI,EAAE;IACZ,IAAMC,uBAAsB,GAAGF,cAAc,CAACL,KAAK,CAACM,IAAI,CAAC;IACzD,IAAME,cAAa,GAAGD,uBAAsB,CAACE,MAAM,GAAG,CAAC;IACvD,IAAID,cAAa,EAAE;MACf,oBAAOjB,MAAA,CAAAW,OAAA,CAAAQ,aAAA,CAACnB,MAAA,CAAAoB,QAAQ,QAAEZ,QAAmB,CAAC;IAC1C;IAEA,OAAO,IAAI;EACf;EAEA,IAAIC,KAAK,CAACY,GAAG,IAAIZ,KAAK,CAACa,GAAG,EAAE;IACxB,MAAM,IAAIC,KAAK,wEAAoE,CAAC;EACxF;EAEA,IAAMC,iBAAiB,GAAGf,KAAK,CAACY,GAAG,IAAIZ,KAAK,CAACa,GAAG,IAAI,EAAE;EAEtD,IAAMN,sBAAsB,GAAGQ,iBAAiB,CAACC,GAAG,CAAC,UAAAV,IAAI;IAAA,OAAID,cAAc,CAACC,IAAI,CAAC;EAAA,EAAC;EAElF,IAAME,aAAa,GAAGR,KAAK,CAACY,GAAG,GACzBL,sBAAsB,CAACU,IAAI,CAAC,UAAAC,UAAU;IAAA,OAAIA,UAAU,CAACT,MAAM,GAAG,CAAC;EAAA,EAAC,GAChEF,sBAAsB,CAACY,KAAK,CAAC,UAAAD,UAAU;IAAA,OAAIA,UAAU,CAACT,MAAM,GAAG,CAAC;EAAA,EAAC;EAEvE,IAAID,aAAa,EAAE;IACf,oBAAOjB,MAAA,CAAAW,OAAA,CAAAQ,aAAA,CAACnB,MAAA,CAAAoB,QAAQ,QAAEZ,QAAmB,CAAC;EAC1C;EAEA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
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,4 +1,4 @@
1
- import React from "react";
1
+ import type React from "react";
2
2
  interface SecureRouteProps {
3
3
  children: React.ReactNode;
4
4
  permission?: string;
@@ -1,31 +1,28 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _useSecurity = require("../hooks/useSecurity");
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
- var identity = security.identity,
17
- getPermission = security.getPermission;
11
+ const {
12
+ identity,
13
+ getPermission
14
+ } = security;
18
15
  if (!identity) {
19
16
  return null;
20
17
  }
21
- var hasPermission = false;
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
- var plugin = _plugins.plugins.byName("secure-route-error");
25
+ const plugin = plugins.byName("secure-route-error");
29
26
  if (!plugin) {
30
27
  return null;
31
28
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_useSecurity","require","_plugins","_default","exports","default","_ref","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,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAA0C,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAM3B,SAAAF,SAAAG,IAAA,EAA2E;EAAA,IAAxEC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,UAAU,GAAAF,IAAA,CAAVE,UAAU;EAClC,IAAMC,QAAQ,GAAG,IAAAC,wBAAW,EAAC,CAAC;EAE9B,IAAI,CAACD,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EAEA,IAAQE,QAAQ,GAAoBF,QAAQ,CAApCE,QAAQ;IAAEC,aAAa,GAAKH,QAAQ,CAA1BG,aAAa;EAE/B,IAAI,CAACD,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EAEA,IAAIE,aAAa,GAAG,KAAK;EACzB,IAAIF,QAAQ,EAAE;IACVE,aAAa,GAAGL,UAAU,GAAGM,OAAO,CAACF,aAAa,CAACJ,UAAU,CAAC,CAAC,GAAG,IAAI;EAC1E;EAEA,IAAIK,aAAa,EAAE;IACf,OAAON,QAAQ;EACnB;EAEA,IAAMQ,MAAM,GAAGC,gBAAO,CAACC,MAAM,CAAyB,oBAAoB,CAAC;EAC3E,IAAI,CAACF,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,OAAOA,MAAM,CAACG,MAAM,CAAC,CAAC;AAC1B,CAAC","ignoreList":[]}
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;
@@ -1,29 +1,25 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _useSecurity2 = require("../hooks/useSecurity");
8
- function SecureView(_ref) {
9
- var children = _ref.children,
10
- permission = _ref.permission;
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: hasPermission,
17
+ hasPermission,
22
18
  permission: matchedPermission
23
19
  });
24
20
  }
25
21
  return hasPermission ? children : null;
26
22
  }
27
- var _default = exports.default = SecureView;
23
+ export default SecureView;
28
24
 
29
25
  //# sourceMappingURL=SecureView.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_useSecurity2","require","SecureView","_ref","children","permission","_useSecurity","useSecurity","getPermission","hasPermission","matchedPermission","Boolean","_default","exports","default"],"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,IAAAA,aAAA,GAAAC,OAAA;AAaA,SAASC,UAAUA,CAAAC,IAAA,EAGqB;EAAA,IAFpCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,UAAU,GAAAF,IAAA,CAAVE,UAAU;EAEV,IAAAC,YAAA,GAA0B,IAAAC,yBAAW,EAAC,CAAC;IAA/BC,aAAa,GAAAF,YAAA,CAAbE,aAAa;EAErB,IAAIC,aAAa,GAAG,KAAK;EACzB,IAAIC,iBAA2B,GAAG,IAAI;EACtC,IAAIL,UAAU,EAAE;IACZK,iBAAiB,GAAGF,aAAa,CAAIH,UAAU,CAAC;IAChDI,aAAa,GAAGE,OAAO,CAACD,iBAAiB,CAAC;EAC9C;EAEA,IAAI,OAAON,QAAQ,KAAK,UAAU,EAAE;IAChC,OAAOA,QAAQ,CAAC;MACZK,aAAa,EAAbA,aAAa;MACbJ,UAAU,EAAEK;IAChB,CAAC,CAAC;EACN;EAEA,OAAOD,aAAa,GAAGL,QAAQ,GAAG,IAAI;AAC1C;AAAC,IAAAQ,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcZ,UAAU","ignoreList":[]}
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":[]}
@@ -1,29 +1,5 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
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
@@ -1 +1 @@
1
- {"version":3,"names":["_SecureView","_interopRequireDefault","require","_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,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA","ignoreList":[]}
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":[]}
@@ -1,5 +1,6 @@
1
- import React, { Dispatch, SetStateAction } from "react";
2
- import { IdTokenProvider, SecurityIdentity, SecurityPermission } from "../types";
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;
@@ -1,38 +1,16 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.SecurityProvider = exports.SecurityContext = void 0;
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
- var perms = identity.permissions || [];
33
- var exactMatch = perms.find(function (p) {
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(function (p) {
44
- return (0, _minimatch.default)(name, p.name);
45
- }) || null;
21
+ return perms.find(p => minimatch(name, p.name)) || null;
46
22
  }, [identity]);
47
- var getPermissions = (0, _react.useCallback)(function (name) {
23
+ const getPermissions = useCallback(name => {
48
24
  if (!identity) {
49
25
  return [];
50
26
  }
51
- var permissions = identity.permissions || [];
52
- return permissions.filter(function (current) {
53
- var exactMatch = current.name === name;
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 (0, _minimatch.default)(name, current.name);
35
+ return minimatch(name, current.name);
60
36
  });
61
37
  }, [identity]);
62
- var getIdentityId = (0, _react.useCallback)(function () {
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
- var value = (0, _react.useMemo)(function () {
44
+ const value = useMemo(() => {
69
45
  return {
70
- identity: identity ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, identity), {}, {
46
+ identity: identity ? {
47
+ ...identity,
71
48
  // For backwards compatibility, expose the `getPermission` method on the `identity` object.
72
- getPermission: getPermission
73
- }) : null,
74
- getIdentityId: getIdentityId,
75
- setIdentity: setIdentity,
76
- getPermission: getPermission,
77
- getPermissions: getPermissions,
49
+ getPermission
50
+ } : null,
51
+ getIdentityId,
52
+ setIdentity,
53
+ getPermission,
54
+ getPermissions,
78
55
  getIdToken: idTokenProvider,
79
- setIdTokenProvider: function setIdTokenProvider(provider) {
80
- _setIdTokenProvider(function () {
81
- return provider;
82
- });
56
+ setIdTokenProvider: provider => {
57
+ setIdTokenProvider(() => provider);
83
58
  }
84
59
  };
85
60
  }, [idTokenProvider, identity]);
86
- return /*#__PURE__*/_react.default.createElement(SecurityContext.Provider, {
61
+ return /*#__PURE__*/React.createElement(SecurityContext.Provider, {
87
62
  value: value
88
63
  }, props.children);
89
64
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_minimatch","_interopRequireDefault","require","_react","_interopRequireWildcard","defaultIdTokenProvider","undefined","SecurityContext","exports","React","createContext","SecurityProvider","props","_useState","useState","_useState2","_slicedToArray2","default","identity","setIdentity","_useState3","_useState4","idTokenProvider","setIdTokenProvider","getPermission","useCallback","name","exact","perms","permissions","exactMatch","find","p","minimatch","getPermissions","filter","current","getIdentityId","id","login","value","useMemo","_objectSpread2","getIdToken","provider","createElement","Provider","children"],"sources":["Security.tsx"],"sourcesContent":["import minimatch from \"minimatch\";\nimport React, { Dispatch, SetStateAction, useCallback, useMemo, useState } from \"react\";\nimport { 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":"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","ignoreList":[]}
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":[]}
@@ -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;
@@ -1,13 +1,8 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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":["_useSecurity2","require","usePermission","name","_useSecurity","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,IAAAA,aAAA,GAAAC,OAAA;AAGO,SAASC,aAAaA,CAAoDC,IAAY,EAAE;EAC3F,IAAAC,YAAA,GAA0B,IAAAC,yBAAW,EAAC,CAAC;IAA/BC,aAAa,GAAAF,YAAA,CAAbE,aAAa;EACrB,OAAOA,aAAa,CAAIH,IAAI,CAAC;AACjC","ignoreList":[]}
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":[]}
@@ -1,15 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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("Missing <SecurityProvider> in the component hierarchy!");
6
+ throw Error(`Missing <SecurityProvider> in the component hierarchy!`);
13
7
  }
14
8
  return context;
15
9
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_Security","useSecurity","context","useContext","SecurityContext","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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEO,SAASE,WAAWA,CAAA,EAAG;EAC1B,IAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACC,yBAAe,CAAC;EAE3C,IAAI,CAACF,OAAO,EAAE;IACV,MAAMG,KAAK,yDAAyD,CAAC;EACzE;EAEA,OAAOH,OAAO;AAClB","ignoreList":[]}
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
- "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
- 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":["_components","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_Security","_useSecurity","_usePermission","_Security2"],"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,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAb,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,SAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,SAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,SAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,SAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AAEA,IAAAU,YAAA,GAAAd,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAY,YAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAU,YAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,YAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,cAAA,GAAAf,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAa,cAAA,EAAAZ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAW,cAAA,CAAAX,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAG,cAAA,CAAAX,GAAA;IAAA;EAAA;AAAA;AACA,IAAAY,UAAA,GAAAhB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAc,UAAA,EAAAb,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAY,UAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAI,UAAA,CAAAZ,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
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": "5.43.3",
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": "5.43.3",
17
- "@webiny/plugins": "5.43.3",
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": "5.43.3",
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": "c6d623eb1b715f3731434a8d3107b8fd8a1d6792"
43
+ "gitHead": "9bd236cf5e689f209a11bec089207dcc2d41a53c"
44
44
  }
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Plugin } from "@webiny/app/types";
2
+ import type { Plugin } from "@webiny/app/types";
3
3
  export type SecureRouteErrorPlugin = Plugin & {
4
4
  render(): React.ReactElement;
5
5
  };
package/types.js CHANGED
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=types.js.map
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":[]}