paseo-plugin-secure-input 0.2.2 → 0.4.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/client/fields.tsx CHANGED
@@ -1,9 +1,11 @@
1
+ import { useTranslation } from "@getpaseo/plugin/client";
1
2
  import { Icon, TextInput } from "@getpaseo/plugin/client/ui";
2
3
  import { useEffect, useMemo, useRef, useState } from "react";
3
4
  import { ActivityIndicator, Platform, Pressable, Text, View } from "react-native";
4
5
  import { checkedFile, fileLine, fromPasted, takeFile, type FileValue } from "./file-entry";
5
6
  import type { FormRow } from "./form-state";
6
- import { A11Y, KEY_PLACEHOLDER, eye } from "./presentation";
7
+ import { messages, type Translate } from "./messages";
8
+ import { KEY_PLACEHOLDER, eye } from "./presentation";
7
9
  import type { Tone } from "./tone";
8
10
  import { canPickFiles, pickFile, useFileDrop } from "./web";
9
11
 
@@ -52,7 +54,7 @@ interface IconButtonProps {
52
54
  busy?: boolean;
53
55
  }
54
56
 
55
- /** A control with an icon and no words: what it does is its accessibility label, in Ukrainian, and the field it is for its hint. */
57
+ /** A control with an icon and no words: what it does is its accessibility label, in the app's language, and the field it is for its hint. */
56
58
  export function IconButton({ icon, label, hint, color, onPress, disabled = false, fill, busy = false }: IconButtonProps) {
57
59
  return (
58
60
  <Pressable
@@ -96,12 +98,12 @@ function KeyText({ row, colors }: { row: FormRow; colors: Tone }) {
96
98
  }
97
99
 
98
100
  /** The name of a key the human adds. A name is not a secret, so it is shown as typed; a screen reader is told what it is. */
99
- function NameInput({ row, colors, locked, onName }: { row: FormRow; colors: Tone; locked: boolean; onName(key: string): void }) {
101
+ function NameInput({ t, row, colors, locked, onName }: { t: Translate; row: FormRow; colors: Tone; locked: boolean; onName(key: string): void }) {
100
102
  return (
101
103
  <TextInput
102
104
  value={row.key}
103
105
  onChangeText={onName}
104
- accessibilityLabel={A11Y.name}
106
+ accessibilityLabel={t("a11y.name")}
105
107
  placeholder={KEY_PLACEHOLDER}
106
108
  placeholderTextColor={colors.muted}
107
109
  editable={!locked}
@@ -137,13 +139,14 @@ interface TextRowProps extends RowProps {
137
139
  * of the row takes a press, the eye included.
138
140
  */
139
141
  export function TextRow({ row, hint, error, colors, locked, onText, onName, onToFile, onRemove }: TextRowProps) {
142
+ const { t } = useTranslation(messages);
140
143
  const [shown, setShown] = useState(false);
141
- const look = eye(shown);
144
+ const look = eye(t, shown);
142
145
  const text = row.value.kind === "text" ? row.value.text : "";
143
146
  return (
144
147
  <View style={{ gap: 4, opacity: locked ? 0.5 : 1 }}>
145
148
  <View style={boxStyle(colors, error !== null)}>
146
- {row.declared ? <KeyText row={row} colors={colors} /> : <NameInput row={row} colors={colors} locked={locked} onName={onName} />}
149
+ {row.declared ? <KeyText row={row} colors={colors} /> : <NameInput t={t} row={row} colors={colors} locked={locked} onName={onName} />}
147
150
  <TextInput
148
151
  value={text}
149
152
  onChangeText={onText}
@@ -157,8 +160,8 @@ export function TextRow({ row, hint, error, colors, locked, onText, onName, onTo
157
160
  <IconButton icon={look.icon} label={look.label} color={colors.muted} disabled={locked} onPress={() => setShown((current) => !current)} />
158
161
  {row.declared ? null : (
159
162
  <>
160
- <IconButton icon="Paperclip" label={A11Y.pick} color={colors.muted} disabled={locked} onPress={onToFile} />
161
- <IconButton icon="X" label={A11Y.remove} color={colors.muted} disabled={locked} onPress={onRemove} />
163
+ <IconButton icon="Paperclip" label={t("a11y.pick")} color={colors.muted} disabled={locked} onPress={onToFile} />
164
+ <IconButton icon="X" label={t("a11y.remove")} color={colors.muted} disabled={locked} onPress={onRemove} />
162
165
  </>
163
166
  )}
164
167
  </View>
@@ -180,6 +183,7 @@ interface FileRowProps extends RowProps {
180
183
  * loses focus its text becomes the file and the area closes. The agent's label is the hint of each of its controls.
181
184
  */
182
185
  export function FileRow({ row, hint, error, colors, locked, onName, onFile, onClearFile, onRemove }: FileRowProps) {
186
+ const { t } = useTranslation(messages);
183
187
  const box = useRef<View>(null);
184
188
  const alive = useRef(true);
185
189
  useEffect(() => {
@@ -191,7 +195,7 @@ export function FileRow({ row, hint, error, colors, locked, onName, onFile, onCl
191
195
  const [pasting, setPasting] = useState(false);
192
196
  const [pasted, setPasted] = useState("");
193
197
  const file = row.value.kind === "file" ? row.value.file : null;
194
- const line = useMemo(() => (file === null ? null : fileLine(file, row.format, checkedFile(file, row.format))), [file, row.format]);
198
+ const line = useMemo(() => (file === null ? null : fileLine(t, file, row.format, checkedFile(file, row.format))), [t, file, row.format]);
195
199
 
196
200
  // A file is handed on only while the row is unlocked and mounted, and wiped otherwise (`takeFile`).
197
201
  const take = (value: FileValue) =>
@@ -217,30 +221,30 @@ export function FileRow({ row, hint, error, colors, locked, onName, onFile, onCl
217
221
  return (
218
222
  <View style={{ gap: 4, opacity: locked ? 0.5 : 1 }}>
219
223
  <View ref={box} style={boxStyle(colors, error !== null, file === null)}>
220
- {row.declared ? <KeyText row={row} colors={colors} /> : <NameInput row={row} colors={colors} locked={locked} onName={onName} />}
224
+ {row.declared ? <KeyText row={row} colors={colors} /> : <NameInput t={t} row={row} colors={colors} locked={locked} onName={onName} />}
221
225
  {row.format === "any" ? null : <Text style={{ color: colors.muted, opacity: 0.7, fontFamily: MONO, fontSize: 11 }}>{row.format}</Text>}
222
226
  {line === null ? (
223
227
  <>
224
228
  <View style={{ flex: 1 }} />
225
- {canPickFiles ? <IconButton icon="Paperclip" label={A11Y.pick} hint={hint} color={colors.muted} disabled={locked} onPress={pick} /> : null}
226
- <IconButton icon="ClipboardPaste" label={A11Y.paste} hint={hint} color={colors.muted} disabled={locked} onPress={() => setPasting(true)} />
229
+ {canPickFiles ? <IconButton icon="Paperclip" label={t("a11y.pick")} hint={hint} color={colors.muted} disabled={locked} onPress={pick} /> : null}
230
+ <IconButton icon="ClipboardPaste" label={t("a11y.paste")} hint={hint} color={colors.muted} disabled={locked} onPress={() => setPasting(true)} />
227
231
  </>
228
232
  ) : (
229
233
  <>
230
234
  <Text numberOfLines={1} style={{ flex: 1, color: colors.text, fontSize: 12 }}>
231
235
  {line}
232
236
  </Text>
233
- <IconButton icon="X" label={A11Y.removeFile} hint={hint} color={colors.muted} disabled={locked} onPress={onClearFile} />
237
+ <IconButton icon="X" label={t("a11y.removeFile")} hint={hint} color={colors.muted} disabled={locked} onPress={onClearFile} />
234
238
  </>
235
239
  )}
236
- {row.declared ? null : <IconButton icon="X" label={A11Y.remove} color={colors.muted} disabled={locked} onPress={onRemove} />}
240
+ {row.declared ? null : <IconButton icon="X" label={t("a11y.remove")} color={colors.muted} disabled={locked} onPress={onRemove} />}
237
241
  </View>
238
242
  {pasting ? (
239
243
  <TextInput
240
244
  value={pasted}
241
245
  onChangeText={setPasted}
242
246
  onBlur={endPaste}
243
- accessibilityLabel={A11Y.pasteArea}
247
+ accessibilityLabel={t("a11y.pasteArea")}
244
248
  accessibilityHint={hint === "" ? undefined : hint}
245
249
  multiline
246
250
  autoFocus
@@ -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 { bytesText } from "./text";
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: "Це не JSON" | "Це не PEM" | "Не довше 128 КіБ" };
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
- /** `LIMITS.fileBytes`, 128 KiB, as the form words it: a literal, so that the type says which line it is. */
24
- const TOO_LARGE: FileCheck = { ok: false, message: "Не довше 128 КіБ" };
25
- const NOT_JSON: FileCheck = { ok: false, message: "Це не JSON" };
26
- const NOT_PEM: FileCheck = { ok: false, message: "Це не PEM" };
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,1 КіБ»: the size of a file, in bytes below a KiB and in KiB with one decimal above. */
68
- export function sizeText(bytes: number): string {
69
- if (bytes < 1024) return bytesText(bytes);
70
- return `${(bytes / 1024).toFixed(1).replace(".", ",")} КіБ`;
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 «вставлено» for a paste, its size, and for a format that
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 ? "вставлено" : sanitizeText(file.name, NAME_MAX);
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
  }
@@ -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: INVALID_NAME };
63
- if (RESERVED_KEYS.includes(key)) return { key: null, error: RESERVED_NAME };
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: `Вже є ${earlier}` };
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: TEXT_TOO_LARGE, entry: null };
80
- if (hasLoneSurrogate(text)) return { error: BROKEN_TEXT, entry: null };
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: TOTAL_TOO_LARGE };
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: string | null;
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. */