@backstage/plugin-auth-react 0.1.14-next.0 → 0.1.14-next.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/CHANGELOG.md +13 -0
- package/dist/components/CookieAuthRedirect/CookieAuthRedirect.esm.js +13 -8
- package/dist/components/CookieAuthRedirect/CookieAuthRedirect.esm.js.map +1 -1
- package/dist/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.esm.js +4 -4
- package/dist/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.esm.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/package.json +12 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @backstage/plugin-auth-react
|
|
2
2
|
|
|
3
|
+
## 0.1.14-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a47fd39: Removes instances of default React imports, a necessary update for the upcoming React 19 migration.
|
|
8
|
+
|
|
9
|
+
<https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html>
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/core-components@0.17.1-next.1
|
|
13
|
+
- @backstage/core-plugin-api@1.10.6-next.0
|
|
14
|
+
- @backstage/errors@1.2.7
|
|
15
|
+
|
|
3
16
|
## 0.1.14-next.0
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useApi, identityApiRef } from '@backstage/core-plugin-api';
|
|
3
3
|
import { useAsync, useMountEffect } from '@react-hookz/web';
|
|
4
4
|
|
|
@@ -13,20 +13,25 @@ function CookieAuthRedirect() {
|
|
|
13
13
|
});
|
|
14
14
|
useMountEffect(actions.execute);
|
|
15
15
|
if (state.status === "error" && state.error) {
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
17
|
+
"An error occurred: ",
|
|
18
|
+
state.error.message
|
|
19
|
+
] });
|
|
17
20
|
}
|
|
18
21
|
if (state.status === "success" && state.result) {
|
|
19
|
-
return /* @__PURE__ */
|
|
22
|
+
return /* @__PURE__ */ jsxs(
|
|
20
23
|
"form",
|
|
21
24
|
{
|
|
22
25
|
ref: (form) => form?.submit(),
|
|
23
26
|
action: window.location.href,
|
|
24
27
|
method: "POST",
|
|
25
|
-
style: { visibility: "hidden" }
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
style: { visibility: "hidden" },
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsx("input", { type: "hidden", name: "type", value: "sign-in" }),
|
|
31
|
+
/* @__PURE__ */ jsx("input", { type: "hidden", name: "token", value: state.result }),
|
|
32
|
+
/* @__PURE__ */ jsx("input", { type: "submit", value: "Continue" })
|
|
33
|
+
]
|
|
34
|
+
}
|
|
30
35
|
);
|
|
31
36
|
}
|
|
32
37
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieAuthRedirect.esm.js","sources":["../../../src/components/CookieAuthRedirect/CookieAuthRedirect.tsx"],"sourcesContent":["/*\n * Copyright 2024 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
|
|
1
|
+
{"version":3,"file":"CookieAuthRedirect.esm.js","sources":["../../../src/components/CookieAuthRedirect/CookieAuthRedirect.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 { identityApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useAsync, useMountEffect } from '@react-hookz/web';\n\n/**\n * @public\n * A component that redirects to the page an user was trying to access before sign-in.\n */\nexport function CookieAuthRedirect() {\n const identityApi = useApi(identityApiRef);\n\n const [state, actions] = useAsync(async () => {\n const { token } = await identityApi.getCredentials();\n if (!token) {\n throw new Error('Expected Backstage token in sign-in response');\n }\n return token;\n });\n\n useMountEffect(actions.execute);\n\n if (state.status === 'error' && state.error) {\n return <>An error occurred: {state.error.message}</>;\n }\n\n if (state.status === 'success' && state.result) {\n return (\n <form\n ref={form => form?.submit()}\n action={window.location.href}\n method=\"POST\"\n style={{ visibility: 'hidden' }}\n >\n <input type=\"hidden\" name=\"type\" value=\"sign-in\" />\n <input type=\"hidden\" name=\"token\" value={state.result} />\n <input type=\"submit\" value=\"Continue\" />\n </form>\n );\n }\n\n return null;\n}\n"],"names":[],"mappings":";;;;AAuBO,SAAS,kBAAqB,GAAA;AACnC,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA;AAEzC,EAAA,MAAM,CAAC,KAAA,EAAO,OAAO,CAAA,GAAI,SAAS,YAAY;AAC5C,IAAA,MAAM,EAAE,KAAA,EAAU,GAAA,MAAM,YAAY,cAAe,EAAA;AACnD,IAAA,IAAI,CAAC,KAAO,EAAA;AACV,MAAM,MAAA,IAAI,MAAM,8CAA8C,CAAA;AAAA;AAEhE,IAAO,OAAA,KAAA;AAAA,GACR,CAAA;AAED,EAAA,cAAA,CAAe,QAAQ,OAAO,CAAA;AAE9B,EAAA,IAAI,KAAM,CAAA,MAAA,KAAW,OAAW,IAAA,KAAA,CAAM,KAAO,EAAA;AAC3C,IAAA,uBAAS,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,MAAA,qBAAA;AAAA,MAAoB,MAAM,KAAM,CAAA;AAAA,KAAQ,EAAA,CAAA;AAAA;AAGnD,EAAA,IAAI,KAAM,CAAA,MAAA,KAAW,SAAa,IAAA,KAAA,CAAM,MAAQ,EAAA;AAC9C,IACE,uBAAA,IAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,GAAA,EAAK,CAAQ,IAAA,KAAA,IAAA,EAAM,MAAO,EAAA;AAAA,QAC1B,MAAA,EAAQ,OAAO,QAAS,CAAA,IAAA;AAAA,QACxB,MAAO,EAAA,MAAA;AAAA,QACP,KAAA,EAAO,EAAE,UAAA,EAAY,QAAS,EAAA;AAAA,QAE9B,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,WAAM,IAAK,EAAA,QAAA,EAAS,IAAK,EAAA,MAAA,EAAO,OAAM,SAAU,EAAA,CAAA;AAAA,0BACjD,GAAA,CAAC,WAAM,IAAK,EAAA,QAAA,EAAS,MAAK,OAAQ,EAAA,KAAA,EAAO,MAAM,MAAQ,EAAA,CAAA;AAAA,0BACtD,GAAA,CAAA,OAAA,EAAA,EAAM,IAAK,EAAA,QAAA,EAAS,OAAM,UAAW,EAAA;AAAA;AAAA;AAAA,KACxC;AAAA;AAIJ,EAAO,OAAA,IAAA;AACT;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { ErrorPanel } from '@backstage/core-components';
|
|
3
3
|
import { useApp } from '@backstage/core-plugin-api';
|
|
4
4
|
import Button from '@material-ui/core/Button';
|
|
@@ -10,12 +10,12 @@ function CookieAuthRefreshProvider(props) {
|
|
|
10
10
|
const { Progress } = app.getComponents();
|
|
11
11
|
const result = useCookieAuthRefresh(options);
|
|
12
12
|
if (result.status === "loading") {
|
|
13
|
-
return /* @__PURE__ */
|
|
13
|
+
return /* @__PURE__ */ jsx(Progress, {});
|
|
14
14
|
}
|
|
15
15
|
if (result.status === "error") {
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ jsx(ErrorPanel, { error: result.error, children: /* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: result.retry, children: "Retry" }) });
|
|
17
17
|
}
|
|
18
|
-
return /* @__PURE__ */
|
|
18
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export { CookieAuthRefreshProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieAuthRefreshProvider.esm.js","sources":["../../../src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx"],"sourcesContent":["/*\n * Copyright 2024 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
|
|
1
|
+
{"version":3,"file":"CookieAuthRefreshProvider.esm.js","sources":["../../../src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 { ReactNode } from 'react';\nimport { ErrorPanel } from '@backstage/core-components';\nimport { useApp } from '@backstage/core-plugin-api';\nimport Button from '@material-ui/core/Button';\nimport { useCookieAuthRefresh } from '../../hooks';\n\n/**\n * @public\n * Props for the {@link CookieAuthRefreshProvider} component.\n */\nexport type CookieAuthRefreshProviderProps = {\n // The plugin ID used for discovering the API origin\n pluginId: string;\n // The children to render when the refresh is successful\n children: ReactNode;\n};\n\n/**\n * @public\n * A provider that will refresh the cookie when it is about to expire.\n */\nexport function CookieAuthRefreshProvider(\n props: CookieAuthRefreshProviderProps,\n): JSX.Element {\n const { children, ...options } = props;\n const app = useApp();\n const { Progress } = app.getComponents();\n\n const result = useCookieAuthRefresh(options);\n\n if (result.status === 'loading') {\n return <Progress />;\n }\n\n if (result.status === 'error') {\n return (\n <ErrorPanel error={result.error}>\n <Button variant=\"outlined\" onClick={result.retry}>\n Retry\n </Button>\n </ErrorPanel>\n );\n }\n\n return <>{children}</>;\n}\n"],"names":[],"mappings":";;;;;;AAqCO,SAAS,0BACd,KACa,EAAA;AACb,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,OAAA,EAAY,GAAA,KAAA;AACjC,EAAA,MAAM,MAAM,MAAO,EAAA;AACnB,EAAA,MAAM,EAAE,QAAA,EAAa,GAAA,GAAA,CAAI,aAAc,EAAA;AAEvC,EAAM,MAAA,MAAA,GAAS,qBAAqB,OAAO,CAAA;AAE3C,EAAI,IAAA,MAAA,CAAO,WAAW,SAAW,EAAA;AAC/B,IAAA,2BAAQ,QAAS,EAAA,EAAA,CAAA;AAAA;AAGnB,EAAI,IAAA,MAAA,CAAO,WAAW,OAAS,EAAA;AAC7B,IAAA,uBACG,GAAA,CAAA,UAAA,EAAA,EAAW,KAAO,EAAA,MAAA,CAAO,KACxB,EAAA,QAAA,kBAAA,GAAA,CAAC,MAAO,EAAA,EAAA,OAAA,EAAQ,UAAW,EAAA,OAAA,EAAS,MAAO,CAAA,KAAA,EAAO,mBAElD,CACF,EAAA,CAAA;AAAA;AAIJ,EAAA,uCAAU,QAAS,EAAA,CAAA;AACrB;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @public
|
|
5
6
|
* A component that redirects to the page an user was trying to access before sign-in.
|
|
6
7
|
*/
|
|
7
|
-
declare function CookieAuthRedirect():
|
|
8
|
+
declare function CookieAuthRedirect(): react_jsx_runtime.JSX.Element | null;
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @public
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-auth-react",
|
|
3
|
-
"version": "0.1.14-next.
|
|
3
|
+
"version": "0.1.14-next.1",
|
|
4
4
|
"description": "Web library for the auth plugin",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library",
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
"test": "backstage-cli package test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@backstage/core-components": "0.17.1-next.
|
|
42
|
-
"@backstage/core-plugin-api": "1.10.
|
|
41
|
+
"@backstage/core-components": "0.17.1-next.1",
|
|
42
|
+
"@backstage/core-plugin-api": "1.10.6-next.0",
|
|
43
43
|
"@backstage/errors": "1.2.7",
|
|
44
44
|
"@material-ui/core": "^4.9.13",
|
|
45
45
|
"@react-hookz/web": "^24.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@backstage/cli": "0.32.0-next.
|
|
49
|
-
"@backstage/test-utils": "1.7.
|
|
48
|
+
"@backstage/cli": "0.32.0-next.2",
|
|
49
|
+
"@backstage/test-utils": "1.7.7-next.0",
|
|
50
50
|
"@testing-library/jest-dom": "^6.0.0",
|
|
51
51
|
"@testing-library/react": "^16.0.0",
|
|
52
52
|
"@testing-library/user-event": "^14.0.0",
|
|
@@ -67,5 +67,12 @@
|
|
|
67
67
|
"optional": true
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
+
"typesVersions": {
|
|
71
|
+
"*": {
|
|
72
|
+
"package.json": [
|
|
73
|
+
"package.json"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
},
|
|
70
77
|
"module": "./dist/index.esm.js"
|
|
71
78
|
}
|