badmfck-api-server 4.0.97 → 4.0.99

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.
@@ -18,9 +18,13 @@ class PostgresAdapter {
18
18
  pingInterval = 1000 * 60 * 5;
19
19
  poolConnections = 0;
20
20
  acquiredPoolConnections = 0;
21
+ statFrames = new Map();
21
22
  constructor(options) {
22
23
  this.options = options;
23
24
  }
25
+ stat() {
26
+ return this.statFrames;
27
+ }
24
28
  escape(value) {
25
29
  return value;
26
30
  }
@@ -9,5 +9,5 @@ export declare class Documentation extends BaseEndpoint {
9
9
  data: Record<string, any>[];
10
10
  }>;
11
11
  html(req: HTTPRequestVO): Promise<TransferPacketVO<any>>;
12
- checkAuthorization(req: HTTPRequestVO): Promise<void>;
12
+ checkAuthorization(req: HTTPRequestVO): Promise<string[] | undefined>;
13
13
  }
@@ -33,8 +33,27 @@ class Documentation extends BaseEndpoint_1.BaseEndpoint {
33
33
  }]);
34
34
  }
35
35
  async json(req) {
36
- await this.checkAuthorization(req);
37
- const doc = await DocumentService_1.REQ_DOC.request();
36
+ const endpoints = await this.checkAuthorization(req);
37
+ let doc = JSON.parse(JSON.stringify(await DocumentService_1.REQ_DOC.request()));
38
+ if (endpoints && endpoints.length > 0) {
39
+ doc = doc.filter((group) => {
40
+ if (group.endpoints && Array.isArray(group.endpoints)) {
41
+ group.endpoints = group.endpoints.filter((ep) => {
42
+ const path = ep.name;
43
+ return endpoints.some((pattern) => {
44
+ if (pattern.endsWith('/*')) {
45
+ const base = pattern.slice(0, -2);
46
+ return path === base || path.startsWith(base + '/');
47
+ }
48
+ else {
49
+ return path === pattern;
50
+ }
51
+ });
52
+ });
53
+ }
54
+ return group.endpoints && group.endpoints.length > 0;
55
+ });
56
+ }
38
57
  return { data: doc };
39
58
  }
40
59
  async html(req) {
@@ -80,7 +99,7 @@ class Documentation extends BaseEndpoint_1.BaseEndpoint {
80
99
  for (let i of users) {
81
100
  const hash = crypto_1.default.createHash("sha256").update(i.login + ":" + i.password).digest("hex");
82
101
  if (hash === header) {
83
- return;
102
+ return i.endpoints;
84
103
  }
85
104
  }
86
105
  throw { ...DefaultErrors_1.default.UNAUTHORIZED, details: "Invalid user" };