@ccci/micro-server 1.0.52 → 1.0.54
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/index.d.ts +2 -0
- package/dist/index.js +170 -152
- package/dist/utils/WebsocketServer.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export { default as BaseController } from './utils/BaseController';
|
|
|
7
7
|
export { ConstructQuery, ResponseHelper, ErrorResponseHandler, } from './utils/BaseControllerHelper';
|
|
8
8
|
export { default as IBaseModel } from './utils/IBaseModel';
|
|
9
9
|
export { default as BaseModel } from './utils/BaseModel';
|
|
10
|
+
export { default as ErrorHandler } from './utils/ErrorHandler';
|
|
11
|
+
export { generate, verify, decode } from './utils/TokenGenerator';
|
|
10
12
|
export { default as DatabaseConnector } from './utils/DatabaseConnector';
|
|
11
13
|
export { default as BaseSocketHandler } from './utils/BaseSocketHandler';
|
|
12
14
|
export type { WebSocketData } from './types/BaseSocketType';
|
package/dist/index.js
CHANGED
|
@@ -88825,7 +88825,7 @@ var require_decode_uri_component = __commonJS((exports, module) => {
|
|
|
88825
88825
|
var right = components.slice(split);
|
|
88826
88826
|
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
|
|
88827
88827
|
};
|
|
88828
|
-
var
|
|
88828
|
+
var decode2 = function(input) {
|
|
88829
88829
|
try {
|
|
88830
88830
|
return decodeURIComponent(input);
|
|
88831
88831
|
} catch (err) {
|
|
@@ -88847,7 +88847,7 @@ var require_decode_uri_component = __commonJS((exports, module) => {
|
|
|
88847
88847
|
try {
|
|
88848
88848
|
replaceMap[match[0]] = decodeURIComponent(match[0]);
|
|
88849
88849
|
} catch (err) {
|
|
88850
|
-
var result =
|
|
88850
|
+
var result = decode2(match[0]);
|
|
88851
88851
|
if (result !== match[0]) {
|
|
88852
88852
|
replaceMap[match[0]] = result;
|
|
88853
88853
|
}
|
|
@@ -97719,8 +97719,8 @@ var require_cookies = __commonJS((exports, module) => {
|
|
|
97719
97719
|
if (urlparts.hostname !== cookie.domain && (cookie.domain.charAt(0) !== "." || ("." + urlparts.hostname).substr(-cookie.domain.length) !== cookie.domain)) {
|
|
97720
97720
|
return false;
|
|
97721
97721
|
}
|
|
97722
|
-
let
|
|
97723
|
-
if (
|
|
97722
|
+
let path3 = this.getPath(urlparts.pathname);
|
|
97723
|
+
if (path3.substr(0, cookie.path.length) !== cookie.path) {
|
|
97724
97724
|
return false;
|
|
97725
97725
|
}
|
|
97726
97726
|
if (cookie.secure && urlparts.protocol !== "https:") {
|
|
@@ -97756,16 +97756,16 @@ var require_cookies = __commonJS((exports, module) => {
|
|
|
97756
97756
|
return cookie.expires && cookie.expires < new Date || !cookie.value;
|
|
97757
97757
|
}
|
|
97758
97758
|
getPath(pathname) {
|
|
97759
|
-
let
|
|
97760
|
-
|
|
97761
|
-
|
|
97762
|
-
if (
|
|
97763
|
-
|
|
97759
|
+
let path3 = (pathname || "/").split("/");
|
|
97760
|
+
path3.pop();
|
|
97761
|
+
path3 = path3.join("/").trim();
|
|
97762
|
+
if (path3.charAt(0) !== "/") {
|
|
97763
|
+
path3 = "/" + path3;
|
|
97764
97764
|
}
|
|
97765
|
-
if (
|
|
97766
|
-
|
|
97765
|
+
if (path3.substr(-1) !== "/") {
|
|
97766
|
+
path3 += "/";
|
|
97767
97767
|
}
|
|
97768
|
-
return
|
|
97768
|
+
return path3;
|
|
97769
97769
|
}
|
|
97770
97770
|
}
|
|
97771
97771
|
module.exports = Cookies;
|
|
@@ -98129,7 +98129,7 @@ var require_shared = __commonJS((exports, module) => {
|
|
|
98129
98129
|
};
|
|
98130
98130
|
var urllib = __require("url");
|
|
98131
98131
|
var util = __require("util");
|
|
98132
|
-
var
|
|
98132
|
+
var fs5 = __require("fs");
|
|
98133
98133
|
var nmfetch = require_fetch();
|
|
98134
98134
|
var dns = __require("dns");
|
|
98135
98135
|
var net = __require("net");
|
|
@@ -98479,7 +98479,7 @@ var require_shared = __commonJS((exports, module) => {
|
|
|
98479
98479
|
}
|
|
98480
98480
|
return callback(null, parsedDataUri.data);
|
|
98481
98481
|
} else if (content.path) {
|
|
98482
|
-
return resolveStream(
|
|
98482
|
+
return resolveStream(fs5.createReadStream(content.path), callback);
|
|
98483
98483
|
}
|
|
98484
98484
|
}
|
|
98485
98485
|
if (typeof data[key].content === "string" && !["utf8", "usascii", "ascii"].includes(encoding)) {
|
|
@@ -98527,7 +98527,7 @@ var require_shared = __commonJS((exports, module) => {
|
|
|
98527
98527
|
|
|
98528
98528
|
// node_modules/nodemailer/lib/mime-funcs/mime-types.js
|
|
98529
98529
|
var require_mime_types2 = __commonJS((exports, module) => {
|
|
98530
|
-
var
|
|
98530
|
+
var path3 = __require("path");
|
|
98531
98531
|
var defaultMimeType = "application/octet-stream";
|
|
98532
98532
|
var defaultExtension = "bin";
|
|
98533
98533
|
var mimeTypes = new Map([
|
|
@@ -100583,7 +100583,7 @@ var require_mime_types2 = __commonJS((exports, module) => {
|
|
|
100583
100583
|
if (!filename) {
|
|
100584
100584
|
return defaultMimeType;
|
|
100585
100585
|
}
|
|
100586
|
-
let parsed =
|
|
100586
|
+
let parsed = path3.parse(filename);
|
|
100587
100587
|
let extension = (parsed.ext.substr(1) || parsed.name || "").split("?").shift().trim().toLowerCase();
|
|
100588
100588
|
let value = defaultMimeType;
|
|
100589
100589
|
if (extensions2.has(extension)) {
|
|
@@ -100708,7 +100708,7 @@ var require_punycode = __commonJS((exports, module) => {
|
|
|
100708
100708
|
}
|
|
100709
100709
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
100710
100710
|
};
|
|
100711
|
-
var
|
|
100711
|
+
var decode2 = function(input) {
|
|
100712
100712
|
const output = [];
|
|
100713
100713
|
const inputLength = input.length;
|
|
100714
100714
|
let i = 0;
|
|
@@ -100818,7 +100818,7 @@ var require_punycode = __commonJS((exports, module) => {
|
|
|
100818
100818
|
};
|
|
100819
100819
|
var toUnicode = function(input) {
|
|
100820
100820
|
return mapDomain(input, function(string) {
|
|
100821
|
-
return regexPunycode.test(string) ?
|
|
100821
|
+
return regexPunycode.test(string) ? decode2(string.slice(4).toLowerCase()) : string;
|
|
100822
100822
|
});
|
|
100823
100823
|
};
|
|
100824
100824
|
var toASCII = function(input) {
|
|
@@ -100832,7 +100832,7 @@ var require_punycode = __commonJS((exports, module) => {
|
|
|
100832
100832
|
decode: ucs2decode,
|
|
100833
100833
|
encode: ucs2encode
|
|
100834
100834
|
},
|
|
100835
|
-
decode,
|
|
100835
|
+
decode: decode2,
|
|
100836
100836
|
encode: encode2,
|
|
100837
100837
|
toASCII,
|
|
100838
100838
|
toUnicode
|
|
@@ -101806,7 +101806,7 @@ var require_le_unix = __commonJS((exports, module) => {
|
|
|
101806
101806
|
// node_modules/nodemailer/lib/mime-node/index.js
|
|
101807
101807
|
var require_mime_node = __commonJS((exports, module) => {
|
|
101808
101808
|
var crypto4 = __require("crypto");
|
|
101809
|
-
var
|
|
101809
|
+
var fs5 = __require("fs");
|
|
101810
101810
|
var punycode = require_punycode();
|
|
101811
101811
|
var PassThrough = __require("stream").PassThrough;
|
|
101812
101812
|
var shared = require_shared();
|
|
@@ -102406,7 +102406,7 @@ var require_mime_node = __commonJS((exports, module) => {
|
|
|
102406
102406
|
setImmediate(() => contentStream.emit("error", new Error("File access rejected for " + content.path)));
|
|
102407
102407
|
return contentStream;
|
|
102408
102408
|
}
|
|
102409
|
-
return
|
|
102409
|
+
return fs5.createReadStream(content.path);
|
|
102410
102410
|
} else if (content && typeof content.href === "string") {
|
|
102411
102411
|
if (this.disableUrlAccess) {
|
|
102412
102412
|
contentStream = new PassThrough;
|
|
@@ -103270,8 +103270,8 @@ var require_dkim = __commonJS((exports, module) => {
|
|
|
103270
103270
|
var RelaxedBody = require_relaxed_body();
|
|
103271
103271
|
var sign = require_sign2();
|
|
103272
103272
|
var PassThrough = __require("stream").PassThrough;
|
|
103273
|
-
var
|
|
103274
|
-
var
|
|
103273
|
+
var fs5 = __require("fs");
|
|
103274
|
+
var path3 = __require("path");
|
|
103275
103275
|
var crypto4 = __require("crypto");
|
|
103276
103276
|
var DKIM_ALGO = "sha256";
|
|
103277
103277
|
var MAX_MESSAGE_SIZE = 128 * 1024;
|
|
@@ -103286,7 +103286,7 @@ var require_dkim = __commonJS((exports, module) => {
|
|
|
103286
103286
|
this.chunks = [];
|
|
103287
103287
|
this.chunklen = 0;
|
|
103288
103288
|
this.readPos = 0;
|
|
103289
|
-
this.cachePath = this.cacheDir ?
|
|
103289
|
+
this.cachePath = this.cacheDir ? path3.join(this.cacheDir, "message." + Date.now() + "-" + crypto4.randomBytes(14).toString("hex")) : false;
|
|
103290
103290
|
this.cache = false;
|
|
103291
103291
|
this.headers = false;
|
|
103292
103292
|
this.bodyHash = false;
|
|
@@ -103306,10 +103306,10 @@ var require_dkim = __commonJS((exports, module) => {
|
|
|
103306
103306
|
if (!this.cache || !this.cachePath) {
|
|
103307
103307
|
return;
|
|
103308
103308
|
}
|
|
103309
|
-
|
|
103309
|
+
fs5.unlink(this.cachePath, () => false);
|
|
103310
103310
|
}
|
|
103311
103311
|
createReadCache() {
|
|
103312
|
-
this.cache =
|
|
103312
|
+
this.cache = fs5.createReadStream(this.cachePath);
|
|
103313
103313
|
this.cache.once("error", (err) => {
|
|
103314
103314
|
this.cleanup();
|
|
103315
103315
|
this.output.emit("error", err);
|
|
@@ -103365,7 +103365,7 @@ var require_dkim = __commonJS((exports, module) => {
|
|
|
103365
103365
|
}
|
|
103366
103366
|
createWriteCache() {
|
|
103367
103367
|
this.output.usingCache = true;
|
|
103368
|
-
this.cache =
|
|
103368
|
+
this.cache = fs5.createWriteStream(this.cachePath);
|
|
103369
103369
|
this.cache.once("error", (err) => {
|
|
103370
103370
|
this.cleanup();
|
|
103371
103371
|
this.relaxedBody.unpipe(this.cache);
|
|
@@ -108490,11 +108490,11 @@ var require_ast = __commonJS((exports, module) => {
|
|
|
108490
108490
|
helperExpression: function helperExpression(node) {
|
|
108491
108491
|
return node.type === "SubExpression" || (node.type === "MustacheStatement" || node.type === "BlockStatement") && !!(node.params && node.params.length || node.hash);
|
|
108492
108492
|
},
|
|
108493
|
-
scopedId: function scopedId(
|
|
108494
|
-
return /^\.|this\b/.test(
|
|
108493
|
+
scopedId: function scopedId(path3) {
|
|
108494
|
+
return /^\.|this\b/.test(path3.original);
|
|
108495
108495
|
},
|
|
108496
|
-
simpleId: function simpleId(
|
|
108497
|
-
return
|
|
108496
|
+
simpleId: function simpleId(path3) {
|
|
108497
|
+
return path3.parts.length === 1 && !AST.helpers.scopedId(path3) && !path3.depth;
|
|
108498
108498
|
}
|
|
108499
108499
|
}
|
|
108500
108500
|
};
|
|
@@ -109546,12 +109546,12 @@ var require_helpers3 = __commonJS((exports) => {
|
|
|
109546
109546
|
loc
|
|
109547
109547
|
};
|
|
109548
109548
|
};
|
|
109549
|
-
var prepareMustache = function(
|
|
109549
|
+
var prepareMustache = function(path3, params, hash, open, strip, locInfo) {
|
|
109550
109550
|
var escapeFlag = open.charAt(3) || open.charAt(2), escaped = escapeFlag !== "{" && escapeFlag !== "&";
|
|
109551
109551
|
var decorator = /\*/.test(open);
|
|
109552
109552
|
return {
|
|
109553
109553
|
type: decorator ? "Decorator" : "MustacheStatement",
|
|
109554
|
-
path:
|
|
109554
|
+
path: path3,
|
|
109555
109555
|
params,
|
|
109556
109556
|
hash,
|
|
109557
109557
|
escaped,
|
|
@@ -109907,9 +109907,9 @@ var require_compiler = __commonJS((exports) => {
|
|
|
109907
109907
|
},
|
|
109908
109908
|
DecoratorBlock: function DecoratorBlock(decorator) {
|
|
109909
109909
|
var program = decorator.program && this.compileProgram(decorator.program);
|
|
109910
|
-
var params = this.setupFullMustacheParams(decorator, program, undefined),
|
|
109910
|
+
var params = this.setupFullMustacheParams(decorator, program, undefined), path3 = decorator.path;
|
|
109911
109911
|
this.useDecorators = true;
|
|
109912
|
-
this.opcode("registerDecorator", params.length,
|
|
109912
|
+
this.opcode("registerDecorator", params.length, path3.original);
|
|
109913
109913
|
},
|
|
109914
109914
|
PartialStatement: function PartialStatement(partial) {
|
|
109915
109915
|
this.usePartial = true;
|
|
@@ -109973,46 +109973,46 @@ var require_compiler = __commonJS((exports) => {
|
|
|
109973
109973
|
}
|
|
109974
109974
|
},
|
|
109975
109975
|
ambiguousSexpr: function ambiguousSexpr(sexpr, program, inverse) {
|
|
109976
|
-
var
|
|
109977
|
-
this.opcode("getContext",
|
|
109976
|
+
var path3 = sexpr.path, name = path3.parts[0], isBlock = program != null || inverse != null;
|
|
109977
|
+
this.opcode("getContext", path3.depth);
|
|
109978
109978
|
this.opcode("pushProgram", program);
|
|
109979
109979
|
this.opcode("pushProgram", inverse);
|
|
109980
|
-
|
|
109981
|
-
this.accept(
|
|
109980
|
+
path3.strict = true;
|
|
109981
|
+
this.accept(path3);
|
|
109982
109982
|
this.opcode("invokeAmbiguous", name, isBlock);
|
|
109983
109983
|
},
|
|
109984
109984
|
simpleSexpr: function simpleSexpr(sexpr) {
|
|
109985
|
-
var
|
|
109986
|
-
|
|
109987
|
-
this.accept(
|
|
109985
|
+
var path3 = sexpr.path;
|
|
109986
|
+
path3.strict = true;
|
|
109987
|
+
this.accept(path3);
|
|
109988
109988
|
this.opcode("resolvePossibleLambda");
|
|
109989
109989
|
},
|
|
109990
109990
|
helperSexpr: function helperSexpr(sexpr, program, inverse) {
|
|
109991
|
-
var params = this.setupFullMustacheParams(sexpr, program, inverse),
|
|
109991
|
+
var params = this.setupFullMustacheParams(sexpr, program, inverse), path3 = sexpr.path, name = path3.parts[0];
|
|
109992
109992
|
if (this.options.knownHelpers[name]) {
|
|
109993
109993
|
this.opcode("invokeKnownHelper", params.length, name);
|
|
109994
109994
|
} else if (this.options.knownHelpersOnly) {
|
|
109995
109995
|
throw new _exception2["default"]("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
|
|
109996
109996
|
} else {
|
|
109997
|
-
|
|
109998
|
-
|
|
109999
|
-
this.accept(
|
|
110000
|
-
this.opcode("invokeHelper", params.length,
|
|
109997
|
+
path3.strict = true;
|
|
109998
|
+
path3.falsy = true;
|
|
109999
|
+
this.accept(path3);
|
|
110000
|
+
this.opcode("invokeHelper", params.length, path3.original, _ast2["default"].helpers.simpleId(path3));
|
|
110001
110001
|
}
|
|
110002
110002
|
},
|
|
110003
|
-
PathExpression: function PathExpression(
|
|
110004
|
-
this.addDepth(
|
|
110005
|
-
this.opcode("getContext",
|
|
110006
|
-
var name =
|
|
110003
|
+
PathExpression: function PathExpression(path3) {
|
|
110004
|
+
this.addDepth(path3.depth);
|
|
110005
|
+
this.opcode("getContext", path3.depth);
|
|
110006
|
+
var name = path3.parts[0], scoped = _ast2["default"].helpers.scopedId(path3), blockParamId = !path3.depth && !scoped && this.blockParamIndex(name);
|
|
110007
110007
|
if (blockParamId) {
|
|
110008
|
-
this.opcode("lookupBlockParam", blockParamId,
|
|
110008
|
+
this.opcode("lookupBlockParam", blockParamId, path3.parts);
|
|
110009
110009
|
} else if (!name) {
|
|
110010
110010
|
this.opcode("pushContext");
|
|
110011
|
-
} else if (
|
|
110011
|
+
} else if (path3.data) {
|
|
110012
110012
|
this.options.data = true;
|
|
110013
|
-
this.opcode("lookupData",
|
|
110013
|
+
this.opcode("lookupData", path3.depth, path3.parts, path3.strict);
|
|
110014
110014
|
} else {
|
|
110015
|
-
this.opcode("lookupOnContext",
|
|
110015
|
+
this.opcode("lookupOnContext", path3.parts, path3.falsy, path3.strict, scoped);
|
|
110016
110016
|
}
|
|
110017
110017
|
},
|
|
110018
110018
|
StringLiteral: function StringLiteral(string) {
|
|
@@ -110273,16 +110273,16 @@ var require_util2 = __commonJS((exports) => {
|
|
|
110273
110273
|
return url;
|
|
110274
110274
|
};
|
|
110275
110275
|
var normalize = function(aPath) {
|
|
110276
|
-
var
|
|
110276
|
+
var path3 = aPath;
|
|
110277
110277
|
var url = urlParse(aPath);
|
|
110278
110278
|
if (url) {
|
|
110279
110279
|
if (!url.path) {
|
|
110280
110280
|
return aPath;
|
|
110281
110281
|
}
|
|
110282
|
-
|
|
110282
|
+
path3 = url.path;
|
|
110283
110283
|
}
|
|
110284
|
-
var isAbsolute = exports.isAbsolute(
|
|
110285
|
-
var parts =
|
|
110284
|
+
var isAbsolute = exports.isAbsolute(path3);
|
|
110285
|
+
var parts = path3.split(/\/+/);
|
|
110286
110286
|
for (var part, up = 0, i = parts.length - 1;i >= 0; i--) {
|
|
110287
110287
|
part = parts[i];
|
|
110288
110288
|
if (part === ".") {
|
|
@@ -110299,15 +110299,15 @@ var require_util2 = __commonJS((exports) => {
|
|
|
110299
110299
|
}
|
|
110300
110300
|
}
|
|
110301
110301
|
}
|
|
110302
|
-
|
|
110303
|
-
if (
|
|
110304
|
-
|
|
110302
|
+
path3 = parts.join("/");
|
|
110303
|
+
if (path3 === "") {
|
|
110304
|
+
path3 = isAbsolute ? "/" : ".";
|
|
110305
110305
|
}
|
|
110306
110306
|
if (url) {
|
|
110307
|
-
url.path =
|
|
110307
|
+
url.path = path3;
|
|
110308
110308
|
return urlGenerate(url);
|
|
110309
110309
|
}
|
|
110310
|
-
return
|
|
110310
|
+
return path3;
|
|
110311
110311
|
};
|
|
110312
110312
|
var join = function(aRoot, aPath) {
|
|
110313
110313
|
if (aRoot === "") {
|
|
@@ -112857,8 +112857,8 @@ var require_printer = __commonJS((exports) => {
|
|
|
112857
112857
|
return this.accept(sexpr.path) + " " + params + hash;
|
|
112858
112858
|
};
|
|
112859
112859
|
PrintVisitor.prototype.PathExpression = function(id) {
|
|
112860
|
-
var
|
|
112861
|
-
return (id.data ? "@" : "") + "PATH:" +
|
|
112860
|
+
var path3 = id.parts.join("/");
|
|
112861
|
+
return (id.data ? "@" : "") + "PATH:" + path3;
|
|
112862
112862
|
};
|
|
112863
112863
|
PrintVisitor.prototype.StringLiteral = function(string) {
|
|
112864
112864
|
return '"' + string.value + '"';
|
|
@@ -112890,8 +112890,8 @@ var require_printer = __commonJS((exports) => {
|
|
|
112890
112890
|
// node_modules/handlebars/lib/index.js
|
|
112891
112891
|
var require_lib10 = __commonJS((exports, module) => {
|
|
112892
112892
|
var extension = function(module2, filename) {
|
|
112893
|
-
var
|
|
112894
|
-
var templateString =
|
|
112893
|
+
var fs5 = __require("fs");
|
|
112894
|
+
var templateString = fs5.readFileSync(filename, "utf8");
|
|
112895
112895
|
module2.exports = handlebars.compile(templateString);
|
|
112896
112896
|
};
|
|
112897
112897
|
var handlebars = require_handlebars()["default"];
|
|
@@ -113646,6 +113646,9 @@ import path from "path";
|
|
|
113646
113646
|
|
|
113647
113647
|
// src/utils/TokenGenerator.ts
|
|
113648
113648
|
var import_jsonwebtoken = __toESM(require_jsonwebtoken(), 1);
|
|
113649
|
+
function generate(payload) {
|
|
113650
|
+
return import_jsonwebtoken.default.sign(payload, SECRET_KEY, { expiresIn: EXPIRY, issuer: ISSUER });
|
|
113651
|
+
}
|
|
113649
113652
|
function verify(token) {
|
|
113650
113653
|
let decoded = import_jsonwebtoken.default.verify(token, SECRET_KEY);
|
|
113651
113654
|
if (decoded.iss !== ISSUER) {
|
|
@@ -113653,6 +113656,16 @@ function verify(token) {
|
|
|
113653
113656
|
}
|
|
113654
113657
|
return decoded;
|
|
113655
113658
|
}
|
|
113659
|
+
function decode(val2) {
|
|
113660
|
+
let token = "";
|
|
113661
|
+
if (typeof val2 !== "string") {
|
|
113662
|
+
token = val2.headers["access-token"];
|
|
113663
|
+
} else {
|
|
113664
|
+
token = val2;
|
|
113665
|
+
}
|
|
113666
|
+
let decoded = import_jsonwebtoken.default.decode(token);
|
|
113667
|
+
return decoded;
|
|
113668
|
+
}
|
|
113656
113669
|
var SECRET_KEY = process.env.JWT_SECRET_KEY ? process.env.JWT_SECRET_KEY : "your-secret-key-here";
|
|
113657
113670
|
var EXPIRY = process.env.JWT_EXPIRY ? process.env.JWT_EXPIRY : "30 days";
|
|
113658
113671
|
var ISSUER = process.env.JWT_ISSUER ? process.env.JWT_ISSUER : "*.service";
|
|
@@ -113691,10 +113704,12 @@ class RouterFactory {
|
|
|
113691
113704
|
}
|
|
113692
113705
|
static authenticate(req, res, next, grantPublicAccess = false) {
|
|
113693
113706
|
try {
|
|
113707
|
+
console.log("req.body", req.body);
|
|
113694
113708
|
let bearerToken = req.headers.authorization;
|
|
113695
113709
|
if (bearerToken && bearerToken != null && bearerToken != "null") {
|
|
113696
113710
|
const token = bearerToken.split(" ")[1];
|
|
113697
113711
|
let decoded = verify(token);
|
|
113712
|
+
console.log("decoded", decoded);
|
|
113698
113713
|
} else if (!grantPublicAccess)
|
|
113699
113714
|
return res.status(401).send({ success: false, error: 1004, errorMessage: "Unauthorized. No access token found on the request." });
|
|
113700
113715
|
next();
|
|
@@ -113707,62 +113722,6 @@ class RouterFactory {
|
|
|
113707
113722
|
}
|
|
113708
113723
|
}
|
|
113709
113724
|
|
|
113710
|
-
// src/utils/WebSocketServer.ts
|
|
113711
|
-
import fs3 from "node:fs";
|
|
113712
|
-
import path2 from "node:path";
|
|
113713
|
-
class WebSocketServer {
|
|
113714
|
-
constructor(port = 5001, dir, folder = "sockets") {
|
|
113715
|
-
let handlers = [];
|
|
113716
|
-
let fullDir = path2.join(dir, folder);
|
|
113717
|
-
fs3.readdirSync(fullDir).forEach((file) => {
|
|
113718
|
-
if (file.toLowerCase().indexOf(".ts")) {
|
|
113719
|
-
let filePath = path2.join(fullDir, file);
|
|
113720
|
-
import(filePath).then((handlerClass) => {
|
|
113721
|
-
let path3 = file.replace(".ts", "");
|
|
113722
|
-
let handler = new handlerClass.default;
|
|
113723
|
-
handlers.push({ path: path3, handler });
|
|
113724
|
-
});
|
|
113725
|
-
}
|
|
113726
|
-
});
|
|
113727
|
-
Bun.serve({
|
|
113728
|
-
port,
|
|
113729
|
-
async fetch(req, server) {
|
|
113730
|
-
const url = new URL(req.url);
|
|
113731
|
-
let websocket = handlers.find((rec) => rec.path === url.pathname.replaceAll("/", ""));
|
|
113732
|
-
if (websocket) {
|
|
113733
|
-
await websocket.handler.upgrade(req, server);
|
|
113734
|
-
return;
|
|
113735
|
-
}
|
|
113736
|
-
return new Response("Upgrade failed :(", { status: 500 });
|
|
113737
|
-
},
|
|
113738
|
-
websocket: {
|
|
113739
|
-
async message(ws, message) {
|
|
113740
|
-
let websocket = handlers.find((rec) => rec.path === "echo");
|
|
113741
|
-
if (websocket) {
|
|
113742
|
-
await websocket.handler.accept(ws, message);
|
|
113743
|
-
return;
|
|
113744
|
-
}
|
|
113745
|
-
},
|
|
113746
|
-
async open(ws) {
|
|
113747
|
-
let websocket = handlers.find((rec) => rec.path === "echo");
|
|
113748
|
-
if (websocket) {
|
|
113749
|
-
await websocket.handler.connect(ws);
|
|
113750
|
-
return;
|
|
113751
|
-
}
|
|
113752
|
-
},
|
|
113753
|
-
async close(ws, code, reason) {
|
|
113754
|
-
let websocket = handlers.find((rec) => rec.path === "echo");
|
|
113755
|
-
if (websocket) {
|
|
113756
|
-
websocket.handler.disconnect(ws, code, reason);
|
|
113757
|
-
return;
|
|
113758
|
-
}
|
|
113759
|
-
}
|
|
113760
|
-
}
|
|
113761
|
-
});
|
|
113762
|
-
Logger.info(`Web Socket Sever ready at: http://127.0.0.1:${port}\n`);
|
|
113763
|
-
}
|
|
113764
|
-
}
|
|
113765
|
-
|
|
113766
113725
|
// node_modules/minio/dist/esm/minio.mjs
|
|
113767
113726
|
var import_async = __toESM(require_async(), 1);
|
|
113768
113727
|
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
@@ -113953,14 +113912,14 @@ import * as crypto from "crypto";
|
|
|
113953
113912
|
import * as stream2 from "stream";
|
|
113954
113913
|
|
|
113955
113914
|
// node_modules/minio/dist/esm/internal/async.mjs
|
|
113956
|
-
import * as
|
|
113915
|
+
import * as fs3 from "fs";
|
|
113957
113916
|
import * as stream from "stream";
|
|
113958
113917
|
import {promisify} from "util";
|
|
113959
113918
|
import {promises} from "node:fs";
|
|
113960
113919
|
var streamPromise = {
|
|
113961
113920
|
pipeline: promisify(stream.pipeline)
|
|
113962
113921
|
};
|
|
113963
|
-
var fstat2 = promisify(
|
|
113922
|
+
var fstat2 = promisify(fs3.fstat);
|
|
113964
113923
|
|
|
113965
113924
|
// node_modules/minio/dist/esm/internal/type.mjs
|
|
113966
113925
|
var ENCRYPTION_TYPES = function(ENCRYPTION_TYPES2) {
|
|
@@ -114044,8 +114003,8 @@ function isValidDomain(host) {
|
|
|
114044
114003
|
}
|
|
114045
114004
|
return true;
|
|
114046
114005
|
}
|
|
114047
|
-
function probeContentType(
|
|
114048
|
-
let contentType = mime.lookup(
|
|
114006
|
+
function probeContentType(path2) {
|
|
114007
|
+
let contentType = mime.lookup(path2);
|
|
114049
114008
|
if (!contentType) {
|
|
114050
114009
|
contentType = "application/octet-stream";
|
|
114051
114010
|
}
|
|
@@ -114512,10 +114471,10 @@ var import_block_stream2 = __toESM(require_block_stream2(), 1);
|
|
|
114512
114471
|
var import_browser_or_node = __toESM(require_lib9(), 1);
|
|
114513
114472
|
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
114514
114473
|
import * as crypto3 from "crypto";
|
|
114515
|
-
import * as
|
|
114474
|
+
import * as fs4 from "fs";
|
|
114516
114475
|
import * as http from "http";
|
|
114517
114476
|
import * as https from "https";
|
|
114518
|
-
import * as
|
|
114477
|
+
import * as path2 from "path";
|
|
114519
114478
|
import * as stream4 from "stream";
|
|
114520
114479
|
var import_xml2js = __toESM(require_xml2js(), 1);
|
|
114521
114480
|
|
|
@@ -114598,11 +114557,11 @@ class CredentialProvider {
|
|
|
114598
114557
|
|
|
114599
114558
|
// node_modules/minio/dist/esm/signing.mjs
|
|
114600
114559
|
import * as crypto2 from "crypto";
|
|
114601
|
-
var getCanonicalRequest = function(method,
|
|
114560
|
+
var getCanonicalRequest = function(method, path2, headers, signedHeaders, hashedPayload) {
|
|
114602
114561
|
if (!isString(method)) {
|
|
114603
114562
|
throw new TypeError('method should be of type "string"');
|
|
114604
114563
|
}
|
|
114605
|
-
if (!isString(
|
|
114564
|
+
if (!isString(path2)) {
|
|
114606
114565
|
throw new TypeError('path should be of type "string"');
|
|
114607
114566
|
}
|
|
114608
114567
|
if (!isObject(headers)) {
|
|
@@ -114619,8 +114578,8 @@ var getCanonicalRequest = function(method, path3, headers, signedHeaders, hashed
|
|
|
114619
114578
|
acc.push(`${i.toLowerCase()}:${val2}`);
|
|
114620
114579
|
return acc;
|
|
114621
114580
|
}, []);
|
|
114622
|
-
const requestResource =
|
|
114623
|
-
let requestQuery =
|
|
114581
|
+
const requestResource = path2.split("?")[0];
|
|
114582
|
+
let requestQuery = path2.split("?")[1];
|
|
114624
114583
|
if (!requestQuery) {
|
|
114625
114584
|
requestQuery = "";
|
|
114626
114585
|
}
|
|
@@ -114769,12 +114728,12 @@ function presignSignatureV4(request, accessKey, secretKey, sessionToken, region,
|
|
|
114769
114728
|
} else {
|
|
114770
114729
|
query = requestQuery.join("&");
|
|
114771
114730
|
}
|
|
114772
|
-
const
|
|
114773
|
-
const canonicalRequest = getCanonicalRequest(request.method,
|
|
114731
|
+
const path2 = resource + "?" + query;
|
|
114732
|
+
const canonicalRequest = getCanonicalRequest(request.method, path2, request.headers, signedHeaders, hashedPayload);
|
|
114774
114733
|
const stringToSign = getStringToSign(canonicalRequest, requestDate, region);
|
|
114775
114734
|
const signingKey = getSigningKey(requestDate, region, secretKey);
|
|
114776
114735
|
const signature = crypto2.createHmac("sha256", signingKey).update(stringToSign).digest("hex").toLowerCase();
|
|
114777
|
-
return request.protocol + "//" + request.headers.host +
|
|
114736
|
+
return request.protocol + "//" + request.headers.host + path2 + `&X-Amz-Signature=${signature}`;
|
|
114778
114737
|
}
|
|
114779
114738
|
var signV4Algorithm = "AWS4-HMAC-SHA256";
|
|
114780
114739
|
|
|
@@ -115825,7 +115784,7 @@ class TypedClient {
|
|
|
115825
115784
|
if (bucketName) {
|
|
115826
115785
|
virtualHostStyle = isVirtualHostStyle(this.host, this.protocol, bucketName, this.pathStyle);
|
|
115827
115786
|
}
|
|
115828
|
-
let
|
|
115787
|
+
let path3 = "/";
|
|
115829
115788
|
let host = this.host;
|
|
115830
115789
|
let port;
|
|
115831
115790
|
if (this.port) {
|
|
@@ -115847,18 +115806,18 @@ class TypedClient {
|
|
|
115847
115806
|
host = `${bucketName}.${host}`;
|
|
115848
115807
|
}
|
|
115849
115808
|
if (objectName) {
|
|
115850
|
-
|
|
115809
|
+
path3 = `/${objectName}`;
|
|
115851
115810
|
}
|
|
115852
115811
|
} else {
|
|
115853
115812
|
if (bucketName) {
|
|
115854
|
-
|
|
115813
|
+
path3 = `/${bucketName}`;
|
|
115855
115814
|
}
|
|
115856
115815
|
if (objectName) {
|
|
115857
|
-
|
|
115816
|
+
path3 = `/${bucketName}/${objectName}`;
|
|
115858
115817
|
}
|
|
115859
115818
|
}
|
|
115860
115819
|
if (query) {
|
|
115861
|
-
|
|
115820
|
+
path3 += `?${query}`;
|
|
115862
115821
|
}
|
|
115863
115822
|
reqOptions.headers.host = host;
|
|
115864
115823
|
if (reqOptions.protocol === "http:" && port !== 80 || reqOptions.protocol === "https:" && port !== 443) {
|
|
@@ -115876,7 +115835,7 @@ class TypedClient {
|
|
|
115876
115835
|
headers: import_lodash2.default.mapValues(import_lodash2.default.pickBy(reqOptions.headers, isDefined), (v) => v.toString()),
|
|
115877
115836
|
host,
|
|
115878
115837
|
port,
|
|
115879
|
-
path:
|
|
115838
|
+
path: path3
|
|
115880
115839
|
};
|
|
115881
115840
|
}
|
|
115882
115841
|
async setCredentialsProvider(credentialsProvider) {
|
|
@@ -116255,7 +116214,7 @@ class TypedClient {
|
|
|
116255
116214
|
let partFileStream;
|
|
116256
116215
|
const objStat = await this.statObject(bucketName, objectName, getOpts);
|
|
116257
116216
|
const partFile2 = `${filePath}.${objStat.etag}.part.minio`;
|
|
116258
|
-
await promises.mkdir(
|
|
116217
|
+
await promises.mkdir(path2.dirname(filePath), {
|
|
116259
116218
|
recursive: true
|
|
116260
116219
|
});
|
|
116261
116220
|
let offset = 0;
|
|
@@ -116265,12 +116224,12 @@ class TypedClient {
|
|
|
116265
116224
|
return partFile2;
|
|
116266
116225
|
}
|
|
116267
116226
|
offset = stats2.size;
|
|
116268
|
-
partFileStream =
|
|
116227
|
+
partFileStream = fs4.createWriteStream(partFile2, {
|
|
116269
116228
|
flags: "a"
|
|
116270
116229
|
});
|
|
116271
116230
|
} catch (e) {
|
|
116272
116231
|
if (e instanceof Error && e.code === "ENOENT") {
|
|
116273
|
-
partFileStream =
|
|
116232
|
+
partFileStream = fs4.createWriteStream(partFile2, {
|
|
116274
116233
|
flags: "w"
|
|
116275
116234
|
});
|
|
116276
116235
|
} else {
|
|
@@ -116652,7 +116611,7 @@ class TypedClient {
|
|
|
116652
116611
|
}
|
|
116653
116612
|
metaData = insertContentType(metaData, filePath);
|
|
116654
116613
|
const stat = await promises.lstat(filePath);
|
|
116655
|
-
await this.putObject(bucketName, objectName,
|
|
116614
|
+
await this.putObject(bucketName, objectName, fs4.createReadStream(filePath), stat.size, metaData);
|
|
116656
116615
|
}
|
|
116657
116616
|
async putObject(bucketName, objectName, stream5, size, metaData) {
|
|
116658
116617
|
if (!isValidBucketName(bucketName)) {
|
|
@@ -119013,11 +118972,11 @@ class Uploader {
|
|
|
119013
118972
|
const file = files[index2];
|
|
119014
118973
|
let filename = file.name.replace(/ /g, "_");
|
|
119015
118974
|
let newName = new Date;
|
|
119016
|
-
let
|
|
118975
|
+
let path3 = `/${bucket}/${dir}/${newName.getTime()}`;
|
|
119017
118976
|
let etag = await Uploader.client.putObject(bucket, `${dir}/${newName.getTime()}`, file.data, file.size, { "Content-type": file.mimetype });
|
|
119018
118977
|
response4.push({
|
|
119019
118978
|
etag,
|
|
119020
|
-
path:
|
|
118979
|
+
path: path3,
|
|
119021
118980
|
bucket,
|
|
119022
118981
|
directory: dir,
|
|
119023
118982
|
objectName: filename,
|
|
@@ -119045,7 +119004,7 @@ class Uploader {
|
|
|
119045
119004
|
// src/utils/Mailer.ts
|
|
119046
119005
|
var import_nodemailer = __toESM(require_nodemailer(), 1);
|
|
119047
119006
|
var import_handlebars = __toESM(require_lib10(), 1);
|
|
119048
|
-
import
|
|
119007
|
+
import fs5 from "fs";
|
|
119049
119008
|
class Mailer {
|
|
119050
119009
|
static instance;
|
|
119051
119010
|
transporter;
|
|
@@ -119121,7 +119080,7 @@ class Mailer {
|
|
|
119121
119080
|
}
|
|
119122
119081
|
findTemplate(name) {
|
|
119123
119082
|
return new Promise((resolve, reject) => {
|
|
119124
|
-
|
|
119083
|
+
fs5.readFile(`${this.LOCAL_DIR}${name}.html`, { encoding: "utf-8" }, (err, html) => {
|
|
119125
119084
|
if (err) {
|
|
119126
119085
|
reject(err);
|
|
119127
119086
|
} else {
|
|
@@ -119132,6 +119091,62 @@ class Mailer {
|
|
|
119132
119091
|
}
|
|
119133
119092
|
}
|
|
119134
119093
|
|
|
119094
|
+
// src/utils/WebsocketServer.ts
|
|
119095
|
+
import fs6 from "node:fs";
|
|
119096
|
+
import path3 from "node:path";
|
|
119097
|
+
class WebSocketServer {
|
|
119098
|
+
constructor(port = 5001, dir, folder = "sockets") {
|
|
119099
|
+
let handlers = [];
|
|
119100
|
+
let fullDir = path3.join(dir, folder);
|
|
119101
|
+
fs6.readdirSync(fullDir).forEach((file) => {
|
|
119102
|
+
if (file.toLowerCase().indexOf(".ts")) {
|
|
119103
|
+
let filePath = path3.join(fullDir, file);
|
|
119104
|
+
import(filePath).then((handlerClass) => {
|
|
119105
|
+
let path4 = file.replace(".ts", "");
|
|
119106
|
+
let handler = new handlerClass.default;
|
|
119107
|
+
handlers.push({ path: path4, handler });
|
|
119108
|
+
});
|
|
119109
|
+
}
|
|
119110
|
+
});
|
|
119111
|
+
Bun.serve({
|
|
119112
|
+
port,
|
|
119113
|
+
async fetch(req, server) {
|
|
119114
|
+
const url = new URL(req.url);
|
|
119115
|
+
let websocket = handlers.find((rec) => rec.path === url.pathname.replaceAll("/", ""));
|
|
119116
|
+
if (websocket) {
|
|
119117
|
+
await websocket.handler.upgrade(req, server);
|
|
119118
|
+
return;
|
|
119119
|
+
}
|
|
119120
|
+
return new Response("Upgrade failed :(", { status: 500 });
|
|
119121
|
+
},
|
|
119122
|
+
websocket: {
|
|
119123
|
+
async message(ws, message) {
|
|
119124
|
+
let websocket = handlers.find((rec) => rec.path === "echo");
|
|
119125
|
+
if (websocket) {
|
|
119126
|
+
await websocket.handler.accept(ws, message);
|
|
119127
|
+
return;
|
|
119128
|
+
}
|
|
119129
|
+
},
|
|
119130
|
+
async open(ws) {
|
|
119131
|
+
let websocket = handlers.find((rec) => rec.path === "echo");
|
|
119132
|
+
if (websocket) {
|
|
119133
|
+
await websocket.handler.connect(ws);
|
|
119134
|
+
return;
|
|
119135
|
+
}
|
|
119136
|
+
},
|
|
119137
|
+
async close(ws, code, reason) {
|
|
119138
|
+
let websocket = handlers.find((rec) => rec.path === "echo");
|
|
119139
|
+
if (websocket) {
|
|
119140
|
+
websocket.handler.disconnect(ws, code, reason);
|
|
119141
|
+
return;
|
|
119142
|
+
}
|
|
119143
|
+
}
|
|
119144
|
+
}
|
|
119145
|
+
});
|
|
119146
|
+
Logger.info(`Web Socket Sever ready at: http://127.0.0.1:${port}\n`);
|
|
119147
|
+
}
|
|
119148
|
+
}
|
|
119149
|
+
|
|
119135
119150
|
// src/utils/ApplicationServer.ts
|
|
119136
119151
|
class ApplicationServer {
|
|
119137
119152
|
static app;
|
|
@@ -119518,7 +119533,6 @@ class BaseController {
|
|
|
119518
119533
|
try {
|
|
119519
119534
|
await this.beforeCreate(req);
|
|
119520
119535
|
let data = req.body;
|
|
119521
|
-
data.createdById = (req.user || {}).id || null;
|
|
119522
119536
|
let response4 = await this._model?.create(data);
|
|
119523
119537
|
await this.afterCreate(req, response4);
|
|
119524
119538
|
return ResponseHelper(response4);
|
|
@@ -119683,12 +119697,16 @@ var PrivateAccess = (constructor) => {
|
|
|
119683
119697
|
};
|
|
119684
119698
|
};
|
|
119685
119699
|
export {
|
|
119700
|
+
verify,
|
|
119701
|
+
generate,
|
|
119686
119702
|
endpoint,
|
|
119703
|
+
decode,
|
|
119687
119704
|
RouterFactory,
|
|
119688
119705
|
ResponseHelper,
|
|
119689
119706
|
PublicAccess,
|
|
119690
119707
|
PrivateAccess,
|
|
119691
119708
|
ErrorResponseHandler,
|
|
119709
|
+
ErrorHandler,
|
|
119692
119710
|
DatabaseConnector,
|
|
119693
119711
|
ConstructQuery,
|
|
119694
119712
|
BaseSocketHandler,
|