@backstage/plugin-permission-react 0.1.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # @backstage/plugin-permission-react
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/config@0.1.12
9
+ - @backstage/core-plugin-api@0.5.0
10
+ - @backstage/plugin-permission-common@0.3.1
11
+
12
+ ## 0.2.1
13
+
14
+ ### Patch Changes
15
+
16
+ - 4ce51ab0f1: Internal refactor of the `react-use` imports to use `react-use/lib/*` instead.
17
+ - Updated dependencies
18
+ - @backstage/core-plugin-api@0.4.1
19
+
20
+ ## 0.2.0
21
+
22
+ ### Minor Changes
23
+
24
+ - 70281a475b: Breaking Changes:
25
+
26
+ - Remove "api" suffixes from constructor parameters in IdentityPermissionApi.create
27
+
28
+ ```diff
29
+ const { config, discovery, identity } = options;
30
+ - const permissionApi = IdentityPermissionApi.create({
31
+ - configApi: config,
32
+ - discoveryApi: discovery,
33
+ - identityApi: identity
34
+ - });
35
+ + const permissionApi = IdentityPermissionApi.create({ config, discovery, identity });
36
+ ```
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies
41
+ - @backstage/core-plugin-api@0.4.0
42
+ - @backstage/plugin-permission-common@0.3.0
43
+
44
+ ## 0.1.1
45
+
46
+ ### Patch Changes
47
+
48
+ - cd450844f6: Moved React dependencies to `peerDependencies` and allow both React v16 and v17 to be used.
49
+ - dcd1a0c3f4: Minor improvement to the API reports, by not unpacking arguments directly
50
+ - Updated dependencies
51
+ - @backstage/core-plugin-api@0.3.0
52
+
3
53
  ## 0.1.0
4
54
 
5
55
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -5,12 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var React = require('react');
6
6
  var reactRouter = require('react-router');
7
7
  var corePluginApi = require('@backstage/core-plugin-api');
8
- var reactUse = require('react-use');
8
+ var useAsync = require('react-use/lib/useAsync');
9
9
  var pluginPermissionCommon = require('@backstage/plugin-permission-common');
10
10
 
11
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
12
 
13
13
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
14
+ var useAsync__default = /*#__PURE__*/_interopDefaultLegacy(useAsync);
14
15
 
