@backstage/core-components 0.18.10 → 0.18.11-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 +16 -0
- package/dist/components/AutoLogout/AutoLogout.esm.js +28 -13
- package/dist/components/AutoLogout/AutoLogout.esm.js.map +1 -1
- package/dist/components/AutoLogout/disconnectedUsers.esm.js +20 -14
- package/dist/components/AutoLogout/disconnectedUsers.esm.js.map +1 -1
- package/dist/components/Table/Filters.esm.js +8 -1
- package/dist/components/Table/Filters.esm.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/layout/ProxiedSignInPage/ProxiedSignInIdentity.esm.js +6 -1
- package/dist/layout/ProxiedSignInPage/ProxiedSignInIdentity.esm.js.map +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @backstage/core-components
|
|
2
2
|
|
|
3
|
+
## 0.18.11-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dbe93a7: Fix autologout not working correctly when closing all tabs
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-plugin-api@1.12.7-next.0
|
|
10
|
+
|
|
11
|
+
## 0.18.11-next.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- e0889a3: chore(deps): bump `qs` from 6.15.1 to 6.15.2
|
|
16
|
+
- a07e6a3: Added the correctly-spelled `'header'` literal to the `TableFiltersClassKey` union type and deprecated the previous typoed `'heder'` literal. The generated CSS class with the old key is preserved for backwards compatibility; switch to `'header'` to avoid future removal.
|
|
17
|
+
- 8add9b9: Fixed the proxy-based sign-in page failing to read the session token when the proxy issues a token whose payload is encoded using the URL-safe base64 alphabet. Such tokens are now decoded correctly so sign-in no longer breaks.
|
|
18
|
+
|
|
3
19
|
## 0.18.10
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useApi, identityApiRef, configApiRef } from '@backstage/core-plugin-api';
|
|
3
|
-
import { useState,
|
|
3
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
4
4
|
import { useIdleTimer, workerTimers } from 'react-idle-timer';
|
|
5
5
|
import { LAST_SEEN_ONLINE_STORAGE_KEY, useLogoutDisconnectedUserEffect } from './disconnectedUsers.esm.js';
|
|
6
6
|
import { StillTherePrompt } from './StillTherePrompt.esm.js';
|
|
@@ -28,6 +28,7 @@ const ConditionalAutoLogout = ({
|
|
|
28
28
|
const onIdle = () => {
|
|
29
29
|
setPromptOpen(false);
|
|
30
30
|
setRemainingTimeCountdown(0);
|
|
31
|
+
lastSeenOnlineStore.delete();
|
|
31
32
|
identityApi.signOut();
|
|
32
33
|
};
|
|
33
34
|
const onActive = () => {
|
|
@@ -94,17 +95,34 @@ const parseConfig = (configApi, props) => {
|
|
|
94
95
|
const AutoLogout = (props) => {
|
|
95
96
|
const identityApi = useApi(identityApiRef);
|
|
96
97
|
const configApi = useApi(configApiRef);
|
|
97
|
-
const [isLogged, setIsLogged] = useState(
|
|
98
|
+
const [isLogged, setIsLogged] = useState(null);
|
|
99
|
+
const lastSeenOnlineStore = useMemo(
|
|
100
|
+
() => new DefaultTimestampStore(LAST_SEEN_ONLINE_STORAGE_KEY),
|
|
101
|
+
[]
|
|
102
|
+
);
|
|
98
103
|
useEffect(() => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
let cancelled = false;
|
|
105
|
+
async function checkLogin(identity) {
|
|
106
|
+
try {
|
|
107
|
+
const creds = await identity.getCredentials();
|
|
108
|
+
if (cancelled) return;
|
|
109
|
+
if (creds?.token) {
|
|
110
|
+
setIsLogged(true);
|
|
111
|
+
} else {
|
|
112
|
+
setIsLogged(false);
|
|
113
|
+
lastSeenOnlineStore.delete();
|
|
114
|
+
}
|
|
115
|
+
} catch (err) {
|
|
116
|
+
if (cancelled) return;
|
|
103
117
|
setIsLogged(false);
|
|
118
|
+
lastSeenOnlineStore.delete();
|
|
104
119
|
}
|
|
105
120
|
}
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
checkLogin(identityApi);
|
|
122
|
+
return () => {
|
|
123
|
+
cancelled = true;
|
|
124
|
+
};
|
|
125
|
+
}, [lastSeenOnlineStore, identityApi]);
|
|
108
126
|
const {
|
|
109
127
|
enabled,
|
|
110
128
|
idleTimeoutMinutes,
|
|
@@ -131,15 +149,12 @@ const AutoLogout = (props) => {
|
|
|
131
149
|
);
|
|
132
150
|
}
|
|
133
151
|
}, [idleTimeoutMinutes, promptBeforeIdleSeconds]);
|
|
134
|
-
const lastSeenOnlineStore = useMemo(
|
|
135
|
-
() => new DefaultTimestampStore(LAST_SEEN_ONLINE_STORAGE_KEY),
|
|
136
|
-
[]
|
|
137
|
-
);
|
|
138
152
|
const [promptOpen, setPromptOpen] = useState(false);
|
|
139
153
|
const [remainingTimeCountdown, setRemainingTimeCountdown] = useState(0);
|
|
140
154
|
useLogoutDisconnectedUserEffect({
|
|
141
155
|
enableEffect: logoutIfDisconnected,
|
|
142
|
-
autologoutIsEnabled: enabled
|
|
156
|
+
autologoutIsEnabled: enabled,
|
|
157
|
+
isLoggedIn: isLogged,
|
|
143
158
|
idleTimeoutSeconds: idleTimeoutMinutes * 60,
|
|
144
159
|
lastSeenOnlineStore,
|
|
145
160
|
identityApi
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoLogout.esm.js","sources":["../../../src/components/AutoLogout/AutoLogout.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 ConfigApi,\n configApiRef,\n IdentityApi,\n identityApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { useEffect, useMemo, useState } from 'react';\nimport {\n EventsType,\n IIdleTimer,\n workerTimers,\n useIdleTimer,\n} from 'react-idle-timer';\n\nimport {\n LAST_SEEN_ONLINE_STORAGE_KEY,\n useLogoutDisconnectedUserEffect,\n} from './disconnectedUsers';\nimport { StillTherePrompt } from './StillTherePrompt';\nimport { DefaultTimestampStore, TimestampStore } from './timestampStore';\n\ntype AutoLogoutTrackableEvent = EventsType;\n\n/** @public */\nexport type AutoLogoutProps = {\n /**\n * Enable/disable the AutoLogoutMechanism.\n * defaults to true.\n */\n enabled?: boolean;\n /**\n * The amount of time (in minutes) of inactivity\n * after which the user is automatically logged out.\n * defaults to 60 minutes.\n */\n idleTimeoutMinutes?: number;\n /**\n * The number of seconds before the idleTimeout expires,\n * at which the user will be alerted by a Dialog that\n * they are about to be logged out.\n * defaults to 10 seconds\n */\n promptBeforeIdleSeconds?: number;\n /**\n * Enable/disable the usage of Node's worker thread timers instead of main thread timers.\n * This is helpful if you notice that the your browser is killing inactive tab's timers, like the one used by AutoLogout.\n * If you experience some browser incompatibility, you may try to set this to false.\n * defaults to true.\n */\n useWorkerTimers?: boolean;\n /**\n * Enable/disable the autologout for disconnected users.\n * disconnected users are the ones that are logged in but have no Backstage tab open in their browsers.\n * If enabled, disconnected users will be automatically logged out after `idleTimeoutMinutes`\n * defaults to true\n */\n logoutIfDisconnected?: boolean;\n};\n\ntype AutoLogoutInternalProps = Omit<Required<AutoLogoutProps>, 'enabled'> & {\n events: AutoLogoutTrackableEvent[];\n promptOpen: boolean;\n setPromptOpen: (value: boolean) => void;\n remainingTimeCountdown: number;\n setRemainingTimeCountdown: (amount: number) => void;\n identityApi: IdentityApi;\n lastSeenOnlineStore: TimestampStore;\n};\n\nconst ConditionalAutoLogout = ({\n idleTimeoutMinutes,\n events,\n useWorkerTimers,\n logoutIfDisconnected,\n promptBeforeIdleSeconds,\n promptOpen,\n setPromptOpen,\n remainingTimeCountdown,\n setRemainingTimeCountdown,\n identityApi,\n lastSeenOnlineStore,\n}: AutoLogoutInternalProps): JSX.Element => {\n const promptBeforeIdleMillis = promptBeforeIdleSeconds * 1000;\n const promptBeforeIdle = promptBeforeIdleMillis > 0 ? true : false;\n\n const onPrompt = async () => {\n // onPrompt will be called `promptBeforeIdle` milliseconds before `timeout`.\n // All events are disabled while the prompt is active.\n // If the user wishes to stay active, call the `activate()` method.\n // You can get the remaining prompt time with the `getRemainingTime()` method,\n setPromptOpen(true);\n setRemainingTimeCountdown(promptBeforeIdleMillis);\n };\n\n const onIdle = () => {\n // onIdle will be called after the timeout is reached.\n // Events will be rebound as long as `stopOnMount` is not set.\n setPromptOpen(false);\n setRemainingTimeCountdown(0);\n identityApi.signOut();\n };\n\n const onActive = () => {\n // onActive will only be called if `activate()` is called while `isPrompted()`\n // is true. Here you will also want to close your modal and perform\n // any active actions.\n setPromptOpen(false);\n setRemainingTimeCountdown(0);\n };\n\n const onAction = (\n _event?: Event | undefined,\n _idleTimer?: IIdleTimer | null,\n ) => {\n // onAction will be called if any user event is detected. The list of events that triggers a user event detection is the list of configured events\n // If any user event is detected we update the Last seen online in storage\n lastSeenOnlineStore.save(new Date());\n };\n\n const timer = useIdleTimer({\n timeout: idleTimeoutMinutes * 60 * 1000,\n events: events,\n crossTab: true,\n name: 'autologout-timer',\n timers: useWorkerTimers ? workerTimers : undefined,\n onIdle: onIdle,\n onActive: promptBeforeIdle ? onActive : undefined,\n onAction: logoutIfDisconnected ? onAction : undefined,\n onPrompt: promptBeforeIdle ? onPrompt : undefined,\n promptBeforeIdle: promptBeforeIdle ? promptBeforeIdleMillis : undefined,\n syncTimers: 1000,\n });\n\n return (\n <>\n {promptBeforeIdle && (\n <StillTherePrompt\n idleTimer={timer}\n open={promptOpen}\n setOpen={setPromptOpen}\n remainingTime={remainingTimeCountdown}\n setRemainingTime={setRemainingTimeCountdown}\n promptTimeoutMillis={promptBeforeIdleMillis}\n />\n )}\n </>\n );\n};\n\nconst defaultConfig: Required<AutoLogoutProps> = {\n enabled: true,\n idleTimeoutMinutes: 0.5,\n promptBeforeIdleSeconds: 10,\n useWorkerTimers: true,\n logoutIfDisconnected: true,\n};\n\n/**\n * A list of DOM events that the activity tracker will use to determine if the user is active or not.\n */\nconst defaultTrackedEvents: AutoLogoutTrackableEvent[] = [\n 'mousemove',\n 'keydown',\n 'wheel',\n 'DOMMouseScroll',\n 'mousewheel',\n 'mousedown',\n 'touchstart',\n 'touchmove',\n 'MSPointerDown',\n 'MSPointerMove',\n 'visibilitychange',\n];\n\n/**\n * Parses configuration for the AutoLogout. Properties configured in `app-config` take precedence over the props passed to the React component.\n * If neither props nor config properties are found, a default value will be set accordingly.\n */\nconst parseConfig = (\n configApi: ConfigApi,\n props: AutoLogoutProps,\n): Required<AutoLogoutProps> => {\n return {\n enabled:\n configApi.getOptionalBoolean('auth.autologout.enabled') ??\n props.enabled ??\n defaultConfig.enabled,\n idleTimeoutMinutes:\n configApi.getOptionalNumber('auth.autologout.idleTimeoutMinutes') ??\n props.idleTimeoutMinutes ??\n defaultConfig.idleTimeoutMinutes,\n promptBeforeIdleSeconds:\n configApi.getOptionalNumber('auth.autologout.promptBeforeIdleSeconds') ??\n props.promptBeforeIdleSeconds ??\n defaultConfig.promptBeforeIdleSeconds,\n useWorkerTimers:\n configApi.getOptionalBoolean('auth.autologout.useWorkerTimers') ??\n props.useWorkerTimers ??\n defaultConfig.useWorkerTimers,\n logoutIfDisconnected:\n configApi.getOptionalBoolean('auth.autologout.logoutIfDisconnected') ??\n props.logoutIfDisconnected ??\n defaultConfig.logoutIfDisconnected,\n };\n};\n\n/**\n * The Autologout feature enables platform engineers to add a mechanism to log out users after a configurable amount of time of inactivity.\n * When enabled, the mechanism will track user actions (mouse movement, mouse click, key pressing, taps, etc.) in order to determine if they are active or not.\n * After a certain amount of inactivity/idle time, the user session is invalidated and they are required to sign in again.\n *\n * @public\n */\nexport const AutoLogout = (props: AutoLogoutProps): JSX.Element | null => {\n const identityApi = useApi(identityApiRef);\n const configApi = useApi(configApiRef);\n const [isLogged, setIsLogged] = useState(false);\n useEffect(() => {\n // if the user is not logged in, the autologout feature won't affect the app even if enabled\n async function isLoggedIn(identity: IdentityApi) {\n if ((await identity.getCredentials()).token) {\n setIsLogged(true);\n } else {\n setIsLogged(false);\n }\n }\n isLoggedIn(identityApi);\n }, [identityApi]);\n\n const {\n enabled,\n idleTimeoutMinutes,\n promptBeforeIdleSeconds,\n logoutIfDisconnected,\n useWorkerTimers,\n }: AutoLogoutProps = useMemo(() => {\n return parseConfig(configApi, props);\n }, [configApi, props]);\n\n useEffect(() => {\n if (idleTimeoutMinutes < 0.5) {\n throw new Error(\n '❌ idleTimeoutMinutes property should be >= 0.5 minutes (30 seconds).',\n );\n }\n\n if (promptBeforeIdleSeconds < 0) {\n throw new Error(\n '❌ promptBeforeIdleSeconds property should be >= 0 seconds. Set to 0 to disable the prompt.',\n );\n }\n\n if (idleTimeoutMinutes * 60 <= promptBeforeIdleSeconds) {\n throw new Error(\n `❌ promptBeforeIdleSeconds should be smaller than idleTimeoutMinutes`,\n );\n }\n }, [idleTimeoutMinutes, promptBeforeIdleSeconds]);\n\n const lastSeenOnlineStore: TimestampStore = useMemo(\n () => new DefaultTimestampStore(LAST_SEEN_ONLINE_STORAGE_KEY),\n [],\n );\n const [promptOpen, setPromptOpen] = useState<boolean>(false);\n\n const [remainingTimeCountdown, setRemainingTimeCountdown] =\n useState<number>(0);\n\n useLogoutDisconnectedUserEffect({\n enableEffect: logoutIfDisconnected,\n autologoutIsEnabled: enabled && isLogged,\n idleTimeoutSeconds: idleTimeoutMinutes * 60,\n lastSeenOnlineStore,\n identityApi,\n });\n\n if (!enabled || !isLogged) {\n return null;\n }\n\n return (\n <ConditionalAutoLogout\n idleTimeoutMinutes={idleTimeoutMinutes}\n promptBeforeIdleSeconds={promptBeforeIdleSeconds}\n useWorkerTimers={useWorkerTimers}\n events={defaultTrackedEvents}\n logoutIfDisconnected={logoutIfDisconnected}\n promptOpen={promptOpen}\n setPromptOpen={setPromptOpen}\n remainingTimeCountdown={remainingTimeCountdown}\n setRemainingTimeCountdown={setRemainingTimeCountdown}\n identityApi={identityApi}\n lastSeenOnlineStore={lastSeenOnlineStore}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAsFA,MAAM,wBAAwB,CAAC;AAAA,EAC7B,kBAAA;AAAA,EACA,MAAA;AAAA,EACA,eAAA;AAAA,EACA,oBAAA;AAAA,EACA,uBAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAA;AAAA,EACA,sBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAA,KAA4C;AAC1C,EAAA,MAAM,yBAAyB,uBAAA,GAA0B,GAAA;AACzD,EAAA,MAAM,gBAAA,GAAmB,sBAAA,GAAyB,CAAA,GAAI,IAAA,GAAO,KAAA;AAE7D,EAAA,MAAM,WAAW,YAAY;AAK3B,IAAA,aAAA,CAAc,IAAI,CAAA;AAClB,IAAA,yBAAA,CAA0B,sBAAsB,CAAA;AAAA,EAClD,CAAA;AAEA,EAAA,MAAM,SAAS,MAAM;AAGnB,IAAA,aAAA,CAAc,KAAK,CAAA;AACnB,IAAA,yBAAA,CAA0B,CAAC,CAAA;AAC3B,IAAA,WAAA,CAAY,OAAA,EAAQ;AAAA,EACtB,CAAA;AAEA,EAAA,MAAM,WAAW,MAAM;AAIrB,IAAA,aAAA,CAAc,KAAK,CAAA;AACnB,IAAA,yBAAA,CAA0B,CAAC,CAAA;AAAA,EAC7B,CAAA;AAEA,EAAA,MAAM,QAAA,GAAW,CACf,MAAA,EACA,UAAA,KACG;AAGH,IAAA,mBAAA,CAAoB,IAAA,iBAAK,IAAI,IAAA,EAAM,CAAA;AAAA,EACrC,CAAA;AAEA,EA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BAAA;AAAA,MACA,UAAA;AAAA,MACA,aAAA;AAAA,MACA,sBAAA;AAAA,MACA,yBAAA;AAAA,MACA,WAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"AutoLogout.esm.js","sources":["../../../src/components/AutoLogout/AutoLogout.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 ConfigApi,\n configApiRef,\n IdentityApi,\n identityApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { useEffect, useMemo, useState } from 'react';\nimport {\n EventsType,\n IIdleTimer,\n workerTimers,\n useIdleTimer,\n} from 'react-idle-timer';\n\nimport {\n LAST_SEEN_ONLINE_STORAGE_KEY,\n useLogoutDisconnectedUserEffect,\n} from './disconnectedUsers';\nimport { StillTherePrompt } from './StillTherePrompt';\nimport { DefaultTimestampStore, TimestampStore } from './timestampStore';\n\ntype AutoLogoutTrackableEvent = EventsType;\n\n/** @public */\nexport type AutoLogoutProps = {\n /**\n * Enable/disable the AutoLogoutMechanism.\n * defaults to true.\n */\n enabled?: boolean;\n /**\n * The amount of time (in minutes) of inactivity\n * after which the user is automatically logged out.\n * defaults to 60 minutes.\n */\n idleTimeoutMinutes?: number;\n /**\n * The number of seconds before the idleTimeout expires,\n * at which the user will be alerted by a Dialog that\n * they are about to be logged out.\n * defaults to 10 seconds\n */\n promptBeforeIdleSeconds?: number;\n /**\n * Enable/disable the usage of Node's worker thread timers instead of main thread timers.\n * This is helpful if you notice that the your browser is killing inactive tab's timers, like the one used by AutoLogout.\n * If you experience some browser incompatibility, you may try to set this to false.\n * defaults to true.\n */\n useWorkerTimers?: boolean;\n /**\n * Enable/disable the autologout for disconnected users.\n * disconnected users are the ones that are logged in but have no Backstage tab open in their browsers.\n * If enabled, disconnected users will be automatically logged out after `idleTimeoutMinutes`\n * defaults to true\n */\n logoutIfDisconnected?: boolean;\n};\n\ntype AutoLogoutInternalProps = Omit<Required<AutoLogoutProps>, 'enabled'> & {\n events: AutoLogoutTrackableEvent[];\n promptOpen: boolean;\n setPromptOpen: (value: boolean) => void;\n remainingTimeCountdown: number;\n setRemainingTimeCountdown: (amount: number) => void;\n identityApi: IdentityApi;\n lastSeenOnlineStore: TimestampStore;\n};\n\nconst ConditionalAutoLogout = ({\n idleTimeoutMinutes,\n events,\n useWorkerTimers,\n logoutIfDisconnected,\n promptBeforeIdleSeconds,\n promptOpen,\n setPromptOpen,\n remainingTimeCountdown,\n setRemainingTimeCountdown,\n identityApi,\n lastSeenOnlineStore,\n}: AutoLogoutInternalProps): JSX.Element => {\n const promptBeforeIdleMillis = promptBeforeIdleSeconds * 1000;\n const promptBeforeIdle = promptBeforeIdleMillis > 0 ? true : false;\n\n const onPrompt = async () => {\n // onPrompt will be called `promptBeforeIdle` milliseconds before `timeout`.\n // All events are disabled while the prompt is active.\n // If the user wishes to stay active, call the `activate()` method.\n // You can get the remaining prompt time with the `getRemainingTime()` method,\n setPromptOpen(true);\n setRemainingTimeCountdown(promptBeforeIdleMillis);\n };\n\n const onIdle = () => {\n // onIdle will be called after the timeout is reached.\n // Events will be rebound as long as `stopOnMount` is not set.\n setPromptOpen(false);\n setRemainingTimeCountdown(0);\n lastSeenOnlineStore.delete();\n identityApi.signOut();\n };\n\n const onActive = () => {\n // onActive will only be called if `activate()` is called while `isPrompted()`\n // is true. Here you will also want to close your modal and perform\n // any active actions.\n setPromptOpen(false);\n setRemainingTimeCountdown(0);\n };\n\n const onAction = (\n _event?: Event | undefined,\n _idleTimer?: IIdleTimer | null,\n ) => {\n // onAction will be called if any user event is detected. The list of events that triggers a user event detection is the list of configured events\n // If any user event is detected we update the Last seen online in storage\n lastSeenOnlineStore.save(new Date());\n };\n\n const timer = useIdleTimer({\n timeout: idleTimeoutMinutes * 60 * 1000,\n events: events,\n crossTab: true,\n name: 'autologout-timer',\n timers: useWorkerTimers ? workerTimers : undefined,\n onIdle: onIdle,\n onActive: promptBeforeIdle ? onActive : undefined,\n onAction: logoutIfDisconnected ? onAction : undefined,\n onPrompt: promptBeforeIdle ? onPrompt : undefined,\n promptBeforeIdle: promptBeforeIdle ? promptBeforeIdleMillis : undefined,\n syncTimers: 1000,\n });\n\n return (\n <>\n {promptBeforeIdle && (\n <StillTherePrompt\n idleTimer={timer}\n open={promptOpen}\n setOpen={setPromptOpen}\n remainingTime={remainingTimeCountdown}\n setRemainingTime={setRemainingTimeCountdown}\n promptTimeoutMillis={promptBeforeIdleMillis}\n />\n )}\n </>\n );\n};\n\nconst defaultConfig: Required<AutoLogoutProps> = {\n enabled: true,\n idleTimeoutMinutes: 0.5,\n promptBeforeIdleSeconds: 10,\n useWorkerTimers: true,\n logoutIfDisconnected: true,\n};\n\n/**\n * A list of DOM events that the activity tracker will use to determine if the user is active or not.\n */\nconst defaultTrackedEvents: AutoLogoutTrackableEvent[] = [\n 'mousemove',\n 'keydown',\n 'wheel',\n 'DOMMouseScroll',\n 'mousewheel',\n 'mousedown',\n 'touchstart',\n 'touchmove',\n 'MSPointerDown',\n 'MSPointerMove',\n 'visibilitychange',\n];\n\n/**\n * Parses configuration for the AutoLogout. Properties configured in `app-config` take precedence over the props passed to the React component.\n * If neither props nor config properties are found, a default value will be set accordingly.\n */\nconst parseConfig = (\n configApi: ConfigApi,\n props: AutoLogoutProps,\n): Required<AutoLogoutProps> => {\n return {\n enabled:\n configApi.getOptionalBoolean('auth.autologout.enabled') ??\n props.enabled ??\n defaultConfig.enabled,\n idleTimeoutMinutes:\n configApi.getOptionalNumber('auth.autologout.idleTimeoutMinutes') ??\n props.idleTimeoutMinutes ??\n defaultConfig.idleTimeoutMinutes,\n promptBeforeIdleSeconds:\n configApi.getOptionalNumber('auth.autologout.promptBeforeIdleSeconds') ??\n props.promptBeforeIdleSeconds ??\n defaultConfig.promptBeforeIdleSeconds,\n useWorkerTimers:\n configApi.getOptionalBoolean('auth.autologout.useWorkerTimers') ??\n props.useWorkerTimers ??\n defaultConfig.useWorkerTimers,\n logoutIfDisconnected:\n configApi.getOptionalBoolean('auth.autologout.logoutIfDisconnected') ??\n props.logoutIfDisconnected ??\n defaultConfig.logoutIfDisconnected,\n };\n};\n\n/**\n * The Autologout feature enables platform engineers to add a mechanism to log out users after a configurable amount of time of inactivity.\n * When enabled, the mechanism will track user actions (mouse movement, mouse click, key pressing, taps, etc.) in order to determine if they are active or not.\n * After a certain amount of inactivity/idle time, the user session is invalidated and they are required to sign in again.\n *\n * @public\n */\nexport const AutoLogout = (props: AutoLogoutProps): JSX.Element | null => {\n const identityApi = useApi(identityApiRef);\n const configApi = useApi(configApiRef);\n const [isLogged, setIsLogged] = useState<boolean | null>(null);\n const lastSeenOnlineStore: TimestampStore = useMemo(\n () => new DefaultTimestampStore(LAST_SEEN_ONLINE_STORAGE_KEY),\n [],\n );\n\n useEffect(() => {\n let cancelled = false;\n\n async function checkLogin(identity: IdentityApi) {\n try {\n const creds = await identity.getCredentials();\n if (cancelled) return;\n if (creds?.token) {\n setIsLogged(true);\n } else {\n setIsLogged(false);\n lastSeenOnlineStore.delete();\n }\n } catch (err) {\n if (cancelled) return;\n setIsLogged(false);\n lastSeenOnlineStore.delete();\n }\n }\n checkLogin(identityApi);\n\n return () => {\n cancelled = true;\n };\n }, [lastSeenOnlineStore, identityApi]);\n\n const {\n enabled,\n idleTimeoutMinutes,\n promptBeforeIdleSeconds,\n logoutIfDisconnected,\n useWorkerTimers,\n }: AutoLogoutProps = useMemo(() => {\n return parseConfig(configApi, props);\n }, [configApi, props]);\n\n useEffect(() => {\n if (idleTimeoutMinutes < 0.5) {\n throw new Error(\n '❌ idleTimeoutMinutes property should be >= 0.5 minutes (30 seconds).',\n );\n }\n\n if (promptBeforeIdleSeconds < 0) {\n throw new Error(\n '❌ promptBeforeIdleSeconds property should be >= 0 seconds. Set to 0 to disable the prompt.',\n );\n }\n\n if (idleTimeoutMinutes * 60 <= promptBeforeIdleSeconds) {\n throw new Error(\n `❌ promptBeforeIdleSeconds should be smaller than idleTimeoutMinutes`,\n );\n }\n }, [idleTimeoutMinutes, promptBeforeIdleSeconds]);\n\n const [promptOpen, setPromptOpen] = useState<boolean>(false);\n\n const [remainingTimeCountdown, setRemainingTimeCountdown] =\n useState<number>(0);\n\n useLogoutDisconnectedUserEffect({\n enableEffect: logoutIfDisconnected,\n autologoutIsEnabled: enabled,\n isLoggedIn: isLogged,\n idleTimeoutSeconds: idleTimeoutMinutes * 60,\n lastSeenOnlineStore,\n identityApi,\n });\n\n if (!enabled || !isLogged) {\n return null;\n }\n\n return (\n <ConditionalAutoLogout\n idleTimeoutMinutes={idleTimeoutMinutes}\n promptBeforeIdleSeconds={promptBeforeIdleSeconds}\n useWorkerTimers={useWorkerTimers}\n events={defaultTrackedEvents}\n logoutIfDisconnected={logoutIfDisconnected}\n promptOpen={promptOpen}\n setPromptOpen={setPromptOpen}\n remainingTimeCountdown={remainingTimeCountdown}\n setRemainingTimeCountdown={setRemainingTimeCountdown}\n identityApi={identityApi}\n lastSeenOnlineStore={lastSeenOnlineStore}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAsFA,MAAM,wBAAwB,CAAC;AAAA,EAC7B,kBAAA;AAAA,EACA,MAAA;AAAA,EACA,eAAA;AAAA,EACA,oBAAA;AAAA,EACA,uBAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAA;AAAA,EACA,sBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAA,KAA4C;AAC1C,EAAA,MAAM,yBAAyB,uBAAA,GAA0B,GAAA;AACzD,EAAA,MAAM,gBAAA,GAAmB,sBAAA,GAAyB,CAA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lastSeenOnline";
|
|
|
4
4
|
const useLogoutDisconnectedUserEffect = ({
|
|
5
5
|
enableEffect,
|
|
6
6
|
autologoutIsEnabled,
|
|
7
|
+
isLoggedIn,
|
|
7
8
|
idleTimeoutSeconds,
|
|
8
9
|
lastSeenOnlineStore,
|
|
9
10
|
identityApi
|
|
10
11
|
}) => {
|
|
11
12
|
useEffect(() => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const lastSeenOnlineSeconds = Math.ceil(
|
|
18
|
-
lastSeenOnline.getTime() / 1e3
|
|
19
|
-
);
|
|
20
|
-
if (nowSeconds - lastSeenOnlineSeconds > idleTimeoutSeconds) {
|
|
21
|
-
identityApi.signOut();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
lastSeenOnlineStore.save(/* @__PURE__ */ new Date());
|
|
25
|
-
} else {
|
|
13
|
+
const shouldCheckDisconnectedUser = autologoutIsEnabled && enableEffect;
|
|
14
|
+
if (isLoggedIn === null) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (!shouldCheckDisconnectedUser || !isLoggedIn) {
|
|
26
18
|
lastSeenOnlineStore.delete();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const lastSeenOnline = lastSeenOnlineStore.get();
|
|
22
|
+
if (lastSeenOnline) {
|
|
23
|
+
const now = /* @__PURE__ */ new Date();
|
|
24
|
+
const nowSeconds = Math.ceil(now.getTime() / 1e3);
|
|
25
|
+
const lastSeenOnlineSeconds = Math.ceil(lastSeenOnline.getTime() / 1e3);
|
|
26
|
+
if (nowSeconds - lastSeenOnlineSeconds > idleTimeoutSeconds) {
|
|
27
|
+
lastSeenOnlineStore.delete();
|
|
28
|
+
identityApi.signOut();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
27
31
|
}
|
|
32
|
+
lastSeenOnlineStore.save(/* @__PURE__ */ new Date());
|
|
28
33
|
}, [
|
|
29
34
|
autologoutIsEnabled,
|
|
30
35
|
enableEffect,
|
|
36
|
+
isLoggedIn,
|
|
31
37
|
identityApi,
|
|
32
38
|
idleTimeoutSeconds,
|
|
33
39
|
lastSeenOnlineStore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disconnectedUsers.esm.js","sources":["../../../src/components/AutoLogout/disconnectedUsers.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { IdentityApi } from '@backstage/core-plugin-api';\nimport { useEffect } from 'react';\n\nimport { TimestampStore } from './timestampStore';\n\nexport const LAST_SEEN_ONLINE_STORAGE_KEY =\n '@backstage/autologout:lastSeenOnline';\n\nexport type UseLogoutDisconnectedUserEffectProps = {\n enableEffect: boolean;\n autologoutIsEnabled: boolean;\n idleTimeoutSeconds: number;\n lastSeenOnlineStore: TimestampStore;\n identityApi: IdentityApi;\n};\n\nexport const useLogoutDisconnectedUserEffect = ({\n enableEffect,\n autologoutIsEnabled,\n idleTimeoutSeconds,\n lastSeenOnlineStore,\n identityApi,\n}: UseLogoutDisconnectedUserEffectProps) => {\n useEffect(() => {\n /**\n * Considers disconnected users as inactive users.\n * If all Backstage tabs are closed and idleTimeoutMinutes are passed then logout the user anyway.\n */\n
|
|
1
|
+
{"version":3,"file":"disconnectedUsers.esm.js","sources":["../../../src/components/AutoLogout/disconnectedUsers.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { IdentityApi } from '@backstage/core-plugin-api';\nimport { useEffect } from 'react';\n\nimport { TimestampStore } from './timestampStore';\n\nexport const LAST_SEEN_ONLINE_STORAGE_KEY =\n '@backstage/autologout:lastSeenOnline';\n\nexport type UseLogoutDisconnectedUserEffectProps = {\n enableEffect: boolean;\n autologoutIsEnabled: boolean;\n isLoggedIn: boolean | null;\n idleTimeoutSeconds: number;\n lastSeenOnlineStore: TimestampStore;\n identityApi: IdentityApi;\n};\n\nexport const useLogoutDisconnectedUserEffect = ({\n enableEffect,\n autologoutIsEnabled,\n isLoggedIn,\n idleTimeoutSeconds,\n lastSeenOnlineStore,\n identityApi,\n}: UseLogoutDisconnectedUserEffectProps) => {\n useEffect(() => {\n /**\n * Considers disconnected users as inactive users.\n * If all Backstage tabs are closed and idleTimeoutMinutes are passed then logout the user anyway.\n */\n const shouldCheckDisconnectedUser = autologoutIsEnabled && enableEffect;\n\n // Prevent lastSeen getting deleted before logged state is checked\n if (isLoggedIn === null) {\n return;\n }\n\n if (!shouldCheckDisconnectedUser || !isLoggedIn) {\n lastSeenOnlineStore.delete();\n return;\n }\n\n const lastSeenOnline = lastSeenOnlineStore.get();\n if (lastSeenOnline) {\n const now = new Date();\n const nowSeconds = Math.ceil(now.getTime() / 1000);\n const lastSeenOnlineSeconds = Math.ceil(lastSeenOnline.getTime() / 1000);\n if (nowSeconds - lastSeenOnlineSeconds > idleTimeoutSeconds) {\n lastSeenOnlineStore.delete();\n identityApi.signOut();\n return;\n }\n }\n lastSeenOnlineStore.save(new Date());\n }, [\n autologoutIsEnabled,\n enableEffect,\n isLoggedIn,\n identityApi,\n idleTimeoutSeconds,\n lastSeenOnlineStore,\n ]);\n};\n"],"names":[],"mappings":";;AAoBO,MAAM,4BAAA,GACX;AAWK,MAAM,kCAAkC,CAAC;AAAA,EAC9C,YAAA;AAAA,EACA,mBAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA,EACA;AACF,CAAA,KAA4C;AAC1C,EAAA,SAAA,CAAU,MAAM;AAKd,IAAA,MAAM,8BAA8B,mBAAA,IAAuB,YAAA;AAG3D,IAAA,IAAI,eAAe,IAAA,EAAM;AACvB,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,CAAC,2BAAA,IAA+B,CAAC,UAAA,EAAY;AAC/C,MAAA,mBAAA,CAAoB,MAAA,EAAO;AAC3B,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,cAAA,GAAiB,oBAAoB,GAAA,EAAI;AAC/C,IAAA,IAAI,cAAA,EAAgB;AAClB,MAAA,MAAM,GAAA,uBAAU,IAAA,EAAK;AACrB,MAAA,MAAM,aAAa,IAAA,CAAK,IAAA,CAAK,GAAA,CAAI,OAAA,KAAY,GAAI,CAAA;AACjD,MAAA,MAAM,wBAAwB,IAAA,CAAK,IAAA,CAAK,cAAA,CAAe,OAAA,KAAY,GAAI,CAAA;AACvE,MAAA,IAAI,UAAA,GAAa,wBAAwB,kBAAA,EAAoB;AAC3D,QAAA,mBAAA,CAAoB,MAAA,EAAO;AAC3B,QAAA,WAAA,CAAY,OAAA,EAAQ;AACpB,QAAA;AAAA,MACF;AAAA,IACF;AACA,IAAA,mBAAA,CAAoB,IAAA,iBAAK,IAAI,IAAA,EAAM,CAAA;AAAA,EACrC,CAAA,EAAG;AAAA,IACD,mBAAA;AAAA,IACA,YAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA,kBAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -27,6 +27,13 @@ const useFilterStyles = makeStyles(
|
|
|
27
27
|
justifyContent: "space-between",
|
|
28
28
|
borderBottom: `1px solid ${theme.palette.grey[500]}`
|
|
29
29
|
},
|
|
30
|
+
// Intentionally empty: the deprecated `heder` class is still applied to
|
|
31
|
+
// the same element as `header` so legacy theme overrides on
|
|
32
|
+
// `BackstageTableFilters.heder` continue to work. Keeping this rule empty
|
|
33
|
+
// (rather than duplicating `header`'s styles) avoids clobbering overrides
|
|
34
|
+
// on the canonical `header` key — JSS injects rules in key order, so an
|
|
35
|
+
// empty `heder` defined after `header` has no properties to override.
|
|
36
|
+
heder: {},
|
|
30
37
|
filters: {
|
|
31
38
|
display: "flex",
|
|
32
39
|
flexDirection: "column",
|
|
@@ -53,7 +60,7 @@ const Filters = (props) => {
|
|
|
53
60
|
onChangeFilters(selectedFilters);
|
|
54
61
|
}, [selectedFilters, onChangeFilters]);
|
|
55
62
|
return /* @__PURE__ */ jsxs(Box, { className: classes.root, children: [
|
|
56
|
-
/* @__PURE__ */ jsxs(Box, { className: classes.header
|
|
63
|
+
/* @__PURE__ */ jsxs(Box, { className: `${classes.header} ${classes.heder}`, children: [
|
|
57
64
|
/* @__PURE__ */ jsx(Box, { className: classes.value, children: t("table.filter.title") }),
|
|
58
65
|
/* @__PURE__ */ jsx(Button, { color: "primary", onClick: handleClick, children: t("table.filter.clearAll") })
|
|
59
66
|
] }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Filters.esm.js","sources":["../../../src/components/Table/Filters.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 Box from '@material-ui/core/Box';\nimport Button from '@material-ui/core/Button';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { useEffect, useState } from 'react';\n\nimport { Select } from '../Select';\nimport { SelectProps } from '../Select/Select';\nimport { coreComponentsTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\nexport type TableFiltersClassKey
|
|
1
|
+
{"version":3,"file":"Filters.esm.js","sources":["../../../src/components/Table/Filters.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 Box from '@material-ui/core/Box';\nimport Button from '@material-ui/core/Button';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { useEffect, useState } from 'react';\n\nimport { Select } from '../Select';\nimport { SelectProps } from '../Select/Select';\nimport { coreComponentsTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\nexport type TableFiltersClassKey =\n | 'root'\n | 'value'\n | 'header'\n /**\n * @deprecated Use `'header'` instead. This was a typo in the original class key.\n */\n | 'heder'\n | 'filters';\n\nconst useFilterStyles = makeStyles(\n theme => ({\n root: {\n height: '100%',\n width: '315px',\n display: 'flex',\n flexDirection: 'column',\n marginRight: theme.spacing(3),\n },\n value: {\n fontWeight: 'bold',\n fontSize: 18,\n },\n header: {\n display: 'flex',\n alignItems: 'center',\n height: theme.spacing(7.5),\n justifyContent: 'space-between',\n borderBottom: `1px solid ${theme.palette.grey[500]}`,\n },\n // Intentionally empty: the deprecated `heder` class is still applied to\n // the same element as `header` so legacy theme overrides on\n // `BackstageTableFilters.heder` continue to work. Keeping this rule empty\n // (rather than duplicating `header`'s styles) avoids clobbering overrides\n // on the canonical `header` key — JSS injects rules in key order, so an\n // empty `heder` defined after `header` has no properties to override.\n heder: {},\n filters: {\n display: 'flex',\n flexDirection: 'column',\n '& > *': {\n marginTop: theme.spacing(2),\n },\n },\n }),\n { name: 'BackstageTableFilters' },\n);\n\nexport type Without<T, K> = Pick<T, Exclude<keyof T, K>>;\n\nexport type Filter = {\n type: 'select' | 'multiple-select';\n element: Without<SelectProps, 'onChange'>;\n};\n\nexport type SelectedFilters = {\n [key: string]: string | string[];\n};\n\ntype Props = {\n filters: Filter[];\n selectedFilters?: SelectedFilters;\n onChangeFilters: (arg: any) => any;\n};\n\nexport const Filters = (props: Props) => {\n const classes = useFilterStyles();\n\n const { onChangeFilters } = props;\n const { t } = useTranslationRef(coreComponentsTranslationRef);\n\n const [selectedFilters, setSelectedFilters] = useState<SelectedFilters>({\n ...props.selectedFilters,\n });\n const [reset, triggerReset] = useState(false);\n\n // Trigger re-rendering\n const handleClick = () => {\n setSelectedFilters({});\n triggerReset(el => !el);\n };\n\n useEffect(() => {\n onChangeFilters(selectedFilters);\n }, [selectedFilters, onChangeFilters]);\n\n // As material table doesn't provide a way to add a column filter tab we will make our own filter logic\n return (\n <Box className={classes.root}>\n <Box className={`${classes.header} ${classes.heder}`}>\n <Box className={classes.value}>{t('table.filter.title')}</Box>\n <Button color=\"primary\" onClick={handleClick}>\n {t('table.filter.clearAll')}\n </Button>\n </Box>\n <Box className={classes.filters}>\n {props.filters?.length &&\n props.filters.map(filter => (\n <Select\n triggerReset={reset}\n key={filter.element.label}\n {...(filter.element as SelectProps)}\n selected={selectedFilters[filter.element.label]}\n onChange={el =>\n setSelectedFilters({\n ...selectedFilters,\n [filter.element.label]: el as any,\n })\n }\n />\n ))}\n </Box>\n </Box>\n );\n};\n"],"names":["Select"],"mappings":";;;;;;;;;AAoCA,MAAM,eAAA,GAAkB,UAAA;AAAA,EACtB,CAAA,KAAA,MAAU;AAAA,IACR,IAAA,EAAM;AAAA,MACJ,MAAA,EAAQ,MAAA;AAAA,MACR,KAAA,EAAO,OAAA;AAAA,MACP,OAAA,EAAS,MAAA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AAAA,KAUvB,CAAA,EACL;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1312,7 +1312,11 @@ declare function RoutedTabs(props: {
|
|
|
1312
1312
|
routes: SubRoute[];
|
|
1313
1313
|
}): react_jsx_runtime.JSX.Element;
|
|
1314
1314
|
|
|
1315
|
-
type TableFiltersClassKey = 'root' | 'value' | '
|
|
1315
|
+
type TableFiltersClassKey = 'root' | 'value' | 'header'
|
|
1316
|
+
/**
|
|
1317
|
+
* @deprecated Use `'header'` instead. This was a typo in the original class key.
|
|
1318
|
+
*/
|
|
1319
|
+
| 'heder' | 'filters';
|
|
1316
1320
|
type SelectedFilters = {
|
|
1317
1321
|
[key: string]: string | string[];
|
|
1318
1322
|
};
|
|
@@ -9,13 +9,18 @@ const DEFAULTS = {
|
|
|
9
9
|
// shall start trying to get a new one
|
|
10
10
|
tokenExpiryMarginMillis: 5 * 60 * 1e3
|
|
11
11
|
};
|
|
12
|
+
function decodeBase64Url(value) {
|
|
13
|
+
const base64 = value.replace(/-/g, "+").replace(/_/g, "/");
|
|
14
|
+
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
15
|
+
return window.atob(padded);
|
|
16
|
+
}
|
|
12
17
|
function tokenToExpiry(jwtToken) {
|
|
13
18
|
const fallback = new Date(Date.now() + DEFAULTS.defaultTokenExpiryMillis);
|
|
14
19
|
if (!jwtToken) {
|
|
15
20
|
return fallback;
|
|
16
21
|
}
|
|
17
22
|
const [_header, rawPayload, _signature] = jwtToken.split(".");
|
|
18
|
-
const payload = JSON.parse(
|
|
23
|
+
const payload = JSON.parse(decodeBase64Url(rawPayload));
|
|
19
24
|
if (typeof payload.exp !== "number") {
|
|
20
25
|
return fallback;
|
|
21
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProxiedSignInIdentity.esm.js","sources":["../../../src/layout/ProxiedSignInPage/ProxiedSignInIdentity.ts"],"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 BackstageUserIdentity,\n discoveryApiRef,\n IdentityApi,\n ProfileInfo,\n} from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport { ProxiedSession, proxiedSessionSchema } from './types';\n\nexport const DEFAULTS = {\n // The amount of time between token refreshes, if we fail to get an actual\n // value out of the exp claim\n defaultTokenExpiryMillis: 5 * 60 * 1000,\n // The amount of time before the actual expiry of the Backstage token, that we\n // shall start trying to get a new one\n tokenExpiryMarginMillis: 5 * 60 * 1000,\n} as const;\n\n// When the token expires, with some margin\nexport function tokenToExpiry(jwtToken: string | undefined): Date {\n const fallback = new Date(Date.now() + DEFAULTS.defaultTokenExpiryMillis);\n if (!jwtToken) {\n return fallback;\n }\n\n const [_header, rawPayload, _signature] = jwtToken.split('.');\n const payload = JSON.parse(window.atob(rawPayload));\n if (typeof payload.exp !== 'number') {\n return fallback;\n }\n\n return new Date(payload.exp * 1000 - DEFAULTS.tokenExpiryMarginMillis);\n}\n\ntype ProxiedSignInIdentityOptions = {\n provider: string;\n discoveryApi: typeof discoveryApiRef.T;\n headers?: HeadersInit | (() => HeadersInit) | (() => Promise<HeadersInit>);\n};\n\ntype State =\n | {\n type: 'empty';\n }\n | {\n type: 'fetching';\n promise: Promise<ProxiedSession>;\n previous: ProxiedSession | undefined;\n }\n | {\n type: 'active';\n session: ProxiedSession;\n expiresAt: Date;\n }\n | {\n type: 'failed';\n error: Error;\n };\n\n/**\n * An identity API that gets the user auth information solely based on a\n * provider's `/refresh` endpoint.\n */\nexport class ProxiedSignInIdentity implements IdentityApi {\n private readonly options: ProxiedSignInIdentityOptions;\n private readonly abortController: AbortController;\n private state: State;\n\n constructor(options: ProxiedSignInIdentityOptions) {\n this.options = options;\n this.abortController = new AbortController();\n this.state = { type: 'empty' };\n }\n\n async start() {\n // Try to make a first fetch, bubble up any errors to the caller\n await this.getSessionAsync();\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getUserId} */\n getUserId(): string {\n const { backstageIdentity } = this.getSessionSync();\n const ref = backstageIdentity.identity.userEntityRef;\n const match = /^([^:/]+:)?([^:/]+\\/)?([^:/]+)$/.exec(ref);\n if (!match) {\n throw new TypeError(`Invalid user entity reference \"${ref}\"`);\n }\n\n return match[3];\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getIdToken} */\n async getIdToken(): Promise<string | undefined> {\n const session = await this.getSessionAsync();\n return session.backstageIdentity.token;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getProfile} */\n getProfile(): ProfileInfo {\n const session = this.getSessionSync();\n return session.profile;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getProfileInfo} */\n async getProfileInfo(): Promise<ProfileInfo> {\n const session = await this.getSessionAsync();\n return session.profile;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getBackstageIdentity} */\n async getBackstageIdentity(): Promise<BackstageUserIdentity> {\n const session = await this.getSessionAsync();\n return session.backstageIdentity.identity;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getCredentials} */\n async getCredentials(): Promise<{ token?: string | undefined }> {\n const session = await this.getSessionAsync();\n return {\n token: session.backstageIdentity.token,\n };\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.signOut} */\n async signOut(): Promise<void> {\n this.abortController.abort();\n }\n\n getSessionSync(): ProxiedSession {\n if (this.state.type === 'active') {\n return this.state.session;\n } else if (this.state.type === 'fetching' && this.state.previous) {\n return this.state.previous;\n }\n throw new Error('No session available. Try reloading your browser page.');\n }\n\n async getSessionAsync(): Promise<ProxiedSession> {\n if (this.state.type === 'fetching') {\n return this.state.promise;\n } else if (\n this.state.type === 'active' &&\n new Date() < this.state.expiresAt\n ) {\n return this.state.session;\n }\n\n const previous =\n this.state.type === 'active' ? this.state.session : undefined;\n\n const promise = this.fetchSession().then(\n session => {\n this.state = {\n type: 'active',\n session,\n expiresAt: tokenToExpiry(session.backstageIdentity.token),\n };\n return session;\n },\n error => {\n this.state = {\n type: 'failed',\n error,\n };\n throw error;\n },\n );\n\n this.state = {\n type: 'fetching',\n promise,\n previous,\n };\n\n return promise;\n }\n\n async fetchSession(): Promise<ProxiedSession> {\n const baseUrl = await this.options.discoveryApi.getBaseUrl('auth');\n\n const headers =\n typeof this.options.headers === 'function'\n ? await this.options.headers()\n : this.options.headers;\n const mergedHeaders = new Headers(headers);\n mergedHeaders.set('X-Requested-With', 'XMLHttpRequest');\n\n // Note that we do not use the fetchApi here, since this all happens before\n // sign-in completes so there can be no automatic token injection and\n // similar.\n const response = await fetch(\n `${baseUrl}/${this.options.provider}/refresh`,\n {\n signal: this.abortController.signal,\n headers: mergedHeaders,\n credentials: 'include',\n },\n );\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return proxiedSessionSchema.parse(await response.json());\n }\n}\n"],"names":[],"mappings":";;;AAyBO,MAAM,QAAA,GAAW;AAAA;AAAA;AAAA,EAGtB,wBAAA,EAA0B,IAAI,EAAA,GAAK,GAAA;AAAA;AAAA;AAAA,EAGnC,uBAAA,EAAyB,IAAI,EAAA,GAAK;AACpC;AAGO,SAAS,cAAc,QAAA,EAAoC;AAChE,EAAA,MAAM,WAAW,IAAI,IAAA,CAAK,KAAK,GAAA,EAAI,GAAI,SAAS,wBAAwB,CAAA;AACxE,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,OAAO,QAAA;AAAA,EACT;AAEA,EAAA,MAAM,CAAC,OAAA,EAAS,UAAA,EAAY,UAAU,CAAA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O,CAAA;AACzC,IAAA,aAAA,CAAc,GAAA,CAAI,oBAAoB,gBAAgB,CAAA;AAKtD,IAAA,MAAM,WAAW,MAAM,KAAA;AAAA,MACrB,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,IAAA,CAAK,QAAQ,QAAQ,CAAA,QAAA,CAAA;AAAA,MACnC;AAAA,QACE,MAAA,EAAQ,KAAK,eAAA,CAAgB,MAAA;AAAA,QAC7B,OAAA,EAAS,aAAA;AAAA,QACT,WAAA,EAAa;AAAA;AACf,KACF;AAEA,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,MAAM,MAAM,aAAA,CAAc,YAAA,CAAa,QAAQ,CAAA;AAAA,IACjD;AAEA,IAAA,OAAO,oBAAA,CAAqB,KAAA,CAAM,MAAM,QAAA,CAAS,MAAM,CAAA;AAAA,EACzD;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"ProxiedSignInIdentity.esm.js","sources":["../../../src/layout/ProxiedSignInPage/ProxiedSignInIdentity.ts"],"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 BackstageUserIdentity,\n discoveryApiRef,\n IdentityApi,\n ProfileInfo,\n} from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport { ProxiedSession, proxiedSessionSchema } from './types';\n\nexport const DEFAULTS = {\n // The amount of time between token refreshes, if we fail to get an actual\n // value out of the exp claim\n defaultTokenExpiryMillis: 5 * 60 * 1000,\n // The amount of time before the actual expiry of the Backstage token, that we\n // shall start trying to get a new one\n tokenExpiryMarginMillis: 5 * 60 * 1000,\n} as const;\n\n// Decodes a base64url-encoded string. JWTs encode their segments using base64url\n// (RFC 7515), which substitutes '-' and '_' for '+' and '/' and omits padding.\n// `window.atob` only accepts standard base64, so translate back to that alphabet\n// and restore the padding before decoding.\nfunction decodeBase64Url(value: string): string {\n const base64 = value.replace(/-/g, '+').replace(/_/g, '/');\n const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, '=');\n return window.atob(padded);\n}\n\n// When the token expires, with some margin\nexport function tokenToExpiry(jwtToken: string | undefined): Date {\n const fallback = new Date(Date.now() + DEFAULTS.defaultTokenExpiryMillis);\n if (!jwtToken) {\n return fallback;\n }\n\n const [_header, rawPayload, _signature] = jwtToken.split('.');\n const payload = JSON.parse(decodeBase64Url(rawPayload));\n if (typeof payload.exp !== 'number') {\n return fallback;\n }\n\n return new Date(payload.exp * 1000 - DEFAULTS.tokenExpiryMarginMillis);\n}\n\ntype ProxiedSignInIdentityOptions = {\n provider: string;\n discoveryApi: typeof discoveryApiRef.T;\n headers?: HeadersInit | (() => HeadersInit) | (() => Promise<HeadersInit>);\n};\n\ntype State =\n | {\n type: 'empty';\n }\n | {\n type: 'fetching';\n promise: Promise<ProxiedSession>;\n previous: ProxiedSession | undefined;\n }\n | {\n type: 'active';\n session: ProxiedSession;\n expiresAt: Date;\n }\n | {\n type: 'failed';\n error: Error;\n };\n\n/**\n * An identity API that gets the user auth information solely based on a\n * provider's `/refresh` endpoint.\n */\nexport class ProxiedSignInIdentity implements IdentityApi {\n private readonly options: ProxiedSignInIdentityOptions;\n private readonly abortController: AbortController;\n private state: State;\n\n constructor(options: ProxiedSignInIdentityOptions) {\n this.options = options;\n this.abortController = new AbortController();\n this.state = { type: 'empty' };\n }\n\n async start() {\n // Try to make a first fetch, bubble up any errors to the caller\n await this.getSessionAsync();\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getUserId} */\n getUserId(): string {\n const { backstageIdentity } = this.getSessionSync();\n const ref = backstageIdentity.identity.userEntityRef;\n const match = /^([^:/]+:)?([^:/]+\\/)?([^:/]+)$/.exec(ref);\n if (!match) {\n throw new TypeError(`Invalid user entity reference \"${ref}\"`);\n }\n\n return match[3];\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getIdToken} */\n async getIdToken(): Promise<string | undefined> {\n const session = await this.getSessionAsync();\n return session.backstageIdentity.token;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getProfile} */\n getProfile(): ProfileInfo {\n const session = this.getSessionSync();\n return session.profile;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getProfileInfo} */\n async getProfileInfo(): Promise<ProfileInfo> {\n const session = await this.getSessionAsync();\n return session.profile;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getBackstageIdentity} */\n async getBackstageIdentity(): Promise<BackstageUserIdentity> {\n const session = await this.getSessionAsync();\n return session.backstageIdentity.identity;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getCredentials} */\n async getCredentials(): Promise<{ token?: string | undefined }> {\n const session = await this.getSessionAsync();\n return {\n token: session.backstageIdentity.token,\n };\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.signOut} */\n async signOut(): Promise<void> {\n this.abortController.abort();\n }\n\n getSessionSync(): ProxiedSession {\n if (this.state.type === 'active') {\n return this.state.session;\n } else if (this.state.type === 'fetching' && this.state.previous) {\n return this.state.previous;\n }\n throw new Error('No session available. Try reloading your browser page.');\n }\n\n async getSessionAsync(): Promise<ProxiedSession> {\n if (this.state.type === 'fetching') {\n return this.state.promise;\n } else if (\n this.state.type === 'active' &&\n new Date() < this.state.expiresAt\n ) {\n return this.state.session;\n }\n\n const previous =\n this.state.type === 'active' ? this.state.session : undefined;\n\n const promise = this.fetchSession().then(\n session => {\n this.state = {\n type: 'active',\n session,\n expiresAt: tokenToExpiry(session.backstageIdentity.token),\n };\n return session;\n },\n error => {\n this.state = {\n type: 'failed',\n error,\n };\n throw error;\n },\n );\n\n this.state = {\n type: 'fetching',\n promise,\n previous,\n };\n\n return promise;\n }\n\n async fetchSession(): Promise<ProxiedSession> {\n const baseUrl = await this.options.discoveryApi.getBaseUrl('auth');\n\n const headers =\n typeof this.options.headers === 'function'\n ? await this.options.headers()\n : this.options.headers;\n const mergedHeaders = new Headers(headers);\n mergedHeaders.set('X-Requested-With', 'XMLHttpRequest');\n\n // Note that we do not use the fetchApi here, since this all happens before\n // sign-in completes so there can be no automatic token injection and\n // similar.\n const response = await fetch(\n `${baseUrl}/${this.options.provider}/refresh`,\n {\n signal: this.abortController.signal,\n headers: mergedHeaders,\n credentials: 'include',\n },\n );\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return proxiedSessionSchema.parse(await response.json());\n }\n}\n"],"names":[],"mappings":";;;AAyBO,MAAM,QAAA,GAAW;AAAA;AAAA;AAAA,EAGtB,wBAAA,EAA0B,IAAI,EAAA,GAAK,GAAA;AAAA;AAAA;AAAA,EAGnC,uBAAA,EAAyB,IAAI,EAAA,GAAK;AACpC;AAMA,SAAS,gBAAgB,KAAA,EAAuB;AAC9C,EAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA,CAAE,OAAA,CAAQ,MAAM,GAAG,CAAA;AACzD,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,MAAA,CAAO,IAAA,CAAK,IAAA,CAAK,OAAO,MAAA,GAAS,CAAC,CAAA,GAAI,CAAA,EAAG,GAAG,CAAA;AAClE,EAAA,OAAO,MAAA,CAAO,KAAK,MAAM,CAAA;AAC3B;AAGO,SAAS,cAAc,QAAA,EAAoC;AAChE,EAAA,MAAM,WAAW,IAAI,IAAA,CAAK,KAAK,GAAA,EAAI,GAAI,SAAS,wBAAwB,CAAA;AACxE,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,OAAO,QAAA;AAAA,EACT;AAEA,EAAA,MAAM,CAAC,OAAA,EAAS,UAAA,EAAY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Q,OAAO,CAAA;AACzC,IAAA,aAAA,CAAc,GAAA,CAAI,oBAAoB,gBAAgB,CAAA;AAKtD,IAAA,MAAM,WAAW,MAAM,KAAA;AAAA,MACrB,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,IAAA,CAAK,QAAQ,QAAQ,CAAA,QAAA,CAAA;AAAA,MACnC;AAAA,QACE,MAAA,EAAQ,KAAK,eAAA,CAAgB,MAAA;AAAA,QAC7B,OAAA,EAAS,aAAA;AAAA,QACT,WAAA,EAAa;AAAA;AACf,KACF;AAEA,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,MAAM,MAAM,aAAA,CAAc,YAAA,CAAa,QAAQ,CAAA;AAAA,IACjD;AAEA,IAAA,OAAO,oBAAA,CAAqB,KAAA,CAAM,MAAM,QAAA,CAAS,MAAM,CAAA;AAAA,EACzD;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/core-components",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.11-next.1",
|
|
4
4
|
"description": "Core components used by Backstage plugins and apps",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library"
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
"test": "backstage-cli package test"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@backstage/config": "
|
|
70
|
-
"@backstage/core-plugin-api": "
|
|
71
|
-
"@backstage/errors": "
|
|
72
|
-
"@backstage/theme": "
|
|
73
|
-
"@backstage/version-bridge": "
|
|
69
|
+
"@backstage/config": "1.3.8",
|
|
70
|
+
"@backstage/core-plugin-api": "1.12.7-next.0",
|
|
71
|
+
"@backstage/errors": "1.3.1",
|
|
72
|
+
"@backstage/theme": "0.7.3",
|
|
73
|
+
"@backstage/version-bridge": "1.0.12",
|
|
74
74
|
"@dagrejs/dagre": "^1.1.4",
|
|
75
75
|
"@date-io/core": "^1.3.13",
|
|
76
76
|
"@material-table/core": "^3.1.0",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"linkifyjs": "4.3.2",
|
|
92
92
|
"lodash": "^4.17.21",
|
|
93
93
|
"parse5": "^6.0.0",
|
|
94
|
-
"qs": "^6.
|
|
94
|
+
"qs": "^6.15.2",
|
|
95
95
|
"rc-progress": "3.5.1",
|
|
96
96
|
"react-full-screen": "^1.1.1",
|
|
97
97
|
"react-helmet": "6.1.0",
|
|
@@ -110,10 +110,10 @@
|
|
|
110
110
|
"zod": "^3.25.76 || ^4.0.0"
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
|
-
"@backstage/app-defaults": "
|
|
114
|
-
"@backstage/cli": "
|
|
115
|
-
"@backstage/core-app-api": "
|
|
116
|
-
"@backstage/test-utils": "
|
|
113
|
+
"@backstage/app-defaults": "1.7.9-next.1",
|
|
114
|
+
"@backstage/cli": "0.36.3-next.1",
|
|
115
|
+
"@backstage/core-app-api": "1.20.2-next.0",
|
|
116
|
+
"@backstage/test-utils": "1.7.19-next.0",
|
|
117
117
|
"@testing-library/dom": "^10.0.0",
|
|
118
118
|
"@testing-library/jest-dom": "^6.0.0",
|
|
119
119
|
"@testing-library/user-event": "^14.0.0",
|