@monocloud/auth-core 0.1.4 → 0.1.5
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/index.cjs +70 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +72 -35
- package/dist/index.mjs +70 -35
- package/dist/index.mjs.map +1 -1
- package/dist/types-hokU85Zr.d.mts +1243 -0
- package/dist/utils/index.cjs +4 -5
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.mts +5 -6
- package/dist/utils/index.mjs +4 -5
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/internal.cjs +4 -4
- package/dist/utils/internal.cjs.map +1 -1
- package/dist/utils/internal.d.mts +5 -5
- package/dist/utils/internal.mjs +4 -4
- package/dist/utils/internal.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/index.d.cts +0 -274
- package/dist/types-BAE9nCpJ.d.cts +0 -481
- package/dist/types-D3lVLgLQ.d.mts +0 -481
- package/dist/utils/index.d.cts +0 -105
- package/dist/utils/internal.d.cts +0 -208
package/dist/index.d.mts
CHANGED
|
@@ -1,25 +1,61 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as SecurityAlgorithms, C as Prompt, D as RefreshSessionOptions, E as RefreshGrantOptions, M as UserinfoResponse, O as ResponseModes, S as ParResponse, T as RefetchUserInfoOptions, _ as JwsHeaderParameters, a as Authenticators, b as MonoCloudUser, c as ClientAuthMethod, d as EndSessionParameters, f as Group, g as Jwks, h as Jwk, i as AuthenticateOptions, j as Tokens, k as ResponseTypes, l as CodeChallengeMethod, m as IssuerMetadata, n as Address, o as AuthorizationParams, p as IdTokenClaims, r as AuthState, s as CallbackParams, t as AccessToken, u as DisplayOptions, v as MonoCloudClientOptions, w as PushedAuthorizationParams, x as OnSessionCreating, y as MonoCloudSession } from "./types-hokU85Zr.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors/monocloud-auth-base-error.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Base class for all MonoCloud authentication errors.
|
|
6
|
+
*
|
|
7
|
+
* All errors thrown by the MonoCloud SDK extend this class, allowing applications to safely detect and handle MonoCloud-specific failures using `instanceof`.
|
|
8
|
+
*
|
|
9
|
+
* @category Error Classes
|
|
10
|
+
*/
|
|
4
11
|
declare class MonoCloudAuthBaseError extends Error {}
|
|
5
12
|
//#endregion
|
|
6
13
|
//#region src/errors/monocloud-op-error.d.ts
|
|
14
|
+
/**
|
|
15
|
+
* OAuth error returned by the authorization server during an authentication or token request.
|
|
16
|
+
*
|
|
17
|
+
* These errors correspond to standard OAuth / OpenID Connect error responses such as `invalid_request`, `access_denied`, or `invalid_grant`.
|
|
18
|
+
*
|
|
19
|
+
* @category Error Classes
|
|
20
|
+
*/
|
|
7
21
|
declare class MonoCloudOPError extends MonoCloudAuthBaseError {
|
|
22
|
+
/** OAuth error code returned by the authorization server. */
|
|
8
23
|
error: string;
|
|
24
|
+
/** Human-readable description of the error. */
|
|
9
25
|
errorDescription?: string;
|
|
10
26
|
constructor(error: string, errorDescription?: string);
|
|
11
27
|
}
|
|
12
28
|
//#endregion
|
|
13
29
|
//#region src/errors/monocloud-http-error.d.ts
|
|
30
|
+
/**
|
|
31
|
+
* Error thrown when a request to the MonoCloud authorization server fails.
|
|
32
|
+
*
|
|
33
|
+
* This error typically indicates a network failure, an unexpected HTTP response, or an unsuccessful response returned by the authorization server.
|
|
34
|
+
*
|
|
35
|
+
* @category Error Classes
|
|
36
|
+
*/
|
|
14
37
|
declare class MonoCloudHttpError extends MonoCloudAuthBaseError {}
|
|
15
38
|
//#endregion
|
|
16
39
|
//#region src/errors/monocloud-token-error.d.ts
|
|
40
|
+
/**
|
|
41
|
+
* Error thrown when a token operation fails.
|
|
42
|
+
*
|
|
43
|
+
* @category Error Classes
|
|
44
|
+
*/
|
|
17
45
|
declare class MonoCloudTokenError extends MonoCloudAuthBaseError {}
|
|
18
46
|
//#endregion
|
|
19
47
|
//#region src/errors/monocloud-validation-error.d.ts
|
|
48
|
+
/**
|
|
49
|
+
* Error thrown when validation fails.
|
|
50
|
+
*
|
|
51
|
+
* @category Error Classes
|
|
52
|
+
*/
|
|
20
53
|
declare class MonoCloudValidationError extends MonoCloudAuthBaseError {}
|
|
21
54
|
//#endregion
|
|
22
55
|
//#region src/monocloud-oidc-client.d.ts
|
|
56
|
+
/**
|
|
57
|
+
* @category Classes
|
|
58
|
+
*/
|
|
23
59
|
declare class MonoCloudOidcClient {
|
|
24
60
|
private readonly tenantDomain;
|
|
25
61
|
private readonly clientId;
|
|
@@ -38,9 +74,9 @@ declare class MonoCloudOidcClient {
|
|
|
38
74
|
*
|
|
39
75
|
* If no values are provided for `responseType`, or `codeChallengeMethod`, they default to `code`, and `S256`, respectively.
|
|
40
76
|
*
|
|
41
|
-
* @param params Authorization URL parameters
|
|
77
|
+
* @param params - Authorization URL parameters.
|
|
42
78
|
*
|
|
43
|
-
* @returns Tenant's authorization
|
|
79
|
+
* @returns Tenant's authorization URL.
|
|
44
80
|
*
|
|
45
81
|
* @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
|
|
46
82
|
* unexpected status code during the request or a serialization error while processing the response.
|
|
@@ -61,7 +97,7 @@ declare class MonoCloudOidcClient {
|
|
|
61
97
|
*/
|
|
62
98
|
getMetadata(forceRefresh?: boolean): Promise<IssuerMetadata>;
|
|
63
99
|
/**
|
|
64
|
-
* Fetches the JSON Web Keys used to sign the
|
|
100
|
+
* Fetches the JSON Web Keys used to sign the ID token.
|
|
65
101
|
* The JWKS is cached for 1 minute.
|
|
66
102
|
*
|
|
67
103
|
* @param forceRefresh - If `true`, bypasses the cache and fetches fresh set of JWKS from the server.
|
|
@@ -76,9 +112,9 @@ declare class MonoCloudOidcClient {
|
|
|
76
112
|
/**
|
|
77
113
|
* Performs a pushed authorization request.
|
|
78
114
|
*
|
|
79
|
-
* @param params - Authorization Parameters
|
|
115
|
+
* @param params - Authorization Parameters.
|
|
80
116
|
*
|
|
81
|
-
* @returns Response from Pushed Authorization Request (PAR) endpoint
|
|
117
|
+
* @returns Response from Pushed Authorization Request (PAR) endpoint.
|
|
82
118
|
*
|
|
83
119
|
* @throws {@link MonoCloudOPError} - When the request is invalid.
|
|
84
120
|
*
|
|
@@ -106,13 +142,13 @@ declare class MonoCloudOidcClient {
|
|
|
106
142
|
*/
|
|
107
143
|
userinfo(accessToken: string): Promise<UserinfoResponse>;
|
|
108
144
|
/**
|
|
109
|
-
* Generates OpenID end session
|
|
145
|
+
* Generates OpenID end session URL for signing out.
|
|
110
146
|
*
|
|
111
147
|
* Note - The `state` is added only when `postLogoutRedirectUri` is present.
|
|
112
148
|
*
|
|
113
|
-
* @param params - Parameters to build end session
|
|
149
|
+
* @param params - Parameters to build end session URL.
|
|
114
150
|
*
|
|
115
|
-
* @returns Tenant's end session
|
|
151
|
+
* @returns Tenant's end session URL.
|
|
116
152
|
*
|
|
117
153
|
* @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
|
|
118
154
|
* unexpected status code during the request or a serialization error while processing the response.
|
|
@@ -125,7 +161,7 @@ declare class MonoCloudOidcClient {
|
|
|
125
161
|
* @param code - The authorization code received from the authorization server.
|
|
126
162
|
* @param redirectUri - The redirect URI used in the initial authorization request.
|
|
127
163
|
* @param codeVerifier - Code verifier for PKCE.
|
|
128
|
-
* @param resource - Space-separated list of resources the access token should be scoped to
|
|
164
|
+
* @param resource - Space-separated list of resources the access token should be scoped to.
|
|
129
165
|
*
|
|
130
166
|
* @returns Tokens obtained by exchanging an authorization code at the token endpoint.
|
|
131
167
|
*
|
|
@@ -156,23 +192,23 @@ declare class MonoCloudOidcClient {
|
|
|
156
192
|
/**
|
|
157
193
|
* Generates a session with user and tokens by exchanging authorization code from callback params.
|
|
158
194
|
*
|
|
159
|
-
* @param code - The authorization code received from the callback
|
|
160
|
-
* @param redirectUri - The redirect URI that was used in the authorization request
|
|
195
|
+
* @param code - The authorization code received from the callback.
|
|
196
|
+
* @param redirectUri - The redirect URI that was used in the authorization request.
|
|
161
197
|
* @param requestedScopes - A space-separated list of scopes originally requested via the `/authorize` endpoint.
|
|
162
198
|
* This is stored in the session to ensure the correct access token can be identified and refreshed during `refreshSession()`.
|
|
163
199
|
* @param resource - A space-separated list of resource indicators originally requested via the `/authorize` endpoint.
|
|
164
200
|
* Used alongside scopes to uniquely identify and refresh the specific access token associated with these resources.
|
|
165
|
-
* @param options - Options for authenticating a user with authorization code
|
|
201
|
+
* @param options - Options for authenticating a user with authorization code.
|
|
166
202
|
*
|
|
167
203
|
* @returns The user's session containing authentication tokens and user information.
|
|
168
204
|
*
|
|
169
205
|
* @throws {@link MonoCloudValidationError} - When the token scope does not contain the openid scope,
|
|
170
206
|
* or if 'expires_in' or 'scope' is missing from the token response.
|
|
171
207
|
*
|
|
172
|
-
* @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized
|
|
208
|
+
* @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized.
|
|
173
209
|
* OAuth 2.0 error response.
|
|
174
210
|
*
|
|
175
|
-
* @throws {@link MonoCloudTokenError} - If ID Token validation fails
|
|
211
|
+
* @throws {@link MonoCloudTokenError} - If ID Token validation fails.
|
|
176
212
|
*
|
|
177
213
|
* @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
|
|
178
214
|
* unexpected status code during the request or a serialization error while processing the response.
|
|
@@ -183,11 +219,11 @@ declare class MonoCloudOidcClient {
|
|
|
183
219
|
* Refetches user information for an existing session using the userinfo endpoint.
|
|
184
220
|
* Updates the session's user object with the latest user information while preserving existing properties.
|
|
185
221
|
*
|
|
186
|
-
* @param accessToken - Access token used to fetch the userinfo
|
|
187
|
-
* @param session - The current MonoCloudSession
|
|
188
|
-
* @param options - Userinfo refetch options
|
|
222
|
+
* @param accessToken - Access token used to fetch the userinfo.
|
|
223
|
+
* @param session - The current MonoCloudSession.
|
|
224
|
+
* @param options - Userinfo refetch options.
|
|
189
225
|
*
|
|
190
|
-
* @returns Updated session with the latest userinfo
|
|
226
|
+
* @returns Updated session with the latest userinfo.
|
|
191
227
|
*
|
|
192
228
|
* @throws {@link MonoCloudValidationError} - When the token scope does not contain openid scope
|
|
193
229
|
*
|
|
@@ -205,8 +241,8 @@ declare class MonoCloudOidcClient {
|
|
|
205
241
|
* Refreshes an existing session using the refresh token.
|
|
206
242
|
* This function requests new tokens using the refresh token and optionally updates user information.
|
|
207
243
|
*
|
|
208
|
-
* @param session - The current MonoCloudSession containing the refresh token
|
|
209
|
-
* @param options - Session refresh options
|
|
244
|
+
* @param session - The current MonoCloudSession containing the refresh token.
|
|
245
|
+
* @param options - Session refresh options.
|
|
210
246
|
*
|
|
211
247
|
* @returns User's session containing refreshed authentication tokens and user information.
|
|
212
248
|
*
|
|
@@ -226,10 +262,10 @@ declare class MonoCloudOidcClient {
|
|
|
226
262
|
/**
|
|
227
263
|
* Revokes an access token or refresh token, rendering it invalid for future use.
|
|
228
264
|
*
|
|
229
|
-
* @param token - The token string to be revoked
|
|
230
|
-
* @param tokenType - Hint about the token type ('access_token' or 'refresh_token')
|
|
265
|
+
* @param token - The token string to be revoked.
|
|
266
|
+
* @param tokenType - Hint about the token type ('access_token' or 'refresh_token').
|
|
231
267
|
*
|
|
232
|
-
* @returns If token revocation succeeded
|
|
268
|
+
* @returns If token revocation succeeded.
|
|
233
269
|
*
|
|
234
270
|
* @throws {@link MonoCloudValidationError} - If token is invalid or unsupported token type
|
|
235
271
|
*
|
|
@@ -243,14 +279,14 @@ declare class MonoCloudOidcClient {
|
|
|
243
279
|
/**
|
|
244
280
|
* Validates an ID Token.
|
|
245
281
|
*
|
|
246
|
-
* @param idToken - The ID Token JWT string to validate
|
|
247
|
-
* @param jwks - Array of JSON Web Keys (JWK) used to verify the token's signature
|
|
248
|
-
* @param clockSkew - Number of seconds to adjust the current time to account for clock differences
|
|
249
|
-
* @param clockTolerance - Additional time tolerance in seconds for time-based claim validation
|
|
250
|
-
* @param maxAge -
|
|
251
|
-
* @param nonce -
|
|
282
|
+
* @param idToken - The ID Token JWT string to validate.
|
|
283
|
+
* @param jwks - Array of JSON Web Keys (JWK) used to verify the token's signature.
|
|
284
|
+
* @param clockSkew - Number of seconds to adjust the current time to account for clock differences.
|
|
285
|
+
* @param clockTolerance - Additional time tolerance in seconds for time-based claim validation.
|
|
286
|
+
* @param maxAge - Maximum authentication age in seconds.
|
|
287
|
+
* @param nonce - Nonce value to validate against the token's nonce claim.
|
|
252
288
|
*
|
|
253
|
-
* @returns Validated ID Token claims
|
|
289
|
+
* @returns Validated ID Token claims.
|
|
254
290
|
*
|
|
255
291
|
* @throws {@link MonoCloudTokenError} - If ID Token validation fails
|
|
256
292
|
*
|
|
@@ -258,11 +294,12 @@ declare class MonoCloudOidcClient {
|
|
|
258
294
|
validateIdToken(idToken: string, jwks: Jwk[], clockSkew: number, clockTolerance: number, maxAge?: number, nonce?: string): Promise<IdTokenClaims>;
|
|
259
295
|
/**
|
|
260
296
|
* Decodes the payload of a JSON Web Token (JWT) and returns it as an object.
|
|
261
|
-
* **THIS METHOD DOES NOT VERIFY JWT TOKENS**.
|
|
262
297
|
*
|
|
263
|
-
*
|
|
298
|
+
* >Note: THIS METHOD DOES NOT VERIFY JWT TOKENS.
|
|
299
|
+
*
|
|
300
|
+
* @param jwt - JWT to decode.
|
|
264
301
|
*
|
|
265
|
-
* @returns Decoded payload
|
|
302
|
+
* @returns Decoded payload.
|
|
266
303
|
*
|
|
267
304
|
* @throws {@link MonoCloudTokenError} - If decoding fails
|
|
268
305
|
*
|
|
@@ -270,5 +307,5 @@ declare class MonoCloudOidcClient {
|
|
|
270
307
|
static decodeJwt(jwt: string): IdTokenClaims;
|
|
271
308
|
}
|
|
272
309
|
//#endregion
|
|
273
|
-
export { type AccessToken, type Address, type AuthState, type AuthenticateOptions, type Authenticators, type AuthorizationParams, type CallbackParams, type ClientAuthMethod, type CodeChallengeMethod, type DisplayOptions, type EndSessionParameters, type Group, type IdTokenClaims, type IssuerMetadata, type
|
|
310
|
+
export { type AccessToken, type Address, type AuthState, type AuthenticateOptions, type Authenticators, type AuthorizationParams, type CallbackParams, type ClientAuthMethod, type CodeChallengeMethod, type DisplayOptions, type EndSessionParameters, type Group, type IdTokenClaims, type IssuerMetadata, type Jwk, type Jwks, type JwsHeaderParameters, MonoCloudAuthBaseError, type MonoCloudClientOptions, MonoCloudHttpError, MonoCloudOPError, MonoCloudOidcClient, type MonoCloudSession, MonoCloudTokenError, type MonoCloudUser, MonoCloudValidationError, type OnSessionCreating, type ParResponse, type Prompt, type PushedAuthorizationParams, type RefetchUserInfoOptions, type RefreshGrantOptions, type RefreshSessionOptions, type ResponseModes, type ResponseTypes, type SecurityAlgorithms, type Tokens, type UserinfoResponse };
|
|
274
311
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { decodeBase64Url, encodeBase64Url, findToken, getPublicSigKeyFromIssuerJwks, now, parseSpaceSeparated, randomBytes, stringToArrayBuffer } from "./utils/internal.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors/monocloud-auth-base-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* Base class for all MonoCloud authentication errors.
|
|
6
|
+
*
|
|
7
|
+
* All errors thrown by the MonoCloud SDK extend this class, allowing applications to safely detect and handle MonoCloud-specific failures using `instanceof`.
|
|
8
|
+
*
|
|
9
|
+
* @category Error Classes
|
|
10
|
+
*/
|
|
4
11
|
var MonoCloudAuthBaseError = class extends Error {};
|
|
5
12
|
|
|
6
13
|
//#endregion
|
|
7
14
|
//#region src/errors/monocloud-op-error.ts
|
|
15
|
+
/**
|
|
16
|
+
* OAuth error returned by the authorization server during an authentication or token request.
|
|
17
|
+
*
|
|
18
|
+
* These errors correspond to standard OAuth / OpenID Connect error responses such as `invalid_request`, `access_denied`, or `invalid_grant`.
|
|
19
|
+
*
|
|
20
|
+
* @category Error Classes
|
|
21
|
+
*/
|
|
8
22
|
var MonoCloudOPError = class extends MonoCloudAuthBaseError {
|
|
9
23
|
constructor(error, errorDescription) {
|
|
10
24
|
super(error);
|
|
@@ -15,14 +29,31 @@ var MonoCloudOPError = class extends MonoCloudAuthBaseError {
|
|
|
15
29
|
|
|
16
30
|
//#endregion
|
|
17
31
|
//#region src/errors/monocloud-http-error.ts
|
|
32
|
+
/**
|
|
33
|
+
* Error thrown when a request to the MonoCloud authorization server fails.
|
|
34
|
+
*
|
|
35
|
+
* This error typically indicates a network failure, an unexpected HTTP response, or an unsuccessful response returned by the authorization server.
|
|
36
|
+
*
|
|
37
|
+
* @category Error Classes
|
|
38
|
+
*/
|
|
18
39
|
var MonoCloudHttpError = class extends MonoCloudAuthBaseError {};
|
|
19
40
|
|
|
20
41
|
//#endregion
|
|
21
42
|
//#region src/errors/monocloud-token-error.ts
|
|
43
|
+
/**
|
|
44
|
+
* Error thrown when a token operation fails.
|
|
45
|
+
*
|
|
46
|
+
* @category Error Classes
|
|
47
|
+
*/
|
|
22
48
|
var MonoCloudTokenError = class extends MonoCloudAuthBaseError {};
|
|
23
49
|
|
|
24
50
|
//#endregion
|
|
25
51
|
//#region src/errors/monocloud-validation-error.ts
|
|
52
|
+
/**
|
|
53
|
+
* Error thrown when validation fails.
|
|
54
|
+
*
|
|
55
|
+
* @category Error Classes
|
|
56
|
+
*/
|
|
26
57
|
var MonoCloudValidationError = class extends MonoCloudAuthBaseError {};
|
|
27
58
|
|
|
28
59
|
//#endregion
|
|
@@ -223,12 +254,15 @@ const deserializeJson = async (res) => {
|
|
|
223
254
|
);
|
|
224
255
|
}
|
|
225
256
|
};
|
|
257
|
+
/**
|
|
258
|
+
* @category Classes
|
|
259
|
+
*/
|
|
226
260
|
var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
227
261
|
constructor(tenantDomain, clientId, options) {
|
|
228
262
|
this.jwksCacheExpiry = 0;
|
|
229
|
-
this.jwksCacheDuration =
|
|
263
|
+
this.jwksCacheDuration = 300;
|
|
230
264
|
this.metadataCacheExpiry = 0;
|
|
231
|
-
this.metadataCacheDuration =
|
|
265
|
+
this.metadataCacheDuration = 300;
|
|
232
266
|
tenantDomain ??= "";
|
|
233
267
|
/* v8 ignore next -- @preserve */
|
|
234
268
|
this.tenantDomain = `${!tenantDomain.startsWith("https://") ? "https://" : ""}${tenantDomain.endsWith("/") ? tenantDomain.slice(0, -1) : tenantDomain}`;
|
|
@@ -244,9 +278,9 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
244
278
|
*
|
|
245
279
|
* If no values are provided for `responseType`, or `codeChallengeMethod`, they default to `code`, and `S256`, respectively.
|
|
246
280
|
*
|
|
247
|
-
* @param params Authorization URL parameters
|
|
281
|
+
* @param params - Authorization URL parameters.
|
|
248
282
|
*
|
|
249
|
-
* @returns Tenant's authorization
|
|
283
|
+
* @returns Tenant's authorization URL.
|
|
250
284
|
*
|
|
251
285
|
* @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
|
|
252
286
|
* unexpected status code during the request or a serialization error while processing the response.
|
|
@@ -305,7 +339,7 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
305
339
|
return metadata;
|
|
306
340
|
}
|
|
307
341
|
/**
|
|
308
|
-
* Fetches the JSON Web Keys used to sign the
|
|
342
|
+
* Fetches the JSON Web Keys used to sign the ID token.
|
|
309
343
|
* The JWKS is cached for 1 minute.
|
|
310
344
|
*
|
|
311
345
|
* @param forceRefresh - If `true`, bypasses the cache and fetches fresh set of JWKS from the server.
|
|
@@ -331,9 +365,9 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
331
365
|
/**
|
|
332
366
|
* Performs a pushed authorization request.
|
|
333
367
|
*
|
|
334
|
-
* @param params - Authorization Parameters
|
|
368
|
+
* @param params - Authorization Parameters.
|
|
335
369
|
*
|
|
336
|
-
* @returns Response from Pushed Authorization Request (PAR) endpoint
|
|
370
|
+
* @returns Response from Pushed Authorization Request (PAR) endpoint.
|
|
337
371
|
*
|
|
338
372
|
* @throws {@link MonoCloudOPError} - When the request is invalid.
|
|
339
373
|
*
|
|
@@ -423,13 +457,13 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
423
457
|
return await deserializeJson(response);
|
|
424
458
|
}
|
|
425
459
|
/**
|
|
426
|
-
* Generates OpenID end session
|
|
460
|
+
* Generates OpenID end session URL for signing out.
|
|
427
461
|
*
|
|
428
462
|
* Note - The `state` is added only when `postLogoutRedirectUri` is present.
|
|
429
463
|
*
|
|
430
|
-
* @param params - Parameters to build end session
|
|
464
|
+
* @param params - Parameters to build end session URL.
|
|
431
465
|
*
|
|
432
|
-
* @returns Tenant's end session
|
|
466
|
+
* @returns Tenant's end session URL.
|
|
433
467
|
*
|
|
434
468
|
* @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
|
|
435
469
|
* unexpected status code during the request or a serialization error while processing the response.
|
|
@@ -453,7 +487,7 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
453
487
|
* @param code - The authorization code received from the authorization server.
|
|
454
488
|
* @param redirectUri - The redirect URI used in the initial authorization request.
|
|
455
489
|
* @param codeVerifier - Code verifier for PKCE.
|
|
456
|
-
* @param resource - Space-separated list of resources the access token should be scoped to
|
|
490
|
+
* @param resource - Space-separated list of resources the access token should be scoped to.
|
|
457
491
|
*
|
|
458
492
|
* @returns Tokens obtained by exchanging an authorization code at the token endpoint.
|
|
459
493
|
*
|
|
@@ -536,23 +570,23 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
536
570
|
/**
|
|
537
571
|
* Generates a session with user and tokens by exchanging authorization code from callback params.
|
|
538
572
|
*
|
|
539
|
-
* @param code - The authorization code received from the callback
|
|
540
|
-
* @param redirectUri - The redirect URI that was used in the authorization request
|
|
573
|
+
* @param code - The authorization code received from the callback.
|
|
574
|
+
* @param redirectUri - The redirect URI that was used in the authorization request.
|
|
541
575
|
* @param requestedScopes - A space-separated list of scopes originally requested via the `/authorize` endpoint.
|
|
542
576
|
* This is stored in the session to ensure the correct access token can be identified and refreshed during `refreshSession()`.
|
|
543
577
|
* @param resource - A space-separated list of resource indicators originally requested via the `/authorize` endpoint.
|
|
544
578
|
* Used alongside scopes to uniquely identify and refresh the specific access token associated with these resources.
|
|
545
|
-
* @param options - Options for authenticating a user with authorization code
|
|
579
|
+
* @param options - Options for authenticating a user with authorization code.
|
|
546
580
|
*
|
|
547
581
|
* @returns The user's session containing authentication tokens and user information.
|
|
548
582
|
*
|
|
549
583
|
* @throws {@link MonoCloudValidationError} - When the token scope does not contain the openid scope,
|
|
550
584
|
* or if 'expires_in' or 'scope' is missing from the token response.
|
|
551
585
|
*
|
|
552
|
-
* @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized
|
|
586
|
+
* @throws {@link MonoCloudOPError} - When the OpenID Provider returns a standardized.
|
|
553
587
|
* OAuth 2.0 error response.
|
|
554
588
|
*
|
|
555
|
-
* @throws {@link MonoCloudTokenError} - If ID Token validation fails
|
|
589
|
+
* @throws {@link MonoCloudTokenError} - If ID Token validation fails.
|
|
556
590
|
*
|
|
557
591
|
* @throws {@link MonoCloudHttpError} - Thrown if there is a network error during the request or
|
|
558
592
|
* unexpected status code during the request or a serialization error while processing the response.
|
|
@@ -596,11 +630,11 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
596
630
|
* Refetches user information for an existing session using the userinfo endpoint.
|
|
597
631
|
* Updates the session's user object with the latest user information while preserving existing properties.
|
|
598
632
|
*
|
|
599
|
-
* @param accessToken - Access token used to fetch the userinfo
|
|
600
|
-
* @param session - The current MonoCloudSession
|
|
601
|
-
* @param options - Userinfo refetch options
|
|
633
|
+
* @param accessToken - Access token used to fetch the userinfo.
|
|
634
|
+
* @param session - The current MonoCloudSession.
|
|
635
|
+
* @param options - Userinfo refetch options.
|
|
602
636
|
*
|
|
603
|
-
* @returns Updated session with the latest userinfo
|
|
637
|
+
* @returns Updated session with the latest userinfo.
|
|
604
638
|
*
|
|
605
639
|
* @throws {@link MonoCloudValidationError} - When the token scope does not contain openid scope
|
|
606
640
|
*
|
|
@@ -627,8 +661,8 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
627
661
|
* Refreshes an existing session using the refresh token.
|
|
628
662
|
* This function requests new tokens using the refresh token and optionally updates user information.
|
|
629
663
|
*
|
|
630
|
-
* @param session - The current MonoCloudSession containing the refresh token
|
|
631
|
-
* @param options - Session refresh options
|
|
664
|
+
* @param session - The current MonoCloudSession containing the refresh token.
|
|
665
|
+
* @param options - Session refresh options.
|
|
632
666
|
*
|
|
633
667
|
* @returns User's session containing refreshed authentication tokens and user information.
|
|
634
668
|
*
|
|
@@ -690,10 +724,10 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
690
724
|
/**
|
|
691
725
|
* Revokes an access token or refresh token, rendering it invalid for future use.
|
|
692
726
|
*
|
|
693
|
-
* @param token - The token string to be revoked
|
|
694
|
-
* @param tokenType - Hint about the token type ('access_token' or 'refresh_token')
|
|
727
|
+
* @param token - The token string to be revoked.
|
|
728
|
+
* @param tokenType - Hint about the token type ('access_token' or 'refresh_token').
|
|
695
729
|
*
|
|
696
|
-
* @returns If token revocation succeeded
|
|
730
|
+
* @returns If token revocation succeeded.
|
|
697
731
|
*
|
|
698
732
|
* @throws {@link MonoCloudValidationError} - If token is invalid or unsupported token type
|
|
699
733
|
*
|
|
@@ -727,14 +761,14 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
727
761
|
/**
|
|
728
762
|
* Validates an ID Token.
|
|
729
763
|
*
|
|
730
|
-
* @param idToken - The ID Token JWT string to validate
|
|
731
|
-
* @param jwks - Array of JSON Web Keys (JWK) used to verify the token's signature
|
|
732
|
-
* @param clockSkew - Number of seconds to adjust the current time to account for clock differences
|
|
733
|
-
* @param clockTolerance - Additional time tolerance in seconds for time-based claim validation
|
|
734
|
-
* @param maxAge -
|
|
735
|
-
* @param nonce -
|
|
764
|
+
* @param idToken - The ID Token JWT string to validate.
|
|
765
|
+
* @param jwks - Array of JSON Web Keys (JWK) used to verify the token's signature.
|
|
766
|
+
* @param clockSkew - Number of seconds to adjust the current time to account for clock differences.
|
|
767
|
+
* @param clockTolerance - Additional time tolerance in seconds for time-based claim validation.
|
|
768
|
+
* @param maxAge - Maximum authentication age in seconds.
|
|
769
|
+
* @param nonce - Nonce value to validate against the token's nonce claim.
|
|
736
770
|
*
|
|
737
|
-
* @returns Validated ID Token claims
|
|
771
|
+
* @returns Validated ID Token claims.
|
|
738
772
|
*
|
|
739
773
|
* @throws {@link MonoCloudTokenError} - If ID Token validation fails
|
|
740
774
|
*
|
|
@@ -787,11 +821,12 @@ var MonoCloudOidcClient = class MonoCloudOidcClient {
|
|
|
787
821
|
}
|
|
788
822
|
/**
|
|
789
823
|
* Decodes the payload of a JSON Web Token (JWT) and returns it as an object.
|
|
790
|
-
* **THIS METHOD DOES NOT VERIFY JWT TOKENS**.
|
|
791
824
|
*
|
|
792
|
-
*
|
|
825
|
+
* >Note: THIS METHOD DOES NOT VERIFY JWT TOKENS.
|
|
826
|
+
*
|
|
827
|
+
* @param jwt - JWT to decode.
|
|
793
828
|
*
|
|
794
|
-
* @returns Decoded payload
|
|
829
|
+
* @returns Decoded payload.
|
|
795
830
|
*
|
|
796
831
|
* @throws {@link MonoCloudTokenError} - If decoding fails
|
|
797
832
|
*
|