@capybara-hq/plugin-device-local 0.1.0-rc.5 → 0.1.0-rc.7
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/.capybara-plugin/plugin.json +2 -2
- package/README.md +10 -4
- package/dist/index.mjs +47 -19
- package/guides/connect.md +4 -1
- package/guides/connect.zh.md +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "device-local",
|
|
4
|
-
"version": "0.1.0-rc.
|
|
4
|
+
"version": "0.1.0-rc.7",
|
|
5
5
|
"publisher": "Capybara",
|
|
6
6
|
"description": {
|
|
7
7
|
"en": "Devices on people's own computers: a machine connected with capybara-device serves the device over the dial-in channel, and its owner limits it there",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"entry": "./dist/index.mjs",
|
|
24
24
|
"manifest": {
|
|
25
25
|
"name": "device-local",
|
|
26
|
-
"version": "0.1.0-rc.
|
|
26
|
+
"version": "0.1.0-rc.7",
|
|
27
27
|
"sdk": "^0.1.0-rc.56",
|
|
28
28
|
"provides": [
|
|
29
29
|
"device-provider@1"
|
package/README.md
CHANGED
|
@@ -58,7 +58,9 @@ generation under another runtime identity is refused (`local.invalid_hello`,
|
|
|
58
58
|
- **`report()`** answers from the rows only: a description of the owner's ceiling (project reach
|
|
59
59
|
`machine` / `paths` / `workspace`, always `workspace` in Docker mode; outside the sandbox;
|
|
60
60
|
network) in English and Chinese, the owner's home (OS mode), the machine's own
|
|
61
|
-
narrowing as read-only limits
|
|
61
|
+
narrowing as read-only limits, `reset: false` and `changeHint`: only the computer's owner changes
|
|
62
|
+
the limits, on that computer, with `capybara-device ceiling set -c <device id> …` (the
|
|
63
|
+
connection's real id). Its revision is a hash of everything it is made
|
|
62
64
|
of plus the machine epoch (moved when the machine is revoked or replaced), the instance
|
|
63
65
|
generation, its runtime identity and its stored support; times and connection ids are left out,
|
|
64
66
|
so a reconnect with the same facts keeps it. After a hello or event moved the revision the
|
|
@@ -73,7 +75,10 @@ generation under another runtime identity is refused (`local.invalid_hello`,
|
|
|
73
75
|
may do, so a change calls `ctx.devices.reportChanged` once with the revision kept and the kernel
|
|
74
76
|
stores the new text without invalidating approvals. A stale or conflicting `policy` event never
|
|
75
77
|
changes them; an unreadable summary, or an unreadable list in a readable one, keeps them. The
|
|
76
|
-
line fits as many whole directories as it can, skipping one too long, then
|
|
78
|
+
line fits as many whole directories as it can, skipping one too long, then `+N more` (Chinese:
|
|
79
|
+
`;另有 N 个`) for the rest, within the 60-character limit in each language. Every limit value is
|
|
80
|
+
English and Chinese text (`DeviceReportLimit.value` is `DeviceText`); pure numbers carry English
|
|
81
|
+
only.
|
|
77
82
|
- **Refused project paths.** A machine's `project_refused` outcome becomes
|
|
78
83
|
`ProjectPathRefusedError` with the fixed English and Chinese text of its refusal code
|
|
79
84
|
(`other-connection`, `outside-reach`, `denied`; `PROJECT_REFUSAL_TEXT`): the machine is not
|
|
@@ -81,8 +86,9 @@ generation under another runtime identity is refused (`local.invalid_hello`,
|
|
|
81
86
|
- **`permissionSupport()`** answers from the rows only, never a machine round trip: the support the
|
|
82
87
|
machine attested for the installed binding, with outside-the-sandbox and the open public
|
|
83
88
|
internet narrowed to what the owner allows now (no open public internet while the owner's
|
|
84
|
-
network is an allowlist or the owner facts are blocked or missing)
|
|
85
|
-
|
|
89
|
+
network is an allowlist or the owner facts are blocked or missing), and `limitedBy` naming the
|
|
90
|
+
owner for each crossing the machine attested but the owner keeps closed (so the kernel names the
|
|
91
|
+
owner's limit, not the provider's); closed when no binding is installed or no hello is stored.
|
|
86
92
|
|
|
87
93
|
A handle the machine will never serve again (the device's binding is a newer generation, or the
|
|
88
94
|
machine's last hello did not attest it) still reads its installed support, because the kernel
|
package/dist/index.mjs
CHANGED
|
@@ -186,8 +186,14 @@ var SHARED_LABEL = {
|
|
|
186
186
|
zh: "本机的另一个连接也在使用"
|
|
187
187
|
};
|
|
188
188
|
function sharedRootsValue(roots) {
|
|
189
|
+
return {
|
|
190
|
+
en: fitRoots(roots, (n) => ` +${n} more`),
|
|
191
|
+
zh: fitRoots(roots, (n) => `;另有 ${n} 个`)
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function fitRoots(roots, more) {
|
|
189
195
|
const max = DEVICE_REPORT_LIMITS.limitValueChars;
|
|
190
|
-
const rest = (n) => n > 0 ?
|
|
196
|
+
const rest = (n) => n > 0 ? more(n) : "";
|
|
191
197
|
const kept = [];
|
|
192
198
|
for (const root of roots) {
|
|
193
199
|
const value = `${[...kept, root].join(", ")}${rest(roots.length - kept.length - 1)}`;
|
|
@@ -198,15 +204,15 @@ function sharedRootsValue(roots) {
|
|
|
198
204
|
(best, r) => best === void 0 || r.length < best.length ? r : best,
|
|
199
205
|
void 0
|
|
200
206
|
);
|
|
201
|
-
const
|
|
207
|
+
const left = rest(roots.length - 1);
|
|
202
208
|
const chars = Array.from(shortest ?? "");
|
|
203
209
|
let tail = "";
|
|
204
210
|
for (let i = chars.length - 1; i >= 0; i--) {
|
|
205
211
|
const next = `${chars[i]}${tail}`;
|
|
206
|
-
if (`…${next}${
|
|
212
|
+
if (`…${next}${left}`.length > max) break;
|
|
207
213
|
tail = next;
|
|
208
214
|
}
|
|
209
|
-
return `…${tail}${
|
|
215
|
+
return `…${tail}${left}`;
|
|
210
216
|
}
|
|
211
217
|
var hosts = (n) => n === 1 ? { en: "1 allowed host", zh: "允许 1 个主机" } : { en: `${n} allowed hosts`, zh: `允许 ${n} 个主机` };
|
|
212
218
|
var effectiveReach = (mode, reach) => mode === "docker" ? "workspace" : reach;
|
|
@@ -226,7 +232,10 @@ function describeLocalDevice(c) {
|
|
|
226
232
|
const outside = c.outsideSandbox ? {
|
|
227
233
|
en: "runs outside the sandbox only per approved call",
|
|
228
234
|
zh: "仅在获批的单次调用中在沙箱外运行"
|
|
229
|
-
} : {
|
|
235
|
+
} : {
|
|
236
|
+
en: "the machine's owner keeps every call in the sandbox",
|
|
237
|
+
zh: "本机所有者让每个调用都留在沙箱内"
|
|
238
|
+
};
|
|
230
239
|
return { en: `${reads.en}; ${outside.en}`, zh: `${reads.zh};${outside.zh}` };
|
|
231
240
|
}
|
|
232
241
|
function describe(c, owner) {
|
|
@@ -248,32 +257,47 @@ function describe(c, owner) {
|
|
|
248
257
|
};
|
|
249
258
|
}
|
|
250
259
|
var REACH_VALUE = {
|
|
251
|
-
machine: "machine",
|
|
252
|
-
paths: "listed directories",
|
|
253
|
-
workspace: "workspace"
|
|
260
|
+
machine: { en: "machine", zh: "整台机器" },
|
|
261
|
+
paths: { en: "listed directories", zh: "列出的目录" },
|
|
262
|
+
workspace: { en: "workspace", zh: "工作区" }
|
|
263
|
+
};
|
|
264
|
+
var MODE_VALUE = {
|
|
265
|
+
os: { en: "os", zh: "本机系统" },
|
|
266
|
+
docker: { en: "docker", zh: "Docker 容器" }
|
|
267
|
+
};
|
|
268
|
+
var NETWORK_VALUE = {
|
|
269
|
+
open: { en: "open", zh: "开放互联网" },
|
|
270
|
+
allowlist: { en: "allowlist", zh: "白名单" }
|
|
254
271
|
};
|
|
255
272
|
function limitsOf(c, owner) {
|
|
256
273
|
const lines = [
|
|
257
|
-
{ label: { en: "Mode", zh: "模式" }, value: c.mode },
|
|
274
|
+
{ label: { en: "Mode", zh: "模式" }, value: MODE_VALUE[c.mode] },
|
|
258
275
|
{
|
|
259
276
|
label: { en: "Outside the sandbox", zh: "沙箱外运行" },
|
|
260
|
-
value: owner.outsideSandbox ? "per approved call" : "off"
|
|
277
|
+
value: owner.outsideSandbox ? { en: "per approved call", zh: "仅限获批的单次调用" } : { en: "off", zh: "关闭" }
|
|
261
278
|
},
|
|
262
279
|
{
|
|
263
280
|
label: { en: "Project reach", zh: "项目范围" },
|
|
264
281
|
value: REACH_VALUE[effectiveReach(c.mode, owner.projectReach)]
|
|
265
282
|
},
|
|
266
|
-
{ label: { en: "Network", zh: "网络" }, value: owner.network }
|
|
283
|
+
{ label: { en: "Network", zh: "网络" }, value: NETWORK_VALUE[owner.network] }
|
|
267
284
|
];
|
|
268
285
|
if (owner.network === "allowlist")
|
|
269
286
|
lines.push({
|
|
270
287
|
label: { en: "Allowed hosts", zh: "允许的主机" },
|
|
271
|
-
value: String(owner.allowedDomains.length)
|
|
288
|
+
value: { en: String(owner.allowedDomains.length) }
|
|
272
289
|
});
|
|
273
290
|
if (c.sharedProjectRoots.length > 0)
|
|
274
291
|
lines.push({ label: SHARED_LABEL, value: sharedRootsValue(c.sharedProjectRoots) });
|
|
275
292
|
return lines;
|
|
276
293
|
}
|
|
294
|
+
function localChangeHint(deviceId) {
|
|
295
|
+
const command = `capybara-device ceiling set -c ${deviceId} --outside-sandbox on|off --network open|allowlist --project-reach machine|paths|workspace`;
|
|
296
|
+
return {
|
|
297
|
+
en: `Only the owner of the computer changes these limits, on that computer: ${command}`,
|
|
298
|
+
zh: `只有这台电脑的所有者能在电脑上更改这些限制:${command}`
|
|
299
|
+
};
|
|
300
|
+
}
|
|
277
301
|
function deviceReportOf(c, b) {
|
|
278
302
|
const revision = revisionOf(c, b);
|
|
279
303
|
if (!c)
|
|
@@ -295,7 +319,8 @@ function deviceReportOf(c, b) {
|
|
|
295
319
|
home: c.mode === "os" ? c.home : null,
|
|
296
320
|
limits: limitsOf(c, owner),
|
|
297
321
|
// the files are the machine owner's directory: the provider never resets them
|
|
298
|
-
reset: false
|
|
322
|
+
reset: false,
|
|
323
|
+
changeHint: localChangeHint(c.deviceId)
|
|
299
324
|
};
|
|
300
325
|
}
|
|
301
326
|
function supportOf(h, c, b) {
|
|
@@ -307,17 +332,20 @@ function supportOf(h, c, b) {
|
|
|
307
332
|
if (!c)
|
|
308
333
|
return closedSupport("The machine has not said hello yet; connect it with capybara-device");
|
|
309
334
|
const owner = ownerFactsOf(c.ownerReport);
|
|
310
|
-
const attested = b.installed.permissionSupport;
|
|
335
|
+
const { limitedBy: _attested, ...attested } = b.installed.permissionSupport;
|
|
336
|
+
const ownerOpen = owner.state === "report" && owner.network === "open";
|
|
337
|
+
const limitedBy = {
|
|
338
|
+
...attested.outsideSandbox && !owner.outsideSandbox && { outsideSandbox: "owner" },
|
|
339
|
+
...attested.network.openPublic && !ownerOpen && { openPublic: "owner" }
|
|
340
|
+
};
|
|
311
341
|
return parseSandboxPermissionSupport({
|
|
312
342
|
...attested,
|
|
313
343
|
// never wider than the owner allows now (a ceiling change since the binding narrows it)
|
|
314
344
|
outsideSandbox: attested.outsideSandbox && owner.outsideSandbox,
|
|
315
345
|
// the open public internet only while the owner's sandbox network is open (an allowlist, or
|
|
316
346
|
// blocked or missing facts, narrow every command's egress on the machine)
|
|
317
|
-
network: {
|
|
318
|
-
|
|
319
|
-
openPublic: attested.network.openPublic && owner.state === "report" && owner.network === "open"
|
|
320
|
-
}
|
|
347
|
+
network: { ...attested.network, openPublic: attested.network.openPublic && ownerOpen },
|
|
348
|
+
...Object.keys(limitedBy).length > 0 && { limitedBy }
|
|
321
349
|
});
|
|
322
350
|
}
|
|
323
351
|
async function reportFor(store, device) {
|
|
@@ -4921,7 +4949,7 @@ function createDeviceLocalProvider(ctx, store, opts = {}) {
|
|
|
4921
4949
|
// src/index.ts
|
|
4922
4950
|
var plugin = defineExtension({
|
|
4923
4951
|
name: "device-local",
|
|
4924
|
-
version: "0.1.0-rc.
|
|
4952
|
+
version: "0.1.0-rc.7",
|
|
4925
4953
|
// ctx.dialIn.capacity and the handlers' connection argument are the rc.56 SDK's
|
|
4926
4954
|
sdk: "^0.1.0-rc.56",
|
|
4927
4955
|
provides: [DEVICE_PROVIDER_EXTENSION_POINT],
|
package/guides/connect.md
CHANGED
|
@@ -46,7 +46,10 @@ and `login` prints the exact next command, id included, at its end.
|
|
|
46
46
|
Commands run in a sandbox on your computer, inside the device's directory
|
|
47
47
|
(`~/capybara-device/<device id>`). You set the owner ceiling on the computer:
|
|
48
48
|
`capybara-device ceiling show -c <device id>` shows it, `capybara-device ceiling set -c <device id>`
|
|
49
|
-
changes it (running outside the sandbox, the network, project reach); each connection has its own.
|
|
49
|
+
changes it (running outside the sandbox, the network, project reach); each connection has its own.
|
|
50
|
+
A new connection allows running outside the sandbox: a call that asks to is approved as the
|
|
51
|
+
conversation's permission profile decides; `--outside-sandbox off` keeps every call in the sandbox.
|
|
52
|
+
The organization's and the platform's settings apply as
|
|
50
53
|
well; the narrowest wins. In OS mode commands run as your user with no CPU or memory limits.
|
|
51
54
|
|
|
52
55
|
Deleting the device revokes the computer's sign-in and stops the program; the files stay on your
|
package/guides/connect.zh.md
CHANGED
|
@@ -28,7 +28,7 @@ capybara-device service install -c <device id>
|
|
|
28
28
|
|
|
29
29
|
## 它能做什么
|
|
30
30
|
|
|
31
|
-
命令在你电脑上的沙箱里运行,位于设备目录(`~/capybara-device/<设备 id>`)内。你在本机设置所有者上限:`capybara-device ceiling show -c <设备 id>` 查看,`capybara-device ceiling set -c <设备 id>`
|
|
31
|
+
命令在你电脑上的沙箱里运行,位于设备目录(`~/capybara-device/<设备 id>`)内。你在本机设置所有者上限:`capybara-device ceiling show -c <设备 id>` 查看,`capybara-device ceiling set -c <设备 id>` 修改(是否允许在沙箱外运行、网络、项目范围),每个连接各有一份。新连接默认允许在沙箱外运行:请求在沙箱外运行的调用按会话的权限模式审批;`--outside-sandbox off` 让每个调用都留在沙箱内。组织和平台的设置同样生效,以最严格的为准。OS 模式下命令以你的用户身份运行,没有 CPU 和内存限制。
|
|
32
32
|
|
|
33
33
|
删除设备会撤销这台电脑的登录并停止程序,文件仍保留在你的电脑上。
|
|
34
34
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/plugin-device-local",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Devices on people's own computers: a machine connected with capybara-device serves the device over the dial-in channel, and its owner limits it there",
|