@agentguardx/helper 0.3.89 → 0.3.90
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/wizard.cjs +8 -1
- package/package.json +7 -7
package/lib/wizard.cjs
CHANGED
|
@@ -45,6 +45,9 @@ async function question(ask, label, masked = false) {
|
|
|
45
45
|
}
|
|
46
46
|
async function choose(ask, label, options, multiple = false) {
|
|
47
47
|
let cursor = 0, selected = new Set();
|
|
48
|
+
// 上一步输入残留的回车(例如粘贴地址时末尾带的换行)会在菜单刚出现时立刻到达,
|
|
49
|
+
// 不能把它当成对默认项的选择;菜单显示后短时间内的回车一律忽略。
|
|
50
|
+
const shownAt = Date.now();
|
|
48
51
|
const render = first => {
|
|
49
52
|
if (!first) process.stdout.write(`\x1b[${options.length}A`);
|
|
50
53
|
options.forEach((option, index) => process.stdout.write(`\x1b[2K\r${cursor === index ? '›' : ' '} ${multiple ? `[${selected.has(index) ? '✓' : ' '}] ` : ''}${option.label}\n`));
|
|
@@ -53,6 +56,7 @@ async function choose(ask, label, options, multiple = false) {
|
|
|
53
56
|
if (key.name === 'up') cursor = (cursor + options.length - 1) % options.length;
|
|
54
57
|
else if (key.name === 'down') cursor = (cursor + 1) % options.length;
|
|
55
58
|
else if (multiple && key.name === 'space') selected.has(cursor) ? selected.delete(cursor) : selected.add(cursor);
|
|
59
|
+
else if ((key.name === 'return' || key.name === 'enter') && Date.now() - shownAt < 300) return;
|
|
56
60
|
else if (key.name === 'return' || key.name === 'enter') { done(multiple ? [...selected].sort().map(i => options[i].value) : options[cursor].value); return; }
|
|
57
61
|
render(false);
|
|
58
62
|
});
|
|
@@ -142,7 +146,10 @@ async function init(runtime, args) {
|
|
|
142
146
|
const choices = [{ label: '浏览器网页授权登录(以控制台当前登录的人授权)', value: 'browser' }, { label: '粘贴个人访问令牌', value: 'token' }];
|
|
143
147
|
let httpFlags = [];
|
|
144
148
|
if (new URL(server).protocol === 'http:') {
|
|
145
|
-
const
|
|
149
|
+
const loopback = ['127.0.0.1', 'localhost', '[::1]'].includes(new URL(server).hostname);
|
|
150
|
+
const consent = loopback ? { acknowledged: true } : await queryConsent(runtime, server, prefix);
|
|
151
|
+
// 本机回环地址不经过网络,没有中间人可读取,不再询问明文风险。
|
|
152
|
+
if (loopback) process.stdout.write('本机地址,不经过网络传输,无需明文风险确认。\n');
|
|
146
153
|
if (!consent.acknowledged) {
|
|
147
154
|
const answer = await choose(ask, 'HTTP 会以明文传输登录信息、个人令牌和业务内容,网络中间人可能读取或篡改。是否确认对该服务器继续?', [
|
|
148
155
|
{ label: '取消,不发送登录信息或令牌', value: false },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentguardx/helper",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.90",
|
|
4
4
|
"description": "AgentGuard \u5458\u5de5\u63a5\u5165\u52a9\u624b",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"engines": {
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"preuninstall": "node lib/preuninstall.cjs"
|
|
20
20
|
},
|
|
21
21
|
"optionalDependencies": {
|
|
22
|
-
"@agentguardx/helper-darwin-x64": "0.3.
|
|
23
|
-
"@agentguardx/helper-darwin-arm64": "0.3.
|
|
24
|
-
"@agentguardx/helper-linux-x64": "0.3.
|
|
25
|
-
"@agentguardx/helper-linux-arm64": "0.3.
|
|
26
|
-
"@agentguardx/helper-win32-x64": "0.3.
|
|
27
|
-
"@agentguardx/helper-win32-arm64": "0.3.
|
|
22
|
+
"@agentguardx/helper-darwin-x64": "0.3.90",
|
|
23
|
+
"@agentguardx/helper-darwin-arm64": "0.3.90",
|
|
24
|
+
"@agentguardx/helper-linux-x64": "0.3.90",
|
|
25
|
+
"@agentguardx/helper-linux-arm64": "0.3.90",
|
|
26
|
+
"@agentguardx/helper-win32-x64": "0.3.90",
|
|
27
|
+
"@agentguardx/helper-win32-arm64": "0.3.90"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|