oidc-spa 8.1.4-rc.1 → 8.1.5-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/core/OidcMetadata.js +2 -2
- package/core/OidcMetadata.js.map +1 -1
- package/core/StateData.js +3 -2
- package/core/StateData.js.map +1 -1
- package/core/createOidc.js +37 -34
- package/core/createOidc.js.map +1 -1
- package/core/earlyInit.js +5 -5
- package/core/earlyInit.js.map +1 -1
- package/core/evtIsUserActive.js +5 -4
- package/core/evtIsUserActive.js.map +1 -1
- package/core/iframeMessageProtection.d.ts +1 -0
- package/core/iframeMessageProtection.js +7 -9
- package/core/iframeMessageProtection.js.map +1 -1
- package/core/loginOrGoToAuthServer.js +5 -4
- package/core/loginOrGoToAuthServer.js.map +1 -1
- package/core/loginPropagationToOtherTabs.js +2 -2
- package/core/loginPropagationToOtherTabs.js.map +1 -1
- package/core/loginSilent.d.ts +1 -0
- package/core/loginSilent.js +11 -8
- package/core/loginSilent.js.map +1 -1
- package/core/logoutPropagationToOtherTabs.js +2 -2
- package/core/logoutPropagationToOtherTabs.js.map +1 -1
- package/core/oidcClientTsUserToTokens.js +12 -11
- package/core/oidcClientTsUserToTokens.js.map +1 -1
- package/core/ongoingLoginOrRefreshProcesses.js +5 -4
- package/core/ongoingLoginOrRefreshProcesses.js.map +1 -1
- package/core/persistedAuthState.js +7 -6
- package/core/persistedAuthState.js.map +1 -1
- package/esm/angular.js +1 -1
- package/esm/angular.js.map +1 -1
- package/esm/core/OidcMetadata.js +1 -1
- package/esm/core/OidcMetadata.js.map +1 -1
- package/esm/core/StateData.js +2 -1
- package/esm/core/StateData.js.map +1 -1
- package/esm/core/createOidc.js +7 -4
- package/esm/core/createOidc.js.map +1 -1
- package/esm/core/earlyInit.js +1 -1
- package/esm/core/earlyInit.js.map +1 -1
- package/esm/core/evtIsUserActive.js +2 -1
- package/esm/core/evtIsUserActive.js.map +1 -1
- package/esm/core/iframeMessageProtection.d.ts +1 -0
- package/esm/core/iframeMessageProtection.js +6 -8
- package/esm/core/iframeMessageProtection.js.map +1 -1
- package/esm/core/loginOrGoToAuthServer.js +2 -1
- package/esm/core/loginOrGoToAuthServer.js.map +1 -1
- package/esm/core/loginPropagationToOtherTabs.js +1 -1
- package/esm/core/loginPropagationToOtherTabs.js.map +1 -1
- package/esm/core/loginSilent.d.ts +1 -0
- package/esm/core/loginSilent.js +6 -3
- package/esm/core/loginSilent.js.map +1 -1
- package/esm/core/logoutPropagationToOtherTabs.js +1 -1
- package/esm/core/logoutPropagationToOtherTabs.js.map +1 -1
- package/esm/core/oidcClientTsUserToTokens.js +2 -1
- package/esm/core/oidcClientTsUserToTokens.js.map +1 -1
- package/esm/core/ongoingLoginOrRefreshProcesses.js +2 -1
- package/esm/core/ongoingLoginOrRefreshProcesses.js.map +1 -1
- package/esm/core/persistedAuthState.js +2 -1
- package/esm/core/persistedAuthState.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/keycloak/keycloak-js/Keycloak.js +2 -1
- package/esm/keycloak/keycloak-js/Keycloak.js.map +1 -1
- package/esm/keycloak/keycloakIssuerUriParsed.js +1 -1
- package/esm/keycloak/keycloakIssuerUriParsed.js.map +1 -1
- package/esm/mock/oidc.js +1 -1
- package/esm/mock/oidc.js.map +1 -1
- package/esm/mock/react.d.ts +2 -2
- package/esm/react/react.js +2 -2
- package/esm/react/react.js.map +1 -1
- package/esm/tools/EphemeralSessionStorage.js +3 -1
- package/esm/tools/EphemeralSessionStorage.js.map +1 -1
- package/esm/tools/Evt.js +1 -1
- package/esm/tools/Evt.js.map +1 -1
- package/esm/tools/getDownlinkAndRtt.js +1 -1
- package/esm/tools/getDownlinkAndRtt.js.map +1 -1
- package/esm/tools/readExpirationTimeInJwt.js +1 -1
- package/esm/tools/readExpirationTimeInJwt.js.map +1 -1
- package/esm/tools/tsafe/Equals.d.ts +4 -0
- package/esm/tools/tsafe/Equals.js +5 -0
- package/esm/tools/tsafe/Equals.js.map +1 -0
- package/esm/tools/tsafe/Param0.d.ts +7 -0
- package/esm/tools/tsafe/Param0.js +2 -0
- package/esm/tools/tsafe/Param0.js.map +1 -0
- package/esm/tools/tsafe/Parameters.d.ts +2 -0
- package/esm/tools/tsafe/Parameters.js +2 -0
- package/esm/tools/tsafe/Parameters.js.map +1 -0
- package/esm/tools/tsafe/Reflect.d.ts +2 -0
- package/esm/tools/tsafe/Reflect.js +5 -0
- package/esm/tools/tsafe/Reflect.js.map +1 -0
- package/esm/tools/tsafe/assert.d.ts +10 -0
- package/esm/tools/tsafe/assert.js +46 -0
- package/esm/tools/tsafe/assert.js.map +1 -0
- package/esm/tools/tsafe/id.d.ts +36 -0
- package/esm/tools/tsafe/id.js +3 -0
- package/esm/tools/tsafe/id.js.map +1 -0
- package/esm/tools/tsafe/isAmong.d.ts +2 -0
- package/esm/tools/tsafe/isAmong.js +10 -0
- package/esm/tools/tsafe/isAmong.js.map +1 -0
- package/esm/tools/tsafe/noUndefined.d.ts +9 -0
- package/esm/tools/tsafe/noUndefined.js +19 -0
- package/esm/tools/tsafe/noUndefined.js.map +1 -0
- package/esm/tools/tsafe/tools/StrictEquals.d.ts +1 -0
- package/esm/tools/tsafe/tools/StrictEquals.js +2 -0
- package/esm/tools/tsafe/tools/StrictEquals.js.map +1 -0
- package/esm/tools/tsafe/tools/Unite.d.ts +3 -0
- package/esm/tools/tsafe/tools/Unite.js +2 -0
- package/esm/tools/tsafe/tools/Unite.js.map +1 -0
- package/esm/tools/tsafe/typeGuard.d.ts +2 -0
- package/esm/tools/tsafe/typeGuard.js +5 -0
- package/esm/tools/tsafe/typeGuard.js.map +1 -0
- package/index.d.ts +1 -1
- package/index.js +4 -3
- package/index.js.map +1 -1
- package/keycloak/keycloak-js/Keycloak.js +55 -54
- package/keycloak/keycloak-js/Keycloak.js.map +1 -1
- package/keycloak/keycloakIssuerUriParsed.js +3 -3
- package/keycloak/keycloakIssuerUriParsed.js.map +1 -1
- package/mock/oidc.js +4 -4
- package/mock/oidc.js.map +1 -1
- package/mock/react.d.ts +2 -2
- package/package.json +1 -1
- package/react/react.js +8 -8
- package/react/react.js.map +1 -1
- package/src/angular.ts +1 -1
- package/src/core/OidcMetadata.ts +1 -1
- package/src/core/StateData.ts +2 -1
- package/src/core/createOidc.ts +6 -3
- package/src/core/earlyInit.ts +1 -1
- package/src/core/evtIsUserActive.ts +2 -1
- package/src/core/iframeMessageProtection.ts +13 -10
- package/src/core/loginOrGoToAuthServer.ts +2 -1
- package/src/core/loginPropagationToOtherTabs.ts +1 -1
- package/src/core/loginSilent.ts +8 -3
- package/src/core/logoutPropagationToOtherTabs.ts +1 -1
- package/src/core/oidcClientTsUserToTokens.ts +2 -1
- package/src/core/ongoingLoginOrRefreshProcesses.ts +2 -1
- package/src/core/persistedAuthState.ts +2 -1
- package/src/index.ts +1 -1
- package/src/keycloak/keycloak-js/Keycloak.ts +2 -1
- package/src/keycloak/keycloakIssuerUriParsed.ts +1 -1
- package/src/mock/oidc.ts +1 -1
- package/src/react/react.tsx +3 -2
- package/src/tools/EphemeralSessionStorage.ts +3 -1
- package/src/tools/Evt.ts +1 -1
- package/src/tools/getDownlinkAndRtt.ts +1 -1
- package/src/tools/readExpirationTimeInJwt.ts +1 -1
- package/src/tools/tsafe/Equals.ts +10 -0
- package/src/tools/tsafe/Param0.ts +12 -0
- package/src/tools/tsafe/Parameters.ts +3 -0
- package/src/tools/tsafe/Reflect.ts +4 -0
- package/src/tools/tsafe/assert.ts +66 -0
- package/src/tools/tsafe/id.ts +37 -0
- package/src/tools/tsafe/isAmong.ts +12 -0
- package/src/tools/tsafe/noUndefined.ts +21 -0
- package/src/tools/tsafe/tools/StrictEquals.ts +5 -0
- package/src/tools/tsafe/tools/Unite.ts +1 -0
- package/src/tools/tsafe/typeGuard.ts +4 -0
- package/tools/EphemeralSessionStorage.js +12 -10
- package/tools/EphemeralSessionStorage.js.map +1 -1
- package/tools/Evt.js +2 -2
- package/tools/Evt.js.map +1 -1
- package/tools/getDownlinkAndRtt.js +3 -3
- package/tools/getDownlinkAndRtt.js.map +1 -1
- package/tools/readExpirationTimeInJwt.js +2 -2
- package/tools/readExpirationTimeInJwt.js.map +1 -1
- package/tools/tsafe/Equals.d.ts +4 -0
- package/tools/tsafe/Equals.js +6 -0
- package/tools/tsafe/Equals.js.map +1 -0
- package/tools/tsafe/Param0.d.ts +7 -0
- package/tools/tsafe/Param0.js +3 -0
- package/tools/tsafe/Param0.js.map +1 -0
- package/tools/tsafe/Parameters.d.ts +2 -0
- package/tools/tsafe/Parameters.js +3 -0
- package/tools/tsafe/Parameters.js.map +1 -0
- package/tools/tsafe/Reflect.d.ts +2 -0
- package/tools/tsafe/Reflect.js +8 -0
- package/tools/tsafe/Reflect.js.map +1 -0
- package/tools/tsafe/assert.d.ts +10 -0
- package/tools/tsafe/assert.js +52 -0
- package/tools/tsafe/assert.js.map +1 -0
- package/tools/tsafe/id.d.ts +36 -0
- package/tools/tsafe/id.js +7 -0
- package/tools/tsafe/id.js.map +1 -0
- package/tools/tsafe/isAmong.d.ts +2 -0
- package/tools/tsafe/isAmong.js +13 -0
- package/tools/tsafe/isAmong.js.map +1 -0
- package/tools/tsafe/noUndefined.d.ts +9 -0
- package/tools/tsafe/noUndefined.js +22 -0
- package/tools/tsafe/noUndefined.js.map +1 -0
- package/tools/tsafe/tools/StrictEquals.d.ts +1 -0
- package/tools/tsafe/tools/StrictEquals.js +3 -0
- package/tools/tsafe/tools/StrictEquals.js.map +1 -0
- package/tools/tsafe/tools/Unite.d.ts +3 -0
- package/tools/tsafe/tools/Unite.js +3 -0
- package/tools/tsafe/tools/Unite.js.map +1 -0
- package/tools/tsafe/typeGuard.d.ts +2 -0
- package/tools/tsafe/typeGuard.js +8 -0
- package/tools/tsafe/typeGuard.js.map +1 -0
- package/vendor/backend/tsafe.js +1 -1
- package/esm/vendor/frontend/tsafe.d.ts +0 -7
- package/esm/vendor/frontend/tsafe.js +0 -1
- package/src/vendor/frontend/tsafe.ts +0 -7
- package/vendor/frontend/tsafe.d.ts +0 -7
- package/vendor/frontend/tsafe.js +0 -2
package/react/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react/react.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react/react.tsx"],"names":[],"mappings":";;AAqHA,kFA+UC;AAGD,0CAKC;;AA5cD,iCASe;AACf,kCAAkG;AAClG,kDAA4D;AAE5D,0CAAuC;AAEvC,gDAA6C;AAC7C,sEAAmE;AAsDnE,CAAC;IAMG,IAAA,eAAM,GAA4B,CAAC;AACvC,CAAC;AAwCD,SAAgB,mCAAmC,CAW/C,iBAAyD,EACzD,UAAyE;IAKzE,MAAM,cAAc,GAAG,IAAI,mBAAQ,EAAQ,CAAC;IAE5C,MAAM,WAAW,GAAG,IAAA,qBAAa,EAC7B,SAAS,CACZ,CAAC;IAEF,gEAAgE;IAChE,MAAM,2BAA2B,GAAG,CAAC,KAAK,IAAI,EAAE;QAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE;YAC7B,MAAM,cAAc,CAAC,EAAE,CAAC;YAExB,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE,CAAC;gBAC1C,MAAM,SAAS,GAAG,iBAAiB,CAAC;gBAEpC,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;gBAEjC,OAAO,MAAM,CAAC;YAClB,CAAC;YAED,MAAM,MAAM,GAAG,iBAAiB,CAAC;YAEjC,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC,EAAE,CAAC;QAEL,IAAI,IAA0B,CAAC;QAE/B,IAAI,CAAC;YACD,IAAI,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,CAAC,KAAK,YAAY,8BAAuB,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7B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACvB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CACX,0FAA0F,CAC7F,CAAC;YACN,CAAC;YACD,MAAM,2BAA2B,GAC7B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAExE,MAAM,IAAI,CAAC,KAAK,CAAC;gBACb,WAAW;gBACX,2BAA2B;aAC9B,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,KAAK,UAAU,OAAO;QAClB,cAAc,CAAC,OAAO,EAAE,CAAC;QAEzB,MAAM,yBAAyB,GAAG,MAAM,2BAA2B,CAAC;QAEpE,IAAI,yBAAyB,YAAY,8BAAuB,EAAE,CAAC;YAC/D,MAAM,KAAK,GAAG,yBAAyB,CAAC;YACxC,MAAM,KAAK,CAAC;QAChB,CAAC;QAED,MAAM,IAAI,GAAG,yBAAyB,CAAC;QAEvC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,YAAY,GAAwC;QACtD,YAAY;QACZ,OAAO,EAAE,OAAc;QACvB,OAAO;QACP,iBAAiB;QACjB,YAAY;KACf,CAAC;IAEF,8CAA8C;IAC9C,OAAO,YAAY,CAAC;AACxB,CAAC;AAED,2DAA2D;AAC3D,SAAgB,eAAe,CAG7B,MAAyE;IACvE,OAAO,mCAAmC,CAAC,MAAM,EAAE,iBAAU,CAAC,CAAC;AACnE,CAAC"}
|
package/src/angular.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BehaviorSubject } from "rxjs";
|
|
|
2
2
|
import type { Oidc, OidcInitializationError, ParamsOfCreateOidc } from "./core";
|
|
3
3
|
import type { OidcMetadata } from "./core/OidcMetadata";
|
|
4
4
|
import { Deferred } from "./tools/Deferred";
|
|
5
|
-
import { assert, type Equals, is } from "./
|
|
5
|
+
import { assert, type Equals, is } from "./tools/tsafe/assert";
|
|
6
6
|
import { createObjectThatThrowsIfAccessed } from "./tools/createObjectThatThrowsIfAccessed";
|
|
7
7
|
import {
|
|
8
8
|
type Signal,
|
package/src/core/OidcMetadata.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type OidcMetadata as OidcClientTsOidcMetadata } from "../vendor/frontend/oidc-client-ts";
|
|
2
|
-
import { assert, type Equals } from "../
|
|
2
|
+
import { assert, type Equals } from "../tools/tsafe/assert";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OpenID Providers have metadata describing their configuration.
|
package/src/core/StateData.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assert } from "../tools/tsafe/assert";
|
|
2
|
+
import { typeGuard } from "../tools/tsafe/typeGuard";
|
|
2
3
|
import { generateUrlSafeRandom } from "../tools/generateUrlSafeRandom";
|
|
3
4
|
|
|
4
5
|
export type StateData = StateData.IFrame | StateData.Redirect;
|
package/src/core/createOidc.ts
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
InMemoryWebStorage
|
|
6
6
|
} from "../vendor/frontend/oidc-client-ts";
|
|
7
7
|
import type { OidcMetadata } from "./OidcMetadata";
|
|
8
|
-
import {
|
|
8
|
+
import { assert, is, type Equals } from "../tools/tsafe/assert";
|
|
9
|
+
import { id } from "../tools/tsafe/id";
|
|
9
10
|
import { setTimeout, clearTimeout } from "../tools/workerTimers";
|
|
10
11
|
import { Deferred } from "../tools/Deferred";
|
|
11
12
|
import { createEvtIsUserActive } from "./evtIsUserActive";
|
|
@@ -757,7 +758,8 @@ export async function createOidc_nonMemoized<
|
|
|
757
758
|
transformUrlBeforeRedirect,
|
|
758
759
|
getExtraQueryParams,
|
|
759
760
|
getExtraTokenParams,
|
|
760
|
-
autoLogin
|
|
761
|
+
autoLogin,
|
|
762
|
+
log
|
|
761
763
|
});
|
|
762
764
|
|
|
763
765
|
assert(result_loginSilent.outcome !== "token refreshed using refresh token", "876995");
|
|
@@ -1228,7 +1230,8 @@ export async function createOidc_nonMemoized<
|
|
|
1228
1230
|
transformUrlBeforeRedirect,
|
|
1229
1231
|
getExtraQueryParams,
|
|
1230
1232
|
getExtraTokenParams: () => extraTokenParams,
|
|
1231
|
-
autoLogin
|
|
1233
|
+
autoLogin,
|
|
1234
|
+
log
|
|
1232
1235
|
});
|
|
1233
1236
|
|
|
1234
1237
|
if (result_loginSilent.outcome === "failure") {
|
package/src/core/earlyInit.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getStateData, getIsStatQueryParamValue } from "./StateData";
|
|
2
|
-
import { assert, type Equals } from "../
|
|
2
|
+
import { assert, type Equals } from "../tools/tsafe/assert";
|
|
3
3
|
import type { AuthResponse } from "./AuthResponse";
|
|
4
4
|
import {
|
|
5
5
|
encryptAuthResponse,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createEvt, type NonPostableEvt } from "../tools/Evt";
|
|
2
2
|
import { subscribeToUserInteraction } from "../tools/subscribeToUserInteraction";
|
|
3
|
-
import { assert, is
|
|
3
|
+
import { assert, is } from "../tools/tsafe/assert";
|
|
4
|
+
import { id } from "../tools/tsafe/id";
|
|
4
5
|
import { setTimeout, clearTimeout } from "../tools/workerTimers";
|
|
5
6
|
|
|
6
7
|
const globalContext = {
|
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { assert } from "../
|
|
1
|
+
import { assert } from "../tools/tsafe/assert";
|
|
2
2
|
import { asymmetricEncrypt, asymmetricDecrypt, generateKeys } from "../tools/asymmetricEncryption";
|
|
3
3
|
import { type AuthResponse } from "./AuthResponse";
|
|
4
4
|
|
|
5
|
-
const sessionStorage_original = window.sessionStorage;
|
|
6
5
|
const setItem_real = Storage.prototype.setItem;
|
|
7
6
|
|
|
8
7
|
const SESSION_STORAGE_PREFIX = "oidc-spa_iframe_authResponse_publicKey_";
|
|
9
8
|
|
|
10
9
|
export function preventSessionStorageSetItemOfPublicKeyByThirdParty() {
|
|
11
10
|
const setItem_protected = function setItem(this: any, key: string, value: string): void {
|
|
12
|
-
if (this !== sessionStorage_original) {
|
|
13
|
-
return setItem_real.call(this, key, value);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
11
|
if (key.startsWith(SESSION_STORAGE_PREFIX)) {
|
|
17
12
|
throw new Error(
|
|
18
13
|
"Attack prevented by oidc-spa. You have malicious code running in your system"
|
|
19
14
|
);
|
|
20
15
|
}
|
|
21
16
|
|
|
22
|
-
return setItem_real.call(
|
|
17
|
+
return setItem_real.call(this, key, value);
|
|
23
18
|
};
|
|
24
19
|
|
|
25
20
|
{
|
|
@@ -43,13 +38,20 @@ function getSessionStorageKey(params: { stateUrlParamValue: string }) {
|
|
|
43
38
|
return `${SESSION_STORAGE_PREFIX}${stateUrlParamValue}`;
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
export async function initIframeMessageProtection(params: {
|
|
47
|
-
|
|
41
|
+
export async function initIframeMessageProtection(params: {
|
|
42
|
+
stateUrlParamValue: string;
|
|
43
|
+
log: typeof console.log | undefined;
|
|
44
|
+
}) {
|
|
45
|
+
const { stateUrlParamValue, log } = params;
|
|
48
46
|
|
|
49
47
|
const { publicKey, privateKey } = await generateKeys();
|
|
50
48
|
|
|
51
49
|
const sessionStorageKey = getSessionStorageKey({ stateUrlParamValue });
|
|
52
50
|
|
|
51
|
+
log?.(
|
|
52
|
+
`Writing iframe messaging protection publicKey for state: ${stateUrlParamValue} at sessionStorage -> ${sessionStorageKey}`
|
|
53
|
+
);
|
|
54
|
+
|
|
53
55
|
setItem_real.call(sessionStorage, sessionStorageKey, publicKey);
|
|
54
56
|
|
|
55
57
|
function getIsEncryptedAuthResponse(params: { message: unknown }): boolean {
|
|
@@ -74,6 +76,7 @@ export async function initIframeMessageProtection(params: { stateUrlParamValue:
|
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
function clearSessionStoragePublicKey() {
|
|
79
|
+
log?.(`Clearing session storage public key at ${sessionStorageKey}`);
|
|
77
80
|
sessionStorage.removeItem(sessionStorageKey);
|
|
78
81
|
}
|
|
79
82
|
|
|
@@ -87,7 +90,7 @@ export async function encryptAuthResponse(params: { authResponse: AuthResponse }
|
|
|
87
90
|
getSessionStorageKey({ stateUrlParamValue: authResponse.state })
|
|
88
91
|
);
|
|
89
92
|
|
|
90
|
-
assert(publicKey !== null,
|
|
93
|
+
assert(publicKey !== null, `2293302 no publicKey for state ${authResponse.state}`);
|
|
91
94
|
|
|
92
95
|
const { encryptedMessage: encryptedMessage_withoutPrefix } = await asymmetricEncrypt({
|
|
93
96
|
publicKey,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { UserManager as OidcClientTsUserManager } from "../vendor/frontend/oidc-client-ts";
|
|
2
2
|
import { toFullyQualifiedUrl } from "../tools/toFullyQualifiedUrl";
|
|
3
|
-
import { assert, type Equals
|
|
3
|
+
import { assert, type Equals } from "../tools/tsafe/assert";
|
|
4
|
+
import { noUndefined } from "../tools/tsafe/noUndefined";
|
|
4
5
|
import type { StateData } from "./StateData";
|
|
5
6
|
import type { NonPostableEvt } from "../tools/Evt";
|
|
6
7
|
import { createStatefulEvt } from "../tools/StatefulEvt";
|
package/src/core/loginSilent.ts
CHANGED
|
@@ -3,7 +3,9 @@ import type {
|
|
|
3
3
|
User as OidcClientTsUser
|
|
4
4
|
} from "../vendor/frontend/oidc-client-ts";
|
|
5
5
|
import { Deferred } from "../tools/Deferred";
|
|
6
|
-
import {
|
|
6
|
+
import { assert } from "../tools/tsafe/assert";
|
|
7
|
+
import { id } from "../tools/tsafe/id";
|
|
8
|
+
import { noUndefined } from "../tools/tsafe/noUndefined";
|
|
7
9
|
import { getStateData, clearStateStore, type StateData } from "./StateData";
|
|
8
10
|
import { getDownlinkAndRtt } from "../tools/getDownlinkAndRtt";
|
|
9
11
|
import { getIsDev } from "../tools/isDev";
|
|
@@ -40,6 +42,7 @@ export async function loginSilent(params: {
|
|
|
40
42
|
|
|
41
43
|
getExtraTokenParams: (() => Record<string, string | undefined>) | undefined;
|
|
42
44
|
autoLogin: boolean;
|
|
45
|
+
log: typeof console.log | undefined;
|
|
43
46
|
}): Promise<ResultOfLoginSilent> {
|
|
44
47
|
const {
|
|
45
48
|
oidcClientTsUserManager,
|
|
@@ -48,7 +51,8 @@ export async function loginSilent(params: {
|
|
|
48
51
|
transformUrlBeforeRedirect,
|
|
49
52
|
getExtraQueryParams,
|
|
50
53
|
getExtraTokenParams,
|
|
51
|
-
autoLogin
|
|
54
|
+
autoLogin,
|
|
55
|
+
log
|
|
52
56
|
} = params;
|
|
53
57
|
|
|
54
58
|
const dResult = new Deferred<ResultOfLoginSilent>();
|
|
@@ -76,7 +80,8 @@ export async function loginSilent(params: {
|
|
|
76
80
|
|
|
77
81
|
const { decodeEncryptedAuth, getIsEncryptedAuthResponse, clearSessionStoragePublicKey } =
|
|
78
82
|
await initIframeMessageProtection({
|
|
79
|
-
stateUrlParamValue: stateUrlParamValue_instance
|
|
83
|
+
stateUrlParamValue: stateUrlParamValue_instance,
|
|
84
|
+
log
|
|
80
85
|
});
|
|
81
86
|
|
|
82
87
|
let clearTimeouts: (params: { wasSuccess: boolean }) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { User as OidcClientTsUser } from "../vendor/frontend/oidc-client-ts";
|
|
2
|
-
import { assert
|
|
2
|
+
import { assert } from "../tools/tsafe/assert";
|
|
3
|
+
import { id } from "../tools/tsafe/id";
|
|
3
4
|
import { readExpirationTimeInJwt } from "../tools/readExpirationTimeInJwt";
|
|
4
5
|
import { decodeJwt } from "../tools/decodeJwt";
|
|
5
6
|
import type { Oidc } from "./Oidc";
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { type Oidc, OidcInitializationError, type ParamsOfCreateOidc, createOidc } from "./core";
|
|
@@ -12,7 +12,8 @@ import type {
|
|
|
12
12
|
KeycloakRegisterOptions,
|
|
13
13
|
KeycloakAccountOptions
|
|
14
14
|
} from "./types";
|
|
15
|
-
import { assert, is
|
|
15
|
+
import { assert, is } from "../../tools/tsafe/assert";
|
|
16
|
+
import { isAmong } from "../../tools/tsafe/isAmong";
|
|
16
17
|
import { createOidc, type Oidc, OidcInitializationError } from "../../core";
|
|
17
18
|
import { Deferred } from "../../tools/Deferred";
|
|
18
19
|
import { decodeJwt } from "../../tools/decodeJwt";
|
package/src/mock/oidc.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Oidc } from "../core";
|
|
2
2
|
import { createObjectThatThrowsIfAccessed } from "../tools/createObjectThatThrowsIfAccessed";
|
|
3
|
-
import { id } from "../
|
|
3
|
+
import { id } from "../tools/tsafe/id";
|
|
4
4
|
import { toFullyQualifiedUrl } from "../tools/toFullyQualifiedUrl";
|
|
5
5
|
import { getSearchParam, addOrUpdateSearchParam } from "../tools/urlSearchParams";
|
|
6
6
|
import { getRootRelativeOriginalLocationHref } from "../core/earlyInit";
|
package/src/react/react.tsx
CHANGED
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
type JSX
|
|
10
10
|
} from "react";
|
|
11
11
|
import { type Oidc, createOidc, type ParamsOfCreateOidc, OidcInitializationError } from "../core";
|
|
12
|
-
import { assert, type Equals
|
|
13
|
-
import {
|
|
12
|
+
import { assert, type Equals } from "../tools/tsafe/assert";
|
|
13
|
+
import type { Param0 } from "../tools/tsafe/Param0";
|
|
14
|
+
import { id } from "../tools/tsafe/id";
|
|
14
15
|
import type { ValueOrAsyncGetter } from "../tools/ValueOrAsyncGetter";
|
|
15
16
|
import { Deferred } from "../tools/Deferred";
|
|
16
17
|
import { toFullyQualifiedUrl } from "../tools/toFullyQualifiedUrl";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { assert
|
|
1
|
+
import { assert } from "../tools/tsafe/assert";
|
|
2
|
+
import { id } from "../tools/tsafe/id";
|
|
3
|
+
import { typeGuard } from "../tools/tsafe/typeGuard";
|
|
2
4
|
|
|
3
5
|
type SessionStorageItem_Parsed = {
|
|
4
6
|
__brand: "SessionStorageItem_Parsed-v1";
|
package/src/tools/Evt.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decodeJwt } from "./decodeJwt";
|
|
2
|
-
import { assert } from "../
|
|
2
|
+
import { assert } from "../tools/tsafe/assert";
|
|
3
3
|
import { INFINITY_TIME } from "./INFINITY_TIME";
|
|
4
4
|
|
|
5
5
|
// Return undefined if token provided wasn't a JWT or if it hasn't an exp claim number
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Unite } from "./tools/Unite";
|
|
2
|
+
import type { StrictEquals } from "./tools/StrictEquals";
|
|
3
|
+
|
|
4
|
+
// Credit https://stackoverflow.com/a/53808212/3731798
|
|
5
|
+
/** https://docs.tsafe.dev/main/equals */
|
|
6
|
+
export type Equals<A1, A2> = StrictEquals<Unite<A1>, Unite<A2>>;
|
|
7
|
+
|
|
8
|
+
// TODO: To export and document, this type can be used in place of equals if the types to compare have no `any` in them.
|
|
9
|
+
// (I think but some more testing is needed)
|
|
10
|
+
// export type LooseEquals<T, U> = T extends U ? (U extends T ? true : false) : false;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Parameters } from "./Parameters";
|
|
2
|
+
|
|
3
|
+
type NonUndefined<T> = T extends undefined ? never : T;
|
|
4
|
+
|
|
5
|
+
/** Shorthand for Parameters<typeof f>[0] https://docs.tsafe.dev/param0 */
|
|
6
|
+
export type Param0<T extends ((...args: any[]) => unknown) | null | undefined | false | ""> = [
|
|
7
|
+
Parameters<T>
|
|
8
|
+
] extends [never]
|
|
9
|
+
? never
|
|
10
|
+
: Parameters<T> extends []
|
|
11
|
+
? void
|
|
12
|
+
: NonUndefined<Parameters<T>[0]>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export type { Equals } from "./Equals";
|
|
2
|
+
|
|
3
|
+
/** https://docs.tsafe.dev/assert#error-thrown */
|
|
4
|
+
export class AssertionError extends Error {
|
|
5
|
+
originalMessage?: string;
|
|
6
|
+
|
|
7
|
+
constructor(msg: string | undefined) {
|
|
8
|
+
super(`Wrong assert${!msg ? "" : `: "${msg}"`}`);
|
|
9
|
+
|
|
10
|
+
this.originalMessage = msg;
|
|
11
|
+
|
|
12
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
13
|
+
|
|
14
|
+
if (!this.stack) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let refOfIs: undefined | Record<string, never> = undefined;
|
|
21
|
+
|
|
22
|
+
/** https://docs.tsafe.dev/assert */
|
|
23
|
+
export function assert<_T extends true>(
|
|
24
|
+
condition?: any,
|
|
25
|
+
msg?: string | (() => string)
|
|
26
|
+
): asserts condition {
|
|
27
|
+
if (arguments.length === 0) {
|
|
28
|
+
condition = true;
|
|
29
|
+
}
|
|
30
|
+
if (refOfIs) {
|
|
31
|
+
refOfIs = undefined;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!condition) {
|
|
36
|
+
const error = new AssertionError(typeof msg === "function" ? msg() : msg);
|
|
37
|
+
|
|
38
|
+
if (Error.captureStackTrace) {
|
|
39
|
+
Error.captureStackTrace(error, assert);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const errorMessage = "'is' error";
|
|
47
|
+
|
|
48
|
+
/** https://docs.tsafe.dev/is */
|
|
49
|
+
export function is<T>(_value: any): _value is T {
|
|
50
|
+
const ref = {};
|
|
51
|
+
|
|
52
|
+
if (refOfIs) {
|
|
53
|
+
refOfIs = undefined;
|
|
54
|
+
throw new Error(errorMessage);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
refOfIs = ref;
|
|
58
|
+
|
|
59
|
+
Promise.resolve().then(() => {
|
|
60
|
+
if (refOfIs === ref) {
|
|
61
|
+
throw new Error(errorMessage);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return null as any;
|
|
66
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** https://docs.tsafe.dev/id */
|
|
2
|
+
export const id = <T>(x: T) => x;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Ensure that a that a specific type that we are declaring extends a more generic type
|
|
6
|
+
*
|
|
7
|
+
* Use case example 1:
|
|
8
|
+
*
|
|
9
|
+
* type MyObject = {
|
|
10
|
+
* p1: string;
|
|
11
|
+
* p2: string;
|
|
12
|
+
* a: string;
|
|
13
|
+
* b: string;
|
|
14
|
+
* };
|
|
15
|
+
*
|
|
16
|
+
* We want to define a type that consist in an union of
|
|
17
|
+
* all the property name that are letters:
|
|
18
|
+
*
|
|
19
|
+
* type AlphabeticalKeys = Id<keyof MyObject, "a" | "b">;
|
|
20
|
+
*
|
|
21
|
+
* Here AlphabeticalKeys is "a" | "b" but it's better than
|
|
22
|
+
* simply writing it explicitly as we get autocompletion
|
|
23
|
+
* and we can't include a property name that does not exist on MyObject.
|
|
24
|
+
*
|
|
25
|
+
* Use case example 2:
|
|
26
|
+
*
|
|
27
|
+
* We want to declare object type that only take string or number
|
|
28
|
+
* as key value:
|
|
29
|
+
*
|
|
30
|
+
* export type MyObject = Id<Record<string, string | number>, {
|
|
31
|
+
* p1: string;
|
|
32
|
+
* p2: number;
|
|
33
|
+
* }>;
|
|
34
|
+
*
|
|
35
|
+
* If later on someone adds "p3": string[] he will get a type error.
|
|
36
|
+
* */
|
|
37
|
+
export type Id<Generic, Specific extends Generic> = Specific;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** https://docs.tsafe.dev/isamong */
|
|
2
|
+
export function isAmong<Name extends string | number | boolean | null | undefined>(
|
|
3
|
+
names: readonly Name[],
|
|
4
|
+
value: unknown
|
|
5
|
+
): value is Name {
|
|
6
|
+
for (const name of names) {
|
|
7
|
+
if (name === value) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes the enumerable properties whose values are
|
|
3
|
+
* undefined.
|
|
4
|
+
*
|
|
5
|
+
* Example:
|
|
6
|
+
* noUndefined({ "foo": undefined, "bar": 3 }) returns
|
|
7
|
+
* a new object { "bar": 3 }
|
|
8
|
+
*/
|
|
9
|
+
export function noUndefined<T extends object>(obj: T): T {
|
|
10
|
+
const out: typeof obj = {} as any;
|
|
11
|
+
|
|
12
|
+
for (const key in obj) {
|
|
13
|
+
if (obj[key] === undefined) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
out[key] = obj[key];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Unite<T> = T extends Record<string, unknown> ? { [Key in keyof T]: T[Key] } : T;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createEphemeralSessionStorage = createEphemeralSessionStorage;
|
|
4
|
-
const
|
|
4
|
+
const assert_1 = require("../tools/tsafe/assert");
|
|
5
|
+
const id_1 = require("../tools/tsafe/id");
|
|
6
|
+
const typeGuard_1 = require("../tools/tsafe/typeGuard");
|
|
5
7
|
function parseSessionStorageItem(sessionStorageItemValue) {
|
|
6
8
|
let json;
|
|
7
9
|
try {
|
|
@@ -10,9 +12,9 @@ function parseSessionStorageItem(sessionStorageItemValue) {
|
|
|
10
12
|
catch {
|
|
11
13
|
return undefined;
|
|
12
14
|
}
|
|
13
|
-
if (!(0,
|
|
15
|
+
if (!(0, typeGuard_1.typeGuard)(json, json instanceof Object &&
|
|
14
16
|
"__brand" in json &&
|
|
15
|
-
json.__brand === (0,
|
|
17
|
+
json.__brand === (0, id_1.id)("SessionStorageItem_Parsed-v1"))) {
|
|
16
18
|
return undefined;
|
|
17
19
|
}
|
|
18
20
|
return json;
|
|
@@ -33,7 +35,7 @@ function createStoreInSessionStorageAndScheduleRemovalInMemoryItem(params) {
|
|
|
33
35
|
removeFromSessionStorage
|
|
34
36
|
};
|
|
35
37
|
sessionStorage.removeItem(sessionStorageKey);
|
|
36
|
-
sessionStorage.setItem(sessionStorageKey, JSON.stringify((0,
|
|
38
|
+
sessionStorage.setItem(sessionStorageKey, JSON.stringify((0, id_1.id)({
|
|
37
39
|
__brand: "SessionStorageItem_Parsed-v1",
|
|
38
40
|
value,
|
|
39
41
|
expiresAtTime: Date.now() + remainingTtlMs
|
|
@@ -45,12 +47,12 @@ function createEphemeralSessionStorage(params) {
|
|
|
45
47
|
const inMemoryItems = [];
|
|
46
48
|
for (let i = 0; i < sessionStorage.length; i++) {
|
|
47
49
|
const sessionStorageKey = sessionStorage.key(i);
|
|
48
|
-
(0,
|
|
50
|
+
(0, assert_1.assert)(sessionStorageKey !== null, "470498");
|
|
49
51
|
if (!sessionStorageKey.startsWith(SESSION_STORAGE_PREFIX)) {
|
|
50
52
|
continue;
|
|
51
53
|
}
|
|
52
54
|
const sessionStorageItem = sessionStorage.getItem(sessionStorageKey);
|
|
53
|
-
(0,
|
|
55
|
+
(0, assert_1.assert)(sessionStorageItem !== null, "846771");
|
|
54
56
|
const sessionStorageItem_parsed = parseSessionStorageItem(sessionStorageItem);
|
|
55
57
|
if (sessionStorageItem_parsed === undefined) {
|
|
56
58
|
continue;
|
|
@@ -72,9 +74,9 @@ function createEphemeralSessionStorage(params) {
|
|
|
72
74
|
isPersistenceEnabled = true;
|
|
73
75
|
for (let i = 0; i < storage.length; i++) {
|
|
74
76
|
const key = storage.key(i);
|
|
75
|
-
(0,
|
|
77
|
+
(0, assert_1.assert)(key !== null, "803385");
|
|
76
78
|
const value = storage.getItem(key);
|
|
77
|
-
(0,
|
|
79
|
+
(0, assert_1.assert)(value !== null, "777098");
|
|
78
80
|
storage.setItem(key, value);
|
|
79
81
|
}
|
|
80
82
|
},
|
|
@@ -100,7 +102,7 @@ function createEphemeralSessionStorage(params) {
|
|
|
100
102
|
clear: () => {
|
|
101
103
|
for (let i = 0; i < storage.length; i++) {
|
|
102
104
|
const key = storage.key(i);
|
|
103
|
-
(0,
|
|
105
|
+
(0, assert_1.assert)(key !== null, "290875");
|
|
104
106
|
storage.removeItem(key);
|
|
105
107
|
}
|
|
106
108
|
},
|
|
@@ -126,7 +128,7 @@ function createEphemeralSessionStorage(params) {
|
|
|
126
128
|
value,
|
|
127
129
|
remainingTtlMs: sessionStorageTtlMs
|
|
128
130
|
})
|
|
129
|
-
: (0,
|
|
131
|
+
: (0, id_1.id)({
|
|
130
132
|
key,
|
|
131
133
|
value,
|
|
132
134
|
removeFromSessionStorage: undefined
|