oidc-spa 7.1.9 → 7.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend.js +235 -352
- package/backend.js.map +1 -1
- package/core/AuthResponse.js +12 -49
- package/core/AuthResponse.js.map +1 -1
- package/core/Oidc.d.ts +1 -2
- package/core/OidcInitializationError.d.ts +2 -2
- package/core/OidcInitializationError.js +230 -297
- package/core/OidcInitializationError.js.map +1 -1
- package/core/OidcMetadata.js +1 -1
- package/core/OidcMetadata.js.map +1 -1
- package/core/StateData.d.ts +5 -5
- package/core/StateData.js +25 -25
- package/core/StateData.js.map +1 -1
- package/core/configId.js +1 -1
- package/core/configId.js.map +1 -1
- package/core/createOidc.d.ts +8 -0
- package/core/createOidc.js +999 -1294
- package/core/createOidc.js.map +1 -1
- package/core/evtIsUserActive.js +26 -27
- package/core/evtIsUserActive.js.map +1 -1
- package/core/handleOidcCallback.js +99 -154
- package/core/handleOidcCallback.js.map +1 -1
- package/core/iframeMessageProtection.d.ts +1 -1
- package/core/iframeMessageProtection.js +43 -108
- package/core/iframeMessageProtection.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +3 -3
- package/core/index.js.map +1 -1
- package/core/initialLocationHref.js +1 -1
- package/core/initialLocationHref.js.map +1 -1
- package/core/isNewBrowserSession.js +8 -8
- package/core/isNewBrowserSession.js.map +1 -1
- package/core/loginOrGoToAuthServer.d.ts +1 -1
- package/core/loginOrGoToAuthServer.js +188 -310
- package/core/loginOrGoToAuthServer.js.map +1 -1
- package/core/loginPropagationToOtherTabs.js +15 -16
- package/core/loginPropagationToOtherTabs.js.map +1 -1
- package/core/loginSilent.d.ts +2 -3
- package/core/loginSilent.js +118 -214
- package/core/loginSilent.js.map +1 -1
- package/core/logoutPropagationToOtherTabs.js +15 -16
- package/core/logoutPropagationToOtherTabs.js.map +1 -1
- package/core/oidcClientTsUserToTokens.d.ts +1 -1
- package/core/oidcClientTsUserToTokens.js +75 -72
- package/core/oidcClientTsUserToTokens.js.map +1 -1
- package/core/ongoingLoginOrRefreshProcesses.js +23 -89
- package/core/ongoingLoginOrRefreshProcesses.js.map +1 -1
- package/core/persistedAuthState.js +13 -13
- package/core/persistedAuthState.js.map +1 -1
- package/entrypoint.js +9 -9
- package/entrypoint.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -2
- package/index.js.map +1 -1
- package/keycloak/index.d.ts +3 -0
- package/keycloak/index.js +8 -0
- package/keycloak/index.js.map +1 -0
- package/keycloak/isKeycloak.d.ts +3 -0
- package/keycloak/isKeycloak.js +20 -0
- package/keycloak/isKeycloak.js.map +1 -0
- package/keycloak/keycloak-js/Keycloak.d.ts +284 -0
- package/keycloak/keycloak-js/Keycloak.js +778 -0
- package/keycloak/keycloak-js/Keycloak.js.map +1 -0
- package/keycloak/keycloak-js/index.d.ts +2 -0
- package/keycloak/keycloak-js/index.js +6 -0
- package/keycloak/keycloak-js/index.js.map +1 -0
- package/keycloak/keycloak-js/types.d.ts +361 -0
- package/keycloak/keycloak-js/types.js +3 -0
- package/keycloak/keycloak-js/types.js.map +1 -0
- package/keycloak/keycloakIssuerUriParsed.d.ts +9 -0
- package/keycloak/keycloakIssuerUriParsed.js +19 -0
- package/keycloak/keycloakIssuerUriParsed.js.map +1 -0
- package/keycloak/keycloakUtils.d.ts +37 -0
- package/keycloak/keycloakUtils.js +47 -0
- package/keycloak/keycloakUtils.js.map +1 -0
- package/keycloak-js.d.ts +1 -0
- package/keycloak-js.js +18 -0
- package/keycloak-js.js.map +1 -0
- package/mock/oidc.js +147 -194
- package/mock/oidc.js.map +1 -1
- package/mock/react.js +2 -2
- package/mock/react.js.map +1 -1
- package/package.json +38 -9
- package/react/react.js +133 -244
- package/react/react.js.map +1 -1
- package/src/core/AuthResponse.ts +2 -0
- package/src/core/Oidc.ts +1 -2
- package/src/core/OidcInitializationError.ts +30 -30
- package/src/core/OidcMetadata.ts +1 -1
- package/src/core/StateData.ts +24 -24
- package/src/core/createOidc.ts +24 -31
- package/src/core/handleOidcCallback.ts +44 -23
- package/src/core/iframeMessageProtection.ts +11 -10
- package/src/core/index.ts +1 -1
- package/src/core/loginOrGoToAuthServer.ts +1 -1
- package/src/core/loginSilent.ts +14 -11
- package/src/core/oidcClientTsUserToTokens.ts +1 -1
- package/src/index.ts +1 -7
- package/src/keycloak/index.ts +8 -0
- package/src/keycloak/isKeycloak.ts +23 -0
- package/src/keycloak/keycloak-js/Keycloak.ts +1097 -0
- package/src/keycloak/keycloak-js/index.ts +2 -0
- package/src/keycloak/keycloak-js/types.ts +442 -0
- package/src/keycloak/keycloakIssuerUriParsed.ts +29 -0
- package/src/keycloak/keycloakUtils.ts +90 -0
- package/src/keycloak-js.ts +1 -0
- package/src/react/react.tsx +17 -1
- package/src/tools/decodeJwt.ts +95 -2
- package/src/tools/parseKeycloakIssuerUri.ts +11 -30
- package/src/vendor/frontend/oidc-client-ts.ts +1 -0
- package/src/vendor/frontend/tsafe.ts +1 -0
- package/tools/Deferred.js +13 -35
- package/tools/Deferred.js.map +1 -1
- package/tools/EphemeralSessionStorage.js +46 -48
- package/tools/EphemeralSessionStorage.js.map +1 -1
- package/tools/Evt.js +14 -14
- package/tools/Evt.js.map +1 -1
- package/tools/StatefulEvt.js +5 -5
- package/tools/StatefulEvt.js.map +1 -1
- package/tools/asymmetricEncryption.js +81 -172
- package/tools/asymmetricEncryption.js.map +1 -1
- package/tools/base64.js +2 -2
- package/tools/base64.js.map +1 -1
- package/tools/createObjectThatThrowsIfAccessed.js +13 -61
- package/tools/createObjectThatThrowsIfAccessed.js.map +1 -1
- package/tools/decodeJwt.d.ts +25 -2
- package/tools/decodeJwt.js +61 -3
- package/tools/decodeJwt.js.map +1 -1
- package/tools/generateUrlSafeRandom.js +5 -30
- package/tools/generateUrlSafeRandom.js.map +1 -1
- package/tools/getDownlinkAndRtt.js +8 -30
- package/tools/getDownlinkAndRtt.js.map +1 -1
- package/tools/getIsOnline.js +3 -3
- package/tools/getIsOnline.js.map +1 -1
- package/tools/getIsValidRemoteJson.js +12 -59
- package/tools/getIsValidRemoteJson.js.map +1 -1
- package/tools/getPrUserInteraction.js +4 -4
- package/tools/getPrUserInteraction.js.map +1 -1
- package/tools/getUserEnvironmentInfo.js +17 -12
- package/tools/getUserEnvironmentInfo.js.map +1 -1
- package/tools/haveSharedParentDomain.js +5 -5
- package/tools/haveSharedParentDomain.js.map +1 -1
- package/tools/isDev.js +2 -2
- package/tools/isDev.js.map +1 -1
- package/tools/parseKeycloakIssuerUri.d.ts +2 -0
- package/tools/parseKeycloakIssuerUri.js +11 -42
- package/tools/parseKeycloakIssuerUri.js.map +1 -1
- package/tools/readExpirationTimeInJwt.js +4 -4
- package/tools/readExpirationTimeInJwt.js.map +1 -1
- package/tools/startCountdown.js +17 -65
- package/tools/startCountdown.js.map +1 -1
- package/tools/subscribeToUserInteraction.js +17 -66
- package/tools/subscribeToUserInteraction.js.map +1 -1
- package/tools/toFullyQualifiedUrl.js +7 -7
- package/tools/toFullyQualifiedUrl.js.map +1 -1
- package/tools/toHumanReadableDuration.js +13 -13
- package/tools/toHumanReadableDuration.js.map +1 -1
- package/tools/urlSearchParams.js +28 -50
- package/tools/urlSearchParams.js.map +1 -1
- package/tools/workerTimers.js +10 -10
- package/tools/workerTimers.js.map +1 -1
- package/vendor/frontend/oidc-client-ts.d.ts +1 -0
- package/vendor/frontend/oidc-client-ts.js +3686 -0
- package/vendor/frontend/tsafe.d.ts +1 -0
- package/vendor/frontend/tsafe.js +1 -1
- package/core/trustedFetch.d.ts +0 -2
- package/core/trustedFetch.js +0 -12
- package/core/trustedFetch.js.map +0 -1
- package/src/core/trustedFetch.ts +0 -9
- package/src/vendor/frontend/oidc-client-ts-and-jwt-decode.ts +0 -4
- package/vendor/frontend/oidc-client-ts-and-jwt-decode.d.ts +0 -3
- package/vendor/frontend/oidc-client-ts-and-jwt-decode.js +0 -3
package/src/core/loginSilent.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
UserManager as OidcClientTsUserManager,
|
|
3
|
+
User as OidcClientTsUser
|
|
4
|
+
} from "../vendor/frontend/oidc-client-ts";
|
|
2
5
|
import { Deferred } from "../tools/Deferred";
|
|
3
6
|
import { id, assert, noUndefined } from "../vendor/frontend/tsafe";
|
|
4
7
|
import { getStateData, clearStateStore, type StateData } from "./StateData";
|
|
5
8
|
import { getDownlinkAndRtt } from "../tools/getDownlinkAndRtt";
|
|
6
9
|
import { getIsDev } from "../tools/isDev";
|
|
7
|
-
import type { User as OidcClientTsUser } from "../vendor/frontend/oidc-client-ts-and-jwt-decode";
|
|
8
10
|
import { type AuthResponse } from "./AuthResponse";
|
|
9
11
|
import { addOrUpdateSearchParam } from "../tools/urlSearchParams";
|
|
10
12
|
import { initIframeMessageProtection } from "./iframeMessageProtection";
|
|
@@ -25,7 +27,7 @@ type ResultOfLoginSilent =
|
|
|
25
27
|
|
|
26
28
|
export async function loginSilent(params: {
|
|
27
29
|
oidcClientTsUserManager: OidcClientTsUserManager;
|
|
28
|
-
|
|
30
|
+
stateUrlParamValue_instance: string;
|
|
29
31
|
configId: string;
|
|
30
32
|
|
|
31
33
|
transformUrlBeforeRedirect:
|
|
@@ -41,7 +43,7 @@ export async function loginSilent(params: {
|
|
|
41
43
|
}): Promise<ResultOfLoginSilent> {
|
|
42
44
|
const {
|
|
43
45
|
oidcClientTsUserManager,
|
|
44
|
-
|
|
46
|
+
stateUrlParamValue_instance,
|
|
45
47
|
configId,
|
|
46
48
|
transformUrlBeforeRedirect,
|
|
47
49
|
getExtraQueryParams,
|
|
@@ -77,10 +79,10 @@ export async function loginSilent(params: {
|
|
|
77
79
|
|
|
78
80
|
const { decodeEncryptedAuth, getIsEncryptedAuthResponse, clearSessionStoragePublicKey } =
|
|
79
81
|
await initIframeMessageProtection({
|
|
80
|
-
|
|
82
|
+
stateUrlParamValue: stateUrlParamValue_instance
|
|
81
83
|
});
|
|
82
84
|
|
|
83
|
-
const
|
|
85
|
+
const timer = setTimeout(async () => {
|
|
84
86
|
dResult.resolve({
|
|
85
87
|
outcome: "failure",
|
|
86
88
|
cause: "timeout"
|
|
@@ -102,7 +104,7 @@ export async function loginSilent(params: {
|
|
|
102
104
|
|
|
103
105
|
const { authResponse } = await decodeEncryptedAuth({ encryptedAuthResponse: event.data });
|
|
104
106
|
|
|
105
|
-
const stateData = getStateData({
|
|
107
|
+
const stateData = getStateData({ stateUrlParamValue: authResponse.state });
|
|
106
108
|
|
|
107
109
|
assert(stateData !== undefined, "765645");
|
|
108
110
|
assert(stateData.context === "iframe", "250711");
|
|
@@ -111,7 +113,7 @@ export async function loginSilent(params: {
|
|
|
111
113
|
return;
|
|
112
114
|
}
|
|
113
115
|
|
|
114
|
-
clearTimeout(
|
|
116
|
+
clearTimeout(timer);
|
|
115
117
|
|
|
116
118
|
window.removeEventListener("message", listener);
|
|
117
119
|
|
|
@@ -164,7 +166,8 @@ export async function loginSilent(params: {
|
|
|
164
166
|
oidcClientTsUser => {
|
|
165
167
|
assert(oidcClientTsUser !== null, "oidcClientTsUser is not supposed to be null here");
|
|
166
168
|
|
|
167
|
-
clearTimeout(
|
|
169
|
+
clearTimeout(timer);
|
|
170
|
+
window.removeEventListener("message", listener);
|
|
168
171
|
|
|
169
172
|
dResult.resolve({
|
|
170
173
|
outcome: "token refreshed using refresh token",
|
|
@@ -179,7 +182,7 @@ export async function loginSilent(params: {
|
|
|
179
182
|
// is not pointing to a valid oidc server.
|
|
180
183
|
// It could be a CORS error on the well-known endpoint but it's unlikely.
|
|
181
184
|
|
|
182
|
-
clearTimeout(
|
|
185
|
+
clearTimeout(timer);
|
|
183
186
|
|
|
184
187
|
dResult.resolve({
|
|
185
188
|
outcome: "failure",
|
|
@@ -198,7 +201,7 @@ export async function loginSilent(params: {
|
|
|
198
201
|
clearSessionStoragePublicKey();
|
|
199
202
|
|
|
200
203
|
if (result.outcome === "failure") {
|
|
201
|
-
clearStateStore({
|
|
204
|
+
clearStateStore({ stateUrlParamValue: stateUrlParamValue_instance });
|
|
202
205
|
}
|
|
203
206
|
});
|
|
204
207
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { User as OidcClientTsUser } from "../vendor/frontend/oidc-client-ts
|
|
1
|
+
import type { User as OidcClientTsUser } from "../vendor/frontend/oidc-client-ts";
|
|
2
2
|
import { assert, id } from "../vendor/frontend/tsafe";
|
|
3
3
|
import { readExpirationTimeInJwt } from "../tools/readExpirationTimeInJwt";
|
|
4
4
|
import { decodeJwt } from "../tools/decodeJwt";
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function isKeycloak(params: { issuerUri: string }): boolean {
|
|
2
|
+
const { issuerUri } = params;
|
|
3
|
+
|
|
4
|
+
const url = new URL(issuerUri.replace(/\/$/, ""));
|
|
5
|
+
|
|
6
|
+
const split = url.pathname.split("/realms/");
|
|
7
|
+
|
|
8
|
+
if (split.length !== 2) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const [, realm] = split;
|
|
13
|
+
|
|
14
|
+
if (realm === "") {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (realm.includes("/")) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return true;
|
|
23
|
+
}
|