@dudousxd/nestjs-catalog-dashboard 0.34.0 → 0.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/react/open-console-button.d.ts +1 -1
- package/dist/react/open-console-button.d.ts.map +1 -1
- package/dist/server/index.cjs +103 -30
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +7 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +107 -34
- package/dist/server/index.js.map +1 -1
- package/dist/spa/assets/index-IDIdvur-.css +1 -0
- package/dist/spa/assets/index-wLMRrn0e.js +2951 -0
- package/dist/spa/index.html +2 -2
- package/package.json +19 -16
- package/dist/spa/assets/index-CLg7zNP8.js +0 -2981
- package/dist/spa/assets/index-Ceb-Uc-q.css +0 -1
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/auth/dashboard-auth-config.ts
|
|
5
|
-
var DASHBOARD_AUTH = Symbol("DASHBOARD_AUTH");
|
|
5
|
+
var DASHBOARD_AUTH = /* @__PURE__ */ Symbol("DASHBOARD_AUTH");
|
|
6
6
|
var DEFAULT_TTL = "8h";
|
|
7
7
|
var DEFAULT_TTL_MS = 8 * 60 * 60 * 1e3;
|
|
8
8
|
var DURATION_UNITS = {
|
|
@@ -216,7 +216,7 @@ function writeHtmlRaw(response, html, status = 200) {
|
|
|
216
216
|
__name(writeHtmlRaw, "writeHtmlRaw");
|
|
217
217
|
|
|
218
218
|
// src/server/auth/session-cookie.ts
|
|
219
|
-
import { createHmac, timingSafeEqual } from "
|
|
219
|
+
import { createHmac, timingSafeEqual } from "crypto";
|
|
220
220
|
var EXP_GRACE_MS = 3e4;
|
|
221
221
|
function base64urlEncode(value) {
|
|
222
222
|
return Buffer.from(value, "utf8").toString("base64url");
|
|
@@ -545,17 +545,24 @@ function renderSessionRequiredPage(basePath) {
|
|
|
545
545
|
__name(renderSessionRequiredPage, "renderSessionRequiredPage");
|
|
546
546
|
|
|
547
547
|
// src/server/catalog-ui.controller.ts
|
|
548
|
-
import {
|
|
549
|
-
import { basename, extname, join, resolve, sep } from "
|
|
550
|
-
import { fileURLToPath } from "
|
|
548
|
+
import { createReadStream, readFileSync, statSync } from "fs";
|
|
549
|
+
import { basename, extname, join, resolve, sep } from "path";
|
|
550
|
+
import { fileURLToPath } from "url";
|
|
551
551
|
import { Controller, Get, Header, Inject as Inject2, NotFoundException, Optional as Optional2, Param, StreamableFile, UseFilters } from "@nestjs/common";
|
|
552
552
|
|
|
553
553
|
// src/server/auth/login-redirect.exception.ts
|
|
554
554
|
import { Catch, HttpException, HttpStatus } from "@nestjs/common";
|
|
555
555
|
function _ts_decorate(decorators, target, key, desc) {
|
|
556
556
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
557
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
558
|
-
|
|
557
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
558
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
559
|
+
} else {
|
|
560
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
561
|
+
if (d = decorators[i]) {
|
|
562
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
559
566
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
560
567
|
}
|
|
561
568
|
__name(_ts_decorate, "_ts_decorate");
|
|
@@ -587,13 +594,22 @@ DashboardLoginRedirectFilter = _ts_decorate([
|
|
|
587
594
|
import { Catch as Catch2, HttpException as HttpException2, HttpStatus as HttpStatus2, Inject, Logger, Optional } from "@nestjs/common";
|
|
588
595
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
589
596
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
590
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
591
|
-
|
|
597
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
598
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
599
|
+
} else {
|
|
600
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
601
|
+
if (d = decorators[i]) {
|
|
602
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
592
606
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
593
607
|
}
|
|
594
608
|
__name(_ts_decorate2, "_ts_decorate");
|
|
595
|
-
function _ts_metadata(
|
|
596
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
609
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
610
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
611
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
612
|
+
}
|
|
597
613
|
}
|
|
598
614
|
__name(_ts_metadata, "_ts_metadata");
|
|
599
615
|
function _ts_param(paramIndex, decorator) {
|
|
@@ -663,13 +679,22 @@ DashboardSessionRequiredFilter = _ts_decorate2([
|
|
|
663
679
|
// src/server/catalog-ui.controller.ts
|
|
664
680
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
665
681
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
666
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
667
|
-
|
|
682
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
683
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
684
|
+
} else {
|
|
685
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
686
|
+
if (d = decorators[i]) {
|
|
687
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
668
691
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
669
692
|
}
|
|
670
693
|
__name(_ts_decorate3, "_ts_decorate");
|
|
671
|
-
function _ts_metadata2(
|
|
672
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
694
|
+
function _ts_metadata2(metadataKey, metadataValue) {
|
|
695
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
696
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
697
|
+
}
|
|
673
698
|
}
|
|
674
699
|
__name(_ts_metadata2, "_ts_metadata");
|
|
675
700
|
function _ts_param2(paramIndex, decorator) {
|
|
@@ -678,8 +703,8 @@ function _ts_param2(paramIndex, decorator) {
|
|
|
678
703
|
};
|
|
679
704
|
}
|
|
680
705
|
__name(_ts_param2, "_ts_param");
|
|
681
|
-
var DASHBOARD_BASE_PATH = Symbol("DASHBOARD_BASE_PATH");
|
|
682
|
-
var DASHBOARD_API_PATH = Symbol("DASHBOARD_API_PATH");
|
|
706
|
+
var DASHBOARD_BASE_PATH = /* @__PURE__ */ Symbol("DASHBOARD_BASE_PATH");
|
|
707
|
+
var DASHBOARD_API_PATH = /* @__PURE__ */ Symbol("DASHBOARD_API_PATH");
|
|
683
708
|
var BUILD_BASE = "/catalog";
|
|
684
709
|
function spaDir() {
|
|
685
710
|
return fileURLToPath(new URL("../spa", import.meta.url));
|
|
@@ -702,6 +727,12 @@ var CatalogUiController = class {
|
|
|
702
727
|
apiBasePath;
|
|
703
728
|
auth;
|
|
704
729
|
dir = spaDir();
|
|
730
|
+
/**
|
|
731
|
+
* The rewritten index.html, with the file version it was rendered from. A
|
|
732
|
+
* rebuilt bundle changes the file's mtime or size, and the next request
|
|
733
|
+
* renders it again instead of pointing at hashed assets that are gone.
|
|
734
|
+
*/
|
|
735
|
+
rendered;
|
|
705
736
|
constructor(basePath, apiBasePath, auth = null) {
|
|
706
737
|
this.basePath = basePath;
|
|
707
738
|
this.apiBasePath = apiBasePath;
|
|
@@ -711,10 +742,24 @@ var CatalogUiController = class {
|
|
|
711
742
|
// classic "stuck loading after a deploy"). The hashed assets below are immutable.
|
|
712
743
|
index() {
|
|
713
744
|
const indexPath = join(this.dir, "index.html");
|
|
714
|
-
|
|
745
|
+
const stat = statSync(indexPath, {
|
|
746
|
+
throwIfNoEntry: false
|
|
747
|
+
});
|
|
748
|
+
if (!stat) {
|
|
715
749
|
throw new NotFoundException("Dashboard is not built. Run the package build.");
|
|
716
750
|
}
|
|
717
|
-
const
|
|
751
|
+
const cached = this.rendered;
|
|
752
|
+
if (cached && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size) return cached.html;
|
|
753
|
+
const html = this.render(readFileSync(indexPath, "utf8"));
|
|
754
|
+
this.rendered = {
|
|
755
|
+
mtimeMs: stat.mtimeMs,
|
|
756
|
+
size: stat.size,
|
|
757
|
+
html
|
|
758
|
+
};
|
|
759
|
+
return html;
|
|
760
|
+
}
|
|
761
|
+
render(source) {
|
|
762
|
+
const html = source.replaceAll(`="${BUILD_BASE}/`, `="${this.basePath}/`);
|
|
718
763
|
const hostAuth = this.auth ? "true" : "false";
|
|
719
764
|
const inject = `<script>window.__CATALOG_BASE__='${this.basePath}';window.__CATALOG_API__='${this.apiBasePath}';window.__CATALOG_HOST_AUTH__=${hostAuth};</script>`;
|
|
720
765
|
return html.includes("</head>") ? html.replace("</head>", `${inject}</head>`) : inject + html;
|
|
@@ -724,12 +769,15 @@ var CatalogUiController = class {
|
|
|
724
769
|
if (safe !== file) throw new NotFoundException();
|
|
725
770
|
const root = resolve(this.dir, "assets");
|
|
726
771
|
const assetPath = resolve(root, safe);
|
|
727
|
-
if (!assetPath.startsWith(root + sep)
|
|
728
|
-
|
|
729
|
-
|
|
772
|
+
if (!assetPath.startsWith(root + sep)) throw new NotFoundException();
|
|
773
|
+
const stat = statSync(assetPath, {
|
|
774
|
+
throwIfNoEntry: false
|
|
775
|
+
});
|
|
776
|
+
if (!stat?.isFile()) throw new NotFoundException();
|
|
730
777
|
const type = CONTENT_TYPES[extname(safe)] ?? "application/octet-stream";
|
|
731
|
-
return new StreamableFile(
|
|
732
|
-
type
|
|
778
|
+
return new StreamableFile(createReadStream(assetPath), {
|
|
779
|
+
type,
|
|
780
|
+
length: stat.size
|
|
733
781
|
});
|
|
734
782
|
}
|
|
735
783
|
};
|
|
@@ -769,13 +817,22 @@ CatalogUiController = _ts_decorate3([
|
|
|
769
817
|
// src/server/catalog-auth.controller.ts
|
|
770
818
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
771
819
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
772
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
773
|
-
|
|
820
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
821
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
822
|
+
} else {
|
|
823
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
824
|
+
if (d = decorators[i]) {
|
|
825
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
774
829
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
775
830
|
}
|
|
776
831
|
__name(_ts_decorate4, "_ts_decorate");
|
|
777
|
-
function _ts_metadata3(
|
|
778
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
832
|
+
function _ts_metadata3(metadataKey, metadataValue) {
|
|
833
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
834
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
835
|
+
}
|
|
779
836
|
}
|
|
780
837
|
__name(_ts_metadata3, "_ts_metadata");
|
|
781
838
|
function _ts_param3(paramIndex, decorator) {
|
|
@@ -960,13 +1017,22 @@ import { RouterModule } from "@nestjs/core";
|
|
|
960
1017
|
import { Inject as Inject4, Injectable, UnauthorizedException as UnauthorizedException2 } from "@nestjs/common";
|
|
961
1018
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
962
1019
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
963
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
964
|
-
|
|
1020
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1021
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1022
|
+
} else {
|
|
1023
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1024
|
+
if (d = decorators[i]) {
|
|
1025
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
965
1029
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
966
1030
|
}
|
|
967
1031
|
__name(_ts_decorate5, "_ts_decorate");
|
|
968
|
-
function _ts_metadata4(
|
|
969
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1032
|
+
function _ts_metadata4(metadataKey, metadataValue) {
|
|
1033
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1034
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1035
|
+
}
|
|
970
1036
|
}
|
|
971
1037
|
__name(_ts_metadata4, "_ts_metadata");
|
|
972
1038
|
function _ts_param4(paramIndex, decorator) {
|
|
@@ -1074,8 +1140,15 @@ CatalogApiSessionGuard = _ts_decorate5([
|
|
|
1074
1140
|
// src/server/catalog-dashboard.module.ts
|
|
1075
1141
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
1076
1142
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1077
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1078
|
-
|
|
1143
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1144
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1145
|
+
} else {
|
|
1146
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1147
|
+
if (d = decorators[i]) {
|
|
1148
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1079
1152
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1080
1153
|
}
|
|
1081
1154
|
__name(_ts_decorate6, "_ts_decorate");
|