@monocloud/auth-node-core 0.0.0-canary-20251223204113

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 ADDED
@@ -0,0 +1,1105 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+ let _monocloud_auth_core = require("@monocloud/auth-core");
29
+ let jose = require("jose");
30
+ let _monocloud_auth_core_internal = require("@monocloud/auth-core/internal");
31
+ let _monocloud_auth_core_utils = require("@monocloud/auth-core/utils");
32
+ let uuid = require("uuid");
33
+ let cookie = require("cookie");
34
+ let joi = require("joi");
35
+ joi = __toESM(joi);
36
+ let debug = require("debug");
37
+ debug = __toESM(debug);
38
+
39
+ //#region src/monocloud-session-service.ts
40
+ const CHUNK_BYTE_SIZE = 4090;
41
+ var MonoCloudSessionService = class {
42
+ constructor(options) {
43
+ this.options = options;
44
+ }
45
+ async setSession(req, res, session) {
46
+ const key = (0, uuid.v4)();
47
+ const iat = (0, _monocloud_auth_core_internal.now)();
48
+ const uat = iat;
49
+ const cookieValue = {
50
+ key,
51
+ lifetime: {
52
+ c: iat,
53
+ u: uat,
54
+ e: this.getExpiry(iat, uat)
55
+ }
56
+ };
57
+ await this.saveSession(req, res, cookieValue, session);
58
+ return key;
59
+ }
60
+ async getSession(req, res, shouldResave = true) {
61
+ const cookieValue = await this.getCookieData(req);
62
+ if (!cookieValue) {
63
+ await this.deleteAllCookies(req, res);
64
+ return;
65
+ }
66
+ if (!await this.validateSession(req, res, cookieValue)) return;
67
+ const uat = (0, _monocloud_auth_core_internal.now)();
68
+ const exp = this.getExpiry(cookieValue.lifetime.c, uat);
69
+ if (!this.options.session.store) {
70
+ const session$1 = { user: {} };
71
+ if (!cookieValue.session) return;
72
+ Object.assign(session$1, JSON.parse(JSON.stringify(cookieValue.session)));
73
+ if (shouldResave && exp !== cookieValue.lifetime.e) await this.saveSession(req, res, {
74
+ ...cookieValue,
75
+ lifetime: {
76
+ c: cookieValue.lifetime.c,
77
+ u: uat,
78
+ e: exp
79
+ }
80
+ }, session$1);
81
+ return session$1;
82
+ }
83
+ const sessionObj = await this.options.session.store.get(cookieValue.key);
84
+ if (!sessionObj) {
85
+ await this.deleteAllCookies(req, res);
86
+ return;
87
+ }
88
+ const session = { user: {} };
89
+ Object.assign(session, JSON.parse(JSON.stringify(sessionObj)));
90
+ if (shouldResave && exp !== cookieValue.lifetime.e) await this.saveSession(req, res, {
91
+ ...cookieValue,
92
+ lifetime: {
93
+ c: cookieValue.lifetime.c,
94
+ u: uat,
95
+ e: exp
96
+ }
97
+ }, session);
98
+ return session;
99
+ }
100
+ async updateSession(req, res, session) {
101
+ const cookieValue = await this.getCookieData(req);
102
+ if (!cookieValue) {
103
+ await this.deleteAllCookies(req, res);
104
+ return false;
105
+ }
106
+ if (!await this.validateSession(req, res, cookieValue)) return false;
107
+ const uat = (0, _monocloud_auth_core_internal.now)();
108
+ const exp = this.getExpiry(cookieValue.lifetime.c, uat);
109
+ await this.saveSession(req, res, {
110
+ ...cookieValue,
111
+ lifetime: {
112
+ c: cookieValue.lifetime.c,
113
+ u: uat,
114
+ e: exp
115
+ }
116
+ }, session);
117
+ return true;
118
+ }
119
+ async removeSession(req, res) {
120
+ const cookieValue = await this.getCookieData(req);
121
+ if (!cookieValue) {
122
+ await this.deleteAllCookies(req, res);
123
+ return;
124
+ }
125
+ if (this.options.session.store) {
126
+ /* v8 ignore else -- @preserve */
127
+ if (cookieValue.key) await this.options.session.store.delete(cookieValue.key);
128
+ }
129
+ await this.deleteAllCookies(req, res);
130
+ }
131
+ async validateSession(req, res, cookieValue) {
132
+ const nowTime = (0, _monocloud_auth_core_internal.now)();
133
+ let isValid = true;
134
+ if (cookieValue.lifetime.e && cookieValue.lifetime.e < nowTime) isValid = false;
135
+ if (this.options.session.sliding && cookieValue.lifetime.u + this.options.session.duration < nowTime) isValid = false;
136
+ if (cookieValue.lifetime.c + this.options.session.maximumDuration < nowTime) isValid = false;
137
+ if (isValid) return true;
138
+ if (this.options.session.store) await this.options.session.store.delete(cookieValue.key);
139
+ await this.deleteAllCookies(req, res);
140
+ return false;
141
+ }
142
+ async saveSession(req, res, cookieValue, session) {
143
+ var _await$this$getReques;
144
+ const cookies = new Set(((_await$this$getReques = await this.getRequestCookie(req)) === null || _await$this$getReques === void 0 ? void 0 : _await$this$getReques.keys) ?? []);
145
+ if (!this.options.session.store) cookieValue.session = session;
146
+ if (this.options.session.store) {
147
+ const cookieData = await this.getCookieData(req);
148
+ if (cookieData === null || cookieData === void 0 ? void 0 : cookieData.key) await this.options.session.store.delete(cookieData.key);
149
+ cookieValue.session = void 0;
150
+ await this.options.session.store.set(cookieValue.key, session, cookieValue.lifetime);
151
+ }
152
+ const encryptedData = await (0, _monocloud_auth_core_utils.encrypt)(JSON.stringify(cookieValue), this.options.cookieSecret);
153
+ const cookieExpiry = cookieValue.lifetime.e ? /* @__PURE__ */ new Date(cookieValue.lifetime.e * 1e3) : void 0;
154
+ const cookieOptions = this.getCookieOptions(cookieExpiry);
155
+ const chunkSize = CHUNK_BYTE_SIZE - (0, cookie.serialize)(`${this.options.session.cookie.name}.0`, "", cookieOptions).length;
156
+ const chunks = Math.ceil(encryptedData.length / chunkSize);
157
+ for (let i = 0; i < chunks; i += 1) {
158
+ const encryptedChunk = encryptedData.slice(i * chunkSize, (i + 1) * chunkSize);
159
+ const cookieName = chunks === 1 ? this.options.session.cookie.name : `${this.options.session.cookie.name}.${i}`;
160
+ await res.setCookie(cookieName, encryptedChunk, this.getCookieOptions(cookieExpiry));
161
+ cookies.delete(cookieName);
162
+ }
163
+ for (const cookie$1 of cookies) await res.setCookie(cookie$1, "", this.getCookieOptions(/* @__PURE__ */ new Date(0)));
164
+ }
165
+ async getCookieData(req) {
166
+ const cookieData = await this.getRequestCookie(req);
167
+ if (!(cookieData === null || cookieData === void 0 ? void 0 : cookieData.value)) return;
168
+ const data = await (0, _monocloud_auth_core_utils.decrypt)(cookieData.value, this.options.cookieSecret);
169
+ if (!data) return;
170
+ return JSON.parse(data);
171
+ }
172
+ async getRequestCookie(req) {
173
+ const cookies = await req.getAllCookies();
174
+ if (!cookies.size) return;
175
+ const val = cookies.get(this.options.session.cookie.name);
176
+ if (val) return {
177
+ keys: [this.options.session.cookie.name],
178
+ value: val
179
+ };
180
+ const cookieValues = Array.from(cookies.entries()).filter(([cookie$1]) => cookie$1.startsWith(`${this.options.session.cookie.name}.`)).map(([cookie$1, value]) => ({
181
+ key: parseInt(cookie$1.split(".").pop() || "0", 10),
182
+ value
183
+ })).sort((a, b) => a.key - b.key);
184
+ const cookieValue = cookieValues.map(({ value }) => value).join("");
185
+ if (!cookieValue) return;
186
+ return {
187
+ keys: cookieValues.map(({ key }) => `${this.options.session.cookie.name}.${key}`),
188
+ value: cookieValue
189
+ };
190
+ }
191
+ getExpiry(iat, uat) {
192
+ if (!this.options.session.cookie.persistent) return;
193
+ if (!this.options.session.sliding) return Math.floor(iat + this.options.session.duration);
194
+ return Math.floor(Math.min(uat + this.options.session.duration, iat + this.options.session.maximumDuration));
195
+ }
196
+ getCookieOptions(exp) {
197
+ return {
198
+ domain: this.options.session.cookie.domain,
199
+ httpOnly: this.options.session.cookie.httpOnly,
200
+ sameSite: this.options.session.cookie.sameSite,
201
+ secure: this.options.session.cookie.secure,
202
+ path: this.options.session.cookie.path,
203
+ expires: exp
204
+ };
205
+ }
206
+ async deleteAllCookies(req, res) {
207
+ var _reqCookie$keys;
208
+ const reqCookie = await this.getRequestCookie(req);
209
+ const cookies = reqCookie === null || reqCookie === void 0 || (_reqCookie$keys = reqCookie.keys) === null || _reqCookie$keys === void 0 ? void 0 : _reqCookie$keys.filter((x) => x.startsWith(this.options.session.cookie.name));
210
+ for (const cookie$1 of cookies ?? []) await res.setCookie(cookie$1, "", this.getCookieOptions(/* @__PURE__ */ new Date(0)));
211
+ }
212
+ };
213
+
214
+ //#endregion
215
+ //#region src/monocloud-state-service.ts
216
+ var MonoCloudStateService = class {
217
+ constructor(options) {
218
+ this.options = options;
219
+ }
220
+ async setState(res, state, overrideSameSite) {
221
+ await res.setCookie(this.options.state.cookie.name, await (0, _monocloud_auth_core_utils.encryptAuthState)(state, this.options.cookieSecret), this.getCookieOptions(overrideSameSite));
222
+ }
223
+ async getState(req, res) {
224
+ const cookie$1 = await req.getCookie(this.options.state.cookie.name);
225
+ if (!cookie$1) return;
226
+ let decryptedResult;
227
+ try {
228
+ decryptedResult = await (0, _monocloud_auth_core_utils.decryptAuthState)(cookie$1, this.options.cookieSecret);
229
+ } catch {
230
+ return;
231
+ }
232
+ await res.setCookie(this.options.state.cookie.name, "", {
233
+ ...this.getCookieOptions(),
234
+ expires: /* @__PURE__ */ new Date(0)
235
+ });
236
+ return decryptedResult;
237
+ }
238
+ getCookieOptions(sameSite) {
239
+ return {
240
+ domain: this.options.state.cookie.domain,
241
+ httpOnly: this.options.state.cookie.httpOnly,
242
+ sameSite: sameSite ?? this.options.state.cookie.sameSite,
243
+ secure: this.options.state.cookie.secure,
244
+ path: this.options.state.cookie.path
245
+ };
246
+ }
247
+ };
248
+
249
+ //#endregion
250
+ //#region src/options/defaults.ts
251
+ const DEFAULT_OPTIONS = {
252
+ routes: {
253
+ callback: "/api/auth/callback",
254
+ backChannelLogout: "/api/auth/backchannel-logout",
255
+ signIn: "/api/auth/signin",
256
+ signOut: "/api/auth/signout",
257
+ userInfo: "/api/auth/userinfo"
258
+ },
259
+ clockSkew: 60,
260
+ responseTimeout: 1e4,
261
+ usePar: false,
262
+ userInfo: true,
263
+ refetchUserInfo: false,
264
+ federatedSignOut: true,
265
+ defaultAuthParams: {
266
+ scopes: "openid profile email",
267
+ responseType: "code"
268
+ },
269
+ session: {
270
+ cookie: {
271
+ httpOnly: true,
272
+ name: "session",
273
+ path: "/",
274
+ sameSite: "lax",
275
+ persistent: true
276
+ },
277
+ sliding: false,
278
+ duration: 1440 * 60,
279
+ maximumDuration: 10080 * 60
280
+ },
281
+ state: { cookie: {
282
+ httpOnly: true,
283
+ name: "state",
284
+ path: "/",
285
+ sameSite: "lax",
286
+ persistent: false
287
+ } },
288
+ idTokenSigningAlg: "RS256",
289
+ filteredIdTokenClaims: [
290
+ "iss",
291
+ "exp",
292
+ "nbf",
293
+ "aud",
294
+ "nonce",
295
+ "iat",
296
+ "auth_time",
297
+ "c_hash",
298
+ "at_hash",
299
+ "s_hash"
300
+ ],
301
+ debugger: "node-auth-core",
302
+ userAgent: "node-auth-core"
303
+ };
304
+
305
+ //#endregion
306
+ //#region src/options/validation.ts
307
+ const stringRequired = joi.default.string().required();
308
+ const stringOptional = joi.default.string().optional();
309
+ const boolRequired = joi.default.boolean().required();
310
+ const boolOptional = joi.default.boolean().optional();
311
+ const numRequired = joi.default.number().required();
312
+ const numOptional = joi.default.number().optional();
313
+ const objectOptional = joi.default.object().optional();
314
+ const funcOptional = joi.default.function().optional();
315
+ const sessionCookieSchema = joi.default.object({
316
+ name: stringRequired,
317
+ path: stringRequired.uri({ relativeOnly: true }),
318
+ domain: stringOptional,
319
+ httpOnly: boolRequired,
320
+ secure: boolRequired.when(joi.default.ref("/appUrl"), {
321
+ is: joi.default.string().pattern(/^https:/i),
322
+ then: joi.default.valid(true).messages({ "any.only": "Cookie must be set to secure when app url protocol is https." }),
323
+ otherwise: joi.default.valid(false)
324
+ }),
325
+ sameSite: stringRequired.valid("strict", "lax", "none"),
326
+ persistent: boolRequired
327
+ }).required();
328
+ const resourceSchema = stringRequired.custom((value, helpers) => {
329
+ let valid;
330
+ try {
331
+ const url = new URL(value);
332
+ valid = url.searchParams.size === 0 && url.hash.length === 0;
333
+ } catch {
334
+ valid = false;
335
+ }
336
+ if (!valid) return helpers.message({ custom: "Resource must be a valid URL without query or hash parameters" });
337
+ return value;
338
+ });
339
+ const resourceValidationSchema = joi.default.string().custom((value, helpers) => {
340
+ const parts = value.split(/\s+/).map((x) => x.trim()).filter(Boolean);
341
+ if (parts.length === 0) return helpers.message({ custom: "Resource must not be empty" });
342
+ for (const part of parts) {
343
+ const { error } = resourceSchema.validate(part);
344
+ if (error) return helpers.message({ custom: `Invalid resource "${part}": ${error.message}` });
345
+ }
346
+ return parts.join(" ");
347
+ }).messages({ "string.base": "Resource must be a space-separated string of URLs" });
348
+ const sessionSchema = joi.default.object({
349
+ cookie: sessionCookieSchema,
350
+ sliding: boolRequired,
351
+ duration: numRequired.min(1),
352
+ maximumDuration: numRequired.min(1).greater(joi.default.ref("duration")),
353
+ store: objectOptional
354
+ }).required();
355
+ const stateSchema = joi.default.object({ cookie: sessionCookieSchema }).required();
356
+ const scopesSchema = stringRequired.custom((value, helpers) => {
357
+ const scopes = value.split(/\s+/).map((x) => x.trim()).filter(Boolean);
358
+ if (scopes.length === 0) return helpers.message({ custom: "Scopes must be a space-separated string" });
359
+ if (!scopes.includes("openid")) return helpers.message({ custom: "Scope must contain openid" });
360
+ return scopes.join(" ");
361
+ }).messages({ "string.base": "Scopes must be a space-separated string" });
362
+ const authParamSchema = joi.default.object({
363
+ scopes: scopesSchema,
364
+ responseType: stringOptional.valid("code").optional(),
365
+ responseMode: stringOptional.valid("query", "form_post"),
366
+ resource: resourceValidationSchema.optional()
367
+ }).unknown(true).required();
368
+ const optionalAuthParamSchema = joi.default.object({
369
+ scopes: scopesSchema,
370
+ responseType: stringOptional.valid("code").optional(),
371
+ responseMode: stringOptional.valid("query", "form_post")
372
+ }).unknown(true).optional();
373
+ const routesSchema = joi.default.object({
374
+ callback: stringRequired.uri({ relativeOnly: true }),
375
+ backChannelLogout: stringRequired.uri({ relativeOnly: true }),
376
+ signIn: stringRequired.uri({ relativeOnly: true }),
377
+ signOut: stringRequired.uri({ relativeOnly: true }),
378
+ userInfo: stringRequired.uri({ relativeOnly: true })
379
+ }).required();
380
+ const scopesValidationSchema = stringRequired.custom((value, helpers) => {
381
+ const scopes = value.split(/\s+/).map((x) => x.trim()).filter(Boolean);
382
+ if (scopes.length === 0) return helpers.message({ custom: "Scopes must be a space-separated string" });
383
+ return scopes.join(" ");
384
+ }).messages({ "string.base": "Scopes must be a space-separated string" });
385
+ const indicatorOptionsSchema = joi.default.object({
386
+ resource: resourceValidationSchema,
387
+ scopes: scopesValidationSchema.optional()
388
+ });
389
+ const optionsSchema = joi.default.object({
390
+ clientId: stringRequired,
391
+ clientSecret: stringRequired,
392
+ tenantDomain: stringRequired.uri(),
393
+ cookieSecret: stringRequired.min(8),
394
+ appUrl: stringRequired.uri(),
395
+ routes: routesSchema,
396
+ clockSkew: numRequired,
397
+ responseTimeout: numRequired.min(1e3),
398
+ usePar: boolRequired,
399
+ postLogoutRedirectUri: stringOptional.uri({ allowRelative: true }),
400
+ federatedSignOut: boolRequired,
401
+ userInfo: boolRequired,
402
+ refetchUserInfo: boolRequired,
403
+ defaultAuthParams: authParamSchema,
404
+ resources: joi.default.array().items(indicatorOptionsSchema).optional(),
405
+ session: sessionSchema,
406
+ state: stateSchema,
407
+ idTokenSigningAlg: joi.default.string().valid("RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512"),
408
+ filteredIdTokenClaims: joi.default.array().items(stringRequired),
409
+ debugger: stringRequired,
410
+ userAgent: stringRequired,
411
+ jwksCacheDuration: numOptional,
412
+ metadataCacheDuration: numOptional,
413
+ onBackChannelLogout: funcOptional,
414
+ onSetApplicationState: funcOptional,
415
+ onSessionCreating: funcOptional
416
+ });
417
+ const signInOptionsSchema = joi.default.object({
418
+ returnUrl: stringOptional.uri({ allowRelative: true }),
419
+ register: boolOptional,
420
+ authParams: optionalAuthParamSchema,
421
+ onError: funcOptional
422
+ });
423
+ const callbackOptionsSchema = joi.default.object({
424
+ userInfo: boolOptional,
425
+ redirectUri: stringOptional.uri(),
426
+ onError: funcOptional
427
+ });
428
+ const userInfoOptionsSchema = joi.default.object({
429
+ refresh: boolOptional,
430
+ onError: funcOptional
431
+ });
432
+ const signOutOptionsSchema = joi.default.object({
433
+ postLogoutRedirectUri: stringOptional.uri({ allowRelative: true }),
434
+ idToken: stringOptional,
435
+ state: stringOptional,
436
+ federatedSignOut: boolOptional,
437
+ onError: funcOptional
438
+ });
439
+ const getTokensOptionsSchema = joi.default.object({
440
+ forceRefresh: boolOptional,
441
+ refetchUserInfo: boolOptional,
442
+ resource: resourceValidationSchema.optional(),
443
+ scopes: scopesValidationSchema.optional()
444
+ });
445
+
446
+ //#endregion
447
+ //#region src/options/get-options.ts
448
+ const getOptions = (options, throwOnError = true) => {
449
+ var _options$defaultAuthP, _options$defaultAuthP2, _options$defaultAuthP3, _options$routes, _options$routes2, _options$routes3, _options$routes4, _options$routes5, _options$session, _options$session2, _options$session3, _options$session4, _options$session5, _options$session6, _options$session7, _options$session8, _options$session9, _options$session10, _options$session11, _options$state, _options$state2, _options$state3, _options$state4, _options$state5, _options$state6;
450
+ const MONOCLOUD_AUTH_CLIENT_ID = process.env.MONOCLOUD_AUTH_CLIENT_ID;
451
+ const MONOCLOUD_AUTH_CLIENT_SECRET = process.env.MONOCLOUD_AUTH_CLIENT_SECRET;
452
+ const MONOCLOUD_AUTH_TENANT_DOMAIN = process.env.MONOCLOUD_AUTH_TENANT_DOMAIN;
453
+ const MONOCLOUD_AUTH_SCOPES = process.env.MONOCLOUD_AUTH_SCOPES;
454
+ const MONOCLOUD_AUTH_COOKIE_SECRET = process.env.MONOCLOUD_AUTH_COOKIE_SECRET;
455
+ const MONOCLOUD_AUTH_APP_URL = process.env.MONOCLOUD_AUTH_APP_URL;
456
+ const MONOCLOUD_AUTH_CALLBACK_URL = process.env.MONOCLOUD_AUTH_CALLBACK_URL;
457
+ const MONOCLOUD_AUTH_BACK_CHANNEL_LOGOUT_URL = process.env.MONOCLOUD_AUTH_BACK_CHANNEL_LOGOUT_URL;
458
+ const MONOCLOUD_AUTH_SIGNIN_URL = process.env.MONOCLOUD_AUTH_SIGNIN_URL;
459
+ const MONOCLOUD_AUTH_SIGNOUT_URL = process.env.MONOCLOUD_AUTH_SIGNOUT_URL;
460
+ const MONOCLOUD_AUTH_USER_INFO_URL = process.env.MONOCLOUD_AUTH_USER_INFO_URL;
461
+ const MONOCLOUD_AUTH_RESOURCE = process.env.MONOCLOUD_AUTH_RESOURCE;
462
+ const MONOCLOUD_AUTH_CLOCK_SKEW = process.env.MONOCLOUD_AUTH_CLOCK_SKEW;
463
+ const MONOCLOUD_AUTH_RESPONSE_TIMEOUT = process.env.MONOCLOUD_AUTH_RESPONSE_TIMEOUT;
464
+ const MONOCLOUD_AUTH_USE_PAR = process.env.MONOCLOUD_AUTH_USE_PAR;
465
+ const MONOCLOUD_AUTH_POST_LOGOUT_REDIRECT_URI = process.env.MONOCLOUD_AUTH_POST_LOGOUT_REDIRECT_URI;
466
+ const MONOCLOUD_AUTH_FEDERATED_SIGNOUT = process.env.MONOCLOUD_AUTH_FEDERATED_SIGNOUT;
467
+ const MONOCLOUD_AUTH_USER_INFO = process.env.MONOCLOUD_AUTH_USER_INFO;
468
+ const MONOCLOUD_AUTH_REFETCH_USER_INFO = process.env.MONOCLOUD_AUTH_REFETCH_USER_INFO;
469
+ const MONOCLOUD_AUTH_SESSION_COOKIE_NAME = process.env.MONOCLOUD_AUTH_SESSION_COOKIE_NAME;
470
+ const MONOCLOUD_AUTH_SESSION_COOKIE_PATH = process.env.MONOCLOUD_AUTH_SESSION_COOKIE_PATH;
471
+ const MONOCLOUD_AUTH_SESSION_COOKIE_DOMAIN = process.env.MONOCLOUD_AUTH_SESSION_COOKIE_DOMAIN;
472
+ const MONOCLOUD_AUTH_SESSION_COOKIE_HTTP_ONLY = process.env.MONOCLOUD_AUTH_SESSION_COOKIE_HTTP_ONLY;
473
+ const MONOCLOUD_AUTH_SESSION_COOKIE_SECURE = process.env.MONOCLOUD_AUTH_SESSION_COOKIE_SECURE;
474
+ const MONOCLOUD_AUTH_SESSION_COOKIE_SAME_SITE = process.env.MONOCLOUD_AUTH_SESSION_COOKIE_SAME_SITE;
475
+ const MONOCLOUD_AUTH_SESSION_COOKIE_PERSISTENT = process.env.MONOCLOUD_AUTH_SESSION_COOKIE_PERSISTENT;
476
+ const MONOCLOUD_AUTH_SESSION_SLIDING = process.env.MONOCLOUD_AUTH_SESSION_SLIDING;
477
+ const MONOCLOUD_AUTH_SESSION_DURATION = process.env.MONOCLOUD_AUTH_SESSION_DURATION;
478
+ const MONOCLOUD_AUTH_SESSION_MAX_DURATION = process.env.MONOCLOUD_AUTH_SESSION_MAX_DURATION;
479
+ const MONOCLOUD_AUTH_STATE_COOKIE_NAME = process.env.MONOCLOUD_AUTH_STATE_COOKIE_NAME;
480
+ const MONOCLOUD_AUTH_STATE_COOKIE_PATH = process.env.MONOCLOUD_AUTH_STATE_COOKIE_PATH;
481
+ const MONOCLOUD_AUTH_STATE_COOKIE_DOMAIN = process.env.MONOCLOUD_AUTH_STATE_COOKIE_DOMAIN;
482
+ const MONOCLOUD_AUTH_STATE_COOKIE_SECURE = process.env.MONOCLOUD_AUTH_STATE_COOKIE_SECURE;
483
+ const MONOCLOUD_AUTH_STATE_COOKIE_SAME_SITE = process.env.MONOCLOUD_AUTH_STATE_COOKIE_SAME_SITE;
484
+ const MONOCLOUD_AUTH_STATE_COOKIE_PERSISTENT = process.env.MONOCLOUD_AUTH_STATE_COOKIE_PERSISTENT;
485
+ const MONOCLOUD_AUTH_ID_TOKEN_SIGNING_ALG = process.env.MONOCLOUD_AUTH_ID_TOKEN_SIGNING_ALG;
486
+ const MONOCLOUD_AUTH_FILTERED_ID_TOKEN_CLAIMS = process.env.MONOCLOUD_AUTH_FILTERED_ID_TOKEN_CLAIMS;
487
+ const MONOCLOUD_AUTH_JWKS_CACHE_DURATION = process.env.MONOCLOUD_AUTH_JWKS_CACHE_DURATION;
488
+ const MONOCLOUD_AUTH_METADATA_CACHE_DURATION = process.env.MONOCLOUD_AUTH_METADATA_CACHE_DURATION;
489
+ const appUrl = (options === null || options === void 0 ? void 0 : options.appUrl) ?? MONOCLOUD_AUTH_APP_URL;
490
+ const opt = {
491
+ clientId: (options === null || options === void 0 ? void 0 : options.clientId) ?? MONOCLOUD_AUTH_CLIENT_ID,
492
+ clientSecret: (options === null || options === void 0 ? void 0 : options.clientSecret) ?? MONOCLOUD_AUTH_CLIENT_SECRET,
493
+ tenantDomain: (options === null || options === void 0 ? void 0 : options.tenantDomain) ?? MONOCLOUD_AUTH_TENANT_DOMAIN,
494
+ defaultAuthParams: {
495
+ ...(options === null || options === void 0 ? void 0 : options.defaultAuthParams) ?? {},
496
+ scopes: (options === null || options === void 0 || (_options$defaultAuthP = options.defaultAuthParams) === null || _options$defaultAuthP === void 0 ? void 0 : _options$defaultAuthP.scopes) ?? MONOCLOUD_AUTH_SCOPES ?? DEFAULT_OPTIONS.defaultAuthParams.scopes,
497
+ responseType: (options === null || options === void 0 || (_options$defaultAuthP2 = options.defaultAuthParams) === null || _options$defaultAuthP2 === void 0 ? void 0 : _options$defaultAuthP2.responseType) ?? DEFAULT_OPTIONS.defaultAuthParams.responseType,
498
+ resource: (options === null || options === void 0 || (_options$defaultAuthP3 = options.defaultAuthParams) === null || _options$defaultAuthP3 === void 0 ? void 0 : _options$defaultAuthP3.resource) ?? MONOCLOUD_AUTH_RESOURCE
499
+ },
500
+ resources: options === null || options === void 0 ? void 0 : options.resources,
501
+ cookieSecret: (options === null || options === void 0 ? void 0 : options.cookieSecret) ?? MONOCLOUD_AUTH_COOKIE_SECRET,
502
+ appUrl: (0, _monocloud_auth_core_internal.removeTrailingSlash)(appUrl),
503
+ routes: {
504
+ callback: (0, _monocloud_auth_core_internal.removeTrailingSlash)((options === null || options === void 0 || (_options$routes = options.routes) === null || _options$routes === void 0 ? void 0 : _options$routes.callback) ?? MONOCLOUD_AUTH_CALLBACK_URL ?? DEFAULT_OPTIONS.routes.callback),
505
+ backChannelLogout: (0, _monocloud_auth_core_internal.removeTrailingSlash)((options === null || options === void 0 || (_options$routes2 = options.routes) === null || _options$routes2 === void 0 ? void 0 : _options$routes2.backChannelLogout) ?? MONOCLOUD_AUTH_BACK_CHANNEL_LOGOUT_URL ?? DEFAULT_OPTIONS.routes.backChannelLogout),
506
+ signIn: (0, _monocloud_auth_core_internal.removeTrailingSlash)((options === null || options === void 0 || (_options$routes3 = options.routes) === null || _options$routes3 === void 0 ? void 0 : _options$routes3.signIn) ?? MONOCLOUD_AUTH_SIGNIN_URL ?? DEFAULT_OPTIONS.routes.signIn),
507
+ signOut: (0, _monocloud_auth_core_internal.removeTrailingSlash)((options === null || options === void 0 || (_options$routes4 = options.routes) === null || _options$routes4 === void 0 ? void 0 : _options$routes4.signOut) ?? MONOCLOUD_AUTH_SIGNOUT_URL ?? DEFAULT_OPTIONS.routes.signOut),
508
+ userInfo: (0, _monocloud_auth_core_internal.removeTrailingSlash)((options === null || options === void 0 || (_options$routes5 = options.routes) === null || _options$routes5 === void 0 ? void 0 : _options$routes5.userInfo) ?? MONOCLOUD_AUTH_USER_INFO_URL ?? DEFAULT_OPTIONS.routes.userInfo)
509
+ },
510
+ clockSkew: (options === null || options === void 0 ? void 0 : options.clockSkew) ?? (0, _monocloud_auth_core_internal.getNumber)(MONOCLOUD_AUTH_CLOCK_SKEW) ?? DEFAULT_OPTIONS.clockSkew,
511
+ responseTimeout: (options === null || options === void 0 ? void 0 : options.responseTimeout) ?? (0, _monocloud_auth_core_internal.getNumber)(MONOCLOUD_AUTH_RESPONSE_TIMEOUT) ?? DEFAULT_OPTIONS.responseTimeout,
512
+ usePar: (options === null || options === void 0 ? void 0 : options.usePar) ?? (0, _monocloud_auth_core_internal.getBoolean)(MONOCLOUD_AUTH_USE_PAR) ?? DEFAULT_OPTIONS.usePar,
513
+ postLogoutRedirectUri: (options === null || options === void 0 ? void 0 : options.postLogoutRedirectUri) ?? MONOCLOUD_AUTH_POST_LOGOUT_REDIRECT_URI,
514
+ federatedSignOut: (options === null || options === void 0 ? void 0 : options.federatedSignOut) ?? (0, _monocloud_auth_core_internal.getBoolean)(MONOCLOUD_AUTH_FEDERATED_SIGNOUT) ?? DEFAULT_OPTIONS.federatedSignOut,
515
+ userInfo: (options === null || options === void 0 ? void 0 : options.userInfo) ?? (0, _monocloud_auth_core_internal.getBoolean)(MONOCLOUD_AUTH_USER_INFO) ?? DEFAULT_OPTIONS.userInfo,
516
+ refetchUserInfo: (options === null || options === void 0 ? void 0 : options.refetchUserInfo) ?? (0, _monocloud_auth_core_internal.getBoolean)(MONOCLOUD_AUTH_REFETCH_USER_INFO) ?? DEFAULT_OPTIONS.refetchUserInfo,
517
+ session: {
518
+ cookie: {
519
+ name: (options === null || options === void 0 || (_options$session = options.session) === null || _options$session === void 0 || (_options$session = _options$session.cookie) === null || _options$session === void 0 ? void 0 : _options$session.name) ?? MONOCLOUD_AUTH_SESSION_COOKIE_NAME ?? DEFAULT_OPTIONS.session.cookie.name,
520
+ path: (options === null || options === void 0 || (_options$session2 = options.session) === null || _options$session2 === void 0 || (_options$session2 = _options$session2.cookie) === null || _options$session2 === void 0 ? void 0 : _options$session2.path) ?? MONOCLOUD_AUTH_SESSION_COOKIE_PATH ?? DEFAULT_OPTIONS.session.cookie.path,
521
+ domain: (options === null || options === void 0 || (_options$session3 = options.session) === null || _options$session3 === void 0 || (_options$session3 = _options$session3.cookie) === null || _options$session3 === void 0 ? void 0 : _options$session3.domain) ?? MONOCLOUD_AUTH_SESSION_COOKIE_DOMAIN,
522
+ httpOnly: (options === null || options === void 0 || (_options$session4 = options.session) === null || _options$session4 === void 0 || (_options$session4 = _options$session4.cookie) === null || _options$session4 === void 0 ? void 0 : _options$session4.httpOnly) ?? (0, _monocloud_auth_core_internal.getBoolean)(MONOCLOUD_AUTH_SESSION_COOKIE_HTTP_ONLY) ?? DEFAULT_OPTIONS.session.cookie.httpOnly,
523
+ secure: (options === null || options === void 0 || (_options$session5 = options.session) === null || _options$session5 === void 0 || (_options$session5 = _options$session5.cookie) === null || _options$session5 === void 0 ? void 0 : _options$session5.secure) ?? (0, _monocloud_auth_core_internal.getBoolean)(MONOCLOUD_AUTH_SESSION_COOKIE_SECURE) ?? (appUrl === null || appUrl === void 0 ? void 0 : appUrl.startsWith("https:")),
524
+ sameSite: (options === null || options === void 0 || (_options$session6 = options.session) === null || _options$session6 === void 0 || (_options$session6 = _options$session6.cookie) === null || _options$session6 === void 0 ? void 0 : _options$session6.sameSite) ?? MONOCLOUD_AUTH_SESSION_COOKIE_SAME_SITE ?? DEFAULT_OPTIONS.session.cookie.sameSite,
525
+ persistent: (options === null || options === void 0 || (_options$session7 = options.session) === null || _options$session7 === void 0 || (_options$session7 = _options$session7.cookie) === null || _options$session7 === void 0 ? void 0 : _options$session7.persistent) ?? (0, _monocloud_auth_core_internal.getBoolean)(MONOCLOUD_AUTH_SESSION_COOKIE_PERSISTENT) ?? DEFAULT_OPTIONS.session.cookie.persistent
526
+ },
527
+ sliding: (options === null || options === void 0 || (_options$session8 = options.session) === null || _options$session8 === void 0 ? void 0 : _options$session8.sliding) ?? (0, _monocloud_auth_core_internal.getBoolean)(MONOCLOUD_AUTH_SESSION_SLIDING) ?? DEFAULT_OPTIONS.session.sliding,
528
+ duration: (options === null || options === void 0 || (_options$session9 = options.session) === null || _options$session9 === void 0 ? void 0 : _options$session9.duration) ?? (0, _monocloud_auth_core_internal.getNumber)(MONOCLOUD_AUTH_SESSION_DURATION) ?? DEFAULT_OPTIONS.session.duration,
529
+ maximumDuration: (options === null || options === void 0 || (_options$session10 = options.session) === null || _options$session10 === void 0 ? void 0 : _options$session10.maximumDuration) ?? (0, _monocloud_auth_core_internal.getNumber)(MONOCLOUD_AUTH_SESSION_MAX_DURATION) ?? DEFAULT_OPTIONS.session.maximumDuration,
530
+ store: options === null || options === void 0 || (_options$session11 = options.session) === null || _options$session11 === void 0 ? void 0 : _options$session11.store
531
+ },
532
+ state: { cookie: {
533
+ name: (options === null || options === void 0 || (_options$state = options.state) === null || _options$state === void 0 || (_options$state = _options$state.cookie) === null || _options$state === void 0 ? void 0 : _options$state.name) ?? MONOCLOUD_AUTH_STATE_COOKIE_NAME ?? DEFAULT_OPTIONS.state.cookie.name,
534
+ path: (options === null || options === void 0 || (_options$state2 = options.state) === null || _options$state2 === void 0 || (_options$state2 = _options$state2.cookie) === null || _options$state2 === void 0 ? void 0 : _options$state2.path) ?? MONOCLOUD_AUTH_STATE_COOKIE_PATH ?? DEFAULT_OPTIONS.state.cookie.path,
535
+ domain: (options === null || options === void 0 || (_options$state3 = options.state) === null || _options$state3 === void 0 || (_options$state3 = _options$state3.cookie) === null || _options$state3 === void 0 ? void 0 : _options$state3.domain) ?? MONOCLOUD_AUTH_STATE_COOKIE_DOMAIN,
536
+ httpOnly: DEFAULT_OPTIONS.state.cookie.httpOnly,
537
+ secure: (options === null || options === void 0 || (_options$state4 = options.state) === null || _options$state4 === void 0 || (_options$state4 = _options$state4.cookie) === null || _options$state4 === void 0 ? void 0 : _options$state4.secure) ?? (0, _monocloud_auth_core_internal.getBoolean)(MONOCLOUD_AUTH_STATE_COOKIE_SECURE) ?? (appUrl === null || appUrl === void 0 ? void 0 : appUrl.startsWith("https:")),
538
+ sameSite: (options === null || options === void 0 || (_options$state5 = options.state) === null || _options$state5 === void 0 || (_options$state5 = _options$state5.cookie) === null || _options$state5 === void 0 ? void 0 : _options$state5.sameSite) ?? MONOCLOUD_AUTH_STATE_COOKIE_SAME_SITE ?? DEFAULT_OPTIONS.state.cookie.sameSite,
539
+ persistent: (options === null || options === void 0 || (_options$state6 = options.state) === null || _options$state6 === void 0 || (_options$state6 = _options$state6.cookie) === null || _options$state6 === void 0 ? void 0 : _options$state6.persistent) ?? (0, _monocloud_auth_core_internal.getBoolean)(MONOCLOUD_AUTH_STATE_COOKIE_PERSISTENT) ?? DEFAULT_OPTIONS.state.cookie.persistent
540
+ } },
541
+ idTokenSigningAlg: (options === null || options === void 0 ? void 0 : options.idTokenSigningAlg) ?? MONOCLOUD_AUTH_ID_TOKEN_SIGNING_ALG ?? DEFAULT_OPTIONS.idTokenSigningAlg,
542
+ filteredIdTokenClaims: (options === null || options === void 0 ? void 0 : options.filteredIdTokenClaims) ?? (MONOCLOUD_AUTH_FILTERED_ID_TOKEN_CLAIMS === null || MONOCLOUD_AUTH_FILTERED_ID_TOKEN_CLAIMS === void 0 ? void 0 : MONOCLOUD_AUTH_FILTERED_ID_TOKEN_CLAIMS.split(" ").map((x) => x.trim()).filter((x) => x.length)) ?? DEFAULT_OPTIONS.filteredIdTokenClaims,
543
+ debugger: (options === null || options === void 0 ? void 0 : options.debugger) ?? DEFAULT_OPTIONS.debugger,
544
+ userAgent: (options === null || options === void 0 ? void 0 : options.userAgent) ?? DEFAULT_OPTIONS.userAgent,
545
+ jwksCacheDuration: (options === null || options === void 0 ? void 0 : options.jwksCacheDuration) ?? (0, _monocloud_auth_core_internal.getNumber)(MONOCLOUD_AUTH_JWKS_CACHE_DURATION),
546
+ metadataCacheDuration: (options === null || options === void 0 ? void 0 : options.metadataCacheDuration) ?? (0, _monocloud_auth_core_internal.getNumber)(MONOCLOUD_AUTH_METADATA_CACHE_DURATION),
547
+ onBackChannelLogout: options === null || options === void 0 ? void 0 : options.onBackChannelLogout,
548
+ onSetApplicationState: options === null || options === void 0 ? void 0 : options.onSetApplicationState,
549
+ onSessionCreating: options === null || options === void 0 ? void 0 : options.onSessionCreating
550
+ };
551
+ const { value, error } = optionsSchema.validate(opt, { abortEarly: false });
552
+ const requiredEnv = {
553
+ tenantDomain: "MONOCLOUD_AUTH_TENANT_DOMAIN",
554
+ clientId: "MONOCLOUD_AUTH_CLIENT_ID",
555
+ clientSecret: "MONOCLOUD_AUTH_CLIENT_SECRET",
556
+ appUrl: "MONOCLOUD_AUTH_APP_URL",
557
+ cookieSecret: "MONOCLOUD_AUTH_COOKIE_SECRET"
558
+ };
559
+ if (error) {
560
+ if (throwOnError) throw new _monocloud_auth_core.MonoCloudValidationError(error.details[0].message);
561
+ console.warn("WARNING: One or more configuration options were not provided for MonoCloudClient.");
562
+ error.details.forEach((detail) => {
563
+ var _detail$context;
564
+ if (((_detail$context = detail.context) === null || _detail$context === void 0 ? void 0 : _detail$context.key) && requiredEnv[detail.context.key]) console.warn(`Missing: ${detail.context.key} - Set ${requiredEnv[detail.context.key]} enviornment variable in your .env file.`);
565
+ });
566
+ }
567
+ return value;
568
+ };
569
+
570
+ //#endregion
571
+ //#region src/monocloud-node-core-client.ts
572
+ var MonoCloudCoreClient = class {
573
+ constructor(partialOptions) {
574
+ this.optionsValidated = false;
575
+ this.options = getOptions(partialOptions, false);
576
+ this.oidcClient = new _monocloud_auth_core.MonoCloudOidcClient(this.options.tenantDomain, this.options.clientId, {
577
+ clientSecret: this.options.clientSecret,
578
+ idTokenSigningAlgorithm: this.options.idTokenSigningAlg
579
+ });
580
+ this.debug = (0, debug.default)(this.options.debugger);
581
+ this.stateService = new MonoCloudStateService(this.options);
582
+ this.sessionService = new MonoCloudSessionService(this.options);
583
+ /* v8 ignore next -- @preserve */
584
+ if (process.env.DEBUG && !this.debug.enabled) debug.default.enable(process.env.DEBUG);
585
+ this.debug("Debug logging enabled.");
586
+ }
587
+ /**
588
+ * Initiates the sign-in flow by redirecting the user to the MonoCloud authorization endpoint.
589
+ *
590
+ * This method handles scope and resource merging, state generation (nonce, state, PKCE),
591
+ * and Constructing the final authorization URL.
592
+ *
593
+ * @param request - MonoCloud request object.
594
+ * @param response - MonoCloud response object.
595
+ * @param signInOptions - Optional configuration to customize the sign-in behavior.
596
+ * @returns A promise that resolves when the callback processing and redirection are complete.
597
+ *
598
+ * @throws {@link MonoCloudValidationError} When validation of parameters or state fails.
599
+ */
600
+ async signIn(request, response, signInOptions) {
601
+ this.debug("Starting sign-in handler");
602
+ try {
603
+ var _this$options$resourc, _this$options$resourc2, _signInOptions$authPa, _signInOptions$authPa2, _signInOptions$authPa3;
604
+ this.validateOptions();
605
+ const { method } = await request.getRawRequest();
606
+ if (method.toLowerCase() !== "get") {
607
+ response.methodNotAllowed();
608
+ return response.done();
609
+ }
610
+ const indicatorResource = (_this$options$resourc = this.options.resources) === null || _this$options$resourc === void 0 ? void 0 : _this$options$resourc.map((x) => x.resource).filter((x) => !!x).reduce((acc, x) => `${acc} ${x}`, "");
611
+ const indicatorScopes = (_this$options$resourc2 = this.options.resources) === null || _this$options$resourc2 === void 0 ? void 0 : _this$options$resourc2.map((x) => x.scopes).filter((x) => !!x).reduce((acc, x) => `${acc} ${x}`, "");
612
+ const mergedScopes = (0, _monocloud_auth_core_utils.mergeArrays)((0, _monocloud_auth_core_internal.parseSpaceSeparated)(signInOptions === null || signInOptions === void 0 || (_signInOptions$authPa = signInOptions.authParams) === null || _signInOptions$authPa === void 0 ? void 0 : _signInOptions$authPa.scopes), (0, _monocloud_auth_core_internal.parseSpaceSeparated)(this.options.defaultAuthParams.scopes), (0, _monocloud_auth_core_internal.parseSpaceSeparated)(indicatorScopes)) ?? ["openid"];
613
+ const mergedResources = (0, _monocloud_auth_core_utils.mergeArrays)((0, _monocloud_auth_core_internal.parseSpaceSeparated)(signInOptions === null || signInOptions === void 0 || (_signInOptions$authPa2 = signInOptions.authParams) === null || _signInOptions$authPa2 === void 0 ? void 0 : _signInOptions$authPa2.resource), (0, _monocloud_auth_core_internal.parseSpaceSeparated)(this.options.defaultAuthParams.resource), (0, _monocloud_auth_core_internal.parseSpaceSeparated)(indicatorResource));
614
+ const opt = {
615
+ ...signInOptions ?? {},
616
+ authParams: {
617
+ ...this.options.defaultAuthParams,
618
+ ...signInOptions === null || signInOptions === void 0 ? void 0 : signInOptions.authParams,
619
+ scopes: mergedScopes.join(" "),
620
+ acrValues: (0, _monocloud_auth_core_utils.mergeArrays)(signInOptions === null || signInOptions === void 0 || (_signInOptions$authPa3 = signInOptions.authParams) === null || _signInOptions$authPa3 === void 0 ? void 0 : _signInOptions$authPa3.acrValues, this.options.defaultAuthParams.acrValues),
621
+ resource: mergedResources === null || mergedResources === void 0 ? void 0 : mergedResources.join(" ")
622
+ }
623
+ };
624
+ let appState = {};
625
+ if (this.options.onSetApplicationState) {
626
+ appState = await this.options.onSetApplicationState(request);
627
+ if (appState === null || appState === void 0 || typeof appState !== "object" || Array.isArray(appState)) throw new _monocloud_auth_core.MonoCloudValidationError("Invalid Application State. Expected state to be an object");
628
+ }
629
+ const retUrl = request.getQuery("return_url") ?? opt.returnUrl;
630
+ if (typeof retUrl === "string" && retUrl && (!(0, _monocloud_auth_core_internal.isAbsoluteUrl)(retUrl) || (0, _monocloud_auth_core_internal.isSameHost)(this.options.appUrl, retUrl))) opt.returnUrl = retUrl;
631
+ const { error } = signInOptionsSchema.validate(opt, { abortEarly: true });
632
+ if (error) throw new _monocloud_auth_core.MonoCloudValidationError(error.details[0].message);
633
+ const state = (0, _monocloud_auth_core_utils.generateState)();
634
+ const nonce = (0, _monocloud_auth_core_utils.generateNonce)();
635
+ const { codeChallenge, codeVerifier } = await (0, _monocloud_auth_core_utils.generatePKCE)();
636
+ const maxAgeQuery = request.getQuery("max_age");
637
+ if (typeof maxAgeQuery === "string" && maxAgeQuery) {
638
+ const parsedMaxAge = parseInt(maxAgeQuery, 10);
639
+ if (!isNaN(parsedMaxAge)) opt.authParams.maxAge = parsedMaxAge;
640
+ }
641
+ const returnUrl = encodeURIComponent(opt.returnUrl ?? this.options.appUrl);
642
+ let params = {
643
+ redirectUri: `${this.options.appUrl}${(0, _monocloud_auth_core_internal.ensureLeadingSlash)(this.options.routes.callback)}`,
644
+ ...opt.authParams,
645
+ nonce,
646
+ state,
647
+ codeChallenge
648
+ };
649
+ const authenticatorHint = request.getQuery("authenticator_hint") ?? opt.authParams.authenticatorHint;
650
+ if (typeof authenticatorHint === "string" && authenticatorHint) params.authenticatorHint = authenticatorHint;
651
+ const reqScope = request.getQuery("scope");
652
+ const scopes = (typeof reqScope === "string" ? reqScope : void 0) ?? opt.authParams.scopes;
653
+ if (scopes) {
654
+ const { error: e } = scopesValidationSchema.validate(scopes, { abortEarly: true });
655
+ if (!e) params.scopes = scopes;
656
+ }
657
+ const reqResource = request.getQuery("resource");
658
+ const resource = (typeof reqResource === "string" ? reqResource : void 0) ?? opt.authParams.resource;
659
+ if (resource) {
660
+ const { error: e } = resourceValidationSchema.validate(resource, { abortEarly: true });
661
+ if (!e) params.resource = resource;
662
+ }
663
+ const display = request.getQuery("display") ?? opt.authParams.display;
664
+ if (typeof display === "string" && display) params.display = display;
665
+ const uiLocales = request.getQuery("ui_locales") ?? opt.authParams.uiLocales;
666
+ if (typeof uiLocales === "string" && uiLocales) params.uiLocales = uiLocales;
667
+ const acrValues = request.getQuery("acr_values") ?? opt.authParams.acrValues;
668
+ if (typeof acrValues === "string" && acrValues) params.acrValues = acrValues.split(" ").map((x) => x.trim()).filter((x) => x !== "");
669
+ const loginHint = request.getQuery("login_hint") ?? opt.authParams.loginHint;
670
+ if (typeof loginHint === "string" && loginHint) params.loginHint = loginHint;
671
+ let prompt;
672
+ if (typeof request.getQuery("prompt") === "string") prompt = request.getQuery("prompt");
673
+ else prompt = opt.register ? "create" : opt.authParams.prompt;
674
+ if (prompt) params.prompt = prompt;
675
+ /* v8 ignore next -- @preserve */
676
+ if (!params.scopes || params.scopes.length < 0) throw new _monocloud_auth_core.MonoCloudValidationError("Scopes are required for signing in");
677
+ const monoCloudState = {
678
+ returnUrl,
679
+ state,
680
+ nonce,
681
+ codeVerifier,
682
+ maxAge: opt.authParams.maxAge,
683
+ appState: JSON.stringify(appState),
684
+ resource: this.options.defaultAuthParams.resource,
685
+ scopes: params.scopes
686
+ };
687
+ if (this.options.usePar) {
688
+ const { request_uri } = await this.oidcClient.pushedAuthorizationRequest(params);
689
+ params = { requestUri: request_uri };
690
+ }
691
+ const authUrl = await this.oidcClient.authorizationUrl(params);
692
+ await this.stateService.setState(response, monoCloudState, params.responseMode === "form_post" ? "none" : void 0);
693
+ response.redirect(authUrl, 302);
694
+ } catch (error) {
695
+ if (typeof (signInOptions === null || signInOptions === void 0 ? void 0 : signInOptions.onError) === "function") return signInOptions.onError(error);
696
+ else this.handleCatchAll(error, response);
697
+ }
698
+ return response.done();
699
+ }
700
+ /**
701
+ * Handles the OpenID callback after the user authenticates with MonoCloud.
702
+ *
703
+ * Processes the authorization code, validates the state and nonce, exchanges the code for tokens,
704
+ * initializes the user session, and performs the final redirect to the application's return URL.
705
+ *
706
+ * @param request - MonoCloud request object.
707
+ * @param response - MonoCloud response object.
708
+ * @param callbackOptions - Optional configuration for the callback handler.
709
+ * @returns A promise that resolves when the callback processing and redirection are complete.
710
+ *
711
+ * @throws {@link MonoCloudValidationError} If the state is mismatched or tokens are invalid.
712
+ */
713
+ async callback(request, response, callbackOptions) {
714
+ this.debug("Starting callback handler");
715
+ try {
716
+ this.validateOptions();
717
+ const { method, url, body } = await request.getRawRequest();
718
+ if (method.toLowerCase() !== "get" && method.toLowerCase() !== "post") {
719
+ response.methodNotAllowed();
720
+ return response.done();
721
+ }
722
+ if (callbackOptions) {
723
+ const { error } = callbackOptionsSchema.validate(callbackOptions, { abortEarly: true });
724
+ if (error) throw new _monocloud_auth_core.MonoCloudValidationError(error.details[0].message);
725
+ }
726
+ const monoCloudState = await this.stateService.getState(request, response);
727
+ if (!monoCloudState) throw new _monocloud_auth_core.MonoCloudValidationError("Invalid Authentication State");
728
+ let fullUrl = url;
729
+ if (!(0, _monocloud_auth_core_internal.isAbsoluteUrl)(url)) fullUrl = `${this.options.appUrl}${(0, _monocloud_auth_core_internal.ensureLeadingSlash)(url)}`;
730
+ const callbackParams = (0, _monocloud_auth_core_utils.parseCallbackParams)(method.toLowerCase() === "post" ? new URLSearchParams(body) : new URL(fullUrl).searchParams);
731
+ if (callbackParams.state !== monoCloudState.state) throw new _monocloud_auth_core.MonoCloudValidationError("Invalid state");
732
+ const redirectUri = (callbackOptions === null || callbackOptions === void 0 ? void 0 : callbackOptions.redirectUri) ?? `${this.options.appUrl}${(0, _monocloud_auth_core_internal.ensureLeadingSlash)(this.options.routes.callback)}`;
733
+ if (!callbackParams.code) throw new _monocloud_auth_core.MonoCloudValidationError("Authorization code not found in callback params");
734
+ const appState = JSON.parse(monoCloudState.appState);
735
+ const session = await this.oidcClient.authenticate(callbackParams.code, redirectUri, monoCloudState.scopes, monoCloudState.resource, {
736
+ codeVerifier: monoCloudState.codeVerifier,
737
+ validateIdToken: true,
738
+ idTokenClockSkew: this.options.clockSkew,
739
+ idTokenNonce: monoCloudState.nonce,
740
+ idTokenMaxAge: monoCloudState.maxAge,
741
+ idTokenClockTolerance: 5,
742
+ fetchUserInfo: (callbackOptions === null || callbackOptions === void 0 ? void 0 : callbackOptions.userInfo) ?? this.options.userInfo,
743
+ filteredIdTokenClaims: this.options.filteredIdTokenClaims,
744
+ onSessionCreating: async (s, i, u) => {
745
+ var _this$options$onSessi, _this$options;
746
+ return await ((_this$options$onSessi = (_this$options = this.options).onSessionCreating) === null || _this$options$onSessi === void 0 ? void 0 : _this$options$onSessi.call(_this$options, s, i, u, appState));
747
+ }
748
+ });
749
+ await this.sessionService.setSession(request, response, session);
750
+ if (!monoCloudState.returnUrl) {
751
+ response.redirect(this.options.appUrl);
752
+ return response.done();
753
+ }
754
+ try {
755
+ const decodedUrl = decodeURIComponent(monoCloudState.returnUrl);
756
+ if (!(0, _monocloud_auth_core_internal.isAbsoluteUrl)(decodedUrl)) {
757
+ response.redirect(`${this.options.appUrl}${(0, _monocloud_auth_core_internal.ensureLeadingSlash)(decodedUrl)}`);
758
+ return response.done();
759
+ }
760
+ if ((0, _monocloud_auth_core_internal.isSameHost)(this.options.appUrl, decodedUrl)) {
761
+ response.redirect(decodedUrl);
762
+ return response.done();
763
+ }
764
+ } catch {}
765
+ /* c8 ignore stop */
766
+ response.redirect(this.options.appUrl);
767
+ } catch (error) {
768
+ if (typeof (callbackOptions === null || callbackOptions === void 0 ? void 0 : callbackOptions.onError) === "function") return callbackOptions.onError(error);
769
+ else this.handleCatchAll(error, response);
770
+ }
771
+ return response.done();
772
+ }
773
+ /**
774
+ * Retrieves user information, optionally refetching fresh data from the UserInfo endpoint.
775
+ *
776
+ * @param request - MonoCloud request object.
777
+ * @param response - MonoCloud response object.
778
+ * @param userinfoOptions - Configuration to control refetching and error handling.
779
+ * @returns A promise that resolves with the user information sent as a JSON response.
780
+ *
781
+ * @remarks
782
+ * If `refresh` is true, the session is updated with fresh claims from the identity provider.
783
+ */
784
+ async userInfo(request, response, userinfoOptions) {
785
+ this.debug("Starting userinfo handler");
786
+ try {
787
+ var _this$options$onSessi2;
788
+ this.validateOptions();
789
+ const { method } = await request.getRawRequest();
790
+ if (method.toLowerCase() !== "get") {
791
+ response.methodNotAllowed();
792
+ return response.done();
793
+ }
794
+ if (userinfoOptions) {
795
+ const { error } = userInfoOptionsSchema.validate(userinfoOptions, { abortEarly: true });
796
+ if (error) throw new _monocloud_auth_core.MonoCloudValidationError(error.details[0].message);
797
+ }
798
+ const refetchUserInfo = (userinfoOptions === null || userinfoOptions === void 0 ? void 0 : userinfoOptions.refresh) ?? this.options.refetchUserInfo;
799
+ const session = await this.sessionService.getSession(request, response, !refetchUserInfo);
800
+ if (!session) {
801
+ response.setNoCache();
802
+ response.noContent();
803
+ return response.done();
804
+ }
805
+ const defaultToken = (0, _monocloud_auth_core_internal.findToken)(session.accessTokens, this.options.defaultAuthParams.resource, session.authorizedScopes);
806
+ if (!refetchUserInfo || !defaultToken) {
807
+ response.sendJson(session.user);
808
+ return response.done();
809
+ }
810
+ const newSession = await this.oidcClient.refetchUserInfo(defaultToken, session, { onSessionCreating: (_this$options$onSessi2 = this.options.onSessionCreating) === null || _this$options$onSessi2 === void 0 ? void 0 : _this$options$onSessi2.bind(this) });
811
+ if (!await this.sessionService.updateSession(request, response, newSession)) {
812
+ response.setNoCache();
813
+ response.noContent();
814
+ return response.done();
815
+ }
816
+ response.sendJson(session.user);
817
+ } catch (error) {
818
+ if (typeof (userinfoOptions === null || userinfoOptions === void 0 ? void 0 : userinfoOptions.onError) === "function") return userinfoOptions.onError(error);
819
+ else this.handleCatchAll(error, response);
820
+ }
821
+ return response.done();
822
+ }
823
+ /**
824
+ * Initiates the sign-out flow, destroying the local session and optionally performing federated sign-out.
825
+ *
826
+ * @param request - MonoCloud request object.
827
+ * @param response - MonoCloud response object.
828
+ * @param signOutOptions - Configuration for post-logout behavior and federated sign-out.
829
+ *
830
+ * @returns A promise that resolves when the sign-out redirection is initiated.
831
+ */
832
+ async signOut(request, response, signOutOptions) {
833
+ this.debug("Starting sign-out handler");
834
+ try {
835
+ this.validateOptions();
836
+ const { method } = await request.getRawRequest();
837
+ if (method.toLowerCase() !== "get") {
838
+ response.methodNotAllowed();
839
+ return response.done();
840
+ }
841
+ if (signOutOptions) {
842
+ const { error } = signOutOptionsSchema.validate(signOutOptions, { abortEarly: true });
843
+ if (error) throw new _monocloud_auth_core.MonoCloudValidationError(error.details[0].message);
844
+ }
845
+ let returnUrl = this.options.postLogoutRedirectUri ?? (signOutOptions === null || signOutOptions === void 0 ? void 0 : signOutOptions.postLogoutRedirectUri) ?? this.options.appUrl;
846
+ const retUrl = request.getQuery("post_logout_url");
847
+ if (typeof retUrl === "string" && retUrl) {
848
+ const { error } = signOutOptionsSchema.validate({ postLogoutRedirectUri: retUrl });
849
+ if (!error) returnUrl = retUrl;
850
+ }
851
+ if (!(0, _monocloud_auth_core_internal.isAbsoluteUrl)(returnUrl)) returnUrl = `${this.options.appUrl}${(0, _monocloud_auth_core_internal.ensureLeadingSlash)(returnUrl)}`;
852
+ const session = await this.sessionService.getSession(request, response, false);
853
+ if (!session) {
854
+ response.redirect(returnUrl);
855
+ return response.done();
856
+ }
857
+ await this.sessionService.removeSession(request, response);
858
+ if (!((signOutOptions === null || signOutOptions === void 0 ? void 0 : signOutOptions.federatedSignOut) ?? this.options.federatedSignOut)) {
859
+ response.redirect(returnUrl);
860
+ return response.done();
861
+ }
862
+ const url = await this.oidcClient.endSessionUrl({
863
+ idToken: session.idToken,
864
+ postLogoutRedirectUri: returnUrl,
865
+ state: signOutOptions === null || signOutOptions === void 0 ? void 0 : signOutOptions.state
866
+ });
867
+ response.redirect(url);
868
+ } catch (error) {
869
+ if (typeof (signOutOptions === null || signOutOptions === void 0 ? void 0 : signOutOptions.onError) === "function") return signOutOptions.onError(error);
870
+ else this.handleCatchAll(error, response);
871
+ }
872
+ return response.done();
873
+ }
874
+ /**
875
+ * Handles Back-Channel Logout notifications from the identity provider.
876
+ *
877
+ * Validates the Logout Token and triggers the `onBackChannelLogout` callback defined in options.
878
+ *
879
+ * @param request - MonoCloud request object.
880
+ * @param response - MonoCloud response object.
881
+ *
882
+ * @returns A promise that resolves when the logout notification has been processed.
883
+ *
884
+ * @throws {@link MonoCloudValidationError} If the logout token is missing or invalid.
885
+ */
886
+ async backChannelLogout(request, response) {
887
+ this.debug("Starting back-channel logout handler");
888
+ try {
889
+ this.validateOptions();
890
+ response.setNoCache();
891
+ if (!this.options.onBackChannelLogout) {
892
+ response.notFound();
893
+ return response.done();
894
+ }
895
+ const { method, body } = await request.getRawRequest();
896
+ if (method.toLowerCase() !== "post") {
897
+ response.methodNotAllowed();
898
+ return response.done();
899
+ }
900
+ const logoutToken = new URLSearchParams(body).get("logout_token");
901
+ if (!logoutToken) throw new _monocloud_auth_core.MonoCloudValidationError("Missing Logout Token");
902
+ const metadata = await this.oidcClient.getMetadata();
903
+ const { sid, sub } = await this.verifyLogoutToken(logoutToken, metadata);
904
+ await this.options.onBackChannelLogout(sub, sid);
905
+ response.noContent();
906
+ } catch (error) {
907
+ this.handleCatchAll(error, response);
908
+ }
909
+ return response.done();
910
+ }
911
+ /**
912
+ * Checks if the current request has an active and authenticated session.
913
+ *
914
+ * @param request - MonoCloud cookie request object.
915
+ * @param response - MonoCloud cookie response object.
916
+ *
917
+ * @returns `true` if a valid session with user data exists, `false` otherwise.
918
+ *
919
+ */
920
+ async isAuthenticated(request, response) {
921
+ const session = await this.sessionService.getSession(request, response);
922
+ return !!(session === null || session === void 0 ? void 0 : session.user);
923
+ }
924
+ /**
925
+ * Checks if the current session user belongs to the specified groups.
926
+ *
927
+ * @param request - MonoCloud cookie request object.
928
+ * @param response - MonoCloud cookie response object.
929
+ * @param groups - List of group names or IDs to check.
930
+ * @param groupsClaim - Optional claim name that holds groups. Defaults to "groups".
931
+ * @param matchAll - If `true`, requires membership in all groups; otherwise any one group is sufficient.
932
+ *
933
+ * @returns `true` if the user satisfies the group condition, `false` otherwise.
934
+ */
935
+ async isUserInGroup(request, response, groups, groupsClaim, matchAll) {
936
+ const session = await this.sessionService.getSession(request, response);
937
+ if (!(session === null || session === void 0 ? void 0 : session.user)) return false;
938
+ return (0, _monocloud_auth_core_utils.isUserInGroup)(session.user, groups, groupsClaim, matchAll);
939
+ }
940
+ /**
941
+ * Retrieves the current user's session data.
942
+ *
943
+ * @param request - MonoCloud cookie request object.
944
+ * @param response - MonoCloud cookie response object.
945
+ *
946
+ * @returns Session or `undefined`.
947
+ */
948
+ getSession(request, response) {
949
+ return this.sessionService.getSession(request, response);
950
+ }
951
+ /**
952
+ * Updates the current user's session with new data.
953
+ *
954
+ * @param request - MonoCloud cookie request object.
955
+ * @param response - MonoCloud cookie response object.
956
+ * @param session - The updated session object to persist.
957
+ */
958
+ async updateSession(request, response, session) {
959
+ await this.sessionService.updateSession(request, response, session);
960
+ }
961
+ /**
962
+ * Returns a copy of the current client configuration options.
963
+ *
964
+ * @returns A copy of the initialized configuration.
965
+ */
966
+ getOptions() {
967
+ return { ...this.options };
968
+ }
969
+ /**
970
+ * Destroys the local user session.
971
+ *
972
+ * @param request - MonoCloud cookie request object.
973
+ * @param response - MonoCloud cookie response object.
974
+ *
975
+ * @remarks
976
+ * This does not perform federated sign-out. For identity provider sign-out, use `signOut` handler.
977
+ */
978
+ destroySession(request, response) {
979
+ return this.sessionService.removeSession(request, response);
980
+ }
981
+ /**
982
+ * Retrieves active tokens (Access, ID, Refresh), performing a refresh if they are expired or missing.
983
+ *
984
+ * @param request - MonoCloud cookie request object.
985
+ * @param response - MonoCloud cookie response object.
986
+ * @param options - Configuration for token retrieval (force refresh, specific scopes/resources).
987
+ *
988
+ * @returns Fetched tokens
989
+ *
990
+ * @throws {@link MonoCloudValidationError} If the session does not exist or tokens cannot be found/refreshed.
991
+ */
992
+ async getTokens(request, response, options) {
993
+ if (options) {
994
+ const { error } = getTokensOptionsSchema.validate(options, { abortEarly: true });
995
+ if (error) throw new _monocloud_auth_core.MonoCloudValidationError(error.details[0].message);
996
+ }
997
+ const session = await this.sessionService.getSession(request, response);
998
+ if (!session) throw new _monocloud_auth_core.MonoCloudValidationError("Session does not exist");
999
+ let scopes = options === null || options === void 0 ? void 0 : options.scopes;
1000
+ const resource = (options === null || options === void 0 ? void 0 : options.resource) ?? this.options.defaultAuthParams.resource;
1001
+ if ((0, _monocloud_auth_core_internal.isPresent)(options === null || options === void 0 ? void 0 : options.resource)) {
1002
+ if (!(0, _monocloud_auth_core_internal.isPresent)(scopes)) {
1003
+ var _this$options$resourc3;
1004
+ if (!((_this$options$resourc3 = this.options.resources) === null || _this$options$resourc3 === void 0 ? void 0 : _this$options$resourc3.find((x) => (0, _monocloud_auth_core_internal.setsEqual)((0, _monocloud_auth_core_internal.parseSpaceSeparatedSet)(x.resource), (0, _monocloud_auth_core_internal.parseSpaceSeparatedSet)(resource)) && !x.scopes))) {
1005
+ var _this$options$resourc4;
1006
+ scopes = (_this$options$resourc4 = this.options.resources) === null || _this$options$resourc4 === void 0 || (_this$options$resourc4 = _this$options$resourc4.find((x) => (0, _monocloud_auth_core_internal.setsEqual)((0, _monocloud_auth_core_internal.parseSpaceSeparatedSet)(x.resource), (0, _monocloud_auth_core_internal.parseSpaceSeparatedSet)(resource)))) === null || _this$options$resourc4 === void 0 ? void 0 : _this$options$resourc4.scopes;
1007
+ }
1008
+ }
1009
+ }
1010
+ const findTokenScopes = !(0, _monocloud_auth_core_internal.isPresent)(options === null || options === void 0 ? void 0 : options.resource) && !(0, _monocloud_auth_core_internal.isPresent)(scopes) ? session.authorizedScopes : scopes;
1011
+ let token = (0, _monocloud_auth_core_internal.findToken)(session.accessTokens, resource, findTokenScopes);
1012
+ const tokenExpired = !!token && token.accessTokenExpiration - 30 < (0, _monocloud_auth_core_internal.now)();
1013
+ let { idToken } = session;
1014
+ let { refreshToken } = session;
1015
+ if ((options === null || options === void 0 ? void 0 : options.forceRefresh) || !token || tokenExpired) {
1016
+ var _this$options$onSessi3;
1017
+ const updatedSession = await this.oidcClient.refreshSession(session, {
1018
+ fetchUserInfo: (options === null || options === void 0 ? void 0 : options.refetchUserInfo) ?? this.options.refetchUserInfo,
1019
+ validateIdToken: true,
1020
+ idTokenClockSkew: this.options.clockSkew,
1021
+ idTokenClockTolerance: 5,
1022
+ refreshGrantOptions: {
1023
+ resource,
1024
+ scopes
1025
+ },
1026
+ filteredIdTokenClaims: this.options.filteredIdTokenClaims,
1027
+ onSessionCreating: (_this$options$onSessi3 = this.options.onSessionCreating) === null || _this$options$onSessi3 === void 0 ? void 0 : _this$options$onSessi3.bind(this)
1028
+ });
1029
+ await this.sessionService.updateSession(request, response, updatedSession);
1030
+ token = (0, _monocloud_auth_core_internal.findToken)(updatedSession === null || updatedSession === void 0 ? void 0 : updatedSession.accessTokens, resource, findTokenScopes);
1031
+ idToken = updatedSession.idToken;
1032
+ refreshToken = updatedSession.refreshToken;
1033
+ }
1034
+ /* v8 ignore next -- @preserve */
1035
+ if (!token) throw new _monocloud_auth_core.MonoCloudValidationError("Access token not found");
1036
+ return {
1037
+ ...token,
1038
+ idToken,
1039
+ refreshToken,
1040
+ isExpired: token.accessTokenExpiration - 30 < (0, _monocloud_auth_core_internal.now)()
1041
+ };
1042
+ }
1043
+ async verifyLogoutToken(token, metadata) {
1044
+ const { payload } = await (0, jose.jwtVerify)(token, (0, jose.createRemoteJWKSet)(new URL(metadata.jwks_uri)), {
1045
+ issuer: metadata.issuer,
1046
+ audience: this.options.clientId,
1047
+ algorithms: [this.options.idTokenSigningAlg],
1048
+ requiredClaims: ["iat"]
1049
+ });
1050
+ if (!payload.sid && !payload.sub || payload.nonce || !payload.events || typeof payload.events !== "object") throw new _monocloud_auth_core.MonoCloudValidationError("Invalid logout token");
1051
+ const event = payload.events["http://schemas.openid.net/event/backchannel-logout"];
1052
+ if (!event || typeof event !== "object") throw new _monocloud_auth_core.MonoCloudValidationError("Invalid logout token");
1053
+ return payload;
1054
+ }
1055
+ handleCatchAll(error, res) {
1056
+ console.error(error);
1057
+ res.internalServerError();
1058
+ }
1059
+ validateOptions() {
1060
+ if (!this.optionsValidated) {
1061
+ this.optionsValidated = true;
1062
+ getOptions(this.options);
1063
+ }
1064
+ }
1065
+ };
1066
+
1067
+ //#endregion
1068
+ Object.defineProperty(exports, 'MonoCloudAuthBaseError', {
1069
+ enumerable: true,
1070
+ get: function () {
1071
+ return _monocloud_auth_core.MonoCloudAuthBaseError;
1072
+ }
1073
+ });
1074
+ exports.MonoCloudCoreClient = MonoCloudCoreClient;
1075
+ Object.defineProperty(exports, 'MonoCloudHttpError', {
1076
+ enumerable: true,
1077
+ get: function () {
1078
+ return _monocloud_auth_core.MonoCloudHttpError;
1079
+ }
1080
+ });
1081
+ Object.defineProperty(exports, 'MonoCloudOPError', {
1082
+ enumerable: true,
1083
+ get: function () {
1084
+ return _monocloud_auth_core.MonoCloudOPError;
1085
+ }
1086
+ });
1087
+ Object.defineProperty(exports, 'MonoCloudOidcClient', {
1088
+ enumerable: true,
1089
+ get: function () {
1090
+ return _monocloud_auth_core.MonoCloudOidcClient;
1091
+ }
1092
+ });
1093
+ Object.defineProperty(exports, 'MonoCloudTokenError', {
1094
+ enumerable: true,
1095
+ get: function () {
1096
+ return _monocloud_auth_core.MonoCloudTokenError;
1097
+ }
1098
+ });
1099
+ Object.defineProperty(exports, 'MonoCloudValidationError', {
1100
+ enumerable: true,
1101
+ get: function () {
1102
+ return _monocloud_auth_core.MonoCloudValidationError;
1103
+ }
1104
+ });
1105
+ //# sourceMappingURL=index.cjs.map