@keycloakify/keycloak-account-ui 25.0.1-rc.0
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/KeycloakAccountUi.d.ts +3 -0
- package/KeycloakAccountUi.js +29 -0
- package/KeycloakAccountUi.js.map +1 -0
- package/LICENSE +2 -0
- package/README.md +39 -0
- package/account-security/AccountRow.d.ts +8 -0
- package/account-security/AccountRow.js +36 -0
- package/account-security/AccountRow.js.map +1 -0
- package/account-security/DeviceActivity.d.ts +2 -0
- package/account-security/DeviceActivity.js +70 -0
- package/account-security/DeviceActivity.js.map +1 -0
- package/account-security/LinkedAccounts.d.ts +2 -0
- package/account-security/LinkedAccounts.js +25 -0
- package/account-security/LinkedAccounts.js.map +1 -0
- package/account-security/SigningIn.d.ts +2 -0
- package/account-security/SigningIn.js +65 -0
- package/account-security/SigningIn.js.map +1 -0
- package/api/constants.d.ts +2 -0
- package/api/constants.js +3 -0
- package/api/constants.js.map +1 -0
- package/api/methods.d.ts +25 -0
- package/api/methods.js +73 -0
- package/api/methods.js.map +1 -0
- package/api/parse-links.d.ts +5 -0
- package/api/parse-links.js +23 -0
- package/api/parse-links.js.map +1 -0
- package/api/parse-response.d.ts +3 -0
- package/api/parse-response.js +40 -0
- package/api/parse-response.js.map +1 -0
- package/api/representations.d.ts +202 -0
- package/api/representations.js +3 -0
- package/api/representations.js.map +1 -0
- package/api/request.d.ts +12 -0
- package/api/request.js +33 -0
- package/api/request.js.map +1 -0
- package/api.d.ts +13 -0
- package/api.js +52 -0
- package/api.js.map +1 -0
- package/applications/Applications.d.ts +2 -0
- package/applications/Applications.js +52 -0
- package/applications/Applications.js.map +1 -0
- package/components/datalist/EmptyRow.d.ts +5 -0
- package/components/datalist/EmptyRow.js +20 -0
- package/components/datalist/EmptyRow.js.map +1 -0
- package/components/page/Page.d.ts +7 -0
- package/components/page/Page.js +6 -0
- package/components/page/Page.js.map +1 -0
- package/content/ContentComponent.d.ts +2 -0
- package/content/ContentComponent.js +36 -0
- package/content/ContentComponent.js.map +1 -0
- package/content/fetchContent.d.ts +3 -0
- package/content/fetchContent.js +6 -0
- package/content/fetchContent.js.map +1 -0
- package/environment.d.ts +25 -0
- package/environment.js +3 -0
- package/environment.js.map +1 -0
- package/groups/Groups.d.ts +2 -0
- package/groups/Groups.js +45 -0
- package/groups/Groups.js.map +1 -0
- package/i18n.d.ts +4 -0
- package/i18n.js +31 -0
- package/i18n.js.map +1 -0
- package/oid4vci/Oid4Vci.d.ts +2 -0
- package/oid4vci/Oid4Vci.js +54 -0
- package/oid4vci/Oid4Vci.js.map +1 -0
- package/package.json +428 -0
- package/personal-info/PersonalInfo.d.ts +2 -0
- package/personal-info/PersonalInfo.js +63 -0
- package/personal-info/PersonalInfo.js.map +1 -0
- package/resources/EditTheResource.d.ts +8 -0
- package/resources/EditTheResource.js +36 -0
- package/resources/EditTheResource.js.map +1 -0
- package/resources/PermissionRequest.d.ts +7 -0
- package/resources/PermissionRequest.js +39 -0
- package/resources/PermissionRequest.js.map +1 -0
- package/resources/ResourceToolbar.d.ts +12 -0
- package/resources/ResourceToolbar.js +24 -0
- package/resources/ResourceToolbar.js.map +1 -0
- package/resources/Resources.d.ts +2 -0
- package/resources/Resources.js +13 -0
- package/resources/Resources.js.map +1 -0
- package/resources/ResourcesTab.d.ts +5 -0
- package/resources/ResourcesTab.js +103 -0
- package/resources/ResourcesTab.js.map +1 -0
- package/resources/ShareTheResource.d.ts +9 -0
- package/resources/ShareTheResource.js +70 -0
- package/resources/ShareTheResource.js.map +1 -0
- package/resources/SharedWith.d.ts +6 -0
- package/resources/SharedWith.js +8 -0
- package/resources/SharedWith.js.map +1 -0
- package/root/ErrorPage.d.ts +5 -0
- package/root/ErrorPage.js +29 -0
- package/root/ErrorPage.js.map +1 -0
- package/root/Header.d.ts +1 -0
- package/root/Header.js +31 -0
- package/root/Header.js.map +1 -0
- package/root/PageNav.d.ts +23 -0
- package/root/PageNav.js +44 -0
- package/root/PageNav.js.map +1 -0
- package/root/Root.d.ts +1 -0
- package/root/Root.js +12 -0
- package/root/Root.js.map +1 -0
- package/root/header.module.css +3 -0
- package/routes.d.ts +15 -0
- package/routes.js +69 -0
- package/routes.js.map +1 -0
- package/src/KeycloakAccountUi.tsx +36 -0
- package/src/account-security/AccountRow.tsx +136 -0
- package/src/account-security/DeviceActivity.tsx +253 -0
- package/src/account-security/LinkedAccounts.tsx +86 -0
- package/src/account-security/SigningIn.tsx +251 -0
- package/src/api/constants.ts +2 -0
- package/src/api/methods.ts +158 -0
- package/src/api/parse-links.ts +28 -0
- package/src/api/parse-response.ts +53 -0
- package/src/api/representations.ts +219 -0
- package/src/api/request.ts +74 -0
- package/src/api.ts +127 -0
- package/src/applications/Applications.tsx +282 -0
- package/src/components/datalist/EmptyRow.tsx +26 -0
- package/src/components/page/Page.tsx +27 -0
- package/src/content/ContentComponent.tsx +62 -0
- package/src/content/fetchContent.ts +13 -0
- package/src/environment.ts +31 -0
- package/src/global.d.ts +4 -0
- package/src/groups/Groups.tsx +142 -0
- package/src/i18n.ts +47 -0
- package/src/i18next.d.ts +10 -0
- package/src/oid4vci/Oid4Vci.tsx +136 -0
- package/src/personal-info/PersonalInfo.tsx +184 -0
- package/src/resources/EditTheResource.tsx +101 -0
- package/src/resources/PermissionRequest.tsx +129 -0
- package/src/resources/ResourceToolbar.tsx +87 -0
- package/src/resources/Resources.tsx +39 -0
- package/src/resources/ResourcesTab.tsx +410 -0
- package/src/resources/ShareTheResource.tsx +217 -0
- package/src/resources/SharedWith.tsx +26 -0
- package/src/root/ErrorPage.tsx +65 -0
- package/src/root/Header.tsx +62 -0
- package/src/root/PageNav.tsx +154 -0
- package/src/root/Root.tsx +20 -0
- package/src/root/header.module.css +3 -0
- package/src/routes.tsx +85 -0
- package/src/ui-shared/alerts/Alerts.tsx +86 -0
- package/src/ui-shared/buttons/FormSubmitButton.tsx +47 -0
- package/src/ui-shared/context/ErrorPage.tsx +60 -0
- package/src/ui-shared/context/HelpContext.tsx +30 -0
- package/src/ui-shared/context/KeycloakContext.tsx +97 -0
- package/src/ui-shared/context/environment.ts +50 -0
- package/src/ui-shared/continue-cancel/ContinueCancelModal.tsx +75 -0
- package/src/ui-shared/controls/FormErrorText.tsx +23 -0
- package/src/ui-shared/controls/FormLabel.tsx +40 -0
- package/src/ui-shared/controls/HelpItem.tsx +43 -0
- package/src/ui-shared/controls/NumberControl.tsx +89 -0
- package/src/ui-shared/controls/PasswordControl.tsx +71 -0
- package/src/ui-shared/controls/PasswordInput.tsx +50 -0
- package/src/ui-shared/controls/SwitchControl.tsx +67 -0
- package/src/ui-shared/controls/TextAreaControl.tsx +60 -0
- package/src/ui-shared/controls/TextControl.tsx +74 -0
- package/src/ui-shared/controls/keycloak-text-area/KeycloakTextArea.tsx +23 -0
- package/src/ui-shared/controls/select-control/SelectControl.tsx +75 -0
- package/src/ui-shared/controls/select-control/SingleSelectControl.tsx +107 -0
- package/src/ui-shared/controls/select-control/TypeaheadSelectControl.tsx +283 -0
- package/src/ui-shared/icons/IconMapper.tsx +63 -0
- package/src/ui-shared/index.ts +1 -0
- package/src/ui-shared/main.ts +62 -0
- package/src/ui-shared/masthead/DefaultAvatar.tsx +109 -0
- package/src/ui-shared/masthead/KeycloakDropdown.tsx +47 -0
- package/src/ui-shared/masthead/Masthead.tsx +145 -0
- package/src/ui-shared/scroll-form/FormPanel.tsx +29 -0
- package/src/ui-shared/scroll-form/FormTitle.tsx +28 -0
- package/src/ui-shared/scroll-form/ScrollForm.tsx +98 -0
- package/src/ui-shared/scroll-form/ScrollPanel.tsx +21 -0
- package/src/ui-shared/scroll-form/form-title.module.css +4 -0
- package/src/ui-shared/scroll-form/scroll-form.module.css +8 -0
- package/src/ui-shared/select/KeycloakSelect.tsx +49 -0
- package/src/ui-shared/select/SingleSelect.tsx +85 -0
- package/src/ui-shared/select/TypeaheadSelect.tsx +196 -0
- package/src/ui-shared/user-profile/LocaleSelector.tsx +51 -0
- package/src/ui-shared/user-profile/MultiInputComponent.tsx +146 -0
- package/src/ui-shared/user-profile/OptionsComponent.tsx +60 -0
- package/src/ui-shared/user-profile/SelectComponent.tsx +106 -0
- package/src/ui-shared/user-profile/TextAreaComponent.tsx +23 -0
- package/src/ui-shared/user-profile/TextComponent.tsx +30 -0
- package/src/ui-shared/user-profile/UserProfileFields.tsx +246 -0
- package/src/ui-shared/user-profile/UserProfileGroup.tsx +70 -0
- package/src/ui-shared/user-profile/utils.ts +161 -0
- package/src/ui-shared/utils/createNamedContext.ts +11 -0
- package/src/ui-shared/utils/isDefined.ts +3 -0
- package/src/ui-shared/utils/useRequiredContext.ts +24 -0
- package/src/ui-shared/utils/useStorageItem.ts +51 -0
- package/src/ui-shared/utils/useStoredState.ts +38 -0
- package/src/utils/formatDate.ts +18 -0
- package/src/utils/isRecord.ts +2 -0
- package/src/utils/joinPath.ts +22 -0
- package/src/utils/usePromise.ts +74 -0
- package/ui-shared/alerts/Alerts.d.ts +17 -0
- package/ui-shared/alerts/Alerts.js +27 -0
- package/ui-shared/alerts/Alerts.js.map +1 -0
- package/ui-shared/buttons/FormSubmitButton.d.ts +10 -0
- package/ui-shared/buttons/FormSubmitButton.js +26 -0
- package/ui-shared/buttons/FormSubmitButton.js.map +1 -0
- package/ui-shared/context/ErrorPage.d.ts +5 -0
- package/ui-shared/context/ErrorPage.js +24 -0
- package/ui-shared/context/ErrorPage.js.map +1 -0
- package/ui-shared/context/HelpContext.d.ts +9 -0
- package/ui-shared/context/HelpContext.js +14 -0
- package/ui-shared/context/HelpContext.js.map +1 -0
- package/ui-shared/context/KeycloakContext.d.ts +12 -0
- package/ui-shared/context/KeycloakContext.js +53 -0
- package/ui-shared/context/KeycloakContext.js.map +1 -0
- package/ui-shared/context/environment.d.ts +36 -0
- package/ui-shared/context/environment.js +27 -0
- package/ui-shared/context/environment.js.map +1 -0
- package/ui-shared/continue-cancel/ContinueCancelModal.d.ts +15 -0
- package/ui-shared/continue-cancel/ContinueCancelModal.js +27 -0
- package/ui-shared/continue-cancel/ContinueCancelModal.js.map +1 -0
- package/ui-shared/controls/FormErrorText.d.ts +5 -0
- package/ui-shared/controls/FormErrorText.js +19 -0
- package/ui-shared/controls/FormErrorText.js.map +1 -0
- package/ui-shared/controls/FormLabel.d.ts +13 -0
- package/ui-shared/controls/FormLabel.js +20 -0
- package/ui-shared/controls/FormLabel.js.map +1 -0
- package/ui-shared/controls/HelpItem.d.ts +9 -0
- package/ui-shared/controls/HelpItem.js +9 -0
- package/ui-shared/controls/HelpItem.js.map +1 -0
- package/ui-shared/controls/NumberControl.d.ts +13 -0
- package/ui-shared/controls/NumberControl.js +32 -0
- package/ui-shared/controls/NumberControl.js.map +1 -0
- package/ui-shared/controls/PasswordControl.d.ts +9 -0
- package/ui-shared/controls/PasswordControl.js +25 -0
- package/ui-shared/controls/PasswordControl.js.map +1 -0
- package/ui-shared/controls/PasswordInput.d.ts +7 -0
- package/ui-shared/controls/PasswordInput.js +25 -0
- package/ui-shared/controls/PasswordInput.js.map +1 -0
- package/ui-shared/controls/SwitchControl.d.ts +11 -0
- package/ui-shared/controls/SwitchControl.js +29 -0
- package/ui-shared/controls/SwitchControl.js.map +1 -0
- package/ui-shared/controls/TextAreaControl.d.ts +8 -0
- package/ui-shared/controls/TextAreaControl.js +12 -0
- package/ui-shared/controls/TextAreaControl.js.map +1 -0
- package/ui-shared/controls/TextControl.d.ts +10 -0
- package/ui-shared/controls/TextControl.js +24 -0
- package/ui-shared/controls/TextControl.js.map +1 -0
- package/ui-shared/controls/keycloak-text-area/KeycloakTextArea.d.ts +4 -0
- package/ui-shared/controls/keycloak-text-area/KeycloakTextArea.js +5 -0
- package/ui-shared/controls/keycloak-text-area/KeycloakTextArea.js.map +1 -0
- package/ui-shared/controls/select-control/SelectControl.d.ts +31 -0
- package/ui-shared/controls/select-control/SelectControl.js +28 -0
- package/ui-shared/controls/select-control/SelectControl.js.map +1 -0
- package/ui-shared/controls/select-control/SingleSelectControl.d.ts +3 -0
- package/ui-shared/controls/select-control/SingleSelectControl.js +41 -0
- package/ui-shared/controls/select-control/SingleSelectControl.js.map +1 -0
- package/ui-shared/controls/select-control/TypeaheadSelectControl.d.ts +3 -0
- package/ui-shared/controls/select-control/TypeaheadSelectControl.js +138 -0
- package/ui-shared/controls/select-control/TypeaheadSelectControl.js.map +1 -0
- package/ui-shared/icons/IconMapper.d.ts +5 -0
- package/ui-shared/icons/IconMapper.js +40 -0
- package/ui-shared/icons/IconMapper.js.map +1 -0
- package/ui-shared/index.d.ts +1 -0
- package/ui-shared/index.js +2 -0
- package/ui-shared/index.js.map +1 -0
- package/ui-shared/main.d.ts +31 -0
- package/ui-shared/main.js +29 -0
- package/ui-shared/main.js.map +1 -0
- package/ui-shared/masthead/DefaultAvatar.d.ts +7 -0
- package/ui-shared/masthead/DefaultAvatar.js +26 -0
- package/ui-shared/masthead/DefaultAvatar.js.map +1 -0
- package/ui-shared/masthead/KeycloakDropdown.d.ts +10 -0
- package/ui-shared/masthead/KeycloakDropdown.js +23 -0
- package/ui-shared/masthead/KeycloakDropdown.js.map +1 -0
- package/ui-shared/masthead/Masthead.d.ts +22 -0
- package/ui-shared/masthead/Masthead.js +55 -0
- package/ui-shared/masthead/Masthead.js.map +1 -0
- package/ui-shared/scroll-form/FormPanel.d.ts +8 -0
- package/ui-shared/scroll-form/FormPanel.js +9 -0
- package/ui-shared/scroll-form/FormPanel.js.map +1 -0
- package/ui-shared/scroll-form/FormTitle.d.ts +8 -0
- package/ui-shared/scroll-form/FormTitle.js +19 -0
- package/ui-shared/scroll-form/FormTitle.js.map +1 -0
- package/ui-shared/scroll-form/ScrollForm.d.ts +15 -0
- package/ui-shared/scroll-form/ScrollForm.js +38 -0
- package/ui-shared/scroll-form/ScrollForm.js.map +1 -0
- package/ui-shared/scroll-form/ScrollPanel.d.ts +7 -0
- package/ui-shared/scroll-form/ScrollPanel.js +18 -0
- package/ui-shared/scroll-form/ScrollPanel.js.map +1 -0
- package/ui-shared/select/KeycloakSelect.d.ts +30 -0
- package/ui-shared/select/KeycloakSelect.js +31 -0
- package/ui-shared/select/KeycloakSelect.js.map +1 -0
- package/ui-shared/select/SingleSelect.d.ts +4 -0
- package/ui-shared/select/SingleSelect.js +46 -0
- package/ui-shared/select/SingleSelect.js.map +1 -0
- package/ui-shared/select/TypeaheadSelect.d.ts +2 -0
- package/ui-shared/select/TypeaheadSelect.js +96 -0
- package/ui-shared/select/TypeaheadSelect.js.map +1 -0
- package/ui-shared/user-profile/LocaleSelector.d.ts +7 -0
- package/ui-shared/user-profile/LocaleSelector.js +28 -0
- package/ui-shared/user-profile/LocaleSelector.js.map +1 -0
- package/ui-shared/user-profile/MultiInputComponent.d.ts +15 -0
- package/ui-shared/user-profile/MultiInputComponent.js +61 -0
- package/ui-shared/user-profile/MultiInputComponent.js.map +1 -0
- package/ui-shared/user-profile/OptionsComponent.d.ts +2 -0
- package/ui-shared/user-profile/OptionsComponent.js +28 -0
- package/ui-shared/user-profile/OptionsComponent.js.map +1 -0
- package/ui-shared/user-profile/SelectComponent.d.ts +2 -0
- package/ui-shared/user-profile/SelectComponent.js +55 -0
- package/ui-shared/user-profile/SelectComponent.js.map +1 -0
- package/ui-shared/user-profile/TextAreaComponent.d.ts +2 -0
- package/ui-shared/user-profile/TextAreaComponent.js +11 -0
- package/ui-shared/user-profile/TextAreaComponent.js.map +1 -0
- package/ui-shared/user-profile/TextComponent.d.ts +2 -0
- package/ui-shared/user-profile/TextComponent.js +14 -0
- package/ui-shared/user-profile/TextComponent.js.map +1 -0
- package/ui-shared/user-profile/UserProfileFields.d.ts +39 -0
- package/ui-shared/user-profile/UserProfileFields.js +112 -0
- package/ui-shared/user-profile/UserProfileFields.js.map +1 -0
- package/ui-shared/user-profile/UserProfileGroup.d.ts +12 -0
- package/ui-shared/user-profile/UserProfileGroup.js +15 -0
- package/ui-shared/user-profile/UserProfileGroup.js.map +1 -0
- package/ui-shared/user-profile/utils.d.ts +32 -0
- package/ui-shared/user-profile/utils.js +79 -0
- package/ui-shared/user-profile/utils.js.map +1 -0
- package/ui-shared/utils/createNamedContext.d.ts +3 -0
- package/ui-shared/utils/createNamedContext.js +7 -0
- package/ui-shared/utils/createNamedContext.js.map +1 -0
- package/ui-shared/utils/isDefined.d.ts +1 -0
- package/ui-shared/utils/isDefined.js +4 -0
- package/ui-shared/utils/isDefined.js.map +1 -0
- package/ui-shared/utils/useRequiredContext.d.ts +9 -0
- package/ui-shared/utils/useRequiredContext.js +17 -0
- package/ui-shared/utils/useRequiredContext.js.map +1 -0
- package/ui-shared/utils/useStorageItem.d.ts +10 -0
- package/ui-shared/utils/useStorageItem.js +40 -0
- package/ui-shared/utils/useStorageItem.js.map +1 -0
- package/ui-shared/utils/useStoredState.d.ts +13 -0
- package/ui-shared/utils/useStoredState.js +21 -0
- package/ui-shared/utils/useStoredState.js.map +1 -0
- package/utils/formatDate.d.ts +4 -0
- package/utils/formatDate.js +12 -0
- package/utils/formatDate.js.map +1 -0
- package/utils/isRecord.d.ts +1 -0
- package/utils/isRecord.js +2 -0
- package/utils/isRecord.js.map +1 -0
- package/utils/joinPath.d.ts +1 -0
- package/utils/joinPath.js +18 -0
- package/utils/joinPath.js.map +1 -0
- package/utils/usePromise.d.ts +41 -0
- package/utils/usePromise.js +55 -0
- package/utils/usePromise.js.map +1 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
KeycloakContext,
|
|
3
|
+
type BaseEnvironment,
|
|
4
|
+
} from "@keycloakify/keycloak-account-ui/ui-shared";
|
|
5
|
+
import Keycloak from "keycloak-js";
|
|
6
|
+
|
|
7
|
+
import { joinPath } from "@keycloakify/keycloak-account-ui/utils/joinPath";
|
|
8
|
+
import { CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON } from "@keycloakify/keycloak-account-ui/api/constants";
|
|
9
|
+
|
|
10
|
+
export type RequestOptions = {
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
getAccessToken?: () => Promise<string | undefined>;
|
|
13
|
+
method?: "POST" | "PUT" | "DELETE";
|
|
14
|
+
searchParams?: Record<string, string>;
|
|
15
|
+
body?: unknown;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
async function _request(
|
|
19
|
+
url: URL,
|
|
20
|
+
{ signal, getAccessToken, method, searchParams, body }: RequestOptions = {},
|
|
21
|
+
): Promise<Response> {
|
|
22
|
+
if (searchParams) {
|
|
23
|
+
Object.entries(searchParams).forEach(([key, value]) =>
|
|
24
|
+
url.searchParams.set(key, value),
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return fetch(url, {
|
|
29
|
+
signal,
|
|
30
|
+
method,
|
|
31
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
32
|
+
headers: {
|
|
33
|
+
[CONTENT_TYPE_HEADER]: CONTENT_TYPE_JSON,
|
|
34
|
+
authorization: `Bearer ${await getAccessToken?.()}`,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function request(
|
|
40
|
+
path: string,
|
|
41
|
+
{ environment, keycloak }: KeycloakContext<BaseEnvironment>,
|
|
42
|
+
opts: RequestOptions = {},
|
|
43
|
+
fullUrl?: URL,
|
|
44
|
+
) {
|
|
45
|
+
if (typeof fullUrl === "undefined") {
|
|
46
|
+
fullUrl = url(environment, path);
|
|
47
|
+
}
|
|
48
|
+
return _request(fullUrl, {
|
|
49
|
+
...opts,
|
|
50
|
+
getAccessToken: token(keycloak),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const url = (environment: BaseEnvironment, path: string) =>
|
|
55
|
+
new URL(
|
|
56
|
+
joinPath(
|
|
57
|
+
environment.serverBaseUrl,
|
|
58
|
+
"realms",
|
|
59
|
+
environment.realm,
|
|
60
|
+
"account",
|
|
61
|
+
path,
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export const token = (keycloak: Keycloak) =>
|
|
66
|
+
async function getAccessToken() {
|
|
67
|
+
try {
|
|
68
|
+
await keycloak.updateToken(5);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
await keycloak.login();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return keycloak.token;
|
|
74
|
+
};
|
package/src/api.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
KeycloakContext,
|
|
3
|
+
type BaseEnvironment,
|
|
4
|
+
} from "@keycloakify/keycloak-account-ui/ui-shared";
|
|
5
|
+
|
|
6
|
+
import { CallOptions } from "@keycloakify/keycloak-account-ui/api/methods";
|
|
7
|
+
import { Links, parseLinks } from "@keycloakify/keycloak-account-ui/api/parse-links";
|
|
8
|
+
import { parseResponse } from "@keycloakify/keycloak-account-ui/api/parse-response";
|
|
9
|
+
import {
|
|
10
|
+
CredentialsIssuer,
|
|
11
|
+
Permission,
|
|
12
|
+
Resource,
|
|
13
|
+
Scope,
|
|
14
|
+
SupportedCredentialConfiguration,
|
|
15
|
+
} from "@keycloakify/keycloak-account-ui/api/representations";
|
|
16
|
+
import { request } from "@keycloakify/keycloak-account-ui/api/request";
|
|
17
|
+
import { joinPath } from "@keycloakify/keycloak-account-ui/utils/joinPath";
|
|
18
|
+
|
|
19
|
+
export const fetchResources = async (
|
|
20
|
+
{ signal, context }: CallOptions,
|
|
21
|
+
requestParams: Record<string, string>,
|
|
22
|
+
shared: boolean | undefined = false,
|
|
23
|
+
): Promise<{ data: Resource[]; links: Links }> => {
|
|
24
|
+
const response = await request(
|
|
25
|
+
`/resources${shared ? "/shared-with-me?" : "?"}`,
|
|
26
|
+
context,
|
|
27
|
+
{ searchParams: shared ? requestParams : undefined, signal },
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
let links: Links;
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
links = parseLinks(response);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
links = {};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
data: checkResponse(await response.json()),
|
|
40
|
+
links,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const fetchPermission = async (
|
|
45
|
+
{ signal, context }: CallOptions,
|
|
46
|
+
resourceId: string,
|
|
47
|
+
): Promise<Permission[]> => {
|
|
48
|
+
const response = await request(
|
|
49
|
+
`/resources/${resourceId}/permissions`,
|
|
50
|
+
context,
|
|
51
|
+
{ signal },
|
|
52
|
+
);
|
|
53
|
+
return parseResponse<Permission[]>(response);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const updateRequest = (
|
|
57
|
+
context: KeycloakContext<BaseEnvironment>,
|
|
58
|
+
resourceId: string,
|
|
59
|
+
username: string,
|
|
60
|
+
scopes: Scope[] | string[],
|
|
61
|
+
) =>
|
|
62
|
+
request(`/resources/${resourceId}/permissions`, context, {
|
|
63
|
+
method: "PUT",
|
|
64
|
+
body: [{ username, scopes }],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const updatePermissions = (
|
|
68
|
+
context: KeycloakContext<BaseEnvironment>,
|
|
69
|
+
resourceId: string,
|
|
70
|
+
permissions: Permission[],
|
|
71
|
+
) =>
|
|
72
|
+
request(`/resources/${resourceId}/permissions`, context, {
|
|
73
|
+
method: "PUT",
|
|
74
|
+
body: permissions,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
function checkResponse<T>(response: T) {
|
|
78
|
+
if (!response) throw new Error("Could not fetch");
|
|
79
|
+
return response;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export async function getIssuer(context: KeycloakContext<BaseEnvironment>) {
|
|
83
|
+
const response = await request(
|
|
84
|
+
joinPath(
|
|
85
|
+
"/realms/",
|
|
86
|
+
context.environment.realm,
|
|
87
|
+
"/.well-known/openid-credential-issuer",
|
|
88
|
+
),
|
|
89
|
+
context,
|
|
90
|
+
{},
|
|
91
|
+
new URL(
|
|
92
|
+
joinPath(
|
|
93
|
+
context.environment.serverBaseUrl,
|
|
94
|
+
"/realms/",
|
|
95
|
+
context.environment.realm,
|
|
96
|
+
"/.well-known/openid-credential-issuer",
|
|
97
|
+
),
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
return parseResponse<CredentialsIssuer>(response);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export async function requestVCOffer(
|
|
104
|
+
context: KeycloakContext<BaseEnvironment>,
|
|
105
|
+
supportedCredentialConfiguration: SupportedCredentialConfiguration,
|
|
106
|
+
credentialsIssuer: CredentialsIssuer,
|
|
107
|
+
) {
|
|
108
|
+
const response = await request(
|
|
109
|
+
"/protocol/oid4vc/credential-offer-uri",
|
|
110
|
+
context,
|
|
111
|
+
{
|
|
112
|
+
searchParams: {
|
|
113
|
+
credential_configuration_id: supportedCredentialConfiguration.id,
|
|
114
|
+
type: "qr-code",
|
|
115
|
+
width: "500",
|
|
116
|
+
height: "500",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
new URL(
|
|
120
|
+
joinPath(
|
|
121
|
+
credentialsIssuer.credential_issuer +
|
|
122
|
+
"/protocol/oid4vc/credential-offer-uri",
|
|
123
|
+
),
|
|
124
|
+
),
|
|
125
|
+
);
|
|
126
|
+
return response.blob();
|
|
127
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
DataList,
|
|
4
|
+
DataListCell,
|
|
5
|
+
DataListContent,
|
|
6
|
+
DataListItem,
|
|
7
|
+
DataListItemCells,
|
|
8
|
+
DataListItemRow,
|
|
9
|
+
DataListToggle,
|
|
10
|
+
DescriptionList,
|
|
11
|
+
DescriptionListDescription,
|
|
12
|
+
DescriptionListGroup,
|
|
13
|
+
DescriptionListTerm,
|
|
14
|
+
Grid,
|
|
15
|
+
GridItem,
|
|
16
|
+
Spinner,
|
|
17
|
+
} from "@patternfly/react-core";
|
|
18
|
+
import {
|
|
19
|
+
CheckIcon,
|
|
20
|
+
ExternalLinkAltIcon,
|
|
21
|
+
InfoAltIcon,
|
|
22
|
+
} from "@patternfly/react-icons";
|
|
23
|
+
import { useState } from "react";
|
|
24
|
+
import { useTranslation } from "react-i18next";
|
|
25
|
+
import {
|
|
26
|
+
ContinueCancelModal,
|
|
27
|
+
useAlerts,
|
|
28
|
+
useEnvironment,
|
|
29
|
+
} from "@keycloakify/keycloak-account-ui/ui-shared";
|
|
30
|
+
import { deleteConsent, getApplications } from "@keycloakify/keycloak-account-ui/api/methods";
|
|
31
|
+
import { ClientRepresentation } from "@keycloakify/keycloak-account-ui/api/representations";
|
|
32
|
+
import { Page } from "@keycloakify/keycloak-account-ui/components/page/Page";
|
|
33
|
+
import { TFuncKey } from "@keycloakify/keycloak-account-ui/i18n";
|
|
34
|
+
import { formatDate } from "@keycloakify/keycloak-account-ui/utils/formatDate";
|
|
35
|
+
import { usePromise } from "@keycloakify/keycloak-account-ui/utils/usePromise";
|
|
36
|
+
|
|
37
|
+
type Application = ClientRepresentation & {
|
|
38
|
+
open: boolean;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Applications = () => {
|
|
42
|
+
const { t } = useTranslation();
|
|
43
|
+
const context = useEnvironment();
|
|
44
|
+
const { addAlert, addError } = useAlerts();
|
|
45
|
+
|
|
46
|
+
const [applications, setApplications] = useState<Application[]>();
|
|
47
|
+
const [key, setKey] = useState(1);
|
|
48
|
+
const refresh = () => setKey(key + 1);
|
|
49
|
+
|
|
50
|
+
usePromise(
|
|
51
|
+
(signal) => getApplications({ signal, context }),
|
|
52
|
+
(clients) => setApplications(clients.map((c) => ({ ...c, open: false }))),
|
|
53
|
+
[key],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const toggleOpen = (clientId: string) => {
|
|
57
|
+
setApplications([
|
|
58
|
+
...applications!.map((a) =>
|
|
59
|
+
a.clientId === clientId ? { ...a, open: !a.open } : a,
|
|
60
|
+
),
|
|
61
|
+
]);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const removeConsent = async (id: string) => {
|
|
65
|
+
try {
|
|
66
|
+
await deleteConsent(context, id);
|
|
67
|
+
refresh();
|
|
68
|
+
addAlert(t("removeConsentSuccess"));
|
|
69
|
+
} catch (error) {
|
|
70
|
+
addError(t("removeConsentError", { error }).toString());
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
if (!applications) {
|
|
75
|
+
return <Spinner />;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<Page title={t("application")} description={t("applicationsIntroMessage")}>
|
|
80
|
+
<DataList id="applications-list" aria-label={t("application")}>
|
|
81
|
+
<DataListItem
|
|
82
|
+
id="applications-list-header"
|
|
83
|
+
aria-labelledby="Columns names"
|
|
84
|
+
>
|
|
85
|
+
<DataListItemRow>
|
|
86
|
+
<span style={{ visibility: "hidden", height: 55 }}>
|
|
87
|
+
<DataListToggle
|
|
88
|
+
id="applications-list-header-invisible-toggle"
|
|
89
|
+
aria-controls="applications-list-content"
|
|
90
|
+
/>
|
|
91
|
+
</span>
|
|
92
|
+
<DataListItemCells
|
|
93
|
+
dataListCells={[
|
|
94
|
+
<DataListCell
|
|
95
|
+
key="applications-list-client-id-header"
|
|
96
|
+
width={2}
|
|
97
|
+
className="pf-v5-u-pt-md"
|
|
98
|
+
>
|
|
99
|
+
<strong>{t("name")}</strong>
|
|
100
|
+
</DataListCell>,
|
|
101
|
+
<DataListCell
|
|
102
|
+
key="applications-list-app-type-header"
|
|
103
|
+
width={2}
|
|
104
|
+
className="pf-v5-u-pt-md"
|
|
105
|
+
>
|
|
106
|
+
<strong>{t("applicationType")}</strong>
|
|
107
|
+
</DataListCell>,
|
|
108
|
+
<DataListCell
|
|
109
|
+
key="applications-list-status"
|
|
110
|
+
width={2}
|
|
111
|
+
className="pf-v5-u-pt-md"
|
|
112
|
+
>
|
|
113
|
+
<strong>{t("status")}</strong>
|
|
114
|
+
</DataListCell>,
|
|
115
|
+
]}
|
|
116
|
+
/>
|
|
117
|
+
</DataListItemRow>
|
|
118
|
+
</DataListItem>
|
|
119
|
+
{applications.map((application) => (
|
|
120
|
+
<DataListItem
|
|
121
|
+
key={application.clientId}
|
|
122
|
+
aria-labelledby="applications-list"
|
|
123
|
+
data-testid="applications-list-item"
|
|
124
|
+
isExpanded={application.open}
|
|
125
|
+
>
|
|
126
|
+
<DataListItemRow className="pf-v5-u-align-items-center">
|
|
127
|
+
<DataListToggle
|
|
128
|
+
onClick={() => toggleOpen(application.clientId)}
|
|
129
|
+
isExpanded={application.open}
|
|
130
|
+
id={`toggle-${application.clientId}`}
|
|
131
|
+
aria-controls={`content-${application.clientId}`}
|
|
132
|
+
/>
|
|
133
|
+
<DataListItemCells
|
|
134
|
+
className="pf-v5-u-align-items-center"
|
|
135
|
+
dataListCells={[
|
|
136
|
+
<DataListCell width={2} key={`client${application.clientId}`}>
|
|
137
|
+
{application.effectiveUrl && (
|
|
138
|
+
<Button
|
|
139
|
+
className="pf-v5-u-pl-0 title-case"
|
|
140
|
+
component="a"
|
|
141
|
+
variant="link"
|
|
142
|
+
onClick={() => window.open(application.effectiveUrl)}
|
|
143
|
+
>
|
|
144
|
+
{application.clientName || application.clientId}{" "}
|
|
145
|
+
<ExternalLinkAltIcon />
|
|
146
|
+
</Button>
|
|
147
|
+
)}
|
|
148
|
+
{!application.effectiveUrl && (
|
|
149
|
+
<span>
|
|
150
|
+
{application.clientName || application.clientId}
|
|
151
|
+
</span>
|
|
152
|
+
)}
|
|
153
|
+
</DataListCell>,
|
|
154
|
+
<DataListCell
|
|
155
|
+
width={2}
|
|
156
|
+
key={`internal${application.clientId}`}
|
|
157
|
+
>
|
|
158
|
+
{application.userConsentRequired
|
|
159
|
+
? t("thirdPartyApp")
|
|
160
|
+
: t("internalApp")}
|
|
161
|
+
{application.offlineAccess ? ", " + t("offlineAccess") : ""}
|
|
162
|
+
</DataListCell>,
|
|
163
|
+
<DataListCell width={2} key={`status${application.clientId}`}>
|
|
164
|
+
{application.inUse ? t("inUse") : t("notInUse")}
|
|
165
|
+
</DataListCell>,
|
|
166
|
+
]}
|
|
167
|
+
/>
|
|
168
|
+
</DataListItemRow>
|
|
169
|
+
|
|
170
|
+
<DataListContent
|
|
171
|
+
id={`content-${application.clientId}`}
|
|
172
|
+
className="pf-v5-u-pl-4xl"
|
|
173
|
+
aria-label={t("applicationDetails", {
|
|
174
|
+
clientId: application.clientId,
|
|
175
|
+
})}
|
|
176
|
+
isHidden={!application.open}
|
|
177
|
+
>
|
|
178
|
+
<DescriptionList>
|
|
179
|
+
<DescriptionListGroup>
|
|
180
|
+
<DescriptionListTerm>{t("client")}</DescriptionListTerm>
|
|
181
|
+
<DescriptionListDescription>
|
|
182
|
+
{application.clientId}
|
|
183
|
+
</DescriptionListDescription>
|
|
184
|
+
</DescriptionListGroup>
|
|
185
|
+
{application.description && (
|
|
186
|
+
<DescriptionListGroup>
|
|
187
|
+
<DescriptionListTerm>
|
|
188
|
+
{t("description")}
|
|
189
|
+
</DescriptionListTerm>
|
|
190
|
+
<DescriptionListDescription>
|
|
191
|
+
{application.description}
|
|
192
|
+
</DescriptionListDescription>
|
|
193
|
+
</DescriptionListGroup>
|
|
194
|
+
)}
|
|
195
|
+
{application.effectiveUrl && (
|
|
196
|
+
<DescriptionListGroup>
|
|
197
|
+
<DescriptionListTerm>URL</DescriptionListTerm>
|
|
198
|
+
<DescriptionListDescription>
|
|
199
|
+
{application.effectiveUrl.split('"')}
|
|
200
|
+
</DescriptionListDescription>
|
|
201
|
+
</DescriptionListGroup>
|
|
202
|
+
)}
|
|
203
|
+
{application.consent && (
|
|
204
|
+
<>
|
|
205
|
+
<DescriptionListGroup>
|
|
206
|
+
<DescriptionListTerm>
|
|
207
|
+
{t("hasAccessTo")}
|
|
208
|
+
</DescriptionListTerm>
|
|
209
|
+
{application.consent.grantedScopes.map((scope) => (
|
|
210
|
+
<DescriptionListDescription key={`scope${scope.id}`}>
|
|
211
|
+
<CheckIcon /> {t(scope.name as TFuncKey)}
|
|
212
|
+
</DescriptionListDescription>
|
|
213
|
+
))}
|
|
214
|
+
</DescriptionListGroup>
|
|
215
|
+
{application.tosUri && (
|
|
216
|
+
<DescriptionListGroup>
|
|
217
|
+
<DescriptionListTerm>
|
|
218
|
+
{t("termsOfService")}
|
|
219
|
+
</DescriptionListTerm>
|
|
220
|
+
<DescriptionListDescription>
|
|
221
|
+
{application.tosUri}
|
|
222
|
+
</DescriptionListDescription>
|
|
223
|
+
</DescriptionListGroup>
|
|
224
|
+
)}
|
|
225
|
+
{application.policyUri && (
|
|
226
|
+
<DescriptionListGroup>
|
|
227
|
+
<DescriptionListTerm>
|
|
228
|
+
{t("privacyPolicy")}
|
|
229
|
+
</DescriptionListTerm>
|
|
230
|
+
<DescriptionListDescription>
|
|
231
|
+
{application.policyUri}
|
|
232
|
+
</DescriptionListDescription>
|
|
233
|
+
</DescriptionListGroup>
|
|
234
|
+
)}
|
|
235
|
+
{application.logoUri && (
|
|
236
|
+
<DescriptionListGroup>
|
|
237
|
+
<DescriptionListTerm>{t("logo")}</DescriptionListTerm>
|
|
238
|
+
<DescriptionListDescription>
|
|
239
|
+
<img src={application.logoUri} />
|
|
240
|
+
</DescriptionListDescription>
|
|
241
|
+
</DescriptionListGroup>
|
|
242
|
+
)}
|
|
243
|
+
<DescriptionListGroup>
|
|
244
|
+
<DescriptionListTerm>
|
|
245
|
+
{t("accessGrantedOn")}
|
|
246
|
+
</DescriptionListTerm>
|
|
247
|
+
<DescriptionListDescription>
|
|
248
|
+
{formatDate(new Date(application.consent.createdDate))}
|
|
249
|
+
</DescriptionListDescription>
|
|
250
|
+
</DescriptionListGroup>
|
|
251
|
+
</>
|
|
252
|
+
)}
|
|
253
|
+
</DescriptionList>
|
|
254
|
+
{(application.consent || application.offlineAccess) && (
|
|
255
|
+
<Grid hasGutter>
|
|
256
|
+
<hr />
|
|
257
|
+
<GridItem>
|
|
258
|
+
<ContinueCancelModal
|
|
259
|
+
buttonTitle={t("removeAccess")}
|
|
260
|
+
modalTitle={t("removeAccess")}
|
|
261
|
+
continueLabel={t("confirm")}
|
|
262
|
+
cancelLabel={t("cancel")}
|
|
263
|
+
buttonVariant="secondary"
|
|
264
|
+
onContinue={() => removeConsent(application.clientId)}
|
|
265
|
+
>
|
|
266
|
+
{t("removeModalMessage", { name: application.clientId })}
|
|
267
|
+
</ContinueCancelModal>
|
|
268
|
+
</GridItem>
|
|
269
|
+
<GridItem>
|
|
270
|
+
<InfoAltIcon /> {t("infoMessage")}
|
|
271
|
+
</GridItem>
|
|
272
|
+
</Grid>
|
|
273
|
+
)}
|
|
274
|
+
</DataListContent>
|
|
275
|
+
</DataListItem>
|
|
276
|
+
))}
|
|
277
|
+
</DataList>
|
|
278
|
+
</Page>
|
|
279
|
+
);
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
export default Applications;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DataListItem,
|
|
3
|
+
DataListItemRow,
|
|
4
|
+
DataListItemCells,
|
|
5
|
+
DataListCell,
|
|
6
|
+
} from "@patternfly/react-core";
|
|
7
|
+
|
|
8
|
+
type EmptyRowProps = {
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const EmptyRow = ({ message, ...props }: EmptyRowProps) => {
|
|
13
|
+
return (
|
|
14
|
+
<DataListItem className="pf-v5-u-align-items-center pf-p-b-0">
|
|
15
|
+
<DataListItemRow>
|
|
16
|
+
<DataListItemCells
|
|
17
|
+
dataListCells={[
|
|
18
|
+
<DataListCell key="0" {...props}>
|
|
19
|
+
{message}
|
|
20
|
+
</DataListCell>,
|
|
21
|
+
]}
|
|
22
|
+
/>
|
|
23
|
+
</DataListItemRow>
|
|
24
|
+
</DataListItem>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PageSection, Text, TextContent, Title } from "@patternfly/react-core";
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
|
+
|
|
4
|
+
type PageProps = {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Page = ({
|
|
10
|
+
title,
|
|
11
|
+
description,
|
|
12
|
+
children,
|
|
13
|
+
}: PropsWithChildren<PageProps>) => {
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
<PageSection variant="light">
|
|
17
|
+
<TextContent>
|
|
18
|
+
<Title headingLevel="h1" data-testid="page-heading">
|
|
19
|
+
{title}
|
|
20
|
+
</Title>
|
|
21
|
+
<Text component="p">{description}</Text>
|
|
22
|
+
</TextContent>
|
|
23
|
+
</PageSection>
|
|
24
|
+
<PageSection variant="light">{children}</PageSection>
|
|
25
|
+
</>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Spinner } from "@patternfly/react-core";
|
|
2
|
+
import { Suspense, lazy, useMemo, useState } from "react";
|
|
3
|
+
import { useParams } from "react-router-dom";
|
|
4
|
+
import { useEnvironment } from "@keycloakify/keycloak-account-ui/ui-shared";
|
|
5
|
+
import { MenuItem } from "@keycloakify/keycloak-account-ui/root/PageNav";
|
|
6
|
+
import { ContentComponentParams } from "@keycloakify/keycloak-account-ui/routes";
|
|
7
|
+
import { joinPath } from "@keycloakify/keycloak-account-ui/utils/joinPath";
|
|
8
|
+
import { usePromise } from "@keycloakify/keycloak-account-ui/utils/usePromise";
|
|
9
|
+
import fetchContentJson from "@keycloakify/keycloak-account-ui/content/fetchContent";
|
|
10
|
+
|
|
11
|
+
function findComponent(
|
|
12
|
+
content: MenuItem[],
|
|
13
|
+
componentId: string,
|
|
14
|
+
): string | undefined {
|
|
15
|
+
for (const item of content) {
|
|
16
|
+
if (
|
|
17
|
+
"path" in item &&
|
|
18
|
+
item.path.endsWith(componentId) &&
|
|
19
|
+
"modulePath" in item
|
|
20
|
+
) {
|
|
21
|
+
return item.modulePath;
|
|
22
|
+
}
|
|
23
|
+
if ("children" in item) {
|
|
24
|
+
return findComponent(item.children, componentId);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const ContentComponent = () => {
|
|
31
|
+
const context = useEnvironment();
|
|
32
|
+
|
|
33
|
+
const [content, setContent] = useState<MenuItem[]>();
|
|
34
|
+
const { componentId } = useParams<ContentComponentParams>();
|
|
35
|
+
|
|
36
|
+
usePromise((signal) => fetchContentJson({ signal, context }), setContent);
|
|
37
|
+
const modulePath = useMemo(
|
|
38
|
+
() => findComponent(content || [], componentId!),
|
|
39
|
+
[content, componentId],
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return modulePath && <Component modulePath={modulePath} />;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type ComponentProps = {
|
|
46
|
+
modulePath: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const Component = ({ modulePath }: ComponentProps) => {
|
|
50
|
+
const { environment } = useEnvironment();
|
|
51
|
+
|
|
52
|
+
const Element = lazy(
|
|
53
|
+
() => import(joinPath(environment.resourceUrl, modulePath)),
|
|
54
|
+
);
|
|
55
|
+
return (
|
|
56
|
+
<Suspense fallback={<Spinner />}>
|
|
57
|
+
<Element />
|
|
58
|
+
</Suspense>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default ContentComponent;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CallOptions } from "@keycloakify/keycloak-account-ui/api/methods";
|
|
2
|
+
import { MenuItem } from "@keycloakify/keycloak-account-ui/root/PageNav";
|
|
3
|
+
import { joinPath } from "@keycloakify/keycloak-account-ui/utils/joinPath";
|
|
4
|
+
|
|
5
|
+
export default async function fetchContentJson(
|
|
6
|
+
opts: CallOptions,
|
|
7
|
+
): Promise<MenuItem[]> {
|
|
8
|
+
const response = await fetch(
|
|
9
|
+
joinPath(opts.context.environment.resourceUrl, "/content.json"),
|
|
10
|
+
opts,
|
|
11
|
+
);
|
|
12
|
+
return await response.json();
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getInjectedEnvironment,
|
|
3
|
+
type BaseEnvironment,
|
|
4
|
+
} from "@keycloakify/keycloak-account-ui/ui-shared";
|
|
5
|
+
|
|
6
|
+
export type Environment = BaseEnvironment & {
|
|
7
|
+
/** The URL to the root of the account console. */
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
/** The locale of the user */
|
|
10
|
+
locale: string;
|
|
11
|
+
/** Name of the referrer application in the back link */
|
|
12
|
+
referrerName?: string;
|
|
13
|
+
/** UR to the referrer application in the back link */
|
|
14
|
+
referrerUrl?: string;
|
|
15
|
+
/** Feature flags */
|
|
16
|
+
features: Feature;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type Feature = {
|
|
20
|
+
isRegistrationEmailAsUsername: boolean;
|
|
21
|
+
isEditUserNameAllowed: boolean;
|
|
22
|
+
isLinkedAccountsEnabled: boolean;
|
|
23
|
+
isMyResourcesEnabled: boolean;
|
|
24
|
+
deleteAccountAllowed: boolean;
|
|
25
|
+
updateEmailFeatureEnabled: boolean;
|
|
26
|
+
updateEmailActionEnabled: boolean;
|
|
27
|
+
isViewGroupsEnabled: boolean;
|
|
28
|
+
isOid4VciEnabled: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const environment = getInjectedEnvironment<Environment>();
|
package/src/global.d.ts
ADDED