@dsh-plus/access-gate 0.2.0 → 0.2.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/lib/client.js +3 -2
- package/lib/index.js +9 -8
- package/package.json +11 -11
- package/src/client/client.ts +1 -1
- package/src/config.ts +2 -3
- package/src/index.ts +10 -6
- package/src/ns.ts +3 -2
package/lib/client.js
CHANGED
|
@@ -350,8 +350,9 @@ ${extra}
|
|
|
350
350
|
//#region src/ns.ts
|
|
351
351
|
/**
|
|
352
352
|
* settings 命名空间字面量(纯常量,零依赖,浏览器半可安全引入)。
|
|
353
|
-
*
|
|
354
|
-
* settings.plugin.item keyed 槽位的
|
|
353
|
+
* 服务端直接以字面量注册(0.1.2-alpha.2 起 dsh-settings 编译期校验命名空间
|
|
354
|
+
* 语法,见 config.ts),浏览器半将其作为 settings.plugin.item keyed 槽位的
|
|
355
|
+
* key —— 同一字面量两处共用,防止漂移。
|
|
355
356
|
* @module access-gate/ns
|
|
356
357
|
*/
|
|
357
358
|
const SETTINGS_NS = "dsh-plus-access-gate";
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Service } from "@deepseek-ai/cordis";
|
|
2
|
-
import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
|
|
3
2
|
import z from "@deepseek-ai/schemastery";
|
|
4
3
|
//#endregion
|
|
5
4
|
//#region src/config.ts
|
|
@@ -15,8 +14,8 @@ import z from "@deepseek-ai/schemastery";
|
|
|
15
14
|
* schemastery 透传忽略,不阻断加载(已实测验证)。
|
|
16
15
|
* @module access-gate/config
|
|
17
16
|
*/
|
|
18
|
-
/** settings
|
|
19
|
-
const SETTINGS_NS =
|
|
17
|
+
/** settings 命名空间(字面量即合法命名空间,0.1.2-alpha.2 起编译期校验;webui 配置卡片与插件运行期读取同一份)。 */
|
|
18
|
+
const SETTINGS_NS = "dsh-plus-access-gate";
|
|
20
19
|
const Config = z.object({
|
|
21
20
|
enabled: z.boolean().description("访问围栏总开关(false = 一切放行,等价插件缺席)").default(false),
|
|
22
21
|
allowedIps: z.array(z.string()).description("附加 IP 围栏:非空时仅白名单条目(精确 IP 或 CIDR,IPv4/IPv6 皆可)可通行与登录;空 = 不限制来源 IP(仅官方登录保护)").default([]),
|
|
@@ -555,11 +554,13 @@ var AccessGateService = class extends Service {
|
|
|
555
554
|
constructor(ctx, config) {
|
|
556
555
|
super(ctx, "accessGate");
|
|
557
556
|
this.current = () => config;
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
557
|
+
ctx.inject(["settings"], (settingsCtx) => {
|
|
558
|
+
settingsCtx.settings.installSection(ctx, SETTINGS_NS, Config, config, {
|
|
559
|
+
setSource: (source) => {
|
|
560
|
+
this.current = source;
|
|
561
|
+
},
|
|
562
|
+
onChange: () => {}
|
|
563
|
+
});
|
|
563
564
|
});
|
|
564
565
|
const logger = ctx.logger("access-gate");
|
|
565
566
|
const officialAuth = (req) => ctx.connection.requestRejection({ headers: req.headers }) === void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-plus/access-gate",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "dsh-plus service+ui plugin: dsh web 全量访问围栏——与官方 browser-auth 合并:官方 cookie 为唯一凭据,可选 IP 附加围栏,未认证导航渲染 token 输入页(PWA 可恢复),loopback 管理通道",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@dsh-plus/shared": "0.1.
|
|
34
|
+
"@dsh-plus/shared": "0.1.7"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
38
|
-
"@deepseek-ai/dsh-home-paths": "^0.1.2-alpha.
|
|
39
|
-
"@deepseek-ai/dsh-settings": "^0.1.2-alpha.
|
|
38
|
+
"@deepseek-ai/dsh-home-paths": "^0.1.2-alpha.2",
|
|
39
|
+
"@deepseek-ai/dsh-settings": "^0.1.2-alpha.2",
|
|
40
40
|
"@deepseek-ai/schemastery": "^3.18.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@deepseek-ai/cordis": "4.0.
|
|
44
|
-
"@deepseek-ai/dsh-client-connection": "0.1.2-alpha.
|
|
45
|
-
"@deepseek-ai/dsh-home-paths": "0.1.2-alpha.
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/dsh-
|
|
48
|
-
"@deepseek-ai/schemastery": "3.18.
|
|
49
|
-
"@types/react": "~18.3.
|
|
43
|
+
"@deepseek-ai/cordis": "4.0.2",
|
|
44
|
+
"@deepseek-ai/dsh-client-connection": "0.1.2-alpha.2",
|
|
45
|
+
"@deepseek-ai/dsh-home-paths": "0.1.2-alpha.2",
|
|
46
|
+
"@deepseek-ai/dsh-host-webserver": "0.1.2-alpha.2",
|
|
47
|
+
"@deepseek-ai/dsh-settings": "0.1.2-alpha.2",
|
|
48
|
+
"@deepseek-ai/schemastery": "3.18.2",
|
|
49
|
+
"@types/react": "~18.3.31",
|
|
50
50
|
"react": "^18.2.0"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
package/src/client/client.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 类型说明:浏览器半只用到 slots/locale/remote 的很窄一面,
|
|
7
7
|
* scope 与基础控件走 @dsh-plus/shared/client 套件(收编自本插件原实现)。
|
|
8
8
|
* 该插槽为 keyed 槽位:key 必须是卡片编辑的 settings 命名空间
|
|
9
|
-
*
|
|
9
|
+
* (即服务端注册的同一字面量,见 ../ns.ts),
|
|
10
10
|
* 官方配置页按此 key 与 Host 已注册命名空间配对分发。
|
|
11
11
|
* 配置读写经 ctx.remote.settings 直连(0.1.2-alpha.1 起 connection.api.settings
|
|
12
12
|
* 已移除;不复用 settingsScope 服务——非 loopback 页面下它固定 memory 模式无数据)。
|
package/src/config.ts
CHANGED
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
* schemastery 透传忽略,不阻断加载(已实测验证)。
|
|
11
11
|
* @module access-gate/config
|
|
12
12
|
*/
|
|
13
|
-
import { settingsNamespace } from '@deepseek-ai/dsh-settings'
|
|
14
13
|
import z from '@deepseek-ai/schemastery'
|
|
15
14
|
|
|
16
15
|
import { SETTINGS_NS as NS_LITERAL } from './ns.ts'
|
|
17
16
|
|
|
18
|
-
/** settings
|
|
19
|
-
export const SETTINGS_NS =
|
|
17
|
+
/** settings 命名空间(字面量即合法命名空间,0.1.2-alpha.2 起编译期校验;webui 配置卡片与插件运行期读取同一份)。 */
|
|
18
|
+
export const SETTINGS_NS = NS_LITERAL
|
|
20
19
|
|
|
21
20
|
export const Config = z.object({
|
|
22
21
|
enabled: z
|
package/src/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ import type { IncomingMessage } from 'node:http'
|
|
|
27
27
|
import { type Context, Service } from '@deepseek-ai/cordis'
|
|
28
28
|
// HostConnectionHandle 的 Context 声明合并(connection 服务类型来源)。
|
|
29
29
|
import type {} from '@deepseek-ai/dsh-client-connection'
|
|
30
|
-
import {
|
|
30
|
+
import type {} from '@deepseek-ai/dsh-settings'
|
|
31
31
|
|
|
32
32
|
import { type AccessGateConfig, Config, SETTINGS_NS } from './config.ts'
|
|
33
33
|
import { type GateWebServer, installGateInterceptor } from './interceptor.ts'
|
|
@@ -52,11 +52,15 @@ export class AccessGateService extends Service {
|
|
|
52
52
|
constructor(ctx: Context, config: AccessGateConfig) {
|
|
53
53
|
super(ctx, 'accessGate')
|
|
54
54
|
this.current = () => config
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
// 官方 installSection 范式(0.1.2-alpha.2):settings 提供方在时以行级 config 为
|
|
56
|
+
// base 注册用户层命名空间,缺席/ detach 时回落行级 config。
|
|
57
|
+
ctx.inject(['settings'], (settingsCtx) => {
|
|
58
|
+
settingsCtx.settings.installSection(ctx, SETTINGS_NS, Config, config, {
|
|
59
|
+
setSource: (source) => {
|
|
60
|
+
this.current = source
|
|
61
|
+
},
|
|
62
|
+
onChange: () => {},
|
|
63
|
+
})
|
|
60
64
|
})
|
|
61
65
|
const logger = ctx.logger('access-gate')
|
|
62
66
|
|
package/src/ns.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* settings 命名空间字面量(纯常量,零依赖,浏览器半可安全引入)。
|
|
3
|
-
*
|
|
4
|
-
* settings.plugin.item keyed 槽位的
|
|
3
|
+
* 服务端直接以字面量注册(0.1.2-alpha.2 起 dsh-settings 编译期校验命名空间
|
|
4
|
+
* 语法,见 config.ts),浏览器半将其作为 settings.plugin.item keyed 槽位的
|
|
5
|
+
* key —— 同一字面量两处共用,防止漂移。
|
|
5
6
|
* @module access-gate/ns
|
|
6
7
|
*/
|
|
7
8
|
export const SETTINGS_NS = 'dsh-plus-access-gate'
|