oidc-spa 8.1.3 → 8.1.4
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 +33 -32
- 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.js +4 -8
- 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.js +8 -6
- 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 +3 -2
- 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.js +2 -6
- 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.js +3 -1
- 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/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/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/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/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 +2 -1
- package/src/core/earlyInit.ts +1 -1
- package/src/core/evtIsUserActive.ts +2 -1
- package/src/core/iframeMessageProtection.ts +2 -7
- package/src/core/loginOrGoToAuthServer.ts +2 -1
- package/src/core/loginPropagationToOtherTabs.ts +1 -1
- package/src/core/loginSilent.ts +3 -1
- 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/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/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";
|
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
|
{
|
|
@@ -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";
|
|
@@ -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";
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EphemeralSessionStorage.js","sourceRoot":"","sources":["../src/tools/EphemeralSessionStorage.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"EphemeralSessionStorage.js","sourceRoot":"","sources":["../src/tools/EphemeralSessionStorage.ts"],"names":[],"mappings":";;AA+FA,sEAiIC;AAhOD,kDAA+C;AAC/C,0CAAuC;AACvC,wDAAqD;AAQrD,SAAS,uBAAuB,CAC5B,uBAA+B;IAE/B,IAAI,IAAa,CAAC;IAElB,IAAI,CAAC;QACD,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IACI,CAAC,IAAA,qBAAS,EACN,IAAI,EACJ,IAAI,YAAY,MAAM;QAClB,SAAS,IAAI,IAAI;QACjB,IAAI,CAAC,OAAO,KAAK,IAAA,OAAE,EAAuC,8BAA8B,CAAC,CAChG,EACH,CAAC;QACC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAQD,MAAM,sBAAsB,GAAG,YAAY,CAAC;AAE5C,SAAS,yDAAyD,CAAC,MAIlE;IACG,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IAE9C,MAAM,iBAAiB,GAAG,GAAG,sBAAsB,GAAG,GAAG,EAAE,CAAC;IAE5D,MAAM,wBAAwB,GAAG,GAAG,EAAE;QAClC,YAAY,CAAC,wBAAwB,GAAG,SAAS,CAAC;QAClD,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,cAAc,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACjD,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,wBAAwB,EAAE,EAAE,cAAc,CAAC,CAAC;IAE3E,MAAM,YAAY,GAAiB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G,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBACpE,CAAC;YACL,CAAC;YAED,MAAM,gBAAgB,GAAG,oBAAoB;gBACzC,CAAC,CAAC,yDAAyD,CAAC;oBACtD,GAAG;oBACH,KAAK;oBACL,cAAc,EAAE,mBAAmB;iBACtC,CAAC;gBACJ,CAAC,CAAC,IAAA,OAAE,EAAe;oBACb,GAAG;oBACH,KAAK;oBACL,wBAAwB,EAAE,SAAS;iBACtC,CAAC,CAAC;YAET,IAAI,yBAAyB,KAAK,SAAS,EAAE,CAAC;gBAC1C,aAAa,CAAC,yBAAyB,CAAC,GAAG,gBAAgB,CAAC;YAChE,CAAC;iBAAM,CAAC;gBACJ,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACzC,CAAC;QACL,CAAC;KACJ,CAAC;IAEF,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
package/tools/Evt.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createEvt = createEvt;
|
|
4
4
|
const Deferred_1 = require("./Deferred");
|
|
5
|
-
const
|
|
5
|
+
const assert_1 = require("../tools/tsafe/assert");
|
|
6
6
|
function createEvt() {
|
|
7
7
|
const eventTarget = new EventTarget();
|
|
8
8
|
const KEY = "event";
|
|
@@ -10,7 +10,7 @@ function createEvt() {
|
|
|
10
10
|
const evt = {
|
|
11
11
|
subscribe: next => {
|
|
12
12
|
const listener = (e) => {
|
|
13
|
-
(0,
|
|
13
|
+
(0, assert_1.assert)((0, assert_1.is)(e));
|
|
14
14
|
next(e.detail);
|
|
15
15
|
};
|
|
16
16
|
eventTarget.addEventListener(KEY, listener);
|
package/tools/Evt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Evt.js","sourceRoot":"","sources":["../src/tools/Evt.ts"],"names":[],"mappings":";;AAaA,8BA0CC;AAvDD,yCAAsC;AACtC,
|
|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AAS,CAAC;QACrB,CAAC;KACJ,CAAC;IAEF,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDownlinkAndRtt = getDownlinkAndRtt;
|
|
4
|
-
const
|
|
4
|
+
const assert_1 = require("../tools/tsafe/assert");
|
|
5
5
|
function getDownlinkAndRtt() {
|
|
6
6
|
if (!(window.navigator instanceof Object)) {
|
|
7
7
|
return undefined;
|
|
@@ -10,8 +10,8 @@ function getDownlinkAndRtt() {
|
|
|
10
10
|
for (const key of ["connection", "mozConnection", "webkitConnection"]) {
|
|
11
11
|
try {
|
|
12
12
|
const { downlink, rtt } = navigator[key];
|
|
13
|
-
(0,
|
|
14
|
-
(0,
|
|
13
|
+
(0, assert_1.assert)(typeof downlink === "number", "768860");
|
|
14
|
+
(0, assert_1.assert)(typeof rtt === "number", "945829");
|
|
15
15
|
return { downlink, rtt };
|
|
16
16
|
}
|
|
17
17
|
catch { }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDownlinkAndRtt.js","sourceRoot":"","sources":["../src/tools/getDownlinkAndRtt.ts"],"names":[],"mappings":";;AAEA,8CAmBC;AArBD,
|
|
1
|
+
{"version":3,"file":"getDownlinkAndRtt.js","sourceRoot":"","sources":["../src/tools/getDownlinkAndRtt.ts"],"names":[],"mappings":";;AAEA,8CAmBC;AArBD,kDAA+C;AAE/C,SAAgB,iBAAiB;IAC7B,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,YAAY,MAAM,CAAC,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,SAAS,GAAQ,MAAM,CAAC,SAAS,CAAC;IAExC,KAAK,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE,kBAAkB,CAAU,EAAE,CAAC;QAC7E,IAAI,CAAC;YACD,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;YAEzC,IAAA,eAAM,EAAC,OAAO,QAAQ,KAAK,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC/C,IAAA,eAAM,EAAC,OAAO,GAAG,KAAK,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAE1C,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACd,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readExpirationTimeInJwt = readExpirationTimeInJwt;
|
|
4
4
|
const decodeJwt_1 = require("./decodeJwt");
|
|
5
|
-
const
|
|
5
|
+
const assert_1 = require("../tools/tsafe/assert");
|
|
6
6
|
const INFINITY_TIME_1 = require("./INFINITY_TIME");
|
|
7
7
|
// Return undefined if token provided wasn't a JWT or if it hasn't an exp claim number
|
|
8
8
|
function readExpirationTimeInJwt(token) {
|
|
9
9
|
let exp;
|
|
10
10
|
try {
|
|
11
11
|
exp = (0, decodeJwt_1.decodeJwt)(token).exp;
|
|
12
|
-
(0,
|
|
12
|
+
(0, assert_1.assert)(typeof exp === "number");
|
|
13
13
|
}
|
|
14
14
|
catch {
|
|
15
15
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readExpirationTimeInJwt.js","sourceRoot":"","sources":["../src/tools/readExpirationTimeInJwt.ts"],"names":[],"mappings":";;AAKA,0DAeC;AApBD,2CAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"readExpirationTimeInJwt.js","sourceRoot":"","sources":["../src/tools/readExpirationTimeInJwt.ts"],"names":[],"mappings":";;AAKA,0DAeC;AApBD,2CAAwC;AACxC,kDAA+C;AAC/C,mDAAgD;AAEhD,sFAAsF;AACtF,SAAgB,uBAAuB,CAAC,KAAa;IACjD,IAAI,GAAW,CAAC;IAEhB,IAAI,CAAC;QACD,GAAG,GAAG,IAAA,qBAAS,EAAkB,KAAK,CAAC,CAAC,GAAG,CAAC;QAC5C,IAAA,eAAM,EAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,6BAAa,CAAC;IACzB,CAAC;IAED,OAAO,GAAG,GAAG,IAAI,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// TODO: To export and document, this type can be used in place of equals if the types to compare have no `any` in them.
|
|
4
|
+
// (I think but some more testing is needed)
|
|
5
|
+
// export type LooseEquals<T, U> = T extends U ? (U extends T ? true : false) : false;
|
|
6
|
+
//# sourceMappingURL=Equals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Equals.js","sourceRoot":"","sources":["../../src/tools/tsafe/Equals.ts"],"names":[],"mappings":";;AAOA,wHAAwH;AACxH,4CAA4C;AAC5C,sFAAsF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Parameters } from "./Parameters";
|
|
2
|
+
type NonUndefined<T> = T extends undefined ? never : T;
|
|
3
|
+
/** Shorthand for Parameters<typeof f>[0] https://docs.tsafe.dev/param0 */
|
|
4
|
+
export type Param0<T extends ((...args: any[]) => unknown) | null | undefined | false | ""> = [
|
|
5
|
+
Parameters<T>
|
|
6
|
+
] extends [never] ? never : Parameters<T> extends [] ? void : NonUndefined<Parameters<T>[0]>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Param0.js","sourceRoot":"","sources":["../../src/tools/tsafe/Param0.ts"],"names":[],"mappings":""}
|