paseo-plugin-secure-input 0.3.0 → 0.4.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/OVERVIEW.md +2 -2
- package/README.md +11 -11
- package/SECURITY.md +7 -7
- package/client/card.tsx +6 -3
- package/client/codes.ts +9 -26
- package/client/diagnostics-rows.ts +32 -47
- package/client/dialog-state.ts +1 -1
- package/client/dialog.tsx +11 -9
- package/client/fields.tsx +19 -15
- package/client/file-entry.ts +14 -14
- package/client/form-state.ts +13 -19
- package/client/messages.ts +312 -0
- package/client/outcome.ts +3 -3
- package/client/presentation.ts +13 -39
- package/client/self-test.ts +6 -8
- package/client/settings.tsx +24 -22
- package/npm-shrinkwrap.json +2 -2
- package/package.json +7 -6
- package/paseo-plugin.json +1 -1
- package/server/core/continuation.ts +1 -1
- package/server/paseo/hooks.ts +14 -14
- package/server/paseo/plugin.ts +1 -1
- package/server/paseo/tools.ts +15 -2
- package/shared/limits.ts +2 -2
- package/skills/secure-input/SKILL.md +3 -3
- package/client/text.ts +0 -47
package/client/file-entry.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toBase64Url, utf8 } from "../shared/bytes";
|
|
2
2
|
import { LIMITS } from "../shared/limits";
|
|
3
3
|
import { sanitizeText } from "../shared/sanitize";
|
|
4
|
-
import {
|
|
4
|
+
import type { Translate } from "./messages";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A file the human picked, dropped or pasted: its bytes, as they are, and its name. The name is null for a paste. The
|
|
@@ -17,13 +17,13 @@ export interface FileValue {
|
|
|
17
17
|
type Format = "json" | "pem" | "any";
|
|
18
18
|
|
|
19
19
|
/** What the app found of a file, before anything is sealed: it passes, or the one line under its row says why not. */
|
|
20
|
-
export type FileCheck = { ok: true } | { ok: false; message: "
|
|
20
|
+
export type FileCheck = { ok: true } | { ok: false; message: "file.notJson" | "file.notPem" | "form.tooLarge" };
|
|
21
21
|
|
|
22
22
|
const PASSES: FileCheck = { ok: true };
|
|
23
|
-
/**
|
|
24
|
-
const TOO_LARGE: FileCheck = { ok: false, message: "
|
|
25
|
-
const NOT_JSON: FileCheck = { ok: false, message: "
|
|
26
|
-
const NOT_PEM: FileCheck = { ok: false, message: "
|
|
23
|
+
/** The size line stays a key, so that a cached check reads in the current language. */
|
|
24
|
+
const TOO_LARGE: FileCheck = { ok: false, message: "form.tooLarge" };
|
|
25
|
+
const NOT_JSON: FileCheck = { ok: false, message: "file.notJson" };
|
|
26
|
+
const NOT_PEM: FileCheck = { ok: false, message: "file.notPem" };
|
|
27
27
|
|
|
28
28
|
/** A line of a PEM that opens a block, and one that closes it, ending in CR LF or in LF. */
|
|
29
29
|
const PEM_BEGIN = /^-----BEGIN [^\r\n]+-----\r?$/m;
|
|
@@ -64,20 +64,20 @@ export function checkFile(file: FileValue, format: Format): FileCheck {
|
|
|
64
64
|
/** The most of a file's name that is shown: the longest name a file system gives one. */
|
|
65
65
|
const NAME_MAX = 255;
|
|
66
66
|
|
|
67
|
-
/** «2
|
|
68
|
-
export function sizeText(bytes: number): string {
|
|
69
|
-
if (bytes < 1024) return
|
|
70
|
-
return
|
|
67
|
+
/** «2.1 KiB»: the size of a file, in bytes below a KiB and in KiB with one decimal above, written as the app's language writes a decimal («2,1 КіБ»). */
|
|
68
|
+
export function sizeText(t: Translate, bytes: number): string {
|
|
69
|
+
if (bytes < 1024) return t("file.bytes", { count: bytes });
|
|
70
|
+
return t("file.kib", { size: bytes / 1024 });
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* The line that stands for a file in its row: its name, or
|
|
74
|
+
* The line that stands for a file in its row: its name, or «pasted» for a paste, its size, and for a format that
|
|
75
75
|
* is checked, the check. Never a byte of the file. The name is the human's file system's, and it is shown without what
|
|
76
76
|
* could hide or reorder it, which a name made to deceive could hold.
|
|
77
77
|
*/
|
|
78
|
-
export function fileLine(file: FileValue, format: "json" | "pem" | "any", check: FileCheck): string {
|
|
79
|
-
const name = file.name === null ? "
|
|
80
|
-
const parts = [name, sizeText(file.bytes.length)];
|
|
78
|
+
export function fileLine(t: Translate, file: FileValue, format: "json" | "pem" | "any", check: FileCheck): string {
|
|
79
|
+
const name = file.name === null ? t("file.pasted") : sanitizeText(file.name, NAME_MAX);
|
|
80
|
+
const parts = [name, sizeText(t, file.bytes.length)];
|
|
81
81
|
if (format !== "any") parts.push(`${format} ${check.ok ? "✓" : "✗"}`);
|
|
82
82
|
return parts.filter((part) => part !== "").join(" · ");
|
|
83
83
|
}
|
package/client/form-state.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { MAX_PAYLOAD_BYTES, payloadSize, type PayloadEntry } from "../shared/sea
|
|
|
4
4
|
import { hasLoneSurrogate } from "../shared/text";
|
|
5
5
|
import type { RequestView } from "../shared/view";
|
|
6
6
|
import { checkedFile, encodedFile, wipeFile, type FileValue } from "./file-entry";
|
|
7
|
+
import type { Translate } from "./messages";
|
|
7
8
|
import { fieldId } from "./presentation";
|
|
8
9
|
|
|
9
10
|
/** What a row holds: a line of text, or a file, which is null until one is picked, dropped or pasted. */
|
|
@@ -42,27 +43,20 @@ export function formFromView(view: RequestView): FormState {
|
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
// The lines under a row, as the form words them. A limit a line names is the plugin's own number (`LIMITS`, `MAX_PAYLOAD_BYTES`).
|
|
46
|
-
const INVALID_NAME = "Лише A–Z, 0–9, _";
|
|
47
|
-
const RESERVED_NAME = "Ім'я зарезервоване";
|
|
48
|
-
const TEXT_TOO_LARGE = `Не довше ${LIMITS.valueBytes / 1024} КіБ`;
|
|
49
|
-
const BROKEN_TEXT = "Некоректний символ";
|
|
50
|
-
const TOTAL_TOO_LARGE = `Разом не довше ${MAX_PAYLOAD_BYTES / 1024} КіБ`;
|
|
51
|
-
|
|
52
46
|
/**
|
|
53
47
|
* The key a row's name gives, and the line about it. A declared row's key is the agent's, which the plugin checked. A
|
|
54
48
|
* name of the human's is trimmed, and gives no key while it is empty (and no line), is of another shape than a key, is
|
|
55
49
|
* a name a plain object treats specially, or names a file an earlier row names already, exactly or by letter case: two
|
|
56
50
|
* such keys would be one file on a volume that ignores case. `taken` maps each earlier key, folded, to itself.
|
|
57
51
|
*/
|
|
58
|
-
function nameOf(row: FormRow, taken: ReadonlyMap<string, string>): { key: string | null; error: string | null } {
|
|
52
|
+
function nameOf(t: Translate, row: FormRow, taken: ReadonlyMap<string, string>): { key: string | null; error: string | null } {
|
|
59
53
|
if (row.declared) return { key: row.key, error: null };
|
|
60
54
|
const key = row.key.trim();
|
|
61
55
|
if (key === "") return { key: null, error: null };
|
|
62
|
-
if (!KEY_PATTERN.test(key)) return { key: null, error:
|
|
63
|
-
if (RESERVED_KEYS.includes(key)) return { key: null, error:
|
|
56
|
+
if (!KEY_PATTERN.test(key)) return { key: null, error: t("form.invalidName") };
|
|
57
|
+
if (RESERVED_KEYS.includes(key)) return { key: null, error: t("form.reservedName") };
|
|
64
58
|
const earlier = taken.get(key.toLowerCase());
|
|
65
|
-
return earlier === undefined ? { key, error: null } : { key: null, error:
|
|
59
|
+
return earlier === undefined ? { key, error: null } : { key: null, error: t("form.duplicateName", { key: earlier }) };
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
/**
|
|
@@ -71,19 +65,19 @@ function nameOf(row: FormRow, taken: ReadonlyMap<string, string>): { key: string
|
|
|
71
65
|
* with no partner would be written as another character. A file is checked against its row's format, and encoded, once
|
|
72
66
|
* for as long as the row holds it (`checkedFile`, `encodedFile`).
|
|
73
67
|
*/
|
|
74
|
-
function valueOf(row: FormRow): { error: string | null; entry: ((key: string) => PayloadEntry) | null } {
|
|
68
|
+
function valueOf(t: Translate, row: FormRow): { error: string | null; entry: ((key: string) => PayloadEntry) | null } {
|
|
75
69
|
const { value } = row;
|
|
76
70
|
if (value.kind === "text") {
|
|
77
71
|
const { text } = value;
|
|
78
72
|
if (text === "") return { error: null, entry: null };
|
|
79
|
-
if (utf8Length(text) > LIMITS.valueBytes) return { error:
|
|
80
|
-
if (hasLoneSurrogate(text)) return { error:
|
|
73
|
+
if (utf8Length(text) > LIMITS.valueBytes) return { error: t("form.tooLarge", { kib: LIMITS.valueBytes / 1024 }), entry: null };
|
|
74
|
+
if (hasLoneSurrogate(text)) return { error: t("form.brokenText"), entry: null };
|
|
81
75
|
return { error: null, entry: (key) => ({ key, value: text }) };
|
|
82
76
|
}
|
|
83
77
|
const { file } = value;
|
|
84
78
|
if (file === null) return { error: null, entry: null };
|
|
85
79
|
const check = checkedFile(file, row.format);
|
|
86
|
-
if (!check.ok) return { error: check.message, entry: null };
|
|
80
|
+
if (!check.ok) return { error: t(check.message, { kib: LIMITS.fileBytes / 1024 }), entry: null };
|
|
87
81
|
// The plugin gives a key whose file has no bytes no file: such a row is an empty one, here as there.
|
|
88
82
|
if (file.bytes.length === 0) return { error: null, entry: null };
|
|
89
83
|
return { error: null, entry: (key) => ({ key, file: encodedFile(file) }) };
|
|
@@ -98,16 +92,16 @@ function valueOf(row: FormRow): { error: string | null; entry: ((key: string) =>
|
|
|
98
92
|
* An empty row says nothing: «→» is just disabled. A row has one line, about its name before its value. Messages name
|
|
99
93
|
* keys, never values. Every file goes as `{ key, file }`, its bytes as base64url.
|
|
100
94
|
*/
|
|
101
|
-
export function checkForm(form: FormState): { entries: PayloadEntry[] | null; errors: ReadonlyMap<string, string>; total: string | null } {
|
|
95
|
+
export function checkForm(t: Translate, form: FormState): { entries: PayloadEntry[] | null; errors: ReadonlyMap<string, string>; total: string | null } {
|
|
102
96
|
const errors = new Map<string, string>();
|
|
103
97
|
const taken = new Map<string, string>();
|
|
104
98
|
const ready: Array<() => PayloadEntry> = [];
|
|
105
99
|
let complete = true;
|
|
106
100
|
for (const row of form.rows) {
|
|
107
|
-
const name = nameOf(row, taken);
|
|
101
|
+
const name = nameOf(t, row, taken);
|
|
108
102
|
const { key } = name;
|
|
109
103
|
if (key !== null && !taken.has(key.toLowerCase())) taken.set(key.toLowerCase(), key);
|
|
110
|
-
const value = valueOf(row);
|
|
104
|
+
const value = valueOf(t, row);
|
|
111
105
|
const error = name.error ?? value.error;
|
|
112
106
|
if (error !== null) {
|
|
113
107
|
errors.set(row.id, error);
|
|
@@ -124,7 +118,7 @@ export function checkForm(form: FormState): { entries: PayloadEntry[] | null; er
|
|
|
124
118
|
}
|
|
125
119
|
if (!complete) return { entries: null, errors, total: null };
|
|
126
120
|
const entries = ready.map((make) => make());
|
|
127
|
-
if (payloadSize(entries) > MAX_PAYLOAD_BYTES) return { entries: null, errors, total:
|
|
121
|
+
if (payloadSize(entries) > MAX_PAYLOAD_BYTES) return { entries: null, errors, total: t("form.totalTooLarge", { kib: MAX_PAYLOAD_BYTES / 1024 }) };
|
|
128
122
|
if (entries.length === 0 || entries.length > LIMITS.fields) return { entries: null, errors, total: null };
|
|
129
123
|
return { entries, errors, total: null };
|
|
130
124
|
}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { defineTranslations, type useTranslation } from "@getpaseo/plugin/client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The app's words, in the app's language. English is the source: the SDK falls back to it key by key, so every other
|
|
5
|
+
* language has every English key (`tests/messages.test.ts`). The Ukrainian reads as the plugin said it before it had
|
|
6
|
+
* English.
|
|
7
|
+
*
|
|
8
|
+
* Three sentences name the retry limit in words, which no plural rule can do: «Three attempts failed», «After three
|
|
9
|
+
* failed attempts». `tests/messages.test.ts` holds `MAX_RETRIES` to three, so a new limit fails there until they say it.
|
|
10
|
+
*/
|
|
11
|
+
const en = {
|
|
12
|
+
form: {
|
|
13
|
+
titleOne: "Secret for the agent",
|
|
14
|
+
titleMany: "Secrets for the agent",
|
|
15
|
+
invalidName: "Only A–Z, 0–9, _",
|
|
16
|
+
reservedName: "This name is reserved",
|
|
17
|
+
tooLarge: "No longer than {{kib}} KiB",
|
|
18
|
+
totalTooLarge: "No longer than {{kib}} KiB in total",
|
|
19
|
+
brokenText: "Invalid character",
|
|
20
|
+
duplicateName: "Already used: {{key}}",
|
|
21
|
+
unavailable: "The plugin is not available right now. Press → again.",
|
|
22
|
+
closed: "The request is already closed.",
|
|
23
|
+
},
|
|
24
|
+
a11y: {
|
|
25
|
+
enter: "Enter the value",
|
|
26
|
+
decline: "Decline the request",
|
|
27
|
+
add: "Add a key",
|
|
28
|
+
remove: "Remove the key",
|
|
29
|
+
show: "Show the value",
|
|
30
|
+
hide: "Hide the value",
|
|
31
|
+
submit: "Send",
|
|
32
|
+
pick: "Choose a file",
|
|
33
|
+
paste: "Paste from the clipboard",
|
|
34
|
+
removeFile: "Remove the file",
|
|
35
|
+
name: "Key name",
|
|
36
|
+
pasteArea: "File contents",
|
|
37
|
+
},
|
|
38
|
+
pill: {
|
|
39
|
+
tamper: "Suspicious submission",
|
|
40
|
+
delivered: "Delivered",
|
|
41
|
+
declined: "Declined",
|
|
42
|
+
cancelled: "Cancelled",
|
|
43
|
+
expired: "Expired",
|
|
44
|
+
rejected: "Not accepted",
|
|
45
|
+
keys_one: "{{count}} key",
|
|
46
|
+
keys_other: "{{count}} keys",
|
|
47
|
+
},
|
|
48
|
+
file: {
|
|
49
|
+
notJson: "Not JSON",
|
|
50
|
+
notPem: "Not PEM",
|
|
51
|
+
pasted: "pasted",
|
|
52
|
+
kib: "{{size, number(minimumFractionDigits: 1; maximumFractionDigits: 1)}} KiB",
|
|
53
|
+
bytes_one: "{{count}} byte",
|
|
54
|
+
bytes_other: "{{count}} bytes",
|
|
55
|
+
},
|
|
56
|
+
selfTest: {
|
|
57
|
+
running: "Check in progress",
|
|
58
|
+
passed: "✓ {{ms}} ms",
|
|
59
|
+
mismatch: "✗ the data did not match",
|
|
60
|
+
sealFailed: "✗ could not encrypt",
|
|
61
|
+
noAnswer: "✗ the plugin did not answer",
|
|
62
|
+
},
|
|
63
|
+
settings: {
|
|
64
|
+
encryption: "Encryption",
|
|
65
|
+
thisDevice: "This device",
|
|
66
|
+
check: "Check",
|
|
67
|
+
result: "Result",
|
|
68
|
+
refresh: "Refresh",
|
|
69
|
+
refreshFailed: "Could not refresh: showing the previous state",
|
|
70
|
+
readFailed: "Could not read the plugin's state",
|
|
71
|
+
loading: "Loading…",
|
|
72
|
+
status: "Status",
|
|
73
|
+
deleteAll: "Delete all secret files now",
|
|
74
|
+
delete: "Delete",
|
|
75
|
+
deleteFailed: "Could not delete",
|
|
76
|
+
},
|
|
77
|
+
status: {
|
|
78
|
+
plugin: "Plugin",
|
|
79
|
+
files: "Secrets on the server",
|
|
80
|
+
pending: "Waiting requests",
|
|
81
|
+
errors: "Errors",
|
|
82
|
+
none: "None",
|
|
83
|
+
some: "Some",
|
|
84
|
+
notStarted: "Did not start",
|
|
85
|
+
starting: "Starting",
|
|
86
|
+
running: "Running",
|
|
87
|
+
notAllDeleted: "{{delivered}} · not all deleted",
|
|
88
|
+
deleteFailedHint: "Some files could not be deleted. Press “{{action}}” or delete {{dir}}/drop.",
|
|
89
|
+
nextGoesAt: "{{delivered}} · the next goes at {{time}}",
|
|
90
|
+
unexpected: "Unexpected error. (unexpected)",
|
|
91
|
+
saveRequestsFailed: "Cannot save the state of the requests.",
|
|
92
|
+
requestsUnreadable: "The requests file cannot be read.",
|
|
93
|
+
saveMessagesFailed: "Cannot save the messages to agents.",
|
|
94
|
+
cardsOwed: "Card not shown in the chat: {{cards}}.",
|
|
95
|
+
},
|
|
96
|
+
codes: {
|
|
97
|
+
invalid_request: "The request or the values sent could not be read.",
|
|
98
|
+
request_already_pending: "The agent already has another open request.",
|
|
99
|
+
unknown_agent: "The plugin could not tell which agent sent the request.",
|
|
100
|
+
service_unavailable: "The plugin cannot take the request right now.",
|
|
101
|
+
write_failed: "The file could not be written.",
|
|
102
|
+
retry_limit: "Three attempts failed: the encrypted values could not be opened.",
|
|
103
|
+
request_closed: "The request was already closed when you answered (for example, the plugin was restarted).",
|
|
104
|
+
decrypt_failed:
|
|
105
|
+
"The plugin could not open the encrypted values, and the channel may have been tampered with. Check that the connection goes through the relay or Tailscale, and try again. After three failed attempts the request closes.",
|
|
106
|
+
unknown: "Unknown error.",
|
|
107
|
+
},
|
|
108
|
+
} as const;
|
|
109
|
+
|
|
110
|
+
const uk = {
|
|
111
|
+
form: {
|
|
112
|
+
titleOne: "Секрет для агента",
|
|
113
|
+
titleMany: "Секрети для агента",
|
|
114
|
+
invalidName: "Лише A–Z, 0–9, _",
|
|
115
|
+
reservedName: "Ім'я зарезервоване",
|
|
116
|
+
tooLarge: "Не довше {{kib}} КіБ",
|
|
117
|
+
totalTooLarge: "Разом не довше {{kib}} КіБ",
|
|
118
|
+
brokenText: "Некоректний символ",
|
|
119
|
+
duplicateName: "Вже є {{key}}",
|
|
120
|
+
unavailable: "Плагін зараз недоступний. Натисни «→» ще раз.",
|
|
121
|
+
closed: "Запит уже закрито.",
|
|
122
|
+
},
|
|
123
|
+
a11y: {
|
|
124
|
+
enter: "Ввести значення",
|
|
125
|
+
decline: "Відхилити запит",
|
|
126
|
+
add: "Додати ключ",
|
|
127
|
+
remove: "Прибрати ключ",
|
|
128
|
+
show: "Показати значення",
|
|
129
|
+
hide: "Сховати значення",
|
|
130
|
+
submit: "Передати",
|
|
131
|
+
pick: "Вибрати файл",
|
|
132
|
+
paste: "Вставити з буфера",
|
|
133
|
+
removeFile: "Прибрати файл",
|
|
134
|
+
name: "Назва ключа",
|
|
135
|
+
pasteArea: "Вміст файлу",
|
|
136
|
+
},
|
|
137
|
+
pill: {
|
|
138
|
+
tamper: "Підозріле подання",
|
|
139
|
+
delivered: "Передано",
|
|
140
|
+
declined: "Відхилено",
|
|
141
|
+
cancelled: "Скасовано",
|
|
142
|
+
expired: "Час минув",
|
|
143
|
+
rejected: "Не прийнято",
|
|
144
|
+
keys_one: "{{count}} ключ",
|
|
145
|
+
keys_few: "{{count}} ключі",
|
|
146
|
+
keys_many: "{{count}} ключів",
|
|
147
|
+
keys_other: "{{count}} ключа",
|
|
148
|
+
},
|
|
149
|
+
file: {
|
|
150
|
+
notJson: "Це не JSON",
|
|
151
|
+
notPem: "Це не PEM",
|
|
152
|
+
pasted: "вставлено",
|
|
153
|
+
kib: "{{size, number(minimumFractionDigits: 1; maximumFractionDigits: 1)}} КіБ",
|
|
154
|
+
bytes_one: "{{count}} байт",
|
|
155
|
+
bytes_few: "{{count}} байти",
|
|
156
|
+
bytes_many: "{{count}} байтів",
|
|
157
|
+
bytes_other: "{{count}} байта",
|
|
158
|
+
},
|
|
159
|
+
selfTest: {
|
|
160
|
+
running: "Перевірка триває",
|
|
161
|
+
passed: "✓ {{ms}} мс",
|
|
162
|
+
mismatch: "✗ дані не збіглися",
|
|
163
|
+
sealFailed: "✗ не вдалося зашифрувати",
|
|
164
|
+
noAnswer: "✗ плагін не відповів",
|
|
165
|
+
},
|
|
166
|
+
settings: {
|
|
167
|
+
encryption: "Шифрування",
|
|
168
|
+
thisDevice: "Цей пристрій",
|
|
169
|
+
check: "Перевірити",
|
|
170
|
+
result: "Результат",
|
|
171
|
+
refresh: "Оновлення",
|
|
172
|
+
refreshFailed: "Не вдалося оновити: показано попередній стан",
|
|
173
|
+
readFailed: "Не вдалося прочитати стан плагіна",
|
|
174
|
+
loading: "Завантаження…",
|
|
175
|
+
status: "Стан",
|
|
176
|
+
deleteAll: "Видалити всі файли секретів зараз",
|
|
177
|
+
delete: "Видалити",
|
|
178
|
+
deleteFailed: "Не вдалося видалити",
|
|
179
|
+
},
|
|
180
|
+
status: {
|
|
181
|
+
plugin: "Плагін",
|
|
182
|
+
files: "Секрети на сервері",
|
|
183
|
+
pending: "Запити, що чекають",
|
|
184
|
+
errors: "Помилки",
|
|
185
|
+
none: "Немає",
|
|
186
|
+
some: "Є",
|
|
187
|
+
notStarted: "Не запустився",
|
|
188
|
+
starting: "Запускається",
|
|
189
|
+
running: "Працює",
|
|
190
|
+
notAllDeleted: "{{delivered}} · не все видалено",
|
|
191
|
+
deleteFailedHint: "Не вдалося видалити деякі файли. Натисніть «{{action}}» або видаліть {{dir}}/drop.",
|
|
192
|
+
nextGoesAt: "{{delivered}} · найближчий зникне о {{time}}",
|
|
193
|
+
unexpected: "Непередбачена помилка. (unexpected)",
|
|
194
|
+
saveRequestsFailed: "Не вдається зберегти стан запитів.",
|
|
195
|
+
requestsUnreadable: "Файл запитів не читається.",
|
|
196
|
+
saveMessagesFailed: "Не вдається зберегти повідомлення агентам.",
|
|
197
|
+
cardsOwed: "Картку не показано в чаті: {{cards}}.",
|
|
198
|
+
},
|
|
199
|
+
codes: {
|
|
200
|
+
invalid_request: "Запит або надіслані значення не вдалося прочитати.",
|
|
201
|
+
request_already_pending: "Від агента вже є ще один відкритий запит.",
|
|
202
|
+
unknown_agent: "Плагін не зміг визначити, який агент надіслав запит.",
|
|
203
|
+
service_unavailable: "Плагін зараз не може прийняти запит.",
|
|
204
|
+
write_failed: "Файл не вдалося записати.",
|
|
205
|
+
retry_limit: "Три спроби не вдались: зашифровані значення не вдалося розкрити.",
|
|
206
|
+
request_closed: "Запит уже було закрито, коли ви відповіли (наприклад, плагін перезапускали).",
|
|
207
|
+
decrypt_failed:
|
|
208
|
+
"Плагін не зміг розкрити зашифровані значення — можливе втручання в канал. Перевірте, що з'єднання йде через relay або Tailscale, і спробуйте ще раз. Після трьох невдалих спроб запит закривається.",
|
|
209
|
+
unknown: "Невідома помилка.",
|
|
210
|
+
},
|
|
211
|
+
} as const;
|
|
212
|
+
|
|
213
|
+
const ko = {
|
|
214
|
+
form: {
|
|
215
|
+
titleOne: "에이전트용 시크릿",
|
|
216
|
+
titleMany: "에이전트용 시크릿",
|
|
217
|
+
invalidName: "A–Z, 0–9, _만 사용 가능",
|
|
218
|
+
reservedName: "예약된 이름입니다",
|
|
219
|
+
tooLarge: "최대 {{kib}} KiB",
|
|
220
|
+
totalTooLarge: "합계 최대 {{kib}} KiB",
|
|
221
|
+
brokenText: "잘못된 문자",
|
|
222
|
+
duplicateName: "이미 있는 키: {{key}}",
|
|
223
|
+
unavailable: "지금은 플러그인을 사용할 수 없습니다. →를 다시 누르세요.",
|
|
224
|
+
closed: "요청이 이미 닫혔습니다.",
|
|
225
|
+
},
|
|
226
|
+
a11y: {
|
|
227
|
+
enter: "값 입력",
|
|
228
|
+
decline: "요청 거부",
|
|
229
|
+
add: "키 추가",
|
|
230
|
+
remove: "키 제거",
|
|
231
|
+
show: "값 보기",
|
|
232
|
+
hide: "값 숨기기",
|
|
233
|
+
submit: "전달",
|
|
234
|
+
pick: "파일 선택",
|
|
235
|
+
paste: "클립보드에서 붙여넣기",
|
|
236
|
+
removeFile: "파일 제거",
|
|
237
|
+
name: "키 이름",
|
|
238
|
+
pasteArea: "파일 내용",
|
|
239
|
+
},
|
|
240
|
+
pill: {
|
|
241
|
+
tamper: "의심스러운 제출",
|
|
242
|
+
delivered: "전달됨",
|
|
243
|
+
declined: "거부됨",
|
|
244
|
+
cancelled: "취소됨",
|
|
245
|
+
expired: "만료됨",
|
|
246
|
+
rejected: "수락되지 않음",
|
|
247
|
+
keys_other: "키 {{count}}개",
|
|
248
|
+
},
|
|
249
|
+
file: {
|
|
250
|
+
notJson: "JSON이 아님",
|
|
251
|
+
notPem: "PEM이 아님",
|
|
252
|
+
pasted: "붙여넣음",
|
|
253
|
+
kib: "{{size, number(minimumFractionDigits: 1; maximumFractionDigits: 1)}} KiB",
|
|
254
|
+
bytes_other: "{{count}}바이트",
|
|
255
|
+
},
|
|
256
|
+
selfTest: {
|
|
257
|
+
running: "확인 중",
|
|
258
|
+
passed: "✓ {{ms}}ms",
|
|
259
|
+
mismatch: "✗ 데이터가 일치하지 않음",
|
|
260
|
+
sealFailed: "✗ 암호화하지 못함",
|
|
261
|
+
noAnswer: "✗ 플러그인이 응답하지 않음",
|
|
262
|
+
},
|
|
263
|
+
settings: {
|
|
264
|
+
encryption: "암호화",
|
|
265
|
+
thisDevice: "이 기기",
|
|
266
|
+
check: "확인",
|
|
267
|
+
result: "결과",
|
|
268
|
+
refresh: "새로고침",
|
|
269
|
+
refreshFailed: "새로고침하지 못했습니다: 이전 상태를 표시합니다",
|
|
270
|
+
readFailed: "플러그인 상태를 읽지 못했습니다",
|
|
271
|
+
loading: "불러오는 중…",
|
|
272
|
+
status: "상태",
|
|
273
|
+
deleteAll: "지금 모든 시크릿 파일 삭제",
|
|
274
|
+
delete: "삭제",
|
|
275
|
+
deleteFailed: "삭제하지 못했습니다",
|
|
276
|
+
},
|
|
277
|
+
status: {
|
|
278
|
+
plugin: "플러그인",
|
|
279
|
+
files: "서버의 시크릿",
|
|
280
|
+
pending: "대기 중인 요청",
|
|
281
|
+
errors: "오류",
|
|
282
|
+
none: "없음",
|
|
283
|
+
some: "있음",
|
|
284
|
+
notStarted: "시작되지 않음",
|
|
285
|
+
starting: "시작 중",
|
|
286
|
+
running: "실행 중",
|
|
287
|
+
notAllDeleted: "{{delivered}} · 일부 삭제되지 않음",
|
|
288
|
+
deleteFailedHint: "일부 파일을 삭제하지 못했습니다. ‘{{action}}’ 버튼을 누르거나 {{dir}}/drop을 삭제하세요.",
|
|
289
|
+
nextGoesAt: "{{delivered}} · 다음 삭제 {{time}}",
|
|
290
|
+
unexpected: "예기치 않은 오류입니다. (unexpected)",
|
|
291
|
+
saveRequestsFailed: "요청 상태를 저장할 수 없습니다.",
|
|
292
|
+
requestsUnreadable: "요청 파일을 읽을 수 없습니다.",
|
|
293
|
+
saveMessagesFailed: "에이전트에게 보낼 메시지를 저장할 수 없습니다.",
|
|
294
|
+
cardsOwed: "채팅에 표시되지 않은 카드: {{cards}}.",
|
|
295
|
+
},
|
|
296
|
+
codes: {
|
|
297
|
+
invalid_request: "요청이나 보낸 값을 읽을 수 없습니다.",
|
|
298
|
+
request_already_pending: "이 에이전트가 보낸 다른 요청이 이미 열려 있습니다.",
|
|
299
|
+
unknown_agent: "플러그인이 요청을 보낸 에이전트를 확인하지 못했습니다.",
|
|
300
|
+
service_unavailable: "플러그인이 지금 요청을 받을 수 없습니다.",
|
|
301
|
+
write_failed: "파일을 쓰지 못했습니다.",
|
|
302
|
+
retry_limit: "세 번 시도했지만 실패했습니다: 암호화된 값을 복호화하지 못했습니다.",
|
|
303
|
+
request_closed: "응답했을 때 요청이 이미 닫혀 있었습니다(예: 플러그인이 다시 시작됨).",
|
|
304
|
+
decrypt_failed:
|
|
305
|
+
"플러그인이 암호화된 값을 복호화하지 못했습니다. 채널이 변조되었을 수 있습니다. 연결이 relay 또는 Tailscale을 거치는지 확인하고 다시 시도하세요. 세 번 실패하면 요청이 닫힙니다.",
|
|
306
|
+
unknown: "알 수 없는 오류입니다.",
|
|
307
|
+
},
|
|
308
|
+
} as const;
|
|
309
|
+
|
|
310
|
+
export const messages = defineTranslations({ resources: { en, uk, ko } });
|
|
311
|
+
|
|
312
|
+
export type Translate = ReturnType<typeof useTranslation<typeof en>>["t"];
|
package/client/outcome.ts
CHANGED
|
@@ -10,10 +10,10 @@ export type FulfillResult =
|
|
|
10
10
|
| { ok: false; code: ErrorCode; retryable: boolean; detail?: string };
|
|
11
11
|
|
|
12
12
|
/** The line at the top of the form when the plugin did not take what was sent, but the request may still be open. */
|
|
13
|
-
export const UNAVAILABLE = "
|
|
13
|
+
export const UNAVAILABLE = "form.unavailable";
|
|
14
14
|
|
|
15
15
|
/** The line at the top of the form when the request is closed: what was typed stays, and «→» is disabled. */
|
|
16
|
-
export const CLOSED = "
|
|
16
|
+
export const CLOSED = "form.closed";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* A plain description of what the form does next. The component does exactly this and decides nothing. Every flag is
|
|
@@ -21,7 +21,7 @@ export const CLOSED = "Запит уже закрито.";
|
|
|
21
21
|
*/
|
|
22
22
|
export interface Next {
|
|
23
23
|
/** The one line at the top of the form, or none. Nothing the plugin said besides its code is ever in it. */
|
|
24
|
-
top:
|
|
24
|
+
top: typeof UNAVAILABLE | typeof CLOSED | null;
|
|
25
25
|
/** The form closes. */
|
|
26
26
|
close: boolean;
|
|
27
27
|
/** The request is closed on the plugin's side: «→» is disabled from now on, and what was typed stays. */
|
package/client/presentation.ts
CHANGED
|
@@ -1,40 +1,22 @@
|
|
|
1
1
|
import type { CardData } from "../shared/card";
|
|
2
2
|
import type { RequestView } from "../shared/view";
|
|
3
|
-
import {
|
|
3
|
+
import type { Translate } from "./messages";
|
|
4
4
|
import type { Tone } from "./tone";
|
|
5
5
|
|
|
6
6
|
/** What the form says of how the values travel: the cipher `shared/seal.ts` really uses, and nothing else. */
|
|
7
7
|
export const FORM_BADGE = "X25519 · ChaCha20-Poly1305";
|
|
8
8
|
|
|
9
9
|
/** The form's title: one key on screen, or several. */
|
|
10
|
-
export function formTitle(rowsOnScreen: number): string {
|
|
11
|
-
return rowsOnScreen > 1 ? "
|
|
10
|
+
export function formTitle(t: Translate, rowsOnScreen: number): string {
|
|
11
|
+
return t(rowsOnScreen > 1 ? "form.titleMany" : "form.titleOne");
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/** What a screen reader says of each control that has an icon and no words, and of each input that shows no name of its own. */
|
|
15
|
-
export const A11Y: Readonly<
|
|
16
|
-
Record<"enter" | "decline" | "add" | "remove" | "show" | "hide" | "submit" | "pick" | "paste" | "removeFile" | "name" | "pasteArea", string>
|
|
17
|
-
> = {
|
|
18
|
-
enter: "Ввести значення",
|
|
19
|
-
decline: "Відхилити запит",
|
|
20
|
-
add: "Додати ключ",
|
|
21
|
-
remove: "Прибрати ключ",
|
|
22
|
-
show: "Показати значення",
|
|
23
|
-
hide: "Сховати значення",
|
|
24
|
-
submit: "Передати",
|
|
25
|
-
pick: "Вибрати файл",
|
|
26
|
-
paste: "Вставити з буфера",
|
|
27
|
-
removeFile: "Прибрати файл",
|
|
28
|
-
name: "Назва ключа",
|
|
29
|
-
pasteArea: "Вміст файлу",
|
|
30
|
-
};
|
|
31
|
-
|
|
32
14
|
/** What the name input of a row of the human's shows while it is empty: the form a key has. */
|
|
33
15
|
export const KEY_PLACEHOLDER = "KEY_NAME";
|
|
34
16
|
|
|
35
17
|
/** The eye of a text row: what it shows, and what pressing it will do. */
|
|
36
|
-
export function eye(shown: boolean): { icon: "Eye" | "EyeOff"; label: string } {
|
|
37
|
-
return shown ? { icon: "EyeOff", label:
|
|
18
|
+
export function eye(t: Translate, shown: boolean): { icon: "Eye" | "EyeOff"; label: string } {
|
|
19
|
+
return shown ? { icon: "EyeOff", label: t("a11y.hide") } : { icon: "Eye", label: t("a11y.show") };
|
|
38
20
|
}
|
|
39
21
|
|
|
40
22
|
/** The pill in the chat. Its look comes from the card's data alone, and nothing in it changes its height. */
|
|
@@ -50,33 +32,25 @@ export interface Pill {
|
|
|
50
32
|
/** The height of the pill, in every state. The chat's list does not take a row whose height changes (getpaseo/paseo#7486). */
|
|
51
33
|
export const PILL_HEIGHT = 36;
|
|
52
34
|
|
|
53
|
-
/** The word for each way a request ends without its values. All of them are drawn the same way: dimmed and struck through. */
|
|
54
|
-
const ENDED_AS: Readonly<Record<"declined" | "cancelled" | "expired" | "rejected", string>> = {
|
|
55
|
-
declined: "Відхилено",
|
|
56
|
-
cancelled: "Скасовано",
|
|
57
|
-
expired: "Час минув",
|
|
58
|
-
rejected: "Не прийнято",
|
|
59
|
-
};
|
|
60
|
-
|
|
61
35
|
/**
|
|
62
36
|
* How a request looks as a pill in each state it can be in. Only a request that waits can be pressed, and not once a
|
|
63
37
|
* second, different submission has come: that one is red in every state. A waiting request names its one key, or counts
|
|
64
38
|
* several; every other state counts them.
|
|
65
39
|
*/
|
|
66
|
-
export function pill(data: Pick<CardData, "state" | "tamper" | "keys">): Pill {
|
|
67
|
-
const count =
|
|
68
|
-
if (data.tamper) return { tone: "danger", icon: "ShieldAlert", title: "
|
|
40
|
+
export function pill(t: Translate, data: Pick<CardData, "state" | "tamper" | "keys">): Pill {
|
|
41
|
+
const count = t("pill.keys", { count: data.keys.length });
|
|
42
|
+
if (data.tamper) return { tone: "danger", icon: "ShieldAlert", title: t("pill.tamper"), detail: count, struck: false, pressable: false };
|
|
69
43
|
switch (data.state) {
|
|
70
44
|
case "pending":
|
|
71
45
|
return data.keys.length > 1
|
|
72
|
-
? { tone: "accent", icon: "Shield", title: "
|
|
73
|
-
: { tone: "accent", icon: "Shield", title: "
|
|
46
|
+
? { tone: "accent", icon: "Shield", title: t("form.titleMany"), detail: count, struck: false, pressable: true }
|
|
47
|
+
: { tone: "accent", icon: "Shield", title: t("form.titleOne"), detail: data.keys[0] ?? "", struck: false, pressable: true };
|
|
74
48
|
case "delivered":
|
|
75
|
-
return { tone: "success", icon: "ShieldCheck", title: "
|
|
49
|
+
return { tone: "success", icon: "ShieldCheck", title: t("pill.delivered"), detail: count, struck: false, pressable: false };
|
|
76
50
|
case "released":
|
|
77
|
-
return { tone: "muted", icon: "ShieldCheck", title: "
|
|
51
|
+
return { tone: "muted", icon: "ShieldCheck", title: t("pill.delivered"), detail: count, struck: false, pressable: false };
|
|
78
52
|
default:
|
|
79
|
-
return { tone: "dim", icon: "ShieldX", title:
|
|
53
|
+
return { tone: "dim", icon: "ShieldX", title: t(`pill.${data.state}`), detail: count, struck: true, pressable: false };
|
|
80
54
|
}
|
|
81
55
|
}
|
|
82
56
|
|
package/client/self-test.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fromBase64Url } from "../shared/bytes";
|
|
2
2
|
import { MAX_PAYLOAD_BYTES, buildAad, digestHex, seal, type SealedEnvelope } from "../shared/seal";
|
|
3
|
+
import type { Translate } from "./messages";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* What the self-test seals: the largest submission one Paseo call can carry. It proves on this device that the biggest thing
|
|
@@ -73,24 +74,21 @@ export async function runSelfTest(deps: SelfTestDeps, bytes: number = SELF_TEST_
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
/** What a screen reader says of the spinner that stands in the place of the result while a run is going. */
|
|
77
|
-
export const SELF_TEST_RUNNING = "Перевірка триває";
|
|
78
|
-
|
|
79
77
|
/**
|
|
80
78
|
* What the settings screen says of a run, next to the button: how long it took, or why it did not pass, in a fixed
|
|
81
79
|
* sentence and never in the words of an error. Before a run and while one is going it says nothing: the screen shows a
|
|
82
|
-
* spinner then
|
|
80
|
+
* spinner then.
|
|
83
81
|
*/
|
|
84
|
-
export function selfTestText(state: SelfTestState): string {
|
|
82
|
+
export function selfTestText(t: Translate, state: SelfTestState): string {
|
|
85
83
|
switch (state.kind) {
|
|
86
84
|
case "idle":
|
|
87
85
|
case "running":
|
|
88
86
|
return "";
|
|
89
87
|
case "passed":
|
|
90
|
-
return
|
|
88
|
+
return t("selfTest.passed", { ms: state.ms });
|
|
91
89
|
case "mismatch":
|
|
92
|
-
return "
|
|
90
|
+
return t("selfTest.mismatch");
|
|
93
91
|
default:
|
|
94
|
-
return state.stage === "seal" ? "
|
|
92
|
+
return t(state.stage === "seal" ? "selfTest.sealFailed" : "selfTest.noAnswer");
|
|
95
93
|
}
|
|
96
94
|
}
|