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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class OidcInitializationError extends Error {
|
|
2
|
+
constructor(params) {
|
|
3
|
+
super((() => {
|
|
4
|
+
if (typeof params.messageOrCause === "string") {
|
|
5
|
+
return params.messageOrCause;
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
return `Unknown initialization error: ${params.messageOrCause.message}`;
|
|
9
|
+
}
|
|
10
|
+
})(),
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
{ cause: typeof params.messageOrCause === "string" ? undefined : params.messageOrCause });
|
|
13
|
+
this.isAuthServerLikelyDown = params.isAuthServerLikelyDown;
|
|
14
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=OidcInitializationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OidcInitializationError.js","sourceRoot":"","sources":["../../../src/core/OidcInitializationError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAG9C,YAAY,MAA2E;QACnF,KAAK,CACD,CAAC,GAAG,EAAE;YACF,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ,EAAE,CAAC;gBAC5C,OAAO,MAAM,CAAC,cAAc,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACJ,OAAO,iCAAiC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;YAC5E,CAAC;QACL,CAAC,CAAC,EAAE;QACJ,mBAAmB;QACnB,EAAE,KAAK,EAAE,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAC3F,CAAC;QACF,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,CAAC;QAC5D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACJ"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { type OidcMetadata as OidcClientTsOidcMetadata } from "../vendor/frontend/oidc-client-ts";
|
|
2
|
-
import { assert, type Equals } from "../vendor/frontend/tsafe";
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* OpenID Providers have metadata describing their configuration.
|
|
6
3
|
*
|
|
@@ -267,5 +264,3 @@ export type OidcMetadata = {
|
|
|
267
264
|
*/
|
|
268
265
|
code_challenge_methods_supported: string[];
|
|
269
266
|
};
|
|
270
|
-
|
|
271
|
-
assert<Equals<OidcMetadata, OidcClientTsOidcMetadata>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OidcMetadata.js","sourceRoot":"","sources":["../../../src/core/OidcMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAe,MAAM,0BAA0B,CAAC;AA6Q/D,MAAsD,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type StateData = StateData.IFrame | StateData.Redirect;
|
|
2
|
+
export declare namespace StateData {
|
|
3
|
+
type Common = {
|
|
4
|
+
configId: string;
|
|
5
|
+
};
|
|
6
|
+
export type IFrame = Common & {
|
|
7
|
+
context: "iframe";
|
|
8
|
+
};
|
|
9
|
+
export type Redirect = Redirect.Login | Redirect.Logout;
|
|
10
|
+
export namespace Redirect {
|
|
11
|
+
type Common_Redirect = Common & {
|
|
12
|
+
context: "redirect";
|
|
13
|
+
redirectUrl: string;
|
|
14
|
+
hasBeenProcessedByCallback: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type Login = Common_Redirect & {
|
|
17
|
+
action: "login";
|
|
18
|
+
redirectUrl_consentRequiredCase: string;
|
|
19
|
+
extraQueryParams: Record<string, string>;
|
|
20
|
+
};
|
|
21
|
+
export type Logout = Common_Redirect & {
|
|
22
|
+
action: "logout";
|
|
23
|
+
sessionId: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
}
|
|
29
|
+
export declare function generateStateUrlParamValue(): string;
|
|
30
|
+
export declare function getIsStatQueryParamValue(params: {
|
|
31
|
+
maybeStateUrlParamValue: string;
|
|
32
|
+
}): boolean;
|
|
33
|
+
export declare const STATE_STORE_KEY_PREFIX = "oidc.";
|
|
34
|
+
export declare function clearStateStore(params: {
|
|
35
|
+
stateUrlParamValue: string;
|
|
36
|
+
}): void;
|
|
37
|
+
export declare function getStateData(params: {
|
|
38
|
+
stateUrlParamValue: string;
|
|
39
|
+
}): StateData | undefined;
|
|
40
|
+
export declare function markStateDataAsProcessedByCallback(params: {
|
|
41
|
+
stateUrlParamValue: string;
|
|
42
|
+
}): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { typeGuard, assert } from "../vendor/frontend/tsafe";
|
|
2
|
+
import { generateUrlSafeRandom } from "../tools/generateUrlSafeRandom";
|
|
3
|
+
const STATE_QUERY_PARAM_VALUE_IDENTIFIER_PREFIX = "b2lkYy1zcGEu";
|
|
4
|
+
const RANDOM_STRING_LENGTH = 32 - STATE_QUERY_PARAM_VALUE_IDENTIFIER_PREFIX.length;
|
|
5
|
+
export function generateStateUrlParamValue() {
|
|
6
|
+
return `${STATE_QUERY_PARAM_VALUE_IDENTIFIER_PREFIX}${generateUrlSafeRandom({
|
|
7
|
+
length: RANDOM_STRING_LENGTH
|
|
8
|
+
})}`;
|
|
9
|
+
}
|
|
10
|
+
export function getIsStatQueryParamValue(params) {
|
|
11
|
+
const { maybeStateUrlParamValue } = params;
|
|
12
|
+
return (maybeStateUrlParamValue.startsWith(STATE_QUERY_PARAM_VALUE_IDENTIFIER_PREFIX) &&
|
|
13
|
+
maybeStateUrlParamValue.length ===
|
|
14
|
+
STATE_QUERY_PARAM_VALUE_IDENTIFIER_PREFIX.length + RANDOM_STRING_LENGTH);
|
|
15
|
+
}
|
|
16
|
+
export const STATE_STORE_KEY_PREFIX = "oidc.";
|
|
17
|
+
function getKey(params) {
|
|
18
|
+
const { stateUrlParamValue } = params;
|
|
19
|
+
return `${STATE_STORE_KEY_PREFIX}${stateUrlParamValue}`;
|
|
20
|
+
}
|
|
21
|
+
function getStateStore(params) {
|
|
22
|
+
const { stateUrlParamValue } = params;
|
|
23
|
+
const item = localStorage.getItem(getKey({ stateUrlParamValue }));
|
|
24
|
+
if (item === null) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const obj = JSON.parse(item);
|
|
28
|
+
assert(typeGuard(obj, obj instanceof Object && obj.data instanceof Object && typeof obj.data.context === "string"));
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
function setStateStore(params) {
|
|
32
|
+
const { stateUrlParamValue, obj } = params;
|
|
33
|
+
localStorage.setItem(getKey({ stateUrlParamValue }), JSON.stringify(obj));
|
|
34
|
+
}
|
|
35
|
+
export function clearStateStore(params) {
|
|
36
|
+
const { stateUrlParamValue } = params;
|
|
37
|
+
localStorage.removeItem(getKey({ stateUrlParamValue }));
|
|
38
|
+
}
|
|
39
|
+
export function getStateData(params) {
|
|
40
|
+
const { stateUrlParamValue } = params;
|
|
41
|
+
const stateStore = getStateStore({ stateUrlParamValue });
|
|
42
|
+
if (stateStore === undefined) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return stateStore.data;
|
|
46
|
+
}
|
|
47
|
+
export function markStateDataAsProcessedByCallback(params) {
|
|
48
|
+
const { stateUrlParamValue } = params;
|
|
49
|
+
const obj = getStateStore({ stateUrlParamValue });
|
|
50
|
+
assert(obj !== undefined, "180465");
|
|
51
|
+
assert(obj.data.context === "redirect", "649531");
|
|
52
|
+
obj.data.hasBeenProcessedByCallback = true;
|
|
53
|
+
setStateStore({ stateUrlParamValue, obj });
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=StateData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateData.js","sourceRoot":"","sources":["../../../src/core/StateData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAkCvE,MAAM,yCAAyC,GAAG,cAAc,CAAC;AACjE,MAAM,oBAAoB,GAAG,EAAE,GAAG,yCAAyC,CAAC,M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;AACpD,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { OidcMetadata } from "./OidcMetadata";
|
|
2
|
+
import type { Oidc } from "./Oidc";
|
|
3
|
+
export type ParamsOfCreateOidc<DecodedIdToken extends Record<string, unknown> = Record<string, unknown>, AutoLogin extends boolean = false> = {
|
|
4
|
+
issuerUri: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
/**
|
|
7
|
+
* The scopes being requested from the OIDC/OAuth2 provider (default: `["profile"]`
|
|
8
|
+
* (the scope "openid" is added automatically as it's mandatory)
|
|
9
|
+
**/
|
|
10
|
+
scopes?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Transform the url (authorization endpoint) before redirecting to the login pages.
|
|
13
|
+
*
|
|
14
|
+
* The isSilent parameter is true when the redirect is initiated in the background iframe for silent signin.
|
|
15
|
+
* This can be used to omit ui related query parameters (like `ui_locales`).
|
|
16
|
+
*/
|
|
17
|
+
transformUrlBeforeRedirect?: (params: {
|
|
18
|
+
authorizationUrl: string;
|
|
19
|
+
isSilent: boolean;
|
|
20
|
+
}) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Extra query params to be added to the authorization endpoint url before redirecting or silent signing in.
|
|
23
|
+
* You can provide a function that returns those extra query params, it will be called
|
|
24
|
+
* when login() is called.
|
|
25
|
+
*
|
|
26
|
+
* Example: extraQueryParams: ()=> ({ ui_locales: "fr" })
|
|
27
|
+
*
|
|
28
|
+
* This parameter can also be passed to login() directly.
|
|
29
|
+
*/
|
|
30
|
+
extraQueryParams?: Record<string, string | undefined> | ((params: {
|
|
31
|
+
isSilent: boolean;
|
|
32
|
+
url: string;
|
|
33
|
+
}) => Record<string, string | undefined>);
|
|
34
|
+
/**
|
|
35
|
+
* Extra body params to be added to the /token POST request.
|
|
36
|
+
*
|
|
37
|
+
* It will be used when for the initial request, whenever the token is getting refreshed and if you call `renewTokens()`.
|
|
38
|
+
* You can also provide this parameter directly to the `renewTokens()` method.
|
|
39
|
+
*
|
|
40
|
+
* It can be either a string to string record or a function that returns a string to string record.
|
|
41
|
+
*
|
|
42
|
+
* Example: extraTokenParams: ()=> ({ selectedCustomer: "xxx" })
|
|
43
|
+
* extraTokenParams: { selectedCustomer: "xxx" }
|
|
44
|
+
*/
|
|
45
|
+
extraTokenParams?: Record<string, string | undefined> | (() => Record<string, string | undefined>);
|
|
46
|
+
/**
|
|
47
|
+
* Usage discouraged, it's here because we don't want to assume too much on your
|
|
48
|
+
* usecase but I can't think of a scenario where you would want anything
|
|
49
|
+
* other than the current page.
|
|
50
|
+
*
|
|
51
|
+
* Where to redirect after successful login.
|
|
52
|
+
* Default: window.location.href (here)
|
|
53
|
+
*
|
|
54
|
+
* It does not need to include the origin, eg: "/dashboard"
|
|
55
|
+
*
|
|
56
|
+
* This parameter can also be passed to login() directly as `redirectUrl`.
|
|
57
|
+
*/
|
|
58
|
+
postLoginRedirectUrl?: string;
|
|
59
|
+
/**
|
|
60
|
+
* What should you put in this parameter?
|
|
61
|
+
* - Vite project: `BASE_URL: import.meta.env.BASE_URL`
|
|
62
|
+
* - Create React App project: `BASE_URL: process.env.PUBLIC_URL`
|
|
63
|
+
* - Other: `BASE_URL: "/"` (Usually, or `/dashboard` if your app is not at the root of the domain)
|
|
64
|
+
*/
|
|
65
|
+
homeUrl: string;
|
|
66
|
+
decodedIdTokenSchema?: {
|
|
67
|
+
parse: (decodedIdToken_original: Oidc.Tokens.DecodedIdToken_base) => DecodedIdToken;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* This parameter defines after how many seconds of inactivity the user should be
|
|
71
|
+
* logged out automatically.
|
|
72
|
+
*
|
|
73
|
+
* WARNING: It should be configured on the identity server side
|
|
74
|
+
* as it's the authoritative source for security policies and not the client.
|
|
75
|
+
* If you don't provide this parameter it will be inferred from the refresh token expiration time.
|
|
76
|
+
* */
|
|
77
|
+
idleSessionLifetimeInSeconds?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Usage discouraged, this parameter exists because we don't want to assume
|
|
80
|
+
* too much about your usecase but I can't think of a scenario where you would
|
|
81
|
+
* want anything other than the current page.
|
|
82
|
+
*
|
|
83
|
+
* Default: { redirectTo: "current page" }
|
|
84
|
+
*/
|
|
85
|
+
autoLogoutParams?: Parameters<Oidc.LoggedIn<any>["logout"]>[0];
|
|
86
|
+
autoLogin?: AutoLogin;
|
|
87
|
+
/**
|
|
88
|
+
* Default: false
|
|
89
|
+
*
|
|
90
|
+
* See: https://docs.oidc-spa.dev/v/v7/resources/iframe-related-issues
|
|
91
|
+
*/
|
|
92
|
+
noIframe?: boolean;
|
|
93
|
+
debugLogs?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* WARNING: This option exists solely as a workaround
|
|
96
|
+
* for limitations in the Google OAuth API.
|
|
97
|
+
* See: https://docs.oidc-spa.dev/providers-configuration/google-oauth
|
|
98
|
+
*
|
|
99
|
+
* Do not use this for other providers.
|
|
100
|
+
* If you think you need a client secret in a SPA, you are likely
|
|
101
|
+
* trying to use a confidential (private) client in the browser,
|
|
102
|
+
* which is insecure and not supported.
|
|
103
|
+
*/
|
|
104
|
+
__unsafe_clientSecret?: string;
|
|
105
|
+
/**
|
|
106
|
+
* WARNING: Setting this to true is a workaround for provider
|
|
107
|
+
* like Google OAuth that don't support JWT access token.
|
|
108
|
+
* Use at your own risk, this is a hack.
|
|
109
|
+
*/
|
|
110
|
+
__unsafe_useIdTokenAsAccessToken?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* This option should only be used as a last resort.
|
|
113
|
+
*
|
|
114
|
+
* If your OIDC provider is correctly configured, this should not be necessary.
|
|
115
|
+
*
|
|
116
|
+
* The metadata is normally retrieved automatically from:
|
|
117
|
+
* `${issuerUri}/.well-known/openid-configuration`
|
|
118
|
+
*
|
|
119
|
+
* Use this only if that endpoint is not accessible (e.g. due to missing CORS headers
|
|
120
|
+
* or non-standard deployments), and you cannot fix the server-side configuration.
|
|
121
|
+
*/
|
|
122
|
+
__metadata?: Partial<OidcMetadata>;
|
|
123
|
+
};
|
|
124
|
+
/** @see: https://docs.oidc-spa.dev/v/v7/usage */
|
|
125
|
+
export declare function createOidc<DecodedIdToken extends Record<string, unknown> = Record<string, unknown>, AutoLogin extends boolean = false>(params: ParamsOfCreateOidc<DecodedIdToken, AutoLogin>): Promise<AutoLogin extends true ? Oidc.LoggedIn<DecodedIdToken> : Oidc<DecodedIdToken>>;
|
|
126
|
+
export declare function createOidc_nonMemoized<DecodedIdToken extends Record<string, unknown> = Record<string, unknown>, AutoLogin extends boolean = false>(params: Omit<ParamsOfCreateOidc<DecodedIdToken, AutoLogin>, "issuerUri" | "clientId" | "scopes" | "debugLogs">, preProcessedParams: {
|
|
127
|
+
issuerUri: string;
|
|
128
|
+
clientId: string;
|
|
129
|
+
scopes: string[];
|
|
130
|
+
configId: string;
|
|
131
|
+
log: typeof console.log | undefined;
|
|
132
|
+
}): Promise<AutoLogin extends true ? Oidc.LoggedIn<DecodedIdToken> : Oidc<DecodedIdToken>>;
|