-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
411 lines (359 loc) · 9.18 KB
/
Copy pathtypes.ts
File metadata and controls
411 lines (359 loc) · 9.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
export type HostConfig = {
host: string;
hostName: string;
user: string;
port: number;
identityFile: string;
proxyJump: string;
proxyCommand: string;
};
/** OpenSSH StrictHostKeyChecking modes persisted per host (kebab-case JSON, matches Rust). */
export type StrictHostKeyPolicy = "ask" | "accept-new" | "no";
export type HostMetadata = {
favorite: boolean;
tags: string[];
lastUsedAt: number | null;
trustHostDefault: boolean;
/** When set, drives SSH `-o StrictHostKeyChecking=…` for saved hosts. */
strictHostKeyPolicy?: StrictHostKeyPolicy;
/** Bastion host: listed in ProxyJump shortcuts once at least one host is marked. */
isJumpHost?: boolean;
};
export type HostMetadataStore = {
defaultUser: string;
hosts: Record<string, HostMetadata>;
};
/** Must match `ENTITY_STORE_SCHEMA_VERSION` in `store_models.rs`. */
export const ENTITY_STORE_SCHEMA_VERSION = 3 as const;
export type StoreSchemaVersion = typeof ENTITY_STORE_SCHEMA_VERSION;
export type KeyKdf = "argon2id";
export type HostKeyRef = {
keyId: string;
usage: string;
};
export type UserObject = {
id: string;
name: string;
username: string;
/** When set and this user is linked on a host binding, overrides SSH HostName for the session. */
hostName: string;
/** When set and the host binding has no ProxyJump, used as ProxyJump for the session. */
proxyJump: string;
keyRefs: HostKeyRef[];
tagIds: string[];
createdAt: number;
updatedAt: number;
};
export type GroupObject = {
id: string;
name: string;
memberUserIds: string[];
tagIds: string[];
createdAt: number;
updatedAt: number;
};
export type TagObject = {
id: string;
name: string;
createdAt: number;
updatedAt: number;
};
export type PathSshKeyObject = {
type: "path";
id: string;
name: string;
identityFilePath: string;
tagIds: string[];
createdAt: number;
updatedAt: number;
};
export type EncryptedSshKeyObject = {
type: "encrypted";
id: string;
name: string;
ciphertext: string;
kdf: KeyKdf;
salt: string;
nonce: string;
fingerprint: string;
publicKey: string;
tagIds: string[];
createdAt: number;
updatedAt: number;
};
export type SshKeyObject = PathSshKeyObject | EncryptedSshKeyObject;
export type HostBinding = {
userId?: string;
groupIds: string[];
tagIds: string[];
keyRefs: HostKeyRef[];
proxyJump: string;
legacyUser: string;
legacyTags: string[];
legacyIdentityFile: string;
legacyProxyJump: string;
legacyProxyCommand: string;
};
export type EntityStore = {
schemaVersion: StoreSchemaVersion | number;
updatedAt: number;
users: Record<string, UserObject>;
groups: Record<string, GroupObject>;
keys: Record<string, SshKeyObject>;
tags: Record<string, TagObject>;
hostBindings: Record<string, HostBinding>;
};
export type BackupPayload = {
sshConfig: string;
metadata: HostMetadataStore;
exportedAt: number;
};
/** Paths for OpenSSH data root (`config`, store, etc.). From `get_ssh_dir_info`. */
export type SshDirInfo = {
defaultPath: string;
effectivePath: string;
overridePath: string | null;
userProfile: string | null;
};
/** Persisted under the SSH directory; drives Rust connect and HTTP timeouts. */
export type AppPreferences = {
connectTimeoutSecs: number;
httpRequestTimeoutSecs: number;
nssCommanderUseClassicGutter: boolean;
};
export type SessionOutputEvent = {
session_id: string;
chunk: string;
host_key_prompt: boolean;
};
export type SessionStarted = {
session_id: string;
};
export type QuickSshSessionRequest = {
hostName: string;
user: string;
port?: number;
identityFile: string;
proxyJump: string;
proxyCommand: string;
/** Overrides metadata for Quick Connect sessions. */
strictHostKeyPolicy?: StrictHostKeyPolicy;
};
export type SftpDirEntry = {
name: string;
isDir: boolean;
/** Directories first when sorting; true for dirs and for symlinks pointing at a directory. */
sortWithDirectories: boolean;
size: number;
mtime: number | null;
/** Permission mode string only, e.g. `drwxr-xr-x` (owner/group are separate fields). */
modeDisplay: string;
/** Permission bits only, e.g. `755`. */
modeOctal: string;
/** Numeric uid from the server when available. */
userDisplay: string;
/** Numeric gid from the server when available. */
groupDisplay: string;
};
export type LocalDirEntry = {
name: string;
isDir: boolean;
/** Directories first when sorting; true for dirs and for symlinks pointing at a directory. */
sortWithDirectories: boolean;
size: number;
mtime: number | null;
/** Permission mode string only; owner/group are in `userDisplay` / `groupDisplay`. */
modeDisplay: string;
modeOctal: string;
userDisplay: string;
groupDisplay: string;
};
export type RemoteSshSpec =
| { kind: "saved"; host: HostConfig }
| { kind: "quick"; request: QuickSshSessionRequest };
export type PaneLayoutItem = {
id: string;
width: number;
height: number;
};
export type LayoutPaneSessionKind = "sshSaved" | "local" | "sshQuick";
export type LayoutPaneSnapshot = {
width: number;
height: number;
hostAlias: string | null;
/** Present in saved layouts v2; omitted in older files (infer from hostAlias). */
sessionKind?: LayoutPaneSessionKind | null;
/** Required when sessionKind is sshQuick. */
quickSsh?: QuickSshSessionRequest | null;
/** Proxmox-only: PEM certificate. */
tlsTrustedCertPem?: string | null;
};
export type LayoutSplitTreeNode =
| {
id: string;
type: "leaf";
paneIndex: number;
}
| {
id: string;
type: "split";
axis: "horizontal" | "vertical";
ratio: number;
first: LayoutSplitTreeNode;
second: LayoutSplitTreeNode;
};
export type LayoutProfile = {
id: string;
name: string;
withHosts: boolean;
panes: LayoutPaneSnapshot[];
splitTree?: LayoutSplitTreeNode | null;
createdAt: number;
updatedAt: number;
};
export type ViewBuiltInId = "all" | "favorites";
export type ViewFilterField =
| "host"
| "hostName"
| "user"
| "port"
| "status"
| "favorite"
| "recent"
| "tag";
export type ViewFilterOperator =
| "equals"
| "not_equals"
| "contains"
| "starts_with"
| "ends_with"
| "greater_than"
| "less_than"
| "in";
export type ViewFilterRule = {
id: string;
field: ViewFilterField;
operator: ViewFilterOperator;
value: string;
};
export type ViewFilterGroup = {
id: string;
mode: "and" | "or";
rules: ViewFilterRule[];
groups: ViewFilterGroup[];
};
export type ViewSortField = "host" | "hostName" | "user" | "port" | "lastUsedAt" | "status" | "favorite";
export type ViewSortRule = {
field: ViewSortField;
direction: "asc" | "desc";
};
export type ViewProfile = {
id: string;
name: string;
order: number;
filterGroup: ViewFilterGroup;
sortRules: ViewSortRule[];
createdAt: number;
updatedAt: number;
};
export type PluginCapability = "credentialProvider" | "settingsUi" | "hostMetadataEnricher";
export type PluginManifest = {
id: string;
version: string;
displayName: string;
capabilities: PluginCapability[];
};
export type PluginListEntry = {
manifest: PluginManifest;
enabled: boolean;
entitlementOk: boolean;
};
export type LicensePayload = {
v: number;
licenseId: string;
entitlements: string[];
iat: number;
exp?: number | null;
};
export type LicenseStatus = {
active: boolean;
licenseId: string | null;
entitlements: string[];
exp: number | null;
};
export type HetznerProjectRow = {
id: string;
name: string;
};
export type HetznerListStateResponse = {
activeProjectId: string | null;
projects: HetznerProjectRow[];
favoritesByProject?: Record<string, string[]>;
};
export type HetznerServerRow = {
type: "server";
id: string;
name: string;
status: string;
ip4: string;
ip6: string;
serverType: string;
cores: number;
memoryGb: number;
diskGb: number;
datacenter: string;
image: string;
created: string;
};
export type HetznerConsoleResponse = {
ok: boolean;
wssUrl: string;
password: string;
};
export type KnownHostConflictLine = {
hostLabel: string;
lineNumber: number;
content: string;
};
export type KnownHostMismatchPayload = {
mismatchedHosts: string[];
knownHostsPath: string;
conflictingLines: KnownHostConflictLine[];
};
const KNOWN_HOST_MISMATCH_PREFIX = "KNOWN_HOST_MISMATCH:";
export function parseKnownHostMismatch(error: string): KnownHostMismatchPayload | null {
if (!error.startsWith(KNOWN_HOST_MISMATCH_PREFIX)) {
return null;
}
try {
return JSON.parse(error.slice(KNOWN_HOST_MISMATCH_PREFIX.length)) as KnownHostMismatchPayload;
} catch {
return null;
}
}
export type KnownHostEntry = {
lineNumber: number;
hostnames: string;
keyType: string;
keyFingerprint: string;
isHashed: boolean;
rawLine: string;
};
export type KnownHostUnknownPayload = {
hostname: string;
port: number;
keyType: string;
keyFingerprint: string;
keyBase64: string;
};
const KNOWN_HOST_UNKNOWN_PREFIX = "KNOWN_HOST_UNKNOWN:";
export function parseKnownHostUnknown(error: string): KnownHostUnknownPayload | null {
if (!error.startsWith(KNOWN_HOST_UNKNOWN_PREFIX)) {
return null;
}
try {
return JSON.parse(error.slice(KNOWN_HOST_UNKNOWN_PREFIX.length)) as KnownHostUnknownPayload;
} catch {
return null;
}
}