@akanjs/cli 3.1.1-rc.8 → 3.1.1

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 (184) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-35wnb7w5.js +9 -0
  3. package/{CodeTui-rqxarxsn.js → CodeTui-h6yz2kvq.js} +1 -1
  4. package/TunnelShare-xyjpa7gx.js +14 -0
  5. package/agent.command-3r4jsck8.js +46 -0
  6. package/akanCode.js +10 -6
  7. package/{application.command-14xsthcr.js → application.command-g7xv6ad0.js} +46 -13
  8. package/{applicationBuildRunner-t2r84sz6.js → applicationBuildRunner-qvjnhr9j.js} +9 -6
  9. package/buildBatch.proc.js +6 -6
  10. package/{cloud.command-rmw1kcf1.js → cloud.command-6ebygmhw.js} +17 -15
  11. package/cloud.script-0s1jybd5.js +26 -0
  12. package/{code.command-719k3e9q.js → code.command-mpkm2emr.js} +6 -6
  13. package/commandManifest.json +1 -1
  14. package/{context.command-c4t4z1vy.js → context.command-svdh6b2w.js} +18 -17
  15. package/context.runner-ch0z3a8g.js +26 -0
  16. package/{devTui-q7k7bakd.js → devTui-evr3b35y.js} +1 -1
  17. package/{guideline.command-snh85ctf.js → guideline.command-qwp3tnjx.js} +3 -3
  18. package/guidelines/conventions/core.md +106 -0
  19. package/guidelines/conventions/rules/app.md +83 -0
  20. package/guidelines/conventions/rules/auth.md +45 -0
  21. package/guidelines/conventions/rules/config.md +56 -0
  22. package/guidelines/conventions/rules/constant.md +24 -0
  23. package/guidelines/conventions/rules/gates.md +31 -0
  24. package/guidelines/conventions/rules/layer.md +25 -0
  25. package/guidelines/conventions/rules/migration.md +27 -0
  26. package/guidelines/conventions/rules/module.md +90 -0
  27. package/guidelines/conventions/rules/page.md +56 -0
  28. package/guidelines/conventions/rules/sensitive.md +16 -0
  29. package/guidelines/conventions/rules/server.md +86 -0
  30. package/guidelines/conventions/rules/ssr.md +47 -0
  31. package/guidelines/conventions/rules/style.md +43 -0
  32. package/guidelines/conventions/rules/test.md +34 -0
  33. package/guidelines/conventions/rules/ts.md +95 -0
  34. package/guidelines/conventions/rules/tsx.md +75 -0
  35. package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
  36. package/guidelines/pageRule/pageRule.instruction.md +4 -3
  37. package/guidelines/queryRule/queryRule.instruction.md +4 -0
  38. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +3 -3
  39. package/incrementalBuilder.proc.js +6 -6
  40. package/{index-pcwzkdqb.js → index-1p0qbq3m.js} +1 -1
  41. package/{index-xb8809yb.js → index-1shvxzt0.js} +3 -3
  42. package/{index-8w76g4rm.js → index-266dewjs.js} +11 -11
  43. package/{index-5max10jx.js → index-3yz30c07.js} +72 -53
  44. package/{index-xjf5j657.js → index-4mj92tsh.js} +952 -47
  45. package/index-4pdts00b.js +1604 -0
  46. package/{index-42j4a8zq.js → index-8559hsz4.js} +4 -3
  47. package/{index-wcej7g4z.js → index-8scw1pjk.js} +93 -23
  48. package/{index-5phjb48k.js → index-96wzdhfh.js} +74 -233
  49. package/index-9bv479q5.js +1 -0
  50. package/index-9rvcs76p.js +653 -0
  51. package/index-am36s3jh.js +3582 -0
  52. package/index-b8c289dx.js +444 -0
  53. package/{index-espk51ah.js → index-dd44g6vz.js} +3 -3
  54. package/{index-3wypz6xj.js → index-eja64h28.js} +7 -3
  55. package/index-fbewhg4g.js +590 -0
  56. package/index-jje9qzyq.js +27 -0
  57. package/{index-j9vyj3dj.js → index-k5jbcxyh.js} +3 -3
  58. package/{index-hmmv2cah.js → index-ksfgqq1x.js} +1 -1
  59. package/index-m5n3ka0p.js +18 -0
  60. package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
  61. package/{index-0p37cz91.js → index-payhwt51.js} +21 -29
  62. package/{index-myc22sgv.js → index-qkkdhjm6.js} +5 -4
  63. package/{index-74tjjsnc.js → index-qxzrp5xt.js} +33 -37
  64. package/{index-zrte51fn.js → index-r0k3ham2.js} +4 -4
  65. package/{index-hmt54t45.js → index-r2w2eh93.js} +4 -4
  66. package/index-r2wedvqn.js +138 -0
  67. package/{index-skk9zc1x.js → index-rnphv731.js} +2 -2
  68. package/{index-pa3c2mb8.js → index-s6da8ta9.js} +82 -1227
  69. package/index-tenw3mah.js +225 -0
  70. package/{index-31es1yev.js → index-tgt2fnd6.js} +107 -6
  71. package/{index-8ap5z1n5.js → index-vxmy1p4f.js} +16 -36
  72. package/{index-mdqr41sp.js → index-w4k2ragk.js} +7 -7
  73. package/{index-qd5km521.js → index-w7q6h97v.js} +1 -1
  74. package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
  75. package/{index-2xcc2ax5.js → index-xq543a5y.js} +2 -2
  76. package/{index-0fz95kxe.js → index-xqgwjz7a.js} +1 -1
  77. package/{index-40brg4px.js → index-xxfy1jp2.js} +4 -4
  78. package/{index-905qdgqp.js → index-z4b84y6k.js} +1 -1
  79. package/index-zcf6k8a5.js +410 -0
  80. package/index.js +23 -22
  81. package/{library.command-gycrwhf1.js → library.command-2853y6mk.js} +3 -3
  82. package/{localRegistry.command-2t3fghje.js → localRegistry.command-76ds31p4.js} +19 -15
  83. package/{module.command-v6hgs1bc.js → module.command-yfnb0abs.js} +5 -5
  84. package/{package.command-shzpcfph.js → package.command-d9s86hp9.js} +3 -3
  85. package/package.json +2 -2
  86. package/{page.command-ptxn5kqk.js → page.command-6a8a8rd1.js} +3 -3
  87. package/{pipeline.command-zz31pgax.js → pipeline.command-rt3rwd2z.js} +2 -2
  88. package/{primitive.command-a1vse91z.js → primitive.command-emcebgrq.js} +6 -6
  89. package/{projectTypecheck-2ztky9cf.js → projectTypecheck-51m7eh1f.js} +1 -1
  90. package/{prompter-76k56b37.js → prompter-hgcta8pb.js} +1 -1
  91. package/quality.command-xtrk0n3x.js +76 -0
  92. package/{repair.command-cvazbz99.js → repair.command-51szxnxx.js} +5 -5
  93. package/{routeSourceValidator-6jd0q6r6.js → routeSourceValidator-4h947v7c.js} +13 -3
  94. package/{scalar.command-0acvyp26.js → scalar.command-8qv27t82.js} +4 -4
  95. package/skills/akan-agent/SKILL.md +36 -0
  96. package/skills/akan-code/SKILL.md +1 -0
  97. package/skills/akan-debug/SKILL.md +40 -6
  98. package/skills/akan-deps/SKILL.md +1 -2
  99. package/skills/akan-mcp/SKILL.md +40 -0
  100. package/skills/akan-page/SKILL.md +44 -0
  101. package/skills/akan-query/SKILL.md +38 -0
  102. package/skills/akan-runtime/SKILL.md +40 -0
  103. package/skills/akan-scaffold/SKILL.md +16 -6
  104. package/skills/akan-transport/SKILL.md +40 -0
  105. package/skills/akan-validate/SKILL.md +13 -11
  106. package/{subspace.command-kvxmyxtf.js → subspace.command-pn56pnh8.js} +8 -8
  107. package/templates/__scalar/__model__/__model__.constant.ts +3 -5
  108. package/templates/__scalar/__model__/__model__.dictionary.ts +6 -5
  109. package/templates/__scalar/__model__/__model__.document.ts +3 -3
  110. package/templates/app/akan.config.ts +2 -3
  111. package/templates/app/env/env.client.ts +2 -4
  112. package/templates/app/env/env.client.type.ts +2 -3
  113. package/templates/app/env/env.server.ts +2 -3
  114. package/templates/app/lib/___appName__/__appName__.dictionary.ts +1 -2
  115. package/templates/app/lib/___appName__/__appName__.service.ts +3 -3
  116. package/templates/app/lib/___appName__/__appName__.signal.ts +5 -5
  117. package/templates/app/lib/___appName__/__appName__.store.ts +4 -6
  118. package/templates/app/lib/option.ts +2 -3
  119. package/templates/app/main.ts +2 -4
  120. package/templates/app/page/_index.tsx +3 -3
  121. package/templates/app/page/_layout.tsx +13 -10
  122. package/templates/appSample/lib/__scalar/workHistory/workHistory.constant.ts +1 -5
  123. package/templates/appSample/lib/__scalar/workHistory/workHistory.dictionary.ts +1 -1
  124. package/templates/appSample/lib/_noti/noti.signal.ts +1 -1
  125. package/templates/appSample/lib/task/Task.Template.tsx +2 -1
  126. package/templates/appSample/lib/task/Task.Unit.tsx +3 -2
  127. package/templates/appSample/lib/task/Task.Util.tsx +16 -4
  128. package/templates/appSample/lib/task/task.constant.ts +1 -5
  129. package/templates/appSample/lib/task/task.dictionary.ts +2 -8
  130. package/templates/appSample/lib/task/task.document.ts +1 -1
  131. package/templates/appSample/page/task/_index.tsx +2 -1
  132. package/templates/appSample/page/task/new.tsx +2 -1
  133. package/templates/appSample/ui/QuantityControl.tsx +5 -9
  134. package/templates/biomeForm.ts +144 -0
  135. package/templates/crudPages/[__model__Id]/edit/page.tsx +3 -3
  136. package/templates/crudPages/[__model__Id]/page.tsx +5 -5
  137. package/templates/crudPages/new/page.tsx +4 -3
  138. package/templates/crudPages/page.tsx +3 -3
  139. package/templates/crudSinglePage/page.tsx +9 -5
  140. package/templates/libRoot/akan.config.ts +2 -3
  141. package/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +1 -2
  142. package/templates/libRoot/lib/___libName__/__libName__.service.ts +5 -4
  143. package/templates/libRoot/lib/___libName__/__libName__.signal.ts +6 -5
  144. package/templates/libRoot/lib/___libName__/__libName__.store.ts +5 -6
  145. package/templates/libRoot/lib/option.ts +1 -2
  146. package/templates/module/__Model__.Template.tsx +11 -10
  147. package/templates/module/__Model__.Unit.tsx +18 -5
  148. package/templates/module/__Model__.Util.tsx +9 -7
  149. package/templates/module/__Model__.View.tsx +9 -6
  150. package/templates/module/__Model__.Zone.tsx +25 -17
  151. package/templates/module/__model__.constant.ts +8 -9
  152. package/templates/module/__model__.dictionary.ts +16 -17
  153. package/templates/module/__model__.document.ts +6 -8
  154. package/templates/module/__model__.service.ts +3 -3
  155. package/templates/module/__model__.signal.ts +11 -10
  156. package/templates/module/__model__.store.ts +3 -5
  157. package/templates/service/__model__.dictionary.ts +6 -5
  158. package/templates/service/__model__.service.ts +3 -3
  159. package/templates/service/__model__.signal.ts +5 -4
  160. package/templates/service/__model__.store.ts +3 -5
  161. package/templates/workspaceRoot/.gitignore.template +3 -0
  162. package/templates/workspaceRoot/.vscode/settings.json.template +21 -21
  163. package/templates/workspaceRoot/AGENTS.md.template +4 -10
  164. package/{tunnel.command-kxv0ddmp.js → tunnel.command-q2h0j2en.js} +7 -7
  165. package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
  166. package/typecheck.proc.js +6 -1
  167. package/verify.command-z1dsbmrt.js +91 -0
  168. package/{workflow.command-abb1d5xy.js → workflow.command-r3y67jeq.js} +47 -13
  169. package/workspace.command-t2f0xsrw.js +263 -0
  170. package/CodeAgent-3sy7kjgj.js +0 -9
  171. package/TunnelShare-2ef94kha.js +0 -14
  172. package/agent.command-ydftceda.js +0 -25
  173. package/cloud.script-v1ysyerg.js +0 -24
  174. package/context.runner-qb15sjf8.js +0 -25
  175. package/guidelines/conventions/conventions.instruction.md +0 -617
  176. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
  177. package/index-4vgbysa0.js +0 -279
  178. package/index-7md2g9vw.js +0 -6
  179. package/index-b70zct19.js +0 -856
  180. package/index-zzvvc845.js +0 -74
  181. package/quality.command-ah8qcakd.js +0 -1478
  182. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
  183. package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
  184. package/workspace.command-tsc99yec.js +0 -521
