balda-js 0.0.45 → 0.0.46
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/lib/index.cjs +18 -33
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +22 -8
- package/lib/index.d.ts +22 -8
- package/lib/index.js +18 -34
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -2224,6 +2224,8 @@ var commandRegistry = CommandRegistry.getInstance();
|
|
|
2224
2224
|
// src/runtime/native_request.ts
|
|
2225
2225
|
var NativeRequest = class extends Request {
|
|
2226
2226
|
};
|
|
2227
|
+
|
|
2228
|
+
// src/server/http/request.ts
|
|
2227
2229
|
var Request2 = class _Request extends NativeRequest {
|
|
2228
2230
|
static fromRequest(request) {
|
|
2229
2231
|
return new _Request(request.url, {
|
|
@@ -2330,7 +2332,10 @@ var Request2 = class _Request extends NativeRequest {
|
|
|
2330
2332
|
*/
|
|
2331
2333
|
files = [];
|
|
2332
2334
|
/**
|
|
2333
|
-
* The parameters of the request.
|
|
2335
|
+
* The parameters of the request. Can be typed with a generic in the Request object
|
|
2336
|
+
* @example
|
|
2337
|
+
* ```ts
|
|
2338
|
+
* Request<{ id: string }>
|
|
2334
2339
|
*/
|
|
2335
2340
|
params = {};
|
|
2336
2341
|
/**
|
|
@@ -3781,14 +3786,14 @@ var NativeHash = class {
|
|
|
3781
3786
|
const hashBase64 = this.encodeBase64(new Uint8Array(hashBuffer));
|
|
3782
3787
|
return `${saltBase64}:${hashBase64}`;
|
|
3783
3788
|
}
|
|
3784
|
-
async compare(
|
|
3785
|
-
if (!
|
|
3789
|
+
async compare(hash2, data) {
|
|
3790
|
+
if (!hash2 || !data) {
|
|
3786
3791
|
return false;
|
|
3787
3792
|
}
|
|
3788
3793
|
try {
|
|
3789
3794
|
const encoder = new TextEncoder();
|
|
3790
3795
|
const passwordBuffer = encoder.encode(data);
|
|
3791
|
-
const parts =
|
|
3796
|
+
const parts = hash2.split(":");
|
|
3792
3797
|
if (parts.length !== 2) {
|
|
3793
3798
|
throw new Error("Invalid hash format");
|
|
3794
3799
|
}
|
|
@@ -3843,7 +3848,7 @@ var NativeHash = class {
|
|
|
3843
3848
|
return bytes;
|
|
3844
3849
|
}
|
|
3845
3850
|
};
|
|
3846
|
-
var
|
|
3851
|
+
var hash = new NativeHash();
|
|
3847
3852
|
|
|
3848
3853
|
// src/plugins/body_parser/body_parser.ts
|
|
3849
3854
|
var bodyParser = () => {
|
|
@@ -3987,7 +3992,9 @@ var fileParser = (options) => {
|
|
|
3987
3992
|
const indexOfSub = (haystack, needle, from = 0) => {
|
|
3988
3993
|
outer: for (let i = from; i <= haystack.length - needle.length; i++) {
|
|
3989
3994
|
for (let j = 0; j < needle.length; j++) {
|
|
3990
|
-
if (haystack[i + j] !== needle[j])
|
|
3995
|
+
if (haystack[i + j] !== needle[j]) {
|
|
3996
|
+
continue outer;
|
|
3997
|
+
}
|
|
3991
3998
|
}
|
|
3992
3999
|
return i;
|
|
3993
4000
|
}
|
|
@@ -4271,9 +4278,7 @@ var swagger = (globalOptions) => {
|
|
|
4271
4278
|
const uiPath = `${swaggerOptions.path}`;
|
|
4272
4279
|
const jsonPath = `${uiPath}/json`;
|
|
4273
4280
|
let uiContent;
|
|
4274
|
-
if (swaggerOptions.type === "
|
|
4275
|
-
uiContent = generateRedocUI(jsonPath, swaggerOptions);
|
|
4276
|
-
} else if (swaggerOptions.type === "rapidoc") {
|
|
4281
|
+
if (swaggerOptions.type === "rapidoc") {
|
|
4277
4282
|
uiContent = generateRapiDocUI(jsonPath, swaggerOptions);
|
|
4278
4283
|
} else if (swaggerOptions.type === "scalar") {
|
|
4279
4284
|
uiContent = generateScalarUI(jsonPath, swaggerOptions);
|
|
@@ -4572,27 +4577,6 @@ function generateSwaggerUI(specUrl, globalOptions) {
|
|
|
4572
4577
|
</body>
|
|
4573
4578
|
</html>`;
|
|
4574
4579
|
}
|
|
4575
|
-
function generateRedocUI(specUrl, globalOptions) {
|
|
4576
|
-
return `
|
|
4577
|
-
<!DOCTYPE html>
|
|
4578
|
-
<html>
|
|
4579
|
-
<head>
|
|
4580
|
-
<title>${globalOptions.title}</title>
|
|
4581
|
-
<meta charset="utf-8"/>
|
|
4582
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
4583
|
-
<meta name="description" content="${globalOptions.description}" />
|
|
4584
|
-
<link rel="icon" type="image/png" href="https://redocly.github.io/redoc/favicon.ico">
|
|
4585
|
-
<style>
|
|
4586
|
-
body { margin: 0; padding: 0; }
|
|
4587
|
-
</style>
|
|
4588
|
-
</head>
|
|
4589
|
-
<body>
|
|
4590
|
-
<redoc spec-url="${specUrl}"></redoc>
|
|
4591
|
-
<script src="https://unpkg.com/redoc/bundles/redoc.standalone.js"></script>
|
|
4592
|
-
</body>
|
|
4593
|
-
</html>
|
|
4594
|
-
`;
|
|
4595
|
-
}
|
|
4596
4580
|
function generateRapiDocUI(specUrl, globalOptions) {
|
|
4597
4581
|
return `
|
|
4598
4582
|
<!DOCTYPE html>
|
|
@@ -5071,10 +5055,10 @@ var Server = class {
|
|
|
5071
5055
|
return router.getRoutes() || [];
|
|
5072
5056
|
}
|
|
5073
5057
|
async hash(data) {
|
|
5074
|
-
return
|
|
5058
|
+
return hash.hash(data);
|
|
5075
5059
|
}
|
|
5076
|
-
async compareHash(
|
|
5077
|
-
return
|
|
5060
|
+
async compareHash(hash2, data) {
|
|
5061
|
+
return hash.compare(hash2, data);
|
|
5078
5062
|
}
|
|
5079
5063
|
getEnvironment() {
|
|
5080
5064
|
return this.nativeEnv.getEnvironment();
|
|
@@ -5496,6 +5480,7 @@ exports.fileParser = fileParser;
|
|
|
5496
5480
|
exports.flag = flag;
|
|
5497
5481
|
exports.get = get;
|
|
5498
5482
|
exports.getContentType = getContentType;
|
|
5483
|
+
exports.hash = hash;
|
|
5499
5484
|
exports.helmet = helmet;
|
|
5500
5485
|
exports.json = json;
|
|
5501
5486
|
exports.log = log;
|