@thunderid/javascript 1.4.0 → 1.4.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/dist/DefaultCrypto.d.ts.map +1 -1
- package/dist/IsomorphicCrypto.d.ts +8 -0
- package/dist/IsomorphicCrypto.d.ts.map +1 -1
- package/dist/StorageManager.d.ts.map +1 -1
- package/dist/ThunderIDJavaScriptClient.d.ts +19 -1
- package/dist/ThunderIDJavaScriptClient.d.ts.map +1 -1
- package/dist/cjs/index.cjs +136 -26
- package/dist/constants/OIDCRequestConstants.d.ts +5 -0
- package/dist/constants/OIDCRequestConstants.d.ts.map +1 -1
- package/dist/edge/index.js +136 -28
- package/dist/index.js +136 -28
- package/dist/models/client.d.ts +2 -2
- package/dist/models/client.d.ts.map +1 -1
- package/dist/utils/AuthenticationHelper.d.ts.map +1 -1
- package/dist/utils/base64Encode.d.ts +1 -1
- package/dist/utils/base64Encode.d.ts.map +1 -1
- package/dist/utils/getAuthorizeRequestUrlParams.d.ts +2 -1
- package/dist/utils/getAuthorizeRequestUrlParams.d.ts.map +1 -1
- package/dist/utils/getOAuthErrorMessage.d.ts +17 -0
- package/dist/utils/getOAuthErrorMessage.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultCrypto.d.ts","sourceRoot":"","sources":["../src/DefaultCrypto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DefaultCrypto.d.ts","sourceRoot":"","sources":["../src/DefaultCrypto.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,MAAM,EAAE,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,qBAAa,aAAc,YAAW,MAAM,CAAC,UAAU,CAAC;IAC/C,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAKtC,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM;IAI1C,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;IAIzC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAQ7C,SAAS,CACpB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,MAAM,EAAE,EACpB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,MAAM,EACvB,iBAAiB,UAAO,GACvB,OAAO,CAAC,OAAO,CAAC;CAapB"}
|
|
@@ -8,6 +8,14 @@ export declare class IsomorphicCrypto<T = any> {
|
|
|
8
8
|
* @returns code verifier.
|
|
9
9
|
*/
|
|
10
10
|
getCodeVerifier(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Generates the random part of an authorization request `state` from 32 random bytes. Only
|
|
13
|
+
* letters and digits are kept, so the value never contains the `_` that separates the parts of
|
|
14
|
+
* the state.
|
|
15
|
+
*
|
|
16
|
+
* @returns A random string of about 42 characters.
|
|
17
|
+
*/
|
|
18
|
+
generateState(): string;
|
|
11
19
|
/**
|
|
12
20
|
* Derive code challenge from the code verifier.
|
|
13
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsomorphicCrypto.d.ts","sourceRoot":"","sources":["../src/IsomorphicCrypto.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,MAAM,EAAE,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAErD,qBAAa,gBAAgB,CAAC,CAAC,GAAG,GAAG;IACnC,OAAO,CAAC,WAAW,CAAY;gBAEZ,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAIzC;;;;OAIG;IACI,eAAe,IAAI,MAAM;IAIhC;;;;;;OAMG;IACU,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKhE;;;;;;;;;OASG;IAEI,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI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AAE,MAAM,wBAAwB,EACnC,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,IAAI,CAAC;IAIH,yBAAyB,CACpC,GAAG,EAAE,MAAM,cAAc,EACzB,KAAK,EAAE,mBAAmB,EAC1B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAIH,sBAAsB,CACjC,GAAG,EAAE,MAAM,WAAW,EACtB,KAAK,EAAE,mBAAmB,EAC1B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAaH,uBAAuB,CAClC,GAAG,EAAE,MAAM,WAAW,EACtB,KAAK,EAAE,mBAAmB,EAC1B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAIH,yBAAyB,CAAC,GAAG,EAAE,MAAM,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE,mCAAmC,CAAC,GAAG,EAAE,MAAM,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvF,4BAA4B,CAAC,GAAG,EAAE,MAAM,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvF,yBAAyB,CAAC,GAAG,EAAE,MAAM,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAajF,0BAA0B,CAAC,GAAG,EAAE,MAAM,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGhG;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -26,7 +26,13 @@ declare class ThunderIDJavaScriptClient<T = Config> implements ThunderIDClient<T
|
|
|
26
26
|
constructor(storage?: Storage, cryptoUtils?: Crypto);
|
|
27
27
|
initialize(config: T, storage?: Storage): Promise<boolean>;
|
|
28
28
|
reInitialize(config: Partial<T>): Promise<boolean>;
|
|
29
|
-
getConfiguration(): T
|
|
29
|
+
getConfiguration(): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the signed-in user, read from the claims of the session's ID token.
|
|
32
|
+
*
|
|
33
|
+
* @param userId - The session to read, on a server.
|
|
34
|
+
* @throws {ThunderIDRuntimeError} With code `JS-AUTH_CORE-GU-NF01` when the session holds no ID token.
|
|
35
|
+
*/
|
|
30
36
|
getUser(userId?: string): Promise<User>;
|
|
31
37
|
isSignedIn(userId?: string): Promise<boolean>;
|
|
32
38
|
getAccessToken(sessionId?: string): Promise<string>;
|
|
@@ -60,8 +66,20 @@ declare class ThunderIDJavaScriptClient<T = Config> implements ThunderIDClient<T
|
|
|
60
66
|
params: Record<string, unknown>;
|
|
61
67
|
}): Promise<TokenResponse>;
|
|
62
68
|
protected getSignOutUrl(userId?: string): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the endpoints the SDK calls. Loads the discovery document first when no other call has.
|
|
71
|
+
*/
|
|
63
72
|
protected getOpenIDProviderEndpoints(): Promise<Partial<OIDCEndpoints>>;
|
|
73
|
+
/**
|
|
74
|
+
* Returns the discovery document. Loads it first when no other call has. Resolves to `null`
|
|
75
|
+
* before `initialize()`.
|
|
76
|
+
*/
|
|
64
77
|
getDiscoveryResponse(): Promise<OIDCDiscoveryApiResponse | null>;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the claims of the session's ID token, or of `idToken` when the session holds none.
|
|
80
|
+
*
|
|
81
|
+
* @throws {ThunderIDRuntimeError} With code `JS-AUTH_CORE-GDIT-NF01` when there is no ID token to decode.
|
|
82
|
+
*/
|
|
65
83
|
protected getDecodedIdToken(userId?: string, idToken?: string): Promise<IdToken>;
|
|
66
84
|
protected getIdToken(userId?: string): Promise<string>;
|
|
67
85
|
protected getUserSession(userId?: string): Promise<UserSession>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThunderIDJavaScriptClient.d.ts","sourceRoot":"","sources":["../src/ThunderIDJavaScriptClient.ts"],"names":[],"mappings":"
|
|
1
|
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GAAG,OAAO,CAAC,IAAI,CAAC;IAIjF,aAAa,IAAI,MAAM;IAI9B,SAAS,CAAC,iBAAiB,IAAI,cAAc,CAAC,CAAC,CAAC;IAIhD,SAAS,CAAC,eAAe,IAAI,gBAAgB;WAM/B,mBAAmB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO;WAQrD,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO;IAUjD,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;CASxE;AAED,eAAe,yBAAyB,CAAC"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -29,8 +29,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
}) : target, mod));
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
|
-
let
|
|
33
|
-
|
|
32
|
+
let jose_base64url = require("jose/base64url");
|
|
33
|
+
jose_base64url = __toESM(jose_base64url);
|
|
34
|
+
let jose_key_import = require("jose/key/import");
|
|
35
|
+
jose_key_import = __toESM(jose_key_import);
|
|
36
|
+
let jose_jwt_verify = require("jose/jwt/verify");
|
|
37
|
+
jose_jwt_verify = __toESM(jose_jwt_verify);
|
|
34
38
|
|
|
35
39
|
//#region src/constants/TokenConstants.ts
|
|
36
40
|
/**
|
|
@@ -107,6 +111,16 @@ var IsomorphicCrypto = class {
|
|
|
107
111
|
return this.cryptoUtils.base64URLEncode(this.cryptoUtils.generateRandomBytes(32));
|
|
108
112
|
}
|
|
109
113
|
/**
|
|
114
|
+
* Generates the random part of an authorization request `state` from 32 random bytes. Only
|
|
115
|
+
* letters and digits are kept, so the value never contains the `_` that separates the parts of
|
|
116
|
+
* the state.
|
|
117
|
+
*
|
|
118
|
+
* @returns A random string of about 42 characters.
|
|
119
|
+
*/
|
|
120
|
+
generateState() {
|
|
121
|
+
return this.cryptoUtils.base64URLEncode(this.cryptoUtils.generateRandomBytes(32)).replace(/[^A-Za-z0-9]/g, "");
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
110
124
|
* Derive code challenge from the code verifier.
|
|
111
125
|
*
|
|
112
126
|
* @param verifier - Code verifier.
|
|
@@ -2245,7 +2259,10 @@ const OIDCRequestConstants = {
|
|
|
2245
2259
|
SIGN_OUT_SUCCESS: "sign_out_success",
|
|
2246
2260
|
STATE: "state"
|
|
2247
2261
|
},
|
|
2248
|
-
SignIn: {
|
|
2262
|
+
SignIn: {
|
|
2263
|
+
Payload: { DEFAULT_SCOPES: [ScopeConstants_default.OPENID, ScopeConstants_default.PROFILE] },
|
|
2264
|
+
Storage: { StorageKeys: { STATE: "authorization_state" } }
|
|
2265
|
+
},
|
|
2249
2266
|
SignOut: { Storage: { StorageKeys: { SIGN_OUT_URL: "sign_out_url" } } }
|
|
2250
2267
|
};
|
|
2251
2268
|
var OIDCRequestConstants_default = OIDCRequestConstants;
|
|
@@ -2702,11 +2719,11 @@ var DefaultCacheStore = class {
|
|
|
2702
2719
|
*/
|
|
2703
2720
|
var DefaultCrypto = class {
|
|
2704
2721
|
base64URLDecode(value) {
|
|
2705
|
-
const decodedArray =
|
|
2722
|
+
const decodedArray = jose_base64url.decode(value);
|
|
2706
2723
|
return new TextDecoder().decode(decodedArray);
|
|
2707
2724
|
}
|
|
2708
2725
|
base64URLEncode(value) {
|
|
2709
|
-
return
|
|
2726
|
+
return jose_base64url.encode(value);
|
|
2710
2727
|
}
|
|
2711
2728
|
generateRandomBytes(length) {
|
|
2712
2729
|
return crypto.getRandomValues(new Uint8Array(length));
|
|
@@ -2717,8 +2734,7 @@ var DefaultCrypto = class {
|
|
|
2717
2734
|
return new Uint8Array(hashBuffer);
|
|
2718
2735
|
}
|
|
2719
2736
|
async verifyJwt(idToken, jwk, algorithms, clientId, issuer, subject, clockTolerance, validateJwtIssuer = true) {
|
|
2720
|
-
|
|
2721
|
-
await jose.jwtVerify(idToken, key, {
|
|
2737
|
+
await (0, jose_jwt_verify.jwtVerify)(idToken, await (0, jose_key_import.importJWK)(jwk), {
|
|
2722
2738
|
algorithms,
|
|
2723
2739
|
audience: [clientId],
|
|
2724
2740
|
clockTolerance,
|
|
@@ -2805,6 +2821,7 @@ var StorageManager = class StorageManager {
|
|
|
2805
2821
|
return `${store}-${this.id}`;
|
|
2806
2822
|
}
|
|
2807
2823
|
static isLocalStorageAvailable() {
|
|
2824
|
+
if (typeof window === "undefined") return false;
|
|
2808
2825
|
try {
|
|
2809
2826
|
const testValue = "__AUTH_SDK_STORAGE_TEST__";
|
|
2810
2827
|
localStorage.setItem(testValue, testValue);
|
|
@@ -3444,7 +3461,7 @@ var AuthenticationHelper = class {
|
|
|
3444
3461
|
} else sessionData = await this.storageManager.getSessionData(userId);
|
|
3445
3462
|
const scope = processOpenIDScopes_default(configData.scopes);
|
|
3446
3463
|
if (typeof text !== "string") return text;
|
|
3447
|
-
return text.replace(TokenExchangeConstants_default.Placeholders.ACCESS_TOKEN, sessionData
|
|
3464
|
+
return text.replace(TokenExchangeConstants_default.Placeholders.ACCESS_TOKEN, () => sessionData?.access_token ?? "").replace(TokenExchangeConstants_default.Placeholders.USERNAME, () => sessionData?.id_token ? this.getAuthenticatedUserInfo(sessionData.id_token).username ?? "" : "").replace(TokenExchangeConstants_default.Placeholders.SCOPES, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientId ?? "").replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
|
|
3448
3465
|
}
|
|
3449
3466
|
/**
|
|
3450
3467
|
* Clears all temporary and session data for the given user.
|
|
@@ -3499,7 +3516,7 @@ var AuthenticationHelper_default = AuthenticationHelper;
|
|
|
3499
3516
|
/**
|
|
3500
3517
|
* Encodes a string to standard base64 using `jose` (already a package dependency).
|
|
3501
3518
|
*
|
|
3502
|
-
* `
|
|
3519
|
+
* jose's `base64url.encode` is environment-agnostic (browser, Node.js, Deno, Bun,
|
|
3503
3520
|
* edge/service-worker runtimes). It produces base64url output, which is then
|
|
3504
3521
|
* converted to standard base64 by restoring the `+`/`/` characters and adding
|
|
3505
3522
|
* `=` padding.
|
|
@@ -3513,7 +3530,7 @@ var AuthenticationHelper_default = AuthenticationHelper;
|
|
|
3513
3530
|
* ```
|
|
3514
3531
|
*/
|
|
3515
3532
|
const base64Encode = (value) => {
|
|
3516
|
-
const b64url =
|
|
3533
|
+
const b64url = jose_base64url.encode(new TextEncoder().encode(value));
|
|
3517
3534
|
const rem = b64url.length % 4;
|
|
3518
3535
|
return (rem === 0 ? b64url : b64url + "=".repeat(4 - rem)).replace(/-/g, "+").replace(/_/g, "/");
|
|
3519
3536
|
};
|
|
@@ -3648,7 +3665,7 @@ var generateStateParamForRequestCorrelation_default = generateStateParamForReque
|
|
|
3648
3665
|
* This utility ensures the `openid` scope is always included, handles both string and array forms of the `scope` parameter,
|
|
3649
3666
|
* and supports PKCE and custom parameters. Throws if a code challenge is provided without a code challenge method.
|
|
3650
3667
|
*
|
|
3651
|
-
* @param options - The main options for the authorization request, including redirectUri, clientId, scope, responseMode, codeChallenge, codeChallengeMethod, and
|
|
3668
|
+
* @param options - The main options for the authorization request, including redirectUri, clientId, scope, responseMode, codeChallenge, codeChallengeMethod, prompt, and randomState (a value generated from random bytes that makes the `state` unique to this request).
|
|
3652
3669
|
* @param pkceOptions - PKCE options, including the PKCE key for state correlation.
|
|
3653
3670
|
* @param customParams - Optional custom parameters to include in the request (excluding the `state` param, which is handled separately).
|
|
3654
3671
|
* @returns A Map of key-value pairs representing the authorization request URL parameters.
|
|
@@ -3693,14 +3710,67 @@ const getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
|
|
|
3693
3710
|
const customState = customParams?.[OIDCRequestConstants_default.Params.STATE]?.toString() ?? "";
|
|
3694
3711
|
let customStateValue = customState;
|
|
3695
3712
|
if (options.instanceId) customStateValue = AUTH_INSTANCE_PREFIX + options.instanceId + (customState ? `_${customState}` : "");
|
|
3713
|
+
if (options.randomState) customStateValue = customStateValue ? `${customStateValue}_${options.randomState}` : options.randomState;
|
|
3696
3714
|
authorizeRequestParams.set(OIDCRequestConstants_default.Params.STATE, generateStateParamForRequestCorrelation_default(pkceKey, customStateValue));
|
|
3697
3715
|
return authorizeRequestParams;
|
|
3698
3716
|
};
|
|
3699
3717
|
var getAuthorizeRequestUrlParams_default = getAuthorizeRequestUrlParams;
|
|
3700
3718
|
|
|
3719
|
+
//#endregion
|
|
3720
|
+
//#region src/utils/getOAuthErrorMessage.ts
|
|
3721
|
+
/**
|
|
3722
|
+
* Builds a readable message from the body of an OAuth 2.0 error response (RFC 6749 section 5.2).
|
|
3723
|
+
*
|
|
3724
|
+
* Only the `error` and `error_description` members are read, so nothing else in the body, such as
|
|
3725
|
+
* a token, can end up in the message.
|
|
3726
|
+
*
|
|
3727
|
+
* @param body - The parsed response body, or its raw text.
|
|
3728
|
+
* @param fallback - The message to use when the body carries neither member.
|
|
3729
|
+
* @returns `"<error>: <error_description>"`, whichever of the two is present, or `fallback`.
|
|
3730
|
+
*
|
|
3731
|
+
* @example
|
|
3732
|
+
* getOAuthErrorMessage({error: 'invalid_grant', error_description: 'The code has expired.'}, 'Failed');
|
|
3733
|
+
* // Returns: "invalid_grant: The code has expired."
|
|
3734
|
+
*/
|
|
3735
|
+
const getOAuthErrorMessage = (body, fallback) => {
|
|
3736
|
+
let parsed = body;
|
|
3737
|
+
if (typeof body === "string") try {
|
|
3738
|
+
parsed = JSON.parse(body);
|
|
3739
|
+
} catch {
|
|
3740
|
+
return fallback;
|
|
3741
|
+
}
|
|
3742
|
+
if (!parsed || typeof parsed !== "object") return fallback;
|
|
3743
|
+
const { error: error$1, error_description: description } = parsed;
|
|
3744
|
+
const parts = [error$1, description].filter((part) => typeof part === "string" && part.trim().length > 0);
|
|
3745
|
+
return parts.length > 0 ? parts.join(": ") : fallback;
|
|
3746
|
+
};
|
|
3747
|
+
var getOAuthErrorMessage_default = getOAuthErrorMessage;
|
|
3748
|
+
|
|
3701
3749
|
//#endregion
|
|
3702
3750
|
//#region src/ThunderIDJavaScriptClient.ts
|
|
3703
3751
|
const WELL_KNOWN_PATH = "/.well-known/openid-configuration";
|
|
3752
|
+
/**
|
|
3753
|
+
* The issuer a discovery document must name: the configured `endpoints.issuer`, else the URL the
|
|
3754
|
+
* well-known path was appended to (OpenID Connect Discovery 1.0, section 4.3).
|
|
3755
|
+
*/
|
|
3756
|
+
const getExpectedIssuer = (configuredIssuer, wellKnownOverride, baseUrl) => {
|
|
3757
|
+
if (configuredIssuer) return configuredIssuer;
|
|
3758
|
+
if (wellKnownOverride) return wellKnownOverride.endsWith(WELL_KNOWN_PATH) ? wellKnownOverride.slice(0, -33) : void 0;
|
|
3759
|
+
return baseUrl || void 0;
|
|
3760
|
+
};
|
|
3761
|
+
/**
|
|
3762
|
+
* Compares two issuers exactly, apart from a trailing slash on either side.
|
|
3763
|
+
*/
|
|
3764
|
+
const issuersMatch = (discovered, expected) => typeof discovered === "string" && discovered.replace(/\/+$/, "") === expected.replace(/\/+$/, "");
|
|
3765
|
+
/**
|
|
3766
|
+
* Reads a readable message from the body of a failed token, revocation, or custom grant response.
|
|
3767
|
+
*/
|
|
3768
|
+
const readErrorMessage = async (response, fallback) => getOAuthErrorMessage_default(await response.json().catch(() => void 0), fallback);
|
|
3769
|
+
/**
|
|
3770
|
+
* The storage key of the `state` sent with the authorization request whose PKCE key is given. Both
|
|
3771
|
+
* share the request index, so the callback finds the state from the index at the end of `state`.
|
|
3772
|
+
*/
|
|
3773
|
+
const getStateStorageKey = (pkceKey) => pkceKey.replace(PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER, OIDCRequestConstants_default.SignIn.Storage.StorageKeys.STATE);
|
|
3704
3774
|
const REVOKE_ACCESS_TOKEN_REQUEST_TIMEOUT_MS = 1e4;
|
|
3705
3775
|
const DEFAULT_CONFIG = {
|
|
3706
3776
|
enablePKCE: true,
|
|
@@ -3758,12 +3828,19 @@ var ThunderIDJavaScriptClient = class {
|
|
|
3758
3828
|
await this.loadOpenIDProviderConfiguration(true);
|
|
3759
3829
|
return true;
|
|
3760
3830
|
}
|
|
3761
|
-
getConfiguration() {
|
|
3762
|
-
return this.storageManager.getConfigData();
|
|
3831
|
+
async getConfiguration() {
|
|
3832
|
+
return await this.storageManager.getConfigData();
|
|
3763
3833
|
}
|
|
3834
|
+
/**
|
|
3835
|
+
* Returns the signed-in user, read from the claims of the session's ID token.
|
|
3836
|
+
*
|
|
3837
|
+
* @param userId - The session to read, on a server.
|
|
3838
|
+
* @throws {ThunderIDRuntimeError} With code `JS-AUTH_CORE-GU-NF01` when the session holds no ID token.
|
|
3839
|
+
*/
|
|
3764
3840
|
async getUser(userId) {
|
|
3765
3841
|
const sessionData = await this.storageManager.getSessionData(userId);
|
|
3766
|
-
|
|
3842
|
+
if (!sessionData?.id_token) throw new ThunderIDRuntimeError("No signed-in session was found.", "JS-AUTH_CORE-GU-NF01", "javascript");
|
|
3843
|
+
const authenticatedUser = this.authHelper.getAuthenticatedUserInfo(sessionData.id_token);
|
|
3767
3844
|
Object.keys(authenticatedUser).forEach((key) => {
|
|
3768
3845
|
if (authenticatedUser[key] === void 0 || authenticatedUser[key] === "" || authenticatedUser[key] === null) delete authenticatedUser[key];
|
|
3769
3846
|
});
|
|
@@ -3832,7 +3909,7 @@ var ThunderIDJavaScriptClient = class {
|
|
|
3832
3909
|
};
|
|
3833
3910
|
if (config.attachToken) requestHeaders = {
|
|
3834
3911
|
...requestHeaders,
|
|
3835
|
-
Authorization: `Bearer ${(await this.storageManager.getSessionData(sessionId))
|
|
3912
|
+
Authorization: `Bearer ${(await this.storageManager.getSessionData(sessionId))?.access_token}`
|
|
3836
3913
|
};
|
|
3837
3914
|
const requestConfig = {
|
|
3838
3915
|
body: data.join("&"),
|
|
@@ -3846,7 +3923,7 @@ var ThunderIDJavaScriptClient = class {
|
|
|
3846
3923
|
} catch (error$1) {
|
|
3847
3924
|
throw new ThunderIDAuthException("JS-AUTH_CORE-RCG-NE02", "The custom grant request failed.", error$1 ?? "The request sent to get the custom grant failed.");
|
|
3848
3925
|
}
|
|
3849
|
-
if (response.status !== 200 || !response.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RCG-HE03", `Invalid response status received for the custom grant request. (${response.statusText})`, await response.
|
|
3926
|
+
if (response.status !== 200 || !response.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RCG-HE03", `Invalid response status received for the custom grant request. (${response.statusText})`, await readErrorMessage(response, "The custom grant request was rejected."));
|
|
3850
3927
|
if (config.returnsSession) return this.authHelper.handleTokenResponse(response, sessionId);
|
|
3851
3928
|
return await response.json();
|
|
3852
3929
|
}
|
|
@@ -3878,7 +3955,8 @@ var ThunderIDJavaScriptClient = class {
|
|
|
3878
3955
|
const configData = await this.configProvider();
|
|
3879
3956
|
if (!forceInit && await this.storageManager.getTemporaryDataParameter(OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)) return;
|
|
3880
3957
|
const { discovery, baseUrl, endpoints } = configData;
|
|
3881
|
-
const
|
|
3958
|
+
const wellKnownOverride = endpoints?.wellKnown;
|
|
3959
|
+
const resolvedWellKnownEndpoint = wellKnownOverride || (discovery?.wellKnown?.enabled !== false && baseUrl ? `${baseUrl}${WELL_KNOWN_PATH}` : void 0);
|
|
3882
3960
|
if (resolvedWellKnownEndpoint) {
|
|
3883
3961
|
let response;
|
|
3884
3962
|
try {
|
|
@@ -3893,8 +3971,19 @@ var ThunderIDJavaScriptClient = class {
|
|
|
3893
3971
|
}
|
|
3894
3972
|
if (response) {
|
|
3895
3973
|
let discoveryResolved = false;
|
|
3974
|
+
let discovered;
|
|
3975
|
+
try {
|
|
3976
|
+
discovered = await response.json();
|
|
3977
|
+
} catch {
|
|
3978
|
+
discovered = void 0;
|
|
3979
|
+
}
|
|
3980
|
+
if (discovered && typeof discovered === "object") {
|
|
3981
|
+
const expectedIssuer = getExpectedIssuer(endpoints?.issuer, wellKnownOverride, baseUrl);
|
|
3982
|
+
if (expectedIssuer !== void 0 && !issuersMatch(discovered.issuer, expectedIssuer)) throw new ThunderIDRuntimeError("The discovered issuer does not match the expected issuer. Set endpoints.issuer if your server uses a custom issuer.", "JS-AUTH_CORE-GOPMD-IV03", "javascript");
|
|
3983
|
+
}
|
|
3896
3984
|
try {
|
|
3897
|
-
|
|
3985
|
+
if (!discovered || typeof discovered !== "object") throw new Error("The discovery response is not a JSON object.");
|
|
3986
|
+
await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpoints(discovered));
|
|
3898
3987
|
discoveryResolved = true;
|
|
3899
3988
|
} catch (error$1) {
|
|
3900
3989
|
logger_default.warn(`ThunderIDJavaScriptClient: Could not resolve endpoints from the discovery response of ${resolvedWellKnownEndpoint}; falling back to endpoints derived from the base URL.`, error$1);
|
|
@@ -3942,10 +4031,12 @@ var ThunderIDJavaScriptClient = class {
|
|
|
3942
4031
|
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
3943
4032
|
instanceId: this.getInstanceId().toString(),
|
|
3944
4033
|
prompt: configData.prompt,
|
|
4034
|
+
randomState: this.cryptoHelper.generateState(),
|
|
3945
4035
|
redirectUri: configData.afterSignInUrl ?? "",
|
|
3946
4036
|
responseMode: configData.responseMode,
|
|
3947
4037
|
scopes: processOpenIDScopes_default(configData.scopes)
|
|
3948
4038
|
}).filter(([, v]) => v !== void 0)), { key: pkceKey }, authRequestConfig);
|
|
4039
|
+
await this.storageManager.setHybridDataParameter(getStateStorageKey(pkceKey), authorizeRequestParams.get(OIDCRequestConstants_default.Params.STATE) ?? "", userId);
|
|
3949
4040
|
Array.from(authorizeRequestParams.entries()).forEach(([paramKey, paramValue]) => {
|
|
3950
4041
|
authorizeRequest.searchParams.append(paramKey, paramValue);
|
|
3951
4042
|
});
|
|
@@ -3956,6 +4047,10 @@ var ThunderIDJavaScriptClient = class {
|
|
|
3956
4047
|
}
|
|
3957
4048
|
async requestAccessToken(authorizationCode, state, userId, tokenRequestConfig) {
|
|
3958
4049
|
if (!await this.storageManager.getTemporaryDataParameter(OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)) await this.loadOpenIDProviderConfiguration(false);
|
|
4050
|
+
const stateStorageKey = getStateStorageKey(extractPkceStorageKeyFromState_default(state ?? ""));
|
|
4051
|
+
const expectedState = await this.storageManager.getHybridDataParameter(stateStorageKey, userId);
|
|
4052
|
+
if (!state || typeof expectedState !== "string" || !expectedState || state !== expectedState) throw new ThunderIDRuntimeError("The state returned to the callback does not match the state of the authorization request.", "JS-AUTH_CORE-RAT1-IV04", "javascript");
|
|
4053
|
+
await this.storageManager.removeHybridDataParameter(stateStorageKey, userId);
|
|
3959
4054
|
const tokenEndpoint = (await this.oidcProviderMetaDataProvider()).token_endpoint;
|
|
3960
4055
|
const configData = await this.configProvider();
|
|
3961
4056
|
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) throw new ThunderIDAuthException("JS-AUTH_CORE-RAT1-NF01", "Token endpoint not found.", "No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty.");
|
|
@@ -3990,7 +4085,7 @@ var ThunderIDJavaScriptClient = class {
|
|
|
3990
4085
|
} catch (error$1) {
|
|
3991
4086
|
throw new ThunderIDAuthException("JS-AUTH_CORE-RAT1-NE02", "Requesting access token failed", error$1 ?? "The request to get the access token from the server failed.");
|
|
3992
4087
|
}
|
|
3993
|
-
if (!tokenResponse.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RAT1-HE03", `Requesting access token failed with ${tokenResponse.statusText}`, await tokenResponse.
|
|
4088
|
+
if (!tokenResponse.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RAT1-HE03", `Requesting access token failed with ${tokenResponse.statusText}`, await readErrorMessage(tokenResponse, "The token request was rejected."));
|
|
3994
4089
|
return this.authHelper.handleTokenResponse(tokenResponse, userId);
|
|
3995
4090
|
}
|
|
3996
4091
|
async getSignOutUrl(userId) {
|
|
@@ -4007,7 +4102,11 @@ var ThunderIDJavaScriptClient = class {
|
|
|
4007
4102
|
queryParams.set("state", OIDCRequestConstants_default.Params.SIGN_OUT_SUCCESS);
|
|
4008
4103
|
return `${logoutEndpoint}?${queryParams.toString()}`;
|
|
4009
4104
|
}
|
|
4105
|
+
/**
|
|
4106
|
+
* Returns the endpoints the SDK calls. Loads the discovery document first when no other call has.
|
|
4107
|
+
*/
|
|
4010
4108
|
async getOpenIDProviderEndpoints() {
|
|
4109
|
+
await this.loadOpenIDProviderConfiguration(false);
|
|
4011
4110
|
const meta = await this.oidcProviderMetaDataProvider();
|
|
4012
4111
|
return {
|
|
4013
4112
|
authorizationEndpoint: meta.authorization_endpoint ?? "",
|
|
@@ -4021,16 +4120,27 @@ var ThunderIDJavaScriptClient = class {
|
|
|
4021
4120
|
userinfoEndpoint: meta.userinfo_endpoint ?? ""
|
|
4022
4121
|
};
|
|
4023
4122
|
}
|
|
4123
|
+
/**
|
|
4124
|
+
* Returns the discovery document. Loads it first when no other call has. Resolves to `null`
|
|
4125
|
+
* before `initialize()`.
|
|
4126
|
+
*/
|
|
4024
4127
|
async getDiscoveryResponse() {
|
|
4025
4128
|
if (!this.storageManager) return null;
|
|
4129
|
+
await this.loadOpenIDProviderConfiguration(false);
|
|
4026
4130
|
return this.storageManager.loadOpenIDProviderConfiguration();
|
|
4027
4131
|
}
|
|
4132
|
+
/**
|
|
4133
|
+
* Returns the claims of the session's ID token, or of `idToken` when the session holds none.
|
|
4134
|
+
*
|
|
4135
|
+
* @throws {ThunderIDRuntimeError} With code `JS-AUTH_CORE-GDIT-NF01` when there is no ID token to decode.
|
|
4136
|
+
*/
|
|
4028
4137
|
async getDecodedIdToken(userId, idToken) {
|
|
4029
|
-
const
|
|
4030
|
-
|
|
4138
|
+
const token = (await this.storageManager.getSessionData(userId))?.id_token ?? idToken;
|
|
4139
|
+
if (!token) throw new ThunderIDRuntimeError("No signed-in session was found.", "JS-AUTH_CORE-GDIT-NF01", "javascript");
|
|
4140
|
+
return this.cryptoHelper.decodeJwtToken(token);
|
|
4031
4141
|
}
|
|
4032
4142
|
async getIdToken(userId) {
|
|
4033
|
-
return (await this.storageManager.getSessionData(userId))
|
|
4143
|
+
return (await this.storageManager.getSessionData(userId))?.id_token;
|
|
4034
4144
|
}
|
|
4035
4145
|
async getUserSession(userId) {
|
|
4036
4146
|
return { scopes: (await this.storageManager.getSessionData(userId))?.scope?.split(" ") };
|
|
@@ -4061,7 +4171,7 @@ var ThunderIDJavaScriptClient = class {
|
|
|
4061
4171
|
} catch (error$1) {
|
|
4062
4172
|
throw new ThunderIDAuthException("JS-AUTH_CORE-RAT2-NR03", "Refresh access token request failed.", error$1 ?? "The request to refresh the access token failed.");
|
|
4063
4173
|
}
|
|
4064
|
-
if (!tokenResponse.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RAT2-HE04", `Refreshing access token failed with ${tokenResponse.statusText}`, await tokenResponse.
|
|
4174
|
+
if (!tokenResponse.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RAT2-HE04", `Refreshing access token failed with ${tokenResponse.statusText}`, await readErrorMessage(tokenResponse, "The refresh token request was rejected."));
|
|
4065
4175
|
return this.authHelper.handleTokenResponse(tokenResponse, userId);
|
|
4066
4176
|
}
|
|
4067
4177
|
/**
|
|
@@ -4100,7 +4210,7 @@ var ThunderIDJavaScriptClient = class {
|
|
|
4100
4210
|
} catch (error$1) {
|
|
4101
4211
|
throw new ThunderIDAuthException("JS-AUTH_CORE-RCCT-NE02", "Requesting client credentials token failed.", error$1 ?? "The request to get the client credentials access token failed.");
|
|
4102
4212
|
}
|
|
4103
|
-
if (!tokenResponse.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RCCT-HE03", `Requesting client credentials token failed with ${tokenResponse.statusText}`, await tokenResponse.
|
|
4213
|
+
if (!tokenResponse.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RCCT-HE03", `Requesting client credentials token failed with ${tokenResponse.statusText}`, await readErrorMessage(tokenResponse, "The client credentials token request was rejected."));
|
|
4104
4214
|
const parsedResponse = await tokenResponse.json();
|
|
4105
4215
|
parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
|
|
4106
4216
|
await this.storageManager.setSessionData(parsedResponse, sessionId);
|
|
@@ -4144,7 +4254,7 @@ var ThunderIDJavaScriptClient = class {
|
|
|
4144
4254
|
} catch (error$1) {
|
|
4145
4255
|
throw new ThunderIDAuthException("JS-AUTH_CORE-RAT3-NE02", "The request to revoke access token failed.", error$1 ?? "The request sent to revoke the access token failed.");
|
|
4146
4256
|
}
|
|
4147
|
-
if (response.status !== 200 || !response.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RAT3-HE03", `Invalid response status received for revoke access token request (${response.statusText}).`, await response.
|
|
4257
|
+
if (response.status !== 200 || !response.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RAT3-HE03", `Invalid response status received for revoke access token request (${response.statusText}).`, await readErrorMessage(response, "The revocation request was rejected."));
|
|
4148
4258
|
return response;
|
|
4149
4259
|
}
|
|
4150
4260
|
async revokeAccessToken(userId) {
|
|
@@ -4200,7 +4310,7 @@ var ThunderIDJavaScriptClient = class {
|
|
|
4200
4310
|
} catch {
|
|
4201
4311
|
parsedBody = rawBody;
|
|
4202
4312
|
}
|
|
4203
|
-
if (!response.ok) throw new ThunderIDAPIError(parsedBody, "JS-AUTH_CORE-CIBA1-HE03", "javascript", response.status, response.statusText, "CIBA backchannel authentication request failed");
|
|
4313
|
+
if (!response.ok) throw new ThunderIDAPIError(getOAuthErrorMessage_default(parsedBody, "The backchannel authentication request was rejected."), "JS-AUTH_CORE-CIBA1-HE03", "javascript", response.status, response.statusText, "CIBA backchannel authentication request failed");
|
|
4204
4314
|
const payload = parsedBody;
|
|
4205
4315
|
if (!payload.auth_req_id) throw new ThunderIDAPIError("The server response did not include an auth_req_id.", "JS-AUTH_CORE-CIBA1-PR04", "javascript");
|
|
4206
4316
|
return {
|
|
@@ -12,6 +12,11 @@ declare const OIDCRequestConstants: {
|
|
|
12
12
|
readonly Payload: {
|
|
13
13
|
readonly DEFAULT_SCOPES: readonly string[];
|
|
14
14
|
};
|
|
15
|
+
readonly Storage: {
|
|
16
|
+
readonly StorageKeys: {
|
|
17
|
+
readonly STATE: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
15
20
|
};
|
|
16
21
|
readonly SignOut: {
|
|
17
22
|
readonly Storage: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OIDCRequestConstants.d.ts","sourceRoot":"","sources":["../../src/constants/OIDCRequestConstants.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,QAAA,MAAM,oBAAoB,EAAE;IAC1B,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;QACpC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,OAAO,EAAE;YAChB,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;SAC5C,CAAC;KACH,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,OAAO,EAAE;YAChB,QAAQ,CAAC,WAAW,EAAE;gBACpB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;aAC/B,CAAC;SACH,CAAC;KACH,CAAC;
|
|
1
|
+
{"version":3,"file":"OIDCRequestConstants.d.ts","sourceRoot":"","sources":["../../src/constants/OIDCRequestConstants.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,QAAA,MAAM,oBAAoB,EAAE;IAC1B,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;QACpC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,C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