dsh-zipfix 0.4.0 → 0.4.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 +2 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/plugin/lib/webapi.js +3 -2
- package/ui/index.js +6 -2
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { apply as applyTools } from './plugin/index.js';
|
|
|
10
10
|
import { apply as applyUi } from './ui/index.js';
|
|
11
11
|
|
|
12
12
|
export const name = 'dsh-zipfix';
|
|
13
|
-
export const inject = ['tools'];
|
|
13
|
+
export const inject = ['tools', 'webServer', 'connection'];
|
|
14
14
|
|
|
15
15
|
export function apply(ctx) {
|
|
16
16
|
applyTools(ctx);
|
package/package.json
CHANGED
package/plugin/lib/webapi.js
CHANGED
|
@@ -169,9 +169,9 @@ export function installZipfixWebApi(ctx) {
|
|
|
169
169
|
ctx.logger?.warn?.('zipfix-ui: webServer service unavailable; sidebar API disabled');
|
|
170
170
|
return () => {};
|
|
171
171
|
}
|
|
172
|
-
//
|
|
172
|
+
// 宿主连接认证在每次请求时解析 connection(不要在这里缓存:冷启动时服务可能尚未就绪),
|
|
173
|
+
// 所有路由先过 connection.requestRejection(Host/Origin 围栏 + 浏览器会话认证)。
|
|
173
174
|
// 拿不到 connection 或检查抛错时一律拒绝,绝不退化到「只检查 Host/Origin/回环」。
|
|
174
|
-
const connection = ctx.get('connection');
|
|
175
175
|
|
|
176
176
|
const tempRoot = path.join(os.tmpdir(), 'dsh-zipfix-web');
|
|
177
177
|
const tasks = new Map();
|
|
@@ -230,6 +230,7 @@ export function installZipfixWebApi(ctx) {
|
|
|
230
230
|
* 失败关闭(fail closed):没有 connection 服务、检查抛错、或返回 401/403 都拒绝。
|
|
231
231
|
*/
|
|
232
232
|
function assertAdmitted(req) {
|
|
233
|
+
const connection = ctx.get('connection');
|
|
233
234
|
if (connection === undefined || typeof connection.requestRejection !== 'function') {
|
|
234
235
|
throw new HttpError(403, '宿主认证服务不可用,已拒绝该请求');
|
|
235
236
|
}
|
package/ui/index.js
CHANGED
|
@@ -10,8 +10,12 @@ import { installZipfixWebApi } from '../plugin/lib/webapi.js';
|
|
|
10
10
|
/** Cordis 插件名。 */
|
|
11
11
|
export const name = 'dsh-zipfix-ui';
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* 硬依赖宿主服务,避免冷启动时 webServer/connection 尚未就绪导致静默不注册路由:
|
|
15
|
+
* - webServer:/zipfix-api 路由的注册目标
|
|
16
|
+
* - connection:宿主认证(Host/Origin 围栏 + 浏览器会话)
|
|
17
|
+
*/
|
|
18
|
+
export const inject = ['webServer', 'connection'];
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* 注册 HTTP API,并随插件卸载释放路由与临时目录。
|