clinkx 1.4.0 → 1.4.2

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/clinkx-workflows/dist/dashboard-ui/assets/{index-DSOtuS0p.js → index-CX4FrhYN.js} +1 -1
  3. package/clinkx-workflows/dist/dashboard-ui/index.html +1 -1
  4. package/clinkx-workflows/dist/settings/registry.js +5 -0
  5. package/clinkx-workflows/dist/settings/registry.js.map +1 -1
  6. package/dist/dashboard-cli.d.ts +11 -3
  7. package/dist/dashboard-cli.js +149 -32
  8. package/dist/dashboard-cli.js.map +1 -1
  9. package/dist/dashboard-companion/client.d.ts +14 -0
  10. package/dist/dashboard-companion/client.js +16 -0
  11. package/dist/dashboard-companion/client.js.map +1 -1
  12. package/dist/dashboard-companion/credential-expectation.d.ts +23 -0
  13. package/dist/dashboard-companion/credential-expectation.js +50 -0
  14. package/dist/dashboard-companion/credential-expectation.js.map +1 -0
  15. package/dist/dashboard-companion/host-channel.d.ts +36 -0
  16. package/dist/dashboard-companion/host-channel.js +78 -0
  17. package/dist/dashboard-companion/host-channel.js.map +1 -0
  18. package/dist/dashboard-companion/host-status.d.ts +179 -0
  19. package/dist/dashboard-companion/host-status.js +122 -0
  20. package/dist/dashboard-companion/host-status.js.map +1 -0
  21. package/dist/dashboard-companion/standalone-assets.d.ts +8 -0
  22. package/dist/dashboard-companion/standalone-assets.js +7 -1
  23. package/dist/dashboard-companion/standalone-assets.js.map +1 -1
  24. package/dist/dashboard-companion/standalone-entry.js +34 -13
  25. package/dist/dashboard-companion/standalone-entry.js.map +1 -1
  26. package/dist/desktop-host/child-env.d.ts +23 -0
  27. package/dist/desktop-host/child-env.js +70 -0
  28. package/dist/desktop-host/child-env.js.map +1 -0
  29. package/dist/desktop-host/daemon-entry.d.ts +2 -0
  30. package/dist/desktop-host/daemon-entry.js +50 -0
  31. package/dist/desktop-host/daemon-entry.js.map +1 -0
  32. package/dist/desktop-host/daemon-env.d.ts +12 -0
  33. package/dist/desktop-host/daemon-env.js +35 -0
  34. package/dist/desktop-host/daemon-env.js.map +1 -0
  35. package/dist/desktop-host/daemon-protocol.d.ts +210 -0
  36. package/dist/desktop-host/daemon-protocol.js +56 -0
  37. package/dist/desktop-host/daemon-protocol.js.map +1 -0
  38. package/dist/desktop-host/daemon.d.ts +50 -0
  39. package/dist/desktop-host/daemon.js +441 -0
  40. package/dist/desktop-host/daemon.js.map +1 -0
  41. package/dist/desktop-host/enrollment.d.ts +17 -0
  42. package/dist/desktop-host/enrollment.js +25 -0
  43. package/dist/desktop-host/enrollment.js.map +1 -0
  44. package/dist/desktop-host/import.d.ts +14 -0
  45. package/dist/desktop-host/import.js +95 -0
  46. package/dist/desktop-host/import.js.map +1 -0
  47. package/dist/desktop-host/profile.d.ts +130 -0
  48. package/dist/desktop-host/profile.js +176 -0
  49. package/dist/desktop-host/profile.js.map +1 -0
  50. package/dist/desktop-host/service.d.ts +6 -0
  51. package/dist/desktop-host/service.js +7 -0
  52. package/dist/desktop-host/service.js.map +1 -0
  53. package/dist/desktop-host/supervisor.d.ts +57 -0
  54. package/dist/desktop-host/supervisor.js +256 -0
  55. package/dist/desktop-host/supervisor.js.map +1 -0
  56. package/dist/desktop-host/view-state.d.ts +138 -0
  57. package/dist/desktop-host/view-state.js +27 -0
  58. package/dist/desktop-host/view-state.js.map +1 -0
  59. package/dist/registry.d.ts +7 -0
  60. package/dist/registry.js +21 -7
  61. package/dist/registry.js.map +1 -1
  62. package/docs/verification/README.md +28 -2
  63. package/docs/verification/workflow-handoff.md +86 -0
  64. package/package.json +2 -2