15
16
  const permissionApiRef = corePluginApi.createApiRef({
16
17
  id: "plugin.permission.api"
@@ -21,13 +22,10 @@ class IdentityPermissionApi {
21
22
  this.permissionClient = permissionClient;
22
23
  this.identityApi = identityApi;
23
24
  }
24
- static create({
25
- configApi,
26
- discoveryApi,
27
- identityApi
28
- }) {
29
- const permissionClient = new pluginPermissionCommon.PermissionClient({discoveryApi, configApi});
30
- return new IdentityPermissionApi(permissionClient, identityApi);
25
+ static create(options) {
26
+ const { config, discovery, identity } = options;
27
+ const permissionClient = new pluginPermissionCommon.PermissionClient({ discovery, config });
28
+ return new IdentityPermissionApi(permissionClient, identity);
31
29
  }
32
30
  async authorize(request) {
33
31
  const response = await this.permissionClient.authorize([request], {
@@ -39,39 +37,35 @@ class IdentityPermissionApi {
39
37
 
40
38
  const usePermission = (permission, resourceRef) => {
41
39
  const permissionApi = corePluginApi.useApi(permissionApiRef);
42
- const {loading, error, value} = reactUse.useAsync(async () => {
43
- const {result} = await permissionApi.authorize({
40
+ const { loading, error, value } = useAsync__default["default"](async () => {
41
+ const { result } = await permissionApi.authorize({
44
42
  permission,
45
43
  resourceRef
46
44
  });
47
45
  return result;
48
46
  }, [permissionApi, permission, resourceRef]);
49
47
  if (loading) {
50
- return {loading: true, allowed: false};
48
+ return { loading: true, allowed: false };
51
49
  }
52
50
  if (error) {
53
- return {error, loading: false, allowed: false};
51
+ return { error, loading: false, allowed: false };
54
52
  }
55
- return {loading: false, allowed: value === pluginPermissionCommon.AuthorizeResult.ALLOW};
53
+ return { loading: false, allowed: value === pluginPermissionCommon.AuthorizeResult.ALLOW };
56
54
  };
57
55
 
58
- const PermissionedRoute = ({
59
- permission,
60
- resourceRef,
61
- errorComponent,
62
- ...props
63
- }) => {
56
+ const PermissionedRoute = (props) => {
57
+ const { permission, resourceRef, errorComponent, ...otherProps } = props;
64
58
  const permissionResult = usePermission(permission, resourceRef);
65
59
  const app = corePluginApi.useApp();
66
- const {NotFoundErrorPage} = app.getComponents();
67
- let shownElement = errorComponent === void 0 ? /* @__PURE__ */ React__default['default'].createElement(NotFoundErrorPage, null) : errorComponent;
60
+ const { NotFoundErrorPage } = app.getComponents();
61
+ let shownElement = errorComponent === void 0 ? /* @__PURE__ */ React__default["default"].createElement(NotFoundErrorPage, null) : errorComponent;
68
62
  if (permissionResult.loading) {
69
63
  shownElement = null;
70
64
  } else if (permissionResult.allowed) {
71
65
  shownElement = props.element;
72
66
  }
73
- return /* @__PURE__ */ React__default['default'].createElement(reactRouter.Route, {
74
- ...props,
67
+ return /* @__PURE__ */ React__default["default"].createElement(reactRouter.Route, {
68
+ ...otherProps,
75
69
  element: shownElement
76
70
  });
77
71
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/apis/PermissionApi.ts","../src/apis/IdentityPermissionApi.ts","../src/hooks/usePermission.ts","../src/components/PermissionedRoute.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AuthorizeRequest,\n AuthorizeResponse,\n} from '@backstage/plugin-permission-common';\nimport { ApiRef, createApiRef } from '@backstage/core-plugin-api';\n\n/**\n * This API is used by various frontend utilities that allow developers to implement authorization wihtin their frontend\n * plugins. A plugin developer will likely not have to interact with this API or its implementations directly, but\n * rather with the aforementioned utility components/hooks.\n * @public\n */\nexport type PermissionApi = {\n authorize(request: AuthorizeRequest): Promise<AuthorizeResponse>;\n};\n\n/**\n * A Backstage ApiRef for the Permission API. See https://backstage.io/docs/api/utility-apis for more information on\n * Backstage ApiRefs.\n * @public\n */\nexport const permissionApiRef: ApiRef<PermissionApi> = createApiRef({\n id: 'plugin.permission.api',\n});\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';\nimport { PermissionApi } from './PermissionApi';\nimport {\n AuthorizeRequest,\n AuthorizeResponse,\n PermissionClient,\n} from '@backstage/plugin-permission-common';\nimport { Config } from '@backstage/config';\n\n/**\n * The default implementation of the PermissionApi, which simply calls the authorize method of the given\n * {@link @backstage/plugin-permission-common#PermissionClient}.\n * @public\n */\nexport class IdentityPermissionApi implements PermissionApi {\n private constructor(\n private readonly permissionClient: PermissionClient,\n private readonly identityApi: IdentityApi,\n ) {}\n\n static create({\n configApi,\n discoveryApi,\n identityApi,\n }: {\n configApi: Config;\n discoveryApi: DiscoveryApi;\n identityApi: IdentityApi;\n }) {\n const permissionClient = new PermissionClient({ discoveryApi, configApi });\n return new IdentityPermissionApi(permissionClient, identityApi);\n }\n\n async authorize(request: AuthorizeRequest): Promise<AuthorizeResponse> {\n const response = await this.permissionClient.authorize([request], {\n token: await this.identityApi.getIdToken(),\n });\n return response[0];\n }\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useAsync } from 'react-use';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { permissionApiRef } from '../apis';\nimport {\n AuthorizeResult,\n Permission,\n} from '@backstage/plugin-permission-common';\n\n/** @public */\nexport type AsyncPermissionResult = {\n loading: boolean;\n allowed: boolean;\n error?: Error;\n};\n\n/**\n * React hook utlity for authorization. Given a {@link @backstage/plugin-permission-common#Permission} and an optional\n * resourceRef, it will return whether or not access is allowed (for the given resource, if resourceRef is provided). See\n * {@link @backstage/plugin-permission-common/PermissionClient#authorize} for more details.\n * @public\n */\nexport const usePermission = (\n permission: Permission,\n resourceRef?: string,\n): AsyncPermissionResult => {\n const permissionApi = useApi(permissionApiRef);\n\n const { loading, error, value } = useAsync(async () => {\n const { result } = await permissionApi.authorize({\n permission,\n resourceRef,\n });\n\n return result;\n }, [permissionApi, permission, resourceRef]);\n\n if (loading) {\n return { loading: true, allowed: false };\n }\n if (error) {\n return { error, loading: false, allowed: false };\n }\n return { loading: false, allowed: value === AuthorizeResult.ALLOW };\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentProps, ReactElement } from 'react';\nimport { Route } from 'react-router';\nimport { useApp } from '@backstage/core-plugin-api';\nimport { usePermission } from '../hooks';\nimport { Permission } from '@backstage/plugin-permission-common';\n\n/**\n * Returns a React Router Route which only renders the element when authorized. If unathorized, the Route will render a\n * NotFoundErrorPage (see {@link @backstage/core-app-api#AppComponents}).\n * @public\n */\nexport const PermissionedRoute = ({\n permission,\n resourceRef,\n errorComponent,\n ...props\n}: ComponentProps<typeof Route> & {\n permission: Permission;\n resourceRef?: string;\n errorComponent?: ReactElement | null;\n}) => {\n const permissionResult = usePermission(permission, resourceRef);\n const app = useApp();\n const { NotFoundErrorPage } = app.getComponents();\n\n let shownElement: ReactElement | null | undefined =\n errorComponent === undefined ? <NotFoundErrorPage /> : errorComponent;\n\n if (permissionResult.loading) {\n shownElement = null;\n } else if (permissionResult.allowed) {\n shownElement = props.element;\n }\n\n return <Route {...props} element={shownElement} />;\n};\n"],"names":["createApiRef","PermissionClient","useApi","useAsync","AuthorizeResult","useApp","Route"],"mappings":";;;;;;;;;;;;;;MAqCa,mBAA0CA,2BAAa;AAAA,EAClE,IAAI;AAAA;;4BCRsD;AAAA,EAClD,YACW,kBACA,aACjB;AAFiB;AACA;AAAA;AAAA,SAGZ,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,KAKC;AACD,UAAM,mBAAmB,IAAIC,wCAAiB,CAAE,cAAc;AAC9D,WAAO,IAAI,sBAAsB,kBAAkB;AAAA;AAAA,QAG/C,UAAU,SAAuD;AACrE,UAAM,WAAW,MAAM,KAAK,iBAAiB,UAAU,CAAC,UAAU;AAAA,MAChE,OAAO,MAAM,KAAK,YAAY;AAAA;AAEhC,WAAO,SAAS;AAAA;AAAA;;MChBP,gBAAgB,CAC3B,YACA,gBAC0B;AAC1B,QAAM,gBAAgBC,qBAAO;AAE7B,QAAM,CAAE,SAAS,OAAO,SAAUC,kBAAS,YAAY;AACrD,UAAM,CAAE,UAAW,MAAM,cAAc,UAAU;AAAA,MAC/C;AAAA,MACA;AAAA;AAGF,WAAO;AAAA,KACN,CAAC,eAAe,YAAY;AAE/B,MAAI,SAAS;AACX,WAAO,CAAE,SAAS,MAAM,SAAS;AAAA;AAEnC,MAAI,OAAO;AACT,WAAO,CAAE,OAAO,SAAS,OAAO,SAAS;AAAA;AAE3C,SAAO,CAAE,SAAS,OAAO,SAAS,UAAUC,uCAAgB;AAAA;;MC/BjD,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,KACG;AAAA,MAKC;AACJ,QAAM,mBAAmB,cAAc,YAAY;AACnD,QAAM,MAAMC;AACZ,QAAM,CAAE,qBAAsB,IAAI;AAElC,MAAI,eACF,mBAAmB,iEAAa,mBAAD,QAAwB;AAEzD,MAAI,iBAAiB,SAAS;AAC5B,mBAAe;AAAA,aACN,iBAAiB,SAAS;AACnC,mBAAe,MAAM;AAAA;AAGvB,iEAAQC,mBAAD;AAAA,OAAW;AAAA,IAAO,SAAS;AAAA;AAAA;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/apis/PermissionApi.ts","../src/apis/IdentityPermissionApi.ts","../src/hooks/usePermission.ts","../src/components/PermissionedRoute.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AuthorizeRequest,\n AuthorizeResponse,\n} from '@backstage/plugin-permission-common';\nimport { ApiRef, createApiRef } from '@backstage/core-plugin-api';\n\n/**\n * This API is used by various frontend utilities that allow developers to implement authorization wihtin their frontend\n * plugins. A plugin developer will likely not have to interact with this API or its implementations directly, but\n * rather with the aforementioned utility components/hooks.\n * @public\n */\nexport type PermissionApi = {\n authorize(request: AuthorizeRequest): Promise<AuthorizeResponse>;\n};\n\n/**\n * A Backstage ApiRef for the Permission API. See https://backstage.io/docs/api/utility-apis for more information on\n * Backstage ApiRefs.\n * @public\n */\nexport const permissionApiRef: ApiRef<PermissionApi> = createApiRef({\n id: 'plugin.permission.api',\n});\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';\nimport { PermissionApi } from './PermissionApi';\nimport {\n AuthorizeRequest,\n AuthorizeResponse,\n PermissionClient,\n} from '@backstage/plugin-permission-common';\nimport { Config } from '@backstage/config';\n\n/**\n * The default implementation of the PermissionApi, which simply calls the authorize method of the given\n * {@link @backstage/plugin-permission-common#PermissionClient}.\n * @public\n */\nexport class IdentityPermissionApi implements PermissionApi {\n private constructor(\n private readonly permissionClient: PermissionClient,\n private readonly identityApi: IdentityApi,\n ) {}\n\n static create(options: {\n config: Config;\n discovery: DiscoveryApi;\n identity: IdentityApi;\n }) {\n const { config, discovery, identity } = options;\n const permissionClient = new PermissionClient({ discovery, config });\n return new IdentityPermissionApi(permissionClient, identity);\n }\n\n async authorize(request: AuthorizeRequest): Promise<AuthorizeResponse> {\n const response = await this.permissionClient.authorize([request], {\n token: await this.identityApi.getIdToken(),\n });\n return response[0];\n }\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport useAsync from 'react-use/lib/useAsync';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { permissionApiRef } from '../apis';\nimport {\n AuthorizeResult,\n Permission,\n} from '@backstage/plugin-permission-common';\n\n/** @public */\nexport type AsyncPermissionResult = {\n loading: boolean;\n allowed: boolean;\n error?: Error;\n};\n\n/**\n * React hook utlity for authorization. Given a {@link @backstage/plugin-permission-common#Permission} and an optional\n * resourceRef, it will return whether or not access is allowed (for the given resource, if resourceRef is provided). See\n * {@link @backstage/plugin-permission-common/PermissionClient#authorize} for more details.\n * @public\n */\nexport const usePermission = (\n permission: Permission,\n resourceRef?: string,\n): AsyncPermissionResult => {\n const permissionApi = useApi(permissionApiRef);\n\n const { loading, error, value } = useAsync(async () => {\n const { result } = await permissionApi.authorize({\n permission,\n resourceRef,\n });\n\n return result;\n }, [permissionApi, permission, resourceRef]);\n\n if (loading) {\n return { loading: true, allowed: false };\n }\n if (error) {\n return { error, loading: false, allowed: false };\n }\n return { loading: false, allowed: value === AuthorizeResult.ALLOW };\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentProps, ReactElement } from 'react';\nimport { Route } from 'react-router';\nimport { useApp } from '@backstage/core-plugin-api';\nimport { usePermission } from '../hooks';\nimport { Permission } from '@backstage/plugin-permission-common';\n\n/**\n * Returns a React Router Route which only renders the element when authorized. If unauthorized, the Route will render a\n * NotFoundErrorPage (see {@link @backstage/core-app-api#AppComponents}).\n *\n * @public\n */\nexport const PermissionedRoute = (\n props: ComponentProps<typeof Route> & {\n permission: Permission;\n resourceRef?: string;\n errorComponent?: ReactElement | null;\n },\n) => {\n const { permission, resourceRef, errorComponent, ...otherProps } = props;\n const permissionResult = usePermission(permission, resourceRef);\n const app = useApp();\n const { NotFoundErrorPage } = app.getComponents();\n\n let shownElement: ReactElement | null | undefined =\n errorComponent === undefined ? <NotFoundErrorPage /> : errorComponent;\n\n if (permissionResult.loading) {\n shownElement = null;\n } else if (permissionResult.allowed) {\n shownElement = props.element;\n }\n\n return <Route {...otherProps} element={shownElement} />;\n};\n"],"names":["createApiRef","PermissionClient","useApi","useAsync","AuthorizeResult","useApp","Route"],"mappings":";;;;;;;;;;;;;;;MAqCa,mBAA0CA,2BAAa;AAAA,EAClE,IAAI;AAAA;;4BCRsD;AAAA,EAClD,YACW,kBACA,aACjB;AAFiB;AACA;AAAA;AAAA,SAGZ,OAAO,SAIX;AACD,UAAM,EAAE,QAAQ,WAAW,aAAa;AACxC,UAAM,mBAAmB,IAAIC,wCAAiB,EAAE,WAAW;AAC3D,WAAO,IAAI,sBAAsB,kBAAkB;AAAA;AAAA,QAG/C,UAAU,SAAuD;AACrE,UAAM,WAAW,MAAM,KAAK,iBAAiB,UAAU,CAAC,UAAU;AAAA,MAChE,OAAO,MAAM,KAAK,YAAY;AAAA;AAEhC,WAAO,SAAS;AAAA;AAAA;;MCbP,gBAAgB,CAC3B,YACA,gBAC0B;AAC1B,QAAM,gBAAgBC,qBAAO;AAE7B,QAAM,EAAE,SAAS,OAAO,UAAUC,6BAAS,YAAY;AACrD,UAAM,EAAE,WAAW,MAAM,cAAc,UAAU;AAAA,MAC/C;AAAA,MACA;AAAA;AAGF,WAAO;AAAA,KACN,CAAC,eAAe,YAAY;AAE/B,MAAI,SAAS;AACX,WAAO,EAAE,SAAS,MAAM,SAAS;AAAA;AAEnC,MAAI,OAAO;AACT,WAAO,EAAE,OAAO,SAAS,OAAO,SAAS;AAAA;AAE3C,SAAO,EAAE,SAAS,OAAO,SAAS,UAAUC,uCAAgB;AAAA;;MC9BjD,oBAAoB,CAC/B,UAKG;AACH,QAAM,EAAE,YAAY,aAAa,mBAAmB,eAAe;AACnE,QAAM,mBAAmB,cAAc,YAAY;AACnD,QAAM,MAAMC;AACZ,QAAM,EAAE,sBAAsB,IAAI;AAElC,MAAI,eACF,mBAAmB,iEAAa,mBAAD,QAAwB;AAEzD,MAAI,iBAAiB,SAAS;AAC5B,mBAAe;AAAA,aACN,iBAAiB,SAAS;AACnC,mBAAe,MAAM;AAAA;AAGvB,iEAAQC,mBAAD;AAAA,OAAW;AAAA,IAAY,SAAS;AAAA;AAAA;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,18 +1,19 @@
1
- import * as react_router from 'react-router';
2
- import React from 'react';
1
+ import { ComponentProps, ReactElement } from 'react';
2
+ import { Route } from 'react-router';
3
3
  import { Permission, AuthorizeRequest, AuthorizeResponse } from '@backstage/plugin-permission-common';
4
4
  import { ApiRef, DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';
5
5
  import { Config } from '@backstage/config';
6
6
 
7
7
  /**
8
- * Returns a React Router Route which only renders the element when authorized. If unathorized, the Route will render a
8
+ * Returns a React Router Route which only renders the element when authorized. If unauthorized, the Route will render a
9
9
  * NotFoundErrorPage (see {@link @backstage/core-app-api#AppComponents}).
10
+ *
10
11
  * @public
11
12
  */
12
- declare const PermissionedRoute: ({ permission, resourceRef, errorComponent, ...props }: react_router.RouteProps & {
13
+ declare const PermissionedRoute: (props: ComponentProps<typeof Route> & {
13
14
  permission: Permission;
14
- resourceRef?: string | undefined;
15
- errorComponent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined;
15
+ resourceRef?: string;
16
+ errorComponent?: ReactElement | null;
16
17
  }) => JSX.Element;
17
18
 
18
19
  /** @public */
@@ -54,10 +55,10 @@ declare class IdentityPermissionApi implements PermissionApi {
54
55
  private readonly permissionClient;
55
56
  private readonly identityApi;
56
57
  private constructor();
57
- static create({ configApi, discoveryApi, identityApi, }: {
58
- configApi: Config;
59
- discoveryApi: DiscoveryApi;
60
- identityApi: IdentityApi;
58
+ static create(options: {
59
+ config: Config;
60
+ discovery: DiscoveryApi;
61
+ identity: IdentityApi;
61
62
  }): IdentityPermissionApi;
62
63
  authorize(request: AuthorizeRequest): Promise<AuthorizeResponse>;
63
64
  }
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Route } from 'react-router';
3
3
  import { createApiRef, useApi, useApp } from '@backstage/core-plugin-api';
4
- import { useAsync } from 'react-use';
4
+ import useAsync from 'react-use/lib/useAsync';
5
5
  import { PermissionClient, AuthorizeResult } from '@backstage/plugin-permission-common';
6
6
 
7
7
  const permissionApiRef = createApiRef({
@@ -13,13 +13,10 @@ class IdentityPermissionApi {
13
13
  this.permissionClient = permissionClient;
14
14
  this.identityApi = identityApi;
15
15
  }
16
- static create({
17
- configApi,
18
- discoveryApi,
19
- identityApi
20
- }) {
21
- const permissionClient = new PermissionClient({discoveryApi, configApi});
22
- return new IdentityPermissionApi(permissionClient, identityApi);
16
+ static create(options) {
17
+ const { config, discovery, identity } = options;
18
+ const permissionClient = new PermissionClient({ discovery, config });
19
+ return new IdentityPermissionApi(permissionClient, identity);
23
20
  }
24
21
  async authorize(request) {
25
22
  const response = await this.permissionClient.authorize([request], {
@@ -31,31 +28,27 @@ class IdentityPermissionApi {
31
28
 
32
29
  const usePermission = (permission, resourceRef) => {
33
30
  const permissionApi = useApi(permissionApiRef);
34
- const {loading, error, value} = useAsync(async () => {
35
- const {result} = await permissionApi.authorize({
31
+ const { loading, error, value } = useAsync(async () => {
32
+ const { result } = await permissionApi.authorize({
36
33
  permission,
37
34
  resourceRef
38
35
  });
39
36
  return result;
40
37
  }, [permissionApi, permission, resourceRef]);
41
38
  if (loading) {
42
- return {loading: true, allowed: false};
39
+ return { loading: true, allowed: false };
43
40
  }
44
41
  if (error) {
45
- return {error, loading: false, allowed: false};
42
+ return { error, loading: false, allowed: false };
46
43
  }
47
- return {loading: false, allowed: value === AuthorizeResult.ALLOW};
44
+ return { loading: false, allowed: value === AuthorizeResult.ALLOW };
48
45
  };
49
46
 
50
- const PermissionedRoute = ({
51
- permission,
52
- resourceRef,
53
- errorComponent,
54
- ...props
55
- }) => {
47
+ const PermissionedRoute = (props) => {
48
+ const { permission, resourceRef, errorComponent, ...otherProps } = props;
56
49
  const permissionResult = usePermission(permission, resourceRef);
57
50
  const app = useApp();
58
- const {NotFoundErrorPage} = app.getComponents();
51
+ const { NotFoundErrorPage } = app.getComponents();
59
52
  let shownElement = errorComponent === void 0 ? /* @__PURE__ */ React.createElement(NotFoundErrorPage, null) : errorComponent;
60
53
  if (permissionResult.loading) {
61
54
  shownElement = null;
@@ -63,7 +56,7 @@ const PermissionedRoute = ({
63
56
  shownElement = props.element;
64
57
  }
65
58
  return /* @__PURE__ */ React.createElement(Route, {
66
- ...props,
59
+ ...otherProps,
67
60
  element: shownElement
68
61
  });
69
62
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/apis/PermissionApi.ts","../src/apis/IdentityPermissionApi.ts","../src/hooks/usePermission.ts","../src/components/PermissionedRoute.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AuthorizeRequest,\n AuthorizeResponse,\n} from '@backstage/plugin-permission-common';\nimport { ApiRef, createApiRef } from '@backstage/core-plugin-api';\n\n/**\n * This API is used by various frontend utilities that allow developers to implement authorization wihtin their frontend\n * plugins. A plugin developer will likely not have to interact with this API or its implementations directly, but\n * rather with the aforementioned utility components/hooks.\n * @public\n */\nexport type PermissionApi = {\n authorize(request: AuthorizeRequest): Promise<AuthorizeResponse>;\n};\n\n/**\n * A Backstage ApiRef for the Permission API. See https://backstage.io/docs/api/utility-apis for more information on\n * Backstage ApiRefs.\n * @public\n */\nexport const permissionApiRef: ApiRef<PermissionApi> = createApiRef({\n id: 'plugin.permission.api',\n});\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';\nimport { PermissionApi } from './PermissionApi';\nimport {\n AuthorizeRequest,\n AuthorizeResponse,\n PermissionClient,\n} from '@backstage/plugin-permission-common';\nimport { Config } from '@backstage/config';\n\n/**\n * The default implementation of the PermissionApi, which simply calls the authorize method of the given\n * {@link @backstage/plugin-permission-common#PermissionClient}.\n * @public\n */\nexport class IdentityPermissionApi implements PermissionApi {\n private constructor(\n private readonly permissionClient: PermissionClient,\n private readonly identityApi: IdentityApi,\n ) {}\n\n static create({\n configApi,\n discoveryApi,\n identityApi,\n }: {\n configApi: Config;\n discoveryApi: DiscoveryApi;\n identityApi: IdentityApi;\n }) {\n const permissionClient = new PermissionClient({ discoveryApi, configApi });\n return new IdentityPermissionApi(permissionClient, identityApi);\n }\n\n async authorize(request: AuthorizeRequest): Promise<AuthorizeResponse> {\n const response = await this.permissionClient.authorize([request], {\n token: await this.identityApi.getIdToken(),\n });\n return response[0];\n }\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useAsync } from 'react-use';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { permissionApiRef } from '../apis';\nimport {\n AuthorizeResult,\n Permission,\n} from '@backstage/plugin-permission-common';\n\n/** @public */\nexport type AsyncPermissionResult = {\n loading: boolean;\n allowed: boolean;\n error?: Error;\n};\n\n/**\n * React hook utlity for authorization. Given a {@link @backstage/plugin-permission-common#Permission} and an optional\n * resourceRef, it will return whether or not access is allowed (for the given resource, if resourceRef is provided). See\n * {@link @backstage/plugin-permission-common/PermissionClient#authorize} for more details.\n * @public\n */\nexport const usePermission = (\n permission: Permission,\n resourceRef?: string,\n): AsyncPermissionResult => {\n const permissionApi = useApi(permissionApiRef);\n\n const { loading, error, value } = useAsync(async () => {\n const { result } = await permissionApi.authorize({\n permission,\n resourceRef,\n });\n\n return result;\n }, [permissionApi, permission, resourceRef]);\n\n if (loading) {\n return { loading: true, allowed: false };\n }\n if (error) {\n return { error, loading: false, allowed: false };\n }\n return { loading: false, allowed: value === AuthorizeResult.ALLOW };\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentProps, ReactElement } from 'react';\nimport { Route } from 'react-router';\nimport { useApp } from '@backstage/core-plugin-api';\nimport { usePermission } from '../hooks';\nimport { Permission } from '@backstage/plugin-permission-common';\n\n/**\n * Returns a React Router Route which only renders the element when authorized. If unathorized, the Route will render a\n * NotFoundErrorPage (see {@link @backstage/core-app-api#AppComponents}).\n * @public\n */\nexport const PermissionedRoute = ({\n permission,\n resourceRef,\n errorComponent,\n ...props\n}: ComponentProps<typeof Route> & {\n permission: Permission;\n resourceRef?: string;\n errorComponent?: ReactElement | null;\n}) => {\n const permissionResult = usePermission(permission, resourceRef);\n const app = useApp();\n const { NotFoundErrorPage } = app.getComponents();\n\n let shownElement: ReactElement | null | undefined =\n errorComponent === undefined ? <NotFoundErrorPage /> : errorComponent;\n\n if (permissionResult.loading) {\n shownElement = null;\n } else if (permissionResult.allowed) {\n shownElement = props.element;\n }\n\n return <Route {...props} element={shownElement} />;\n};\n"],"names":[],"mappings":";;;;;;MAqCa,mBAA0C,aAAa;AAAA,EAClE,IAAI;AAAA;;4BCRsD;AAAA,EAClD,YACW,kBACA,aACjB;AAFiB;AACA;AAAA;AAAA,SAGZ,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,KAKC;AACD,UAAM,mBAAmB,IAAI,iBAAiB,CAAE,cAAc;AAC9D,WAAO,IAAI,sBAAsB,kBAAkB;AAAA;AAAA,QAG/C,UAAU,SAAuD;AACrE,UAAM,WAAW,MAAM,KAAK,iBAAiB,UAAU,CAAC,UAAU;AAAA,MAChE,OAAO,MAAM,KAAK,YAAY;AAAA;AAEhC,WAAO,SAAS;AAAA;AAAA;;MChBP,gBAAgB,CAC3B,YACA,gBAC0B;AAC1B,QAAM,gBAAgB,OAAO;AAE7B,QAAM,CAAE,SAAS,OAAO,SAAU,SAAS,YAAY;AACrD,UAAM,CAAE,UAAW,MAAM,cAAc,UAAU;AAAA,MAC/C;AAAA,MACA;AAAA;AAGF,WAAO;AAAA,KACN,CAAC,eAAe,YAAY;AAE/B,MAAI,SAAS;AACX,WAAO,CAAE,SAAS,MAAM,SAAS;AAAA;AAEnC,MAAI,OAAO;AACT,WAAO,CAAE,OAAO,SAAS,OAAO,SAAS;AAAA;AAE3C,SAAO,CAAE,SAAS,OAAO,SAAS,UAAU,gBAAgB;AAAA;;MC/BjD,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,KACG;AAAA,MAKC;AACJ,QAAM,mBAAmB,cAAc,YAAY;AACnD,QAAM,MAAM;AACZ,QAAM,CAAE,qBAAsB,IAAI;AAElC,MAAI,eACF,mBAAmB,6CAAa,mBAAD,QAAwB;AAEzD,MAAI,iBAAiB,SAAS;AAC5B,mBAAe;AAAA,aACN,iBAAiB,SAAS;AACnC,mBAAe,MAAM;AAAA;AAGvB,6CAAQ,OAAD;AAAA,OAAW;AAAA,IAAO,SAAS;AAAA;AAAA;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/apis/PermissionApi.ts","../src/apis/IdentityPermissionApi.ts","../src/hooks/usePermission.ts","../src/components/PermissionedRoute.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AuthorizeRequest,\n AuthorizeResponse,\n} from '@backstage/plugin-permission-common';\nimport { ApiRef, createApiRef } from '@backstage/core-plugin-api';\n\n/**\n * This API is used by various frontend utilities that allow developers to implement authorization wihtin their frontend\n * plugins. A plugin developer will likely not have to interact with this API or its implementations directly, but\n * rather with the aforementioned utility components/hooks.\n * @public\n */\nexport type PermissionApi = {\n authorize(request: AuthorizeRequest): Promise<AuthorizeResponse>;\n};\n\n/**\n * A Backstage ApiRef for the Permission API. See https://backstage.io/docs/api/utility-apis for more information on\n * Backstage ApiRefs.\n * @public\n */\nexport const permissionApiRef: ApiRef<PermissionApi> = createApiRef({\n id: 'plugin.permission.api',\n});\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';\nimport { PermissionApi } from './PermissionApi';\nimport {\n AuthorizeRequest,\n AuthorizeResponse,\n PermissionClient,\n} from '@backstage/plugin-permission-common';\nimport { Config } from '@backstage/config';\n\n/**\n * The default implementation of the PermissionApi, which simply calls the authorize method of the given\n * {@link @backstage/plugin-permission-common#PermissionClient}.\n * @public\n */\nexport class IdentityPermissionApi implements PermissionApi {\n private constructor(\n private readonly permissionClient: PermissionClient,\n private readonly identityApi: IdentityApi,\n ) {}\n\n static create(options: {\n config: Config;\n discovery: DiscoveryApi;\n identity: IdentityApi;\n }) {\n const { config, discovery, identity } = options;\n const permissionClient = new PermissionClient({ discovery, config });\n return new IdentityPermissionApi(permissionClient, identity);\n }\n\n async authorize(request: AuthorizeRequest): Promise<AuthorizeResponse> {\n const response = await this.permissionClient.authorize([request], {\n token: await this.identityApi.getIdToken(),\n });\n return response[0];\n }\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport useAsync from 'react-use/lib/useAsync';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { permissionApiRef } from '../apis';\nimport {\n AuthorizeResult,\n Permission,\n} from '@backstage/plugin-permission-common';\n\n/** @public */\nexport type AsyncPermissionResult = {\n loading: boolean;\n allowed: boolean;\n error?: Error;\n};\n\n/**\n * React hook utlity for authorization. Given a {@link @backstage/plugin-permission-common#Permission} and an optional\n * resourceRef, it will return whether or not access is allowed (for the given resource, if resourceRef is provided). See\n * {@link @backstage/plugin-permission-common/PermissionClient#authorize} for more details.\n * @public\n */\nexport const usePermission = (\n permission: Permission,\n resourceRef?: string,\n): AsyncPermissionResult => {\n const permissionApi = useApi(permissionApiRef);\n\n const { loading, error, value } = useAsync(async () => {\n const { result } = await permissionApi.authorize({\n permission,\n resourceRef,\n });\n\n return result;\n }, [permissionApi, permission, resourceRef]);\n\n if (loading) {\n return { loading: true, allowed: false };\n }\n if (error) {\n return { error, loading: false, allowed: false };\n }\n return { loading: false, allowed: value === AuthorizeResult.ALLOW };\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentProps, ReactElement } from 'react';\nimport { Route } from 'react-router';\nimport { useApp } from '@backstage/core-plugin-api';\nimport { usePermission } from '../hooks';\nimport { Permission } from '@backstage/plugin-permission-common';\n\n/**\n * Returns a React Router Route which only renders the element when authorized. If unauthorized, the Route will render a\n * NotFoundErrorPage (see {@link @backstage/core-app-api#AppComponents}).\n *\n * @public\n */\nexport const PermissionedRoute = (\n props: ComponentProps<typeof Route> & {\n permission: Permission;\n resourceRef?: string;\n errorComponent?: ReactElement | null;\n },\n) => {\n const { permission, resourceRef, errorComponent, ...otherProps } = props;\n const permissionResult = usePermission(permission, resourceRef);\n const app = useApp();\n const { NotFoundErrorPage } = app.getComponents();\n\n let shownElement: ReactElement | null | undefined =\n errorComponent === undefined ? <NotFoundErrorPage /> : errorComponent;\n\n if (permissionResult.loading) {\n shownElement = null;\n } else if (permissionResult.allowed) {\n shownElement = props.element;\n }\n\n return <Route {...otherProps} element={shownElement} />;\n};\n"],"names":[],"mappings":";;;;;;MAqCa,mBAA0C,aAAa;AAAA,EAClE,IAAI;AAAA;;4BCRsD;AAAA,EAClD,YACW,kBACA,aACjB;AAFiB;AACA;AAAA;AAAA,SAGZ,OAAO,SAIX;AACD,UAAM,EAAE,QAAQ,WAAW,aAAa;AACxC,UAAM,mBAAmB,IAAI,iBAAiB,EAAE,WAAW;AAC3D,WAAO,IAAI,sBAAsB,kBAAkB;AAAA;AAAA,QAG/C,UAAU,SAAuD;AACrE,UAAM,WAAW,MAAM,KAAK,iBAAiB,UAAU,CAAC,UAAU;AAAA,MAChE,OAAO,MAAM,KAAK,YAAY;AAAA;AAEhC,WAAO,SAAS;AAAA;AAAA;;MCbP,gBAAgB,CAC3B,YACA,gBAC0B;AAC1B,QAAM,gBAAgB,OAAO;AAE7B,QAAM,EAAE,SAAS,OAAO,UAAU,SAAS,YAAY;AACrD,UAAM,EAAE,WAAW,MAAM,cAAc,UAAU;AAAA,MAC/C;AAAA,MACA;AAAA;AAGF,WAAO;AAAA,KACN,CAAC,eAAe,YAAY;AAE/B,MAAI,SAAS;AACX,WAAO,EAAE,SAAS,MAAM,SAAS;AAAA;AAEnC,MAAI,OAAO;AACT,WAAO,EAAE,OAAO,SAAS,OAAO,SAAS;AAAA;AAE3C,SAAO,EAAE,SAAS,OAAO,SAAS,UAAU,gBAAgB;AAAA;;MC9BjD,oBAAoB,CAC/B,UAKG;AACH,QAAM,EAAE,YAAY,aAAa,mBAAmB,eAAe;AACnE,QAAM,mBAAmB,cAAc,YAAY;AACnD,QAAM,MAAM;AACZ,QAAM,EAAE,sBAAsB,IAAI;AAElC,MAAI,eACF,mBAAmB,6CAAa,mBAAD,QAAwB;AAEzD,MAAI,iBAAiB,SAAS;AAC5B,mBAAe;AAAA,aACN,iBAAiB,SAAS;AACnC,mBAAe,MAAM;AAAA;AAGvB,6CAAQ,OAAD;AAAA,OAAW;AAAA,IAAY,SAAS;AAAA;AAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-permission-react",
3
- "version": "0.1.0",
3
+ "version": "0.2.2",
4
4
  "main": "dist/index.esm.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -27,18 +27,20 @@
27
27
  "clean": "backstage-cli clean"
28
28
  },
29
29
  "dependencies": {
30
- "@backstage/config": "^0.1.11",
31
- "@backstage/core-plugin-api": "^0.2.2",
32
- "@backstage/plugin-permission-common": "^0.2.0",
33
- "@types/react": "*",
30
+ "@backstage/config": "^0.1.12",
31
+ "@backstage/core-plugin-api": "^0.5.0",
32
+ "@backstage/plugin-permission-common": "^0.3.1",
34
33
  "cross-fetch": "^3.0.6",
35
- "react": "^16.13.1",
36
34
  "react-router": "6.0.0-beta.0",
37
35
  "react-use": "^17.2.4"
38
36
  },
37
+ "peerDependencies": {
38
+ "@types/react": "^16.13.1 || ^17.0.0",
39
+ "react": "^16.13.1 || ^17.0.0"
40
+ },
39
41
  "devDependencies": {
40
- "@backstage/cli": "^0.10.0",
41
- "@backstage/test-utils": "^0.1.22",
42
+ "@backstage/cli": "^0.11.0",
43
+ "@backstage/test-utils": "^0.2.2",
42
44
  "@testing-library/jest-dom": "^5.10.1",
43
45
  "@testing-library/react": "^11.2.5",
44
46
  "@types/jest": "^26.0.7"
@@ -46,5 +48,5 @@
46
48
  "files": [
47
49
  "dist"
48
50
  ],
49
- "gitHead": "a05e7081b805006e3f0b2960a08a7753357f532f"
51
+ "gitHead": "da66c61bdd63cdb3f0f0cd2e26dc9e6454d93c7b"
50
52
  }