@dudousxd/nestjs-catalog-dashboard 0.1.0

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.
@@ -0,0 +1,1108 @@
1
+ const __importMetaUrl = require('url').pathToFileURL(__filename).href;
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/server/index.ts
23
+ var index_exports = {};
24
+ __export(index_exports, {
25
+ CatalogApiSessionGuard: () => CatalogApiSessionGuard,
26
+ CatalogAuthController: () => CatalogAuthController,
27
+ CatalogDashboardModule: () => CatalogDashboardModule,
28
+ CatalogUiController: () => CatalogUiController,
29
+ CatalogUiSessionGuard: () => CatalogUiSessionGuard,
30
+ DASHBOARD_API_PATH: () => DASHBOARD_API_PATH,
31
+ DASHBOARD_AUTH: () => DASHBOARD_AUTH,
32
+ DASHBOARD_BASE_PATH: () => DASHBOARD_BASE_PATH,
33
+ catalogDashboardMountPaths: () => catalogDashboardMountPaths
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/server/auth/dashboard-auth-config.ts
38
+ var DASHBOARD_AUTH = Symbol("DASHBOARD_AUTH");
39
+ var DEFAULT_TTL_MS = 8 * 60 * 60 * 1e3;
40
+ var DURATION_UNITS = {
41
+ s: 1e3,
42
+ m: 60 * 1e3,
43
+ h: 60 * 60 * 1e3,
44
+ d: 24 * 60 * 60 * 1e3
45
+ };
46
+
47
+ // src/server/catalog-auth.controller.ts
48
+ var import_common4 = require("@nestjs/common");
49
+
50
+ // src/server/auth/login-page.ts
51
+ function page(content, title = "Catalog") {
52
+ return `<!doctype html>
53
+ <html lang="en">
54
+ <head>
55
+ <meta charset="utf-8" />
56
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
57
+ <meta name="robots" content="noindex, nofollow" />
58
+ <title>${title}</title>
59
+ <style>
60
+ :root { color-scheme: dark; }
61
+ * { box-sizing: border-box; }
62
+ body {
63
+ margin: 0;
64
+ min-height: 100vh;
65
+ display: flex;
66
+ align-items: center;
67
+ justify-content: center;
68
+ background: #09090b;
69
+ color: #e4e4e7;
70
+ font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
71
+ padding: 16px;
72
+ }
73
+ .card {
74
+ width: 100%;
75
+ max-width: 384px;
76
+ border: 1px solid #27272a;
77
+ background: #18181b;
78
+ border-radius: 8px;
79
+ padding: 32px;
80
+ box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.5);
81
+ }
82
+ .brand {
83
+ margin: 0 0 24px;
84
+ text-align: center;
85
+ font-size: 18px;
86
+ font-weight: 600;
87
+ color: #34d399;
88
+ }
89
+ h1 {
90
+ margin: 0 0 12px;
91
+ font-size: 16px;
92
+ font-weight: 600;
93
+ color: #f4f4f5;
94
+ }
95
+ p { margin: 0 0 16px; color: #a1a1aa; }
96
+ form { display: flex; flex-direction: column; gap: 16px; }
97
+ label { display: flex; flex-direction: column; gap: 6px; }
98
+ .field-label {
99
+ font-size: 11px;
100
+ text-transform: uppercase;
101
+ letter-spacing: 0.05em;
102
+ color: #71717a;
103
+ }
104
+ input {
105
+ border-radius: 4px;
106
+ border: 1px solid #3f3f46;
107
+ background: #09090b;
108
+ color: #f4f4f5;
109
+ padding: 8px 12px;
110
+ font: inherit;
111
+ outline: none;
112
+ }
113
+ input:focus { border-color: rgb(52 211 153 / 0.6); }
114
+ #error {
115
+ display: none;
116
+ margin: 0;
117
+ font-size: 12px;
118
+ color: #fb7185;
119
+ }
120
+ button, .button {
121
+ margin-top: 8px;
122
+ border-radius: 4px;
123
+ border: 1px solid rgb(52 211 153 / 0.4);
124
+ background: rgb(52 211 153 / 0.1);
125
+ color: #6ee7b7;
126
+ padding: 8px 12px;
127
+ font: inherit;
128
+ font-size: 12px;
129
+ font-weight: 500;
130
+ text-transform: uppercase;
131
+ letter-spacing: 0.05em;
132
+ cursor: pointer;
133
+ display: inline-block;
134
+ text-align: center;
135
+ text-decoration: none;
136
+ box-sizing: border-box;
137
+ }
138
+ button:hover:not(:disabled), .button:hover { background: rgb(52 211 153 / 0.2); }
139
+ button:disabled { opacity: 0.6; cursor: default; }
140
+ </style>
141
+ </head>
142
+ <body>
143
+ <div class="card">
144
+ ${content}
145
+ </div>
146
+ </body>
147
+ </html>`;
148
+ }
149
+ __name(page, "page");
150
+ function renderLoginPage(basePath) {
151
+ const loginAction = `${basePath}/login`;
152
+ const defaultReturnTo = basePath;
153
+ return page(`<p class="brand">Catalog</p>
154
+ <form id="login-form" autocomplete="on">
155
+ <label>
156
+ <span class="field-label">Username</span>
157
+ <input id="username" name="username" type="text" autocomplete="username" required autofocus />
158
+ </label>
159
+ <label>
160
+ <span class="field-label">Password</span>
161
+ <input id="password" name="password" type="password" autocomplete="current-password" />
162
+ </label>
163
+ <p id="error" role="alert">Invalid username or password.</p>
164
+ <button id="submit" type="submit">Sign in</button>
165
+ </form>
166
+ <script>
167
+ (function () {
168
+ var LOGIN_ACTION = ${JSON.stringify(loginAction)};
169
+ var DEFAULT_RETURN_TO = ${JSON.stringify(defaultReturnTo)};
170
+ var params = new URLSearchParams(window.location.search);
171
+ var errorBox = document.getElementById('error');
172
+ if (params.get('error')) errorBox.style.display = 'block';
173
+
174
+ function sameOriginReturnTo(value) {
175
+ if (typeof value !== 'string' || value === '') return DEFAULT_RETURN_TO;
176
+ if (value.charAt(0) !== '/' || value.charAt(1) === '/' || value.indexOf('://') !== -1) {
177
+ return DEFAULT_RETURN_TO;
178
+ }
179
+ return value;
180
+ }
181
+
182
+ var form = document.getElementById('login-form');
183
+ var submitButton = document.getElementById('submit');
184
+ form.addEventListener('submit', function (event) {
185
+ event.preventDefault();
186
+ submitButton.disabled = true;
187
+ errorBox.style.display = 'none';
188
+ var returnTo = sameOriginReturnTo(params.get('returnTo'));
189
+ fetch(LOGIN_ACTION, {
190
+ method: 'POST',
191
+ headers: { 'content-type': 'application/json' },
192
+ credentials: 'same-origin',
193
+ body: JSON.stringify({
194
+ username: document.getElementById('username').value,
195
+ password: document.getElementById('password').value,
196
+ returnTo: returnTo,
197
+ }),
198
+ })
199
+ .then(function (response) {
200
+ if (!response.ok) throw new Error('unauthorized');
201
+ return response.json();
202
+ })
203
+ .then(function (data) {
204
+ window.location.href = data.redirectTo || DEFAULT_RETURN_TO;
205
+ })
206
+ .catch(function () {
207
+ errorBox.style.display = 'block';
208
+ submitButton.disabled = false;
209
+ });
210
+ });
211
+ })();
212
+ </script>`, "Sign in \u2014 Catalog");
213
+ }
214
+ __name(renderLoginPage, "renderLoginPage");
215
+ function renderSessionRequiredPage(basePath) {
216
+ return page(`<h1>Open this console from your application</h1>
217
+ <p>Your session is minted by the host app. Use its console launcher to sign in, then reload.</p>
218
+ <a class="button" href="${basePath}">Retry</a>`);
219
+ }
220
+ __name(renderSessionRequiredPage, "renderSessionRequiredPage");
221
+
222
+ // src/server/auth/request.ts
223
+ function isRecord(value) {
224
+ return typeof value === "object" && value !== null;
225
+ }
226
+ __name(isRecord, "isRecord");
227
+ function readHeaders(request) {
228
+ if (!isRecord(request)) return {};
229
+ const headers = request.headers;
230
+ return isRecord(headers) ? headers : {};
231
+ }
232
+ __name(readHeaders, "readHeaders");
233
+ function headerToString(value) {
234
+ if (typeof value === "string") return value;
235
+ if (Array.isArray(value) && value.every((part) => typeof part === "string")) {
236
+ return value.join(",");
237
+ }
238
+ return void 0;
239
+ }
240
+ __name(headerToString, "headerToString");
241
+ function readCookieHeader(request) {
242
+ return headerToString(readHeaders(request).cookie);
243
+ }
244
+ __name(readCookieHeader, "readCookieHeader");
245
+ function isHttpsRequest(request) {
246
+ if (isRecord(request) && request.protocol === "https") return true;
247
+ const forwarded = headerToString(readHeaders(request)["x-forwarded-proto"]);
248
+ if (forwarded === void 0) return false;
249
+ return forwarded.split(",").map((proto) => proto.trim().toLowerCase()).includes("https");
250
+ }
251
+ __name(isHttpsRequest, "isHttpsRequest");
252
+ function originalRequestUrl(request) {
253
+ if (!isRecord(request)) return "/";
254
+ if (typeof request.originalUrl === "string" && request.originalUrl !== "") {
255
+ return request.originalUrl;
256
+ }
257
+ if (typeof request.url === "string" && request.url !== "") return request.url;
258
+ return "/";
259
+ }
260
+ __name(originalRequestUrl, "originalRequestUrl");
261
+ function sanitizeReturnTo(candidate, fallback) {
262
+ if (typeof candidate !== "string") return fallback;
263
+ if (!candidate.startsWith("/")) return fallback;
264
+ if (candidate.startsWith("//")) return fallback;
265
+ if (candidate.includes("://")) return fallback;
266
+ return candidate;
267
+ }
268
+ __name(sanitizeReturnTo, "sanitizeReturnTo");
269
+
270
+ // src/server/auth/response.ts
271
+ function isRecord2(value) {
272
+ return typeof value === "object" && value !== null;
273
+ }
274
+ __name(isRecord2, "isRecord");
275
+ function isRawCookieResponse(value) {
276
+ return isRecord2(value) && typeof value.getHeader === "function" && typeof value.setHeader === "function";
277
+ }
278
+ __name(isRawCookieResponse, "isRawCookieResponse");
279
+ function resolveCookieResponse(response) {
280
+ if (isRawCookieResponse(response)) return response;
281
+ if (isRecord2(response) && isRawCookieResponse(response.raw)) return response.raw;
282
+ return null;
283
+ }
284
+ __name(resolveCookieResponse, "resolveCookieResponse");
285
+ function existingSetCookies(response) {
286
+ const current = response.getHeader("set-cookie");
287
+ if (Array.isArray(current)) return current;
288
+ if (typeof current === "string") return [
289
+ current
290
+ ];
291
+ return [];
292
+ }
293
+ __name(existingSetCookies, "existingSetCookies");
294
+ function appendSetCookie(response, cookie) {
295
+ const raw = resolveCookieResponse(response);
296
+ if (!raw) return;
297
+ raw.setHeader("set-cookie", [
298
+ ...existingSetCookies(raw),
299
+ cookie
300
+ ]);
301
+ }
302
+ __name(appendSetCookie, "appendSetCookie");
303
+ function isRawRedirectResponse(value) {
304
+ return isRecord2(value) && typeof value.getHeader === "function" && typeof value.setHeader === "function" && typeof value.end === "function";
305
+ }
306
+ __name(isRawRedirectResponse, "isRawRedirectResponse");
307
+ function resolveRedirectResponse(response) {
308
+ if (isRawRedirectResponse(response)) return response;
309
+ if (isRecord2(response) && isRawRedirectResponse(response.raw)) return response.raw;
310
+ return null;
311
+ }
312
+ __name(resolveRedirectResponse, "resolveRedirectResponse");
313
+ function redirectRaw(response, location, status = 302) {
314
+ const raw = resolveRedirectResponse(response);
315
+ if (!raw) return;
316
+ raw.statusCode = status;
317
+ raw.setHeader("location", location);
318
+ raw.end();
319
+ }
320
+ __name(redirectRaw, "redirectRaw");
321
+ function responseAlreadyWritten(response) {
322
+ const raw = resolveRedirectResponse(response);
323
+ return raw?.headersSent === true;
324
+ }
325
+ __name(responseAlreadyWritten, "responseAlreadyWritten");
326
+ function writeHtmlRaw(response, html, status = 200) {
327
+ const raw = resolveRedirectResponse(response);
328
+ if (!raw) return;
329
+ raw.statusCode = status;
330
+ raw.setHeader("content-type", "text/html; charset=utf-8");
331
+ raw.setHeader("cache-control", "no-store, must-revalidate");
332
+ raw.end(html);
333
+ }
334
+ __name(writeHtmlRaw, "writeHtmlRaw");
335
+
336
+ // src/server/auth/cookie-header.ts
337
+ function parseCookieHeader(header) {
338
+ const cookies = {};
339
+ if (typeof header !== "string" || header === "") return cookies;
340
+ for (const segment of header.split(";")) {
341
+ const eq = segment.indexOf("=");
342
+ if (eq <= 0) continue;
343
+ const name = segment.slice(0, eq).trim();
344
+ if (name === "") continue;
345
+ let rawValue = segment.slice(eq + 1).trim();
346
+ if (rawValue.length >= 2 && rawValue.startsWith('"') && rawValue.endsWith('"')) {
347
+ rawValue = rawValue.slice(1, -1);
348
+ }
349
+ if (name in cookies) continue;
350
+ try {
351
+ cookies[name] = decodeURIComponent(rawValue);
352
+ } catch {
353
+ cookies[name] = rawValue;
354
+ }
355
+ }
356
+ return cookies;
357
+ }
358
+ __name(parseCookieHeader, "parseCookieHeader");
359
+ function serializeSetCookie(name, value, options) {
360
+ const parts = [
361
+ `${name}=${options.clear ? "" : encodeURIComponent(value)}`
362
+ ];
363
+ parts.push(`Path=${options.path}`);
364
+ parts.push("HttpOnly");
365
+ parts.push("SameSite=Lax");
366
+ if (options.secure) parts.push("Secure");
367
+ if (options.clear) {
368
+ parts.push("Max-Age=0");
369
+ parts.push("Expires=Thu, 01 Jan 1970 00:00:00 GMT");
370
+ } else {
371
+ parts.push(`Max-Age=${options.maxAgeSeconds}`);
372
+ }
373
+ return parts.join("; ");
374
+ }
375
+ __name(serializeSetCookie, "serializeSetCookie");
376
+
377
+ // src/server/auth/session-cookie.ts
378
+ var import_node_crypto = require("crypto");
379
+ var EXP_GRACE_MS = 3e4;
380
+ function base64urlEncode(value) {
381
+ return Buffer.from(value, "utf8").toString("base64url");
382
+ }
383
+ __name(base64urlEncode, "base64urlEncode");
384
+ function base64urlDecode(value) {
385
+ return Buffer.from(value, "base64url").toString("utf8");
386
+ }
387
+ __name(base64urlDecode, "base64urlDecode");
388
+ function hmac(secret, payload) {
389
+ return (0, import_node_crypto.createHmac)("sha256", secret).update(payload).digest("base64url");
390
+ }
391
+ __name(hmac, "hmac");
392
+ function signSessionCookie(user, options) {
393
+ const issuedAt = options.now ?? Date.now();
394
+ const session = {
395
+ sub: user.id,
396
+ ...user.name !== void 0 ? {
397
+ name: user.name
398
+ } : {},
399
+ roles: user.roles ?? [],
400
+ iat: issuedAt,
401
+ exp: issuedAt + options.ttlMs
402
+ };
403
+ const encodedPayload = base64urlEncode(JSON.stringify(session));
404
+ const signature = hmac(options.secret, encodedPayload);
405
+ return `${encodedPayload}.${signature}`;
406
+ }
407
+ __name(signSessionCookie, "signSessionCookie");
408
+ function isSessionPayload(value) {
409
+ if (typeof value !== "object" || value === null) return false;
410
+ const record = {
411
+ ...value
412
+ };
413
+ if (typeof record.sub !== "string") return false;
414
+ if (record.name !== void 0 && typeof record.name !== "string") return false;
415
+ if (!Array.isArray(record.roles)) return false;
416
+ if (!record.roles.every((role) => typeof role === "string")) return false;
417
+ if (typeof record.iat !== "number" || !Number.isFinite(record.iat)) return false;
418
+ if (typeof record.exp !== "number" || !Number.isFinite(record.exp)) return false;
419
+ return true;
420
+ }
421
+ __name(isSessionPayload, "isSessionPayload");
422
+ function verifySessionCookie(value, options) {
423
+ try {
424
+ const dot = value.indexOf(".");
425
+ if (dot <= 0 || dot === value.length - 1) return null;
426
+ const encodedPayload = value.slice(0, dot);
427
+ const providedSignature = value.slice(dot + 1);
428
+ const expectedSignature = hmac(options.secret, encodedPayload);
429
+ const provided = Buffer.from(providedSignature, "base64url");
430
+ const expected = Buffer.from(expectedSignature, "base64url");
431
+ if (provided.length !== expected.length) return null;
432
+ if (!(0, import_node_crypto.timingSafeEqual)(provided, expected)) return null;
433
+ const decoded = JSON.parse(base64urlDecode(encodedPayload));
434
+ if (!isSessionPayload(decoded)) return null;
435
+ const now = options.now ?? Date.now();
436
+ if (now > decoded.exp + EXP_GRACE_MS) return null;
437
+ const session = {
438
+ sub: decoded.sub,
439
+ ...decoded.name !== void 0 ? {
440
+ name: decoded.name
441
+ } : {},
442
+ roles: decoded.roles,
443
+ iat: decoded.iat,
444
+ exp: decoded.exp
445
+ };
446
+ return session;
447
+ } catch {
448
+ return null;
449
+ }
450
+ }
451
+ __name(verifySessionCookie, "verifySessionCookie");
452
+
453
+ // src/server/auth/session-cookie-io.ts
454
+ var SESSION_COOKIE_NAME = "catalog_dashboard_session";
455
+ var COOKIE_PATH = "/";
456
+ function issueSessionCookie(user, context) {
457
+ const value = signSessionCookie(user, {
458
+ secret: context.auth.secret,
459
+ ttlMs: context.auth.ttlMs,
460
+ ...context.now !== void 0 ? {
461
+ now: context.now
462
+ } : {}
463
+ });
464
+ const cookie = serializeSetCookie(SESSION_COOKIE_NAME, value, {
465
+ path: COOKIE_PATH,
466
+ maxAgeSeconds: Math.floor(context.auth.ttlMs / 1e3),
467
+ secure: isHttpsRequest(context.request)
468
+ });
469
+ appendSetCookie(context.response, cookie);
470
+ }
471
+ __name(issueSessionCookie, "issueSessionCookie");
472
+ function clearSessionCookie(context) {
473
+ const cookie = serializeSetCookie(SESSION_COOKIE_NAME, "", {
474
+ path: COOKIE_PATH,
475
+ maxAgeSeconds: 0,
476
+ secure: isHttpsRequest(context.request),
477
+ clear: true
478
+ });
479
+ appendSetCookie(context.response, cookie);
480
+ }
481
+ __name(clearSessionCookie, "clearSessionCookie");
482
+ function readSessionFromRequest(auth, request) {
483
+ const cookieValue = parseCookieHeader(readCookieHeader(request))[SESSION_COOKIE_NAME];
484
+ if (cookieValue === void 0) return null;
485
+ return verifySessionCookie(cookieValue, {
486
+ secret: auth.secret
487
+ });
488
+ }
489
+ __name(readSessionFromRequest, "readSessionFromRequest");
490
+ var inFlightRevalidations = /* @__PURE__ */ new Map();
491
+ function revalidateOnce(auth, user) {
492
+ const revalidate = auth.revalidate;
493
+ if (!revalidate) return Promise.resolve(true);
494
+ const key = `${auth.secret}:${user.id}`;
495
+ const inFlight = inFlightRevalidations.get(key);
496
+ if (inFlight) return inFlight;
497
+ const call = Promise.resolve().then(() => revalidate(user)).catch(() => false).finally(() => {
498
+ inFlightRevalidations.delete(key);
499
+ });
500
+ inFlightRevalidations.set(key, call);
501
+ return call;
502
+ }
503
+ __name(revalidateOnce, "revalidateOnce");
504
+ async function maybeRenewSession(auth, session, request, response, now = Date.now()) {
505
+ if (now - session.iat <= auth.ttlMs / 2) return true;
506
+ const user = {
507
+ id: session.sub,
508
+ ...session.name !== void 0 ? {
509
+ name: session.name
510
+ } : {},
511
+ roles: session.roles
512
+ };
513
+ const allowed = await revalidateOnce(auth, user);
514
+ if (!allowed) {
515
+ clearSessionCookie({
516
+ request,
517
+ response
518
+ });
519
+ return false;
520
+ }
521
+ issueSessionCookie(user, {
522
+ auth,
523
+ request,
524
+ response,
525
+ now
526
+ });
527
+ return true;
528
+ }
529
+ __name(maybeRenewSession, "maybeRenewSession");
530
+
531
+ // src/server/catalog-ui.controller.ts
532
+ var import_node_fs = require("fs");
533
+ var import_node_path = require("path");
534
+ var import_node_url = require("url");
535
+ var import_common3 = require("@nestjs/common");
536
+
537
+ // src/server/auth/login-redirect.exception.ts
538
+ var import_common = require("@nestjs/common");
539
+ function _ts_decorate(decorators, target, key, desc) {
540
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
541
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
542
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
543
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
544
+ }
545
+ __name(_ts_decorate, "_ts_decorate");
546
+ var DashboardLoginRedirectException = class extends import_common.HttpException {
547
+ static {
548
+ __name(this, "DashboardLoginRedirectException");
549
+ }
550
+ location;
551
+ constructor(location) {
552
+ super({
553
+ location
554
+ }, import_common.HttpStatus.FOUND), this.location = location;
555
+ }
556
+ };
557
+ var DashboardLoginRedirectFilter = class {
558
+ static {
559
+ __name(this, "DashboardLoginRedirectFilter");
560
+ }
561
+ catch(exception, host) {
562
+ const response = host.switchToHttp().getResponse();
563
+ redirectRaw(response, exception.location);
564
+ }
565
+ };
566
+ DashboardLoginRedirectFilter = _ts_decorate([
567
+ (0, import_common.Catch)(DashboardLoginRedirectException)
568
+ ], DashboardLoginRedirectFilter);
569
+
570
+ // src/server/auth/session-required.exception.ts
571
+ var import_common2 = require("@nestjs/common");
572
+ function _ts_decorate2(decorators, target, key, desc) {
573
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
574
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
575
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
576
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
577
+ }
578
+ __name(_ts_decorate2, "_ts_decorate");
579
+ function _ts_metadata(k, v) {
580
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
581
+ }
582
+ __name(_ts_metadata, "_ts_metadata");
583
+ function _ts_param(paramIndex, decorator) {
584
+ return function(target, key) {
585
+ decorator(target, key, paramIndex);
586
+ };
587
+ }
588
+ __name(_ts_param, "_ts_param");
589
+ var DashboardSessionRequiredException = class extends import_common2.HttpException {
590
+ static {
591
+ __name(this, "DashboardSessionRequiredException");
592
+ }
593
+ basePath;
594
+ constructor(basePath) {
595
+ super({
596
+ basePath
597
+ }, import_common2.HttpStatus.UNAUTHORIZED), this.basePath = basePath;
598
+ }
599
+ };
600
+ var DashboardSessionRequiredFilter = class _DashboardSessionRequiredFilter {
601
+ static {
602
+ __name(this, "DashboardSessionRequiredFilter");
603
+ }
604
+ auth;
605
+ logger = new import_common2.Logger(_DashboardSessionRequiredFilter.name);
606
+ warned = false;
607
+ constructor(auth = null) {
608
+ this.auth = auth;
609
+ }
610
+ async catch(exception, host) {
611
+ const http = host.switchToHttp();
612
+ const response = http.getResponse();
613
+ const hook = this.auth?.unauthenticatedPage;
614
+ if (hook) {
615
+ try {
616
+ await hook({
617
+ request: http.getRequest(),
618
+ response,
619
+ basePath: exception.basePath
620
+ });
621
+ if (responseAlreadyWritten(response)) return;
622
+ this.warnOnce("dashboardAuth.unauthenticatedPage returned without writing a response; falling back to the built-in page. The hook must write AND end the response it is given.");
623
+ } catch (error) {
624
+ this.warnOnce(`dashboardAuth.unauthenticatedPage threw; falling back to the built-in page. ${String(error)}`);
625
+ if (responseAlreadyWritten(response)) return;
626
+ }
627
+ }
628
+ writeHtmlRaw(response, renderSessionRequiredPage(exception.basePath), import_common2.HttpStatus.UNAUTHORIZED);
629
+ }
630
+ /** Once per process, not once per request: a broken hook fires on every denied navigation. */
631
+ warnOnce(message) {
632
+ if (this.warned) return;
633
+ this.warned = true;
634
+ this.logger.warn(message);
635
+ }
636
+ };
637
+ DashboardSessionRequiredFilter = _ts_decorate2([
638
+ (0, import_common2.Catch)(DashboardSessionRequiredException),
639
+ _ts_param(0, (0, import_common2.Optional)()),
640
+ _ts_param(0, (0, import_common2.Inject)(DASHBOARD_AUTH)),
641
+ _ts_metadata("design:type", Function),
642
+ _ts_metadata("design:paramtypes", [
643
+ Object
644
+ ])
645
+ ], DashboardSessionRequiredFilter);
646
+
647
+ // src/server/catalog-ui.controller.ts
648
+ function _ts_decorate3(decorators, target, key, desc) {
649
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
650
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
651
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
652
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
653
+ }
654
+ __name(_ts_decorate3, "_ts_decorate");
655
+ function _ts_metadata2(k, v) {
656
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
657
+ }
658
+ __name(_ts_metadata2, "_ts_metadata");
659
+ function _ts_param2(paramIndex, decorator) {
660
+ return function(target, key) {
661
+ decorator(target, key, paramIndex);
662
+ };
663
+ }
664
+ __name(_ts_param2, "_ts_param");
665
+ var DASHBOARD_BASE_PATH = Symbol("DASHBOARD_BASE_PATH");
666
+ var DASHBOARD_API_PATH = Symbol("DASHBOARD_API_PATH");
667
+ var BUILD_BASE = "/catalog";
668
+ function spaDir() {
669
+ return (0, import_node_url.fileURLToPath)(new URL("../spa", __importMetaUrl));
670
+ }
671
+ __name(spaDir, "spaDir");
672
+ var CONTENT_TYPES = {
673
+ ".js": "text/javascript; charset=utf-8",
674
+ ".css": "text/css; charset=utf-8",
675
+ ".map": "application/json; charset=utf-8",
676
+ ".svg": "image/svg+xml",
677
+ ".json": "application/json; charset=utf-8",
678
+ ".woff2": "font/woff2",
679
+ ".ico": "image/x-icon"
680
+ };
681
+ var CatalogUiController = class {
682
+ static {
683
+ __name(this, "CatalogUiController");
684
+ }
685
+ basePath;
686
+ apiBasePath;
687
+ dir = spaDir();
688
+ constructor(basePath, apiBasePath) {
689
+ this.basePath = basePath;
690
+ this.apiBasePath = apiBasePath;
691
+ }
692
+ // index.html references hash-named bundles, so it MUST NOT be cached (stale bundle = the
693
+ // classic "stuck loading after a deploy"). The hashed assets below are immutable.
694
+ index() {
695
+ const indexPath = (0, import_node_path.join)(this.dir, "index.html");
696
+ if (!(0, import_node_fs.existsSync)(indexPath)) {
697
+ throw new import_common3.NotFoundException("Dashboard is not built. Run the package build.");
698
+ }
699
+ const html = (0, import_node_fs.readFileSync)(indexPath, "utf8").replaceAll(`="${BUILD_BASE}/`, `="${this.basePath}/`);
700
+ const inject = `<script>window.__DURABLE_BASE__='${this.basePath}';window.__DURABLE_API__='${this.apiBasePath}';</script>`;
701
+ return html.includes("</head>") ? html.replace("</head>", `${inject}</head>`) : inject + html;
702
+ }
703
+ asset(file) {
704
+ const safe = (0, import_node_path.basename)(file);
705
+ if (safe !== file) throw new import_common3.NotFoundException();
706
+ const root = (0, import_node_path.resolve)(this.dir, "assets");
707
+ const assetPath = (0, import_node_path.resolve)(root, safe);
708
+ if (!assetPath.startsWith(root + import_node_path.sep) || !(0, import_node_fs.existsSync)(assetPath)) {
709
+ throw new import_common3.NotFoundException();
710
+ }
711
+ const type = CONTENT_TYPES[(0, import_node_path.extname)(safe)] ?? "application/octet-stream";
712
+ return new import_common3.StreamableFile((0, import_node_fs.readFileSync)(assetPath), {
713
+ type
714
+ });
715
+ }
716
+ };
717
+ _ts_decorate3([
718
+ (0, import_common3.Get)(),
719
+ (0, import_common3.Header)("Content-Type", "text/html; charset=utf-8"),
720
+ (0, import_common3.Header)("Cache-Control", "no-store, must-revalidate"),
721
+ _ts_metadata2("design:type", Function),
722
+ _ts_metadata2("design:paramtypes", []),
723
+ _ts_metadata2("design:returntype", String)
724
+ ], CatalogUiController.prototype, "index", null);
725
+ _ts_decorate3([
726
+ (0, import_common3.Get)("assets/:file"),
727
+ (0, import_common3.Header)("Cache-Control", "public, max-age=31536000, immutable"),
728
+ _ts_param2(0, (0, import_common3.Param)("file")),
729
+ _ts_metadata2("design:type", Function),
730
+ _ts_metadata2("design:paramtypes", [
731
+ String
732
+ ]),
733
+ _ts_metadata2("design:returntype", typeof import_common3.StreamableFile === "undefined" ? Object : import_common3.StreamableFile)
734
+ ], CatalogUiController.prototype, "asset", null);
735
+ CatalogUiController = _ts_decorate3([
736
+ (0, import_common3.UseFilters)(DashboardLoginRedirectFilter, DashboardSessionRequiredFilter),
737
+ (0, import_common3.Controller)(),
738
+ _ts_param2(0, (0, import_common3.Inject)(DASHBOARD_BASE_PATH)),
739
+ _ts_param2(1, (0, import_common3.Inject)(DASHBOARD_API_PATH)),
740
+ _ts_metadata2("design:type", Function),
741
+ _ts_metadata2("design:paramtypes", [
742
+ String,
743
+ String
744
+ ])
745
+ ], CatalogUiController);
746
+
747
+ // src/server/catalog-auth.controller.ts
748
+ function _ts_decorate4(decorators, target, key, desc) {
749
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
750
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
751
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
752
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
753
+ }
754
+ __name(_ts_decorate4, "_ts_decorate");
755
+ function _ts_metadata3(k, v) {
756
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
757
+ }
758
+ __name(_ts_metadata3, "_ts_metadata");
759
+ function _ts_param3(paramIndex, decorator) {
760
+ return function(target, key) {
761
+ decorator(target, key, paramIndex);
762
+ };
763
+ }
764
+ __name(_ts_param3, "_ts_param");
765
+ function isString(value) {
766
+ return typeof value === "string";
767
+ }
768
+ __name(isString, "isString");
769
+ var CatalogAuthController = class _CatalogAuthController {
770
+ static {
771
+ __name(this, "CatalogAuthController");
772
+ }
773
+ auth;
774
+ basePath;
775
+ logger = new import_common4.Logger(_CatalogAuthController.name);
776
+ /** Warn once per hook kind so a throwing hook doesn't spam logs on every failed attempt. */
777
+ warnedHooks = /* @__PURE__ */ new Set();
778
+ constructor(auth, basePath) {
779
+ this.auth = auth;
780
+ this.basePath = basePath;
781
+ }
782
+ // The login page reads `returnTo`/`error` from `location.search` client-side (see
783
+ // `login-page.ts`), so this response never varies per request and needs no templating beyond
784
+ // the developer-controlled `basePath`.
785
+ loginPage() {
786
+ const auth = this.requireAuth();
787
+ if (!auth.modes.includes("login")) throw new import_common4.NotFoundException();
788
+ return renderLoginPage(this.basePath);
789
+ }
790
+ // Called by the login page's own fetch (JSON, not a classic form POST — see `login-page.ts` for
791
+ // why: it keeps the login page working with no host-configured body parser beyond the
792
+ // JSON one Nest wires in by default on both Express and Fastify). Uniform `401` on any failure
793
+ // (unknown user, wrong password, throwing hook) — no user-enumeration.
794
+ async login(body, request, response) {
795
+ const auth = this.requireAuth();
796
+ if (!auth.modes.includes("login")) throw new import_common4.NotFoundException();
797
+ if (!isString(body?.username) || !isString(body?.password)) {
798
+ throw new import_common4.BadRequestException("Body must include string `username` and `password`.");
799
+ }
800
+ const { username, password } = body;
801
+ const user = await this.runHook("login", () => auth.login?.(username, password) ?? null);
802
+ if (!user) throw new import_common4.UnauthorizedException({
803
+ message: "Invalid username or password."
804
+ });
805
+ issueSessionCookie(user, {
806
+ auth,
807
+ request,
808
+ response
809
+ });
810
+ return {
811
+ redirectTo: sanitizeReturnTo(body.returnTo, this.basePath)
812
+ };
813
+ }
814
+ // Mode A: the host frontend (carrying its own auth) POSTs here; the host hook validates the raw
815
+ // request and returns the session user, or `null` to deny. This is the SSO path — the host's own
816
+ // guard decides, and no credential ever reaches this library.
817
+ async session(request, response) {
818
+ const auth = this.requireAuth();
819
+ if (!auth.modes.includes("session")) throw new import_common4.NotFoundException();
820
+ const user = await this.runHook("session", () => auth.session?.(request) ?? null);
821
+ if (!user) throw new import_common4.UnauthorizedException();
822
+ issueSessionCookie(user, {
823
+ auth,
824
+ request,
825
+ response
826
+ });
827
+ }
828
+ // Plain `GET` (not `POST`): logging out only ever destroys the CALLER's own session, so it's
829
+ // safe/idempotent from the caller's perspective — a simple `<a href>` (no JS, no CSRF token)
830
+ // works. Non-passthrough `@Res()`: this handler owns the response outright (clears the cookie,
831
+ // then redirects), so Nest must not also try to send a return value afterwards.
832
+ logout(request, response) {
833
+ clearSessionCookie({
834
+ request,
835
+ response
836
+ });
837
+ redirectRaw(response, this.auth?.modes.includes("login") ? `${this.basePath}/login` : this.basePath);
838
+ }
839
+ requireAuth() {
840
+ if (!this.auth) throw new import_common4.NotFoundException();
841
+ return this.auth;
842
+ }
843
+ /**
844
+ * Run a host hook (`login` or `session`) defensively: a throw is treated as a denial (uniform
845
+ * failure) and warn-logged once PER KIND, so a buggy hook never 500s the endpoint into a
846
+ * stack-trace leak nor floods the logs on repeated bad attempts.
847
+ */
848
+ async runHook(kind, run) {
849
+ try {
850
+ return await run() ?? null;
851
+ } catch (error) {
852
+ if (!this.warnedHooks.has(kind)) {
853
+ this.warnedHooks.add(kind);
854
+ this.logger.warn(`dashboardAuth ${kind} hook threw; treating as denial. ${error instanceof Error ? error.message : String(error)}`);
855
+ }
856
+ return null;
857
+ }
858
+ }
859
+ };
860
+ _ts_decorate4([
861
+ (0, import_common4.Get)("login"),
862
+ (0, import_common4.Header)("Content-Type", "text/html; charset=utf-8"),
863
+ (0, import_common4.Header)("Cache-Control", "no-store, must-revalidate"),
864
+ _ts_metadata3("design:type", Function),
865
+ _ts_metadata3("design:paramtypes", []),
866
+ _ts_metadata3("design:returntype", String)
867
+ ], CatalogAuthController.prototype, "loginPage", null);
868
+ _ts_decorate4([
869
+ (0, import_common4.Post)("login"),
870
+ (0, import_common4.HttpCode)(200),
871
+ _ts_param3(0, (0, import_common4.Body)()),
872
+ _ts_param3(1, (0, import_common4.Req)()),
873
+ _ts_param3(2, (0, import_common4.Res)({
874
+ passthrough: true
875
+ })),
876
+ _ts_metadata3("design:type", Function),
877
+ _ts_metadata3("design:paramtypes", [
878
+ typeof LoginBody === "undefined" ? Object : LoginBody,
879
+ Object,
880
+ Object
881
+ ]),
882
+ _ts_metadata3("design:returntype", Promise)
883
+ ], CatalogAuthController.prototype, "login", null);
884
+ _ts_decorate4([
885
+ (0, import_common4.Post)("session"),
886
+ (0, import_common4.HttpCode)(204),
887
+ _ts_param3(0, (0, import_common4.Req)()),
888
+ _ts_param3(1, (0, import_common4.Res)({
889
+ passthrough: true
890
+ })),
891
+ _ts_metadata3("design:type", Function),
892
+ _ts_metadata3("design:paramtypes", [
893
+ Object,
894
+ Object
895
+ ]),
896
+ _ts_metadata3("design:returntype", Promise)
897
+ ], CatalogAuthController.prototype, "session", null);
898
+ _ts_decorate4([
899
+ (0, import_common4.Get)("logout"),
900
+ _ts_param3(0, (0, import_common4.Req)()),
901
+ _ts_param3(1, (0, import_common4.Res)()),
902
+ _ts_metadata3("design:type", Function),
903
+ _ts_metadata3("design:paramtypes", [
904
+ Object,
905
+ Object
906
+ ]),
907
+ _ts_metadata3("design:returntype", void 0)
908
+ ], CatalogAuthController.prototype, "logout", null);
909
+ CatalogAuthController = _ts_decorate4([
910
+ (0, import_common4.Controller)(),
911
+ _ts_param3(0, (0, import_common4.Optional)()),
912
+ _ts_param3(0, (0, import_common4.Inject)(DASHBOARD_AUTH)),
913
+ _ts_param3(1, (0, import_common4.Inject)(DASHBOARD_BASE_PATH)),
914
+ _ts_metadata3("design:type", Function),
915
+ _ts_metadata3("design:paramtypes", [
916
+ Object,
917
+ String
918
+ ])
919
+ ], CatalogAuthController);
920
+
921
+ // src/server/catalog-dashboard.module.ts
922
+ var import_common5 = require("@nestjs/common");
923
+ function _ts_decorate5(decorators, target, key, desc) {
924
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
925
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
926
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
927
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
928
+ }
929
+ __name(_ts_decorate5, "_ts_decorate");
930
+ var CatalogDashboardModule = class _CatalogDashboardModule {
931
+ static {
932
+ __name(this, "CatalogDashboardModule");
933
+ }
934
+ static forRoot(options = {}) {
935
+ const path = normalise(options.path ?? "/catalog");
936
+ const apiPath = normalise(options.apiPath ?? "/api/catalog-service");
937
+ const providers = [
938
+ {
939
+ provide: DASHBOARD_BASE_PATH,
940
+ useValue: path
941
+ },
942
+ {
943
+ provide: DASHBOARD_API_PATH,
944
+ useValue: apiPath
945
+ },
946
+ {
947
+ provide: DASHBOARD_AUTH,
948
+ useValue: options.auth ?? null
949
+ }
950
+ ];
951
+ return {
952
+ module: _CatalogDashboardModule,
953
+ controllers: [
954
+ CatalogUiController,
955
+ CatalogAuthController
956
+ ],
957
+ providers,
958
+ exports: providers
959
+ };
960
+ }
961
+ };
962
+ CatalogDashboardModule = _ts_decorate5([
963
+ (0, import_common5.Module)({})
964
+ ], CatalogDashboardModule);
965
+ function catalogDashboardMountPaths(options = {}) {
966
+ const base = normalise(options.path ?? "/catalog").replace(/^\//, "");
967
+ return [
968
+ {
969
+ path: base,
970
+ method: 7
971
+ },
972
+ {
973
+ path: `${base}/{*path}`,
974
+ method: 7
975
+ }
976
+ ];
977
+ }
978
+ __name(catalogDashboardMountPaths, "catalogDashboardMountPaths");
979
+ function normalise(path) {
980
+ const withLeading = path.startsWith("/") ? path : `/${path}`;
981
+ return withLeading.length > 1 ? withLeading.replace(/\/+$/, "") : withLeading;
982
+ }
983
+ __name(normalise, "normalise");
984
+
985
+ // src/server/catalog-session.guard.ts
986
+ var import_common6 = require("@nestjs/common");
987
+ function _ts_decorate6(decorators, target, key, desc) {
988
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
989
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
990
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
991
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
992
+ }
993
+ __name(_ts_decorate6, "_ts_decorate");
994
+ function _ts_metadata4(k, v) {
995
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
996
+ }
997
+ __name(_ts_metadata4, "_ts_metadata");
998
+ function _ts_param4(paramIndex, decorator) {
999
+ return function(target, key) {
1000
+ decorator(target, key, paramIndex);
1001
+ };
1002
+ }
1003
+ __name(_ts_param4, "_ts_param");
1004
+ var CatalogUiSessionGuard = class {
1005
+ static {
1006
+ __name(this, "CatalogUiSessionGuard");
1007
+ }
1008
+ auth;
1009
+ basePath;
1010
+ constructor(auth, basePath) {
1011
+ this.auth = auth;
1012
+ this.basePath = basePath;
1013
+ }
1014
+ async canActivate(context) {
1015
+ if (!this.auth) return true;
1016
+ const auth = this.auth;
1017
+ const http = context.switchToHttp();
1018
+ const request = http.getRequest();
1019
+ const session = readSessionFromRequest(auth, request);
1020
+ if (!session) {
1021
+ this.denyUnauthenticated(auth, request);
1022
+ }
1023
+ if (!await maybeRenewSession(auth, session, request, http.getResponse())) {
1024
+ this.denyUnauthenticated(auth, request);
1025
+ }
1026
+ return true;
1027
+ }
1028
+ /**
1029
+ * A revoked session (the host's `revalidate` hook says no) is denied exactly like an absent
1030
+ * one — by design, there is nothing left to distinguish "never had a session" from "had one,
1031
+ * then lost it" once the cookie is cleared, so both get the same Mode-aware treatment.
1032
+ *
1033
+ * Takes `auth` explicitly rather than reading `this.auth`: `canActivate`'s `!this.auth` early
1034
+ * return narrows the field within that method only — TS doesn't carry it across a method call
1035
+ * — so callers pass the already-narrowed value instead of this method re-deriving (or
1036
+ * asserting away) the nullability.
1037
+ */
1038
+ denyUnauthenticated(auth, request) {
1039
+ if (!auth.modes.includes("login")) throw new DashboardSessionRequiredException(this.basePath);
1040
+ const returnTo = encodeURIComponent(originalRequestUrl(request));
1041
+ throw new DashboardLoginRedirectException(`${this.basePath}/login?returnTo=${returnTo}`);
1042
+ }
1043
+ };
1044
+ CatalogUiSessionGuard = _ts_decorate6([
1045
+ (0, import_common6.Injectable)(),
1046
+ _ts_param4(0, (0, import_common6.Inject)(DASHBOARD_AUTH)),
1047
+ _ts_param4(1, (0, import_common6.Inject)(DASHBOARD_BASE_PATH)),
1048
+ _ts_metadata4("design:type", Function),
1049
+ _ts_metadata4("design:paramtypes", [
1050
+ Object,
1051
+ String
1052
+ ])
1053
+ ], CatalogUiSessionGuard);
1054
+ var CatalogApiSessionGuard = class {
1055
+ static {
1056
+ __name(this, "CatalogApiSessionGuard");
1057
+ }
1058
+ auth;
1059
+ constructor(auth) {
1060
+ this.auth = auth;
1061
+ }
1062
+ async canActivate(context) {
1063
+ if (!this.auth) return true;
1064
+ const auth = this.auth;
1065
+ const http = context.switchToHttp();
1066
+ const request = http.getRequest();
1067
+ const session = readSessionFromRequest(auth, request);
1068
+ if (!session) throw this.unauthorized(auth);
1069
+ if (!await maybeRenewSession(auth, session, request, http.getResponse())) {
1070
+ throw this.unauthorized(auth);
1071
+ }
1072
+ return true;
1073
+ }
1074
+ /**
1075
+ * A bare 401 body carrying `{ auth: { modes } }` — mirrors `@dudousxd/nestjs-telescope`'s
1076
+ * dashboardAuth 401. The API is fetched (never navigated), so this is the ONLY way the console
1077
+ * SPA (`catalog-client.ts`) learns which auth surface to send the operator to on a mid-session
1078
+ * 401; `CatalogUiSessionGuard`'s redirect/session-required exceptions above don't reach it.
1079
+ */
1080
+ unauthorized(auth) {
1081
+ return new import_common6.UnauthorizedException({
1082
+ auth: {
1083
+ modes: auth.modes
1084
+ }
1085
+ });
1086
+ }
1087
+ };
1088
+ CatalogApiSessionGuard = _ts_decorate6([
1089
+ (0, import_common6.Injectable)(),
1090
+ _ts_param4(0, (0, import_common6.Inject)(DASHBOARD_AUTH)),
1091
+ _ts_metadata4("design:type", Function),
1092
+ _ts_metadata4("design:paramtypes", [
1093
+ Object
1094
+ ])
1095
+ ], CatalogApiSessionGuard);
1096
+ // Annotate the CommonJS export names for ESM import in node:
1097
+ 0 && (module.exports = {
1098
+ CatalogApiSessionGuard,
1099
+ CatalogAuthController,
1100
+ CatalogDashboardModule,
1101
+ CatalogUiController,
1102
+ CatalogUiSessionGuard,
1103
+ DASHBOARD_API_PATH,
1104
+ DASHBOARD_AUTH,
1105
+ DASHBOARD_BASE_PATH,
1106
+ catalogDashboardMountPaths
1107
+ });
1108
+ //# sourceMappingURL=index.cjs.map