@iasiv5/dsh-skins 1.5.30 → 1.5.31

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/client.js CHANGED
@@ -2976,7 +2976,7 @@ ${references.join("\n")}`,
2976
2976
  if (typeof extension !== "string" || !/^[a-z0-9]+$/.test(extension)) {
2977
2977
  throw new RangeError(`builtinAssetUrl: invalid extension ${JSON.stringify(extension)}`);
2978
2978
  }
2979
- const rev = "1.5.30";
2979
+ const rev = "1.5.31";
2980
2980
  return `/dsh-skins/assets/b_${skinId}_${assetKey}.${extension}?v=${rev}`;
2981
2981
  }
2982
2982
 
package/lib/index.js CHANGED
@@ -1183,10 +1183,31 @@ function decodeDisplayName(request) {
1183
1183
  throw codedError("FILENAME_INVALID", "x-filename 不是合法的 encodeURIComponent 输出");
1184
1184
  }
1185
1185
  }
1186
+ function createOfficialRejection(ctx) {
1187
+ return (request) => {
1188
+ let connection, reject;
1189
+ try {
1190
+ connection = ctx?.get?.("connection");
1191
+ reject = connection?.requestRejection;
1192
+ } catch {
1193
+ return void 0;
1194
+ }
1195
+ if (typeof reject !== "function") return void 0;
1196
+ try {
1197
+ return reject.call(connection, { headers: request.headers }) ?? void 0;
1198
+ } catch {
1199
+ return 403;
1200
+ }
1201
+ };
1202
+ }
1186
1203
  function mountPersonalizationRoutes(host, options) {
1187
- const { store, assetsBasePath = "/dsh-skins/assets", trustedHosts = [], serveBuiltinAsset } = options;
1204
+ const { store, assetsBasePath = "/dsh-skins/assets", trustedHosts = [], rejection, serveBuiltinAsset } = options;
1188
1205
  const disposers = [];
1189
1206
  const fence = (request, response) => {
1207
+ if (rejection !== void 0 && rejection(request) !== void 0) {
1208
+ sendJson(response, 403, { error: "trusted DSH Web request required" });
1209
+ return false;
1210
+ }
1190
1211
  if (isTrustedRequest(request, typeof trustedHosts === "function" ? trustedHosts() : trustedHosts)) return true;
1191
1212
  sendJson(response, 403, { error: "trusted DSH Web request required" });
1192
1213
  return false;
@@ -1402,6 +1423,7 @@ function apply(ctx) {
1402
1423
  return mountPersonalizationRoutes(hostContext, {
1403
1424
  store: personalization,
1404
1425
  trustedHosts: () => resolveTrustedHosts(ctx),
1426
+ rejection: createOfficialRejection(ctx),
1405
1427
  serveBuiltinAsset
1406
1428
  });
1407
1429
  }, "dsh-skins: personalization routes");
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@iasiv5/dsh-skins",
3
3
  "description": "DSH Web 皮肤插件:多套品牌皮肤侧栏热切换。",
4
4
  "icon": "./icon.svg",
5
- "version": "1.5.30",
5
+ "version": "1.5.31",
6
6
  "homepage": "https://github.com/iasiv5/dsh-skins#readme",
7
7
  "repository": {
8
8
  "type": "git",