@@ -0,0 +1,441 @@
1
+ import { isSea } from "node:sea";
2
+ import { createInterface } from "node:readline";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { mkdir, stat } from "node:fs/promises";
5
+ import { buildCompanionArguments, buildCompanionEnvironment, isWorkstationKeyForMode, } from "./child-env.js";
6
+ import { beginEnrollmentRecovery, reconcileCredentialExpectation } from "./enrollment.js";
7
+ import { importCompanionState } from "./import.js";
8
+ import { HOSTED_SERVICE, } from "./service.js";
9
+ import { defaultDesktopProfile, desktopProfilePath, readDesktopProfile, validateDesktopProfile, writeDesktopProfile, } from "./profile.js";
10
+ import { CompanionSupervisor, runCompanionCommand, } from "./supervisor.js";
11
+ import { formatHostStatusEvent, hostFatalMessage } from "../dashboard-companion/host-status.js";
12
+ import { parseDaemonRequestLine } from "./daemon-protocol.js";
13
+ import { SetupInputSchema } from "./view-state.js";
14
+ /** Where the shell puts the keychain-held key and the app-data location. */
15
+ export const DESKTOP_KEY_ENV = "CLINKX_DESKTOP_WORKSTATION_KEY";
16
+ export const DESKTOP_APP_DATA_ENV = "CLINKX_DESKTOP_APP_DATA";
17
+ export const DESKTOP_VAULT_ENV = "CLINKX_DESKTOP_VAULT";
18
+ const KEY_STORE_TIMEOUT_MS = 10_000;
19
+ const RECOVERY_BY_REASON = {
20
+ enrolled_store_missing: "new-enrollment",
21
+ passkey_volume_missing: "new-enrollment",
22
+ passkey_volume_replaced: "reset-binding",
23
+ workstation_binding_mismatch: "reset-binding",
24
+ };
25
+ async function isDirectory(path) {
26
+ try {
27
+ return (await stat(path)).isDirectory();
28
+ }
29
+ catch {
30
+ return false;
31
+ }
32
+ }
33
+ /**
34
+ * The host daemon: the Electron-free controller from the first launcher
35
+ * release, now running inside the companion executable itself. A thin shell
36
+ * (Tauri) spawns this process with `--host-daemon`, holds the workstation key
37
+ * in the OS keychain, and exchanges newline-delimited JSON: requests on the
38
+ * daemon's stdin, `state`/`response` events on its stdout. One binary plays
39
+ * both roles — this process supervises a child of itself running the
40
+ * dashboard companion.
41
+ */
42
+ export class DesktopDaemon {
43
+ #options;
44
+ #supervisor;
45
+ #service;
46
+ #io;
47
+ #profile;
48
+ #key;
49
+ #vaultAvailable;
50
+ #notice;
51
+ #busy = false;
52
+ #poll;
53
+ #shuttingDown = false;
54
+ /** The in-flight keychain store the shell must answer; setup is exclusive, so one slot suffices. */
55
+ #keyWaiter;
56
+ #resolveShutdown;
57
+ constructor(options) {
58
+ this.#options = options;
59
+ this.#service = options.service ?? HOSTED_SERVICE;
60
+ this.#io = options.io ?? { stdin: process.stdin, stdout: process.stdout };
61
+ this.#key = options.ambient[DESKTOP_KEY_ENV];
62
+ this.#vaultAvailable = options.ambient[DESKTOP_VAULT_ENV] !== "unavailable";
63
+ this.#supervisor = new CompanionSupervisor({
64
+ onStatus: () => {
65
+ if (!this.#supervisor.running)
66
+ this.#stopPolling();
67
+ this.#publish();
68
+ },
69
+ ...(options.stopTimeoutMs === undefined ? {} : { stopTimeoutMs: options.stopTimeoutMs }),
70
+ });
71
+ }
72
+ /** Serve requests until a shutdown request (or stdin EOF) completes. */
73
+ async run() {
74
+ try {
75
+ this.#profile = await readDesktopProfile(desktopProfilePath(this.#options.appData));
76
+ }
77
+ catch (error) {
78
+ this.#notice = { kind: "error", message: `The saved setup could not be read: ${error.message}` };
79
+ }
80
+ const lines = createInterface({ input: this.#io.stdin, crlfDelay: Infinity });
81
+ lines.on("line", (line) => this.#handleLine(line.trim()));
82
+ const stdinClosed = new Promise((resolveClosed) => {
83
+ this.#io.stdin.once("end", resolveClosed);
84
+ this.#io.stdin.once("close", resolveClosed);
85
+ });
86
+ // A completed shutdown request ends the daemon without waiting for the
87
+ // shell to close its stdin; stdin EOF does the same without a request.
88
+ const shutdownRequested = new Promise((resolveRequested) => {
89
+ this.#resolveShutdown = resolveRequested;
90
+ });
91
+ this.#publish();
92
+ if (this.#profile !== undefined && this.#key !== undefined && this.#vaultAvailable) {
93
+ await this.startCompanion().catch(() => {
94
+ // Reported through state.
95
+ });
96
+ }
97
+ await Promise.race([stdinClosed, shutdownRequested]);
98
+ lines.close();
99
+ if (!this.#shuttingDown)
100
+ await this.shutdown();
101
+ }
102
+ state() {
103
+ const profile = this.#profile ?? defaultDesktopProfile({
104
+ home: this.#options.home,
105
+ appData: this.#options.appData,
106
+ service: this.#service,
107
+ });
108
+ const status = this.#supervisor.status;
109
+ const selfHosted = profile.service.origin !== this.#service.origin
110
+ || profile.service.gatewayUrl !== this.#service.gatewayUrl;
111
+ const recovery = status.failure === undefined ? undefined : RECOVERY_BY_REASON[status.failure.reason];
112
+ return {
113
+ platform: this.#options.platform,
114
+ setup: this.#profile !== undefined && this.#key !== undefined ? "complete" : "required",
115
+ vault: this.#vaultAvailable ? "available" : "unavailable",
116
+ keyStored: this.#key !== undefined,
117
+ service: { ...profile.service, selfHosted },
118
+ roots: {
119
+ state: profile.roots.state,
120
+ contextRuns: profile.roots.contextRuns,
121
+ workspace: profile.roots.workspace,
122
+ settings: profile.roots.settings,
123
+ },
124
+ lifecycle: profile.lifecycle,
125
+ enrolled: profile.credentialExpectation === "existing-enrolled",
126
+ companion: {
127
+ phase: status.phase,
128
+ ...(status.settings === undefined ? {} : { settings: status.settings }),
129
+ ...(status.gateway === undefined ? {} : { gateway: status.gateway }),
130
+ ...(status.rejectedStatus === undefined ? {} : { rejectedStatus: status.rejectedStatus }),
131
+ ...(status.enrollmentCode === undefined || profile.credentialExpectation !== "bootstrap"
132
+ ? {}
133
+ : { enrollmentCode: status.enrollmentCode }),
134
+ ...(status.failure === undefined ? {} : { failure: status.failure }),
135
+ },
136
+ ...(recovery === undefined ? {} : { recovery }),
137
+ ...(this.#notice === undefined ? {} : { notice: this.#notice }),
138
+ busy: this.#busy,
139
+ };
140
+ }
141
+ enrollmentCode() {
142
+ return this.state().companion.enrollmentCode;
143
+ }
144
+ async startCompanion() {
145
+ if (this.#supervisor.running)
146
+ return;
147
+ let profile = this.#requireProfile();
148
+ const reconciled = await reconcileCredentialExpectation(profile);
149
+ if (reconciled.changed) {
150
+ await writeDesktopProfile(desktopProfilePath(this.#options.appData), reconciled.profile);
151
+ this.#profile = profile = reconciled.profile;
152
+ }
153
+ this.#supervisor.start(await this.#launch(profile, buildCompanionArguments(profile)));
154
+ if (profile.credentialExpectation === "bootstrap")
155
+ this.#startPolling();
156
+ }
157
+ async stopCompanion() {
158
+ await this.#supervisor.stop();
159
+ }
160
+ async saveSetup(raw) {
161
+ const input = SetupInputSchema.parse(raw);
162
+ const current = this.#profile ?? defaultDesktopProfile({
163
+ home: this.#options.home,
164
+ appData: this.#options.appData,
165
+ service: this.#service,
166
+ });
167
+ const service = input.service ?? this.#service;
168
+ const roots = {
169
+ ...current.roots,
170
+ state: resolve(input.roots.state),
171
+ contextRuns: resolve(input.roots.contextRuns),
172
+ workspace: resolve(input.roots.workspace),
173
+ settings: resolve(input.roots.settings),
174
+ };
175
+ const profile = {
176
+ ...current,
177
+ service: { ...service },
178
+ roots,
179
+ lifecycle: { ...input.lifecycle },
180
+ };
181
+ await validateDesktopProfile(profile, this.#options.home);
182
+ if (!(await isDirectory(roots.workspace)))
183
+ throw new Error(`The workspace folder ${roots.workspace} does not exist.`);
184
+ for (const folder of [roots.state, roots.contextRuns]) {
185
+ if (await isDirectory(folder))
186
+ continue;
187
+ if (!input.createMissingFolders) {
188
+ throw new Error(`${folder} does not exist. Point it at the folder your ClinkX tools write to, or allow creating it.`);
189
+ }
190
+ await mkdir(folder, { recursive: true, mode: 0o700 });
191
+ }
192
+ if (input.workstationKey !== undefined && !isWorkstationKeyForMode(input.workstationKey, service.mode)) {
193
+ throw new Error(service.mode === "tenant"
194
+ ? "That is not a workstation key. Copy the clxd_… key shown once on the ClinkX workspace screen."
195
+ : "That is not a 43-character gateway pairing token.");
196
+ }
197
+ if (input.workstationKey === undefined && this.#key === undefined)
198
+ throw new Error("Enter the workstation key.");
199
+ if (!this.#vaultAvailable) {
200
+ throw new Error("Secure storage is unavailable, so the workstation key cannot be stored. Unlock or configure the OS keychain and try again.");
201
+ }
202
+ await this.#supervisor.stop();
203
+ // The key is stored first: a stored key without an import is harmless,
204
+ // while imported credentials without a matching saved profile would
205
+ // strand the setup.
206
+ if (input.workstationKey !== undefined) {
207
+ await this.#storeKey(input.workstationKey);
208
+ }
209
+ let saved = profile;
210
+ let imported = false;
211
+ if (input.importFrom !== undefined) {
212
+ await importCompanionState(resolve(input.importFrom), profile);
213
+ imported = true;
214
+ saved = { ...profile, credentialExpectation: "existing-enrolled" };
215
+ }
216
+ try {
217
+ await writeDesktopProfile(desktopProfilePath(this.#options.appData), saved);
218
+ }
219
+ catch (error) {
220
+ if (imported) {
221
+ // Leave the stores as empty as they were found.
222
+ const { rm } = await import("node:fs/promises");
223
+ await rm(join(profile.roots.credentials, "credentials.json"), { force: true }).catch(() => { });
224
+ await rm(join(profile.roots.binding, "workstation-binding.json"), { force: true }).catch(() => { });
225
+ }
226
+ throw error;
227
+ }
228
+ this.#profile = saved;
229
+ this.#notice = undefined;
230
+ await this.startCompanion();
231
+ }
232
+ async recover(action) {
233
+ const profile = this.#requireProfile();
234
+ await this.#supervisor.stop();
235
+ const next = action === "new-enrollment" ? await beginEnrollmentRecovery(profile) : profile;
236
+ const result = await runCompanionCommand(await this.#launch(next, ["--reset-passkey-binding"]));
237
+ if (result.code !== 0)
238
+ throw new Error(`Resetting the workstation binding failed: ${result.output.trim()}`);
239
+ if (next !== profile) {
240
+ await writeDesktopProfile(desktopProfilePath(this.#options.appData), next);
241
+ this.#profile = next;
242
+ }
243
+ await this.startCompanion();
244
+ }
245
+ diagnostics() {
246
+ return this.#supervisor.diagnostics();
247
+ }
248
+ /** Stop and wait, completing the companion's cleanup before the daemon exits. */
249
+ async shutdown() {
250
+ this.#shuttingDown = true;
251
+ this.#stopPolling();
252
+ await this.#supervisor.stop();
253
+ }
254
+ #requireProfile() {
255
+ if (this.#profile === undefined)
256
+ throw new Error("Finish setup first.");
257
+ return this.#profile;
258
+ }
259
+ /** A child of this same executable runs the companion; plain node uses the compiled CLI. */
260
+ #companionCommand() {
261
+ if (this.#options.companionOverride !== undefined) {
262
+ return {
263
+ executable: this.#options.companionOverride.executable,
264
+ prefixArgs: this.#options.companionOverride.prefixArgs ?? [],
265
+ };
266
+ }
267
+ if (isSea())
268
+ return { executable: process.execPath, prefixArgs: [] };
269
+ return {
270
+ executable: process.execPath,
271
+ prefixArgs: [resolve(dirname(process.argv[1] ?? process.execPath), "..", "dashboard-cli.js")],
272
+ };
273
+ }
274
+ async #launch(profile, args) {
275
+ const key = this.#key;
276
+ if (key === undefined)
277
+ throw new Error("No workstation key is stored. Enter it in Setup.");
278
+ const command = this.#companionCommand();
279
+ return {
280
+ executable: command.executable,
281
+ args: [...command.prefixArgs, ...args],
282
+ env: buildCompanionEnvironment({
283
+ profile,
284
+ workstationKey: key,
285
+ home: this.#options.home,
286
+ tmpdir: this.#options.tmpdir,
287
+ platform: this.#options.platform,
288
+ ambient: this.#options.ambient,
289
+ }),
290
+ cwd: this.#options.appData,
291
+ secrets: [key],
292
+ };
293
+ }
294
+ /** Hand a newly entered key to the shell's keychain and wait for its verdict. */
295
+ #storeKey(key) {
296
+ return new Promise((resolveStore, rejectStore) => {
297
+ const timer = setTimeout(() => {
298
+ this.#keyWaiter = undefined;
299
+ rejectStore(new Error("Storing the workstation key timed out."));
300
+ }, KEY_STORE_TIMEOUT_MS);
301
+ this.#keyWaiter = (error) => {
302
+ clearTimeout(timer);
303
+ this.#keyWaiter = undefined;
304
+ if (error === undefined) {
305
+ this.#key = key;
306
+ resolveStore();
307
+ }
308
+ else {
309
+ rejectStore(error);
310
+ }
311
+ };
312
+ this.#emit({ type: "store_key", key });
313
+ });
314
+ }
315
+ #startPolling() {
316
+ this.#stopPolling();
317
+ this.#poll = setInterval(() => {
318
+ const profile = this.#profile;
319
+ if (profile === undefined || profile.credentialExpectation !== "bootstrap") {
320
+ this.#stopPolling();
321
+ return;
322
+ }
323
+ void reconcileCredentialExpectation(profile).then(async (result) => {
324
+ if (!result.changed || this.#profile !== profile)
325
+ return;
326
+ await writeDesktopProfile(desktopProfilePath(this.#options.appData), result.profile);
327
+ this.#profile = result.profile;
328
+ this.#stopPolling();
329
+ this.#publish();
330
+ }).catch(() => {
331
+ // A store mid-write is retried on the next tick.
332
+ });
333
+ }, this.#options.enrollmentPollMs ?? 2_000);
334
+ this.#poll.unref();
335
+ }
336
+ #stopPolling() {
337
+ if (this.#poll !== undefined)
338
+ clearInterval(this.#poll);
339
+ this.#poll = undefined;
340
+ }
341
+ #handleLine(line) {
342
+ if (line === "")
343
+ return;
344
+ let request;
345
+ try {
346
+ request = parseDaemonRequestLine(line);
347
+ }
348
+ catch (error) {
349
+ this.#emit({
350
+ type: "response",
351
+ id: "invalid",
352
+ ok: false,
353
+ error: error instanceof Error ? error.message : String(error),
354
+ });
355
+ return;
356
+ }
357
+ if (request.op === "key-stored") {
358
+ this.#keyWaiter?.(request.ok ? undefined : new Error(request.error ?? "Storing the workstation key failed."));
359
+ return;
360
+ }
361
+ void this.#respond(request);
362
+ }
363
+ async #respond(request) {
364
+ if (this.#busy && request.op !== "get-state" && request.op !== "shutdown") {
365
+ this.#emit({
366
+ type: "response",
367
+ id: request.id,
368
+ ok: false,
369
+ error: "Another action is still running.",
370
+ });
371
+ return;
372
+ }
373
+ if (request.op !== "get-state") {
374
+ this.#busy = true;
375
+ this.#publish();
376
+ }
377
+ let ok = true;
378
+ let error;
379
+ let result;
380
+ try {
381
+ switch (request.op) {
382
+ case "get-state":
383
+ result = this.state();
384
+ break;
385
+ case "save-setup":
386
+ await this.saveSetup(request.input);
387
+ result = this.state();
388
+ break;
389
+ case "connect":
390
+ await this.startCompanion();
391
+ result = this.state();
392
+ break;
393
+ case "disconnect":
394
+ await this.stopCompanion();
395
+ result = this.state();
396
+ break;
397
+ case "recover":
398
+ await this.recover(request.action);
399
+ result = this.state();
400
+ break;
401
+ case "diagnostics":
402
+ result = this.diagnostics();
403
+ break;
404
+ case "shutdown":
405
+ await this.shutdown();
406
+ break;
407
+ }
408
+ }
409
+ catch (caught) {
410
+ ok = false;
411
+ error = caught instanceof Error ? caught.message : String(caught);
412
+ this.#notice = { kind: "error", message: error };
413
+ }
414
+ finally {
415
+ if (request.op !== "get-state") {
416
+ this.#busy = false;
417
+ }
418
+ }
419
+ this.#emit({
420
+ type: "response",
421
+ id: request.id,
422
+ ok,
423
+ ...(ok ? (result === undefined ? {} : { result }) : { error }),
424
+ });
425
+ this.#publish();
426
+ if (request.op === "shutdown") {
427
+ this.#io.stdout.end?.();
428
+ this.#resolveShutdown?.();
429
+ }
430
+ }
431
+ #emit(event) {
432
+ this.#io.stdout.write(formatHostStatusEvent(event));
433
+ }
434
+ #publish() {
435
+ this.#emit({ type: "state", state: this.state() });
436
+ }
437
+ }
438
+ export function daemonFatalMessage(error) {
439
+ return hostFatalMessage(error);
440
+ }
441
+ //# sourceMappingURL=daemon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemon.js","sourceRoot":"","sources":["../../src/desktop-host/daemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,GAGpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAA4B,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAA8C,MAAM,iBAAiB,C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CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,IAAI,OAAO,CAAC,EAAE,KAAK,UAAU,EAAE,CAAC;YAC9B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,gBAAgB,EAAE,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAkD;QACtD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAwC,EAAE,CAAC,CAAC;IAC3F,CAAC;CACF;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { DashboardCredentialEnrollmentState } from "../../clinkx-workflows/dist/dashboard/auth/credential-store.js";
2
+ import type { DesktopProfile } from "./profile.js";
3
+ /**
4
+ * Advance a bootstrap profile once its store holds a credential. Enrollment
5
+ * is the only transition made automatically; going back to `bootstrap` is an
6
+ * explicit recovery action.
7
+ */
8
+ export declare function reconcileCredentialExpectation(profile: DesktopProfile): Promise<{
9
+ readonly profile: DesktopProfile;
10
+ readonly state: DashboardCredentialEnrollmentState;
11
+ readonly changed: boolean;
12
+ }>;
13
+ /**
14
+ * Begin a deliberate new enrollment. Allowed only when no credential remains,
15
+ * so recovery never hides a store that still exists; nothing is deleted.
16
+ */
17
+ export declare function beginEnrollmentRecovery(profile: DesktopProfile): Promise<DesktopProfile>;
@@ -0,0 +1,25 @@
1
+ import { inspectCredentialEnrollmentState } from "../dashboard-companion/credential-expectation.js";
2
+ /**
3
+ * Advance a bootstrap profile once its store holds a credential. Enrollment
4
+ * is the only transition made automatically; going back to `bootstrap` is an
5
+ * explicit recovery action.
6
+ */
7
+ export async function reconcileCredentialExpectation(profile) {
8
+ const state = await inspectCredentialEnrollmentState(profile.roots.credentials);
9
+ if (profile.credentialExpectation === "bootstrap" && state === "nonzero") {
10
+ return { profile: { ...profile, credentialExpectation: "existing-enrolled" }, state, changed: true };
11
+ }
12
+ return { profile, state, changed: false };
13
+ }
14
+ /**
15
+ * Begin a deliberate new enrollment. Allowed only when no credential remains,
16
+ * so recovery never hides a store that still exists; nothing is deleted.
17
+ */
18
+ export async function beginEnrollmentRecovery(profile) {
19
+ const state = await inspectCredentialEnrollmentState(profile.roots.credentials);
20
+ if (state === "nonzero") {
21
+ throw new Error(`the passkey store in ${profile.roots.credentials} still holds a credential; sign in with an existing passkey instead of enrolling again`);
22
+ }
23
+ return { ...profile, credentialExpectation: "bootstrap" };
24
+ }
25
+ //# sourceMappingURL=enrollment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enrollment.js","sourceRoot":"","sources":["../../src/desktop-host/enrollment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gCAAgC,EAAE,MAAM,kDAAkD,CAAC;AAGpG;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,OAAuB;IAEvB,MAAM,KAAK,GAAG,MAAM,gCAAgC,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAChF,IAAI,OAAO,CAAC,qBAAqB,KAAK,WAAW,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzE,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACvG,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAAuB;IACnE,MAAM,KAAK,GAAG,MAAM,gCAAgC,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAChF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,wBAAwB,OAAO,CAAC,KAAK,CAAC,WAAW,wFAAwF,CAC1I,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,GAAG,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { DesktopProfile } from "./profile.js";
2
+ export interface ImportedCompanionState {
3
+ readonly credentials: number;
4
+ readonly companionId?: string;
5
+ }
6
+ /**
7
+ * Import a Docker companion's exported passkey store and workstation binding
8
+ * (`<source>/webauthn/credentials.json`, optional
9
+ * `<source>/binding/workstation-binding.json`) into the profile's private
10
+ * directories. Public verification records move, not authenticators' private
11
+ * keys. Both must belong to the profile's RP and to each other; targets must
12
+ * be empty, so an import never overwrites existing state.
13
+ */
14
+ export declare function importCompanionState(source: string, profile: DesktopProfile): Promise<ImportedCompanionState>;
@@ -0,0 +1,95 @@
1
+ import { closeSync, fsyncSync, openSync } from "node:fs";
2
+ import { mkdir, open, readFile, readdir, rm } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { inspectDashboardCredentialEnrollmentState } from "../../clinkx-workflows/dist/dashboard/auth/credential-store.js";
5
+ import { WORKSTATION_BINDING_FILENAME, readPasskeyStoreIdentity, readWorkstationBinding, } from "../dashboard-companion/workstation-binding.js";
6
+ const CREDENTIALS_FILENAME = "credentials.json";
7
+ const MAX_IMPORTED_FILE_BYTES = 256 * 1_024;
8
+ async function isAbsentOrEmpty(directory) {
9
+ try {
10
+ return (await readdir(directory)).length === 0;
11
+ }
12
+ catch (error) {
13
+ if (error.code === "ENOENT")
14
+ return true;
15
+ throw error;
16
+ }
17
+ }
18
+ async function readBounded(path) {
19
+ const bytes = await readFile(path);
20
+ if (bytes.byteLength > MAX_IMPORTED_FILE_BYTES)
21
+ throw new Error(`${path} exceeds the import size limit`);
22
+ return bytes;
23
+ }
24
+ async function writePrivate(directory, name, bytes) {
25
+ await mkdir(directory, { recursive: true, mode: 0o700 });
26
+ const handle = await open(join(directory, name), "wx", 0o600);
27
+ try {
28
+ await handle.writeFile(bytes);
29
+ await handle.sync();
30
+ }
31
+ finally {
32
+ await handle.close();
33
+ }
34
+ if (process.platform !== "win32") {
35
+ const descriptor = openSync(directory, "r");
36
+ try {
37
+ fsyncSync(descriptor);
38
+ }
39
+ finally {
40
+ closeSync(descriptor);
41
+ }
42
+ }
43
+ }
44
+ /**
45
+ * Import a Docker companion's exported passkey store and workstation binding
46
+ * (`<source>/webauthn/credentials.json`, optional
47
+ * `<source>/binding/workstation-binding.json`) into the profile's private
48
+ * directories. Public verification records move, not authenticators' private
49
+ * keys. Both must belong to the profile's RP and to each other; targets must
50
+ * be empty, so an import never overwrites existing state.
51
+ */
52
+ export async function importCompanionState(source, profile) {
53
+ const expectedRpId = new URL(profile.service.origin).hostname;
54
+ const credentialSource = join(source, "webauthn");
55
+ if (await inspectDashboardCredentialEnrollmentState(credentialSource) !== "nonzero") {
56
+ throw new Error(`${credentialSource} must hold an enrolled credentials.json with at least one passkey`);
57
+ }
58
+ const identity = await readPasskeyStoreIdentity(credentialSource);
59
+ if (identity.rpId !== expectedRpId) {
60
+ throw new Error(`the exported passkeys belong to ${JSON.stringify(identity.rpId)}, not ${JSON.stringify(expectedRpId)}`);
61
+ }
62
+ const binding = await readWorkstationBinding(join(source, "binding"));
63
+ if (binding !== undefined && (binding.rp_id !== expectedRpId || binding.user_handle !== identity.userHandle)) {
64
+ throw new Error("the exported workstation binding does not belong to the exported passkey store");
65
+ }
66
+ for (const target of [profile.roots.credentials, profile.roots.binding]) {
67
+ if (!(await isAbsentOrEmpty(target))) {
68
+ throw new Error(`${target} already holds companion state; an import never overwrites it`);
69
+ }
70
+ }
71
+ const credentials = await readBounded(join(credentialSource, CREDENTIALS_FILENAME));
72
+ const bindingBytes = binding === undefined
73
+ ? undefined
74
+ : await readBounded(join(source, "binding", WORKSTATION_BINDING_FILENAME));
75
+ try {
76
+ await writePrivate(profile.roots.credentials, CREDENTIALS_FILENAME, credentials);
77
+ if (bindingBytes !== undefined)
78
+ await writePrivate(profile.roots.binding, WORKSTATION_BINDING_FILENAME, bindingBytes);
79
+ if (await inspectDashboardCredentialEnrollmentState(profile.roots.credentials) !== "nonzero") {
80
+ throw new Error("the imported passkey store did not verify");
81
+ }
82
+ }
83
+ catch (error) {
84
+ // Leave nothing half-imported: both targets were empty before.
85
+ await rm(join(profile.roots.credentials, CREDENTIALS_FILENAME), { force: true });
86
+ await rm(join(profile.roots.binding, WORKSTATION_BINDING_FILENAME), { force: true });
87
+ throw error;
88
+ }
89
+ const document = JSON.parse(credentials.toString("utf8"));
90
+ return {
91
+ credentials: document.credentials.length,
92
+ ...(binding === undefined ? {} : { companionId: binding.companion_id }),
93
+ };
94
+ }
95
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/desktop-host/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,yCAAyC,EAAE,MAAM,gEAAgE,CAAC;AAC3H,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,+CAA+C,CAAC;AAGvD,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAChD,MAAM,uBAAuB,GAAG,GAAG,GAAG,KAAK,CAAC;AAO5C,KAAK,UAAU,eAAe,CAAC,SAAiB;IAC9C,IAAI,CAAC;QACH,OAAO,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