@monocloud/auth-node-core 0.1.4 → 0.1.6
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/README.md +19 -2
- package/dist/index.cjs +19 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +466 -175
- package/dist/index.mjs +14 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/dist/index.d.cts +0 -690
- package/dist/utils/index.d.cts +0 -1
- package/dist/utils/internal.d.cts +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,275 +1,432 @@
|
|
|
1
|
-
import { AccessToken, AccessToken as AccessToken$1, AuthState, AuthenticateOptions, Authenticators, AuthorizationParams, AuthorizationParams as AuthorizationParams$1, CallbackParams, ClientAuthMethod, CodeChallengeMethod, DisplayOptions, EndSessionParameters, EndSessionParameters as EndSessionParameters$1, Group, IdTokenClaims, IdTokenClaims as IdTokenClaims$1, IssuerMetadata,
|
|
2
|
-
import { SerializeOptions } from "cookie";
|
|
3
|
-
import { Except, PartialDeep } from "type-fest";
|
|
1
|
+
import { AccessToken, AccessToken as AccessToken$1, Address, AuthState, AuthenticateOptions, Authenticators, AuthorizationParams, AuthorizationParams as AuthorizationParams$1, CallbackParams, ClientAuthMethod, CodeChallengeMethod, DisplayOptions, EndSessionParameters, EndSessionParameters as EndSessionParameters$1, Group, IdTokenClaims, IdTokenClaims as IdTokenClaims$1, IssuerMetadata, Jwk, Jwks, JwsHeaderParameters, MonoCloudAuthBaseError, MonoCloudClientOptions, MonoCloudHttpError, MonoCloudOPError, MonoCloudOidcClient, MonoCloudSession, MonoCloudSession as MonoCloudSession$1, MonoCloudTokenError, MonoCloudUser, MonoCloudValidationError, OnSessionCreating as OnCoreSessionCreating, ParResponse, Prompt, PushedAuthorizationParams, RefetchUserInfoOptions, RefreshGrantOptions, RefreshGrantOptions as RefreshGrantOptions$1, RefreshSessionOptions, ResponseModes, ResponseTypes, SecurityAlgorithms, SecurityAlgorithms as SecurityAlgorithms$1, Tokens, UserinfoResponse, UserinfoResponse as UserinfoResponse$1 } from "@monocloud/auth-core";
|
|
2
|
+
import { SerializeOptions, SerializeOptions as SerializeOptions$1, SetCookie } from "cookie";
|
|
4
3
|
|
|
5
4
|
//#region src/types/internal.d.ts
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Options for serializing cookies.
|
|
7
|
+
*
|
|
8
|
+
* @category Types
|
|
9
|
+
*/
|
|
10
|
+
interface CookieOptions extends SerializeOptions$1 {}
|
|
11
|
+
/**
|
|
12
|
+
* Interface for reading cookies from an incoming request.
|
|
13
|
+
*
|
|
14
|
+
* @category Types
|
|
15
|
+
*/
|
|
7
16
|
interface IMonoCloudCookieRequest {
|
|
17
|
+
/** Retrieves a single cookie value by name. */
|
|
8
18
|
getCookie(name: string): Promise<string | undefined>;
|
|
19
|
+
/** Retrieves all cookies from the request. */
|
|
9
20
|
getAllCookies(): Promise<Map<string, string>>;
|
|
10
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Represents a request object that includes cookie handling capabilities.
|
|
24
|
+
*
|
|
25
|
+
* @category Types
|
|
26
|
+
*/
|
|
11
27
|
interface MonoCloudRequest extends IMonoCloudCookieRequest {
|
|
28
|
+
/** Retrieves a query parameter value by name. */
|
|
12
29
|
getQuery(parameter: string): string | string[] | undefined;
|
|
30
|
+
/** Returns the raw request details including method, URL, and body. */
|
|
13
31
|
getRawRequest(): Promise<{
|
|
14
32
|
method: string;
|
|
15
33
|
url: string;
|
|
16
34
|
body: Record<string, string> | string;
|
|
17
35
|
}>;
|
|
18
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Interface for setting cookies on an outgoing response.
|
|
39
|
+
*
|
|
40
|
+
* @category Types
|
|
41
|
+
*/
|
|
19
42
|
interface IMonoCloudCookieResponse {
|
|
43
|
+
/** Sets a cookie on the response. */
|
|
20
44
|
setCookie(cookieName: string, value: string, options: CookieOptions): Promise<void>;
|
|
21
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Represents an outgoing HTTP response with common helper methods.
|
|
48
|
+
*
|
|
49
|
+
* @category Types
|
|
50
|
+
*/
|
|
22
51
|
interface MonoCloudResponse extends IMonoCloudCookieResponse {
|
|
52
|
+
/** Redirects the client to the specified URL. */
|
|
23
53
|
redirect(url: string, statusCode?: number): void;
|
|
54
|
+
/** Sends a JSON response with an optional status code. */
|
|
24
55
|
sendJson(data: any, statusCode?: number): void;
|
|
56
|
+
/** Sends a 404 Not Found response. */
|
|
25
57
|
notFound(): void;
|
|
58
|
+
/** Sends a 204 No Content response. */
|
|
26
59
|
noContent(): void;
|
|
60
|
+
/** Sends a 500 Internal Server Error response. */
|
|
27
61
|
internalServerError(): void;
|
|
62
|
+
/** Sends a 405 Method Not Allowed response. */
|
|
28
63
|
methodNotAllowed(): void;
|
|
64
|
+
/** Sets cache-control headers to prevent caching. */
|
|
29
65
|
setNoCache(): void;
|
|
66
|
+
/** Finalizes and returns the response. */
|
|
30
67
|
done(): any;
|
|
31
68
|
}
|
|
32
69
|
//#endregion
|
|
33
70
|
//#region src/types/index.d.ts
|
|
34
71
|
/**
|
|
35
|
-
*
|
|
72
|
+
* Allowed values for the cookie `SameSite` attribute.
|
|
73
|
+
*
|
|
74
|
+
* The `SameSite` setting controls when cookies are included in cross-site requests and helps protect against cross-site request forgery (CSRF) attacks.
|
|
75
|
+
*
|
|
76
|
+
* @category Types (Enums)
|
|
36
77
|
*/
|
|
37
|
-
type SameSiteValues =
|
|
78
|
+
type SameSiteValues =
|
|
38
79
|
/**
|
|
39
|
-
*
|
|
80
|
+
* Cookies are only sent for same-site requests.
|
|
81
|
+
*
|
|
82
|
+
* Cookies will NOT be included in cross-site navigations, redirects, or embedded requests.
|
|
83
|
+
*
|
|
84
|
+
* Provides the strongest CSRF protection but may break authentication flows that rely on cross-site redirects.
|
|
40
85
|
*/
|
|
41
|
-
|
|
86
|
+
'strict'
|
|
42
87
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
88
|
+
* Cookies are sent for same-site requests and top-level cross-site navigations (for example, following a link).
|
|
89
|
+
*
|
|
90
|
+
* This is the recommended default for most authentication flows.
|
|
91
|
+
*/
|
|
92
|
+
| 'lax'
|
|
93
|
+
/**
|
|
94
|
+
* Cookies are sent with all requests, including cross-site requests.
|
|
95
|
+
*
|
|
96
|
+
* Must be used together with `Secure=true` (HTTPS only).
|
|
97
|
+
*
|
|
98
|
+
* Required for some third-party or cross-origin authentication scenarios.
|
|
99
|
+
*/
|
|
100
|
+
| 'none';
|
|
101
|
+
/**
|
|
102
|
+
* Represents the lifetime metadata associated with a user session.
|
|
103
|
+
*
|
|
104
|
+
* The properties use short keys to minimize cookie and storage size, since this structure may be serialized as part of session data.
|
|
105
|
+
*
|
|
106
|
+
* All timestamps are expressed as **Unix epoch time (seconds)**.
|
|
107
|
+
*
|
|
108
|
+
* @category Types
|
|
45
109
|
*/
|
|
46
110
|
interface SessionLifetime {
|
|
47
111
|
/**
|
|
48
|
-
*
|
|
112
|
+
* Session creation time.
|
|
113
|
+
*
|
|
114
|
+
* The moment the session was initially established.
|
|
49
115
|
*/
|
|
50
116
|
c: number;
|
|
51
117
|
/**
|
|
52
|
-
*
|
|
118
|
+
* Last updated time.
|
|
119
|
+
*
|
|
120
|
+
* Updated whenever the session is refreshed or extended (for example, during sliding expiration).
|
|
53
121
|
*/
|
|
54
122
|
u: number;
|
|
55
123
|
/**
|
|
56
|
-
* Optional
|
|
124
|
+
* Optional expiration time.
|
|
57
125
|
*/
|
|
58
126
|
e?: number;
|
|
59
127
|
}
|
|
60
128
|
/**
|
|
61
|
-
*
|
|
129
|
+
* Defines a storage adapter used to persist authentication sessions.
|
|
130
|
+
*
|
|
131
|
+
* Implement this interface to store sessions outside the default cookie-based storage — for example in Redis, a database, or a distributed cache.
|
|
132
|
+
*
|
|
133
|
+
* @category Types
|
|
62
134
|
*/
|
|
63
135
|
interface MonoCloudSessionStore {
|
|
64
136
|
/**
|
|
65
|
-
* Retrieves a session
|
|
66
|
-
*
|
|
67
|
-
* @
|
|
137
|
+
* Retrieves a session associated with the provided key.
|
|
138
|
+
*
|
|
139
|
+
* @param key Unique identifier of the session.
|
|
140
|
+
* @returns Returns the stored session, or `undefined` / `null` if no session exists.
|
|
68
141
|
*/
|
|
69
142
|
get(key: string): Promise<MonoCloudSession$1 | undefined | null>;
|
|
70
143
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* @
|
|
144
|
+
* Persists or updates a session.
|
|
145
|
+
*
|
|
146
|
+
* The provided lifetime information can be used by the store to configure TTL/expiration policies.
|
|
147
|
+
*
|
|
148
|
+
* @param key Unique identifier of the session.
|
|
149
|
+
* @param data The session data to persist.
|
|
150
|
+
* @param lifetime Session lifetime metadata (creation, update, expiration).
|
|
76
151
|
*/
|
|
77
152
|
set(key: string, data: MonoCloudSession$1, lifetime: SessionLifetime): Promise<void>;
|
|
78
153
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* @
|
|
154
|
+
* Removes a session from the store.
|
|
155
|
+
*
|
|
156
|
+
* @param key Unique identifier of the session to delete.
|
|
82
157
|
*/
|
|
83
158
|
delete(key: string): Promise<void>;
|
|
84
159
|
}
|
|
85
160
|
/**
|
|
86
|
-
*
|
|
161
|
+
* Configuration options for authentication cookies.
|
|
162
|
+
*
|
|
163
|
+
* These settings control how MonoCloud session and state cookies are created, scoped, and transmitted by the browser.
|
|
164
|
+
*
|
|
165
|
+
* @category Types
|
|
87
166
|
*/
|
|
88
167
|
interface MonoCloudCookieOptions {
|
|
89
168
|
/**
|
|
90
|
-
* The name
|
|
91
|
-
*
|
|
92
|
-
*
|
|
169
|
+
* The cookie name.
|
|
170
|
+
*
|
|
171
|
+
* - Session cookie default: `"session"`
|
|
172
|
+
* - State cookie default: `"state"`
|
|
93
173
|
*/
|
|
94
174
|
name: string;
|
|
95
175
|
/**
|
|
96
|
-
* The path for which the cookie is valid.
|
|
176
|
+
* The URL path for which the cookie is valid.
|
|
177
|
+
*
|
|
97
178
|
* @defaultValue '/'
|
|
98
179
|
*/
|
|
99
180
|
path: string;
|
|
100
181
|
/**
|
|
101
|
-
* Optional
|
|
182
|
+
* Optional domain scope for the cookie.
|
|
102
183
|
*/
|
|
103
184
|
domain?: string;
|
|
104
185
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
186
|
+
* Indicates whether the cookie is accessible only via HTTP requests. Helps mitigate XSS attacks by preventing client-side JavaScript access.
|
|
187
|
+
*
|
|
188
|
+
* > Always enforced as `true` for state cookies.
|
|
189
|
+
*
|
|
107
190
|
* @defaultValue true
|
|
108
191
|
*/
|
|
109
192
|
httpOnly: boolean;
|
|
110
193
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
194
|
+
* Indicates whether the cookie should only be transmitted over HTTPS.
|
|
195
|
+
*
|
|
196
|
+
* If not explicitly provided, this value is automatically inferred from the application URL scheme.
|
|
113
197
|
*/
|
|
114
198
|
secure: boolean;
|
|
115
199
|
/**
|
|
116
|
-
* The SameSite
|
|
200
|
+
* The SameSite policy applied to the cookie. Controls cross-site request behavior and CSRF protection.
|
|
201
|
+
*
|
|
117
202
|
* @defaultValue 'lax'
|
|
118
203
|
*/
|
|
119
204
|
sameSite: SameSiteValues;
|
|
120
205
|
/**
|
|
121
|
-
* Determines whether the cookie
|
|
122
|
-
*
|
|
123
|
-
*
|
|
206
|
+
* Determines whether the cookie persists across browser restarts.
|
|
207
|
+
*
|
|
208
|
+
* - Session cookies default to `true`
|
|
209
|
+
* - State cookies default to `false`
|
|
124
210
|
*/
|
|
125
211
|
persistent: boolean;
|
|
126
212
|
}
|
|
127
213
|
/**
|
|
128
|
-
*
|
|
214
|
+
* Configuration options for authentication sessions.
|
|
215
|
+
*
|
|
216
|
+
* These options control how user sessions are created, persisted, and expired.
|
|
217
|
+
*
|
|
218
|
+
* @category Types
|
|
129
219
|
*/
|
|
130
220
|
interface MonoCloudSessionOptionsBase {
|
|
131
221
|
/**
|
|
132
|
-
* Configuration
|
|
222
|
+
* Configuration for the session cookie used to identify the user session.
|
|
133
223
|
*/
|
|
134
224
|
cookie: MonoCloudCookieOptions;
|
|
135
225
|
/**
|
|
136
|
-
*
|
|
226
|
+
* Enables sliding session expiration.
|
|
227
|
+
*
|
|
228
|
+
* When enabled, the session expiration is extended on active requests, up to the configured `maximumDuration`.
|
|
229
|
+
*
|
|
230
|
+
* When disabled, the session expires after a fixed duration regardless of user activity.
|
|
231
|
+
*
|
|
137
232
|
* @defaultValue false
|
|
138
233
|
*/
|
|
139
234
|
sliding: boolean;
|
|
140
235
|
/**
|
|
141
|
-
* The
|
|
236
|
+
* The session lifetime in seconds.
|
|
237
|
+
*
|
|
238
|
+
* - With **absolute sessions** (`sliding = false`), this defines the total session lifetime.
|
|
239
|
+
* - With **sliding sessions**, this defines the idle timeout before the session expires.
|
|
240
|
+
*
|
|
142
241
|
* @defaultValue 86400 (1 Day)
|
|
143
242
|
*/
|
|
144
243
|
duration: number;
|
|
145
244
|
/**
|
|
146
|
-
* The maximum
|
|
147
|
-
*
|
|
148
|
-
*
|
|
245
|
+
* The absolute maximum lifetime of a sliding session in seconds.
|
|
246
|
+
*
|
|
247
|
+
* This value limits how long a session can exist even if the user remains continuously active.
|
|
248
|
+
*
|
|
249
|
+
* Only applies when `sliding` is enabled.
|
|
250
|
+
*
|
|
251
|
+
* @defaultValue 604800 (7 days)
|
|
149
252
|
*/
|
|
150
253
|
maximumDuration: number;
|
|
151
254
|
/**
|
|
152
|
-
* Optional
|
|
255
|
+
* Optional session store used to persist session data.
|
|
256
|
+
*
|
|
257
|
+
* If not provided, The SDK uses the default cookie-based session storage.
|
|
258
|
+
*
|
|
259
|
+
* Custom stores allow centralized session management (e.g. Redis, database).
|
|
153
260
|
*/
|
|
154
261
|
store?: MonoCloudSessionStore;
|
|
155
262
|
}
|
|
156
263
|
/**
|
|
157
|
-
*
|
|
264
|
+
* Partial configuration options for authentication state handling.
|
|
265
|
+
*
|
|
266
|
+
* @category Types
|
|
267
|
+
*/
|
|
268
|
+
interface MonoCloudStatePartialOptions {
|
|
269
|
+
/**
|
|
270
|
+
* Partial configuration for the state cookie.
|
|
271
|
+
*
|
|
272
|
+
* This cookie temporarily stores authorization transaction data required to validate the callback response and prevent replay or CSRF attacks.
|
|
273
|
+
*/
|
|
274
|
+
cookie?: Partial<MonoCloudCookieOptions>;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Configuration options for authentication state handling.
|
|
278
|
+
*
|
|
279
|
+
* @category Types
|
|
158
280
|
*/
|
|
159
281
|
interface MonoCloudStateOptions {
|
|
160
282
|
/**
|
|
161
|
-
* Configuration
|
|
283
|
+
* Configuration for the state cookie.
|
|
284
|
+
*
|
|
285
|
+
* This cookie temporarily stores authorization transaction data required to validate the callback response and prevent replay or CSRF attacks.
|
|
162
286
|
*/
|
|
163
287
|
cookie: MonoCloudCookieOptions;
|
|
164
288
|
}
|
|
165
289
|
/**
|
|
166
|
-
*
|
|
290
|
+
* Route configuration for MonoCloud authentication handlers.
|
|
291
|
+
*
|
|
292
|
+
* These routes define the internal application endpoints used by the SDK to process authentication flows such as sign-in, callback handling, sign-out, and user profile retrieval.
|
|
293
|
+
*
|
|
294
|
+
* You typically do not need to change these values unless you want to customize your application's authentication URLs.
|
|
295
|
+
*
|
|
296
|
+
* > When customizing routes, ensure the corresponding URLs are also configured in your MonoCloud Dashboard and exposed to the client using the matching environment variables.
|
|
297
|
+
*
|
|
298
|
+
* @category Types
|
|
167
299
|
*/
|
|
168
300
|
interface MonoCloudRoutes {
|
|
169
301
|
/**
|
|
170
|
-
*
|
|
302
|
+
* Route that receives the authorization callback from MonoCloud after a successful authentication.
|
|
303
|
+
*
|
|
171
304
|
* @defaultValue '/api/auth/callback'
|
|
172
305
|
*/
|
|
173
306
|
callback: string;
|
|
174
307
|
/**
|
|
175
|
-
*
|
|
308
|
+
* Route that handles OpenID Connect back-channel logout requests initiated by MonoCloud.
|
|
309
|
+
*
|
|
176
310
|
* @defaultValue '/api/auth/backchannel-logout'
|
|
177
311
|
*/
|
|
178
312
|
backChannelLogout: string;
|
|
179
313
|
/**
|
|
180
|
-
*
|
|
314
|
+
* Route used to initiate the sign-in flow.
|
|
315
|
+
*
|
|
181
316
|
* @defaultValue '/api/auth/signin'
|
|
182
317
|
*/
|
|
183
318
|
signIn: string;
|
|
184
319
|
/**
|
|
185
|
-
*
|
|
320
|
+
* Route used to initiate the sign-out flow.
|
|
321
|
+
*
|
|
186
322
|
* @defaultValue '/api/auth/signout'
|
|
187
323
|
*/
|
|
188
324
|
signOut: string;
|
|
189
325
|
/**
|
|
190
|
-
*
|
|
326
|
+
* Route that exposes the authenticated user's profile information.
|
|
327
|
+
*
|
|
191
328
|
* @defaultValue '/api/auth/userinfo'
|
|
192
329
|
*/
|
|
193
330
|
userInfo: string;
|
|
194
331
|
}
|
|
195
332
|
/**
|
|
196
|
-
* Represents an
|
|
333
|
+
* Represents an additional resource indicator that can be requested during token acquisition.
|
|
334
|
+
*
|
|
335
|
+
* Resource indicators allow an access token to be scoped to a specific API or service (audience). Multiple indicators may be provided when requesting tokens for different protected resources.
|
|
336
|
+
*
|
|
337
|
+
* @category Types
|
|
197
338
|
*/
|
|
198
339
|
interface Indicator {
|
|
199
340
|
/**
|
|
200
|
-
* Space
|
|
341
|
+
* Space-separated list of resource identifiers (audiences) that the access token should be issued for.
|
|
342
|
+
*
|
|
343
|
+
* Each value typically represents an API identifier or resource URI.
|
|
201
344
|
*/
|
|
202
345
|
resource: string;
|
|
203
346
|
/**
|
|
204
|
-
* Optional
|
|
347
|
+
* Optional. Space-separated list of scopes to request specifically for this resource.
|
|
205
348
|
*/
|
|
206
349
|
scopes?: string;
|
|
207
350
|
}
|
|
208
351
|
/**
|
|
209
|
-
*
|
|
352
|
+
* Core configuration options for the SDK.
|
|
353
|
+
*
|
|
354
|
+
* These options define how the SDK communicates with your MonoCloud tenant, manages sessions, and performs authentication flows.
|
|
355
|
+
*
|
|
356
|
+
* @category Types
|
|
210
357
|
*/
|
|
211
358
|
interface MonoCloudOptionsBase {
|
|
212
359
|
/**
|
|
213
|
-
*
|
|
360
|
+
* Client identifier of the application registered in MonoCloud.
|
|
214
361
|
*/
|
|
215
362
|
clientId: string;
|
|
216
363
|
/**
|
|
217
|
-
* Optional
|
|
364
|
+
* Optional client secret used for confidential clients.
|
|
218
365
|
*/
|
|
219
366
|
clientSecret?: string;
|
|
220
367
|
/**
|
|
221
|
-
* MonoCloud tenant domain.
|
|
368
|
+
* MonoCloud tenant domain (for example, `https://your-tenant.us.monocloud.com`).
|
|
222
369
|
*/
|
|
223
370
|
tenantDomain: string;
|
|
224
371
|
/**
|
|
225
|
-
*
|
|
372
|
+
* Secret used to encrypt and sign authentication cookies. This value should be long, random, and kept private.
|
|
226
373
|
*/
|
|
227
374
|
cookieSecret: string;
|
|
228
375
|
/**
|
|
229
|
-
*
|
|
376
|
+
* Base URL where the application is hosted.
|
|
377
|
+
*
|
|
378
|
+
* Used to construct redirect URLs and validate requests.
|
|
230
379
|
*/
|
|
231
380
|
appUrl: string;
|
|
232
381
|
/**
|
|
233
|
-
*
|
|
382
|
+
* Route paths used by MonoCloud authentication handlers.
|
|
234
383
|
*/
|
|
235
384
|
routes: MonoCloudRoutes;
|
|
236
385
|
/**
|
|
237
|
-
*
|
|
386
|
+
* Allowed clock skew (in seconds) when validating token timestamps.
|
|
387
|
+
*
|
|
238
388
|
* @defaultValue 60 (seconds)
|
|
239
389
|
*/
|
|
240
390
|
clockSkew: number;
|
|
241
391
|
/**
|
|
242
|
-
*
|
|
392
|
+
* Maximum time (in milliseconds) to wait for responses from the MonoCloud authorization server.
|
|
393
|
+
*
|
|
243
394
|
* @defaultValue 10000 (10 seconds)
|
|
244
395
|
*/
|
|
245
396
|
responseTimeout: number;
|
|
246
397
|
/**
|
|
247
|
-
*
|
|
398
|
+
* Enables Pushed Authorization Requests (PAR).
|
|
399
|
+
*
|
|
400
|
+
* When enabled, authorization parameters are sent securely via the PAR endpoint instead of the browser.
|
|
401
|
+
*
|
|
248
402
|
* @defaultValue false
|
|
249
403
|
*/
|
|
250
404
|
usePar: boolean;
|
|
251
405
|
/**
|
|
252
|
-
*
|
|
406
|
+
* URL to redirect users to after logout completes.
|
|
253
407
|
*/
|
|
254
408
|
postLogoutRedirectUri?: string;
|
|
255
409
|
/**
|
|
256
|
-
*
|
|
410
|
+
* When `true`, signing out also logs the user out of MonoCloud (Single Sign-Out).
|
|
411
|
+
*
|
|
257
412
|
* @defaultValue true
|
|
258
413
|
*/
|
|
259
414
|
federatedSignOut: boolean;
|
|
260
415
|
/**
|
|
261
|
-
*
|
|
416
|
+
* Fetch user profile data from the `UserInfo` endpoint after authentication completes.
|
|
417
|
+
*
|
|
262
418
|
* @defaultValue true
|
|
263
419
|
*/
|
|
264
420
|
userInfo: boolean;
|
|
265
421
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
422
|
+
* Refetch user profile data whenever the application's `UserInfo` endpoint is invoked.
|
|
423
|
+
*
|
|
268
424
|
* @defaultValue false
|
|
269
425
|
*/
|
|
270
426
|
refetchUserInfo: boolean;
|
|
271
427
|
/**
|
|
272
|
-
* Default authorization parameters
|
|
428
|
+
* Default authorization parameters included in authentication requests.
|
|
429
|
+
*
|
|
273
430
|
* @defaultValue {
|
|
274
431
|
* scope: 'openid email profile',
|
|
275
432
|
* response_type: 'code'
|
|
@@ -277,274 +434,408 @@ interface MonoCloudOptionsBase {
|
|
|
277
434
|
*/
|
|
278
435
|
defaultAuthParams: AuthorizationParams$1;
|
|
279
436
|
/**
|
|
280
|
-
* Optional
|
|
437
|
+
* Optional resource indicators available when requesting tokens via `getTokens()`.
|
|
281
438
|
*
|
|
282
439
|
*/
|
|
283
440
|
resources?: Indicator[];
|
|
284
441
|
/**
|
|
285
|
-
*
|
|
442
|
+
* Session configuration.
|
|
286
443
|
*/
|
|
287
444
|
session: MonoCloudSessionOptionsBase;
|
|
288
445
|
/**
|
|
289
|
-
*
|
|
446
|
+
* Authentication state configuration.
|
|
290
447
|
*/
|
|
291
448
|
state: MonoCloudStateOptions;
|
|
292
449
|
/**
|
|
293
|
-
*
|
|
450
|
+
* Expected signing algorithm for ID tokens.
|
|
451
|
+
*
|
|
294
452
|
* @defaultValue 'RS256'
|
|
295
453
|
*/
|
|
296
|
-
idTokenSigningAlg: SecurityAlgorithms;
|
|
454
|
+
idTokenSigningAlg: SecurityAlgorithms$1;
|
|
297
455
|
/**
|
|
298
|
-
*
|
|
456
|
+
* List of ID token claims that should be removed before storing data in the session.
|
|
299
457
|
*/
|
|
300
458
|
filteredIdTokenClaims: string[];
|
|
301
459
|
/**
|
|
302
|
-
*
|
|
460
|
+
* Identifier used for internal debugging/logging.
|
|
303
461
|
*/
|
|
304
462
|
debugger: string;
|
|
305
463
|
/**
|
|
306
|
-
*
|
|
464
|
+
* Custom User-Agent value sent with requests to MonoCloud.
|
|
307
465
|
*/
|
|
308
466
|
userAgent: string;
|
|
309
467
|
/**
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
* Time in seconds to cache the JWKS document after it is fetched
|
|
468
|
+
* Duration (in seconds) to cache the JWKS document.
|
|
313
469
|
*
|
|
314
|
-
* @
|
|
315
|
-
|
|
316
|
-
* */
|
|
470
|
+
* @defaultValue 300
|
|
471
|
+
*/
|
|
317
472
|
jwksCacheDuration?: number;
|
|
318
473
|
/**
|
|
319
|
-
*
|
|
474
|
+
* Duration (in seconds) to cache OpenID discovery metadata.
|
|
320
475
|
*
|
|
321
|
-
*
|
|
322
|
-
|
|
323
|
-
* @default 60 (seconds)
|
|
324
|
-
* */
|
|
476
|
+
* @defaultValue 300
|
|
477
|
+
*/
|
|
325
478
|
metadataCacheDuration?: number;
|
|
326
479
|
/**
|
|
327
|
-
*
|
|
328
|
-
* from query.
|
|
480
|
+
* Allows authorization parameters to be overridden using query parameters.
|
|
329
481
|
*
|
|
330
|
-
* When
|
|
331
|
-
* from the query parameters will be merged into the authentication request.
|
|
482
|
+
* When disabled, parameters such as `scope`, `resource`, `prompt`, and `login_hint` present in the request URL are ignored and cannot modify the authentication request.
|
|
332
483
|
*
|
|
333
|
-
* @
|
|
334
|
-
*
|
|
335
|
-
* // The SDK will automatically use prompt='login' and the login_hint.
|
|
336
|
-
* https://example.com/api/auth/signin?prompt=login&login_hint=user@example.com
|
|
337
|
-
*
|
|
338
|
-
* @default false
|
|
484
|
+
* @defaultValue false
|
|
339
485
|
*/
|
|
340
486
|
allowQueryParamOverrides?: boolean;
|
|
341
487
|
/**
|
|
342
|
-
*
|
|
488
|
+
* Invoked when a back-channel logout request is received.
|
|
343
489
|
*/
|
|
344
490
|
onBackChannelLogout?: OnBackChannelLogout;
|
|
345
491
|
/**
|
|
346
|
-
*
|
|
492
|
+
* Invoked before authentication begins to attach custom application state.
|
|
347
493
|
*/
|
|
348
494
|
onSetApplicationState?: OnSetApplicationState;
|
|
349
495
|
/**
|
|
350
|
-
*
|
|
496
|
+
* Invoked before a session is created or updated. Can be used to modify session data or attach custom fields.
|
|
351
497
|
*/
|
|
352
498
|
onSessionCreating?: OnSessionCreating;
|
|
353
499
|
}
|
|
354
500
|
/**
|
|
355
|
-
*
|
|
501
|
+
* Partial configuration options for authentication sessions.
|
|
502
|
+
*
|
|
503
|
+
* @category Types
|
|
356
504
|
*/
|
|
357
|
-
|
|
505
|
+
interface MonoCloudSessionOptions extends Partial<Omit<MonoCloudSessionOptionsBase, 'store' | 'cookie'>> {
|
|
506
|
+
/**
|
|
507
|
+
* Session cookie settings.
|
|
508
|
+
*/
|
|
509
|
+
cookie?: Partial<MonoCloudCookieOptions>;
|
|
358
510
|
/**
|
|
359
|
-
*
|
|
511
|
+
* A custom session store implementation.
|
|
512
|
+
*
|
|
513
|
+
* When provided, sessions are persisted using this store instead of cookies-only storage.
|
|
360
514
|
*/
|
|
361
515
|
store?: MonoCloudSessionStore;
|
|
362
|
-
}
|
|
516
|
+
}
|
|
363
517
|
/**
|
|
364
|
-
*
|
|
518
|
+
* Configuration options used to initialize the SDK client.
|
|
519
|
+
*
|
|
520
|
+
* ## Configuration Sources
|
|
521
|
+
*
|
|
522
|
+
* Configuration values can be provided using either:
|
|
523
|
+
*
|
|
524
|
+
* - **Constructor options** - passed when creating the client instance.
|
|
525
|
+
* - **Environment variables** - using `MONOCLOUD_AUTH_*` variables.
|
|
526
|
+
*
|
|
527
|
+
* When both are provided, **constructor options override environment variables**.
|
|
528
|
+
*
|
|
529
|
+
* ## Environment Variables
|
|
530
|
+
*
|
|
531
|
+
* ### Core Configuration (Required)
|
|
532
|
+
*
|
|
533
|
+
* | Environment Variable | Description |
|
|
534
|
+
* |----------------------|-------------|
|
|
535
|
+
* | `MONOCLOUD_AUTH_CLIENT_ID` | Unique identifier for your application/client. |
|
|
536
|
+
* | `MONOCLOUD_AUTH_CLIENT_SECRET` | Application/client secret used for authentication. |
|
|
537
|
+
* | `MONOCLOUD_AUTH_TENANT_DOMAIN` | The domain of your MonoCloud tenant (for example, `https://your-tenant.us.monocloud.com`). |
|
|
538
|
+
* | `MONOCLOUD_AUTH_APP_URL` | The base URL where your application is hosted. |
|
|
539
|
+
* | `MONOCLOUD_AUTH_COOKIE_SECRET` | A long, random string used to encrypt and sign session cookies. |
|
|
540
|
+
*
|
|
541
|
+
* ### Authentication & Security
|
|
542
|
+
*
|
|
543
|
+
* | Environment Variable | Description |
|
|
544
|
+
* |----------------------|-------------|
|
|
545
|
+
* | `MONOCLOUD_AUTH_SCOPES` | Space-separated list of OIDC scopes to request (for example, `openid profile email`). |
|
|
546
|
+
* | `MONOCLOUD_AUTH_RESOURCE` | Default resource (audience) identifier used when issuing access tokens. |
|
|
547
|
+
* | `MONOCLOUD_AUTH_USE_PAR` | Enables Pushed Authorization Requests (PAR) for authorization flows. |
|
|
548
|
+
* | `MONOCLOUD_AUTH_CLOCK_SKEW` | Allowed clock drift (in seconds) when validating token timestamps. |
|
|
549
|
+
* | `MONOCLOUD_AUTH_FEDERATED_SIGNOUT` | If `true`, signing out of the application also signs the user out of MonoCloud (SSO sign-out). |
|
|
550
|
+
* | `MONOCLOUD_AUTH_RESPONSE_TIMEOUT` | Maximum time (in milliseconds) to wait for responses from the authentication service. |
|
|
551
|
+
* | `MONOCLOUD_AUTH_ALLOW_QUERY_PARAM_OVERRIDES` | Allows authorization parameters (such as `scope`, `resource`, or `prompt`) to be overridden via URL query parameters. |
|
|
552
|
+
* | `MONOCLOUD_AUTH_POST_LOGOUT_REDIRECT_URI` | URL users are redirected to after a successful logout. |
|
|
553
|
+
* | `MONOCLOUD_AUTH_USER_INFO` | Determines whether user profile data is fetched from the `UserInfo` endpoint after authorization. |
|
|
554
|
+
* | `MONOCLOUD_AUTH_REFETCH_USER_INFO` | If `true`, user information is re-fetched on each userinfo request. |
|
|
555
|
+
* | `MONOCLOUD_AUTH_ID_TOKEN_SIGNING_ALG` | Expected signing algorithm for ID tokens (for example, `RS256`). |
|
|
556
|
+
* | `MONOCLOUD_AUTH_FILTERED_ID_TOKEN_CLAIMS` | Space-separated list of ID token claims excluded from the session object. |
|
|
557
|
+
*
|
|
558
|
+
* ### Routes
|
|
559
|
+
*
|
|
560
|
+
* | Environment Variable | Description |
|
|
561
|
+
* |----------------------|-------------|
|
|
562
|
+
* | `MONOCLOUD_AUTH_CALLBACK_URL` | Application path where the authorization server redirects the user after authentication. |
|
|
563
|
+
* | `MONOCLOUD_AUTH_SIGNIN_URL` | Internal route used to initiate the sign-in flow. |
|
|
564
|
+
* | `MONOCLOUD_AUTH_SIGNOUT_URL` | Internal route used to initiate the sign-out flow. |
|
|
565
|
+
* | `MONOCLOUD_AUTH_USER_INFO_URL` | Route that exposes the authenticated user’s profile retrieved from the UserInfo endpoint. |
|
|
566
|
+
*
|
|
567
|
+
* ### Session Cookie Settings
|
|
568
|
+
*
|
|
569
|
+
* | Environment Variable | Description |
|
|
570
|
+
* |----------------------|-------------|
|
|
571
|
+
* | `MONOCLOUD_AUTH_SESSION_COOKIE_NAME` | Name of the cookie used to store the authenticated user session. |
|
|
572
|
+
* | `MONOCLOUD_AUTH_SESSION_COOKIE_PATH` | Path scope for which the session cookie is valid. |
|
|
573
|
+
* | `MONOCLOUD_AUTH_SESSION_COOKIE_DOMAIN` | Domain scope for which the session cookie is valid. |
|
|
574
|
+
* | `MONOCLOUD_AUTH_SESSION_COOKIE_HTTP_ONLY` | Prevents client-side scripts from accessing the session cookie. |
|
|
575
|
+
* | `MONOCLOUD_AUTH_SESSION_COOKIE_SECURE` | Ensures the session cookie is only sent over HTTPS connections. |
|
|
576
|
+
* | `MONOCLOUD_AUTH_SESSION_COOKIE_SAME_SITE` | SameSite policy applied to the session cookie (`lax`, `strict`, or `none`). |
|
|
577
|
+
* | `MONOCLOUD_AUTH_SESSION_COOKIE_PERSISTENT` | Determines whether the session cookie persists across browser restarts. |
|
|
578
|
+
* | `MONOCLOUD_AUTH_SESSION_SLIDING` | Enables sliding session expiration instead of absolute expiration. |
|
|
579
|
+
* | `MONOCLOUD_AUTH_SESSION_DURATION` | Session lifetime in seconds. |
|
|
580
|
+
* | `MONOCLOUD_AUTH_SESSION_MAX_DURATION` | Maximum allowed lifetime of a sliding session in seconds. |
|
|
581
|
+
*
|
|
582
|
+
* ### State Cookie Settings
|
|
583
|
+
*
|
|
584
|
+
* | Environment Variable | Description |
|
|
585
|
+
* |----------------------|-------------|
|
|
586
|
+
* | `MONOCLOUD_AUTH_STATE_COOKIE_NAME` | Name of the cookie used to store OpenID Connect state and nonce values during authentication. |
|
|
587
|
+
* | `MONOCLOUD_AUTH_STATE_COOKIE_PATH` | Path scope for which the state cookie is valid. |
|
|
588
|
+
* | `MONOCLOUD_AUTH_STATE_COOKIE_DOMAIN` | Domain scope for which the state cookie is valid. |
|
|
589
|
+
* | `MONOCLOUD_AUTH_STATE_COOKIE_SECURE` | Ensures the state cookie is only sent over HTTPS connections. |
|
|
590
|
+
* | `MONOCLOUD_AUTH_STATE_COOKIE_SAME_SITE` | SameSite policy applied to the state cookie (`lax`, `strict`, or `none`). |
|
|
591
|
+
* | `MONOCLOUD_AUTH_STATE_COOKIE_PERSISTENT` | Determines whether the state cookie persists beyond the current browser session. |
|
|
592
|
+
*
|
|
593
|
+
* ### Caching
|
|
594
|
+
*
|
|
595
|
+
* | Environment Variable | Description |
|
|
596
|
+
* |----------------------|-------------|
|
|
597
|
+
* | `MONOCLOUD_AUTH_JWKS_CACHE_DURATION` | Duration (in seconds) to cache the JSON Web Key Set (JWKS) used to verify tokens. |
|
|
598
|
+
* | `MONOCLOUD_AUTH_METADATA_CACHE_DURATION` | Duration (in seconds) to cache the OpenID Connect discovery metadata. |
|
|
599
|
+
*
|
|
600
|
+
* @category Types
|
|
365
601
|
*/
|
|
366
|
-
|
|
602
|
+
interface MonoCloudOptions extends Partial<Omit<MonoCloudOptionsBase, 'defaultAuthParams' | 'session' | 'routes' | 'state'>> {
|
|
367
603
|
/**
|
|
368
|
-
* Default authorization parameters
|
|
604
|
+
* Default authorization parameters automatically included in authentication requests unless explicitly overridden.
|
|
605
|
+
*
|
|
369
606
|
* @defaultValue {
|
|
370
607
|
* scope: 'openid email profile',
|
|
371
608
|
* response_type: 'code'
|
|
372
609
|
* }
|
|
373
610
|
*/
|
|
374
|
-
defaultAuthParams?:
|
|
611
|
+
defaultAuthParams?: AuthorizationParams$1;
|
|
612
|
+
/**
|
|
613
|
+
* Overrides for built-in authentication route paths.
|
|
614
|
+
*/
|
|
615
|
+
routes?: Partial<MonoCloudRoutes>;
|
|
375
616
|
/**
|
|
376
|
-
*
|
|
617
|
+
* Session configuration overrides.
|
|
377
618
|
*/
|
|
378
619
|
session?: MonoCloudSessionOptions;
|
|
379
|
-
|
|
620
|
+
/**
|
|
621
|
+
* Configuration for authentication state handling.
|
|
622
|
+
*/
|
|
623
|
+
state?: MonoCloudStatePartialOptions;
|
|
624
|
+
}
|
|
380
625
|
/**
|
|
381
|
-
*
|
|
382
|
-
*
|
|
626
|
+
* Callback invoked when a back-channel logout event is received from the authorization server.
|
|
627
|
+
*
|
|
628
|
+
* Back-channel logout allows MonoCloud to notify the application that a user session should be terminated without browser interaction.
|
|
629
|
+
*
|
|
630
|
+
* @category Types (Handler)
|
|
383
631
|
*
|
|
384
|
-
* @param sub
|
|
385
|
-
* @param sid
|
|
386
|
-
* @returns
|
|
632
|
+
* @param sub Optional subject identifier (`sub`) of the user associated with the logout event.
|
|
633
|
+
* @param sid Optional session identifier (`sid`) for the session being terminated.
|
|
634
|
+
* @returns Returns a promise or void. Execution completes once logout handling finishes.
|
|
387
635
|
*/
|
|
388
636
|
type OnBackChannelLogout = (
|
|
389
637
|
/**
|
|
390
|
-
*
|
|
638
|
+
* Subject identifier of the user.
|
|
391
639
|
*/
|
|
392
640
|
sub?: string,
|
|
393
641
|
/**
|
|
394
|
-
*
|
|
642
|
+
* Session identifier associated with the logout event.
|
|
395
643
|
*/
|
|
396
644
|
sid?: string) => Promise<void> | void;
|
|
397
645
|
/**
|
|
398
|
-
*
|
|
646
|
+
* Represents custom application state associated with an authentication request.
|
|
647
|
+
*
|
|
648
|
+
* This object is populated via `onSetApplicationState` and is persisted through the authentication flow. The resolved value is later available during session creation and can be used to carry application-specific context (for example: return targets, workflow state, or tenant hints).
|
|
649
|
+
*
|
|
650
|
+
* @category Types
|
|
399
651
|
*/
|
|
400
|
-
|
|
652
|
+
interface ApplicationState extends Record<string, any> {}
|
|
401
653
|
/**
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
654
|
+
* Callback invoked before a session is created or updated.
|
|
655
|
+
*
|
|
656
|
+
* Use this hook to modify or enrich the session before it is persisted. The callback receives the resolved session along with optional claims obtained during authentication and any custom application state.
|
|
657
|
+
*
|
|
658
|
+
* Common use cases include:
|
|
659
|
+
* - Adding custom properties to the session
|
|
660
|
+
* - Mapping or filtering claims
|
|
661
|
+
* - Attaching tenant or application-specific metadata
|
|
406
662
|
*
|
|
407
|
-
* @
|
|
408
|
-
*
|
|
409
|
-
* @param
|
|
410
|
-
* @param
|
|
411
|
-
* @
|
|
663
|
+
* @category Types (Handler)
|
|
664
|
+
*
|
|
665
|
+
* @param session The session being created or updated. Changes made to this object are persisted.
|
|
666
|
+
* @param idToken Optional claims extracted from the ID token.
|
|
667
|
+
* @param userInfo Optional claims returned from the `UserInfo` endpoint.
|
|
668
|
+
* @param state Optional application state created during the authentication request.
|
|
669
|
+
* @returns Returns a promise or void. Execution continues once the callback completes.
|
|
412
670
|
*/
|
|
413
671
|
type OnSessionCreating = (
|
|
414
672
|
/**
|
|
415
|
-
* The
|
|
673
|
+
* The session being created or updated.
|
|
416
674
|
*/
|
|
417
675
|
session: MonoCloudSession$1,
|
|
418
676
|
/**
|
|
419
|
-
* Optional
|
|
677
|
+
* Optional claims extracted from the ID token.
|
|
420
678
|
*/
|
|
421
679
|
idToken?: Partial<IdTokenClaims$1>,
|
|
422
680
|
/**
|
|
423
|
-
* Optional
|
|
681
|
+
* Optional claims returned from the `UserInfo` endpoint.
|
|
424
682
|
*/
|
|
425
683
|
userInfo?: UserinfoResponse$1,
|
|
426
684
|
/**
|
|
427
|
-
* Optional
|
|
685
|
+
* Optional application state associated with the authentication flow.
|
|
428
686
|
*/
|
|
429
687
|
state?: ApplicationState) => Promise<void> | void;
|
|
430
688
|
/**
|
|
431
|
-
*
|
|
432
|
-
*
|
|
689
|
+
* Callback invoked when the authentication state is being created before redirecting the user to the authorization server.
|
|
690
|
+
*
|
|
691
|
+
* Use this hook to attach custom application state that should survive the authentication round-trip and be available after the user returns from sign-in.
|
|
692
|
+
*
|
|
693
|
+
* The returned value is stored securely and later provided during session creation.
|
|
694
|
+
*
|
|
695
|
+
* Common use cases include:
|
|
696
|
+
* - Preserving return URLs or navigation context
|
|
697
|
+
* - Passing tenant or organization identifiers
|
|
698
|
+
* - Storing temporary workflow state across authentication
|
|
699
|
+
*
|
|
700
|
+
* @category Types (Handler)
|
|
433
701
|
*
|
|
434
|
-
* @param req
|
|
435
|
-
* @returns
|
|
702
|
+
* @param req The incoming request initiating authentication.
|
|
703
|
+
* @returns Returns an application state object, either synchronously or as a Promise.
|
|
436
704
|
*/
|
|
437
705
|
type OnSetApplicationState = (
|
|
438
706
|
/**
|
|
439
|
-
* The incoming request.
|
|
707
|
+
* The incoming request initiating authentication.
|
|
440
708
|
*/
|
|
441
709
|
req: MonoCloudRequest) => Promise<ApplicationState> | ApplicationState;
|
|
442
710
|
/**
|
|
443
|
-
* Represents the
|
|
711
|
+
* Represents the token set associated with the currently authenticated user.
|
|
712
|
+
*
|
|
713
|
+
* This object extends {@link AccessToken} and includes additional tokens issued during authentication, along with convenience metadata used by the SDK to indicate token validity.
|
|
714
|
+
*
|
|
715
|
+
* @category Types
|
|
444
716
|
*/
|
|
445
717
|
interface MonoCloudTokens extends AccessToken$1 {
|
|
446
718
|
/**
|
|
447
|
-
* The ID token
|
|
719
|
+
* The ID token issued during authentication. Contains identity claims about the authenticated user.
|
|
448
720
|
*/
|
|
449
721
|
idToken?: string;
|
|
450
722
|
/**
|
|
451
|
-
* The refresh token
|
|
723
|
+
* The refresh token used to obtain new access tokens without requiring the user to re-authenticate.
|
|
452
724
|
*/
|
|
453
725
|
refreshToken?: string;
|
|
454
726
|
/**
|
|
455
|
-
*
|
|
727
|
+
* Indicates whether the current access token is expired at the time of evaluation.
|
|
456
728
|
*/
|
|
457
729
|
isExpired: boolean;
|
|
458
730
|
}
|
|
459
731
|
/**
|
|
460
|
-
*
|
|
732
|
+
* Defines a callback invoked when an unexpected error occurs during execution of authentication endpoints such as sign-in, callback, sign-out, or userinfo.
|
|
733
|
+
*
|
|
734
|
+
* This handler allows applications to log, transform, or respond to errors before the SDK applies its default error handling behavior.
|
|
461
735
|
*
|
|
462
|
-
* @
|
|
736
|
+
* @category Types (Handler)
|
|
737
|
+
*
|
|
738
|
+
* @param error - The error thrown during endpoint execution.
|
|
463
739
|
*/
|
|
464
740
|
type OnError = (error: Error) => Promise<any> | any;
|
|
465
741
|
/**
|
|
466
|
-
*
|
|
742
|
+
* Options used to customize the sign-in flow.
|
|
743
|
+
*
|
|
744
|
+
* @category Types
|
|
467
745
|
*/
|
|
468
746
|
interface SignInOptions {
|
|
469
747
|
/**
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
748
|
+
* Relative URL to redirect the user to after successful authentication.
|
|
749
|
+
*
|
|
750
|
+
* If not provided, the application base URL (`appUrl`) is used.
|
|
473
751
|
*/
|
|
474
752
|
returnUrl?: string;
|
|
475
753
|
/**
|
|
476
|
-
*
|
|
754
|
+
* When `true`, initiates the user registration (sign-up) flow instead of a standard sign-in.
|
|
477
755
|
*/
|
|
478
756
|
register?: boolean;
|
|
479
757
|
/**
|
|
480
|
-
* Additional authorization parameters
|
|
758
|
+
* Additional authorization parameters merged into the authentication request.
|
|
481
759
|
*/
|
|
482
760
|
authParams?: AuthorizationParams$1;
|
|
483
761
|
/**
|
|
484
|
-
*
|
|
762
|
+
* Callback invoked if an unexpected error occurs during the sign-in flow.
|
|
485
763
|
*/
|
|
486
764
|
onError?: OnError;
|
|
487
765
|
}
|
|
488
766
|
/**
|
|
489
|
-
*
|
|
767
|
+
* Options used to customize callback processing after authentication.
|
|
768
|
+
*
|
|
769
|
+
* @category Types
|
|
490
770
|
*/
|
|
491
771
|
interface CallbackOptions {
|
|
492
772
|
/**
|
|
493
|
-
*
|
|
773
|
+
* When `true`, fetches user profile data from the `UserInfo` endpoint after the authorization code exchange completes.
|
|
494
774
|
*/
|
|
495
775
|
userInfo?: boolean;
|
|
496
776
|
/**
|
|
497
|
-
*
|
|
777
|
+
* Redirect URI sent to the token endpoint during the authorization code exchange.
|
|
778
|
+
*
|
|
779
|
+
* > This must match the redirect URI used during the sign-in request.
|
|
498
780
|
*/
|
|
499
781
|
redirectUri?: string;
|
|
500
782
|
/**
|
|
501
|
-
*
|
|
783
|
+
* Callback invoked if an unexpected error occurs while processing the authentication callback.
|
|
502
784
|
*/
|
|
503
785
|
onError?: OnError;
|
|
504
786
|
}
|
|
505
787
|
/**
|
|
506
|
-
*
|
|
788
|
+
* Options used to customize the behavior of the userinfo handler.
|
|
789
|
+
*
|
|
790
|
+
* @category Types
|
|
507
791
|
*/
|
|
508
792
|
interface UserInfoOptions {
|
|
509
793
|
/**
|
|
510
|
-
*
|
|
794
|
+
* When `true`, forces user profile data to be re-fetched from the authentication service instead of using cached session data.
|
|
511
795
|
*/
|
|
512
796
|
refresh?: boolean;
|
|
513
797
|
/**
|
|
514
|
-
*
|
|
798
|
+
* Callback invoked if an unexpected error occurs while retrieving user information.
|
|
515
799
|
*/
|
|
516
800
|
onError?: OnError;
|
|
517
801
|
}
|
|
518
802
|
/**
|
|
519
|
-
*
|
|
803
|
+
* Options used to customize the behavior of the sign-out handler.
|
|
804
|
+
*
|
|
805
|
+
* @category Types
|
|
520
806
|
*/
|
|
521
|
-
|
|
807
|
+
interface SignOutOptions extends EndSessionParameters$1 {
|
|
522
808
|
/**
|
|
523
|
-
*
|
|
809
|
+
* When `true`, also signs the user out of the MonoCloud session (Single Sign-Out) in addition to the local application session.
|
|
524
810
|
*/
|
|
525
811
|
federatedSignOut?: boolean;
|
|
526
812
|
/**
|
|
527
|
-
*
|
|
813
|
+
* Callback invoked if an unexpected error occurs during the sign-out flow.
|
|
528
814
|
*/
|
|
529
815
|
onError?: OnError;
|
|
530
|
-
}
|
|
816
|
+
}
|
|
531
817
|
/**
|
|
532
|
-
*
|
|
818
|
+
* Options used to control token retrieval and refresh behavior when calling `getTokens()`.
|
|
819
|
+
*
|
|
820
|
+
* @category Types
|
|
533
821
|
*/
|
|
534
822
|
interface GetTokensOptions extends RefreshGrantOptions$1 {
|
|
535
823
|
/**
|
|
536
|
-
*
|
|
824
|
+
* When `true`, forces a refresh of the access token even if the current token has not expired.
|
|
537
825
|
*/
|
|
538
826
|
forceRefresh?: boolean;
|
|
539
827
|
/**
|
|
540
|
-
*
|
|
828
|
+
* When enabled, refetches user information from the `UserInfo` endpoint after tokens are refreshed.
|
|
541
829
|
*/
|
|
542
830
|
refetchUserInfo?: boolean;
|
|
543
831
|
}
|
|
544
832
|
//#endregion
|
|
545
833
|
//#region src/monocloud-node-core-client.d.ts
|
|
834
|
+
/**
|
|
835
|
+
* @category Classes
|
|
836
|
+
*/
|
|
546
837
|
declare class MonoCloudCoreClient {
|
|
547
|
-
readonly oidcClient: MonoCloudOidcClient
|
|
838
|
+
readonly oidcClient: MonoCloudOidcClient;
|
|
548
839
|
private readonly options;
|
|
549
840
|
private readonly stateService;
|
|
550
841
|
private readonly sessionService;
|
|
@@ -555,7 +846,7 @@ declare class MonoCloudCoreClient {
|
|
|
555
846
|
* Initiates the sign-in flow by redirecting the user to the MonoCloud authorization endpoint.
|
|
556
847
|
*
|
|
557
848
|
* This method handles scope and resource merging, state generation (nonce, state, PKCE),
|
|
558
|
-
* and
|
|
849
|
+
* and constructing the final authorization URL.
|
|
559
850
|
*
|
|
560
851
|
* @param request - MonoCloud request object.
|
|
561
852
|
* @param response - MonoCloud response object.
|
|
@@ -676,7 +967,7 @@ declare class MonoCloudCoreClient {
|
|
|
676
967
|
* @param response - MonoCloud cookie response object.
|
|
677
968
|
* @param options - Configuration for token retrieval (force refresh, specific scopes/resources).
|
|
678
969
|
*
|
|
679
|
-
* @returns Fetched tokens
|
|
970
|
+
* @returns Fetched tokens.
|
|
680
971
|
*
|
|
681
972
|
* @throws {@link MonoCloudValidationError} If the session does not exist or tokens cannot be found/refreshed.
|
|
682
973
|
*/
|
|
@@ -686,5 +977,5 @@ declare class MonoCloudCoreClient {
|
|
|
686
977
|
private validateOptions;
|
|
687
978
|
}
|
|
688
979
|
//#endregion
|
|
689
|
-
export { type AccessToken, type ApplicationState, type AuthState, type AuthenticateOptions, type Authenticators, type AuthorizationParams, type CallbackOptions, type CallbackParams, type ClientAuthMethod, type CodeChallengeMethod, type CookieOptions, type DisplayOptions, type EndSessionParameters, type GetTokensOptions, type Group, type IMonoCloudCookieRequest, type IMonoCloudCookieResponse, type IdTokenClaims, type Indicator, type IssuerMetadata, type
|
|
980
|
+
export { type AccessToken, type Address, type ApplicationState, type AuthState, type AuthenticateOptions, type Authenticators, type AuthorizationParams, type CallbackOptions, type CallbackParams, type ClientAuthMethod, type CodeChallengeMethod, type CookieOptions, type DisplayOptions, type EndSessionParameters, type GetTokensOptions, type Group, type IMonoCloudCookieRequest, type IMonoCloudCookieResponse, type IdTokenClaims, type Indicator, type IssuerMetadata, type Jwk, type Jwks, type JwsHeaderParameters, MonoCloudAuthBaseError, type MonoCloudClientOptions, type MonoCloudCookieOptions, MonoCloudCoreClient, MonoCloudHttpError, MonoCloudOPError, type MonoCloudOptions, type MonoCloudOptionsBase, type MonoCloudRequest, type MonoCloudResponse, type MonoCloudRoutes, type MonoCloudSession, type MonoCloudSessionOptions, type MonoCloudSessionOptionsBase, type MonoCloudSessionStore, type MonoCloudStateOptions, type MonoCloudStatePartialOptions, MonoCloudTokenError, type MonoCloudTokens, type MonoCloudUser, MonoCloudValidationError, type OnBackChannelLogout, type OnCoreSessionCreating, type OnError, type OnSessionCreating, type OnSetApplicationState, type ParResponse, type Prompt, type PushedAuthorizationParams, type RefetchUserInfoOptions, type RefreshGrantOptions, type RefreshSessionOptions, type ResponseModes, type ResponseTypes, type SameSiteValues, type SecurityAlgorithms, type SerializeOptions, type SessionLifetime, type SetCookie, type SignInOptions, type SignOutOptions, type Tokens, type UserInfoOptions, type UserinfoResponse };
|
|
690
981
|
//# sourceMappingURL=index.d.mts.map
|