@celljs/ta-secrets 4.24.1 → 4.26.0
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.en.md +2 -1
- package/README.md +2 -1
- package/host/index.mjs +162 -41
- package/package.json +3 -3
- package/web/index.js +118 -22
package/README.en.md
CHANGED
|
@@ -12,11 +12,12 @@ A pi package that comes with Ta (on by default, off in Settings → Extensions):
|
|
|
12
12
|
- **SSH**: private keys are held by an ssh-agent of each command that may connect (ssh, scp, rsync, git), never a variable, ended with it.
|
|
13
13
|
- **Lately used**: which secrets each command was given, how, the command and the conversation, in Settings → Vault.
|
|
14
14
|
- **Wiped**: values in tool results and in what goes to the model (as written, base64, URL-encoded) become their names.
|
|
15
|
+
- **With your account**: while devices sync, each goes to your other devices sealed end to end (the class Vault), but those whose "Sync to my devices" you turn off. Other packages keep sign-ins in it too (`TaExtensionHost.credentials`), as the tokens of WeChat and WeCom bots (kept to this device). Opened from Me → Vault.
|
|
15
16
|
|
|
16
17
|
## Data and calls
|
|
17
18
|
|
|
18
19
|
Package data (`@celljs/ta-secrets`): `entries` (`{ name, kind, note?, source, createdAt, usedAt?, uses? }[]`, no values), `capture` (`false`: what you send is not taken), `personal` (`false`: personal details are not taken), `uses` (the latest 100 uses, no values).
|
|
19
20
|
|
|
20
|
-
Methods of the host (`pi.host`), called by the web extension with `callHost`, none giving a value: `info()`, `list()`, `add({ name, value, kind?, note? })`, `remove(name)`, `capturing()`, `setCapturing(on)`, `capturingPersonal()`, `setCapturingPersonal(on)`, `uses()`.
|
|
21
|
+
Methods of the host (`pi.host`), called by the web extension with `callHost`, none giving a value: `info()`, `list()`, `add({ name, value, kind?, note? })`, `remove(name)`, `capturing()`, `setCapturing(on)`, `capturingPersonal()`, `setCapturingPersonal(on)`, `setLocal(name, local)`, `uses()`.
|
|
21
22
|
|
|
22
23
|
Not yet: commands in a folder of a remote host (`ssh://`) do not get values.
|
package/README.md
CHANGED
|
@@ -13,11 +13,12 @@ Ta 自带的 pi 包(默认开启,可在 设置 → 扩展 关闭):保险
|
|
|
13
13
|
- **最近使用**:每次给出密钥都记下哪些、怎么给的、命令和对话,设置 → 保险箱 里能看到。
|
|
14
14
|
- **Ta 自己用的登录**:远程桌面的账号密码由 Ta 服务经 `TaExtensionHost.credentials` 存取(类型 `sign-in`),列在保险箱里可删;不告诉模型,命令里点名会被拒,页面也建不了这一类。
|
|
15
15
|
- **擦**:工具结果和发给模型的内容里出现的值(原文、base64、URL 编码)都换成名字。
|
|
16
|
+
- **跟着账号走**:开着设备同步时,每条默认端到端加密同步到你的其他设备(「保险箱」一类);列表里关掉"同步到我的设备"的只留在这台。别的包也借它存登录(`TaExtensionHost.credentials`),如微信/企业微信机器人的 token(只留本机)。入口在「我」→ 保险箱。
|
|
16
17
|
|
|
17
18
|
## 数据与调用
|
|
18
19
|
|
|
19
20
|
包数据(`@celljs/ta-secrets`):`entries`(`{ name, kind, note?, source, createdAt, usedAt?, uses? }[]`,不含值)、`capture`(`false` 时不收起发出的密钥)、`personal`(`false` 时不收起个人信息)、`uses`(最近 100 次使用,不含值)。
|
|
20
21
|
|
|
21
|
-
包宿主(`pi.host`)的方法,Web 扩展经 `callHost` 调用,都不返回值:`info()`、`list()`、`add({ name, value, kind?, note? })`、`remove(name)`、`capturing()`、`setCapturing(on)`、`capturingPersonal()`、`setCapturingPersonal(on)`、`uses()`。
|
|
22
|
+
包宿主(`pi.host`)的方法,Web 扩展经 `callHost` 调用,都不返回值:`info()`、`list()`、`add({ name, value, kind?, note? })`、`remove(name)`、`capturing()`、`setCapturing(on)`、`capturingPersonal()`、`setCapturingPersonal(on)`、`setLocal(name, local)`、`uses()`。
|
|
22
23
|
|
|
23
24
|
暂不支持:远程主机(`ssh://`)目录里的命令拿不到值。
|
package/host/index.mjs
CHANGED
|
@@ -257,6 +257,48 @@ subjectAltName = ${san}
|
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
+
// web-src/vault-host.ts
|
|
261
|
+
class VaultService {
|
|
262
|
+
vault;
|
|
263
|
+
constructor(vault) {
|
|
264
|
+
this.vault = vault;
|
|
265
|
+
}
|
|
266
|
+
async info() {
|
|
267
|
+
return { store: this.vault.store };
|
|
268
|
+
}
|
|
269
|
+
list() {
|
|
270
|
+
return this.vault.list();
|
|
271
|
+
}
|
|
272
|
+
add(input) {
|
|
273
|
+
const { signIn: _signIn, ...rest } = input ?? {};
|
|
274
|
+
return this.vault.add({ ...rest, kind: rest.kind === "sign-in" ? "credential" : rest.kind });
|
|
275
|
+
}
|
|
276
|
+
remove(name) {
|
|
277
|
+
return this.vault.remove(name);
|
|
278
|
+
}
|
|
279
|
+
setLocal(name, local) {
|
|
280
|
+
return this.vault.setLocal(String(name ?? ""), local === true);
|
|
281
|
+
}
|
|
282
|
+
capturing() {
|
|
283
|
+
return this.vault.capturing();
|
|
284
|
+
}
|
|
285
|
+
uses() {
|
|
286
|
+
return this.vault.uses();
|
|
287
|
+
}
|
|
288
|
+
setCapturing(on) {
|
|
289
|
+
return this.vault.setCapturing(on);
|
|
290
|
+
}
|
|
291
|
+
capturingPersonal() {
|
|
292
|
+
return this.vault.capturingPersonal();
|
|
293
|
+
}
|
|
294
|
+
setCapturingPersonal(on) {
|
|
295
|
+
return this.vault.setCapturingPersonal(on);
|
|
296
|
+
}
|
|
297
|
+
dispose() {
|
|
298
|
+
this.vault.forget();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
260
302
|
// web-src/vault-proxy.ts
|
|
261
303
|
import { randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
|
|
262
304
|
import { createServer, request as httpRequest } from "node:http";
|
|
@@ -950,6 +992,74 @@ class Scrubber {
|
|
|
950
992
|
}
|
|
951
993
|
}
|
|
952
994
|
|
|
995
|
+
// web-src/vault-sync.ts
|
|
996
|
+
var VaultSync;
|
|
997
|
+
((VaultSync) => {
|
|
998
|
+
function about(entry) {
|
|
999
|
+
return {
|
|
1000
|
+
kind: entry.kind,
|
|
1001
|
+
...entry.note ? { note: entry.note } : {},
|
|
1002
|
+
...entry.hosts?.length ? { hosts: entry.hosts } : {},
|
|
1003
|
+
...entry.gitUser ? { gitUser: entry.gitUser } : {},
|
|
1004
|
+
...entry.hint ? { hint: entry.hint } : {},
|
|
1005
|
+
...entry.ssh ? { ssh: true } : {},
|
|
1006
|
+
...entry.signIn ? { signIn: entry.signIn } : {}
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
VaultSync.about = about;
|
|
1010
|
+
function of(entry, value) {
|
|
1011
|
+
return { name: entry.name, value, about: about(entry) };
|
|
1012
|
+
}
|
|
1013
|
+
VaultSync.of = of;
|
|
1014
|
+
function same(entry, value, given) {
|
|
1015
|
+
const came = {
|
|
1016
|
+
name: given.name,
|
|
1017
|
+
kind: given.kind ?? "credential",
|
|
1018
|
+
source: "synced",
|
|
1019
|
+
createdAt: 0,
|
|
1020
|
+
...given.note ? { note: given.note } : {},
|
|
1021
|
+
...Array.isArray(given.hosts) && given.hosts.length ? { hosts: given.hosts } : {},
|
|
1022
|
+
...given.gitUser && Array.isArray(given.hosts) && given.hosts.length ? { gitUser: given.gitUser } : {},
|
|
1023
|
+
...given.kind === "personal" && given.hint ? { hint: given.hint } : {},
|
|
1024
|
+
...SecretNames.privateKey(given.value) ? { ssh: true } : {},
|
|
1025
|
+
...given.signIn ? { signIn: given.signIn } : {}
|
|
1026
|
+
};
|
|
1027
|
+
return value === given.value && JSON.stringify(about(entry)) === JSON.stringify(about(came));
|
|
1028
|
+
}
|
|
1029
|
+
VaultSync.same = same;
|
|
1030
|
+
function input(secret) {
|
|
1031
|
+
const about2 = secret?.about && typeof secret.about === "object" ? secret.about : {};
|
|
1032
|
+
const name = typeof secret?.name === "string" ? secret.name : "";
|
|
1033
|
+
if (!SecretNames.valid(name) || typeof secret.value !== "string" || !secret.value) {
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
const kind = about2.kind === "personal" || about2.kind === "sign-in" ? about2.kind : "credential";
|
|
1037
|
+
const signIn = about2.signIn;
|
|
1038
|
+
if (kind === "sign-in" && (!signIn || typeof signIn.id !== "string" || typeof signIn.name !== "string")) {
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
return {
|
|
1042
|
+
name,
|
|
1043
|
+
value: secret.value,
|
|
1044
|
+
kind,
|
|
1045
|
+
source: "synced",
|
|
1046
|
+
hosts: SecretNames.hosts(about2.hosts),
|
|
1047
|
+
...typeof about2.note === "string" ? { note: about2.note } : {},
|
|
1048
|
+
...typeof about2.gitUser === "string" ? { gitUser: about2.gitUser } : {},
|
|
1049
|
+
...typeof about2.hint === "string" ? { hint: about2.hint } : {},
|
|
1050
|
+
...kind === "sign-in" && signIn ? {
|
|
1051
|
+
signIn: {
|
|
1052
|
+
id: signIn.id,
|
|
1053
|
+
feature: signIn.feature === "bot" || signIn.feature === "relay" ? signIn.feature : "desktop",
|
|
1054
|
+
name: signIn.name,
|
|
1055
|
+
...typeof signIn.user === "string" ? { user: signIn.user } : {}
|
|
1056
|
+
}
|
|
1057
|
+
} : {}
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
VaultSync.input = input;
|
|
1061
|
+
})(VaultSync ||= {});
|
|
1062
|
+
|
|
953
1063
|
// web-src/vault-service.ts
|
|
954
1064
|
var PRELUDE_MS = 60000;
|
|
955
1065
|
|
|
@@ -962,6 +1072,7 @@ class Vault {
|
|
|
962
1072
|
queue = Promise.resolve();
|
|
963
1073
|
placeholderKey = randomBytes3(32);
|
|
964
1074
|
unregister;
|
|
1075
|
+
credentials;
|
|
965
1076
|
constructor(host, vaultStore, proxy) {
|
|
966
1077
|
this.host = host;
|
|
967
1078
|
this.vaultStore = vaultStore;
|
|
@@ -970,6 +1081,7 @@ class Vault {
|
|
|
970
1081
|
forget() {
|
|
971
1082
|
this.unregister?.();
|
|
972
1083
|
this.unregister = undefined;
|
|
1084
|
+
this.credentials = undefined;
|
|
973
1085
|
this.values = undefined;
|
|
974
1086
|
this.scrubbing = undefined;
|
|
975
1087
|
this.proxy?.dispose();
|
|
@@ -1008,13 +1120,15 @@ class Vault {
|
|
|
1008
1120
|
...hosts.length && gitUser ? { gitUser: gitUser.slice(0, 100) } : {},
|
|
1009
1121
|
...ssh ? { ssh: true } : {},
|
|
1010
1122
|
...input.kind === "personal" && input.hint ? { hint: String(input.hint).slice(0, 60) } : {},
|
|
1011
|
-
...input.kind === "sign-in" && input.signIn ? { signIn: input.signIn } : {}
|
|
1123
|
+
...input.kind === "sign-in" && input.signIn ? { signIn: input.signIn } : {},
|
|
1124
|
+
...input.local ?? before?.local ? { local: true } : {}
|
|
1012
1125
|
};
|
|
1013
1126
|
await this.save([...entries.filter((one) => one.name !== name), entry]);
|
|
1014
1127
|
(await this.loaded()).set(name, entry.ssh && !value.endsWith(`
|
|
1015
1128
|
`) ? `${value}
|
|
1016
1129
|
` : value);
|
|
1017
1130
|
this.scrubbing = undefined;
|
|
1131
|
+
this.credentials?.changed();
|
|
1018
1132
|
return entry;
|
|
1019
1133
|
});
|
|
1020
1134
|
}
|
|
@@ -1029,15 +1143,54 @@ class Vault {
|
|
|
1029
1143
|
return false;
|
|
1030
1144
|
}
|
|
1031
1145
|
await this.save(left);
|
|
1146
|
+
this.credentials?.changed();
|
|
1032
1147
|
return true;
|
|
1033
1148
|
});
|
|
1034
1149
|
}
|
|
1150
|
+
setLocal(name, local) {
|
|
1151
|
+
return this.serial(async () => {
|
|
1152
|
+
const entries = await this.list();
|
|
1153
|
+
const entry = entries.find((one) => one.name === name);
|
|
1154
|
+
if (!entry) {
|
|
1155
|
+
throw new Error(`The vault has no ${name}.`);
|
|
1156
|
+
}
|
|
1157
|
+
const { local: _local, ...rest } = entry;
|
|
1158
|
+
const next = local ? { ...rest, local: true } : rest;
|
|
1159
|
+
await this.save(entries.map((one) => one.name === name ? next : one));
|
|
1160
|
+
this.credentials?.changed();
|
|
1161
|
+
return next;
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
async synced() {
|
|
1165
|
+
const values = await this.loaded();
|
|
1166
|
+
return (await this.list()).filter((entry) => !entry.local && values.has(entry.name)).map((entry) => VaultSync.of(entry, values.get(entry.name)));
|
|
1167
|
+
}
|
|
1168
|
+
async receive(name, secret) {
|
|
1169
|
+
const entry = (await this.list()).find((one) => one.name === name);
|
|
1170
|
+
if (entry?.local) {
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
if (!secret) {
|
|
1174
|
+
if (entry) {
|
|
1175
|
+
await this.remove(name);
|
|
1176
|
+
}
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
const given = VaultSync.input({ ...secret, name });
|
|
1180
|
+
if (!given || entry && VaultSync.same(entry, (await this.loaded()).get(name), given)) {
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
await this.add(given);
|
|
1184
|
+
}
|
|
1035
1185
|
keepSignInsFor(credentials) {
|
|
1036
1186
|
this.unregister?.();
|
|
1187
|
+
this.credentials = credentials;
|
|
1037
1188
|
this.unregister = credentials.register({
|
|
1038
1189
|
get: (id) => this.signIn(id),
|
|
1039
1190
|
set: (id, credential, about) => this.keepSignIn(id, credential, about),
|
|
1040
|
-
remove: (id) => this.forgetSignIn(id)
|
|
1191
|
+
remove: (id) => this.forgetSignIn(id),
|
|
1192
|
+
synced: () => this.synced(),
|
|
1193
|
+
receive: (name, secret) => this.receive(name, secret)
|
|
1041
1194
|
});
|
|
1042
1195
|
}
|
|
1043
1196
|
async signIn(id) {
|
|
@@ -1060,7 +1213,13 @@ class Vault {
|
|
|
1060
1213
|
kind: "sign-in",
|
|
1061
1214
|
source: "asked",
|
|
1062
1215
|
hosts: [],
|
|
1063
|
-
signIn: {
|
|
1216
|
+
signIn: {
|
|
1217
|
+
id,
|
|
1218
|
+
feature: about.feature === "bot" || about.feature === "relay" ? about.feature : "desktop",
|
|
1219
|
+
name: String(about.name).slice(0, 100),
|
|
1220
|
+
...user
|
|
1221
|
+
},
|
|
1222
|
+
...about.local ? { local: true } : {}
|
|
1064
1223
|
});
|
|
1065
1224
|
}
|
|
1066
1225
|
async forgetSignIn(id) {
|
|
@@ -1337,44 +1496,6 @@ var WHOLE_KINDS = new Set([
|
|
|
1337
1496
|
"URL_PASSWORD"
|
|
1338
1497
|
]);
|
|
1339
1498
|
|
|
1340
|
-
class VaultService {
|
|
1341
|
-
vault;
|
|
1342
|
-
constructor(vault) {
|
|
1343
|
-
this.vault = vault;
|
|
1344
|
-
}
|
|
1345
|
-
async info() {
|
|
1346
|
-
return { store: this.vault.store };
|
|
1347
|
-
}
|
|
1348
|
-
list() {
|
|
1349
|
-
return this.vault.list();
|
|
1350
|
-
}
|
|
1351
|
-
add(input) {
|
|
1352
|
-
const { signIn: _signIn, ...rest } = input ?? {};
|
|
1353
|
-
return this.vault.add({ ...rest, kind: rest.kind === "sign-in" ? "credential" : rest.kind });
|
|
1354
|
-
}
|
|
1355
|
-
remove(name) {
|
|
1356
|
-
return this.vault.remove(name);
|
|
1357
|
-
}
|
|
1358
|
-
capturing() {
|
|
1359
|
-
return this.vault.capturing();
|
|
1360
|
-
}
|
|
1361
|
-
uses() {
|
|
1362
|
-
return this.vault.uses();
|
|
1363
|
-
}
|
|
1364
|
-
setCapturing(on) {
|
|
1365
|
-
return this.vault.setCapturing(on);
|
|
1366
|
-
}
|
|
1367
|
-
capturingPersonal() {
|
|
1368
|
-
return this.vault.capturingPersonal();
|
|
1369
|
-
}
|
|
1370
|
-
setCapturingPersonal(on) {
|
|
1371
|
-
return this.vault.setCapturingPersonal(on);
|
|
1372
|
-
}
|
|
1373
|
-
dispose() {
|
|
1374
|
-
this.vault.forget();
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
1499
|
// web-src/host.ts
|
|
1379
1500
|
function activate(host) {
|
|
1380
1501
|
let vault;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-secrets",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.26.0",
|
|
4
4
|
"description": "A pi package for Ta: a vault of secrets kept in the keychain, which Ta uses in commands by name without the model ever seeing them",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/ta-protocol": "4.
|
|
31
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.26.0",
|
|
31
|
+
"@celljs/ta-web": "4.26.0",
|
|
32
32
|
"@types/react": "^19.3.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
package/web/index.js
CHANGED
|
@@ -56,6 +56,17 @@ var EN = {
|
|
|
56
56
|
kindCredential: "Credential",
|
|
57
57
|
kindPersonal: "Personal detail",
|
|
58
58
|
kindDesktop: "Remote desktop {name}",
|
|
59
|
+
kindRelay: "Operator of the relay {name}",
|
|
60
|
+
kindBotWeixin: "WeChat bot",
|
|
61
|
+
kindBotWecom: "WeCom bot",
|
|
62
|
+
groupSignIns: "Sign-ins",
|
|
63
|
+
groupCredentials: "Keys and tokens",
|
|
64
|
+
groupPersonal: "Personal details",
|
|
65
|
+
syncedLabel: "On your devices",
|
|
66
|
+
localLabel: "This device only",
|
|
67
|
+
fromDevice: "from another device",
|
|
68
|
+
syncSwitch: "Sync to my devices",
|
|
69
|
+
keptSynced: "Each follows your account to your other devices, sealed end to end, unless you keep it to this one.",
|
|
59
70
|
signInUser: "account {user}",
|
|
60
71
|
remove: "Remove",
|
|
61
72
|
removeTitle: "Remove {name}?",
|
|
@@ -96,6 +107,17 @@ var ZH = {
|
|
|
96
107
|
kindCredential: "凭据",
|
|
97
108
|
kindPersonal: "个人信息",
|
|
98
109
|
kindDesktop: "远程桌面 {name}",
|
|
110
|
+
kindRelay: "中继运营 {name}",
|
|
111
|
+
kindBotWeixin: "微信机器人",
|
|
112
|
+
kindBotWecom: "企业微信机器人",
|
|
113
|
+
groupSignIns: "登录",
|
|
114
|
+
groupCredentials: "密钥与 token",
|
|
115
|
+
groupPersonal: "个人信息",
|
|
116
|
+
syncedLabel: "已同步到我的设备",
|
|
117
|
+
localLabel: "只留本机",
|
|
118
|
+
fromDevice: "来自其他设备",
|
|
119
|
+
syncSwitch: "同步到我的设备",
|
|
120
|
+
keptSynced: "默认随账号端到端加密同步到你的其他设备;关掉开关的只留在这台。",
|
|
99
121
|
signInUser: "账号 {user}",
|
|
100
122
|
remove: "删除",
|
|
101
123
|
removeTitle: "删除 {name}?",
|
|
@@ -136,6 +158,17 @@ var ZH_TW = {
|
|
|
136
158
|
kindCredential: "憑據",
|
|
137
159
|
kindPersonal: "個人資訊",
|
|
138
160
|
kindDesktop: "遠端桌面 {name}",
|
|
161
|
+
kindRelay: "中繼營運 {name}",
|
|
162
|
+
kindBotWeixin: "微信機器人",
|
|
163
|
+
kindBotWecom: "企業微信機器人",
|
|
164
|
+
groupSignIns: "登入",
|
|
165
|
+
groupCredentials: "金鑰與 token",
|
|
166
|
+
groupPersonal: "個人資訊",
|
|
167
|
+
syncedLabel: "已同步到我的裝置",
|
|
168
|
+
localLabel: "只留本機",
|
|
169
|
+
fromDevice: "來自其他裝置",
|
|
170
|
+
syncSwitch: "同步到我的裝置",
|
|
171
|
+
keptSynced: "預設隨帳號端到端加密同步到你的其他裝置;關掉開關的只留在這台。",
|
|
139
172
|
signInUser: "帳號 {user}",
|
|
140
173
|
remove: "刪除",
|
|
141
174
|
removeTitle: "刪除 {name}?",
|
|
@@ -176,6 +209,17 @@ var JA = {
|
|
|
176
209
|
kindCredential: "認証情報",
|
|
177
210
|
kindPersonal: "個人情報",
|
|
178
211
|
kindDesktop: "リモートデスクトップ {name}",
|
|
212
|
+
kindRelay: "リレーの運営 {name}",
|
|
213
|
+
kindBotWeixin: "WeChat ボット",
|
|
214
|
+
kindBotWecom: "WeCom ボット",
|
|
215
|
+
groupSignIns: "サインイン",
|
|
216
|
+
groupCredentials: "鍵とトークン",
|
|
217
|
+
groupPersonal: "個人情報",
|
|
218
|
+
syncedLabel: "自分の端末に同期済み",
|
|
219
|
+
localLabel: "この端末のみ",
|
|
220
|
+
fromDevice: "別の端末から",
|
|
221
|
+
syncSwitch: "自分の端末に同期",
|
|
222
|
+
keptSynced: "アカウントの他の端末へエンドツーエンドで暗号化して同期します。スイッチをオフにしたものはこの端末だけに残ります。",
|
|
179
223
|
signInUser: "アカウント {user}",
|
|
180
224
|
remove: "削除",
|
|
181
225
|
removeTitle: "{name} を削除しますか?",
|
|
@@ -364,6 +408,35 @@ function RemoveButton({ pi, entry }) {
|
|
|
364
408
|
className: "ta-spinner ta-busy-mark"
|
|
365
409
|
}), /* @__PURE__ */ React.createElement("span", null, words.remove));
|
|
366
410
|
}
|
|
411
|
+
function SyncSwitch({ pi, entry }) {
|
|
412
|
+
const words = SecretsWords.of(pi.ui.language);
|
|
413
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
414
|
+
checked: !entry.local,
|
|
415
|
+
label: words.syncSwitch,
|
|
416
|
+
onChange: (next) => pi.callHost("setLocal", entry.name, !next).catch((error) => {
|
|
417
|
+
pi.ui.notify(message(error), "error");
|
|
418
|
+
throw error;
|
|
419
|
+
})
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
function signInWords(words, entry) {
|
|
423
|
+
const signIn = entry.signIn;
|
|
424
|
+
if (!signIn) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (signIn.feature === "relay") {
|
|
428
|
+
return SecretsWords.format(words.kindRelay, { name: signIn.name });
|
|
429
|
+
}
|
|
430
|
+
if (signIn.feature === "bot") {
|
|
431
|
+
return signIn.name.startsWith("weixin:") ? words.kindBotWeixin : words.kindBotWecom;
|
|
432
|
+
}
|
|
433
|
+
return SecretsWords.format(words.kindDesktop, { name: signIn.name });
|
|
434
|
+
}
|
|
435
|
+
var GROUPS = [
|
|
436
|
+
{ title: "groupSignIns", has: (entry) => entry.kind === "sign-in" },
|
|
437
|
+
{ title: "groupCredentials", has: (entry) => entry.kind === "credential" },
|
|
438
|
+
{ title: "groupPersonal", has: (entry) => entry.kind === "personal" }
|
|
439
|
+
];
|
|
367
440
|
function KeptSetting({ pi }) {
|
|
368
441
|
const words = SecretsWords.of(pi.ui.language);
|
|
369
442
|
const entries = useStored(pi, Keys.ENTRIES, SecretNames.entries);
|
|
@@ -374,27 +447,43 @@ function KeptSetting({ pi }) {
|
|
|
374
447
|
hint: words.emptyHint
|
|
375
448
|
});
|
|
376
449
|
}
|
|
377
|
-
return /* @__PURE__ */ React.createElement("
|
|
378
|
-
className: "ta-secrets-
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
450
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
451
|
+
className: "ta-secrets-groups"
|
|
452
|
+
}, GROUPS.map((group) => {
|
|
453
|
+
const items = entries.filter(group.has);
|
|
454
|
+
return items.length > 0 && /* @__PURE__ */ React.createElement("section", {
|
|
455
|
+
key: group.title,
|
|
456
|
+
className: "ta-secrets-group"
|
|
457
|
+
}, /* @__PURE__ */ React.createElement("h4", {
|
|
458
|
+
className: "ta-secrets-group-title"
|
|
459
|
+
}, words[group.title]), /* @__PURE__ */ React.createElement("ul", {
|
|
460
|
+
className: "ta-secrets-list"
|
|
461
|
+
}, items.map((entry) => /* @__PURE__ */ React.createElement("li", {
|
|
462
|
+
key: entry.name
|
|
463
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
464
|
+
className: "ta-secrets-item"
|
|
465
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
466
|
+
className: "ta-secrets-name"
|
|
467
|
+
}, entry.name), /* @__PURE__ */ React.createElement("span", {
|
|
468
|
+
className: "ta-secrets-meta"
|
|
469
|
+
}, [
|
|
470
|
+
signInWords(words, entry) ?? (entry.note || (entry.ssh ? words.sshKey : entry.kind === "personal" ? words.kindPersonal : words.kindCredential)),
|
|
471
|
+
entry.signIn?.user ? SecretsWords.format(words.signInUser, { user: entry.signIn.user }) : undefined,
|
|
472
|
+
entry.hint,
|
|
473
|
+
entry.ssh && entry.note ? words.sshKey : undefined,
|
|
474
|
+
entry.hosts?.length ? SecretsWords.format(words.hostsLabel, { hosts: entry.hosts.join(", ") }) : undefined,
|
|
475
|
+
entry.local ? words.localLabel : entry.source === "synced" ? words.fromDevice : undefined,
|
|
476
|
+
entry.uses ? SecretsWords.format(words.usedTimes, { count: entry.uses }) : words.neverUsed
|
|
477
|
+
].filter(Boolean).join(" · "))), /* @__PURE__ */ React.createElement("span", {
|
|
478
|
+
className: "ta-secrets-actions"
|
|
479
|
+
}, /* @__PURE__ */ React.createElement(SyncSwitch, {
|
|
480
|
+
pi,
|
|
481
|
+
entry
|
|
482
|
+
}), /* @__PURE__ */ React.createElement(RemoveButton, {
|
|
483
|
+
pi,
|
|
484
|
+
entry
|
|
485
|
+
}))))));
|
|
486
|
+
}));
|
|
398
487
|
}
|
|
399
488
|
var HOW = {
|
|
400
489
|
env: "howEnv",
|
|
@@ -531,7 +620,10 @@ function vaultSettings(pi) {
|
|
|
531
620
|
{
|
|
532
621
|
key: "kept",
|
|
533
622
|
label: () => words().keptLabel,
|
|
534
|
-
description: () =>
|
|
623
|
+
description: () => {
|
|
624
|
+
const kept = store === "file" ? words().keptFile : words().keptKeychain;
|
|
625
|
+
return `${kept}${/[。.]$/.test(kept) ? "" : " "}${words().keptSynced}`;
|
|
626
|
+
},
|
|
535
627
|
stacked: true,
|
|
536
628
|
render: () => /* @__PURE__ */ React.createElement(KeptSetting, {
|
|
537
629
|
pi
|
|
@@ -555,6 +647,10 @@ var STYLE = `
|
|
|
555
647
|
.ta-secrets-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
|
556
648
|
.ta-secrets-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-text); font-family: var(--ta-mono); font-size: calc(13px * var(--ta-font-scale)); }
|
|
557
649
|
.ta-secrets-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
650
|
+
.ta-secrets-groups { display: flex; width: 100%; flex-direction: column; gap: 12px; }
|
|
651
|
+
.ta-secrets-group { display: flex; flex-direction: column; }
|
|
652
|
+
.ta-secrets-group-title { margin: 0 0 2px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); font-weight: 500; }
|
|
653
|
+
.ta-secrets-actions { display: flex; flex: none; align-items: center; gap: 12px; }
|
|
558
654
|
.ta-secrets-add { display: flex; gap: 8px; width: 100%; }
|
|
559
655
|
.ta-secrets-value { display: block; box-sizing: border-box; height: 36px; padding: 0 10px; line-height: 34px; resize: none; overflow: hidden; white-space: nowrap; font: inherit; -webkit-text-security: disc; }
|
|
560
656
|
.ta-secrets-value::placeholder { line-height: 34px; }
|