dsh-vscode-mode 0.33.0 → 0.33.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/README.md +12 -4
- package/lib/client.excel.js +22 -1
- package/lib/client.js +21 -0
- package/lib/client.js.map +1 -1
- package/lib/index.js +17 -9
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/httpGuard.ts +30 -8
- package/src/routes.ts +1 -1
package/lib/index.js
CHANGED
|
@@ -5346,6 +5346,8 @@ function replyJson(res, status, value) {
|
|
|
5346
5346
|
res.setHeader("cache-control", "no-store");
|
|
5347
5347
|
res.end(JSON.stringify(value));
|
|
5348
5348
|
}
|
|
5349
|
+
/** 围栏异常只报一次:客户端会重试,逐次刷日志只会淹没真正的原因。 */
|
|
5350
|
+
let fenceWarned = false;
|
|
5349
5351
|
/**
|
|
5350
5352
|
* Resolve the legacy Host connection fence, or undefined when the host no longer has one.
|
|
5351
5353
|
* DSH 0.2.3 removed connection.requestRejection: the framework now authorizes a route
|
|
@@ -5356,17 +5358,22 @@ function replyJson(res, status, value) {
|
|
|
5356
5358
|
* @param req Original Node request, including authentication headers.
|
|
5357
5359
|
* @returns The rejection status, or undefined when the host has no legacy fence.
|
|
5358
5360
|
*/
|
|
5359
|
-
function legacyRejection(ctx, req) {
|
|
5360
|
-
let
|
|
5361
|
+
function legacyRejection(ctx, req, warning) {
|
|
5362
|
+
let connection;
|
|
5361
5363
|
try {
|
|
5362
|
-
|
|
5364
|
+
connection = ctx.get("connection");
|
|
5363
5365
|
} catch {
|
|
5364
|
-
|
|
5366
|
+
connection = void 0;
|
|
5365
5367
|
}
|
|
5368
|
+
const reject = connection?.requestRejection;
|
|
5366
5369
|
if (typeof reject !== "function") return void 0;
|
|
5367
5370
|
try {
|
|
5368
|
-
return reject(req);
|
|
5369
|
-
} catch {
|
|
5371
|
+
return reject.call(connection, req);
|
|
5372
|
+
} catch (error) {
|
|
5373
|
+
if (!fenceWarned) {
|
|
5374
|
+
fenceWarned = true;
|
|
5375
|
+
warning?.("兼容性:旧版 connection.requestRejection 调用失败(" + String(error) + ")");
|
|
5376
|
+
}
|
|
5370
5377
|
return 503;
|
|
5371
5378
|
}
|
|
5372
5379
|
}
|
|
@@ -5390,10 +5397,11 @@ function routeAuthMode(ctx) {
|
|
|
5390
5397
|
* @param req Original Node request, including authentication headers.
|
|
5391
5398
|
* @param res Response receiving a refusal when unavailable or unauthorized.
|
|
5392
5399
|
* @param methods Allowed HTTP methods for this route.
|
|
5400
|
+
* @param warning Optional diagnostic sink for a broken legacy fence.
|
|
5393
5401
|
* @returns Whether the request may proceed.
|
|
5394
5402
|
*/
|
|
5395
|
-
function admitRoute(ctx, req, res, methods) {
|
|
5396
|
-
const rejection = legacyRejection(ctx, req);
|
|
5403
|
+
function admitRoute(ctx, req, res, methods, warning) {
|
|
5404
|
+
const rejection = legacyRejection(ctx, req, warning);
|
|
5397
5405
|
if (rejection !== void 0) {
|
|
5398
5406
|
const status = rejection === 401 || rejection === 403 ? rejection : 503;
|
|
5399
5407
|
replyJson(res, status, {
|
|
@@ -7965,7 +7973,7 @@ function assetHandler(directory, prefix, filename) {
|
|
|
7965
7973
|
function mountRoute(ctx, route, warning) {
|
|
7966
7974
|
/** @author ddj 2026年09月28号 @param req Original HTTP request. @param res HTTP response. */
|
|
7967
7975
|
async function guarded(req, res) {
|
|
7968
|
-
if (!admitRoute(ctx, req, res, route.methods)) return;
|
|
7976
|
+
if (!admitRoute(ctx, req, res, route.methods, warning)) return;
|
|
7969
7977
|
try {
|
|
7970
7978
|
await route.handler(req, res);
|
|
7971
7979
|
} catch {
|