@akanjs/cli 3.1.1-rc.6 → 3.1.1-rc.7

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 (28) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-y6ppa10x.js → CodeAgent-3sy7kjgj.js} +2 -2
  3. package/{CodeTui-dy37zz3j.js → CodeTui-rqxarxsn.js} +1 -1
  4. package/{TunnelShare-mnn0jxnp.js → TunnelShare-q38dxrrr.js} +3 -3
  5. package/akanCode.js +2 -2
  6. package/{application.command-fdghyjfj.js → application.command-fm2yn6hj.js} +3 -3
  7. package/{cloud.command-eyxwxnrn.js → cloud.command-ya0evzfq.js} +15 -10
  8. package/{cloud.script-c9f92bev.js → cloud.script-zg43jse2.js} +6 -6
  9. package/{code.command-4kqbrjt9.js → code.command-719k3e9q.js} +4 -4
  10. package/{context.command-h56yvjay.js → context.command-c4t4z1vy.js} +4 -4
  11. package/{context.runner-cf11819z.js → context.runner-qb15sjf8.js} +3 -3
  12. package/{index-ds2tmxgx.js → index-5max10jx.js} +533 -137
  13. package/{index-bksa6cqh.js → index-5phjb48k.js} +3 -3
  14. package/{index-krz4bcg5.js → index-8ap5z1n5.js} +1 -1
  15. package/{index-kr9vpvdn.js → index-8w76g4rm.js} +4 -4
  16. package/{index-44hh6bx2.js → index-hqegmnb5.js} +53 -6
  17. package/{index-jhbkzc8c.js → index-jh72e64b.js} +42 -1
  18. package/{index-12ny6e0x.js → index-pbtzb54h.js} +11 -9
  19. package/{index-jg2xev75.js → index-qd5km521.js} +3 -97
  20. package/{index-zz4vrw85.js → index-vah0fgkr.js} +1 -1
  21. package/{index-e9b3zh22.js → index-xy97mqgq.js} +34 -3
  22. package/{index-secyhsjs.js → index-zrte51fn.js} +1 -1
  23. package/index.js +8 -8
  24. package/{localRegistry.command-bajag7gm.js → localRegistry.command-h924ek5g.js} +5 -5
  25. package/package.json +2 -2
  26. package/{subspace.command-dzpfbc99.js → subspace.command-vem71tr5.js} +3 -3
  27. package/{tunnel.command-cfw6f0vz.js → tunnel.command-vy08ecyp.js} +3 -3
  28. package/{workspace.command-5rc8f0wt.js → workspace.command-fmgycnbr.js} +8 -8
@@ -2,6 +2,7 @@
2
2
  import {
3
3
  binPlatforms,
4
4
  ServerEnvProfile,
5
+ AkanAppConfig,
5
6
  Executor,
6
7
  WorkspaceExecutor
7
8
  } from "./index-wcej7g4z.js";
@@ -136,8 +137,470 @@ class DesktopBin {
136
137
  }
137
138
  }
138
139
 
139
- // pkgs/@akanjs/devkit/mobile/nativeApi.ts
140
+ // pkgs/@akanjs/devkit/mobile/desktopRelease.ts
141
+ import { createPublicKey, verify } from "crypto";
142
+ import { mkdtemp as mkdtemp2, readFile, rm as rm3 } from "fs/promises";
143
+ import os2 from "os";
144
+ import path4 from "path";
145
+ import { isRecord as isRecord2, toError } from "akanjs/common";
146
+
147
+ // pkgs/@akanjs/devkit/mobile/tarWriter.ts
148
+ import { createHash } from "crypto";
149
+ import { open } from "fs/promises";
150
+
151
+ class TarWriter {
152
+ static #block = 512;
153
+ static #nameBytes = 100;
154
+ static #maxSize = 8 ** 11 - 1;
155
+ #handle;
156
+ #mtime;
157
+ constructor(handle, mtime) {
158
+ this.#handle = handle;
159
+ this.#mtime = mtime;
160
+ }
161
+ static async create(file, { mtime = 0 } = {}) {
162
+ return new TarWriter(await open(file, "wx"), mtime);
163
+ }
164
+ async add(name, source) {
165
+ const { size } = source;
166
+ if (size > TarWriter.#maxSize)
167
+ throw new Error(`${name} is ${size} bytes, more than a tar entry holds.`);
168
+ if (Buffer.byteLength(name) > TarWriter.#nameBytes) {
169
+ const pax = Buffer.from(TarWriter.#paxRecord("path", name));
170
+ await this.#write(TarWriter.#header(`./PaxHeaders/${name.split("/").at(-1) ?? ""}`, pax.length, this.#mtime, "x"));
171
+ await this.#write(pax);
172
+ await this.#pad(pax.length);
173
+ }
174
+ await this.#write(TarWriter.#header(name, size, this.#mtime, "0"));
175
+ const hasher = createHash("sha256");
176
+ let written = 0;
177
+ for await (const chunk of source.stream()) {
178
+ hasher.update(chunk);
179
+ await this.#write(chunk);
180
+ written += chunk.length;
181
+ }
182
+ if (written !== size)
183
+ throw new Error(`${name} changed while it was archived: ${written} bytes, not ${size}.`);
184
+ await this.#pad(size);
185
+ return hasher.digest("hex");
186
+ }
187
+ async close() {
188
+ await this.#write(new Uint8Array(TarWriter.#block * 2));
189
+ await this.#handle.close();
190
+ }
191
+ async discard() {
192
+ await this.#handle.close().catch(() => {
193
+ return;
194
+ });
195
+ }
196
+ async#write(bytes) {
197
+ for (let at = 0;at < bytes.length; )
198
+ at += (await this.#handle.write(bytes, at)).bytesWritten;
199
+ }
200
+ async#pad(size) {
201
+ const rest = size % TarWriter.#block;
202
+ if (rest)
203
+ await this.#write(new Uint8Array(TarWriter.#block - rest));
204
+ }
205
+ static #paxRecord(key, value) {
206
+ const body = Buffer.byteLength(` ${key}=${value}
207
+ `);
208
+ let length = body + 1;
209
+ while (body + String(length).length !== length)
210
+ length = body + String(length).length;
211
+ return `${length} ${key}=${value}
212
+ `;
213
+ }
214
+ static #header(name, size, mtime, type) {
215
+ const header = Buffer.alloc(TarWriter.#block);
216
+ header.write(name, 0, TarWriter.#nameBytes, "utf8");
217
+ const octal = (value, at, width) => header.write(`${value.toString(8).padStart(width - 1, "0")}\x00`, at, width, "latin1");
218
+ octal(420, 100, 8);
219
+ octal(0, 108, 8);
220
+ octal(0, 116, 8);
221
+ octal(size, 124, 12);
222
+ octal(mtime, 136, 12);
223
+ header.write(" ", 148, 8, "latin1");
224
+ header.write(type, 156, 1, "latin1");
225
+ header.write("ustar\x00", 257, 6, "latin1");
226
+ header.write("00", 263, 2, "latin1");
227
+ const checksum = header.reduce((sum, byte) => sum + byte, 0);
228
+ header.write(`${checksum.toString(8).padStart(6, "0")}\x00 `, 148, 8, "latin1");
229
+ return header;
230
+ }
231
+ }
232
+
233
+ // pkgs/@akanjs/devkit/mobile/updateUploader.ts
234
+ import { readdir } from "fs/promises";
235
+ import path3 from "path";
236
+ import { isRecord, trimTrailingSlashes } from "akanjs/common";
237
+
238
+ // pkgs/@akanjs/devkit/mobile/updatePackFolder.ts
239
+ import { mkdtemp, rm as rm2 } from "fs/promises";
240
+ import os from "os";
140
241
  import path2 from "path";