@@ -5,17 +5,17 @@ import {
5
5
  AkanAppConfig,
6
6
  Executor,
7
7
  WorkspaceExecutor
8
- } from "./index-wcej7g4z.js";
8
+ } from "./index-8scw1pjk.js";
9
9
  import {
10
10
  resolveAppId,
11
11
  targetHtmlFilename
12
12
  } from "./index-m9jj544v.js";
13
13
  import {
14
14
  CsrArtifactBuilder
15
- } from "./index-xb8809yb.js";
15
+ } from "./index-1shvxzt0.js";
16
16
  import {
17
17
  ExitCodeError
18
- } from "./index-3wypz6xj.js";
18
+ } from "./index-eja64h28.js";
19
19
 
20
20
  // pkgs/@akanjs/devkit/mobile/desktopBin.ts
21
21
  import { chmod, mkdir, rename, rm, writeFile } from "fs/promises";
@@ -138,7 +138,6 @@ class DesktopBin {
138
138
  }
139
139
 
140
140
  // pkgs/@akanjs/devkit/mobile/desktopRelease.ts
141
- import { createPublicKey, verify } from "crypto";
142
141
  import { mkdtemp as mkdtemp2, readFile, rm as rm3 } from "fs/promises";
143
142
  import os2 from "os";
144
143
  import path4 from "path";
