From 586b28af1cff43252786ad6c6ad6c4e3cd90225c Mon Sep 17 00:00:00 2001 From: giorgoslytos Date: Thu, 16 May 2024 12:53:31 +0300 Subject: [PATCH] fix: Correction of types on KcContext for account pages --- src/account/kcContext/KcContext.ts | 96 +++++++++++++------------ src/account/kcContext/kcContextMocks.ts | 17 +---- 2 files changed, 53 insertions(+), 60 deletions(-) diff --git a/src/account/kcContext/KcContext.ts b/src/account/kcContext/KcContext.ts index f65a0a7f..9748cd2e 100644 --- a/src/account/kcContext/KcContext.ts +++ b/src/account/kcContext/KcContext.ts @@ -91,15 +91,6 @@ export declare namespace KcContext { username?: string; }; properties: Record; - sessions: { - sessions: { - ipAddress: string; - started?: any; - lastAccess?: any; - expires?: any; - clients: string[]; - }[]; - }; }; export type Password = Common & { @@ -126,11 +117,12 @@ export declare namespace KcContext { pageId: "sessions.ftl"; sessions: { sessions: { - ipAddress: string; - started?: any; - lastAccess?: any; - expires?: any; + expires: string; clients: string[]; + ipAddress: string; + started: string; + lastAccess: string; + id: string; }[]; }; stateChecker: string; @@ -193,12 +185,21 @@ export declare namespace KcContext { stateChecker: string; applications: { applications: { - realmRolesAvailable: { name: string; description: string }[]; + realmRolesAvailable: { + name: string; + description: string; + compositesStream?: Record; + clientRole?: boolean; + composite?: boolean; + id?: string; + containerId?: string; + attributes?: Record; + }[]; resourceRolesAvailable: Record< string, { roleName: string; - roleDescription: string; + roleDescription?: string; clientName: string; clientId: string; }[] @@ -207,41 +208,44 @@ export declare namespace KcContext { clientScopesGranted: string[]; effectiveUrl?: string; client: { - consentScreenText: string; - surrogateAuthRequired: boolean; - bearerOnly: boolean; - id: string; - protocolMappersStream: Record; - includeInTokenScope: boolean; - redirectUris: string[]; - fullScopeAllowed: boolean; - registeredNodes: Record; - enabled: boolean; - clientAuthenticatorType: string; - realmScopeMappingsStream: Record; - scopeMappingsStream: Record; - displayOnConsentScreen: boolean; - clientId: string; - rootUrl: string; - authenticationFlowBindingOverrides: Record; - standardFlowEnabled: boolean; - attributes: Record; - publicClient: boolean; alwaysDisplayInConsole: boolean; + attributes: Record; + authenticationFlowBindingOverrides: Record; + baseUrl?: string; + bearerOnly: boolean; + clientAuthenticatorType: string; + clientId: string; consentRequired: boolean; - notBefore: string; - rolesStream: Record; - protocol: string; - dynamicScope: boolean; + consentScreenText: string; + description: string; directAccessGrantsEnabled: boolean; - name: string; - serviceAccountsEnabled: boolean; + displayOnConsentScreen: boolean; + dynamicScope: boolean; + enabled: boolean; frontchannelLogout: boolean; - nodeReRegistrationTimeout: string; + fullScopeAllowed: boolean; + id: string; implicitFlowEnabled: boolean; - baseUrl: string; - webOrigins: string[]; + includeInTokenScope: boolean; + managementUrl: string; + name?: string; + nodeReRegistrationTimeout: string; + notBefore: string; + protocol: string; + protocolMappersStream: Record; + publicClient: boolean; realm: Record; + realmScopeMappingsStream: Record; + redirectUris: string[]; + registeredNodes: Record; + rolesStream: Record; + rootUrl?: string; + scopeMappingsStream: Record; + secret: string; + serviceAccountsEnabled: boolean; + standardFlowEnabled: boolean; + surrogateAuthRequired: boolean; + webOrigins: string[]; }; }[]; }; @@ -254,8 +258,8 @@ export declare namespace KcContext { date: string | number | Date; event: string; ipAddress: string; - client: any; - details: any[]; + client: string; + details: { value: string; key: string }[]; }[]; }; }; diff --git a/src/account/kcContext/kcContextMocks.ts b/src/account/kcContext/kcContextMocks.ts index 383d94c2..c774b44a 100644 --- a/src/account/kcContext/kcContextMocks.ts +++ b/src/account/kcContext/kcContextMocks.ts @@ -156,17 +156,6 @@ export const kcContextCommonMock: KcContext.Common = { "css/account.css img/icon-sidebar-active.png img/logo.png resources-common/node_modules/patternfly/dist/css/patternfly.min.css resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css", "kcButtonClass": "btn", "kcButtonDefaultClass": "btn-default" - }, - "sessions": { - "sessions": [ - { - "ipAddress": "127.0.0.1", - "started": new Date().toString(), - "lastAccess": new Date().toString(), - "expires": new Date().toString(), - "clients": ["Chrome", "Firefox"] - } - ] } }; @@ -200,12 +189,12 @@ export const kcContextMocks: KcContext[] = [ "sessions": { "sessions": [ { - ...kcContextCommonMock.sessions, "ipAddress": "127.0.0.1", "started": new Date().toString(), "lastAccess": new Date().toString(), "expires": new Date().toString(), - "clients": ["Chrome", "Firefox"] + "clients": ["Chrome", "Firefox"], + "id": "f8951177-817d-4a70-9c02-86d3c170fe51" } ] }, @@ -246,7 +235,7 @@ export const kcContextMocks: KcContext[] = [ "event": "login", "ipAddress": "172.17.0.1", "client": "security-admin-console", - "details": ["auth_method = openid-connect, username = admin"] + "details": [{ key: "openid-connect", value: "admin" }] } ] }