242
+ class UpdatePackFolder {
243
+ static packFile = "pack.json";
244
+ static compatFile = "compat.json";
245
+ static bundleFile = "bundle.json";
246
+ static templateFile = "manifest.template.json";
247
+ static filesDir = "files";
248
+ static #records = [
249
+ UpdatePackFolder.templateFile,
250
+ UpdatePackFolder.bundleFile,
251
+ UpdatePackFolder.packFile,
252
+ UpdatePackFolder.compatFile
253
+ ];
254
+ static #sha256 = /^[0-9a-f]{64}$/;
255
+ static async clear(dir) {
256
+ await Promise.all([UpdatePackFolder.packFile, UpdatePackFolder.compatFile].map((name) => rm2(path2.join(dir, name), { force: true })));
257
+ }
258
+ static async read(dir) {
259
+ const file = Bun.file(path2.join(dir, UpdatePackFolder.packFile));
260
+ if (!await file.exists())
261
+ throw new Error(`${dir} holds no ${UpdatePackFolder.packFile}: give the folder \`akan pack-update\` wrote.`);
262
+ const pack = await file.json();
263
+ if (pack.schema !== 1)
264
+ throw new Error(`${dir}/${UpdatePackFolder.packFile} is schema ${pack.schema}, and this akan reads schema 1.`);
265
+ return { ...pack, out: path2.resolve(dir) };
266
+ }
267
+ static async write({ out, ...record }) {
268
+ await Bun.write(path2.join(out, UpdatePackFolder.packFile), `${JSON.stringify(record, null, 2)}
269
+ `);
270
+ }
271
+ static async writeCompat(pack, compat) {
272
+ pack.compat = compat;
273
+ await Bun.write(path2.join(pack.out, UpdatePackFolder.compatFile), `${JSON.stringify(compat, null, 2)}
274
+ `);
275
+ }
276
+ static async readBundle(file) {
277
+ return await Bun.file(file).json();
278
+ }
279
+ static storeBuildVerdict({ out, compat }, then) {
280
+ if (!compat || compat.compatible)
281
+ return null;
282
+ return new ExitCodeError(`The pack in ${out} needs a new store build; it differs from the one ${compat.against} came from:
283
+ - ${compat.problems.join(`
284
+ - `)}${then ? `
285
+ ${then}` : ""}`, 2);
286
+ }
287
+ static async withArchive(pack, use) {
288
+ const { templateFile, filesDir } = UpdatePackFolder;
289
+ const template = Bun.file(path2.join(pack.out, templateFile));
290
+ if (!await template.exists())
291
+ throw new Error(`${pack.out} holds no ${templateFile}: give the folder \`akan pack-update\` wrote.`);
292
+ const { files = [] } = await template.json();
293
+ const hashes = [...new Set(files.map((file) => file.sha256))];
294
+ if (!hashes.every((hash) => typeof hash === "string" && UpdatePackFolder.#sha256.test(hash)))
295
+ throw new Error(`${pack.out}/${templateFile} lists a file whose sha256 is not 64 hex digits.`);
296
+ const present = await Promise.all(UpdatePackFolder.#records.map((name) => Bun.file(path2.join(pack.out, name)).exists()));
297
+ const entries = [
298
+ ...UpdatePackFolder.#records.filter((_, idx) => present[idx]),
299
+ ...hashes.map((hash) => `${filesDir}/${hash}`)
300
+ ];
301
+ const dir = await mkdtemp(path2.join(os.tmpdir(), "akan-pack-"));
302
+ try {
303
+ const tar = Bun.spawn(["tar", "-czf", "pack.tgz", "-C", pack.out, "-T", "-"], {
304
+ cwd: dir,
305
+ stdin: new Blob([entries.map((entry) => `./${entry}
306
+ `).join("")]),
307
+ stdout: "ignore",
308
+ stderr: "pipe"
309
+ });
310
+ const [code, stderr] = await Promise.all([tar.exited, new Response(tar.stderr).text()]);
311
+ if (code !== 0)
312
+ throw new Error(`tar of ${pack.out} failed: ${stderr.trim()}`);
313
+ return await use(path2.join(dir, "pack.tgz"));
314
+ } finally {
315
+ await rm2(dir, { recursive: true, force: true });
316
+ }
317
+ }
318
+ }
319
+
320
+ // pkgs/@akanjs/devkit/mobile/updateUploader.ts
321
+ class UpdateUploader {
322
+ bucket;
323
+ prefix;
324
+ static #manifest = /\.json(?:\.sig)?$/;
325
+ static parseTarget(target) {
326
+ const match = /^s3:\/\/([^/]+)(?:\/(.*))?$/.exec(target.trim());
327
+ if (!match?.[1])
328
+ throw new Error(`--upload takes s3://<bucket>/<prefix>, not ${JSON.stringify(target)}.`);
329
+ return { bucket: match[1], prefix: trimTrailingSlashes(match[2] ?? "") };
330
+ }
331
+ static order(files) {
332
+ const manifests = files.filter((file) => UpdateUploader.#manifest.test(file));
333
+ return {
334
+ releases: files.filter((file) => !UpdateUploader.#manifest.test(file)).sort((a, b) => a.localeCompare(b)),
335
+ manifests: manifests.sort((a, b) => Number(a.endsWith(".json")) - Number(b.endsWith(".json")) || a.localeCompare(b))
336
+ };
337
+ }
338
+ static async releaseFiles(updatesDir, { dir, channel, bundle }) {
339
+ const keyOf = (file) => UpdateUploader.#keyOf(updatesDir, dir, file);
340
+ const desktop = await UpdateUploader.#read(path3.join(dir, `${channel}.json`));
341
+ if (desktop?.bundle === bundle) {
342
+ const archive = desktop.archive?.url;
343
+ const patches = UpdateUploader.#field(desktop.patches, "url");
344
+ return [archive, ...patches, `${channel}.json.sig`, `${channel}.json`].map(keyOf);
345
+ }
346
+ const names = await readdir(path3.join(dir, channel)).catch(() => []);
347
+ for (const name of names.filter((name) => name.endsWith(".json"))) {
348
+ const envelope = await UpdateUploader.#read(path3.join(dir, channel, name));
349
+ const manifest = typeof envelope?.manifest === "string" ? UpdateUploader.#parse(Buffer.from(envelope.manifest, "base64").toString("utf8")) : null;
350
+ if (manifest?.bundle !== bundle)
351
+ continue;
352
+ const hashes = [...new Set(UpdateUploader.#field(manifest.files, "sha256"))];
353
+ if (!hashes.every((hash) => typeof hash === "string" && /^[0-9a-f]{64}$/.test(hash)))
354
+ throw new Error(`${path3.join(dir, channel, name)} lists a file whose sha256 is not 64 hex digits; nothing was uploaded.`);
355
+ return [...hashes.map((hash) => `${UpdatePackFolder.filesDir}/${hash}`), `${channel}/${name}`].map(keyOf);
356
+ }
357
+ throw new Error(`${dir} holds no ${channel} manifest of release ${bundle}; nothing was uploaded.`);
358
+ }
359
+ static #keyOf(updatesDir, dir, file) {
360
+ const resolved = typeof file === "string" ? path3.resolve(dir, file) : "";
361
+ const key = path3.relative(updatesDir, resolved);
362
+ if (!resolved.startsWith(`${path3.resolve(dir)}${path3.sep}`) || key.startsWith("..") || path3.isAbsolute(key))
363
+ throw new Error(`The release in ${dir} names ${typeof file === "string" ? JSON.stringify(file) : "a file with no path"}, which is not inside that folder; nothing was uploaded.`);
364
+ return key.split(path3.sep).join("/");
365
+ }
366
+ static #field(list, key) {
367
+ return Array.isArray(list) ? list.map((item) => isRecord(item) ? item[key] : undefined) : [];
368
+ }
369
+ static async#read(file) {
370
+ const text = await Bun.file(file).text().catch(() => "");
371
+ return UpdateUploader.#parse(text);
372
+ }
373
+ static #parse(text) {
374
+ try {
375
+ const value = JSON.parse(text);
376
+ return isRecord(value) ? value : null;
377
+ } catch {
378
+ return null;
379
+ }
380
+ }
381
+ constructor(bucket, prefix) {
382
+ this.bucket = bucket;
383
+ this.prefix = prefix;
384
+ }
385
+ static forTarget(target) {
386
+ const { bucket, prefix } = UpdateUploader.parseTarget(target);
387
+ return new UpdateUploader(new Bun.S3Client({ bucket }), prefix);
388
+ }
389
+ async upload(updatesDir, release) {
390
+ const { releases, manifests } = UpdateUploader.order(await UpdateUploader.releaseFiles(updatesDir, release));
391
+ const keyOf = (file) => this.prefix ? `${this.prefix}/${file}` : file;
392
+ let uploaded = 0;
393
+ let skipped = 0;
394
+ for (const file of releases) {
395
+ if (await this.bucket.exists(keyOf(file))) {
396
+ skipped++;
397
+ continue;
398
+ }
399
+ await this.bucket.write(keyOf(file), Bun.file(path3.join(updatesDir, file)));
400
+ uploaded++;
401
+ }
402
+ for (const file of manifests) {
403
+ const type = file.endsWith(".json") ? "application/json" : "text/plain";
404
+ await this.bucket.write(keyOf(file), Bun.file(path3.join(updatesDir, file)), { type });
405
+ uploaded++;
406
+ }
407
+ return { uploaded, skipped };
408
+ }
409
+ }
410
+
411
+ // pkgs/@akanjs/devkit/mobile/desktopRelease.ts
412
+ class DesktopRelease {
413
+ dir;
414
+ manifest;
415
+ payloads;
416
+ platform;
417
+ arch;
418
+ channel;
419
+ manifestBytes;
420
+ signatureBytes;
421
+ static #ed25519Spki = Buffer.from("302a300506032b6570032100", "hex");
422
+ static #authenticode = `$ErrorActionPreference = 'Stop'
423
+ $ProgressPreference = 'SilentlyContinue'
424
+ $signature = Get-AuthenticodeSignature -LiteralPath $env:AKAN_RELEASE_EXE
425
+ $subject = if ("$($signature.Status)" -ceq 'Valid') { "$($signature.SignerCertificate.Subject)" } else { '' }
426
+ Set-Content -LiteralPath $env:AKAN_SIGNER_OUT -Value $subject -Encoding UTF8`;
427
+ constructor(dir, manifest, payloads, platform, arch, channel, manifestBytes, signatureBytes) {
428
+ this.dir = dir;
429
+ this.manifest = manifest;
430
+ this.payloads = payloads;
431
+ this.platform = platform;
432
+ this.arch = arch;
433
+ this.channel = channel;
434
+ this.manifestBytes = manifestBytes;
435
+ this.signatureBytes = signatureBytes;
436
+ }
437
+ static async read(updatesDir, {
438
+ platform,
439
+ arch,
440
+ channel,
441
+ appId,
442
+ publicKey
443
+ }) {
444
+ const folder = `${platform}-${arch}`;
445
+ const dir = path4.join(updatesDir, folder);
446
+ const manifestPath = path4.join(dir, `${channel}.json`);
447
+ const [manifestBytes, signatureBytes] = await Promise.all([
448
+ readFile(manifestPath).catch(() => null),
449
+ readFile(`${manifestPath}.sig`).catch(() => null)
450
+ ]);
451
+ if (!manifestBytes || !signatureBytes)
452
+ throw new Error(`${manifestBytes ? `${manifestPath}.sig` : manifestPath} is missing: run \`akan publish-update\` first.`);
453
+ if (!DesktopRelease.#verifies(manifestBytes, signatureBytes, publicKey))
454
+ throw new Error(`${manifestPath}.sig does not verify with updates.publicKeys[0], the one key installed apps trust: publish the release again.`);
455
+ const manifest = DesktopRelease.#parse(manifestBytes);
456
+ if (manifest?.schema !== 1 || manifest.kind !== "app" || manifest.app !== appId || manifest.platform !== platform || manifest.arch !== arch || manifest.channel !== channel || typeof manifest.bundle !== "string" || typeof manifest.sequence !== "number" || typeof manifest.build !== "number" || !manifest.archive)
457
+ throw new Error(`${manifestPath} is not a release of ${appId} for ${folder} on channel ${channel}.`);
458
+ const { archive, bundle, sequence, build } = manifest;
459
+ const keys = await UpdateUploader.releaseFiles(updatesDir, { dir, channel, bundle });
460
+ const expected = new Map([{ url: archive.url, size: archive.size, sha256: archive.gzSha256 }, ...manifest.patches ?? []].map(({ url, size, sha256 }) => [path4.posix.normalize(url), { size, sha256 }]));
461
+ const payloads = keys.flatMap((key) => {
462
+ const name = key.slice(folder.length + 1);
463
+ const digest = expected.get(name);
464
+ return digest ? [{ name, ...digest }] : [];
465
+ });
466
+ return new DesktopRelease(dir, { ...manifest, archive, bundle, sequence, build }, payloads, platform, arch, channel, manifestBytes, signatureBytes);
467
+ }
468
+ record(signer) {
469
+ const { platform, arch, channel } = this;
470
+ const builtAt = new Date(this.manifest.build * 1000).toISOString();
471
+ return { schema: 1, cli: AkanAppConfig.akanVersion, platform, arch, channel, signer, builtAt };
472
+ }
473
+ async withArchive(record, use) {
474
+ const tmp = await mkdtemp2(path4.join(os2.tmpdir(), "akan-release-"));
475
+ try {
476
+ const archive = path4.join(tmp, "release.tar");
477
+ const tar = await TarWriter.create(archive, { mtime: this.manifest.sequence });
478
+ try {
479
+ await tar.add("./release.json", new Blob([`${JSON.stringify(record, null, 2)}
480
+ `]));
481
+ await tar.add(`./${this.channel}.json`, new Blob([this.manifestBytes]));
482
+ await tar.add(`./${this.channel}.json.sig`, new Blob([this.signatureBytes]));
483
+ for (const { name, size, sha256 } of this.payloads) {
484
+ const file = Bun.file(path4.join(this.dir, name));
485
+ const what = `${path4.join(this.dir, name)} is not the file ${this.channel}.json names`;
486
+ if (!await file.exists() || file.size !== size)
487
+ throw new Error(`${what}: publish the release again.`);
488
+ if (await tar.add(`./${name}`, file) !== sha256)
489
+ throw new Error(`${what} (its sha256 differs).`);
490
+ }
491
+ await tar.close();
492
+ } catch (error) {
493
+ await tar.discard();
494
+ throw error;
495
+ }
496
+ return await use(archive);
497
+ } finally {
498
+ await rm3(tmp, { recursive: true, force: true });
499
+ }
500
+ }
501
+ async signer({
502
+ exeName,
503
+ host = process.platform,
504
+ run = DesktopRelease.#run
505
+ }) {
506
+ if (this.platform === "linux")
507
+ return { signer: null, unread: null };
508
+ const app = this.manifest.files?.[0]?.path;
509
+ if (!app || !/^[^/\\]+$/.test(app) || app === "." || app === "..")
510
+ return { signer: null, unread: `${this.channel}.json names no app folder` };
511
+ if (this.platform === "macos" && host !== "darwin")
512
+ return { signer: null, unread: "codesign reads a macOS app's signer on macOS only" };
513
+ if (this.platform === "windows" && host !== "win32")
514
+ return { signer: null, unread: "PowerShell reads a Windows app's Authenticode signer on Windows only" };
515
+ const tmp = await mkdtemp2(path4.join(os2.tmpdir(), "akan-signer-"));
516
+ try {
517
+ const archive = path4.join(this.dir, this.manifest.archive.url);
518
+ return this.platform === "macos" ? await DesktopRelease.#teamOf(run, archive, tmp, app) : await DesktopRelease.#subjectOf(run, archive, tmp, path4.posix.join(app, `${exeName}.exe`));
519
+ } finally {
520
+ await rm3(tmp, { recursive: true, force: true });
521
+ }
522
+ }
523
+ static async#teamOf(run, archive, tmp, app) {
524
+ const contents = `${app}/Contents`;
525
+ await run([
526
+ "/usr/bin/tar",
527
+ "-xzf",
528
+ archive,
529
+ "-C",
530
+ tmp,
531
+ ...["Info.plist", "MacOS/*", "_CodeSignature/*"].flatMap((entry) => ["--include", `${contents}/${entry}`])
532
+ ]);
533
+ if (!await Bun.file(path4.join(tmp, contents, "Info.plist")).exists())
534
+ return { signer: null, unread: `the archive holds no ${contents}/Info.plist` };
535
+ const { output } = await run(["/usr/bin/codesign", "--display", "--verbose=2", path4.join(tmp, app)]);
536
+ const teamId = /^TeamIdentifier=([A-Z0-9]{10})$/m.exec(output)?.[1];
537
+ if (teamId)
538
+ return { signer: { teamId }, unread: null };
539
+ if (/^TeamIdentifier=not set$/m.test(output) || /code object is not signed at all/.test(output))
540
+ return { signer: null, unread: null };
541
+ return { signer: null, unread: `codesign could not read ${app}: ${output.trim().split(`
542
+ `)[0] ?? ""}` };
543
+ }
544
+ static async#subjectOf(run, archive, tmp, exe) {
545
+ await run(["tar.exe", "-xzf", archive, "-C", tmp, exe]);
546
+ const extracted = path4.join(tmp, exe);
547
+ if (!await Bun.file(extracted).exists())
548
+ return { signer: null, unread: `the archive holds no ${exe}` };
549
+ const out = path4.join(tmp, "signer.txt");
550
+ const { code } = await run([
551
+ path4.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
552
+ "-NoProfile",
553
+ "-NonInteractive",
554
+ "-EncodedCommand",
555
+ Buffer.from(DesktopRelease.#authenticode, "utf16le").toString("base64")
556
+ ], { env: { AKAN_RELEASE_EXE: extracted, AKAN_SIGNER_OUT: out } });
557
+ if (code !== 0)
558
+ return { signer: null, unread: `PowerShell could not read the Authenticode signature of ${exe}` };
559
+ const subject = (await readFile(out, "utf8").catch(() => "")).replace(/^\uFEFF/, "").trim();
560
+ return { signer: subject ? { subject } : null, unread: null };
561
+ }
562
+ static #verifies(manifest, signature, publicKey) {
563
+ try {
564
+ const key = createPublicKey({
565
+ key: Buffer.concat([DesktopRelease.#ed25519Spki, Buffer.from(publicKey, "base64")]),
566
+ format: "der",
567
+ type: "spki"
568
+ });
569
+ return verify(null, manifest, key, Buffer.from(new TextDecoder().decode(signature).trim(), "base64"));
570
+ } catch {
571
+ return false;
572
+ }
573
+ }
574
+ static #parse(bytes) {
575
+ try {
576
+ const value = JSON.parse(new TextDecoder().decode(bytes));
577
+ return isRecord2(value) ? value : null;
578
+ } catch {
579
+ return null;
580
+ }
581
+ }
582
+ static async#run(cmd, { env } = {}) {
583
+ try {
584
+ const proc = Bun.spawn(cmd, {
585
+ env: { ...process.env, ...env },
586
+ stdin: "ignore",
587
+ stdout: "pipe",
588
+ stderr: "pipe"
589
+ });
590
+ const [code, stdout, stderr] = await Promise.all([
591
+ proc.exited,
592
+ new Response(proc.stdout).text(),
593
+ new Response(proc.stderr).text()
594
+ ]);
595
+ return { code, output: `${stdout}${stderr}` };
596
+ } catch (error) {
597
+ return { code: -1, output: toError(error).message };
598
+ }
599
+ }
600
+ }
601
+
602
+ // pkgs/@akanjs/devkit/mobile/nativeApi.ts
603
+ import path5 from "path";
141
604
 
