@dsh-plus/secret-env 0.1.32 → 0.1.34
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 +0 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -8
- package/package.json +18 -18
- package/src/api.ts +2 -2
- package/src/client/i18n.ts +0 -2
- package/src/service.ts +4 -6
package/lib/client.js
CHANGED
|
@@ -481,7 +481,6 @@ ${extra}
|
|
|
481
481
|
"command.openPanel": "打开会话变量面板",
|
|
482
482
|
"error.invalid-name": "变量名不合法:大写字母开头,仅字母/数字/下划线,≤64 字符。",
|
|
483
483
|
"error.empty-value": "值不能为空。",
|
|
484
|
-
"error.shadowed": "进程环境中已存在同名变量且优先级更高,写入无效;请先取消该环境变量。",
|
|
485
484
|
"error.conflict": "变量名与其他插件注册的受管变量冲突。",
|
|
486
485
|
"error.no-session": "缺少会话标识,请刷新后重试。",
|
|
487
486
|
"error.method": "请求方法不允许。",
|
|
@@ -542,7 +541,6 @@ ${extra}
|
|
|
542
541
|
"command.openPanel": "Open the session variable panel",
|
|
543
542
|
"error.invalid-name": "Invalid name: start with an uppercase letter; letters/digits/underscore only, ≤64 chars.",
|
|
544
543
|
"error.empty-value": "Value must not be empty.",
|
|
545
|
-
"error.shadowed": "A same-named process environment variable shadows this write; unset it first.",
|
|
546
544
|
"error.conflict": "The variable conflicts with a managed variable registered by another plugin.",
|
|
547
545
|
"error.no-session": "Missing session id; refresh and retry.",
|
|
548
546
|
"error.method": "Method not allowed.",
|
package/lib/index.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ declare class SecretEnvService extends Service {
|
|
|
114
114
|
* 两级屏蔽都在 contributor resolve 时现判,下一条命令即生效。
|
|
115
115
|
*/
|
|
116
116
|
setMask(suffix: string, masked: boolean, sessionId?: string): Promise<void>;
|
|
117
|
-
/**
|
|
117
|
+
/** 写入全局值(空值先行给出结构化错误;其余失败由端点按 internal 上报)。 */
|
|
118
118
|
setGlobal(suffix: string, value: string, description: string): Promise<void>;
|
|
119
119
|
/** 删除全局值与元数据;宿主环境仍有同名变量时回落为继承变量继续纳入。 */
|
|
120
120
|
unsetGlobal(suffix: string): Promise<void>;
|
package/lib/index.js
CHANGED
|
@@ -104,10 +104,10 @@ function readSuffix(raw) {
|
|
|
104
104
|
function readString(raw) {
|
|
105
105
|
return typeof raw === "string" ? raw : "";
|
|
106
106
|
}
|
|
107
|
-
/** 错误 → HTTP 映射(值类错误 400
|
|
107
|
+
/** 错误 → HTTP 映射(值类错误 400,冲突 409,其余 500;均只带错误码与消息)。 */
|
|
108
108
|
function sendError(res, error) {
|
|
109
109
|
if (error instanceof SecretEnvError) {
|
|
110
|
-
sendJson(res, error.code === "
|
|
110
|
+
sendJson(res, error.code === "conflict" ? 409 : 400, {
|
|
111
111
|
ok: false,
|
|
112
112
|
error: error.code,
|
|
113
113
|
message: error.message
|
|
@@ -493,14 +493,10 @@ var SecretEnvService = class extends Service {
|
|
|
493
493
|
if (masked) next.push(suffix);
|
|
494
494
|
if (this.settingsRef !== void 0) await this.settingsRef.update(SETTINGS_NS, { masked: next });
|
|
495
495
|
}
|
|
496
|
-
/**
|
|
496
|
+
/** 写入全局值(空值先行给出结构化错误;其余失败由端点按 internal 上报)。 */
|
|
497
497
|
async setGlobal(suffix, value, description) {
|
|
498
498
|
if (value.length === 0) throw new SecretEnvError("empty-value", "value must not be empty");
|
|
499
|
-
|
|
500
|
-
await this.ctx.credentials.set(credentialRef(envNameOf(suffix)), value);
|
|
501
|
-
} catch (error) {
|
|
502
|
-
throw new SecretEnvError("shadowed", error instanceof Error ? error.message : String(error));
|
|
503
|
-
}
|
|
499
|
+
await this.ctx.credentials.set(credentialRef(envNameOf(suffix)), value);
|
|
504
500
|
const meta = this.currentMeta();
|
|
505
501
|
const next = meta.find((item) => item.name === suffix) === void 0 ? [...meta, {
|
|
506
502
|
name: suffix,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-plus/secret-env",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"description": "dsh-plus service+ui plugin: 密钥环境变量——以 $DSH_VAR_* 变量名向 agent 暴露密钥(全局持久/会话级/一次性),执行期经 dsh-shell-env 原生注入,值不进消息流,不影响缓存率",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -19,27 +19,27 @@
|
|
|
19
19
|
"src"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@dsh-plus/shared": "0.1.
|
|
22
|
+
"@dsh-plus/shared": "0.1.40"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@deepseek-ai/cordis": "^4.0.5-alpha.
|
|
26
|
-
"@deepseek-ai/dsh-credentials": "^0.2.1-alpha.
|
|
27
|
-
"@deepseek-ai/dsh-host-webserver": "^0.2.1-alpha.
|
|
28
|
-
"@deepseek-ai/dsh-settings": "^0.2.1-alpha.
|
|
29
|
-
"@deepseek-ai/dsh-shell-env": "^0.2.1-alpha.
|
|
30
|
-
"@deepseek-ai/schemastery": "^3.18.5-alpha.
|
|
25
|
+
"@deepseek-ai/cordis": "^4.0.5-alpha.2",
|
|
26
|
+
"@deepseek-ai/dsh-credentials": "^0.2.1-alpha.3",
|
|
27
|
+
"@deepseek-ai/dsh-host-webserver": "^0.2.1-alpha.3",
|
|
28
|
+
"@deepseek-ai/dsh-settings": "^0.2.1-alpha.3",
|
|
29
|
+
"@deepseek-ai/dsh-shell-env": "^0.2.1-alpha.3",
|
|
30
|
+
"@deepseek-ai/schemastery": "^3.18.5-alpha.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@deepseek-ai/cordis": "4.0.5-alpha.
|
|
34
|
-
"@deepseek-ai/dsh-client-ui-commands": "0.2.1-alpha.
|
|
35
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.2.1-alpha.
|
|
36
|
-
"@deepseek-ai/dsh-credentials": "0.2.1-alpha.
|
|
37
|
-
"@deepseek-ai/dsh-host-webserver": "0.2.1-alpha.
|
|
38
|
-
"@deepseek-ai/dsh-session": "0.2.1-alpha.
|
|
39
|
-
"@deepseek-ai/dsh-settings": "0.2.1-alpha.
|
|
40
|
-
"@deepseek-ai/dsh-shell-env": "0.2.1-alpha.
|
|
41
|
-
"@deepseek-ai/dsh-tools": "0.2.1-alpha.
|
|
42
|
-
"@deepseek-ai/schemastery": "3.18.5-alpha.
|
|
33
|
+
"@deepseek-ai/cordis": "4.0.5-alpha.2",
|
|
34
|
+
"@deepseek-ai/dsh-client-ui-commands": "0.2.1-alpha.3",
|
|
35
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.1-alpha.3",
|
|
36
|
+
"@deepseek-ai/dsh-credentials": "0.2.1-alpha.3",
|
|
37
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.1-alpha.3",
|
|
38
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.3",
|
|
39
|
+
"@deepseek-ai/dsh-settings": "0.2.1-alpha.3",
|
|
40
|
+
"@deepseek-ai/dsh-shell-env": "0.2.1-alpha.3",
|
|
41
|
+
"@deepseek-ai/dsh-tools": "0.2.1-alpha.3",
|
|
42
|
+
"@deepseek-ai/schemastery": "3.18.5-alpha.2",
|
|
43
43
|
"@types/node": "26.4.0",
|
|
44
44
|
"@types/react": "~18.3.31",
|
|
45
45
|
"react": "^18.2.0"
|
package/src/api.ts
CHANGED
|
@@ -43,10 +43,10 @@ function readString(raw: unknown): string {
|
|
|
43
43
|
return typeof raw === 'string' ? raw : ''
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/** 错误 → HTTP 映射(值类错误 400
|
|
46
|
+
/** 错误 → HTTP 映射(值类错误 400,冲突 409,其余 500;均只带错误码与消息)。 */
|
|
47
47
|
function sendError(res: ServerResponse, error: unknown): void {
|
|
48
48
|
if (error instanceof SecretEnvError) {
|
|
49
|
-
const status = error.code === '
|
|
49
|
+
const status = error.code === 'conflict' ? 409 : 400
|
|
50
50
|
sendJson(res, status, { ok: false, error: error.code, message: error.message })
|
|
51
51
|
return
|
|
52
52
|
}
|
package/src/client/i18n.ts
CHANGED
|
@@ -69,7 +69,6 @@ const ownZh = {
|
|
|
69
69
|
// 错误码
|
|
70
70
|
'error.invalid-name': '变量名不合法:大写字母开头,仅字母/数字/下划线,≤64 字符。',
|
|
71
71
|
'error.empty-value': '值不能为空。',
|
|
72
|
-
'error.shadowed': '进程环境中已存在同名变量且优先级更高,写入无效;请先取消该环境变量。',
|
|
73
72
|
'error.conflict': '变量名与其他插件注册的受管变量冲突。',
|
|
74
73
|
'error.no-session': '缺少会话标识,请刷新后重试。',
|
|
75
74
|
'error.method': '请求方法不允许。',
|
|
@@ -135,7 +134,6 @@ const ownEn = {
|
|
|
135
134
|
'error.invalid-name':
|
|
136
135
|
'Invalid name: start with an uppercase letter; letters/digits/underscore only, ≤64 chars.',
|
|
137
136
|
'error.empty-value': 'Value must not be empty.',
|
|
138
|
-
'error.shadowed': 'A same-named process environment variable shadows this write; unset it first.',
|
|
139
137
|
'error.conflict': 'The variable conflicts with a managed variable registered by another plugin.',
|
|
140
138
|
'error.no-session': 'Missing session id; refresh and retry.',
|
|
141
139
|
'error.method': 'Method not allowed.',
|
package/src/service.ts
CHANGED
|
@@ -277,14 +277,12 @@ export class SecretEnvService extends Service {
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
/**
|
|
280
|
+
/** 写入全局值(空值先行给出结构化错误;其余失败由端点按 internal 上报)。 */
|
|
281
281
|
async setGlobal(suffix: string, value: string, description: string): Promise<void> {
|
|
282
282
|
if (value.length === 0) throw new SecretEnvError('empty-value', 'value must not be empty')
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
throw new SecretEnvError('shadowed', error instanceof Error ? error.message : String(error))
|
|
287
|
-
}
|
|
283
|
+
// 宿主环境同名变量不再遮蔽写入:凭据服务自 0.2.1-alpha.3 起以存值优先,
|
|
284
|
+
// 存值落盘即生效(写入前宿主环境里的同名变量在索引里被显式排除)。
|
|
285
|
+
await this.ctx.credentials.set(credentialRef(envNameOf(suffix)), value)
|
|
288
286
|
const meta = this.currentMeta()
|
|
289
287
|
const existing = meta.find((item) => item.name === suffix)
|
|
290
288
|
const next =
|