@dudousxd/nestjs-telescope-ui 1.15.0 → 1.16.1
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/CHANGELOG.md +14 -0
- package/dist/server/telescope-ui.module.d.ts +11 -1
- package/dist/server/telescope-ui.module.d.ts.map +1 -1
- package/dist/server/telescope-ui.module.js +38 -3
- package/dist/server/telescope-ui.module.js.map +1 -1
- package/dist/server/telescope-ui.options.d.ts +28 -0
- package/dist/server/telescope-ui.options.d.ts.map +1 -1
- package/dist/server/telescope-ui.options.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @dudousxd/nestjs-telescope-ui
|
|
2
2
|
|
|
3
|
+
## 1.16.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`c07d42a`](https://github.com/DavideCarvalho/nestjs-telescope/commit/c07d42a756e77b54ec92db4249ec060d9556e21c) - Docs + regression tests confirming `dashboardAuth`'s `login` hook already receives the submitted password verbatim end-to-end — including an empty string, since the built-in login screen never marks the field `required` and the auth controller only checks it's a string, not a non-empty one. No code path was blocking empty passwords; this closes the gap for hosts whose `login` hook gates on username alone (e.g. email must be an active admin) and deliberately ignores the password. Documented the pass-through in the `dashboardAuth` reference and added tests asserting: the hook is called with `''`, a hook rejecting an empty password still uniform-fails with `401`, and a hook accepting one mints the session.
|
|
8
|
+
|
|
9
|
+
## 1.16.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`46f6bd4`](https://github.com/DavideCarvalho/nestjs-telescope/commit/46f6bd491c962f694ed41066f47da4da29671c3f) - First-class `guards` (+ `imports`) options for the Telescope console, mirroring `@dudousxd/nestjs-agent`'s dashboard module: `TelescopeModule.forRoot`/`forRootAsync` and `TelescopeUiModule.forRoot`/`forRootAsync` now accept `guards: Array<Type<CanActivate> | CanActivate>` fronting the console's controllers, plus `imports` resolving a class guard's own dependencies.
|
|
14
|
+
|
|
15
|
+
This closes the auth seam for hosts with header-only auth: a full-page navigation to the dashboard carries no `Authorization` header, so there was previously no way to hang a cookie/session guard on the page itself. Pass the SAME `guards` (and `imports`) to both modules — they're independent options in separate packages. On core, `guards` **appends** to (never replaces) the existing `TelescopeGuard` gate (`authorizer` / `dashboardAuth` / dev-open-prod-closed default); on `-ui`, `TelescopeUiController` had no guard of its own, so it's a plain replace. See the new "Securing the console with your own guards" docs section.
|
|
16
|
+
|
|
3
17
|
## 1.15.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { type CanActivate, type DynamicModule, type InjectionToken, type OptionalFactoryDependency, type Type } from '@nestjs/common';
|
|
2
3
|
import { type TelescopeUiModuleOptions } from './telescope-ui.options.js';
|
|
3
4
|
export declare class TelescopeUiModule {
|
|
4
5
|
static forRoot(options?: TelescopeUiModuleOptions): DynamicModule;
|
|
@@ -13,6 +14,15 @@ export declare class TelescopeUiModule {
|
|
|
13
14
|
* `'telescope'` and must match the core module's path.
|
|
14
15
|
*/
|
|
15
16
|
path?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Guard classes (or instances) fronting the dashboard's page/asset
|
|
19
|
+
* controller. Must be passed HERE (not inside the async-resolved options)
|
|
20
|
+
* because guard stamping happens at module-build time, synchronously —
|
|
21
|
+
* the SAME constraint as `path` above. See
|
|
22
|
+
* {@link TelescopeUiModuleOptions.guards}. A class guard's dependencies
|
|
23
|
+
* resolve from `imports` above.
|
|
24
|
+
*/
|
|
25
|
+
guards?: Array<Type<CanActivate> | CanActivate>;
|
|
16
26
|
}): DynamicModule;
|
|
17
27
|
}
|
|
18
28
|
//# sourceMappingURL=telescope-ui.module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telescope-ui.module.d.ts","sourceRoot":"","sources":["../../src/server/telescope-ui.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telescope-ui.module.d.ts","sourceRoot":"","sources":["../../src/server/telescope-ui.module.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EAEnB,KAAK,yBAAyB,EAC9B,KAAK,IAAI,EACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAwB,KAAK,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAgChG,qBACa,iBAAiB;IAC5B,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,wBAA6B,GAAG,aAAa;IAerE,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE;QAC1B,UAAU,EAAE,CACV,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,wBAAwB,CAAC,GAAG,wBAAwB,CAAC;QAClE,MAAM,CAAC,EAAE,CAAC,cAAc,GAAG,yBAAyB,CAAC,EAAE,CAAC;QACxD,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QACnC;;;;;WAKG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd;;;;;;;WAOG;QACH,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,CAAC;KACjD,GAAG,aAAa;CA0BlB"}
|
|
@@ -5,26 +5,60 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
var TelescopeUiModule_1;
|
|
8
|
+
import 'reflect-metadata';
|
|
8
9
|
import { dynamicController, normalizeTelescopePath } from '@dudousxd/nestjs-telescope';
|
|
9
10
|
import { Module, } from '@nestjs/common';
|
|
10
11
|
import { TelescopeUiController } from './telescope-ui.controller.js';
|
|
11
12
|
import { TELESCOPE_UI_OPTIONS } from './telescope-ui.options.js';
|
|
13
|
+
/**
|
|
14
|
+
* `@nestjs/common`'s own `GUARDS_METADATA` key, INLINED rather than deep-imported
|
|
15
|
+
* from '@nestjs/common/constants' — that subpath has no extension and a strict
|
|
16
|
+
* ESM resolver 404s on it (same convention used by core's `TelescopeModule` and
|
|
17
|
+
* `@dudousxd/nestjs-agent`'s `agent-dashboard.module.ts`). A drift spec asserts
|
|
18
|
+
* this literal stays byte-identical to the real constant.
|
|
19
|
+
*/
|
|
20
|
+
const GUARDS_METADATA = '__guards__';
|
|
21
|
+
/** Narrows a `guards` entry to a class (constructor), not an already-built instance. */
|
|
22
|
+
function isGuardClass(guard) {
|
|
23
|
+
return typeof guard === 'function';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Stamp host guards onto the dashboard's page/asset controller. `TelescopeUiController`
|
|
27
|
+
* carries no guard of its own, so — unlike core's `stampGuards` — there is nothing to
|
|
28
|
+
* preserve: this is a plain REPLACE of whatever (nothing) was there before. A no-op
|
|
29
|
+
* when `guards` is omitted/empty, leaving the controller unguarded exactly as before.
|
|
30
|
+
*/
|
|
31
|
+
function stampGuards(guards, ...controllers) {
|
|
32
|
+
if (guards === undefined || guards.length === 0)
|
|
33
|
+
return;
|
|
34
|
+
for (const controller of controllers) {
|
|
35
|
+
Reflect.defineMetadata(GUARDS_METADATA, guards, controller);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
12
38
|
let TelescopeUiModule = TelescopeUiModule_1 = class TelescopeUiModule {
|
|
13
39
|
static forRoot(options = {}) {
|
|
14
40
|
const path = normalizeTelescopePath(options.path);
|
|
41
|
+
const uiController = dynamicController(TelescopeUiController, path);
|
|
42
|
+
stampGuards(options.guards, uiController);
|
|
15
43
|
return {
|
|
16
44
|
module: TelescopeUiModule_1,
|
|
17
|
-
|
|
18
|
-
|
|
45
|
+
imports: options.imports ?? [],
|
|
46
|
+
controllers: [uiController],
|
|
47
|
+
providers: [
|
|
48
|
+
{ provide: TELESCOPE_UI_OPTIONS, useValue: options },
|
|
49
|
+
...(options.guards ?? []).filter(isGuardClass),
|
|
50
|
+
],
|
|
19
51
|
};
|
|
20
52
|
}
|
|
21
53
|
static forRootAsync(config) {
|
|
22
54
|
const path = normalizeTelescopePath(config.path);
|
|
55
|
+
const uiController = dynamicController(TelescopeUiController, path);
|
|
56
|
+
stampGuards(config.guards, uiController);
|
|
23
57
|
const { useFactory } = config;
|
|
24
58
|
return {
|
|
25
59
|
module: TelescopeUiModule_1,
|
|
26
60
|
imports: config.imports ?? [],
|
|
27
|
-
controllers: [
|
|
61
|
+
controllers: [uiController],
|
|
28
62
|
providers: [
|
|
29
63
|
{
|
|
30
64
|
provide: TELESCOPE_UI_OPTIONS,
|
|
@@ -38,6 +72,7 @@ let TelescopeUiModule = TelescopeUiModule_1 = class TelescopeUiModule {
|
|
|
38
72
|
}),
|
|
39
73
|
inject: config.inject ?? [],
|
|
40
74
|
},
|
|
75
|
+
...(config.guards ?? []).filter(isGuardClass),
|
|
41
76
|
],
|
|
42
77
|
};
|
|
43
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telescope-ui.module.js","sourceRoot":"","sources":["../../src/server/telescope-ui.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,
|
|
1
|
+
{"version":3,"file":"telescope-ui.module.js","sourceRoot":"","sources":["../../src/server/telescope-ui.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAIL,MAAM,GAGP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAiC,MAAM,2BAA2B,CAAC;AAEhG;;;;;;GAMG;AACH,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AAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACzC,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAC9B,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE;YAC7B,WAAW,EAAE,CAAC,YAAY,CAAC;YAC3B,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,oBAAoB;oBAC7B,wEAAwE;oBACxE,sEAAsE;oBACtE,iEAAiE;oBACjE,+DAA+D;oBAC/D,UAAU,EAAE,KAAK,EAAE,GAAG,IAAe,EAAqC,EAAE,CAAC,CAAC;wBAC5E,GAAG,CAAC,MAAM,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;wBAC9B,IAAI;qBACL,CAAC;oBACF,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;iBAC5B;gBACD,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;aAC9C;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAhEY,iBAAiB;IAD7B,MAAM,CAAC,EAAE,CAAC;GACE,iBAAiB,CAgE7B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CanActivate, DynamicModule, Type } from '@nestjs/common';
|
|
1
2
|
export declare const TELESCOPE_UI_OPTIONS: unique symbol;
|
|
2
3
|
export interface TelescopeUiModuleOptions {
|
|
3
4
|
/** Directory of the built SPA (index.html + assets/). Defaults to the bundled dist/spa. */
|
|
@@ -8,5 +9,32 @@ export interface TelescopeUiModuleOptions {
|
|
|
8
9
|
* before. Must match the core `TelescopeModule.forRoot({ path })`.
|
|
9
10
|
*/
|
|
10
11
|
path?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Guard classes (or already-instantiated `CanActivate`s) fronting the
|
|
14
|
+
* dashboard's page + static-asset controller (`TelescopeUiController`) — the
|
|
15
|
+
* full-page HTML shell and its hashed JS/CSS bundle. See
|
|
16
|
+
* `TelescopeModuleOptions.guards` (`@dudousxd/nestjs-telescope`) for the full
|
|
17
|
+
* rationale: full-page navigations carry no `Authorization` header, so a
|
|
18
|
+
* header-only auth scheme can't gate this controller — a guard here must be
|
|
19
|
+
* able to authenticate from a COOKIE (falling back to a header for XHR/fetch
|
|
20
|
+
* callers if useful). See the "Securing the console" guide.
|
|
21
|
+
*
|
|
22
|
+
* These two `guards` options are INDEPENDENT — different package, different
|
|
23
|
+
* module — so pass the SAME `guards` (and matching `imports`) to BOTH
|
|
24
|
+
* `TelescopeModule.forRoot` (core) and this module. Setting it here alone
|
|
25
|
+
* still leaves the API reachable; setting it only on core still leaves the
|
|
26
|
+
* page itself (HTML shell + assets) reachable by an anonymous browser.
|
|
27
|
+
*
|
|
28
|
+
* Unlike core's console API controllers, `TelescopeUiController` ships with
|
|
29
|
+
* NO guard of its own by default (the page + assets are considered public —
|
|
30
|
+
* no data lives there), so setting `guards` here is a plain REPLACE: the
|
|
31
|
+
* listed guard(s) become the controller's entire gate.
|
|
32
|
+
*/
|
|
33
|
+
guards?: Array<Type<CanActivate> | CanActivate>;
|
|
34
|
+
/**
|
|
35
|
+
* Extra `imports` merged into `TelescopeUiModule`'s own dynamic module — the
|
|
36
|
+
* DI resolution path for a class passed to {@link guards}.
|
|
37
|
+
*/
|
|
38
|
+
imports?: DynamicModule['imports'];
|
|
11
39
|
}
|
|
12
40
|
//# sourceMappingURL=telescope-ui.options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telescope-ui.options.d.ts","sourceRoot":"","sources":["../../src/server/telescope-ui.options.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AAEnE,MAAM,WAAW,wBAAwB;IACvC,2FAA2F;IAC3F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"telescope-ui.options.d.ts","sourceRoot":"","sources":["../../src/server/telescope-ui.options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEvE,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AAEnE,MAAM,WAAW,wBAAwB;IACvC,2FAA2F;IAC3F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,CAAC;IAChD;;;OAGG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telescope-ui.options.js","sourceRoot":"","sources":["../../src/server/telescope-ui.options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telescope-ui.options.js","sourceRoot":"","sources":["../../src/server/telescope-ui.options.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-telescope-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "Bundled dashboard + composable React components for @dudousxd/nestjs-telescope.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@nestjs/common": ">=11.0.0",
|
|
44
44
|
"@nestjs/core": ">=11.0.0",
|
|
45
|
-
"@dudousxd/nestjs-telescope": "^1.
|
|
45
|
+
"@dudousxd/nestjs-telescope": "^1.19.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
48
48
|
"react": {
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"typescript": "^5.4.0",
|
|
82
82
|
"vite": "^5.4.0",
|
|
83
83
|
"vitest": "^3.0.0",
|
|
84
|
-
"@dudousxd/nestjs-telescope": "1.
|
|
84
|
+
"@dudousxd/nestjs-telescope": "1.19.1"
|
|
85
85
|
},
|
|
86
86
|
"engines": {
|
|
87
87
|
"node": ">=20"
|