oidc-spa 7.2.0-rc.1 → 7.2.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend.js.map +1 -1
- package/core/AuthResponse.js.map +1 -1
- package/core/Oidc.js.map +1 -1
- package/core/OidcInitializationError.d.ts +0 -13
- package/core/OidcInitializationError.js +0 -243
- package/core/OidcInitializationError.js.map +1 -1
- package/core/OidcMetadata.js.map +1 -1
- package/core/StateData.js.map +1 -1
- package/core/configId.js.map +1 -1
- package/core/createOidc.js +38 -5
- package/core/createOidc.js.map +1 -1
- package/core/diagnostic.d.ts +14 -0
- package/core/diagnostic.js +214 -0
- package/core/diagnostic.js.map +1 -0
- package/core/evtIsUserActive.js.map +1 -1
- package/core/handleOidcCallback.js.map +1 -1
- package/core/iframeMessageProtection.js.map +1 -1
- package/core/index.js.map +1 -1
- package/core/initialLocationHref.js.map +1 -1
- package/core/isNewBrowserSession.js.map +1 -1
- package/core/loginOrGoToAuthServer.js.map +1 -1
- package/core/loginPropagationToOtherTabs.js.map +1 -1
- package/core/loginSilent.js.map +1 -1
- package/core/logoutPropagationToOtherTabs.js.map +1 -1
- package/core/oidcClientTsUserToTokens.js.map +1 -1
- package/core/ongoingLoginOrRefreshProcesses.js.map +1 -1
- package/core/persistedAuthState.js.map +1 -1
- package/entrypoint.js.map +1 -1
- package/esm/core/AuthResponse.d.ts +5 -0
- package/{src/core/AuthResponse.ts → esm/core/AuthResponse.js} +2 -10
- package/esm/core/AuthResponse.js.map +1 -0
- package/esm/core/Oidc.d.ts +126 -0
- package/esm/core/Oidc.js +2 -0
- package/esm/core/Oidc.js.map +1 -0
- package/esm/core/OidcInitializationError.d.ts +7 -0
- package/esm/core/OidcInitializationError.js +17 -0
- package/esm/core/OidcInitializationError.js.map +1 -0
- package/{src/core/OidcMetadata.ts → esm/core/OidcMetadata.d.ts} +0 -5
- package/esm/core/OidcMetadata.js +3 -0
- package/esm/core/OidcMetadata.js.map +1 -0
- package/esm/core/StateData.d.ts +42 -0
- package/esm/core/StateData.js +55 -0
- package/esm/core/StateData.js.map +1 -0
- package/esm/core/configId.d.ts +4 -0
- package/esm/core/configId.js +4 -0
- package/esm/core/configId.js.map +1 -0
- package/esm/core/createOidc.d.ts +132 -0
- package/{src/core/createOidc.ts → esm/core/createOidc.js} +269 -806
- package/esm/core/createOidc.js.map +1 -0
- package/esm/core/diagnostic.d.ts +14 -0
- package/{src/core/OidcInitializationError.ts → esm/core/diagnostic.js} +32 -109
- package/esm/core/diagnostic.js.map +1 -0
- package/esm/core/evtIsUserActive.d.ts +5 -0
- package/{src/core/evtIsUserActive.ts → esm/core/evtIsUserActive.js} +14 -46
- package/esm/core/evtIsUserActive.js.map +1 -0
- package/esm/core/handleOidcCallback.d.ts +13 -0
- package/{src/core/handleOidcCallback.ts → esm/core/handleOidcCallback.js} +25 -121
- package/esm/core/handleOidcCallback.js.map +1 -0
- package/esm/core/iframeMessageProtection.d.ts +20 -0
- package/{src/core/iframeMessageProtection.ts → esm/core/iframeMessageProtection.js} +10 -45
- package/esm/core/iframeMessageProtection.js.map +1 -0
- package/esm/core/index.js +4 -0
- package/esm/core/index.js.map +1 -0
- package/esm/core/initialLocationHref.d.ts +1 -0
- package/{src/core/initialLocationHref.ts → esm/core/initialLocationHref.js} +1 -1
- package/esm/core/initialLocationHref.js.map +1 -0
- package/esm/core/isNewBrowserSession.d.ts +9 -0
- package/{src/core/isNewBrowserSession.ts → esm/core/isNewBrowserSession.js} +3 -15
- package/esm/core/isNewBrowserSession.js.map +1 -0
- package/esm/core/loginOrGoToAuthServer.d.ts +40 -0
- package/{src/core/loginOrGoToAuthServer.ts → esm/core/loginOrGoToAuthServer.js} +60 -168
- package/esm/core/loginOrGoToAuthServer.js.map +1 -0
- package/esm/core/loginPropagationToOtherTabs.d.ts +8 -0
- package/{src/core/loginPropagationToOtherTabs.ts → esm/core/loginPropagationToOtherTabs.js} +7 -25
- package/esm/core/loginPropagationToOtherTabs.js.map +1 -0
- package/esm/core/loginSilent.d.ts +28 -0
- package/esm/core/loginSilent.js +125 -0
- package/esm/core/loginSilent.js.map +1 -0
- package/esm/core/logoutPropagationToOtherTabs.d.ts +10 -0
- package/{src/core/logoutPropagationToOtherTabs.ts → esm/core/logoutPropagationToOtherTabs.js} +8 -28
- package/esm/core/logoutPropagationToOtherTabs.js.map +1 -0
- package/esm/core/oidcClientTsUserToTokens.d.ts +11 -0
- package/esm/core/oidcClientTsUserToTokens.js +155 -0
- package/esm/core/oidcClientTsUserToTokens.js.map +1 -0
- package/esm/core/ongoingLoginOrRefreshProcesses.d.ts +6 -0
- package/{src/core/ongoingLoginOrRefreshProcesses.ts → esm/core/ongoingLoginOrRefreshProcesses.js} +6 -24
- package/esm/core/ongoingLoginOrRefreshProcesses.js.map +1 -0
- package/esm/core/persistedAuthState.d.ts +28 -0
- package/esm/core/persistedAuthState.js +64 -0
- package/esm/core/persistedAuthState.js.map +1 -0
- package/esm/entrypoint.d.ts +7 -0
- package/{src/entrypoint.ts → esm/entrypoint.js} +3 -26
- package/esm/entrypoint.js.map +1 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -0
- package/esm/keycloak/index.d.ts +3 -0
- package/esm/keycloak/index.js +3 -0
- package/esm/keycloak/index.js.map +1 -0
- package/esm/keycloak/isKeycloak.d.ts +3 -0
- package/{src/keycloak/isKeycloak.ts → esm/keycloak/isKeycloak.js} +2 -8
- package/esm/keycloak/isKeycloak.js.map +1 -0
- package/esm/keycloak/keycloak-js/Keycloak.d.ts +284 -0
- package/{src/keycloak/keycloak-js/Keycloak.ts → esm/keycloak/keycloak-js/Keycloak.js} +116 -439
- package/esm/keycloak/keycloak-js/Keycloak.js.map +1 -0
- package/esm/keycloak/keycloak-js/index.js +2 -0
- package/esm/keycloak/keycloak-js/index.js.map +1 -0
- package/{src/keycloak/keycloak-js/types.ts → esm/keycloak/keycloak-js/types.d.ts} +3 -84
- package/esm/keycloak/keycloak-js/types.js +2 -0
- package/esm/keycloak/keycloak-js/types.js.map +1 -0
- package/esm/keycloak/keycloakIssuerUriParsed.d.ts +9 -0
- package/{src/keycloak/keycloakIssuerUriParsed.ts → esm/keycloak/keycloakIssuerUriParsed.js} +2 -15
- package/esm/keycloak/keycloakIssuerUriParsed.js.map +1 -0
- package/esm/keycloak/keycloakUtils.d.ts +37 -0
- package/esm/keycloak/keycloakUtils.js +44 -0
- package/esm/keycloak/keycloakUtils.js.map +1 -0
- package/esm/keycloak-js.js +2 -0
- package/esm/keycloak-js.js.map +1 -0
- package/esm/mock/index.js +2 -0
- package/esm/mock/index.js.map +1 -0
- package/esm/mock/oidc.d.ts +19 -0
- package/{src/mock/oidc.ts → esm/mock/oidc.js} +28 -88
- package/esm/mock/oidc.js.map +1 -0
- package/esm/mock/react.d.ts +58 -0
- package/esm/mock/react.js +7 -0
- package/esm/mock/react.js.map +1 -0
- package/esm/react/index.js +2 -0
- package/esm/react/index.js.map +1 -0
- package/esm/react/react.d.ts +102 -0
- package/esm/react/react.js +221 -0
- package/esm/react/react.js.map +1 -0
- package/esm/tools/Deferred.d.ts +14 -0
- package/esm/tools/Deferred.js +23 -0
- package/esm/tools/Deferred.js.map +1 -0
- package/esm/tools/EphemeralSessionStorage.d.ts +12 -0
- package/{src/tools/EphemeralSessionStorage.ts → esm/tools/EphemeralSessionStorage.js} +30 -112
- package/esm/tools/EphemeralSessionStorage.js.map +1 -0
- package/esm/tools/Evt.d.ts +11 -0
- package/{src/tools/Evt.ts → esm/tools/Evt.js} +7 -25
- package/esm/tools/Evt.js.map +1 -0
- package/esm/tools/StatefulEvt.d.ts +12 -0
- package/esm/tools/StatefulEvt.js +21 -0
- package/esm/tools/StatefulEvt.js.map +1 -0
- package/esm/tools/ValueOrAsyncGetter.js +2 -0
- package/esm/tools/ValueOrAsyncGetter.js.map +1 -0
- package/esm/tools/asymmetricEncryption.d.ts +18 -0
- package/esm/tools/asymmetricEncryption.js +85 -0
- package/esm/tools/asymmetricEncryption.js.map +1 -0
- package/esm/tools/base64.d.ts +2 -0
- package/{src/tools/base64.ts → esm/tools/base64.js} +3 -3
- package/esm/tools/base64.js.map +1 -0
- package/esm/tools/createObjectThatThrowsIfAccessed.d.ts +8 -0
- package/{src/tools/createObjectThatThrowsIfAccessed.ts → esm/tools/createObjectThatThrowsIfAccessed.js} +7 -18
- package/esm/tools/createObjectThatThrowsIfAccessed.js.map +1 -0
- package/esm/tools/decodeJwt.d.ts +25 -0
- package/esm/tools/decodeJwt.js +60 -0
- package/esm/tools/decodeJwt.js.map +1 -0
- package/esm/tools/generateUrlSafeRandom.d.ts +3 -0
- package/{src/tools/generateUrlSafeRandom.ts → esm/tools/generateUrlSafeRandom.js} +5 -8
- package/esm/tools/generateUrlSafeRandom.js.map +1 -0
- package/esm/tools/getDownlinkAndRtt.d.ts +4 -0
- package/{src/tools/getDownlinkAndRtt.ts → esm/tools/getDownlinkAndRtt.js} +6 -10
- package/esm/tools/getDownlinkAndRtt.js.map +1 -0
- package/esm/tools/getIsOnline.d.ts +7 -0
- package/{src/tools/getIsOnline.ts → esm/tools/getIsOnline.js} +3 -9
- package/esm/tools/getIsOnline.js.map +1 -0
- package/esm/tools/getIsValidRemoteJson.d.ts +1 -0
- package/esm/tools/getIsValidRemoteJson.js +15 -0
- package/esm/tools/getIsValidRemoteJson.js.map +1 -0
- package/esm/tools/getPrUserInteraction.d.ts +4 -0
- package/{src/tools/getPrUserInteraction.ts → esm/tools/getPrUserInteraction.js} +2 -6
- package/esm/tools/getPrUserInteraction.js.map +1 -0
- package/esm/tools/getUserEnvironmentInfo.d.ts +1 -0
- package/esm/tools/getUserEnvironmentInfo.js +50 -0
- package/esm/tools/getUserEnvironmentInfo.js.map +1 -0
- package/esm/tools/haveSharedParentDomain.d.ts +4 -0
- package/{src/tools/haveSharedParentDomain.ts → esm/tools/haveSharedParentDomain.js} +3 -5
- package/esm/tools/haveSharedParentDomain.js.map +1 -0
- package/esm/tools/isDev.d.ts +1 -0
- package/{src/tools/isDev.ts → esm/tools/isDev.js} +5 -12
- package/esm/tools/isDev.js.map +1 -0
- package/esm/tools/parseKeycloakIssuerUri.d.ts +30 -0
- package/{src/tools/parseKeycloakIssuerUri.ts → esm/tools/parseKeycloakIssuerUri.js} +2 -18
- package/esm/tools/parseKeycloakIssuerUri.js.map +1 -0
- package/esm/tools/readExpirationTimeInJwt.d.ts +1 -0
- package/{src/tools/readExpirationTimeInJwt.ts → esm/tools/readExpirationTimeInJwt.js} +6 -7
- package/esm/tools/readExpirationTimeInJwt.js.map +1 -0
- package/esm/tools/startCountdown.d.ts +11 -0
- package/{src/tools/startCountdown.ts → esm/tools/startCountdown.js} +6 -17
- package/esm/tools/startCountdown.js.map +1 -0
- package/esm/tools/subscribeToUserInteraction.d.ts +6 -0
- package/{src/tools/subscribeToUserInteraction.ts → esm/tools/subscribeToUserInteraction.js} +4 -13
- package/esm/tools/subscribeToUserInteraction.js.map +1 -0
- package/esm/tools/toFullyQualifiedUrl.d.ts +10 -0
- package/{src/tools/toFullyQualifiedUrl.ts → esm/tools/toFullyQualifiedUrl.js} +7 -25
- package/esm/tools/toFullyQualifiedUrl.js.map +1 -0
- package/esm/tools/toHumanReadableDuration.d.ts +1 -0
- package/{src/tools/toHumanReadableDuration.ts → esm/tools/toHumanReadableDuration.js} +8 -5
- package/esm/tools/toHumanReadableDuration.js.map +1 -0
- package/esm/tools/urlSearchParams.d.ts +19 -0
- package/{src/tools/urlSearchParams.ts → esm/tools/urlSearchParams.js} +24 -70
- package/esm/tools/urlSearchParams.js.map +1 -0
- package/esm/tools/workerTimers.d.ts +5 -0
- package/{src/tools/workerTimers.ts → esm/tools/workerTimers.js} +7 -27
- package/esm/tools/workerTimers.js.map +1 -0
- package/esm/vendor/frontend/oidc-client-ts.js +3636 -0
- package/esm/vendor/frontend/tsafe.js +1 -0
- package/esm/vendor/frontend/worker-timers.js +1 -0
- package/index.js.map +1 -1
- package/keycloak/index.js.map +1 -1
- package/keycloak/isKeycloak.js.map +1 -1
- package/keycloak/keycloak-js/Keycloak.js.map +1 -1
- package/keycloak/keycloak-js/index.js.map +1 -1
- package/keycloak/keycloak-js/types.js.map +1 -1
- package/keycloak/keycloakIssuerUriParsed.js.map +1 -1
- package/keycloak/keycloakUtils.js.map +1 -1
- package/keycloak-js.js.map +1 -1
- package/mock/index.js.map +1 -1
- package/mock/oidc.js.map +1 -1
- package/mock/react.js.map +1 -1
- package/package.json +74 -328
- package/react/index.js.map +1 -1
- package/react/react.js.map +1 -1
- package/tools/Deferred.js.map +1 -1
- package/tools/EphemeralSessionStorage.js.map +1 -1
- package/tools/Evt.js.map +1 -1
- package/tools/StatefulEvt.js.map +1 -1
- package/tools/ValueOrAsyncGetter.js.map +1 -1
- package/tools/asymmetricEncryption.js.map +1 -1
- package/tools/base64.js.map +1 -1
- package/tools/createObjectThatThrowsIfAccessed.js.map +1 -1
- package/tools/decodeJwt.js.map +1 -1
- package/tools/generateUrlSafeRandom.js.map +1 -1
- package/tools/getDownlinkAndRtt.js.map +1 -1
- package/tools/getIsOnline.js.map +1 -1
- package/tools/getIsValidRemoteJson.js.map +1 -1
- package/tools/getPrUserInteraction.js.map +1 -1
- package/tools/getUserEnvironmentInfo.js.map +1 -1
- package/tools/haveSharedParentDomain.js.map +1 -1
- package/tools/isDev.js.map +1 -1
- package/tools/parseKeycloakIssuerUri.js.map +1 -1
- package/tools/readExpirationTimeInJwt.js.map +1 -1
- package/tools/startCountdown.js.map +1 -1
- package/tools/subscribeToUserInteraction.js.map +1 -1
- package/tools/toFullyQualifiedUrl.js.map +1 -1
- package/tools/toHumanReadableDuration.js.map +1 -1
- package/tools/urlSearchParams.js.map +1 -1
- package/tools/workerTimers.js.map +1 -1
- package/LICENSE +0 -21
- package/README.md +0 -185
- package/src/backend.ts +0 -391
- package/src/core/Oidc.ts +0 -140
- package/src/core/StateData.ts +0 -118
- package/src/core/configId.ts +0 -3
- package/src/core/loginSilent.ts +0 -209
- package/src/core/oidcClientTsUserToTokens.ts +0 -229
- package/src/core/persistedAuthState.ts +0 -122
- package/src/keycloak/index.ts +0 -8
- package/src/keycloak/keycloakUtils.ts +0 -90
- package/src/mock/react.tsx +0 -11
- package/src/react/react.tsx +0 -476
- package/src/tools/Deferred.ts +0 -39
- package/src/tools/StatefulEvt.ts +0 -38
- package/src/tools/asymmetricEncryption.ts +0 -184
- package/src/tools/decodeJwt.ts +0 -95
- package/src/tools/getIsValidRemoteJson.ts +0 -18
- package/src/tools/getUserEnvironmentInfo.ts +0 -42
- package/src/vendor/backend/evt.ts +0 -2
- package/src/vendor/backend/jsonwebtoken.ts +0 -1
- package/src/vendor/backend/node-fetch.ts +0 -2
- package/src/vendor/backend/node-jose.ts +0 -1
- package/src/vendor/backend/tsafe.ts +0 -5
- package/src/vendor/backend/zod.ts +0 -1
- /package/{src/core/index.ts → esm/core/index.d.ts} +0 -0
- /package/{src/index.ts → esm/index.d.ts} +0 -0
- /package/{src/keycloak/keycloak-js/index.ts → esm/keycloak/keycloak-js/index.d.ts} +0 -0
- /package/{src/keycloak-js.ts → esm/keycloak-js.d.ts} +0 -0
- /package/{src/mock/index.ts → esm/mock/index.d.ts} +0 -0
- /package/{src/react/index.ts → esm/react/index.d.ts} +0 -0
- /package/{src/tools/ValueOrAsyncGetter.ts → esm/tools/ValueOrAsyncGetter.d.ts} +0 -0
- /package/{src/vendor/frontend/oidc-client-ts.ts → esm/vendor/frontend/oidc-client-ts.d.ts} +0 -0
- /package/{src/vendor/frontend/tsafe.ts → esm/vendor/frontend/tsafe.d.ts} +0 -0
- /package/{src/vendor/frontend/worker-timers.ts → esm/vendor/frontend/worker-timers.d.ts} +0 -0
|
@@ -1,45 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
KeycloakServerConfig,
|
|
3
|
-
KeycloakInitOptions,
|
|
4
|
-
KeycloakError,
|
|
5
|
-
KeycloakLogoutOptions,
|
|
6
|
-
KeycloakRoles,
|
|
7
|
-
KeycloakTokenParsed,
|
|
8
|
-
KeycloakResourceAccess,
|
|
9
|
-
KeycloakProfile,
|
|
10
|
-
KeycloakUserInfo,
|
|
11
|
-
KeycloakLoginOptions,
|
|
12
|
-
KeycloakRegisterOptions,
|
|
13
|
-
KeycloakAccountOptions
|
|
14
|
-
} from "./types";
|
|
15
1
|
import { assert, is, isAmong } from "../../vendor/frontend/tsafe";
|
|
16
|
-
import { createOidc,
|
|
2
|
+
import { createOidc, OidcInitializationError } from "../../core";
|
|
17
3
|
import { Deferred } from "../../tools/Deferred";
|
|
18
4
|
import { decodeJwt } from "../../tools/decodeJwt";
|
|
19
|
-
import {
|
|
5
|
+
import { createKeycloakUtils } from "../keycloakUtils";
|
|
20
6
|
import { workerTimers } from "../../vendor/frontend/worker-timers";
|
|
21
|
-
import {
|
|
7
|
+
import { createStatefulEvt } from "../../tools/StatefulEvt";
|
|
22
8
|
import { readExpirationTimeInJwt } from "../../tools/readExpirationTimeInJwt";
|
|
23
|
-
|
|
24
|
-
type ConstructorParams = KeycloakServerConfig & {
|
|
25
|
-
homeUrl: string;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type InternalState = {
|
|
29
|
-
constructorParams: ConstructorParams;
|
|
30
|
-
keycloakUtils: KeycloakUtils;
|
|
31
|
-
issuerUri: string;
|
|
32
|
-
dInitialized: Deferred<void>;
|
|
33
|
-
initOptions: KeycloakInitOptions | undefined;
|
|
34
|
-
oidc: Oidc<Record<string, unknown>> | undefined;
|
|
35
|
-
tokens: Oidc.Tokens<Record<string, unknown>> | undefined;
|
|
36
|
-
profile: KeycloakProfile | undefined;
|
|
37
|
-
userInfo: KeycloakUserInfo | undefined;
|
|
38
|
-
$onTokenExpired: StatefulEvt<(() => void) | undefined>;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const internalStateByInstance = new WeakMap<Keycloak, InternalState>();
|
|
42
|
-
|
|
9
|
+
const internalStateByInstance = new WeakMap();
|
|
43
10
|
/**
|
|
44
11
|
* This module provides a drop-in replacement for `keycloak-js`,
|
|
45
12
|
* designed for teams migrating to `oidc-spa` with minimal changes.
|
|
@@ -56,9 +23,36 @@ export class Keycloak {
|
|
|
56
23
|
* But we could if with the __metadata parameter of oidc-spa.
|
|
57
24
|
* I'm not seeing the usecase when ran against keycloak right now so not doing it.
|
|
58
25
|
*/
|
|
59
|
-
constructor(params
|
|
26
|
+
constructor(params) {
|
|
27
|
+
/**
|
|
28
|
+
* Response mode passed in init (default value is `'fragment'`).
|
|
29
|
+
*
|
|
30
|
+
* NOTE oidc-spa: Can only be fragment.
|
|
31
|
+
*/
|
|
32
|
+
this.responseMode = "fragment";
|
|
33
|
+
/**
|
|
34
|
+
* Response type sent to Keycloak with login requests. This is determined
|
|
35
|
+
* based on the flow value used during initialization, but can be overridden
|
|
36
|
+
* by setting this value.
|
|
37
|
+
*
|
|
38
|
+
* NOTE oidc-spa: Can only be 'code'
|
|
39
|
+
*/
|
|
40
|
+
this.responseType = "code";
|
|
41
|
+
/**
|
|
42
|
+
* Flow passed in init.
|
|
43
|
+
*
|
|
44
|
+
* NOTE oidc-spa: Can only be 'standard'
|
|
45
|
+
*/
|
|
46
|
+
this.flow = "standard";
|
|
47
|
+
/**
|
|
48
|
+
* The estimated time difference between the browser time and the Keycloak
|
|
49
|
+
* server in seconds. This value is just an estimation, but is accurate
|
|
50
|
+
* enough when determining if a token is expired or not.
|
|
51
|
+
*
|
|
52
|
+
* NOTE oidc-spa: Not supported.
|
|
53
|
+
*/
|
|
54
|
+
this.timeSkew = null;
|
|
60
55
|
const issuerUri = `${params.url.replace(/\/$/, "")}/realms/${params.realm}`;
|
|
61
|
-
|
|
62
56
|
internalStateByInstance.set(this, {
|
|
63
57
|
constructorParams: params,
|
|
64
58
|
dInitialized: new Deferred(),
|
|
@@ -72,19 +66,15 @@ export class Keycloak {
|
|
|
72
66
|
$onTokenExpired: createStatefulEvt(() => undefined)
|
|
73
67
|
});
|
|
74
68
|
}
|
|
75
|
-
|
|
76
69
|
/**
|
|
77
70
|
* Called to initialize the adapter.
|
|
78
71
|
* @param initOptions Initialization options.
|
|
79
72
|
* @returns A promise to set functions to be invoked on success or error.
|
|
80
73
|
*/
|
|
81
|
-
async init(initOptions
|
|
74
|
+
async init(initOptions = {}) {
|
|
82
75
|
const { onLoad = "check-sso", redirectUri, enableLogging, scope, locale } = initOptions;
|
|
83
|
-
|
|
84
76
|
const internalState = internalStateByInstance.get(this);
|
|
85
|
-
|
|
86
77
|
assert(internalState !== undefined);
|
|
87
|
-
|
|
88
78
|
if (internalState.initOptions !== undefined) {
|
|
89
79
|
if (JSON.stringify(internalState.initOptions) !== JSON.stringify(initOptions)) {
|
|
90
80
|
throw new Error("Can't call init() multiple time with different params");
|
|
@@ -94,15 +84,10 @@ export class Keycloak {
|
|
|
94
84
|
assert(oidc !== undefined);
|
|
95
85
|
return oidc.isUserLoggedIn;
|
|
96
86
|
}
|
|
97
|
-
|
|
98
87
|
internalState.initOptions = initOptions;
|
|
99
|
-
|
|
100
88
|
const { constructorParams, issuerUri } = internalState;
|
|
101
|
-
|
|
102
89
|
const autoLogin = onLoad === "login-required";
|
|
103
|
-
|
|
104
90
|
let hasCreateResolved = false;
|
|
105
|
-
|
|
106
91
|
const oidcOrError = await createOidc({
|
|
107
92
|
homeUrl: constructorParams.homeUrl,
|
|
108
93
|
issuerUri,
|
|
@@ -111,84 +96,62 @@ export class Keycloak {
|
|
|
111
96
|
postLoginRedirectUrl: redirectUri,
|
|
112
97
|
debugLogs: enableLogging,
|
|
113
98
|
scopes: scope?.split(" "),
|
|
114
|
-
extraQueryParams:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
}
|
|
99
|
+
extraQueryParams: !autoLogin || locale === undefined
|
|
100
|
+
? undefined
|
|
101
|
+
: () => {
|
|
102
|
+
if (hasCreateResolved) {
|
|
103
|
+
return {};
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
ui_locales: locale
|
|
107
|
+
};
|
|
108
|
+
}
|
|
126
109
|
})
|
|
127
110
|
// NOTE: This can only happen when autoLogin is true, otherwise the error
|
|
128
111
|
// is in oidc.initializationError
|
|
129
|
-
.catch((error
|
|
130
|
-
|
|
112
|
+
.catch((error) => error);
|
|
131
113
|
hasCreateResolved = true;
|
|
132
|
-
|
|
133
114
|
if (oidcOrError instanceof OidcInitializationError) {
|
|
134
115
|
this.onAuthError?.({
|
|
135
116
|
error: oidcOrError.name,
|
|
136
117
|
error_description: oidcOrError.message
|
|
137
118
|
});
|
|
138
|
-
|
|
139
|
-
await new Promise<never>(() => {});
|
|
119
|
+
await new Promise(() => { });
|
|
140
120
|
assert(false);
|
|
141
121
|
}
|
|
142
|
-
|
|
143
122
|
const oidc = oidcOrError;
|
|
144
|
-
|
|
145
123
|
internalState.oidc = oidc;
|
|
146
|
-
|
|
147
124
|
if (oidc.isUserLoggedIn) {
|
|
148
125
|
{
|
|
149
126
|
const tokens = await oidc.getTokens();
|
|
150
|
-
|
|
151
|
-
const onNewToken = (tokens_new: Oidc.Tokens<Record<string, unknown>>) => {
|
|
127
|
+
const onNewToken = (tokens_new) => {
|
|
152
128
|
internalState.tokens = tokens_new;
|
|
153
129
|
this.onAuthRefreshSuccess?.();
|
|
154
130
|
};
|
|
155
|
-
|
|
156
131
|
onNewToken(tokens);
|
|
157
|
-
|
|
158
132
|
oidc.subscribeToTokensChange(onNewToken);
|
|
159
133
|
}
|
|
160
|
-
|
|
161
134
|
{
|
|
162
135
|
const { $onTokenExpired } = internalState;
|
|
163
|
-
|
|
164
|
-
let clear: (() => void) | undefined = undefined;
|
|
165
|
-
|
|
136
|
+
let clear = undefined;
|
|
166
137
|
$onTokenExpired.subscribe(onTokenExpired => {
|
|
167
138
|
clear?.();
|
|
168
|
-
|
|
169
139
|
if (onTokenExpired === undefined) {
|
|
170
140
|
return;
|
|
171
141
|
}
|
|
172
|
-
|
|
173
|
-
let timer: ReturnType<typeof workerTimers.setTimeout> | undefined = undefined;
|
|
174
|
-
|
|
142
|
+
let timer = undefined;
|
|
175
143
|
const onNewToken = () => {
|
|
176
144
|
if (timer !== undefined) {
|
|
177
145
|
workerTimers.clearTimeout(timer);
|
|
178
146
|
}
|
|
179
|
-
|
|
180
147
|
const { tokens } = internalState;
|
|
181
148
|
assert(tokens !== undefined);
|
|
182
|
-
|
|
183
149
|
timer = workerTimers.setTimeout(() => {
|
|
184
150
|
onTokenExpired.call(this);
|
|
185
|
-
}, Math.max(tokens.accessTokenExpirationTime - Date.now() -
|
|
151
|
+
}, Math.max(tokens.accessTokenExpirationTime - Date.now() - 3000, 0));
|
|
186
152
|
};
|
|
187
|
-
|
|
188
153
|
onNewToken();
|
|
189
|
-
|
|
190
154
|
const { unsubscribe } = oidc.subscribeToTokensChange(onNewToken);
|
|
191
|
-
|
|
192
155
|
clear = () => {
|
|
193
156
|
if (timer !== undefined) {
|
|
194
157
|
workerTimers.clearTimeout(timer);
|
|
@@ -197,445 +160,283 @@ export class Keycloak {
|
|
|
197
160
|
};
|
|
198
161
|
});
|
|
199
162
|
}
|
|
200
|
-
|
|
201
163
|
onActionUpdate_call: {
|
|
202
164
|
if (this.onActionUpdate === undefined) {
|
|
203
165
|
break onActionUpdate_call;
|
|
204
166
|
}
|
|
205
|
-
|
|
206
167
|
const { backFromAuthServer } = oidc;
|
|
207
|
-
|
|
208
168
|
if (backFromAuthServer === undefined) {
|
|
209
169
|
break onActionUpdate_call;
|
|
210
170
|
}
|
|
211
|
-
|
|
212
171
|
const status = backFromAuthServer.result.kc_action_status;
|
|
213
|
-
|
|
214
172
|
if (!isAmong(["success", "cancelled", "error"], status)) {
|
|
215
173
|
break onActionUpdate_call;
|
|
216
174
|
}
|
|
217
|
-
|
|
218
175
|
const action = backFromAuthServer.extraQueryParams.kc_action;
|
|
219
|
-
|
|
220
176
|
if (action === undefined) {
|
|
221
177
|
break onActionUpdate_call;
|
|
222
178
|
}
|
|
223
|
-
|
|
224
179
|
this.onActionUpdate(status, action);
|
|
225
180
|
}
|
|
226
181
|
}
|
|
227
|
-
|
|
228
182
|
if (!oidc.isUserLoggedIn && oidc.initializationError !== undefined) {
|
|
229
183
|
this.onAuthError?.({
|
|
230
184
|
error: oidc.initializationError.name,
|
|
231
185
|
error_description: oidc.initializationError.message
|
|
232
186
|
});
|
|
233
187
|
}
|
|
234
|
-
|
|
235
188
|
internalState.dInitialized.resolve();
|
|
236
|
-
|
|
237
189
|
this.onReady?.(oidc.isUserLoggedIn);
|
|
238
190
|
if (oidc.isUserLoggedIn) {
|
|
239
191
|
this.onAuthSuccess?.();
|
|
240
192
|
}
|
|
241
|
-
|
|
242
193
|
return oidc.isUserLoggedIn;
|
|
243
194
|
}
|
|
244
|
-
|
|
245
195
|
/**
|
|
246
196
|
* Is true if the user is authenticated, false otherwise.
|
|
247
197
|
*/
|
|
248
|
-
get authenticated()
|
|
198
|
+
get authenticated() {
|
|
249
199
|
if (!this.didInitialize) {
|
|
250
200
|
return false;
|
|
251
201
|
}
|
|
252
|
-
|
|
253
202
|
const internalState = internalStateByInstance.get(this);
|
|
254
|
-
|
|
255
203
|
assert(internalState !== undefined);
|
|
256
|
-
|
|
257
204
|
const { oidc } = internalState;
|
|
258
|
-
|
|
259
205
|
assert(oidc !== undefined);
|
|
260
|
-
|
|
261
206
|
return oidc.isUserLoggedIn;
|
|
262
207
|
}
|
|
263
|
-
|
|
264
208
|
/**
|
|
265
209
|
* The user id.
|
|
266
210
|
*/
|
|
267
|
-
get subject()
|
|
211
|
+
get subject() {
|
|
268
212
|
if (!this.didInitialize) {
|
|
269
213
|
return undefined;
|
|
270
214
|
}
|
|
271
|
-
|
|
272
215
|
const internalState = internalStateByInstance.get(this);
|
|
273
|
-
|
|
274
216
|
assert(internalState !== undefined);
|
|
275
|
-
|
|
276
217
|
const { oidc, tokens } = internalState;
|
|
277
|
-
|
|
278
218
|
assert(oidc !== undefined);
|
|
279
|
-
|
|
280
219
|
if (!oidc.isUserLoggedIn) {
|
|
281
|
-
console.warn(
|
|
282
|
-
"Trying to read keycloak.subject when keycloak.authenticated is false is a logical error in your application"
|
|
283
|
-
);
|
|
220
|
+
console.warn("Trying to read keycloak.subject when keycloak.authenticated is false is a logical error in your application");
|
|
284
221
|
return undefined;
|
|
285
222
|
}
|
|
286
|
-
|
|
287
223
|
assert(tokens !== undefined);
|
|
288
|
-
|
|
289
224
|
return tokens.decodedIdToken_original.sub;
|
|
290
225
|
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Response mode passed in init (default value is `'fragment'`).
|
|
294
|
-
*
|
|
295
|
-
* NOTE oidc-spa: Can only be fragment.
|
|
296
|
-
*/
|
|
297
|
-
responseMode = "fragment";
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Response type sent to Keycloak with login requests. This is determined
|
|
301
|
-
* based on the flow value used during initialization, but can be overridden
|
|
302
|
-
* by setting this value.
|
|
303
|
-
*
|
|
304
|
-
* NOTE oidc-spa: Can only be 'code'
|
|
305
|
-
*/
|
|
306
|
-
responseType = "code";
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Flow passed in init.
|
|
310
|
-
*
|
|
311
|
-
* NOTE oidc-spa: Can only be 'standard'
|
|
312
|
-
*/
|
|
313
|
-
flow = "standard";
|
|
314
|
-
|
|
315
226
|
/**
|
|
316
227
|
* The realm roles associated with the token.
|
|
317
228
|
*/
|
|
318
|
-
get realmAccess()
|
|
229
|
+
get realmAccess() {
|
|
319
230
|
if (!this.didInitialize) {
|
|
320
231
|
return undefined;
|
|
321
232
|
}
|
|
322
|
-
|
|
323
233
|
const internalState = internalStateByInstance.get(this);
|
|
324
|
-
|
|
325
234
|
assert(internalState !== undefined);
|
|
326
|
-
|
|
327
235
|
const { oidc, tokens } = internalState;
|
|
328
|
-
|
|
329
236
|
assert(oidc !== undefined);
|
|
330
|
-
|
|
331
237
|
if (!oidc.isUserLoggedIn) {
|
|
332
|
-
console.warn(
|
|
333
|
-
"Trying to read keycloak.realAccess when keycloak.realmAccess is false is a logical error in your application"
|
|
334
|
-
);
|
|
238
|
+
console.warn("Trying to read keycloak.realAccess when keycloak.realmAccess is false is a logical error in your application");
|
|
335
239
|
return undefined;
|
|
336
240
|
}
|
|
337
|
-
|
|
338
241
|
assert(tokens !== undefined);
|
|
339
|
-
assert(is
|
|
340
|
-
|
|
242
|
+
assert(is(tokens.decodedIdToken_original));
|
|
341
243
|
return tokens.decodedIdToken_original.realm_access;
|
|
342
244
|
}
|
|
343
|
-
|
|
344
245
|
/**
|
|
345
246
|
* The resource roles associated with the token.
|
|
346
247
|
*/
|
|
347
|
-
get resourceAccess()
|
|
248
|
+
get resourceAccess() {
|
|
348
249
|
if (!this.didInitialize) {
|
|
349
250
|
return undefined;
|
|
350
251
|
}
|
|
351
|
-
|
|
352
252
|
const internalState = internalStateByInstance.get(this);
|
|
353
|
-
|
|
354
253
|
assert(internalState !== undefined);
|
|
355
|
-
|
|
356
254
|
const { oidc, tokens } = internalState;
|
|
357
|
-
|
|
358
255
|
assert(oidc !== undefined);
|
|
359
|
-
|
|
360
256
|
if (!oidc.isUserLoggedIn) {
|
|
361
|
-
console.warn(
|
|
362
|
-
"Trying to read keycloak.resourceAccess when keycloak.authenticated is false is a logical error in your application"
|
|
363
|
-
);
|
|
257
|
+
console.warn("Trying to read keycloak.resourceAccess when keycloak.authenticated is false is a logical error in your application");
|
|
364
258
|
return undefined;
|
|
365
259
|
}
|
|
366
|
-
|
|
367
260
|
assert(tokens !== undefined);
|
|
368
|
-
assert(is
|
|
369
|
-
|
|
261
|
+
assert(is(tokens.decodedIdToken_original));
|
|
370
262
|
return tokens.decodedIdToken_original.resource_access;
|
|
371
263
|
}
|
|
372
|
-
|
|
373
264
|
/**
|
|
374
265
|
* The base64 encoded token that can be sent in the Authorization header in
|
|
375
266
|
* requests to services.
|
|
376
267
|
*/
|
|
377
|
-
get token()
|
|
268
|
+
get token() {
|
|
378
269
|
const internalState = internalStateByInstance.get(this);
|
|
379
|
-
|
|
380
270
|
assert(internalState !== undefined);
|
|
381
|
-
|
|
382
271
|
if (!this.didInitialize) {
|
|
383
272
|
return internalState.initOptions?.token;
|
|
384
273
|
}
|
|
385
|
-
|
|
386
274
|
const { oidc, tokens } = internalState;
|
|
387
|
-
|
|
388
275
|
assert(oidc !== undefined);
|
|
389
|
-
|
|
390
276
|
if (!oidc.isUserLoggedIn) {
|
|
391
|
-
console.warn(
|
|
392
|
-
"Trying to read keycloak.token when keycloak.token is false is a logical error in your application"
|
|
393
|
-
);
|
|
277
|
+
console.warn("Trying to read keycloak.token when keycloak.token is false is a logical error in your application");
|
|
394
278
|
return undefined;
|
|
395
279
|
}
|
|
396
|
-
|
|
397
280
|
assert(tokens !== undefined);
|
|
398
|
-
|
|
399
281
|
return tokens.accessToken;
|
|
400
282
|
}
|
|
401
|
-
|
|
402
283
|
/**
|
|
403
284
|
* The parsed token as a JavaScript object.
|
|
404
285
|
*/
|
|
405
|
-
get tokenParsed()
|
|
286
|
+
get tokenParsed() {
|
|
406
287
|
const internalState = internalStateByInstance.get(this);
|
|
407
|
-
|
|
408
288
|
assert(internalState !== undefined);
|
|
409
|
-
|
|
410
289
|
if (!this.didInitialize) {
|
|
411
290
|
const { token } = internalState.initOptions ?? {};
|
|
412
|
-
|
|
413
291
|
if (token === undefined) {
|
|
414
292
|
return undefined;
|
|
415
293
|
}
|
|
416
|
-
|
|
417
|
-
return decodeJwt(token) as KeycloakTokenParsed;
|
|
294
|
+
return decodeJwt(token);
|
|
418
295
|
}
|
|
419
|
-
|
|
420
296
|
const { oidc, tokens } = internalState;
|
|
421
|
-
|
|
422
297
|
assert(oidc !== undefined);
|
|
423
|
-
|
|
424
298
|
if (!oidc.isUserLoggedIn) {
|
|
425
|
-
console.warn(
|
|
426
|
-
"Trying to read keycloak.token when keycloak.tokenParsed is false is a logical error in your application"
|
|
427
|
-
);
|
|
299
|
+
console.warn("Trying to read keycloak.token when keycloak.tokenParsed is false is a logical error in your application");
|
|
428
300
|
return undefined;
|
|
429
301
|
}
|
|
430
|
-
|
|
431
302
|
assert(tokens !== undefined);
|
|
432
|
-
|
|
433
303
|
return decodeJwt(tokens.accessToken);
|
|
434
304
|
}
|
|
435
|
-
|
|
436
305
|
/**
|
|
437
306
|
* The base64 encoded refresh token that can be used to retrieve a new token.
|
|
438
307
|
*/
|
|
439
|
-
get refreshToken()
|
|
308
|
+
get refreshToken() {
|
|
440
309
|
const internalState = internalStateByInstance.get(this);
|
|
441
|
-
|
|
442
310
|
assert(internalState !== undefined);
|
|
443
|
-
|
|
444
311
|
if (!this.didInitialize) {
|
|
445
312
|
return internalState.initOptions?.refreshToken;
|
|
446
313
|
}
|
|
447
|
-
|
|
448
314
|
const { oidc, tokens } = internalState;
|
|
449
|
-
|
|
450
315
|
assert(oidc !== undefined);
|
|
451
|
-
|
|
452
316
|
if (!oidc.isUserLoggedIn) {
|
|
453
|
-
console.warn(
|
|
454
|
-
"Trying to read keycloak.token when keycloak.refreshToken is false is a logical error in your application"
|
|
455
|
-
);
|
|
317
|
+
console.warn("Trying to read keycloak.token when keycloak.refreshToken is false is a logical error in your application");
|
|
456
318
|
return undefined;
|
|
457
319
|
}
|
|
458
|
-
|
|
459
320
|
assert(tokens !== undefined);
|
|
460
|
-
|
|
461
321
|
return tokens.refreshToken;
|
|
462
322
|
}
|
|
463
|
-
|
|
464
323
|
/**
|
|
465
324
|
* The parsed refresh token as a JavaScript object.
|
|
466
325
|
*/
|
|
467
|
-
get refreshTokenParsed()
|
|
326
|
+
get refreshTokenParsed() {
|
|
468
327
|
const internalState = internalStateByInstance.get(this);
|
|
469
|
-
|
|
470
328
|
assert(internalState !== undefined);
|
|
471
|
-
|
|
472
329
|
if (!this.didInitialize) {
|
|
473
330
|
const { refreshToken } = internalState.initOptions ?? {};
|
|
474
|
-
|
|
475
331
|
if (refreshToken === undefined) {
|
|
476
332
|
return undefined;
|
|
477
333
|
}
|
|
478
|
-
|
|
479
|
-
return decodeJwt(refreshToken) as KeycloakTokenParsed;
|
|
334
|
+
return decodeJwt(refreshToken);
|
|
480
335
|
}
|
|
481
|
-
|
|
482
336
|
const { oidc, tokens } = internalState;
|
|
483
|
-
|
|
484
337
|
assert(oidc !== undefined);
|
|
485
|
-
|
|
486
338
|
if (!oidc.isUserLoggedIn) {
|
|
487
|
-
console.warn(
|
|
488
|
-
"Trying to read keycloak.token when keycloak.refreshTokenParsed is false is a logical error in your application"
|
|
489
|
-
);
|
|
339
|
+
console.warn("Trying to read keycloak.token when keycloak.refreshTokenParsed is false is a logical error in your application");
|
|
490
340
|
return undefined;
|
|
491
341
|
}
|
|
492
|
-
|
|
493
342
|
assert(tokens !== undefined);
|
|
494
|
-
|
|
495
343
|
if (tokens.refreshToken === undefined) {
|
|
496
344
|
return undefined;
|
|
497
345
|
}
|
|
498
|
-
|
|
499
|
-
return decodeJwt(tokens.refreshToken) as KeycloakTokenParsed;
|
|
346
|
+
return decodeJwt(tokens.refreshToken);
|
|
500
347
|
}
|
|
501
|
-
|
|
502
348
|
/**
|
|
503
349
|
* The base64 encoded ID token.
|
|
504
350
|
*/
|
|
505
|
-
get idToken()
|
|
351
|
+
get idToken() {
|
|
506
352
|
const internalState = internalStateByInstance.get(this);
|
|
507
|
-
|
|
508
353
|
assert(internalState !== undefined);
|
|
509
|
-
|
|
510
354
|
if (!this.didInitialize) {
|
|
511
355
|
return internalState.initOptions?.idToken;
|
|
512
356
|
}
|
|
513
|
-
|
|
514
357
|
const { oidc, tokens } = internalState;
|
|
515
|
-
|
|
516
358
|
assert(oidc !== undefined);
|
|
517
|
-
|
|
518
359
|
if (!oidc.isUserLoggedIn) {
|
|
519
|
-
console.warn(
|
|
520
|
-
"Trying to read keycloak.token when keycloak.token is false is a logical error in your application"
|
|
521
|
-
);
|
|
360
|
+
console.warn("Trying to read keycloak.token when keycloak.token is false is a logical error in your application");
|
|
522
361
|
return undefined;
|
|
523
362
|
}
|
|
524
|
-
|
|
525
363
|
assert(tokens !== undefined);
|
|
526
|
-
|
|
527
364
|
return tokens.idToken;
|
|
528
365
|
}
|
|
529
|
-
|
|
530
366
|
/**
|
|
531
367
|
* The parsed id token as a JavaScript object.
|
|
532
368
|
*/
|
|
533
|
-
get idTokenParsed()
|
|
369
|
+
get idTokenParsed() {
|
|
534
370
|
const internalState = internalStateByInstance.get(this);
|
|
535
|
-
|
|
536
371
|
assert(internalState !== undefined);
|
|
537
|
-
|
|
538
372
|
if (!this.didInitialize) {
|
|
539
373
|
const { idToken } = internalState.initOptions ?? {};
|
|
540
|
-
|
|
541
374
|
if (idToken === undefined) {
|
|
542
375
|
return undefined;
|
|
543
376
|
}
|
|
544
|
-
|
|
545
|
-
return decodeJwt(idToken) as KeycloakTokenParsed;
|
|
377
|
+
return decodeJwt(idToken);
|
|
546
378
|
}
|
|
547
|
-
|
|
548
379
|
const { oidc, tokens } = internalState;
|
|
549
|
-
|
|
550
380
|
assert(oidc !== undefined);
|
|
551
|
-
|
|
552
381
|
if (!oidc.isUserLoggedIn) {
|
|
553
|
-
console.warn(
|
|
554
|
-
"Trying to read keycloak.token when keycloak.refreshTokenParsed is false is a logical error in your application"
|
|
555
|
-
);
|
|
382
|
+
console.warn("Trying to read keycloak.token when keycloak.refreshTokenParsed is false is a logical error in your application");
|
|
556
383
|
return undefined;
|
|
557
384
|
}
|
|
558
|
-
|
|
559
385
|
assert(tokens !== undefined);
|
|
560
|
-
assert(is
|
|
561
|
-
|
|
386
|
+
assert(is(tokens.decodedIdToken_original));
|
|
562
387
|
return tokens.decodedIdToken_original;
|
|
563
388
|
}
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* The estimated time difference between the browser time and the Keycloak
|
|
567
|
-
* server in seconds. This value is just an estimation, but is accurate
|
|
568
|
-
* enough when determining if a token is expired or not.
|
|
569
|
-
*
|
|
570
|
-
* NOTE oidc-spa: Not supported.
|
|
571
|
-
*/
|
|
572
|
-
timeSkew = null;
|
|
573
|
-
|
|
574
389
|
/**
|
|
575
390
|
* Whether the instance has been initialized by calling `.init()`.
|
|
576
391
|
*/
|
|
577
|
-
get didInitialize()
|
|
392
|
+
get didInitialize() {
|
|
578
393
|
const internalState = internalStateByInstance.get(this);
|
|
579
394
|
assert(internalState !== undefined);
|
|
580
395
|
return internalState.oidc !== undefined;
|
|
581
396
|
}
|
|
582
|
-
|
|
583
397
|
/**
|
|
584
398
|
* @private Undocumented.
|
|
585
399
|
*/
|
|
586
|
-
get loginRequired()
|
|
400
|
+
get loginRequired() {
|
|
587
401
|
const internalState = internalStateByInstance.get(this);
|
|
588
402
|
assert(internalState !== undefined);
|
|
589
|
-
|
|
590
403
|
const { initOptions } = internalState;
|
|
591
|
-
|
|
592
404
|
if (initOptions === undefined) {
|
|
593
405
|
return false;
|
|
594
406
|
}
|
|
595
|
-
|
|
596
407
|
return initOptions.onLoad === "login-required";
|
|
597
408
|
}
|
|
598
|
-
|
|
599
409
|
/**
|
|
600
410
|
* @private Undocumented.
|
|
601
411
|
*/
|
|
602
|
-
get authServerUrl()
|
|
412
|
+
get authServerUrl() {
|
|
603
413
|
const internalState = internalStateByInstance.get(this);
|
|
604
414
|
assert(internalState !== undefined);
|
|
605
|
-
const {
|
|
606
|
-
keycloakUtils: { issuerUriParsed }
|
|
607
|
-
} = internalState;
|
|
608
|
-
|
|
415
|
+
const { keycloakUtils: { issuerUriParsed } } = internalState;
|
|
609
416
|
return `${issuerUriParsed.origin}${issuerUriParsed.kcHttpRelativePath}`;
|
|
610
417
|
}
|
|
611
|
-
|
|
612
418
|
/**
|
|
613
419
|
* @private Undocumented.
|
|
614
420
|
*/
|
|
615
|
-
get realm()
|
|
421
|
+
get realm() {
|
|
616
422
|
const internalState = internalStateByInstance.get(this);
|
|
617
423
|
assert(internalState !== undefined);
|
|
618
|
-
const {
|
|
619
|
-
keycloakUtils: { issuerUriParsed }
|
|
620
|
-
} = internalState;
|
|
621
|
-
|
|
424
|
+
const { keycloakUtils: { issuerUriParsed } } = internalState;
|
|
622
425
|
return issuerUriParsed.realm;
|
|
623
426
|
}
|
|
624
|
-
|
|
625
427
|
/**
|
|
626
428
|
* @private Undocumented.
|
|
627
429
|
*/
|
|
628
|
-
get clientId()
|
|
430
|
+
get clientId() {
|
|
629
431
|
const internalState = internalStateByInstance.get(this);
|
|
630
432
|
assert(internalState !== undefined);
|
|
631
433
|
const { constructorParams } = internalState;
|
|
632
434
|
return constructorParams.clientId;
|
|
633
435
|
}
|
|
634
|
-
|
|
635
436
|
/**
|
|
636
437
|
* @private Undocumented.
|
|
637
438
|
*/
|
|
638
|
-
get redirectUri()
|
|
439
|
+
get redirectUri() {
|
|
639
440
|
const internalState = internalStateByInstance.get(this);
|
|
640
441
|
assert(internalState !== undefined);
|
|
641
442
|
const { initOptions } = internalState;
|
|
@@ -644,84 +445,50 @@ export class Keycloak {
|
|
|
644
445
|
}
|
|
645
446
|
return initOptions.redirectUri;
|
|
646
447
|
}
|
|
647
|
-
|
|
648
448
|
/**
|
|
649
449
|
* @private Undocumented.
|
|
650
450
|
*/
|
|
651
|
-
get sessionId()
|
|
451
|
+
get sessionId() {
|
|
652
452
|
if (!this.didInitialize) {
|
|
653
453
|
return undefined;
|
|
654
454
|
}
|
|
655
|
-
|
|
656
455
|
const internalState = internalStateByInstance.get(this);
|
|
657
456
|
assert(internalState !== undefined);
|
|
658
457
|
const { oidc, tokens } = internalState;
|
|
659
|
-
|
|
660
458
|
assert(oidc !== undefined);
|
|
661
|
-
|
|
662
459
|
if (!oidc.isUserLoggedIn) {
|
|
663
|
-
console.warn(
|
|
664
|
-
"Trying to read keycloak.sessionId when keycloak.authenticated is false is a logical error in your application"
|
|
665
|
-
);
|
|
460
|
+
console.warn("Trying to read keycloak.sessionId when keycloak.authenticated is false is a logical error in your application");
|
|
666
461
|
return undefined;
|
|
667
462
|
}
|
|
668
|
-
|
|
669
463
|
assert(tokens !== undefined);
|
|
670
|
-
|
|
671
464
|
const { sid } = tokens.decodedIdToken_original;
|
|
672
|
-
|
|
673
465
|
assert(typeof sid === "string");
|
|
674
|
-
|
|
675
466
|
return sid;
|
|
676
467
|
}
|
|
677
|
-
|
|
678
468
|
/**
|
|
679
469
|
* @private Undocumented.
|
|
680
470
|
*/
|
|
681
|
-
get profile()
|
|
471
|
+
get profile() {
|
|
682
472
|
const internalState = internalStateByInstance.get(this);
|
|
683
473
|
assert(internalState !== undefined);
|
|
684
474
|
const { profile } = internalState;
|
|
685
475
|
return profile;
|
|
686
476
|
}
|
|
687
|
-
|
|
688
477
|
/**
|
|
689
478
|
* @private Undocumented.
|
|
690
479
|
*/
|
|
691
|
-
get userInfo()
|
|
480
|
+
get userInfo() {
|
|
692
481
|
const internalState = internalStateByInstance.get(this);
|
|
693
482
|
assert(internalState !== undefined);
|
|
694
483
|
const { userInfo } = internalState;
|
|
695
484
|
return userInfo;
|
|
696
485
|
}
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
* Called when the adapter is initialized.
|
|
700
|
-
*/
|
|
701
|
-
onReady?(authenticated: boolean): void;
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
* Called when a user is successfully authenticated.
|
|
705
|
-
*/
|
|
706
|
-
onAuthSuccess?(): void;
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
* Called if there was an error during authentication.
|
|
710
|
-
*/
|
|
711
|
-
onAuthError?(errorData: KeycloakError): void;
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
* Called when the token is refreshed.
|
|
715
|
-
*/
|
|
716
|
-
onAuthRefreshSuccess?(): void;
|
|
717
|
-
|
|
718
486
|
/**
|
|
719
487
|
* Called if there was an error while trying to refresh the token.
|
|
720
488
|
*
|
|
721
489
|
* NOTE oidc-spa: In oidc-spa an auth refresh error always triggers a page refresh.
|
|
722
490
|
*/
|
|
723
491
|
//onAuthRefreshError?(): void;
|
|
724
|
-
|
|
725
492
|
/**
|
|
726
493
|
* Called if the user is logged out (will only be called if the session
|
|
727
494
|
* status iframe is enabled, or in Cordova mode).
|
|
@@ -729,14 +496,13 @@ export class Keycloak {
|
|
|
729
496
|
* NOTE oidc-spa: In oidc-spa a logout always triggers a page refresh.
|
|
730
497
|
*/
|
|
731
498
|
//onAuthLogout?(): void;
|
|
732
|
-
|
|
733
499
|
/**
|
|
734
500
|
* Called when the access token is expired. If a refresh token is available
|
|
735
501
|
* the token can be refreshed with Keycloak#updateToken, or in cases where
|
|
736
502
|
* it's not (ie. with implicit flow) you can redirect to login screen to
|
|
737
503
|
* obtain a new access token.
|
|
738
504
|
*/
|
|
739
|
-
set onTokenExpired(value
|
|
505
|
+
set onTokenExpired(value) {
|
|
740
506
|
const internalState = internalStateByInstance.get(this);
|
|
741
507
|
assert(internalState !== undefined);
|
|
742
508
|
const { $onTokenExpired } = internalState;
|
|
@@ -748,62 +514,35 @@ export class Keycloak {
|
|
|
748
514
|
const { $onTokenExpired } = internalState;
|
|
749
515
|
return $onTokenExpired.current;
|
|
750
516
|
}
|
|
751
|
-
|
|
752
|
-
/**
|
|
753
|
-
* Called when a AIA has been requested by the application.
|
|
754
|
-
* @param status the outcome of the required action
|
|
755
|
-
* @param action the alias name of the required action, e.g. UPDATE_PASSWORD, CONFIGURE_TOTP etc.
|
|
756
|
-
*/
|
|
757
|
-
onActionUpdate?(status: "success" | "cancelled" | "error", action?: string): void;
|
|
758
|
-
|
|
759
517
|
/**
|
|
760
518
|
* Redirects to login form.
|
|
761
519
|
* @param options Login options.
|
|
762
520
|
*/
|
|
763
|
-
async login(
|
|
764
|
-
|
|
765
|
-
): Promise<never> {
|
|
766
|
-
const {
|
|
767
|
-
redirectUri,
|
|
768
|
-
action,
|
|
769
|
-
loginHint,
|
|
770
|
-
acr,
|
|
771
|
-
acrValues,
|
|
772
|
-
idpHint,
|
|
773
|
-
locale,
|
|
774
|
-
doesCurrentHrefRequiresAuth
|
|
775
|
-
} = options ?? {};
|
|
776
|
-
|
|
521
|
+
async login(options) {
|
|
522
|
+
const { redirectUri, action, loginHint, acr, acrValues, idpHint, locale, doesCurrentHrefRequiresAuth } = options ?? {};
|
|
777
523
|
const internalState = internalStateByInstance.get(this);
|
|
778
524
|
assert(internalState !== undefined);
|
|
779
|
-
|
|
780
525
|
if (!this.didInitialize) {
|
|
781
526
|
await internalState.dInitialized.pr;
|
|
782
527
|
}
|
|
783
|
-
|
|
784
528
|
const { oidc, keycloakUtils } = internalState;
|
|
785
|
-
|
|
786
529
|
assert(oidc !== undefined);
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
}
|
|
796
|
-
}),
|
|
530
|
+
const extraQueryParams_commons = {
|
|
531
|
+
claims: acr === undefined
|
|
532
|
+
? undefined
|
|
533
|
+
: JSON.stringify({
|
|
534
|
+
id_token: {
|
|
535
|
+
acr
|
|
536
|
+
}
|
|
537
|
+
}),
|
|
797
538
|
acr_values: acrValues,
|
|
798
539
|
ui_locales: locale
|
|
799
540
|
};
|
|
800
|
-
|
|
801
541
|
if (oidc.isUserLoggedIn) {
|
|
802
542
|
assert(action !== "register");
|
|
803
543
|
assert(loginHint === undefined);
|
|
804
544
|
assert(idpHint === undefined);
|
|
805
545
|
assert(doesCurrentHrefRequiresAuth === undefined);
|
|
806
|
-
|
|
807
546
|
await oidc.goToAuthServer({
|
|
808
547
|
redirectUrl: redirectUri,
|
|
809
548
|
extraQueryParams: {
|
|
@@ -814,9 +553,7 @@ export class Keycloak {
|
|
|
814
553
|
});
|
|
815
554
|
assert(false);
|
|
816
555
|
}
|
|
817
|
-
|
|
818
556
|
assert(action === undefined || action === "register");
|
|
819
|
-
|
|
820
557
|
await oidc.login({
|
|
821
558
|
redirectUrl: redirectUri,
|
|
822
559
|
doesCurrentHrefRequiresAuth: doesCurrentHrefRequiresAuth ?? false,
|
|
@@ -825,34 +562,25 @@ export class Keycloak {
|
|
|
825
562
|
login_hint: loginHint,
|
|
826
563
|
kc_idp_hint: idpHint
|
|
827
564
|
},
|
|
828
|
-
transformUrlBeforeRedirect:
|
|
829
|
-
action !== "register" ? undefined : keycloakUtils.transformUrlBeforeRedirectForRegister
|
|
565
|
+
transformUrlBeforeRedirect: action !== "register" ? undefined : keycloakUtils.transformUrlBeforeRedirectForRegister
|
|
830
566
|
});
|
|
831
567
|
assert(false);
|
|
832
568
|
}
|
|
833
|
-
|
|
834
569
|
/**
|
|
835
570
|
* Redirects to logout.
|
|
836
571
|
* @param options Logout options.
|
|
837
572
|
*/
|
|
838
|
-
async logout(options
|
|
573
|
+
async logout(options) {
|
|
839
574
|
const internalState = internalStateByInstance.get(this);
|
|
840
|
-
|
|
841
575
|
assert(internalState !== undefined);
|
|
842
|
-
|
|
843
576
|
if (!this.didInitialize) {
|
|
844
577
|
await internalState.dInitialized.pr;
|
|
845
578
|
}
|
|
846
|
-
|
|
847
579
|
const { oidc, initOptions } = internalState;
|
|
848
|
-
|
|
849
580
|
assert(oidc !== undefined);
|
|
850
581
|
assert(initOptions !== undefined);
|
|
851
|
-
|
|
852
582
|
assert(oidc.isUserLoggedIn, "The user is not currently logged in");
|
|
853
|
-
|
|
854
583
|
const redirectUri = options?.redirectUri ?? initOptions.redirectUri;
|
|
855
|
-
|
|
856
584
|
await oidc.logout({
|
|
857
585
|
...(redirectUri === undefined
|
|
858
586
|
? { redirectTo: "current page" }
|
|
@@ -860,37 +588,27 @@ export class Keycloak {
|
|
|
860
588
|
});
|
|
861
589
|
assert(false);
|
|
862
590
|
}
|
|
863
|
-
|
|
864
591
|
/**
|
|
865
592
|
* Redirects to registration form.
|
|
866
593
|
* @param options The options used for the registration.
|
|
867
594
|
*/
|
|
868
|
-
async register(options
|
|
595
|
+
async register(options) {
|
|
869
596
|
return this.login({
|
|
870
597
|
...options,
|
|
871
598
|
action: "register"
|
|
872
599
|
});
|
|
873
600
|
}
|
|
874
|
-
|
|
875
601
|
/**
|
|
876
602
|
* Redirects to the Account Management Console.
|
|
877
603
|
*/
|
|
878
|
-
async accountManagement(options
|
|
879
|
-
/**
|
|
880
|
-
* Specifies the uri to redirect to when redirecting back to the application.
|
|
881
|
-
*/
|
|
882
|
-
redirectUri?: string;
|
|
883
|
-
locale?: string;
|
|
884
|
-
}): Promise<never> {
|
|
604
|
+
async accountManagement(options) {
|
|
885
605
|
const { redirectUri, locale } = options ?? {};
|
|
886
|
-
|
|
887
606
|
window.location.href = this.createAccountUrl({
|
|
888
607
|
redirectUri,
|
|
889
608
|
locale
|
|
890
609
|
});
|
|
891
|
-
return new Promise
|
|
610
|
+
return new Promise(() => { });
|
|
892
611
|
}
|
|
893
|
-
|
|
894
612
|
/**
|
|
895
613
|
* Returns the URL to login form.
|
|
896
614
|
* @param options Supports same options as Keycloak#login.
|
|
@@ -898,7 +616,6 @@ export class Keycloak {
|
|
|
898
616
|
* NOTE oidc-spa: Not supported, please use login() method.
|
|
899
617
|
*/
|
|
900
618
|
//createLoginUrl(options?: KeycloakLoginOptions): Promise<string>;
|
|
901
|
-
|
|
902
619
|
/**
|
|
903
620
|
* Returns the URL to logout the user.
|
|
904
621
|
* @param options Logout options.
|
|
@@ -906,7 +623,6 @@ export class Keycloak {
|
|
|
906
623
|
* NOTE oidc-spa: Not supported, please use logout() method.
|
|
907
624
|
*/
|
|
908
625
|
//createLogoutUrl(options?: KeycloakLogoutOptions): string;
|
|
909
|
-
|
|
910
626
|
/**
|
|
911
627
|
* Returns the URL to registration page.
|
|
912
628
|
* @param options The options used for creating the registration URL.
|
|
@@ -914,63 +630,49 @@ export class Keycloak {
|
|
|
914
630
|
* NOTE oidc-spa: Not supported please user login({ action: "register" })
|
|
915
631
|
*/
|
|
916
632
|
//createRegisterUrl(options?: KeycloakRegisterOptions): Promise<string>;
|
|
917
|
-
|
|
918
633
|
/**
|
|
919
634
|
* Returns the URL to the Account Management Console.
|
|
920
635
|
* @param options The options used for creating the account URL.
|
|
921
636
|
*/
|
|
922
|
-
createAccountUrl(options
|
|
637
|
+
createAccountUrl(options) {
|
|
923
638
|
const { locale, redirectUri } = options ?? {};
|
|
924
|
-
|
|
925
639
|
const internalState = internalStateByInstance.get(this);
|
|
926
|
-
|
|
927
640
|
assert(internalState !== undefined);
|
|
928
|
-
|
|
929
641
|
const { keycloakUtils } = internalState;
|
|
930
|
-
|
|
931
642
|
return keycloakUtils.getAccountUrl({
|
|
932
643
|
clientId: this.clientId,
|
|
933
644
|
backToAppFromAccountUrl: redirectUri ?? location.href,
|
|
934
645
|
locale
|
|
935
646
|
});
|
|
936
647
|
}
|
|
937
|
-
|
|
938
648
|
/**
|
|
939
649
|
* Returns true if the token has less than `minValidity` seconds left before
|
|
940
650
|
* it expires.
|
|
941
651
|
* @param minValidity If not specified, `0` is used.
|
|
942
652
|
*/
|
|
943
|
-
isTokenExpired(minValidity
|
|
653
|
+
isTokenExpired(minValidity = 0) {
|
|
944
654
|
const internalState = internalStateByInstance.get(this);
|
|
945
655
|
assert(internalState !== undefined);
|
|
946
|
-
|
|
947
|
-
let accessTokenExpirationTime: number;
|
|
948
|
-
|
|
656
|
+
let accessTokenExpirationTime;
|
|
949
657
|
if (!this.didInitialize) {
|
|
950
658
|
const fakeAccessToken = this.token;
|
|
951
659
|
if (fakeAccessToken === undefined) {
|
|
952
660
|
throw new Error("isTokenExpired was called too early");
|
|
953
661
|
}
|
|
954
|
-
|
|
955
662
|
const time = readExpirationTimeInJwt(fakeAccessToken);
|
|
956
|
-
|
|
957
663
|
assert(time !== undefined, "The initial token is not a JWT");
|
|
958
|
-
|
|
959
664
|
accessTokenExpirationTime = time;
|
|
960
|
-
}
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
961
667
|
const { tokens } = internalState;
|
|
962
668
|
assert(tokens !== undefined);
|
|
963
|
-
|
|
964
669
|
accessTokenExpirationTime = tokens.accessTokenExpirationTime;
|
|
965
670
|
}
|
|
966
|
-
|
|
967
|
-
if (accessTokenExpirationTime > Date.now() + minValidity * 1_000) {
|
|
671
|
+
if (accessTokenExpirationTime > Date.now() + minValidity * 1000) {
|
|
968
672
|
return false;
|
|
969
673
|
}
|
|
970
|
-
|
|
971
674
|
return true;
|
|
972
675
|
}
|
|
973
|
-
|
|
974
676
|
/**
|
|
975
677
|
* If the token expires within `minValidity` seconds, the token is refreshed.
|
|
976
678
|
* If the session status iframe is enabled, the session status is also
|
|
@@ -990,30 +692,21 @@ export class Keycloak {
|
|
|
990
692
|
* alert('Failed to refresh the token, or the session has expired');
|
|
991
693
|
* });
|
|
992
694
|
*/
|
|
993
|
-
async updateToken(minValidity
|
|
695
|
+
async updateToken(minValidity = 5) {
|
|
994
696
|
const internalState = internalStateByInstance.get(this);
|
|
995
|
-
|
|
996
697
|
assert(internalState !== undefined);
|
|
997
|
-
|
|
998
698
|
if (!this.didInitialize) {
|
|
999
699
|
await internalState.dInitialized.pr;
|
|
1000
700
|
}
|
|
1001
|
-
|
|
1002
701
|
const { oidc } = internalState;
|
|
1003
|
-
|
|
1004
702
|
assert(oidc !== undefined);
|
|
1005
|
-
|
|
1006
703
|
assert(oidc.isUserLoggedIn, "updateToken called too early");
|
|
1007
|
-
|
|
1008
704
|
if (!this.isTokenExpired(minValidity)) {
|
|
1009
705
|
return false;
|
|
1010
706
|
}
|
|
1011
|
-
|
|
1012
707
|
await oidc.renewTokens();
|
|
1013
|
-
|
|
1014
708
|
return true;
|
|
1015
709
|
}
|
|
1016
|
-
|
|
1017
710
|
/**
|
|
1018
711
|
* Clears authentication state, including tokens. This can be useful if
|
|
1019
712
|
* the application has detected the session was expired, for example if
|
|
@@ -1026,72 +719,56 @@ export class Keycloak {
|
|
|
1026
719
|
* adapter.
|
|
1027
720
|
*/
|
|
1028
721
|
//clearToken(): void;
|
|
1029
|
-
|
|
1030
722
|
/**
|
|
1031
723
|
* Returns true if the token has the given realm role.
|
|
1032
724
|
* @param role A realm role name.
|
|
1033
725
|
*/
|
|
1034
|
-
hasRealmRole(role
|
|
726
|
+
hasRealmRole(role) {
|
|
1035
727
|
const access = this.realmAccess;
|
|
1036
728
|
return access !== undefined && access.roles.indexOf(role) >= 0;
|
|
1037
729
|
}
|
|
1038
|
-
|
|
1039
730
|
/**
|
|
1040
731
|
* Returns true if the token has the given role for the resource.
|
|
1041
732
|
* @param role A role name.
|
|
1042
733
|
* @param resource If not specified, `clientId` is used.
|
|
1043
734
|
*/
|
|
1044
|
-
hasResourceRole(role
|
|
735
|
+
hasResourceRole(role, resource) {
|
|
1045
736
|
if (this.resourceAccess === undefined) {
|
|
1046
737
|
return false;
|
|
1047
738
|
}
|
|
1048
|
-
|
|
1049
739
|
const access = this.resourceAccess[resource || this.clientId];
|
|
1050
740
|
return access !== undefined && access.roles.indexOf(role) >= 0;
|
|
1051
741
|
}
|
|
1052
|
-
|
|
1053
742
|
/**
|
|
1054
743
|
* Loads the user's profile.
|
|
1055
744
|
* @returns A promise to set functions to be invoked on success or error.
|
|
1056
745
|
*/
|
|
1057
|
-
async loadUserProfile()
|
|
746
|
+
async loadUserProfile() {
|
|
1058
747
|
const internalState = internalStateByInstance.get(this);
|
|
1059
748
|
assert(internalState !== undefined);
|
|
1060
|
-
|
|
1061
749
|
if (!this.didInitialize) {
|
|
1062
750
|
await internalState.dInitialized.pr;
|
|
1063
751
|
}
|
|
1064
|
-
|
|
1065
752
|
const { oidc, keycloakUtils } = internalState;
|
|
1066
|
-
|
|
1067
753
|
assert(oidc !== undefined);
|
|
1068
|
-
|
|
1069
754
|
assert(oidc.isUserLoggedIn, "Can't load userProfile if user not authenticated");
|
|
1070
|
-
|
|
1071
755
|
const { accessToken } = await oidc.getTokens();
|
|
1072
|
-
|
|
1073
756
|
return (internalState.profile = await keycloakUtils.fetchUserProfile({ accessToken }));
|
|
1074
757
|
}
|
|
1075
|
-
|
|
1076
758
|
/**
|
|
1077
759
|
* @private Undocumented.
|
|
1078
760
|
*/
|
|
1079
|
-
async loadUserInfo()
|
|
761
|
+
async loadUserInfo() {
|
|
1080
762
|
const internalState = internalStateByInstance.get(this);
|
|
1081
763
|
assert(internalState !== undefined);
|
|
1082
|
-
|
|
1083
764
|
if (!this.didInitialize) {
|
|
1084
765
|
await internalState.dInitialized.pr;
|
|
1085
766
|
}
|
|
1086
|
-
|
|
1087
767
|
const { oidc, keycloakUtils } = internalState;
|
|
1088
|
-
|
|
1089
768
|
assert(oidc !== undefined);
|
|
1090
|
-
|
|
1091
769
|
assert(oidc.isUserLoggedIn, "Can't load userInfo if user not authenticated");
|
|
1092
|
-
|
|
1093
770
|
const { accessToken } = await oidc.getTokens();
|
|
1094
|
-
|
|
1095
771
|
return (internalState.userInfo = await keycloakUtils.fetchUserInfo({ accessToken }));
|
|
1096
772
|
}
|
|
1097
773
|
}
|
|
774
|
+
//# sourceMappingURL=Keycloak.js.map
|