@dudousxd/nestjs-durable-dashboard 0.51.0 → 0.52.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.
- package/dist/server/index.cjs +279 -41
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +112 -11
- package/dist/server/index.d.ts +112 -11
- package/dist/server/index.js +270 -39
- package/dist/server/index.js.map +1 -1
- package/package.json +2 -2
package/dist/server/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/server/dashboard.service.ts
|
|
5
|
-
import { RunGateway, STATE_STORE_CANONICAL, WorkflowEngine, collectMetrics } from "@dudousxd/nestjs-durable-core";
|
|
5
|
+
import { RunGateway, STATE_STORE_CANONICAL, TERMINAL_RUN_STATUSES, WorkflowEngine, collectMetrics, parseWebhookToken } from "@dudousxd/nestjs-durable-core";
|
|
6
6
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
7
7
|
import { Observable } from "rxjs";
|
|
8
8
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -211,11 +211,30 @@ var DashboardService = class {
|
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
213
|
* Deliver a `ctx.webhook()` callback: turn an inbound POST (token + body) into the signal the
|
|
214
|
-
*
|
|
215
|
-
*
|
|
214
|
+
* run is (or will be) parked on. A callback that arrives BEFORE the run reaches `wait()` (the url
|
|
215
|
+
* was handed out and the run is still busy or sleeping) is buffered, and `wait()` consumes it, so
|
|
216
|
+
* the result is the run's current status. Returns `null` — mapped to 404 by the controller — for a
|
|
217
|
+
* token that is not a webhook token, whose run doesn't exist or is terminal, or whose wait already
|
|
218
|
+
* resolved (a duplicate): nothing is buffered for those, so a public endpoint can't leave junk
|
|
219
|
+
* rows behind or signal non-webhook tokens. Control-plane-only.
|
|
216
220
|
*/
|
|
217
221
|
async deliverWebhook(token, body) {
|
|
218
|
-
|
|
222
|
+
const { store, engine } = this.controlPlane();
|
|
223
|
+
const parsed = parseWebhookToken(token);
|
|
224
|
+
if (!parsed) return null;
|
|
225
|
+
const run = await store.getRun(parsed.runId);
|
|
226
|
+
if (!run || TERMINAL_RUN_STATUSES.includes(run.status)) return null;
|
|
227
|
+
const resolved = await store.getCheckpoint(parsed.runId, parsed.seq);
|
|
228
|
+
if (resolved?.status === "completed") return null;
|
|
229
|
+
const delivered = await engine.signal(token, body);
|
|
230
|
+
if (delivered) return delivered;
|
|
231
|
+
const now = await store.getCheckpoint(parsed.runId, parsed.seq);
|
|
232
|
+
if (now?.status === "completed" && await store.takeBufferedSignal(token)) return null;
|
|
233
|
+
const fresh = await store.getRun(parsed.runId);
|
|
234
|
+
return {
|
|
235
|
+
runId: run.id,
|
|
236
|
+
status: fresh?.status ?? run.status
|
|
237
|
+
};
|
|
219
238
|
}
|
|
220
239
|
/** Side-effect-free read of a value a run published via `ctx.setEvent` (a live query). Control-plane-only. */
|
|
221
240
|
async getEvent(runId, key) {
|
|
@@ -1277,7 +1296,7 @@ var DurableApiController = class {
|
|
|
1277
1296
|
*/
|
|
1278
1297
|
async webhook(token, body) {
|
|
1279
1298
|
const result = await this.dashboard.deliverWebhook(token, body);
|
|
1280
|
-
if (!result) throw new NotFoundException(`no run is waiting
|
|
1299
|
+
if (!result) throw new NotFoundException(`no live run is waiting for webhook ${token}`);
|
|
1281
1300
|
return result;
|
|
1282
1301
|
}
|
|
1283
1302
|
/** Live query: the latest value a run published for `key` via `ctx.setEvent` (no side effect). */
|
|
@@ -2450,6 +2469,186 @@ DurableAuthController = _ts_decorate9([
|
|
|
2450
2469
|
])
|
|
2451
2470
|
], DurableAuthController);
|
|
2452
2471
|
|
|
2472
|
+
// src/server/durable-dashboard-gate.guard.ts
|
|
2473
|
+
import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
2474
|
+
import { ForbiddenException, Inject as Inject5, Injectable as Injectable4, Logger as Logger3, UnauthorizedException as UnauthorizedException2 } from "@nestjs/common";
|
|
2475
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
2476
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2477
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2478
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2479
|
+
} else {
|
|
2480
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2481
|
+
if (d = decorators[i]) {
|
|
2482
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2487
|
+
}
|
|
2488
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
2489
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
2490
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2491
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2495
|
+
function _ts_param6(paramIndex, decorator) {
|
|
2496
|
+
return function(target, key) {
|
|
2497
|
+
decorator(target, key, paramIndex);
|
|
2498
|
+
};
|
|
2499
|
+
}
|
|
2500
|
+
__name(_ts_param6, "_ts_param");
|
|
2501
|
+
var DURABLE_DASHBOARD_TOKEN_ENV = "DURABLE_DASHBOARD_TOKEN";
|
|
2502
|
+
var DASHBOARD_GATE = Symbol("DASHBOARD_GATE");
|
|
2503
|
+
var LOG_CONTEXT = "DurableDashboard";
|
|
2504
|
+
var HOW_TO_CONFIGURE = [
|
|
2505
|
+
"Configure one of: `guards: [YourAuthGuard]`, `dashboardAuth: { secret, session | login }`",
|
|
2506
|
+
"(or `useDashboardAuth` in forRootAsync), a bearer token via the `token` option or the",
|
|
2507
|
+
`${DURABLE_DASHBOARD_TOKEN_ENV} env var, or \`allowUnauthenticated: true\` when the console is`,
|
|
2508
|
+
"already protected outside this module (a global guard, a reverse proxy, a private network)."
|
|
2509
|
+
].join(" ");
|
|
2510
|
+
function isProduction() {
|
|
2511
|
+
return (process.env.NODE_ENV ?? "").trim().toLowerCase() === "production";
|
|
2512
|
+
}
|
|
2513
|
+
__name(isProduction, "isProduction");
|
|
2514
|
+
function resolveDashboardGate(options, auth) {
|
|
2515
|
+
if (options.hasGuards || auth !== null) return {
|
|
2516
|
+
mode: "delegated"
|
|
2517
|
+
};
|
|
2518
|
+
const token = options.token ?? process.env[DURABLE_DASHBOARD_TOKEN_ENV];
|
|
2519
|
+
if (typeof token === "string" && token !== "") return {
|
|
2520
|
+
mode: "token",
|
|
2521
|
+
token
|
|
2522
|
+
};
|
|
2523
|
+
if (options.allowUnauthenticated === true) return {
|
|
2524
|
+
mode: "open"
|
|
2525
|
+
};
|
|
2526
|
+
return {
|
|
2527
|
+
mode: isProduction() ? "deny" : "unconfigured"
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
__name(resolveDashboardGate, "resolveDashboardGate");
|
|
2531
|
+
function reportDashboardGate(gate, options, logger = new Logger3(LOG_CONTEXT)) {
|
|
2532
|
+
switch (gate.mode) {
|
|
2533
|
+
case "open":
|
|
2534
|
+
logger.warn("allowUnauthenticated: true. The durable console (including retry/cancel and other mutating endpoints) is served with NO authentication from this module. Only do this when a global guard or reverse proxy already protects it.");
|
|
2535
|
+
return;
|
|
2536
|
+
case "token":
|
|
2537
|
+
if (options.allowUnauthenticated === true) {
|
|
2538
|
+
logger.warn("allowUnauthenticated: true is ignored because a dashboard token is configured; requests must carry the token.");
|
|
2539
|
+
}
|
|
2540
|
+
return;
|
|
2541
|
+
case "unconfigured":
|
|
2542
|
+
logger.warn([
|
|
2543
|
+
"The durable console is UNAUTHENTICATED: no guards, dashboardAuth, token or",
|
|
2544
|
+
"allowUnauthenticated were configured. It is served open because NODE_ENV is not",
|
|
2545
|
+
'"production", but it WILL deny every request when NODE_ENV=production.',
|
|
2546
|
+
HOW_TO_CONFIGURE
|
|
2547
|
+
].join(" "));
|
|
2548
|
+
return;
|
|
2549
|
+
case "deny":
|
|
2550
|
+
logger.error([
|
|
2551
|
+
"The durable console has no authentication configured and NODE_ENV=production, so it",
|
|
2552
|
+
"is failing closed: every console request (UI and API) is denied.",
|
|
2553
|
+
HOW_TO_CONFIGURE
|
|
2554
|
+
].join(" "));
|
|
2555
|
+
return;
|
|
2556
|
+
case "delegated":
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
__name(reportDashboardGate, "reportDashboardGate");
|
|
2561
|
+
function dashboardGateProvider(options) {
|
|
2562
|
+
return {
|
|
2563
|
+
provide: DASHBOARD_GATE,
|
|
2564
|
+
inject: [
|
|
2565
|
+
DASHBOARD_AUTH
|
|
2566
|
+
],
|
|
2567
|
+
useFactory: /* @__PURE__ */ __name((auth) => {
|
|
2568
|
+
const gate = resolveDashboardGate(options, auth);
|
|
2569
|
+
reportDashboardGate(gate, options);
|
|
2570
|
+
return gate;
|
|
2571
|
+
}, "useFactory")
|
|
2572
|
+
};
|
|
2573
|
+
}
|
|
2574
|
+
__name(dashboardGateProvider, "dashboardGateProvider");
|
|
2575
|
+
function isRecord3(value) {
|
|
2576
|
+
return typeof value === "object" && value !== null;
|
|
2577
|
+
}
|
|
2578
|
+
__name(isRecord3, "isRecord");
|
|
2579
|
+
function headerValue(request, name) {
|
|
2580
|
+
const headers = request.headers;
|
|
2581
|
+
if (!isRecord3(headers)) return void 0;
|
|
2582
|
+
const value = headers[name];
|
|
2583
|
+
if (typeof value === "string") return value;
|
|
2584
|
+
if (Array.isArray(value) && typeof value[0] === "string") return value[0];
|
|
2585
|
+
return void 0;
|
|
2586
|
+
}
|
|
2587
|
+
__name(headerValue, "headerValue");
|
|
2588
|
+
function readDashboardToken(request) {
|
|
2589
|
+
if (!isRecord3(request)) return void 0;
|
|
2590
|
+
const authorization = headerValue(request, "authorization");
|
|
2591
|
+
if (authorization) {
|
|
2592
|
+
const match = /^Bearer\s+(.+)$/i.exec(authorization);
|
|
2593
|
+
if (match?.[1]) return match[1].trim();
|
|
2594
|
+
}
|
|
2595
|
+
const header = headerValue(request, "x-durable-token");
|
|
2596
|
+
if (header) return header.trim();
|
|
2597
|
+
const method = typeof request.method === "string" ? request.method.toUpperCase() : "";
|
|
2598
|
+
if (method === "GET" || method === "HEAD") {
|
|
2599
|
+
const query = request.query;
|
|
2600
|
+
if (isRecord3(query)) {
|
|
2601
|
+
const value = query.token;
|
|
2602
|
+
if (typeof value === "string" && value !== "") return value;
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
return void 0;
|
|
2606
|
+
}
|
|
2607
|
+
__name(readDashboardToken, "readDashboardToken");
|
|
2608
|
+
function secretsMatch(provided, expected) {
|
|
2609
|
+
const a = Buffer.from(provided);
|
|
2610
|
+
const b = Buffer.from(expected);
|
|
2611
|
+
if (a.length !== b.length) return false;
|
|
2612
|
+
return timingSafeEqual2(a, b);
|
|
2613
|
+
}
|
|
2614
|
+
__name(secretsMatch, "secretsMatch");
|
|
2615
|
+
var DurableDashboardGateGuard = class {
|
|
2616
|
+
static {
|
|
2617
|
+
__name(this, "DurableDashboardGateGuard");
|
|
2618
|
+
}
|
|
2619
|
+
gate;
|
|
2620
|
+
constructor(gate) {
|
|
2621
|
+
this.gate = gate;
|
|
2622
|
+
}
|
|
2623
|
+
canActivate(context) {
|
|
2624
|
+
switch (this.gate.mode) {
|
|
2625
|
+
case "delegated":
|
|
2626
|
+
case "open":
|
|
2627
|
+
case "unconfigured":
|
|
2628
|
+
return true;
|
|
2629
|
+
case "deny":
|
|
2630
|
+
throw new ForbiddenException([
|
|
2631
|
+
"Durable dashboard authentication is not configured, and NODE_ENV=production denies",
|
|
2632
|
+
"an unauthenticated console.",
|
|
2633
|
+
HOW_TO_CONFIGURE
|
|
2634
|
+
].join(" "));
|
|
2635
|
+
case "token": {
|
|
2636
|
+
const provided = readDashboardToken(context.switchToHttp().getRequest());
|
|
2637
|
+
if (provided !== void 0 && secretsMatch(provided, this.gate.token ?? "")) return true;
|
|
2638
|
+
throw new UnauthorizedException2("A valid durable dashboard token is required (Authorization: Bearer <token>, x-durable-token, or ?token= on GET).");
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
};
|
|
2643
|
+
DurableDashboardGateGuard = _ts_decorate10([
|
|
2644
|
+
Injectable4(),
|
|
2645
|
+
_ts_param6(0, Inject5(DASHBOARD_GATE)),
|
|
2646
|
+
_ts_metadata8("design:type", Function),
|
|
2647
|
+
_ts_metadata8("design:paramtypes", [
|
|
2648
|
+
typeof DashboardGate === "undefined" ? Object : DashboardGate
|
|
2649
|
+
])
|
|
2650
|
+
], DurableDashboardGateGuard);
|
|
2651
|
+
|
|
2453
2652
|
// src/server/durable-dashboard.module.ts
|
|
2454
2653
|
import "reflect-metadata";
|
|
2455
2654
|
import { ApplyFilterInterceptor as ApplyFilterInterceptor2, FilterRunner as FilterRunner2 } from "@dudousxd/nestjs-filter";
|
|
@@ -2457,8 +2656,8 @@ import { Module } from "@nestjs/common";
|
|
|
2457
2656
|
import { ModuleRef, RouterModule } from "@nestjs/core";
|
|
2458
2657
|
|
|
2459
2658
|
// src/server/durable-session.guard.ts
|
|
2460
|
-
import { Inject as
|
|
2461
|
-
function
|
|
2659
|
+
import { Inject as Inject6, Injectable as Injectable5, UnauthorizedException as UnauthorizedException3 } from "@nestjs/common";
|
|
2660
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
2462
2661
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2463
2662
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2464
2663
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2471,19 +2670,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
2471
2670
|
}
|
|
2472
2671
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2473
2672
|
}
|
|
2474
|
-
__name(
|
|
2475
|
-
function
|
|
2673
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
2674
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
2476
2675
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2477
2676
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2478
2677
|
}
|
|
2479
2678
|
}
|
|
2480
|
-
__name(
|
|
2481
|
-
function
|
|
2679
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2680
|
+
function _ts_param7(paramIndex, decorator) {
|
|
2482
2681
|
return function(target, key) {
|
|
2483
2682
|
decorator(target, key, paramIndex);
|
|
2484
2683
|
};
|
|
2485
2684
|
}
|
|
2486
|
-
__name(
|
|
2685
|
+
__name(_ts_param7, "_ts_param");
|
|
2487
2686
|
var DurableUiSessionGuard = class {
|
|
2488
2687
|
static {
|
|
2489
2688
|
__name(this, "DurableUiSessionGuard");
|
|
@@ -2524,12 +2723,12 @@ var DurableUiSessionGuard = class {
|
|
|
2524
2723
|
throw new DashboardLoginRedirectException(`${this.basePath}/login?returnTo=${returnTo}`);
|
|
2525
2724
|
}
|
|
2526
2725
|
};
|
|
2527
|
-
DurableUiSessionGuard =
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2726
|
+
DurableUiSessionGuard = _ts_decorate11([
|
|
2727
|
+
Injectable5(),
|
|
2728
|
+
_ts_param7(0, Inject6(DASHBOARD_AUTH)),
|
|
2729
|
+
_ts_param7(1, Inject6(DASHBOARD_BASE_PATH)),
|
|
2730
|
+
_ts_metadata9("design:type", Function),
|
|
2731
|
+
_ts_metadata9("design:paramtypes", [
|
|
2533
2732
|
Object,
|
|
2534
2733
|
String
|
|
2535
2734
|
])
|
|
@@ -2561,24 +2760,24 @@ var DurableApiSessionGuard = class {
|
|
|
2561
2760
|
* 401; `DurableUiSessionGuard`'s redirect/session-required exceptions above don't reach it.
|
|
2562
2761
|
*/
|
|
2563
2762
|
unauthorized(auth) {
|
|
2564
|
-
return new
|
|
2763
|
+
return new UnauthorizedException3({
|
|
2565
2764
|
auth: {
|
|
2566
2765
|
modes: auth.modes
|
|
2567
2766
|
}
|
|
2568
2767
|
});
|
|
2569
2768
|
}
|
|
2570
2769
|
};
|
|
2571
|
-
DurableApiSessionGuard =
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2770
|
+
DurableApiSessionGuard = _ts_decorate11([
|
|
2771
|
+
Injectable5(),
|
|
2772
|
+
_ts_param7(0, Inject6(DASHBOARD_AUTH)),
|
|
2773
|
+
_ts_metadata9("design:type", Function),
|
|
2774
|
+
_ts_metadata9("design:paramtypes", [
|
|
2576
2775
|
Object
|
|
2577
2776
|
])
|
|
2578
2777
|
], DurableApiSessionGuard);
|
|
2579
2778
|
|
|
2580
2779
|
// src/server/durable-dashboard.module.ts
|
|
2581
|
-
function
|
|
2780
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
2582
2781
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2583
2782
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2584
2783
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2591,7 +2790,7 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
2591
2790
|
}
|
|
2592
2791
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2593
2792
|
}
|
|
2594
|
-
__name(
|
|
2793
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2595
2794
|
var GUARDS_METADATA = "__guards__";
|
|
2596
2795
|
function normalize(path) {
|
|
2597
2796
|
return `/${path.replace(/^\/+|\/+$/g, "")}`;
|
|
@@ -2599,9 +2798,7 @@ function normalize(path) {
|
|
|
2599
2798
|
__name(normalize, "normalize");
|
|
2600
2799
|
function stampGuards(hostGuards, builtIn, controller) {
|
|
2601
2800
|
const merged = [
|
|
2602
|
-
...builtIn
|
|
2603
|
-
builtIn
|
|
2604
|
-
] : [],
|
|
2801
|
+
...builtIn.filter((guard) => guard !== void 0),
|
|
2605
2802
|
...hostGuards ?? []
|
|
2606
2803
|
];
|
|
2607
2804
|
Reflect.defineMetadata(GUARDS_METADATA, merged, controller);
|
|
@@ -2612,7 +2809,10 @@ var DurableApiModule = class _DurableApiModule {
|
|
|
2612
2809
|
__name(this, "DurableApiModule");
|
|
2613
2810
|
}
|
|
2614
2811
|
static register(options) {
|
|
2615
|
-
stampGuards(options.guards,
|
|
2812
|
+
stampGuards(options.guards, [
|
|
2813
|
+
options.authMayBeConfigured ? DurableApiSessionGuard : void 0,
|
|
2814
|
+
options.stampGate ? DurableDashboardGateGuard : void 0
|
|
2815
|
+
], DurableApiController);
|
|
2616
2816
|
return {
|
|
2617
2817
|
module: _DurableApiModule,
|
|
2618
2818
|
imports: [
|
|
@@ -2656,15 +2856,20 @@ var DurableApiModule = class _DurableApiModule {
|
|
|
2656
2856
|
RunFilter,
|
|
2657
2857
|
options.authProvider,
|
|
2658
2858
|
DurableApiSessionGuard,
|
|
2859
|
+
// Resolved ONCE here (this module is imported by the UI module, which reuses it via the
|
|
2860
|
+
// export below), so the boot report is logged once per mount.
|
|
2861
|
+
dashboardGateProvider(options.gate),
|
|
2862
|
+
DurableDashboardGateGuard,
|
|
2659
2863
|
...options.guards ?? []
|
|
2660
2864
|
],
|
|
2661
2865
|
exports: [
|
|
2662
|
-
DashboardService
|
|
2866
|
+
DashboardService,
|
|
2867
|
+
DASHBOARD_GATE
|
|
2663
2868
|
]
|
|
2664
2869
|
};
|
|
2665
2870
|
}
|
|
2666
2871
|
};
|
|
2667
|
-
DurableApiModule =
|
|
2872
|
+
DurableApiModule = _ts_decorate12([
|
|
2668
2873
|
Module({})
|
|
2669
2874
|
], DurableApiModule);
|
|
2670
2875
|
var DurableDashboardModule = class _DurableDashboardModule {
|
|
@@ -2676,7 +2881,8 @@ var DurableDashboardModule = class _DurableDashboardModule {
|
|
|
2676
2881
|
provide: DASHBOARD_AUTH,
|
|
2677
2882
|
useValue: resolveDashboardAuth(options.dashboardAuth)
|
|
2678
2883
|
};
|
|
2679
|
-
|
|
2884
|
+
const authConfigured = options.dashboardAuth !== void 0;
|
|
2885
|
+
return _DurableDashboardModule.build(options, authProvider, authConfigured, authConfigured);
|
|
2680
2886
|
}
|
|
2681
2887
|
static forRootAsync(options) {
|
|
2682
2888
|
const authProvider = {
|
|
@@ -2684,13 +2890,27 @@ var DurableDashboardModule = class _DurableDashboardModule {
|
|
|
2684
2890
|
inject: options.inject ?? [],
|
|
2685
2891
|
useFactory: /* @__PURE__ */ __name(async (...deps) => resolveDashboardAuth(await options.useDashboardAuth(...deps)), "useFactory")
|
|
2686
2892
|
};
|
|
2687
|
-
return _DurableDashboardModule.build(options, authProvider, true);
|
|
2893
|
+
return _DurableDashboardModule.build(options, authProvider, true, false);
|
|
2688
2894
|
}
|
|
2689
2895
|
/** Shared wiring: static routing + the API module, with `dashboardAuth` supplied by `authProvider`. */
|
|
2690
|
-
static build(options, authProvider, authMayBeConfigured) {
|
|
2896
|
+
static build(options, authProvider, authMayBeConfigured, authStaticallyConfigured) {
|
|
2691
2897
|
const basePath = normalize(options.basePath ?? "/durable");
|
|
2692
2898
|
const apiBasePath = normalize(options.apiBasePath ?? `${basePath}/api`);
|
|
2693
|
-
|
|
2899
|
+
const hasGuards = (options.guards?.length ?? 0) > 0;
|
|
2900
|
+
const gate = {
|
|
2901
|
+
hasGuards,
|
|
2902
|
+
...options.allowUnauthenticated !== void 0 ? {
|
|
2903
|
+
allowUnauthenticated: options.allowUnauthenticated
|
|
2904
|
+
} : {},
|
|
2905
|
+
...options.token !== void 0 ? {
|
|
2906
|
+
token: options.token
|
|
2907
|
+
} : {}
|
|
2908
|
+
};
|
|
2909
|
+
const stampGate = !hasGuards && !authStaticallyConfigured;
|
|
2910
|
+
stampGuards(options.guards, [
|
|
2911
|
+
authMayBeConfigured ? DurableUiSessionGuard : void 0,
|
|
2912
|
+
stampGate ? DurableDashboardGateGuard : void 0
|
|
2913
|
+
], DurableUiController);
|
|
2694
2914
|
return {
|
|
2695
2915
|
module: _DurableDashboardModule,
|
|
2696
2916
|
imports: [
|
|
@@ -2706,7 +2926,9 @@ var DurableDashboardModule = class _DurableDashboardModule {
|
|
|
2706
2926
|
guards: options.guards
|
|
2707
2927
|
} : {},
|
|
2708
2928
|
authProvider,
|
|
2709
|
-
authMayBeConfigured
|
|
2929
|
+
authMayBeConfigured,
|
|
2930
|
+
gate,
|
|
2931
|
+
stampGate
|
|
2710
2932
|
}),
|
|
2711
2933
|
RouterModule.register([
|
|
2712
2934
|
{
|
|
@@ -2739,6 +2961,8 @@ var DurableDashboardModule = class _DurableDashboardModule {
|
|
|
2739
2961
|
},
|
|
2740
2962
|
authProvider,
|
|
2741
2963
|
DurableUiSessionGuard,
|
|
2964
|
+
// `DASHBOARD_GATE` itself comes from the imported DurableApiModule (resolved once there).
|
|
2965
|
+
DurableDashboardGateGuard,
|
|
2742
2966
|
// DurableUiController (and DurableAuthController, when present) are hosted HERE, so their
|
|
2743
2967
|
// guards DI-instantiate from this module.
|
|
2744
2968
|
...options.guards ?? []
|
|
@@ -2750,19 +2974,26 @@ var DurableDashboardModule = class _DurableDashboardModule {
|
|
|
2750
2974
|
};
|
|
2751
2975
|
}
|
|
2752
2976
|
};
|
|
2753
|
-
DurableDashboardModule =
|
|
2977
|
+
DurableDashboardModule = _ts_decorate12([
|
|
2754
2978
|
Module({})
|
|
2755
2979
|
], DurableDashboardModule);
|
|
2756
2980
|
export {
|
|
2757
2981
|
DASHBOARD_API_PATH,
|
|
2758
2982
|
DASHBOARD_BASE_PATH,
|
|
2983
|
+
DASHBOARD_GATE,
|
|
2984
|
+
DURABLE_DASHBOARD_TOKEN_ENV,
|
|
2759
2985
|
DashboardService,
|
|
2760
2986
|
DurableApiController,
|
|
2761
2987
|
DurableApiModule,
|
|
2762
2988
|
DurableApiSessionGuard,
|
|
2763
2989
|
DurableAuthController,
|
|
2990
|
+
DurableDashboardGateGuard,
|
|
2764
2991
|
DurableDashboardModule,
|
|
2765
2992
|
DurableUiController,
|
|
2766
|
-
DurableUiSessionGuard
|
|
2993
|
+
DurableUiSessionGuard,
|
|
2994
|
+
dashboardGateProvider,
|
|
2995
|
+
readDashboardToken,
|
|
2996
|
+
reportDashboardGate,
|
|
2997
|
+
resolveDashboardGate
|
|
2767
2998
|
};
|
|
2768
2999
|
//# sourceMappingURL=index.js.map
|