@hanzo/app 0.3.87 → 0.3.89

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/dist/vault.js ADDED
@@ -0,0 +1,514 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Unified Secrets & Credential Autofill Vault shared across:
4
+ // - platform.hanzo.ai (Secrets & KMS)
5
+ // - hanzo.app / hanzo.ai Settings (Computer & Browser / Security)
6
+ // - hanzo.bot (Bot inspector + Desktop Sandbox Computer 1-click & agent autofill)
7
+ //
8
+ // Non-secret metadata lives in `config` under `/v1/settings/vault`; every secret
9
+ // value (passwords, API keys, TOTP seeds, 1Password / LastPass tokens) is sealed
10
+ // directly into Hanzo KMS at `orgs/{org}/settings/vault/{key}` and never returned
11
+ // on read.
12
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
13
+ import { useI18n } from '@hanzo/i18n/react';
14
+ import { Input, Text, XStack, YStack } from '@hanzo/gui';
15
+ import { Dialog, DialogContent, DialogTitle } from '@hanzo/ui';
16
+ import { Check, Globe, KeyRound, Lock, Plus, RefreshCw, Shield, Trash2, Upload, X } from 'lucide-react';
17
+ import { api } from './lib/api.js';
18
+ import { scope } from './lib/session.js';
19
+ import { say } from './failure.js';
20
+ import { CARD, CLIP, LABEL, PILL, ROUND, WORD } from './bots/kit.js';
21
+ import { DIM, FLOOR, GROUND, INK, LINE, PICKED, RAISED } from './bots/ink.js';
22
+ function slugKey(prefix, id) {
23
+ const clean = id
24
+ .toLowerCase()
25
+ .replace(/[^a-z0-9._-]+/g, '-')
26
+ .replace(/^-+|-+$/g, '')
27
+ .slice(0, 44);
28
+ return `${prefix}_${clean || 'item'}`.slice(0, 62);
29
+ }
30
+ function mintId() {
31
+ const rand = Math.random().toString(36).slice(2, 8);
32
+ return `v_${Date.now().toString(36)}${rand}`;
33
+ }
34
+ function normalizeHost(raw) {
35
+ const s = raw.trim().toLowerCase();
36
+ if (!s)
37
+ return '';
38
+ try {
39
+ if (s.includes('://'))
40
+ return new URL(s).hostname.replace(/^www\./, '');
41
+ }
42
+ catch {
43
+ // ignore malformed URL
44
+ }
45
+ return (s.split('/')[0] ?? '').replace(/^www\./, '');
46
+ }
47
+ export async function readVault(signal) {
48
+ try {
49
+ const r = await fetch(`${api()}/v1/settings/vault`, { headers: scope(), signal });
50
+ if (!r.ok)
51
+ return { items: [], providers: {}, secretKeys: [] };
52
+ const j = (await r.json());
53
+ return {
54
+ items: Array.isArray(j.config?.items) ? j.config.items : [],
55
+ providers: j.config?.providers ?? {},
56
+ secretKeys: Array.isArray(j.secretKeys) ? j.secretKeys : [],
57
+ };
58
+ }
59
+ catch {
60
+ return { items: [], providers: {}, secretKeys: [] };
61
+ }
62
+ }
63
+ export async function writeVault(config, secrets = {}) {
64
+ const r = await fetch(`${api()}/v1/settings/vault`, {
65
+ method: 'PUT',
66
+ headers: { ...scope(), 'Content-Type': 'application/json' },
67
+ body: JSON.stringify({ config, secrets }),
68
+ });
69
+ if (!r.ok) {
70
+ const msg = await r.text().catch(() => '');
71
+ throw new Error(msg || `Vault write failed (${r.status})`);
72
+ }
73
+ const j = (await r.json());
74
+ return {
75
+ items: Array.isArray(j.config?.items) ? j.config.items : config.items,
76
+ providers: j.config?.providers ?? config.providers,
77
+ secretKeys: Array.isArray(j.secretKeys) ? j.secretKeys : [],
78
+ };
79
+ }
80
+ function parseCsvRows(raw) {
81
+ const rows = [];
82
+ let cur = [];
83
+ let field = '';
84
+ let inQuotes = false;
85
+ for (let i = 0; i < raw.length; i++) {
86
+ const ch = raw[i];
87
+ const next = raw[i + 1];
88
+ if (inQuotes) {
89
+ if (ch === '"' && next === '"') {
90
+ field += '"';
91
+ i++;
92
+ }
93
+ else if (ch === '"') {
94
+ inQuotes = false;
95
+ }
96
+ else {
97
+ field += ch;
98
+ }
99
+ }
100
+ else if (ch === '"') {
101
+ inQuotes = true;
102
+ }
103
+ else if (ch === ',') {
104
+ cur.push(field);
105
+ field = '';
106
+ }
107
+ else if (ch === '\n' || ch === '\r') {
108
+ if (ch === '\r' && next === '\n')
109
+ i++;
110
+ cur.push(field);
111
+ field = '';
112
+ if (cur.some((c) => c.trim().length > 0))
113
+ rows.push(cur);
114
+ cur = [];
115
+ }
116
+ else {
117
+ field += ch;
118
+ }
119
+ }
120
+ cur.push(field);
121
+ if (cur.some((c) => c.trim().length > 0))
122
+ rows.push(cur);
123
+ return rows;
124
+ }
125
+ export function parsePasswordImport(raw, source) {
126
+ const now = new Date().toISOString();
127
+ const items = [];
128
+ const secrets = {};
129
+ const trimmed = raw.trim();
130
+ if (!trimmed)
131
+ return { items, secrets };
132
+ // JSON export (1Password CLI `op item list --format=json` or structured export)
133
+ if (trimmed.startsWith('[') || trimmed.startsWith('{')) {
134
+ try {
135
+ const parsed = JSON.parse(trimmed);
136
+ const list = Array.isArray(parsed)
137
+ ? parsed
138
+ : Array.isArray(parsed.items)
139
+ ? parsed.items
140
+ : [];
141
+ for (const entry of list) {
142
+ if (!entry || typeof entry !== 'object')
143
+ continue;
144
+ const rec = entry;
145
+ const title = String(rec.title ?? rec.name ?? '').trim();
146
+ const urls = Array.isArray(rec.urls) ? rec.urls : [];
147
+ const rawUrl = String(rec.url ?? urls[0]?.href ?? rec.domain ?? '').trim();
148
+ const fields = Array.isArray(rec.fields) ? rec.fields : [];
149
+ const findField = (pred) => String(fields.find(pred)?.value ?? '').trim();
150
+ const username = String(rec.username ?? '').trim() ||
151
+ findField((f) => String(f.purpose ?? f.id ?? f.label ?? '').toLowerCase().includes('user'));
152
+ const secretVal = String(rec.secret ?? rec.value ?? '').trim() ||
153
+ findField((f) => {
154
+ const k = String(f.purpose ?? f.id ?? f.label ?? '').toLowerCase();
155
+ return k.includes('pass') || k.includes('credential') || k.includes('token');
156
+ });
157
+ const totpVal = String(rec.totp ?? '').trim() ||
158
+ findField((f) => String(f.type ?? f.id ?? f.label ?? '').toLowerCase().includes('otp'));
159
+ if (!secretVal)
160
+ continue;
161
+ const id = mintId();
162
+ const secretKey = slugKey('item', `${id}_s`);
163
+ secrets[secretKey] = secretVal;
164
+ let totpSecretKey;
165
+ if (totpVal) {
166
+ totpSecretKey = slugKey('item', `${id}_t`);
167
+ secrets[totpSecretKey] = totpVal;
168
+ }
169
+ items.push({
170
+ id,
171
+ kind: 'login',
172
+ name: title || normalizeHost(rawUrl) || 'Imported Login',
173
+ domain: normalizeHost(rawUrl) || undefined,
174
+ url: rawUrl || undefined,
175
+ username: username || undefined,
176
+ secretKey,
177
+ totpSecretKey,
178
+ source,
179
+ updatedAt: now,
180
+ });
181
+ }
182
+ return { items, secrets };
183
+ }
184
+ catch {
185
+ // fall through to CSV parser
186
+ }
187
+ }
188
+ // CSV export (LastPass: url,username,password,totp,extra,name,grouping,fav
189
+ // 1Password: Title,Url,Username,Password,OTPAuth)
190
+ const rows = parseCsvRows(trimmed);
191
+ if (rows.length < 2)
192
+ return { items, secrets };
193
+ const header = rows[0].map((h) => h.trim().toLowerCase());
194
+ const col = (...names) => header.findIndex((h) => names.some((n) => h === n || h.includes(n)));
195
+ const idxName = col('title', 'name');
196
+ const idxUrl = col('url', 'website', 'domain');
197
+ const idxUser = col('username', 'login', 'email');
198
+ const idxSecret = col('password', 'secret');
199
+ const idxTotp = col('otpauth', 'totp', 'one-time');
200
+ for (const row of rows.slice(1)) {
201
+ const secretVal = idxSecret >= 0 ? (row[idxSecret] ?? '').trim() : '';
202
+ if (!secretVal)
203
+ continue;
204
+ const rawUrl = idxUrl >= 0 ? (row[idxUrl] ?? '').trim() : '';
205
+ const name = idxName >= 0 ? (row[idxName] ?? '').trim() : '';
206
+ const username = idxUser >= 0 ? (row[idxUser] ?? '').trim() : '';
207
+ const totpVal = idxTotp >= 0 ? (row[idxTotp] ?? '').trim() : '';
208
+ const id = mintId();
209
+ const secretKey = slugKey('item', `${id}_s`);
210
+ secrets[secretKey] = secretVal;
211
+ let totpSecretKey;
212
+ if (totpVal) {
213
+ totpSecretKey = slugKey('item', `${id}_t`);
214
+ secrets[totpSecretKey] = totpVal;
215
+ }
216
+ items.push({
217
+ id,
218
+ kind: 'login',
219
+ name: name || normalizeHost(rawUrl) || username || 'Imported Login',
220
+ domain: normalizeHost(rawUrl) || undefined,
221
+ url: rawUrl || undefined,
222
+ username: username || undefined,
223
+ secretKey,
224
+ totpSecretKey,
225
+ source,
226
+ updatedAt: now,
227
+ });
228
+ if (Object.keys(secrets).length >= 56)
229
+ break;
230
+ }
231
+ return { items, secrets };
232
+ }
233
+ const SOURCE_LABEL = {
234
+ hanzo: 'Hanzo KMS',
235
+ '1password': '1Password',
236
+ lastpass: 'LastPass',
237
+ };
238
+ export function VaultManager({ compact = false, onAutofill, onChanged, }) {
239
+ const { t } = useI18n();
240
+ const [doc, setDoc] = useState({ items: [], providers: {}, secretKeys: [] });
241
+ const [loading, setLoading] = useState(true);
242
+ const [busy, setBusy] = useState(false);
243
+ const [notice, setNotice] = useState(null);
244
+ const [error, setError] = useState(null);
245
+ const [tab, setTab] = useState('all');
246
+ const [kind, setKind] = useState('login');
247
+ const [name, setName] = useState('');
248
+ const [domain, setDomain] = useState('');
249
+ const [envVar, setEnvVar] = useState('');
250
+ const [username, setUsername] = useState('');
251
+ const [secretValue, setSecretValue] = useState('');
252
+ const [totpValue, setTotpValue] = useState('');
253
+ // 1Password & LastPass state
254
+ const [opToken, setOpToken] = useState('');
255
+ const [opVaultName, setOpVaultName] = useState('Private');
256
+ const [lpEmail, setLpEmail] = useState('');
257
+ const [lpToken, setLpToken] = useState('');
258
+ const fileInputRef = useRef(null);
259
+ const [importSource, setImportSource] = useState('1password');
260
+ const refresh = useCallback(async (signal) => {
261
+ setLoading(true);
262
+ const next = await readVault(signal);
263
+ if (!signal?.aborted) {
264
+ setDoc(next);
265
+ if (next.providers.onepassword?.vaultName)
266
+ setOpVaultName(next.providers.onepassword.vaultName);
267
+ if (next.providers.lastpass?.email)
268
+ setLpEmail(next.providers.lastpass.email);
269
+ setLoading(false);
270
+ onChanged?.(next);
271
+ }
272
+ }, [onChanged]);
273
+ useEffect(() => {
274
+ const stop = new AbortController();
275
+ void refresh(stop.signal);
276
+ return () => stop.abort();
277
+ }, [refresh]);
278
+ const handleAdd = async (e) => {
279
+ e.preventDefault();
280
+ if (!name.trim() || !secretValue.trim() || busy)
281
+ return;
282
+ setBusy(true);
283
+ setError(null);
284
+ setNotice(null);
285
+ try {
286
+ const id = mintId();
287
+ const secretKey = slugKey('item', `${id}_s`);
288
+ const secrets = { [secretKey]: secretValue };
289
+ let totpSecretKey;
290
+ if (totpValue.trim()) {
291
+ totpSecretKey = slugKey('item', `${id}_t`);
292
+ secrets[totpSecretKey] = totpValue.trim();
293
+ }
294
+ const nextItem = {
295
+ id,
296
+ kind,
297
+ name: name.trim(),
298
+ domain: kind === 'login' ? normalizeHost(domain) || undefined : undefined,
299
+ url: kind === 'login' && domain.trim() ? domain.trim() : undefined,
300
+ envVar: kind !== 'login' && envVar.trim() ? envVar.trim().toUpperCase() : undefined,
301
+ username: kind === 'login' && username.trim() ? username.trim() : undefined,
302
+ secretKey,
303
+ totpSecretKey,
304
+ source: 'hanzo',
305
+ updatedAt: new Date().toISOString(),
306
+ };
307
+ const saved = await writeVault({ items: [nextItem, ...doc.items], providers: doc.providers }, secrets);
308
+ setDoc(saved);
309
+ onChanged?.(saved);
310
+ setName('');
311
+ setDomain('');
312
+ setEnvVar('');
313
+ setUsername('');
314
+ setSecretValue('');
315
+ setTotpValue('');
316
+ setTab('all');
317
+ setNotice(t('Sealed "{name}" into Hanzo KMS — ready across platform.hanzo.ai, hanzo.app & hanzo.bot.', { name: nextItem.name }));
318
+ }
319
+ catch (err) {
320
+ setError(say(err, t('Vault secret'), 'save', t));
321
+ }
322
+ finally {
323
+ setBusy(false);
324
+ }
325
+ };
326
+ const handleRemove = async (id) => {
327
+ if (busy)
328
+ return;
329
+ setBusy(true);
330
+ setError(null);
331
+ try {
332
+ const nextItems = doc.items.filter((i) => i.id !== id);
333
+ const saved = await writeVault({ items: nextItems, providers: doc.providers });
334
+ setDoc(saved);
335
+ onChanged?.(saved);
336
+ }
337
+ catch (err) {
338
+ setError(say(err, t('Vault item'), 'save', t));
339
+ }
340
+ finally {
341
+ setBusy(false);
342
+ }
343
+ };
344
+ const handleConnect1Password = async (e) => {
345
+ e.preventDefault();
346
+ if (busy)
347
+ return;
348
+ setBusy(true);
349
+ setError(null);
350
+ setNotice(null);
351
+ try {
352
+ const secrets = {};
353
+ if (opToken.trim())
354
+ secrets.op_service_account_token = opToken.trim();
355
+ const saved = await writeVault({
356
+ items: doc.items,
357
+ providers: {
358
+ ...doc.providers,
359
+ onepassword: {
360
+ connected: Boolean(opToken.trim() || doc.providers.onepassword?.connected),
361
+ vaultName: opVaultName.trim() || 'Private',
362
+ secretKey: 'op_service_account_token',
363
+ syncedCount: doc.items.filter((i) => i.source === '1password').length,
364
+ updatedAt: new Date().toISOString(),
365
+ },
366
+ },
367
+ }, secrets);
368
+ setDoc(saved);
369
+ onChanged?.(saved);
370
+ setOpToken('');
371
+ setNotice(t('1Password connected and Service Account token sealed in Hanzo KMS.'));
372
+ }
373
+ catch (err) {
374
+ setError(say(err, '1Password', 'save', t));
375
+ }
376
+ finally {
377
+ setBusy(false);
378
+ }
379
+ };
380
+ const handleConnectLastPass = async (e) => {
381
+ e.preventDefault();
382
+ if (busy)
383
+ return;
384
+ setBusy(true);
385
+ setError(null);
386
+ setNotice(null);
387
+ try {
388
+ const secrets = {};
389
+ if (lpToken.trim())
390
+ secrets.lp_vault_token = lpToken.trim();
391
+ const saved = await writeVault({
392
+ items: doc.items,
393
+ providers: {
394
+ ...doc.providers,
395
+ lastpass: {
396
+ connected: Boolean(lpEmail.trim() || lpToken.trim() || doc.providers.lastpass?.connected),
397
+ email: lpEmail.trim() || doc.providers.lastpass?.email,
398
+ secretKey: 'lp_vault_token',
399
+ syncedCount: doc.items.filter((i) => i.source === 'lastpass').length,
400
+ updatedAt: new Date().toISOString(),
401
+ },
402
+ },
403
+ }, secrets);
404
+ setDoc(saved);
405
+ onChanged?.(saved);
406
+ setLpToken('');
407
+ setNotice(t('LastPass account linked and vault credential sealed in Hanzo KMS.'));
408
+ }
409
+ catch (err) {
410
+ setError(say(err, 'LastPass', 'save', t));
411
+ }
412
+ finally {
413
+ setBusy(false);
414
+ }
415
+ };
416
+ const handleFileSelected = async (e) => {
417
+ const file = e.target.files?.[0];
418
+ e.target.value = '';
419
+ if (!file)
420
+ return;
421
+ setBusy(true);
422
+ setError(null);
423
+ setNotice(null);
424
+ try {
425
+ const raw = await file.text();
426
+ const parsed = parsePasswordImport(raw, importSource);
427
+ if (!parsed.items.length) {
428
+ setError(t('No login rows found in file. Export as CSV or JSON from {src} and try again.', { src: SOURCE_LABEL[importSource] }));
429
+ return;
430
+ }
431
+ const nextItems = [...parsed.items, ...doc.items];
432
+ const nextProviders = {
433
+ ...doc.providers,
434
+ ...(importSource === '1password'
435
+ ? {
436
+ onepassword: {
437
+ ...doc.providers.onepassword,
438
+ connected: true,
439
+ syncedCount: nextItems.filter((i) => i.source === '1password').length,
440
+ updatedAt: new Date().toISOString(),
441
+ },
442
+ }
443
+ : {
444
+ lastpass: {
445
+ ...doc.providers.lastpass,
446
+ connected: true,
447
+ syncedCount: nextItems.filter((i) => i.source === 'lastpass').length,
448
+ updatedAt: new Date().toISOString(),
449
+ },
450
+ }),
451
+ };
452
+ const saved = await writeVault({ items: nextItems, providers: nextProviders }, parsed.secrets);
453
+ setDoc(saved);
454
+ onChanged?.(saved);
455
+ setTab('all');
456
+ setNotice(t('Imported and KMS-sealed {n} credentials from {src}.', {
457
+ n: parsed.items.length,
458
+ src: SOURCE_LABEL[importSource],
459
+ }));
460
+ }
461
+ catch (err) {
462
+ setError(say(err, SOURCE_LABEL[importSource], 'save', t));
463
+ }
464
+ finally {
465
+ setBusy(false);
466
+ }
467
+ };
468
+ const triggerImport = (src) => {
469
+ setImportSource(src);
470
+ fileInputRef.current?.click();
471
+ };
472
+ const counts = useMemo(() => ({
473
+ logins: doc.items.filter((i) => i.kind === 'login').length,
474
+ keys: doc.items.filter((i) => i.kind !== 'login').length,
475
+ op: Boolean(doc.providers.onepassword?.connected),
476
+ lp: Boolean(doc.providers.lastpass?.connected),
477
+ }), [doc]);
478
+ return (_jsxs(YStack, { gap: 14, "data-parity-key": "vault.manager", children: [_jsx("input", { ref: fileInputRef, type: "file", accept: ".csv,.json,.txt", onChange: (e) => void handleFileSelected(e), hidden: true }), _jsxs(XStack, { items: "center", justify: "space-between", gap: 8, flexWrap: "wrap", children: [_jsx(XStack, { p: 3, rounded: 999, bg: RAISED, borderWidth: 1, borderColor: LINE, gap: 2, flexWrap: "wrap", children: [
479
+ { id: 'all', label: t('Vault ({n})', { n: doc.items.length }) },
480
+ { id: 'add', label: t('+ Add Secret / Login') },
481
+ { id: '1password', label: counts.op ? '1Password ✓' : '1Password' },
482
+ { id: 'lastpass', label: counts.lp ? 'LastPass ✓' : 'LastPass' },
483
+ ].map((item) => {
484
+ const active = tab === item.id;
485
+ return (_jsx(XStack, { render: "button", type: 'button', onClick: () => setTab(item.id), height: 28, px: 12, rounded: 999, items: "center", bg: active ? PICKED : 'transparent', borderWidth: 0, cursor: "pointer", children: _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: active ? '500' : '400', color: active ? INK : DIM, children: item.label }) }, item.id));
486
+ }) }), _jsx(XStack, { ...ROUND, width: 30, height: 30, "aria-label": t('Refresh vault'), onClick: () => void refresh(), children: _jsx(RefreshCw, { size: 13, color: DIM, "aria-hidden": true }) })] }), notice ? (_jsxs(XStack, { px: 12, py: 8, rounded: 10, bg: RAISED, borderWidth: 1, borderColor: LINE, gap: 8, items: "center", children: [_jsx(Check, { size: 14, color: INK, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 17, color: INK, flex: 1, children: notice })] })) : null, error ? (_jsx(Text, { role: "alert", fontSize: 12, lineHeight: 17, color: DIM, children: error })) : null, tab === 'add' ? (_jsxs(YStack, { render: "form", onSubmit: (e) => void handleAdd(e), ...CARD, p: 14, gap: 12, children: [_jsx(XStack, { gap: 6, flexWrap: "wrap", children: [
487
+ { id: 'login', label: t('Website Login (Autofill)') },
488
+ { id: 'api_key', label: t('Shared API Key') },
489
+ { id: 'secret', label: t('Environment Secret') },
490
+ ].map((opt) => {
491
+ const picked = kind === opt.id;
492
+ return (_jsx(XStack, { render: "button", type: 'button', onClick: () => setKind(opt.id), height: 28, px: 11, rounded: 999, items: "center", bg: picked ? INK : GROUND, borderWidth: 1, borderColor: picked ? INK : LINE, cursor: "pointer", children: _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: "500", color: picked ? 'var(--background)' : INK, children: opt.label }) }, opt.id));
493
+ }) }), _jsxs(XStack, { gap: 10, flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 180, gap: 4, children: [_jsx(Text, { fontSize: 12, color: DIM, children: t('Name') }), _jsx(Input, { unstyled: true, value: name, onChange: (e) => setName(e.target.value), placeholder: kind === 'login' ? 'GitHub Production' : 'Stripe Live Key', height: 36, px: 11, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13 })] }), kind === 'login' ? (_jsxs(YStack, { flex: 1, minW: 180, gap: 4, children: [_jsx(Text, { fontSize: 12, color: DIM, children: t('Website Domain or URL') }), _jsx(Input, { unstyled: true, value: domain, onChange: (e) => setDomain(e.target.value), placeholder: "github.com", height: 36, px: 11, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13 })] })) : (_jsxs(YStack, { flex: 1, minW: 180, gap: 4, children: [_jsx(Text, { fontSize: 12, color: DIM, children: t('Environment Variable') }), _jsx(Input, { unstyled: true, value: envVar, onChange: (e) => setEnvVar(e.target.value), placeholder: "STRIPE_SECRET_KEY", height: 36, px: 11, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13 })] }))] }), kind === 'login' ? (_jsxs(YStack, { gap: 4, children: [_jsx(Text, { fontSize: 12, color: DIM, children: t('Username or Email') }), _jsx(Input, { unstyled: true, value: username, onChange: (e) => setUsername(e.target.value), placeholder: "ops@hanzo.ai", height: 36, px: 11, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13 })] })) : null, _jsxs(XStack, { gap: 10, flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 200, gap: 4, children: [_jsx(Text, { fontSize: 12, color: DIM, children: kind === 'login' ? t('Password (sealed in Hanzo KMS)') : t('Secret Value (sealed in Hanzo KMS)') }), _jsx(Input, { unstyled: true, secureTextEntry: true, value: secretValue, onChange: (e) => setSecretValue(e.target.value), placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022", height: 36, px: 11, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13 })] }), kind === 'login' ? (_jsxs(YStack, { flex: 1, minW: 200, gap: 4, children: [_jsx(Text, { fontSize: 12, color: DIM, children: t('2FA TOTP Seed / otpauth:// (optional)') }), _jsx(Input, { unstyled: true, secureTextEntry: true, value: totpValue, onChange: (e) => setTotpValue(e.target.value), placeholder: "JBSWY3DPEHPK3PXP", height: 36, px: 11, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13 })] })) : null] }), _jsxs(XStack, { justify: "space-between", items: "center", gap: 8, pt: 2, children: [_jsx(Text, { fontSize: 11, lineHeight: 16, color: DIM, flex: 1, children: t('Values are KMS-encrypted at rest and never exposed in browser storage or model transcripts.') }), _jsxs(XStack, { ...PILL, type: 'submit', height: 34, px: 15, bg: INK, borderColor: INK, disabled: !name.trim() || !secretValue.trim() || busy, opacity: !name.trim() || !secretValue.trim() || busy ? 0.45 : 1, children: [_jsx(Lock, { size: 13, color: "var(--background)", "aria-hidden": true }), _jsx(Text, { ...WORD, fontSize: 13, color: "var(--background)", children: busy ? t('Sealing…') : t('Seal in KMS') })] })] })] })) : null, tab === '1password' ? (_jsxs(YStack, { render: "form", onSubmit: (e) => void handleConnect1Password(e), ...CARD, p: 14, gap: 12, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: 10, flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 200, children: [_jsx(Text, { fontSize: 14, fontWeight: "600", color: INK, children: t('1Password Autofill & Vault Sync') }), _jsx(Text, { fontSize: 12, lineHeight: 17, color: DIM, children: t('Connect a 1Password Service Account token or import a 1Password CSV/JSON export into Hanzo KMS for instant zero-knowledge bot login autofill.') })] }), _jsxs(XStack, { ...PILL, height: 32, px: 12, onClick: () => triggerImport('1password'), children: [_jsx(Upload, { size: 13, color: INK, "aria-hidden": true }), _jsx(Text, { fontSize: 12, fontWeight: "500", color: INK, children: t('Import 1Password CSV / JSON') })] })] }), _jsxs(XStack, { gap: 10, flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 160, gap: 4, children: [_jsx(Text, { fontSize: 12, color: DIM, children: t('Default Vault Name') }), _jsx(Input, { unstyled: true, value: opVaultName, onChange: (e) => setOpVaultName(e.target.value), placeholder: "Employee / Shared", height: 36, px: 11, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13 })] }), _jsxs(YStack, { flex: 2, minW: 220, gap: 4, children: [_jsx(Text, { fontSize: 12, color: DIM, children: t('Service Account Token (OP_SERVICE_ACCOUNT_TOKEN)') }), _jsx(Input, { unstyled: true, secureTextEntry: true, value: opToken, onChange: (e) => setOpToken(e.target.value), placeholder: counts.op ? '•••••••• (sealed in KMS)' : 'ops_eyJ...', height: 36, px: 11, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13 })] })] }), _jsx(XStack, { justify: "flex-end", children: _jsx(XStack, { ...PILL, type: 'submit', height: 34, px: 14, bg: INK, borderColor: INK, disabled: busy, children: _jsx(Text, { ...WORD, fontSize: 13, color: "var(--background)", children: counts.op ? t('Update 1Password') : t('Connect 1Password') }) }) })] })) : null, tab === 'lastpass' ? (_jsxs(YStack, { render: "form", onSubmit: (e) => void handleConnectLastPass(e), ...CARD, p: 14, gap: 12, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: 10, flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 200, children: [_jsx(Text, { fontSize: 14, fontWeight: "600", color: INK, children: t('LastPass Autofill & Vault Sync') }), _jsx(Text, { fontSize: 12, lineHeight: 17, color: DIM, children: t('Link LastPass or import a LastPass Vault CSV so bots and sandbox desktops can autofill logins and 2FA codes safely.') })] }), _jsxs(XStack, { ...PILL, height: 32, px: 12, onClick: () => triggerImport('lastpass'), children: [_jsx(Upload, { size: 13, color: INK, "aria-hidden": true }), _jsx(Text, { fontSize: 12, fontWeight: "500", color: INK, children: t('Import LastPass CSV') })] })] }), _jsxs(XStack, { gap: 10, flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 180, gap: 4, children: [_jsx(Text, { fontSize: 12, color: DIM, children: t('LastPass Account Email') }), _jsx(Input, { unstyled: true, value: lpEmail, onChange: (e) => setLpEmail(e.target.value), placeholder: "team@hanzo.ai", height: 36, px: 11, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13 })] }), _jsxs(YStack, { flex: 1, minW: 180, gap: 4, children: [_jsx(Text, { fontSize: 12, color: DIM, children: t('API / CLI Token (optional)') }), _jsx(Input, { unstyled: true, secureTextEntry: true, value: lpToken, onChange: (e) => setLpToken(e.target.value), placeholder: counts.lp ? '•••••••• (sealed in KMS)' : '••••••••', height: 36, px: 11, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13 })] })] }), _jsx(XStack, { justify: "flex-end", children: _jsx(XStack, { ...PILL, type: 'submit', height: 34, px: 14, bg: INK, borderColor: INK, disabled: busy, children: _jsx(Text, { ...WORD, fontSize: 13, color: "var(--background)", children: counts.lp ? t('Update LastPass') : t('Connect LastPass') }) }) })] })) : null, tab === 'all' ? (doc.items.length === 0 ? (_jsxs(YStack, { ...CARD, p: compact ? 14 : 20, items: "center", gap: 10, children: [_jsx(Shield, { size: 22, color: DIM, "aria-hidden": true }), _jsx(Text, { fontSize: 14, fontWeight: "500", color: INK, text: "center", children: loading ? t('Loading Unified Vault…') : t('No shared secrets or autofill logins yet') }), _jsx(Text, { fontSize: 12, lineHeight: 18, color: DIM, text: "center", maxW: 440, children: t('Secrets added here or on platform.hanzo.ai are KMS-sealed once and available across hanzo.app Settings and hanzo.bot desktop autofill.') }), _jsxs(XStack, { gap: 8, flexWrap: "wrap", justify: "center", children: [_jsxs(XStack, { ...PILL, height: 32, px: 13, bg: INK, borderColor: INK, onClick: () => setTab('add'), children: [_jsx(Plus, { size: 13, color: "var(--background)", "aria-hidden": true }), _jsx(Text, { fontSize: 12, fontWeight: "500", color: "var(--background)", children: t('Add Login or Secret') })] }), _jsx(XStack, { ...PILL, height: 32, px: 12, onClick: () => setTab('1password'), children: _jsx(Text, { fontSize: 12, fontWeight: "500", color: INK, children: "1Password" }) }), _jsx(XStack, { ...PILL, height: 32, px: 12, onClick: () => setTab('lastpass'), children: _jsx(Text, { fontSize: 12, fontWeight: "500", color: INK, children: "LastPass" }) })] })] })) : (_jsx(YStack, { ...CARD, children: doc.items.map((item, idx) => {
494
+ const isLogin = item.kind === 'login';
495
+ const subParts = [
496
+ SOURCE_LABEL[item.source || 'hanzo'],
497
+ item.domain,
498
+ item.username,
499
+ item.envVar,
500
+ item.totpSecretKey ? '2FA TOTP' : undefined,
501
+ ].filter(Boolean);
502
+ return (_jsxs(XStack, { px: 13, py: 10, gap: 11, items: "center", borderBottomWidth: idx === doc.items.length - 1 ? 0 : 1, borderColor: LINE, children: [isLogin ? _jsx(Globe, { size: 16, color: DIM, "aria-hidden": true }) : _jsx(KeyRound, { size: 16, color: DIM, "aria-hidden": true }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(Text, { ...CLIP, fontSize: 14, lineHeight: 19, fontWeight: "500", color: INK, children: item.name }), _jsx(Text, { ...CLIP, fontSize: 12, lineHeight: 16, color: DIM, children: subParts.join(' · ') })] }), onAutofill && isLogin ? (_jsxs(XStack, { gap: 6, items: "center", children: [_jsx(XStack, { ...PILL, height: 28, px: 10, bg: INK, borderColor: INK, onClick: () => onAutofill(item, 'login'), children: _jsx(Text, { fontSize: 11, fontWeight: "500", color: "var(--background)", children: t('Autofill') }) }), item.totpSecretKey ? (_jsx(XStack, { ...PILL, height: 28, px: 9, onClick: () => onAutofill(item, 'totp'), children: _jsx(Text, { fontSize: 11, fontWeight: "500", color: INK, children: "2FA" }) })) : null] })) : (_jsx(Text, { fontSize: 11, color: DIM, children: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" })), _jsx(XStack, { render: "button", type: 'button', "aria-label": t('Remove {name}', { name: item.name }), onClick: () => void handleRemove(item.id), width: 28, height: 28, rounded: 999, items: "center", justify: "center", bg: "transparent", borderWidth: 0, cursor: "pointer", hoverStyle: { bg: PICKED }, children: _jsx(Trash2, { size: 13, color: DIM, "aria-hidden": true }) })] }, item.id));
503
+ }) }))) : null] }));
504
+ }
505
+ export function VaultDialog({ open, onOpenChange, onAutofill, onChanged, }) {
506
+ const { t } = useI18n();
507
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsx(DialogContent, { "data-parity-key": "bots.vault.dialog", width: "94vw", maxW: 680, height: "78vh", maxH: "86vh", p: 0, showCloseButton: false, bg: GROUND, borderWidth: 1, borderColor: LINE, rounded: 18, overflow: "hidden", children: _jsxs(YStack, { height: "78vh", maxH: "86vh", bg: GROUND, children: [_jsxs(XStack, { px: 18, py: 13, items: "center", justify: "space-between", bg: FLOOR, borderBottomWidth: 1, borderColor: LINE, children: [_jsxs(YStack, { minW: 0, children: [_jsx(DialogTitle, { children: _jsx(Text, { fontSize: 16, lineHeight: 21, fontWeight: "600", color: INK, children: t('Unified Secrets & Login Autofill') }) }), _jsx(Text, { fontSize: 12, lineHeight: 16, color: DIM, children: t('Shared across platform.hanzo.ai, hanzo.app Settings & hanzo.bot · KMS-sealed') })] }), _jsx(XStack, { ...ROUND, width: 32, height: 32, "aria-label": t('Close'), onClick: () => onOpenChange(false), children: _jsx(X, { size: 15, color: INK, "aria-hidden": true }) })] }), _jsx(YStack, { flex: 1, minH: 0, overflowY: "auto", p: 18, children: _jsx(VaultManager, { onAutofill: onAutofill
508
+ ? (item, field) => {
509
+ onAutofill(item, field);
510
+ onOpenChange(false);
511
+ }
512
+ : undefined, onChanged: onChanged }) })] }) }) }));
513
+ }
514
+ export { LABEL as VAULT_LABEL };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/app",
3
- "version": "0.3.87",
3
+ "version": "0.3.89",
4
4
  "description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",