@@ -337,25 +336,28 @@ class UpdateUploader {
337
336
  }
338
337
  static async releaseFiles(updatesDir, { dir, channel, bundle }) {
339
338
  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
- }
339
+ const v1 = await UpdateUploader.#read(path3.join(dir, `${channel}.json`));
340
+ const pair = v1?.bundle === bundle ? [`${channel}.json.sig`, `${channel}.json`] : [];
346
341
  const names = await readdir(path3.join(dir, channel)).catch(() => []);
347
342
  for (const name of names.filter((name) => name.endsWith(".json"))) {
348
343
  const envelope = await UpdateUploader.#read(path3.join(dir, channel, name));
349
344
  const manifest = typeof envelope?.manifest === "string" ? UpdateUploader.#parse(Buffer.from(envelope.manifest, "base64").toString("utf8")) : null;
350
345
  if (manifest?.bundle !== bundle)
351
346
  continue;
347
+ if (manifest.kind === "app")
348
+ return [...UpdateUploader.#appFiles(manifest), ...pair, `${channel}/${name}`].map(keyOf);
352
349
  const hashes = [...new Set(UpdateUploader.#field(manifest.files, "sha256"))];
353
350
  if (!hashes.every((hash) => typeof hash === "string" && /^[0-9a-f]{64}$/.test(hash)))
354
351
  throw new Error(`${path3.join(dir, channel, name)} lists a file whose sha256 is not 64 hex digits; nothing was uploaded.`);
355
352
  return [...hashes.map((hash) => `${UpdatePackFolder.filesDir}/${hash}`), `${channel}/${name}`].map(keyOf);
356
353
  }
354
+ if (v1 && pair.length)
355
+ return [...UpdateUploader.#appFiles(v1), ...pair].map(keyOf);
357
356
  throw new Error(`${dir} holds no ${channel} manifest of release ${bundle}; nothing was uploaded.`);
358
357
  }
358
+ static #appFiles(manifest) {
359
+ return [manifest.archive?.url, ...UpdateUploader.#field(manifest.patches, "url")];
360
+ }
359
361
  static #keyOf(updatesDir, dir, file) {
360
362
  const resolved = typeof file === "string" ? path3.resolve(dir, file) : "";
361
363
  const key = path3.relative(updatesDir, resolved);
@@ -416,46 +418,46 @@ class DesktopRelease {
416
418
  platform;
417
419
  arch;
418
420
  channel;
419
- manifestBytes;
420
- signatureBytes;
421
- static #ed25519Spki = Buffer.from("302a300506032b6570032100", "hex");
421
+ manifestFiles;
422
422
  static #authenticode = `$ErrorActionPreference = 'Stop'
423
423
  $ProgressPreference = 'SilentlyContinue'
424
424
  $signature = Get-AuthenticodeSignature -LiteralPath $env:AKAN_RELEASE_EXE
425
425
  $subject = if ("$($signature.Status)" -ceq 'Valid') { "$($signature.SignerCertificate.Subject)" } else { '' }
426
426
  Set-Content -LiteralPath $env:AKAN_SIGNER_OUT -Value $subject -Encoding UTF8`;
427
- constructor(dir, manifest, payloads, platform, arch, channel, manifestBytes, signatureBytes) {
427
+ constructor(dir, manifest, payloads, platform, arch, channel, manifestFiles) {
428
428
  this.dir = dir;
429
429
  this.manifest = manifest;
430
430
  this.payloads = payloads;
431
431
  this.platform = platform;
432
432
  this.arch = arch;
433
433
  this.channel = channel;
434
- this.manifestBytes = manifestBytes;
435
- this.signatureBytes = signatureBytes;
434
+ this.manifestFiles = manifestFiles;
436
435
  }
437
436
  static async read(updatesDir, {
438
437
  platform,
439
438
  arch,
440
439
  channel,
441
440
  appId,
442
- publicKey
441
+ target,
442
+ publicKeys,
443
+ revokedKeys = [],
444
+ api
443
445
  }) {
444
446
  const folder = `${platform}-${arch}`;
445
447
  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}.`);
448
+ const envelopeName = `${channel}/app.json`;
449
+ const envelopePath = path4.join(dir, channel, "app.json");
450
+ const envelope = await readFile(envelopePath).catch(() => null);
451
+ if (!envelope)
452
+ throw new Error(`${envelopePath} is missing: run \`akan publish-update\` first.`);
453
+ const opened = DesktopRelease.#open(api, envelope, publicKeys, revokedKeys);
454
+ if (typeof opened === "string")
455
+ throw new Error(`${envelopePath}: ${opened}; publish the release again.`);
456
+ const manifest = DesktopRelease.#parse(opened);
457
+ if (manifest?.schema !== 2 || manifest.kind !== "app" || manifest.app !== appId || manifest.platform !== platform || manifest.arch !== arch || manifest.channel !== channel || manifest.target !== target || typeof manifest.bundle !== "string" || typeof manifest.sequence !== "number" || typeof manifest.build !== "number" || !manifest.archive)
458
+ throw new Error(`${envelopePath} is not a release of ${appId}${target ? ` target ${target}` : ""} for ${folder} on channel ${channel}.`);
458
459
  const { archive, bundle, sequence, build } = manifest;
460
+ const legacy = await DesktopRelease.#legacyPair(api, dir, channel, publicKeys[0], manifest);
459
461
  const keys = await UpdateUploader.releaseFiles(updatesDir, { dir, channel, bundle });
460
462
  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
463
  const payloads = keys.flatMap((key) => {
@@ -463,12 +465,26 @@ Set-Content -LiteralPath $env:AKAN_SIGNER_OUT -Value $subject -Encoding UTF8`;
463
465
  const digest = expected.get(name);
464
466
  return digest ? [{ name, ...digest }] : [];
465
467
  });
466
- return new DesktopRelease(dir, { ...manifest, archive, bundle, sequence, build }, payloads, platform, arch, channel, manifestBytes, signatureBytes);
468
+ return new DesktopRelease(dir, { ...manifest, archive, bundle, sequence, build }, payloads, platform, arch, channel, [{ name: envelopeName, bytes: envelope }, ...legacy]);
469
+ }
470
+ static async#legacyPair(api, dir, channel, publicKey, manifest) {
471
+ const [bytes, signature] = await Promise.all([`${channel}.json`, `${channel}.json.sig`].map((name) => readFile(path4.join(dir, name)).catch(() => null)));
472
+ if (!bytes || !signature || !publicKey)
473
+ return [];
474
+ const v1 = DesktopRelease.#parse(bytes);
475
+ if (v1?.schema !== 1 || v1.bundle !== manifest.bundle || v1.sequence !== manifest.sequence)
476
+ return [];
477
+ if (!api.verifyManifest(bytes, new TextDecoder().decode(signature).trim(), publicKey))
478
+ return [];
479
+ return [
480
+ { name: `${channel}.json`, bytes },
481
+ { name: `${channel}.json.sig`, bytes: signature }
482
+ ];
467
483
  }
468
484
  record(signer) {
469
485
  const { platform, arch, channel } = this;
470
486
  const builtAt = new Date(this.manifest.build * 1000).toISOString();
471
- return { schema: 1, cli: AkanAppConfig.akanVersion, platform, arch, channel, signer, builtAt };
487
+ return { schema: 2, cli: AkanAppConfig.akanVersion, platform, arch, channel, signer, builtAt };
472
488
  }
473
489
  async withArchive(record, use) {
474
490
  const tmp = await mkdtemp2(path4.join(os2.tmpdir(), "akan-release-"));
@@ -478,11 +494,11 @@ Set-Content -LiteralPath $env:AKAN_SIGNER_OUT -Value $subject -Encoding UTF8`;
478
494
  try {
479
495
  await tar.add("./release.json", new Blob([`${JSON.stringify(record, null, 2)}
480
496
  `]));
481
- await tar.add(`./${this.channel}.json`, new Blob([this.manifestBytes]));
482
- await tar.add(`./${this.channel}.json.sig`, new Blob([this.signatureBytes]));
497
+ for (const { name, bytes } of this.manifestFiles)
498
+ await tar.add(`./${name}`, new Blob([bytes]));
483
499
  for (const { name, size, sha256 } of this.payloads) {
484
500
  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`;
501
+ const what = `${path4.join(this.dir, name)} is not the file ${this.channel}/app.json names`;
486
502
  if (!await file.exists() || file.size !== size)
487
503
  throw new Error(`${what}: publish the release again.`);
488
504
  if (await tar.add(`./${name}`, file) !== sha256)
@@ -507,7 +523,7 @@ Set-Content -LiteralPath $env:AKAN_SIGNER_OUT -Value $subject -Encoding UTF8`;
507
523
  return { signer: null, unread: null };
508
524
  const app = this.manifest.files?.[0]?.path;
509
525
  if (!app || !/^[^/\\]+$/.test(app) || app === "." || app === "..")
510
- return { signer: null, unread: `${this.channel}.json names no app folder` };
526
+ return { signer: null, unread: `${this.channel}/app.json names no app folder` };
511
527
  if (this.platform === "macos" && host !== "darwin")
512
528
  return { signer: null, unread: "codesign reads a macOS app's signer on macOS only" };
513
529
  if (this.platform === "windows" && host !== "win32")
@@ -542,7 +558,8 @@ Set-Content -LiteralPath $env:AKAN_SIGNER_OUT -Value $subject -Encoding UTF8`;
542
558
  `)[0] ?? ""}` };
543
559
  }
544
560
  static async#subjectOf(run, archive, tmp, exe) {
545
- await run(["tar.exe", "-xzf", archive, "-C", tmp, exe]);
561
+ const tar = path4.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe");
562
+ await run([tar, "-xzf", archive, "-C", tmp, exe]);
546
563
  const extracted = path4.join(tmp, exe);
547
564
  if (!await Bun.file(extracted).exists())
548
565
  return { signer: null, unread: `the archive holds no ${exe}` };
@@ -559,16 +576,11 @@ Set-Content -LiteralPath $env:AKAN_SIGNER_OUT -Value $subject -Encoding UTF8`;
559
576
  const subject = (await readFile(out, "utf8").catch(() => "")).replace(/^\uFEFF/, "").trim();
560
577
  return { signer: subject ? { subject } : null, unread: null };
561
578
  }
562
- static #verifies(manifest, signature, publicKey) {
579
+ static #open(api, envelope, publicKeys, revokedKeys) {
563
580
  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;
581
+ return api.openEnvelope(new TextDecoder().decode(envelope), publicKeys, revokedKeys).manifest;
582
+ } catch (error) {
583
+ return toError(error).message;
572
584
  }
573
585
  }
574
586
  static #parse(bytes) {
@@ -604,7 +616,7 @@ import path5 from "path";
604
616
 
605
617
  class NativeApi {
606
618
  static supportedMajor = 0;
607
- static minimumVersion = "0.12.0";
619
+ static minimumVersion = "0.13.0";
608
620
  static entryOf(appDir) {
609
621
  const workspaceEntry = NativeApi.#resolve("@akanjs/native/api", appDir);
610
622
  if (workspaceEntry)
@@ -894,7 +906,7 @@ class NativeConfig {
894
906
  static #updates(target, env) {
895
907
  const { url, publicKey, publicKeys, channel = env, ...rest } = target.updates ?? {};
896
908
  const keys = publicKeys ? { publicKeys: [...publicKeys] } : publicKey ? { publicKey } : null;
897
- return url && keys ? { ...rest, url, ...keys, ...channel ? { channel } : {} } : undefined;
909
+ return url && keys ? { ...rest, url, ...keys, ...channel ? { channel } : {}, target: target.name } : undefined;
898
910
  }
899
911
  static fileNameOf(name) {
900
912
  return /[^-.](?:.*[^-.])?/.exec(name.replace(/[^A-Za-z0-9._-]/g, "-"))?.[0] ?? "app";
@@ -1432,18 +1444,25 @@ class NativeApp {
1432
1444
  }
1433
1445
  async publishedRelease(platform, { arch, channel }) {
1434
1446
  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)
1447
+ const [api, { config }] = await Promise.all([
1448
+ NativeApi.load(this.app.cwdPath),
1449
+ this.config({ platform, stageBin: false })
1450
+ ]);
1451
+ const { updates } = config;
1452
+ const publicKeys = updates?.publicKeys ?? (updates?.publicKey ? [updates.publicKey] : []);
1453
+ if (!updates || !publicKeys.length)
1438
1454
  throw new Error(`Native target '${this.target.name}' has no updates key.`);
1439
1455
  const release = await DesktopRelease.read(this.updatesDir, {
1440
1456
  platform,
1441
1457
  arch,
1442
- channel: channel ?? config.updates.channel ?? "production",
1458
+ channel: channel ?? updates.channel ?? "production",
1443
1459
  appId: config.app.id,
1444
- publicKey
1460
+ ...updates.target ? { target: updates.target } : {},
1461
+ publicKeys,
1462
+ revokedKeys: updates.revokedKeys ?? [],
1463
+ api
1445
1464
  });
1446
- return { release, url: config.updates.url, exeName: config.app.fileName ?? "" };
1465
+ return { release, url: updates.url, exeName: config.app.fileName ?? "" };
1447
1466
  }
1448
1467
  async publishUpdate(platform, {
1449
1468
  channel,