142
605
  class NativeApi {
143
606
  static supportedMajor = 0;
@@ -149,7 +612,7 @@ class NativeApi {
149
612
  const akanjsPackage = NativeApi.#resolve("akanjs/package.json", appDir);
150
613
  if (!akanjsPackage)
151
614
  throw new Error(`akanjs is not installed for ${appDir}; the native build ships inside it.`);
152
- return path2.join(path2.dirname(akanjsPackage), "vendor", "@akanjs", "native", "packages", "cli", "src", "api.ts");
615
+ return path5.join(path5.dirname(akanjsPackage), "vendor", "@akanjs", "native", "packages", "cli", "src", "api.ts");
153
616
  }
154
617
  static async load(appDir) {
155
618
  const entry = NativeApi.entryOf(appDir);
@@ -171,8 +634,8 @@ class NativeApi {
171
634
  }
172
635
 
173
636
  // pkgs/@akanjs/devkit/mobile/nativeApp.ts
174
- import path8 from "path";
175
- import { toError } from "akanjs/common";
637
+ import path10 from "path";
638
+ import { toError as toError2 } from "akanjs/common";
176
639
 
177
640
  // pkgs/@akanjs/devkit/mobile/nativeAppLine.ts
178
641
  class NativeAppLine {
@@ -231,7 +694,7 @@ class NativeAppLine {
231
694
 
232
695
  // pkgs/@akanjs/devkit/mobile/nativeConfig.ts
233
696
  import { readFileSync } from "fs";
234
- import path3 from "path";
697
+ import path6 from "path";
235
698
  import { trimSlashes } from "akanjs/common";
236
699
 
237
700
  // pkgs/@akanjs/devkit/mobile/usageDescriptions.ts
@@ -314,11 +777,11 @@ class NativeConfig {
314
777
  warnings.push(`Permission '${permission}' has no native plugin yet; the app ships without it.`);
315
778
  return used;
316
779
  });
317
- const abs = (relative) => path3.resolve(appPath, relative);
780
+ const abs = (relative) => path6.resolve(appPath, relative);
318
781
  const updates = NativeConfig.#updates(target, env);
319
- const folders = new Set(nativePlugins.map((plugin) => path3.resolve(plugin.dir)));
782
+ const folders = new Set(nativePlugins.map((plugin) => path6.resolve(plugin.dir)));
320
783
  const folderIds = new Set(nativePlugins.map((plugin) => plugin.id));
321
- const listed = (target.plugins ?? []).filter((spec) => NativeConfig.#isId(spec) ? !folderIds.has(spec) : !folders.has(path3.resolve(appPath, spec)));
784
+ const listed = (target.plugins ?? []).filter((spec) => NativeConfig.#isId(spec) ? !folderIds.has(spec) : !folders.has(path6.resolve(appPath, spec)));
322
785
  const plugins = [
323
786
  ...new Set([
324
787
  ...NativeConfig.basePlugins,
@@ -374,7 +837,7 @@ class NativeConfig {
374
837
  app: {
375
838
  id: resolveAppId(target.appId, platform),
376
839
  name: target.appName,
377
- fileName: target.fileName ?? NativeConfig.fileNameOf(path3.basename(appPath)),
840
+ fileName: target.fileName ?? NativeConfig.fileNameOf(path6.basename(appPath)),
378
841
  version: target.version,
379
842
  build: target.buildNum
380
843
  },
@@ -440,14 +903,14 @@ class NativeConfig {
440
903
  if (NativeConfig.#isId(spec))
441
904
  return spec;
442
905
  try {
443
- const { id } = JSON.parse(readFileSync(path3.join(path3.resolve(appPath, spec), "native-plugin.json"), "utf8"));
906
+ const { id } = JSON.parse(readFileSync(path6.join(path6.resolve(appPath, spec), "native-plugin.json"), "utf8"));
444
907
  return typeof id === "string" ? id : spec;
445
908
  } catch {
446
909
  return spec;
447
910
  }
448
911
  }
449
912
  static #isId(spec) {
450
- return !spec.startsWith(".") && !path3.isAbsolute(spec);
913
+ return !spec.startsWith(".") && !path6.isAbsolute(spec);
451
914
  }
452
915
  static #compact(value) {
453
916
  const kept = Object.entries(value).filter(([, entry]) => Array.isArray(entry) ? entry.length > 0 : entry && typeof entry === "object" ? Object.keys(entry).length > 0 : entry !== undefined);
@@ -467,24 +930,24 @@ class NativeConfig {
467
930
  }
468
931
 
469
932
  // pkgs/@akanjs/devkit/mobile/nativePluginFolders.ts
470
- import { readdir } from "fs/promises";
471
- import path4 from "path";
933
+ import { readdir as readdir2 } from "fs/promises";
934
+ import path7 from "path";
472
935
 
473
936
  class NativePluginFolders {
474
937
  static folder = "native";
475
938
  static async in(root, owner) {
476
- const base = path4.join(root, NativePluginFolders.folder);
477
- const entries = await readdir(base, { withFileTypes: true }).catch(() => []);
939
+ const base = path7.join(root, NativePluginFolders.folder);
940
+ const entries = await readdir2(base, { withFileTypes: true }).catch(() => []);
478
941
  const folders = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
479
942
  return await Promise.all(folders.sort().map(async (name) => {
480
943
  const where = `${owner}/${NativePluginFolders.folder}/${name}`;
481
- const manifest = Bun.file(path4.join(base, name, "native-plugin.json"));
944
+ const manifest = Bun.file(path7.join(base, name, "native-plugin.json"));
482
945
  if (!await manifest.exists())
483
946
  throw new Error(`${where} has no native-plugin.json; a folder in native/ is one native plugin.`);
484
947
  const { id } = await manifest.json();
485
948
  if (id !== name)
486
949
  throw new Error(`${where}/native-plugin.json has id ${JSON.stringify(id)}; name the folder after its id.`);
487
- return { id, dir: path4.join(base, name), owner };
950
+ return { id, dir: path7.join(base, name), owner };
488
951
  }));
489
952
  }
490
953
  static select(own, fromLibs) {
@@ -503,14 +966,14 @@ class NativePluginFolders {
503
966
  const root = app.workspace.workspaceRoot;
504
967
  const [own, ...fromLibs] = await Promise.all([
505
968
  NativePluginFolders.in(app.cwdPath, `apps/${app.name}`),
506
- ...scanInfo.getLibs().map((lib) => NativePluginFolders.in(path4.join(root, "libs", lib), `libs/${lib}`))
969
+ ...scanInfo.getLibs().map((lib) => NativePluginFolders.in(path7.join(root, "libs", lib), `libs/${lib}`))
507
970
  ]);
508
971
  return NativePluginFolders.select(own ?? [], fromLibs.flat());
509
972
  }
510
973
  }
511
974
 
512
975
  // pkgs/@akanjs/devkit/mobile/nativePublicEnv.ts
513
- import { createHash } from "crypto";
976
+ import { createHash as createHash2 } from "crypto";
514
977
  class NativePublicEnv {
515
978
  static derivedKeys = [
516
979
  "AKAN_PUBLIC_APP_NAME",
@@ -529,7 +992,7 @@ class NativePublicEnv {
529
992
  return Object.fromEntries(Object.keys(env).filter((key) => key.startsWith("AKAN_PUBLIC_") && !NativePublicEnv.derivedKeys.includes(key)).sort().map((key) => [key, String(env[key])]));
530
993
  }
531
994
  static hash(publicEnv) {
532
- return createHash("sha256").update(JSON.stringify(NativePublicEnv.of(publicEnv))).digest("hex");
995
+ return createHash2("sha256").update(JSON.stringify(NativePublicEnv.of(publicEnv))).digest("hex");
533
996
  }
534
997
  static problems(publicEnv) {
535
998
  const keys = Object.keys(publicEnv);
@@ -609,8 +1072,8 @@ class NativePublicEnv {
609
1072
  }
610
1073
 
611
1074
  // pkgs/@akanjs/devkit/mobile/nativeWebDir.ts
612
- import { cp, mkdir as mkdir2, rm as rm2, stat } from "fs/promises";
613
- import path5 from "path";
1075
+ import { cp, mkdir as mkdir2, rm as rm4, stat } from "fs/promises";
1076
+ import path8 from "path";
614
1077
  import { trimSlashes as trimSlashes2 } from "akanjs/common";
615
1078
 
616
1079
  class NativeWebDir {
@@ -638,7 +1101,7 @@ ${script}${html.slice(at)}`;
638
1101
  }
639
1102
  static #targetTag = "<script>window.__AKAN_MOBILE_TARGET__=";
640
1103
  async clear() {
641
- await rm2(this.dir, { recursive: true, force: true });
1104
+ await rm4(this.dir, { recursive: true, force: true });
642
1105
  await mkdir2(this.dir, { recursive: true });
643
1106
  }
644
1107
  async assemble(target, { html, publicDir, fontsDir }) {
@@ -648,12 +1111,12 @@ ${script}${html.slice(at)}`;
648
1111
  if (publicDir && await NativeWebDir.#isDir(publicDir))
649
1112
  await cp(publicDir, this.dir, { recursive: true });
650
1113
  if (fontsDir && await NativeWebDir.#isDir(fontsDir))
651
- await cp(fontsDir, path5.join(this.dir, "_akan", "fonts"), { recursive: true });
652
- if (await NativeWebDir.#isDir(path5.join(this.dir, NativeWebDir.reservedEntry)))
1114
+ await cp(fontsDir, path8.join(this.dir, "_akan", "fonts"), { recursive: true });
1115
+ if (await NativeWebDir.#isDir(path8.join(this.dir, NativeWebDir.reservedEntry)))
653
1116
  throw new Error(`public/${NativeWebDir.reservedEntry} is reserved for the native runtime.`);
654
- await Bun.write(path5.join(this.dir, "index.html"), NativeWebDir.injectTarget(await Bun.file(html).text(), target));
1117
+ await Bun.write(path8.join(this.dir, "index.html"), NativeWebDir.injectTarget(await Bun.file(html).text(), target));
655
1118
  const files = await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: this.dir, onlyFiles: true, dot: true }));
656
- return files.map((file) => file.split(path5.sep).join("/")).sort();
1119
+ return files.map((file) => file.split(path8.sep).join("/")).sort();
657
1120
  }
658
1121
  static async#isDir(dir) {
659
1122
  try {
@@ -665,8 +1128,8 @@ ${script}${html.slice(at)}`;
665
1128
  }
666
1129
 
667
1130
  // pkgs/@akanjs/devkit/mobile/serverBundleSecrets.ts
668
- import { readdir as readdir2, readFile, stat as stat2 } from "fs/promises";
669
- import path6 from "path";
1131
+ import { readdir as readdir3, readFile as readFile2, stat as stat2 } from "fs/promises";
1132
+ import path9 from "path";
670
1133
  class ServerBundleSecrets {
671
1134
  workspaceRoot;
672
1135
  appDir;
@@ -678,8 +1141,8 @@ class ServerBundleSecrets {
678
1141
  this.appDir = appDir;
679
1142
  }
680
1143
  async envFiles() {
681
- const dirs = [path6.join(this.appDir, "env"), ...(await this.#libDirs()).map((lib) => path6.join(lib, "env"))];
682
- const files = await Promise.all(dirs.map(async (dir) => (await readdir2(dir).catch(() => [])).filter((name) => /^env\.server\.[A-Za-z0-9.-]+\.ts$/.test(name) && !/\.(type|example)\.ts$/.test(name)).map((name) => path6.join(dir, name))));
1144
+ const dirs = [path9.join(this.appDir, "env"), ...(await this.#libDirs()).map((lib) => path9.join(lib, "env"))];
1145
+ const files = await Promise.all(dirs.map(async (dir) => (await readdir3(dir).catch(() => [])).filter((name) => /^env\.server\.[A-Za-z0-9.-]+\.ts$/.test(name) && !/\.(type|example)\.ts$/.test(name)).map((name) => path9.join(dir, name))));
683
1146
  return files.flat();
684
1147
  }
685
1148
  async assertClean(bundleDir) {
@@ -687,7 +1150,7 @@ class ServerBundleSecrets {
687
1150
  const secrets = [];
688
1151
  for (const file of await this.envFiles()) {
689
1152
  try {
690
- const value = await ServerEnvProfile.evaluate(file, path6.dirname(path6.dirname(file)));
1153
+ const value = await ServerEnvProfile.evaluate(file, path9.dirname(path9.dirname(file)));
691
1154
  secrets.push(...ServerEnvProfile.secretValues(value).map((secret) => ({ file, ...secret })));
692
1155
  } catch {
693
1156
  unread.push(ServerBundleSecrets.#relative(this.workspaceRoot, file));
@@ -698,7 +1161,7 @@ class ServerBundleSecrets {
698
1161
  const sought = secrets.map((secret) => ({ secret, needles: ServerBundleSecrets.#needles(secret.value) }));
699
1162
  const found = [];
700
1163
  for (const bundled of await ServerBundleSecrets.#files(bundleDir)) {
701
- const text = await readFile(bundled, "latin1");
1164
+ const text = await readFile2(bundled, "latin1");
702
1165
  for (const { secret, needles } of sought)
703
1166
  if (needles.some((needle) => text.includes(needle)))
704
1167
  found.push({ bundled, secret });
@@ -719,7 +1182,7 @@ Build its server with a profile (native.desktop.server.profile), whose bundle le
719
1182
  return coded;
720
1183
  for (const dir of [this.appDir, ...await this.#libDirs()])
721
1184
  for (const file of await ServerBundleSecrets.#sources(dir)) {
722
- const text = await readFile(file, "utf8");
1185
+ const text = await readFile2(file, "utf8");
723
1186
  for (const value of plain)
724
1187
  if (text.includes(value))
725
1188
  coded.add(value);
@@ -727,8 +1190,8 @@ Build its server with a profile (native.desktop.server.profile), whose bundle le
727
1190
  return coded;
728
1191
  }
729
1192
  async#libDirs() {
730
- const libsDir = path6.join(this.workspaceRoot, "libs");
731
- return (await readdir2(libsDir).catch(() => [])).map((lib) => path6.join(libsDir, lib));
1193
+ const libsDir = path9.join(this.workspaceRoot, "libs");
1194
+ return (await readdir3(libsDir).catch(() => [])).map((lib) => path9.join(libsDir, lib));
732
1195
  }
733
1196
  static #needles(value) {
734
1197
  const escaped = JSON.stringify(value).slice(1, -1);
@@ -741,12 +1204,12 @@ Build its server with a profile (native.desktop.server.profile), whose bundle le
741
1204
  return /^export default (["'`])([\s\S]*)\1;?\s*$/.exec(code)?.[2] ?? value;
742
1205
  }
743
1206
  static #relative(from, to) {
744
- return path6.relative(from, to).split(path6.sep).join("/");
1207
+ return path9.relative(from, to).split(path9.sep).join("/");
745
1208
  }
746
1209
  static async#files(dir) {
747
1210
  const files = [];
748
- for (const entry of await readdir2(dir, { withFileTypes: true })) {
749
- const file = path6.join(dir, entry.name);
1211
+ for (const entry of await readdir3(dir, { withFileTypes: true })) {
1212
+ const file = path9.join(dir, entry.name);
750
1213
  if (entry.isDirectory()) {
751
1214
  if (entry.name !== "node_modules")
752
1215
  files.push(...await ServerBundleSecrets.#files(file));
@@ -757,10 +1220,10 @@ Build its server with a profile (native.desktop.server.profile), whose bundle le
757
1220
  }
758
1221
  static async#sources(dir) {
759
1222
  const files = [];
760
- for (const entry of await readdir2(dir, { withFileTypes: true }).catch(() => [])) {
1223
+ for (const entry of await readdir3(dir, { withFileTypes: true }).catch(() => [])) {
761
1224
  if (entry.name.startsWith("."))
762
1225
  continue;
763
- const file = path6.join(dir, entry.name);
1226
+ const file = path9.join(dir, entry.name);
764
1227
  if (entry.isDirectory()) {
765
1228
  if (!ServerBundleSecrets.#notSource.has(entry.name))
766
1229
  files.push(...await ServerBundleSecrets.#sources(file));
@@ -771,88 +1234,6 @@ Build its server with a profile (native.desktop.server.profile), whose bundle le
771
1234
  }
772
1235
  }
773
1236
 
774
- // pkgs/@akanjs/devkit/mobile/updatePackFolder.ts
775
- import { mkdtemp, rm as rm3 } from "fs/promises";
776
- import os from "os";
777
- import path7 from "path";
778
- class UpdatePackFolder {
779
- static packFile = "pack.json";
780
- static compatFile = "compat.json";
781
- static bundleFile = "bundle.json";
782
- static templateFile = "manifest.template.json";
783
- static filesDir = "files";
784
- static #records = [
785
- UpdatePackFolder.templateFile,
786
- UpdatePackFolder.bundleFile,
787
- UpdatePackFolder.packFile,
788
- UpdatePackFolder.compatFile
789
- ];
790
- static #sha256 = /^[0-9a-f]{64}$/;
791
- static async clear(dir) {
792
- await Promise.all([UpdatePackFolder.packFile, UpdatePackFolder.compatFile].map((name) => rm3(path7.join(dir, name), { force: true })));
793
- }
794
- static async read(dir) {
795
- const file = Bun.file(path7.join(dir, UpdatePackFolder.packFile));
796
- if (!await file.exists())
797
- throw new Error(`${dir} holds no ${UpdatePackFolder.packFile}: give the folder \`akan pack-update\` wrote.`);
798
- const pack = await file.json();
799
- if (pack.schema !== 1)
800
- throw new Error(`${dir}/${UpdatePackFolder.packFile} is schema ${pack.schema}, and this akan reads schema 1.`);
801
- return { ...pack, out: path7.resolve(dir) };
802
- }
803
- static async write({ out, ...record }) {
804
- await Bun.write(path7.join(out, UpdatePackFolder.packFile), `${JSON.stringify(record, null, 2)}
805
- `);
806
- }
807
- static async writeCompat(pack, compat) {
808
- pack.compat = compat;
809
- await Bun.write(path7.join(pack.out, UpdatePackFolder.compatFile), `${JSON.stringify(compat, null, 2)}
810
- `);
811
- }
812
- static async readBundle(file) {
813
- return await Bun.file(file).json();
814
- }
815
- static storeBuildVerdict({ out, compat }, then) {
816
- if (!compat || compat.compatible)
817
- return null;
818
- return new ExitCodeError(`The pack in ${out} needs a new store build; it differs from the one ${compat.against} came from:
819
- - ${compat.problems.join(`
820
- - `)}${then ? `
821
- ${then}` : ""}`, 2);
822
- }
823
- static async withArchive(pack, use) {
824
- const { templateFile, filesDir } = UpdatePackFolder;
825
- const template = Bun.file(path7.join(pack.out, templateFile));
826
- if (!await template.exists())
827
- throw new Error(`${pack.out} holds no ${templateFile}: give the folder \`akan pack-update\` wrote.`);
828
- const { files = [] } = await template.json();
829
- const hashes = [...new Set(files.map((file) => file.sha256))];
830
- if (!hashes.every((hash) => typeof hash === "string" && UpdatePackFolder.#sha256.test(hash)))
831
- throw new Error(`${pack.out}/${templateFile} lists a file whose sha256 is not 64 hex digits.`);
832
- const present = await Promise.all(UpdatePackFolder.#records.map((name) => Bun.file(path7.join(pack.out, name)).exists()));
833
- const entries = [
834
- ...UpdatePackFolder.#records.filter((_, idx) => present[idx]),
835
- ...hashes.map((hash) => `${filesDir}/${hash}`)
836
- ];
837
- const dir = await mkdtemp(path7.join(os.tmpdir(), "akan-pack-"));
838
- try {
839
- const tar = Bun.spawn(["tar", "-czf", "pack.tgz", "-C", pack.out, "-T", "-"], {
840
- cwd: dir,
841
- stdin: new Blob([entries.map((entry) => `./${entry}
842
- `).join("")]),
843
- stdout: "ignore",
844
- stderr: "pipe"
845
- });
846
- const [code, stderr] = await Promise.all([tar.exited, new Response(tar.stderr).text()]);
847
- if (code !== 0)
848
- throw new Error(`tar of ${pack.out} failed: ${stderr.trim()}`);
849
- return await use(path7.join(dir, "pack.tgz"));
850
- } finally {
851
- await rm3(dir, { recursive: true, force: true });
852
- }
853
- }
854
- }
855
-
856
1237
  // pkgs/@akanjs/devkit/mobile/nativeApp.ts
857
1238
  class NativeApp {
858
1239
  app;
@@ -865,14 +1246,14 @@ class NativeApp {
865
1246
  this.app = app;
866
1247
  this.target = target;
867
1248
  this.env = env;
868
- this.targetRoot = path8.join(app.workspace.workspaceRoot, "dist", "native", app.name, target.name);
869
- this.web = new NativeWebDir(path8.join(this.targetRoot, "web"));
1249
+ this.targetRoot = path10.join(app.workspace.workspaceRoot, "dist", "native", app.name, target.name);
1250
+ this.web = new NativeWebDir(path10.join(this.targetRoot, "web"));
870
1251
  }
871
1252
  outDir(platform) {
872
- return path8.join(this.targetRoot, "build", platform);
1253
+ return path10.join(this.targetRoot, "build", platform);
873
1254
  }
874
1255
  devOutDir(platform) {
875
- return path8.join(this.targetRoot, "dev", platform);
1256
+ return path10.join(this.targetRoot, "dev", platform);
876
1257
  }
877
1258
  indexPath(platform) {
878
1259
  const { config } = this.target;
@@ -882,13 +1263,13 @@ class NativeApp {
882
1263
  async assembleWeb(platform) {
883
1264
  const dist = this.app.dist.cwdPath;
884
1265
  return await this.web.assemble({ ...this.target.config, indexPath: this.indexPath(platform) }, {
885
- html: path8.join(dist, "csr", targetHtmlFilename(this.target.config)),
886
- publicDir: path8.join(dist, "public"),
887
- fontsDir: path8.join(dist, ".akan", "artifact", "fonts")
1266
+ html: path10.join(dist, "csr", targetHtmlFilename(this.target.config)),
1267
+ publicDir: path10.join(dist, "public"),
1268
+ fontsDir: path10.join(dist, ".akan", "artifact", "fonts")
888
1269
  });
889
1270
  }
890
1271
  get binDir() {
891
- return path8.join(this.targetRoot, "bin");
1272
+ return path10.join(this.targetRoot, "bin");
892
1273
  }
893
1274
  async config({
894
1275
  server,
@@ -1047,7 +1428,22 @@ class NativeApp {
1047
1428
  }));
1048
1429
  }
1049
1430
  get updatesDir() {
1050
- return path8.join(this.targetRoot, "updates");
1431
+ return path10.join(this.targetRoot, "updates");
1432
+ }
1433
+ async publishedRelease(platform, { arch, channel }) {
1434
+ this.#assertUpdates();
1435
+ const { config } = await this.config({ platform, stageBin: false });
1436
+ const publicKey = config.updates?.publicKeys?.[0] ?? config.updates?.publicKey;
1437
+ if (!config.updates || !publicKey)
1438
+ throw new Error(`Native target '${this.target.name}' has no updates key.`);
1439
+ const release = await DesktopRelease.read(this.updatesDir, {
1440
+ platform,
1441
+ arch,
1442
+ channel: channel ?? config.updates.channel ?? "production",
1443
+ appId: config.app.id,
1444
+ publicKey
1445
+ });
1446
+ return { release, url: config.updates.url, exeName: config.app.fileName ?? "" };
1051
1447
  }
1052
1448
  async publishUpdate(platform, {
1053
1449
  channel,
@@ -1118,7 +1514,7 @@ class NativeApp {
1118
1514
  ...resetSequence ? { resetSequence } : {}
1119
1515
  });
1120
1516
  } catch (error) {
1121
- throw new Error(`Native target '${this.target.name}': ${toError(error).message}`, {
1517
+ throw new Error(`Native target '${this.target.name}': ${toError2(error).message}`, {
1122
1518
  cause: error
1123
1519
  });
1124
1520
  }
@@ -1152,11 +1548,11 @@ class NativeApp {
1152
1548
  const { api, config } = await this.prepare(platform);
1153
1549
  if (!config.updates)
1154
1550
  throw new Error(`Native target '${this.target.name}' takes no updates: add native.updates: { url, publicKey } to akan.config.ts first.`);
1155
- const dir = path8.resolve(out ?? path8.join(this.updatesDir, platform));
1551
+ const dir = path10.resolve(out ?? path10.join(this.updatesDir, platform));
1156
1552
  await UpdatePackFolder.clear(dir);
1157
1553
  const packed = await this.#recorded(dir, publicEnv, api.packUpdate({ ...this.#task(platform, config), platform, out: dir }));
1158
1554
  const channel = config.updates.channel ?? "production";
1159
- const bundle = await UpdatePackFolder.readBundle(path8.join(packed.out, UpdatePackFolder.bundleFile));
1555
+ const bundle = await UpdatePackFolder.readBundle(path10.join(packed.out, UpdatePackFolder.bundleFile));
1160
1556
  const pack = {
1161
1557
  schema: 1,
1162
1558
  app: this.app.name,
@@ -1193,7 +1589,7 @@ bundle.json records none, so no update can be checked against this build.`);
1193
1589
  }
1194
1590
  async#recorded(dir, publicEnv, build) {
1195
1591
  const result = await build;
1196
- const file = path8.join(dir, UpdatePackFolder.bundleFile);
1592
+ const file = path10.join(dir, UpdatePackFolder.bundleFile);
1197
1593
  if (!publicEnv || !await Bun.file(file).exists())
1198
1594
  return result;
1199
1595
  const bundle = await UpdatePackFolder.readBundle(file);
@@ -1256,4 +1652,4 @@ bundle.json records none, so no update can be checked against this build.`);
1256
1652
  }
1257
1653
  }
1258
1654
 
1259
- export { DesktopBin, NativePublicEnv, UpdatePackFolder, NativeApp };
1655
+ export { DesktopBin, UpdatePackFolder, UpdateUploader, NativePublicEnv, NativeApp };