akanjs 3.3.0 → 3.4.0-rc.0

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 (62) hide show
  1. package/common/PipelinePlanSchema.ts +31 -7
  2. package/common/index.ts +6 -0
  3. package/common/pipelinePlan.ts +31 -5
  4. package/index.ts +7 -5
  5. package/package.json +1 -1
  6. package/pipelineConfig.ts +25 -2
  7. package/service/agentLoop/agentLoop.ts +19 -12
  8. package/service/predefinedAdaptor/anthropicTools.ts +8 -2
  9. package/types/common/index.d.ts +1 -1
  10. package/types/common/pipelinePlan.d.ts +35 -6
  11. package/types/index.d.ts +7 -5
  12. package/types/pipelineConfig.d.ts +20 -3
  13. package/types/server/logging/rotatingLogWriter.d.ts +1 -1
  14. package/types/service/predefinedAdaptor/anthropicTools.d.ts +1 -0
  15. package/types/vendor/@akanjs/native/packages/cli/src/api-updates.d.ts +149 -0
  16. package/types/vendor/@akanjs/native/packages/cli/src/api.d.ts +16 -162
  17. package/types/vendor/@akanjs/native/packages/cli/src/config.d.ts +3 -2
  18. package/types/vendor/@akanjs/native/packages/cli/src/lib/api-task.d.ts +79 -0
  19. package/types/vendor/@akanjs/native/packages/cli/src/lib/prepare.d.ts +1 -1
  20. package/types/vendor/@akanjs/native/packages/cli/src/lib/publish.d.ts +17 -5
  21. package/types/vendor/@akanjs/native/packages/cli/src/lib/updates.d.ts +29 -2
  22. package/types/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.d.ts +36 -0
  23. package/types/vendor/@akanjs/native/packages/cli/src/platforms/linux-install.d.ts +15 -0
  24. package/types/vendor/@akanjs/native/packages/core/src/kernel.d.ts +16 -5
  25. package/types/vendor/@akanjs/native/packages/desktop/src/commands.d.ts +81 -0
  26. package/types/vendor/@akanjs/native/packages/desktop/src/deeplinks.d.ts +5 -1
  27. package/types/vendor/@akanjs/native/packages/desktop/src/dispatcher.d.ts +3 -0
  28. package/types/vendor/@akanjs/native/packages/desktop/src/lifecycle.d.ts +8 -1
  29. package/types/vendor/@akanjs/native/packages/desktop/src/plugin.d.ts +21 -0
  30. package/types/vendor/@akanjs/native/packages/desktop/src/server.d.ts +1 -0
  31. package/types/vendor/@akanjs/native/plugins/updates/src/desktop.d.ts +4 -4
  32. package/types/vendor/@akanjs/native/plugins/updates/src/reports.d.ts +49 -0
  33. package/types/vendor/@akanjs/native/plugins/updates/src/signer.d.ts +21 -0
  34. package/types/vendor/@akanjs/native/plugins/window/src/index.d.ts +55 -3
  35. package/vendor/@akanjs/native/native/desktop/src/lib.rs +209 -54
  36. package/vendor/@akanjs/native/packages/cli/src/api-updates.ts +332 -0
  37. package/vendor/@akanjs/native/packages/cli/src/api.ts +67 -419
  38. package/vendor/@akanjs/native/packages/cli/src/commands/build.ts +4 -1
  39. package/vendor/@akanjs/native/packages/cli/src/config.ts +3 -2
  40. package/vendor/@akanjs/native/packages/cli/src/lib/api-task.ts +223 -0
  41. package/vendor/@akanjs/native/packages/cli/src/lib/prepare.ts +2 -7
  42. package/vendor/@akanjs/native/packages/cli/src/lib/publish.ts +164 -19
  43. package/vendor/@akanjs/native/packages/cli/src/lib/updates.ts +90 -3
  44. package/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.ts +195 -43
  45. package/vendor/@akanjs/native/packages/cli/src/platforms/linux-appimage.ts +1 -1
  46. package/vendor/@akanjs/native/packages/cli/src/platforms/linux-install.ts +206 -0
  47. package/vendor/@akanjs/native/packages/cli/src/platforms/linux.ts +5 -1
  48. package/vendor/@akanjs/native/packages/core/src/kernel.ts +21 -6
  49. package/vendor/@akanjs/native/packages/core/vectors/updates.json +2 -1
  50. package/vendor/@akanjs/native/packages/desktop/src/commands.ts +380 -0
  51. package/vendor/@akanjs/native/packages/desktop/src/deeplinks.ts +20 -3
  52. package/vendor/@akanjs/native/packages/desktop/src/dispatcher.ts +28 -13
  53. package/vendor/@akanjs/native/packages/desktop/src/host.ts +6 -18
  54. package/vendor/@akanjs/native/packages/desktop/src/lifecycle.ts +8 -1
  55. package/vendor/@akanjs/native/packages/desktop/src/plugin.ts +21 -0
  56. package/vendor/@akanjs/native/packages/desktop/src/server.ts +1 -1
  57. package/vendor/@akanjs/native/plugins/updates/src/desktop.ts +90 -164
  58. package/vendor/@akanjs/native/plugins/updates/src/reports.ts +255 -0
  59. package/vendor/@akanjs/native/plugins/updates/src/signer.ts +133 -0
  60. package/vendor/@akanjs/native/plugins/window/native-plugin.json +6 -1
  61. package/vendor/@akanjs/native/plugins/window/src/desktop.ts +20 -4
  62. package/vendor/@akanjs/native/plugins/window/src/index.ts +55 -3
@@ -0,0 +1,149 @@
1
+ import type { AkanNativeConfig } from "./config.ts";
2
+ import { type BuildResult, type TaskOptions } from "./lib/api-task.ts";
3
+ import type { MacosBuild } from "./lib/macossigning.ts";
4
+ import { type WindowsBuild } from "./lib/prepare.ts";
5
+ import { type DesktopArch, type UpdateManifest } from "./lib/updates.ts";
6
+ import type { DesktopOs } from "./platforms/desktop.ts";
7
+ import { type AppSigner } from "./platforms/desktop-update.ts";
8
+ import type { TargetPlatform } from "./platforms/index.ts";
9
+ /**
10
+ * An unsigned web bundle update (UP-2), for a signer that keeps the key off the build machine. Writes
11
+ * `<out>/files/<sha256>`, `<out>/manifest.template.json` (the manifest with `channel`, `sequence` and `bundle` left
12
+ * empty for the signer) and `<out>/bundle.json` (the native API the bundle needs, UP-3). Prepares the web bundle as a
13
+ * release build does, without building the native app.
14
+ */
15
+ export declare function packUpdate(options: TaskOptions & {
16
+ platform: "ios" | "android";
17
+ out: string;
18
+ }): Promise<{
19
+ manifest: UpdateManifest;
20
+ out: string;
21
+ }>;
22
+ export interface AppUpdatePack {
23
+ build: BuildResult;
24
+ /** Holds `app/<tar sha256>.tar.gz`, `app/<from>-<to>.delta.gz` with `previous`, and `manifest.template.json`. */
25
+ out: string;
26
+ /** manifest.template.json: `channel`, `sequence` and `bundle` are the signer's to fill (fillManifest). */
27
+ manifest: UpdateManifest;
28
+ /**
29
+ * Who signed the app's files (not the update key): an installed app signed by a team or a certificate takes only a
30
+ * release signed by the same. null: ad hoc or unsigned, which only an app signed that way takes.
31
+ */
32
+ signer: AppSigner | null;
33
+ }
34
+ /**
35
+ * An unsigned desktop app update (UP-1), for a signer that keeps the key off the build machine: a release build, its
36
+ * archive as publishUpdate names it, and the manifest with `channel`, `sequence` and `bundle` left empty. The signer
37
+ * fills it (fillManifest), signs its bytes (manifestBytes) and wraps them (updateEnvelope, sealManifest); the envelope
38
+ * goes to `<os>-<arch>/<channel>/app.json` beside `app/`.
39
+ */
40
+ export declare function packAppUpdate(options: TaskOptions & {
41
+ platform: DesktopOs;
42
+ out: string;
43
+ /** The signature a macOS release carries: the installed app's own, or the updater refuses it. No dmg is made. */
44
+ macos?: Pick<MacosBuild, "signing" | "notarize">;
45
+ /** Authenticode for a Windows release's files. No setup program is made. */
46
+ windows?: Pick<WindowsBuild, "signing">;
47
+ /** The CPU of the apps it updates, of the same OS. Default this computer's. */
48
+ arch?: DesktopArch;
49
+ /**
50
+ * The archive of the release the channel has now (`<tar sha256>.tar.gz`, a path or a URL of the feed): the pack
51
+ * then carries the delta from it, and the manifest names it in `patches`.
52
+ */
53
+ previous?: string;
54
+ }): Promise<AppUpdatePack>;
55
+ export interface PublishResult {
56
+ build: BuildResult;
57
+ /** `<out>/<os>-<arch>` (desktop) or `<out>/<platform>` (a phone's web bundle): what to upload under updates.url. */
58
+ dir: string;
59
+ bundle: string;
60
+ channel: string;
61
+ files: number;
62
+ /** Bytes of the files the manifest names. */
63
+ size: number;
64
+ }
65
+ export interface PublishCheckOptions extends Pick<TaskOptions, "appDir" | "config"> {
66
+ platform: Exclude<TargetPlatform, "web">;
67
+ channel?: string;
68
+ out?: string;
69
+ /** Whether the release will carry a server; the config's `desktop.server` by default. */
70
+ server?: boolean;
71
+ /** A desktop release's CPU, which names its feed folder: this computer's by default. */
72
+ arch?: DesktopArch;
73
+ /**
74
+ * keyIds of updates.publicKeys the release starts revoking, beside updates.revokedKeys and what the channel's releases
75
+ * revoke. It is signed with a key listed after every key it revokes.
76
+ */
77
+ revoke?: string[];
78
+ /** A release that revokes a key: apps compare it with their own build instead of the running release. */
79
+ resetSequence?: boolean;
80
+ }
81
+ /**
82
+ * What publishUpdate() refuses before it builds, without building (CONFIG_INVALID): no updates settings, a channel no
83
+ * app could be configured for, no signing key on this machine or another app's, a desktop release whose server
84
+ * presence is not the channel's previous release's, and a release whose revocations no app would take. For a
85
+ * caller with a long build of its own before publishUpdate.
86
+ */
87
+ export declare function checkPublishUpdate(options: PublishCheckOptions): {
88
+ channel: string;
89
+ out: string;
90
+ };
91
+ /**
92
+ * A signed release for the updates plugin (UP-1, UP-2): a release build, then its envelope and its files under `out`
93
+ * (default <appDir>/.akan/native/updates), signed with the key updateKeygen() made.
94
+ */
95
+ export declare function publishUpdate(options: TaskOptions & {
96
+ platform: Exclude<TargetPlatform, "web">;
97
+ channel?: string;
98
+ out?: string;
99
+ /** The signature a macOS release carries: the installed app's own, or the updater refuses it. No dmg is made. */
100
+ macos?: Pick<MacosBuild, "signing" | "notarize">;
101
+ /** Authenticode for a Windows release's files. No setup program is made. */
102
+ windows?: Pick<WindowsBuild, "signing">;
103
+ /** A desktop release's CPU, of the same OS: an x64 release from an arm64 machine. Default this computer's. */
104
+ arch?: DesktopArch;
105
+ /** keyIds of updates.publicKeys the release starts revoking (PublishCheckOptions.revoke). */
106
+ revoke?: string[];
107
+ /** A release that revokes a key: apps compare it with their own build instead of the running release. */
108
+ resetSequence?: boolean;
109
+ }): Promise<PublishResult>;
110
+ /**
111
+ * Whether a web bundle can run in the binary a store release shipped (UP-3): `shipped` is that build's bundle.json,
112
+ * `bundle` the one `packUpdate` wrote. Anything in `problems` means a new binary.
113
+ */
114
+ export declare function compareBundles(shipped: string, bundle: string): {
115
+ compatible: boolean;
116
+ problems: string[];
117
+ };
118
+ /**
119
+ * The app's update signing key: made once (AKAN_NATIVE_UPDATE_KEY, else ~/.akan/native/keys/<app id>.update.key),
120
+ * then read. `publicKey` goes into the config's `updates.publicKeys`; the key file never leaves the machine. `keyId`
121
+ * is what a revocation names it by (`publishUpdate({ revoke })`, `updates.revokedKeys`).
122
+ */
123
+ export declare function updateKeygen(options: {
124
+ config: AkanNativeConfig;
125
+ }): {
126
+ publicKey: string;
127
+ keyId: string;
128
+ keyPath: string;
129
+ created: boolean;
130
+ };
131
+ export type RepublishResult = Omit<PublishResult, "build"> & {
132
+ /** The bundle id of the release that was signed again. */
133
+ from: string;
134
+ };
135
+ /**
136
+ * Signs a desktop release publishUpdate wrote under `out` again, as its channel's newest: the same archive under a new
137
+ * sequence and bundle id, with no patch and no build. Apps on any other build take it whole, which is how a release is
138
+ * rolled back by the one who holds the key. Refuses what checkPublishUpdate refuses.
139
+ */
140
+ export declare function republishUpdate(options: Pick<TaskOptions, "appDir" | "config" | "resolveFrom" | "log" | "signal"> & {
141
+ platform: DesktopOs;
142
+ /** The release to sign again: its manifest's `bundle`. */
143
+ bundle: string;
144
+ channel?: string;
145
+ out?: string;
146
+ arch?: DesktopArch;
147
+ revoke?: string[];
148
+ resetSequence?: boolean;
149
+ }): Promise<RepublishResult>;
@@ -1,96 +1,39 @@
1
+ import { checkPublishUpdate, compareBundles, packAppUpdate, packUpdate, publishUpdate, republishUpdate, updateKeygen } from "./api-updates.ts";
1
2
  import { type DoctorCheck } from "./commands/doctor.ts";
2
3
  import type { AkanNativeConfig } from "./config.ts";
4
+ import { AkanNativeError, type AkanNativeErrorCode, type Artifact, type BuildResult, type TaskOptions } from "./lib/api-task.ts";
3
5
  import { requestedDistribution } from "./lib/distribution.ts";
4
6
  import type { Device, DeviceSelector } from "./lib/launch.ts";
5
7
  import { type LogEvent, type LogSink } from "./lib/log.ts";
6
8
  import { type MacosBuild, type MacosNotarization, type MacosSigning, macosDistributionFromEnv } from "./lib/macossigning.ts";
7
- import { type AndroidSigning, type BuildProfile, type IosBuild, type IosSigning, type IosSigningResult, type LinuxBuild, type WindowsBuild } from "./lib/prepare.ts";
8
- import { type DesktopArch, type UpdateManifest } from "./lib/updates.ts";
9
+ import type { AndroidSigning, BuildProfile, IosBuild, IosSigning, IosSigningResult, LinuxBuild, WindowsBuild } from "./lib/prepare.ts";
10
+ import type { DesktopArch } from "./lib/updates.ts";
9
11
  import { type WindowsSigning, windowsSigningFromEnv } from "./lib/windowssigning.ts";
10
12
  import { type TargetPlatform } from "./platforms/index.ts";
11
- export { MAX_REVOKE_KEYS, MAX_UPDATE_MANIFEST, UPDATE_REPORT_BATCH, UPDATE_REPORT_EVENTS, UPDATE_REPORT_LIMIT, UPDATE_REPORT_REASONS, type UpdateDecision, type UpdateDecisionInput, type UpdateReportBody, type UpdateReportEntry, type UpdateReportEvent, type UpdateReportOutcome, type UpdateReportReason, updateDecision, updateReportOutcome, } from "../../core/src/kernel.ts";
13
+ export { MAX_REVOKE_KEYS, MAX_UPDATE_MANIFEST, UPDATE_REPORT_BATCH, UPDATE_REPORT_DESKTOP_REASONS, UPDATE_REPORT_EVENTS, UPDATE_REPORT_LIMIT, UPDATE_REPORT_REASONS, type UpdateDecision, type UpdateDecisionInput, type UpdateReportBody, type UpdateReportDesktopReason, type UpdateReportEntry, type UpdateReportEvent, type UpdateReportOutcome, type UpdateReportReason, updateDecision, updateReportOutcome, } from "../../core/src/kernel.ts";
12
14
  /** How a desktop app's launcher keeps the server it carries running: desktop.server's restart and watchdog. */
13
15
  export type { ServerPolicy } from "../../desktop/src/server.ts";
16
+ export type { AppUpdatePack, PublishCheckOptions, PublishResult, RepublishResult } from "./api-updates.ts";
14
17
  /** A build's bundle.json, and the manifest and envelope of a release, as a signer or server reads them. */
15
18
  export type { BundleInfo, NativeApi } from "./lib/compat.ts";
16
- export type { UpdateEnvelope, UpdateFile, UpdateManifest } from "./lib/updates.ts";
19
+ export type { ManifestRelease, UpdateEnvelope, UpdateFile, UpdateManifest } from "./lib/updates.ts";
17
20
  /**
18
- * A phone's update protocol as the apps run it, for a signer or a server that checks what it publishes or registers:
19
- * the envelope's verification, the keyId of a public key, and what a verified manifest means to a binary.
21
+ * The update protocol as the apps run it, for a signer or a server that checks what it publishes or registers: the
22
+ * envelope's verification, the keyId of a public key, and what a verified manifest means to a binary. And what signs
23
+ * a pack: its template made a release's manifest (fillManifest), that manifest's exact bytes (manifestBytes), and
24
+ * their envelope from a key file (sealManifest) or from a signature made elsewhere (updateEnvelope).
20
25
  */
21
- export { keyIdOf, openEnvelope, verifyManifest } from "./lib/updates.ts";
22
- export type { AkanNativeConfig, AndroidSigning, DesktopArch, Device, DeviceSelector, DoctorCheck, IosBuild, IosSigning, IosSigningResult, LinuxBuild, LogEvent, MacosBuild, MacosNotarization, MacosSigning, TargetPlatform, WindowsBuild, WindowsSigning, };
26
+ export { fillManifest, keyIdOf, manifestBytes, openEnvelope, sealManifest, updateEnvelope, verifyManifest, } from "./lib/updates.ts";
27
+ export type { AppSigner } from "./platforms/desktop-update.ts";
28
+ export type { AkanNativeConfig, AkanNativeErrorCode, AndroidSigning, Artifact, BuildResult, DesktopArch, Device, DeviceSelector, DoctorCheck, IosBuild, IosSigning, IosSigningResult, LinuxBuild, LogEvent, MacosBuild, MacosNotarization, MacosSigning, TargetPlatform, TaskOptions, WindowsBuild, WindowsSigning, };
23
29
  /**
24
30
  * The macOS signing and notarization the AKAN_NATIVE_MACOS_* variables name, for a caller that keeps them in its
25
31
  * environment (the API itself reads no variable): pass the result as `macos`.
26
32
  */
27
33
  /** The Authenticode settings the AKAN_NATIVE_WINDOWS_* variables name: pass the result as `windows.signing`. */
28
- export { macosDistributionFromEnv, requestedDistribution, windowsSigningFromEnv };
34
+ export { AkanNativeError, checkPublishUpdate, compareBundles, macosDistributionFromEnv, packAppUpdate, packUpdate, publishUpdate, republishUpdate, requestedDistribution, updateKeygen, windowsSigningFromEnv, };
29
35
  /** semver of this API. A caller checks the major before it relies on anything here. */
30
- export declare const API_VERSION = "0.13.0";
31
- export type AkanNativeErrorCode = "CONFIG_INVALID" | "TOOLCHAIN_MISSING" | "WEB_INPUT_INVALID" | "WEB_BUILD_FAILED" | "NATIVE_BUILD_FAILED" | "SIGNING_FAILED" | "DEVICE_FAILED" | "CANCELLED" | "INTERNAL";
32
- export declare class AkanNativeError extends Error {
33
- readonly code: AkanNativeErrorCode;
34
- readonly details: {
35
- problems?: string[];
36
- hint?: string;
37
- logTail?: string[];
38
- cause?: unknown;
39
- };
40
- constructor(code: AkanNativeErrorCode, message: string, details?: {
41
- problems?: string[];
42
- hint?: string;
43
- logTail?: string[];
44
- cause?: unknown;
45
- });
46
- get problems(): string[] | undefined;
47
- get hint(): string | undefined;
48
- get logTail(): string[] | undefined;
49
- }
50
- export interface TaskOptions {
51
- /** Base of the config's relative paths (web.dir, icon, relative plugin folders). */
52
- appDir: string;
53
- /** What akan-native.config.ts would export. No file is read. */
54
- config: AkanNativeConfig;
55
- platform: TargetPlatform;
56
- /** Default <appDir>/.akan/native/build/<platform>. */
57
- outDir?: string;
58
- /** Picks .env.<mode>. Default "production" for build, "development" for run. */
59
- mode?: string;
60
- /** false: no .env files from appDir. Default true. */
61
- envFiles?: boolean;
62
- /** PUBLIC_ values above .env files and config.env. */
63
- env?: Record<string, string>;
64
- /** Skip config.web.build and use web.dir as it is. */
65
- skipWebBuild?: boolean;
66
- /** Where plugin package names resolve from. Default appDir. */
67
- resolveFrom?: string;
68
- /** Receives the log. Without it nothing is logged. */
69
- log?: LogSink;
70
- /** Kills the running tools and rejects with CANCELLED. */
71
- signal?: AbortSignal;
72
- }
73
- export interface Artifact {
74
- kind: "app" | "apk" | "aab" | "ipa" | "folder" | "web" | "installer";
75
- path: string;
76
- signing: "none" | "adhoc" | "debug" | "development" | "distribution";
77
- device?: "simulator" | "device";
78
- }
79
- export interface BuildResult {
80
- platform: TargetPlatform;
81
- profile: BuildProfile;
82
- outDir: string;
83
- artifacts: Artifact[];
84
- warnings: string[];
85
- durationMs: number;
86
- /** iPhone builds: the identity and provisioning profile found (docs/api.md §3 "Finding the signing"). */
87
- signing?: IosSigningResult;
88
- /**
89
- * Android builds that contain pinned libraries (push's FCM module, iap): the license notices file
90
- * (akan-native-licenses.json, also served in the app at /akan-native-licenses.json).
91
- */
92
- licenses?: string;
93
- }
36
+ export declare const API_VERSION = "0.14.0";
94
37
  export interface RunningApp {
95
38
  build: BuildResult;
96
39
  /** Where the app runs (iOS and Android). */
@@ -127,95 +70,6 @@ export declare function release(options: TaskOptions & ({
127
70
  platform: "ios";
128
71
  signing?: IosSigning;
129
72
  })): Promise<BuildResult>;
130
- /**
131
- * An unsigned web bundle update (UP-2), for a signer that keeps the key off the build machine. Writes
132
- * `<out>/files/<sha256>`, `<out>/manifest.template.json` (the manifest with `channel`, `sequence` and `bundle` left
133
- * empty for the signer) and `<out>/bundle.json` (the native API the bundle needs, UP-3). Prepares the web bundle as a
134
- * release build does, without building the native app.
135
- */
136
- export declare function packUpdate(options: TaskOptions & {
137
- platform: "ios" | "android";
138
- out: string;
139
- }): Promise<{
140
- manifest: UpdateManifest;
141
- out: string;
142
- }>;
143
- export interface PublishResult {
144
- build: BuildResult;
145
- /** `<out>/<os>-<arch>` (desktop) or `<out>/<platform>` (a phone's web bundle): what to upload under updates.url. */
146
- dir: string;
147
- bundle: string;
148
- channel: string;
149
- files: number;
150
- /** Bytes of the files the manifest names. */
151
- size: number;
152
- }
153
- export interface PublishCheckOptions extends Pick<TaskOptions, "appDir" | "config"> {
154
- platform: Exclude<TargetPlatform, "web">;
155
- channel?: string;
156
- out?: string;
157
- /** Whether the release will carry a server; the config's `desktop.server` by default. */
158
- server?: boolean;
159
- /** A desktop release's CPU, which names its feed folder: this computer's by default. */
160
- arch?: DesktopArch;
161
- /**
162
- * keyIds of updates.publicKeys the release starts revoking, beside updates.revokedKeys and what the channel's releases
163
- * revoke. It is signed with a key listed after every key it revokes.
164
- */
165
- revoke?: string[];
166
- /** A release that revokes a key: apps compare it with their own build instead of the running release. */
167
- resetSequence?: boolean;
168
- }
169
- /**
170
- * What publishUpdate() refuses before it builds, without building (CONFIG_INVALID): no updates settings, a channel no
171
- * app could be configured for, no signing key on this machine or another app's, a desktop release whose server
172
- * presence is not the channel's previous release's, and a release whose revocations no app would take. For a
173
- * caller with a long build of its own before publishUpdate.
174
- */
175
- export declare function checkPublishUpdate(options: PublishCheckOptions): {
176
- channel: string;
177
- out: string;
178
- };
179
- /**
180
- * A signed release for the updates plugin (UP-1, UP-2): a release build, then its envelope and its files under `out`
181
- * (default <appDir>/.akan/native/updates), signed with the key updateKeygen() made.
182
- */
183
- export declare function publishUpdate(options: TaskOptions & {
184
- platform: Exclude<TargetPlatform, "web">;
185
- channel?: string;
186
- out?: string;
187
- /** The signature a macOS release carries: the installed app's own, or the updater refuses it. No dmg is made. */
188
- macos?: Pick<MacosBuild, "signing" | "notarize">;
189
- /** Authenticode for a Windows release's files. No setup program is made. */
190
- windows?: Pick<WindowsBuild, "signing">;
191
- /** A desktop release's CPU, of the same OS: an x64 release from an arm64 machine. Default this computer's. */
192
- arch?: DesktopArch;
193
- /** keyIds of updates.publicKeys the release starts revoking (PublishCheckOptions.revoke). */
194
- revoke?: string[];
195
- /** A release that revokes a key: apps compare it with their own build instead of the running release. */
196
- resetSequence?: boolean;
197
- }): Promise<PublishResult>;
198
- /**
199
- * Whether a web bundle can run in the binary a store release shipped (UP-3): `shipped` is that build's bundle.json,
200
- * `bundle` the one `packUpdate` wrote. Anything in `problems` means a new binary.
201
- */
202
- export declare function compareBundles(shipped: string, bundle: string): {
203
- compatible: boolean;
204
- problems: string[];
205
- };
206
- /**
207
- * The app's update signing key: made once (AKAN_NATIVE_UPDATE_KEY, else ~/.akan/native/keys/<app id>.update.key),
208
- * then read. `publicKey` goes into the config's `updates.publicKeys`; the key file never leaves the machine. `keyId`
209
- * is what a revocation names it by (`publishUpdate({ revoke })`, `updates.revokedKeys`).
210
- */
211
- export declare function updateKeygen(options: {
212
- config: AkanNativeConfig;
213
- }): {
214
- publicKey: string;
215
- keyId: string;
216
- keyPath: string;
217
- created: boolean;
218
- };
219
73
  /** Builds (default profile debug) and launches the app on a simulator, emulator, desktop or browser. */
220
74
  export declare function run(options: TaskOptions & {
221
75
  profile?: BuildProfile;
@@ -117,8 +117,9 @@ export interface AkanNativeConfig {
117
117
  * @akanjs/native/plugins/updates. `akan-native update keygen` makes the signing key and prints its public key;
118
118
  * `akan-native update publish <platform>` writes signed releases for `url`. `publicKeys` lists the keys an app
119
119
  * trusts, the online signing key first and offline spares after (a key revokes only keys before it); `publicKey` is
120
- * the one-key form, and a desktop app built before protocol v2 trusts the first. `report.url` is where a phone posts
121
- * what became of each release, at its next launch or return to the foreground.
120
+ * the one-key form, and a desktop app built before protocol v2 trusts the first. `report.url` is where an app posts
121
+ * what became of each release: a phone at its next launch or return to the foreground, a desktop app at launch and
122
+ * with each check.
122
123
  */
123
124
  updates?: {
124
125
  url: string;
@@ -0,0 +1,79 @@
1
+ import type { AkanNativeConfig } from "../config.ts";
2
+ import { type TargetPlatform } from "../platforms/index.ts";
3
+ import { type LogSink } from "./log.ts";
4
+ import { type BuildContext, type BuildOptions, type BuildProfile, type IosSigningResult } from "./prepare.ts";
5
+ export type AkanNativeErrorCode = "CONFIG_INVALID" | "TOOLCHAIN_MISSING" | "WEB_INPUT_INVALID" | "WEB_BUILD_FAILED" | "NATIVE_BUILD_FAILED" | "SIGNING_FAILED" | "DEVICE_FAILED" | "CANCELLED" | "INTERNAL";
6
+ export declare class AkanNativeError extends Error {
7
+ readonly code: AkanNativeErrorCode;
8
+ readonly details: {
9
+ problems?: string[];
10
+ hint?: string;
11
+ logTail?: string[];
12
+ cause?: unknown;
13
+ };
14
+ constructor(code: AkanNativeErrorCode, message: string, details?: {
15
+ problems?: string[];
16
+ hint?: string;
17
+ logTail?: string[];
18
+ cause?: unknown;
19
+ });
20
+ get problems(): string[] | undefined;
21
+ get hint(): string | undefined;
22
+ get logTail(): string[] | undefined;
23
+ }
24
+ export interface TaskOptions {
25
+ /** Base of the config's relative paths (web.dir, icon, relative plugin folders). */
26
+ appDir: string;
27
+ /** What akan-native.config.ts would export. No file is read. */
28
+ config: AkanNativeConfig;
29
+ platform: TargetPlatform;
30
+ /** Default <appDir>/.akan/native/build/<platform>. */
31
+ outDir?: string;
32
+ /** Picks .env.<mode>. Default "production" for build, "development" for run. */
33
+ mode?: string;
34
+ /** false: no .env files from appDir. Default true. */
35
+ envFiles?: boolean;
36
+ /** PUBLIC_ values above .env files and config.env. */
37
+ env?: Record<string, string>;
38
+ /** Skip config.web.build and use web.dir as it is. */
39
+ skipWebBuild?: boolean;
40
+ /** Where plugin package names resolve from. Default appDir. */
41
+ resolveFrom?: string;
42
+ /** Receives the log. Without it nothing is logged. */
43
+ log?: LogSink;
44
+ /** Kills the running tools and rejects with CANCELLED. */
45
+ signal?: AbortSignal;
46
+ }
47
+ export interface Artifact {
48
+ kind: "app" | "apk" | "aab" | "ipa" | "folder" | "web" | "installer";
49
+ path: string;
50
+ signing: "none" | "adhoc" | "debug" | "development" | "distribution";
51
+ device?: "simulator" | "device";
52
+ }
53
+ export interface BuildResult {
54
+ platform: TargetPlatform;
55
+ profile: BuildProfile;
56
+ outDir: string;
57
+ artifacts: Artifact[];
58
+ warnings: string[];
59
+ durationMs: number;
60
+ /** iPhone builds: the identity and provisioning profile found (docs/api.md §3 "Finding the signing"). */
61
+ signing?: IosSigningResult;
62
+ /**
63
+ * Android builds that contain pinned libraries (push's FCM module, iap): the license notices file
64
+ * (akan-native-licenses.json, also served in the app at /akan-native-licenses.json).
65
+ */
66
+ licenses?: string;
67
+ }
68
+ export declare function buildIn(options: TaskOptions, profile: BuildProfile, mode: string, warnings: string[], extra?: Pick<BuildOptions, "android" | "ios" | "windows" | "macos" | "linux" | "arch" | "devServer" | "startPath">): Promise<{
69
+ ctx: BuildContext;
70
+ artifact: string;
71
+ result: BuildResult;
72
+ }>;
73
+ /** Runs an API call with its own log sink (warnings collected) and abort signal; failures become AkanNativeError. */
74
+ export declare function task<T>(options: {
75
+ log?: LogSink;
76
+ signal?: AbortSignal;
77
+ }, fn: (warnings: string[]) => Promise<T>): Promise<T>;
78
+ /** An error as an AkanNativeError: its own kind decides the code, else the phase it happened in. */
79
+ export declare function toAkanNativeError(error: unknown, phase: AkanNativeErrorCode): AkanNativeError;
@@ -50,7 +50,7 @@ export interface BuildOptions {
50
50
  windows?: WindowsBuild;
51
51
  /** macOS: Developer ID signing, notarization and a dmg (lib/macossigning.ts). */
52
52
  macos?: MacosBuild;
53
- /** Linux: an AppImage beside the app folder (platforms/linux-appimage.ts). */
53
+ /** Linux: an AppImage (platforms/linux-appimage.ts) and a per-user installer (platforms/linux-install.ts). */
54
54
  linux?: LinuxBuild;
55
55
  /** Desktop builds: the CPU the app runs on, of the same OS; a macOS app is arm64 only. Default this computer's. */
56
56
  arch?: DesktopArch;
@@ -1,5 +1,6 @@
1
+ import type { DesktopOs } from "../platforms/desktop.ts";
1
2
  import type { BuildContext } from "./prepare.ts";
2
- import { type DesktopArch, type UpdateManifest } from "./updates.ts";
3
+ import { type DesktopArch, type UpdateManifest, type UpdatesConfig } from "./updates.ts";
3
4
  export type ReleasePlatform = "macos" | "windows" | "linux" | "ios" | "android";
4
5
  export interface PublishedRelease {
5
6
  /** `<out>/<os>-<arch>` for a desktop app, `<out>/<platform>` for a phone's web bundle. */
@@ -57,10 +58,21 @@ export declare function releaseRevocations(config: RevocationConfig, platform: R
57
58
  revokeKeys: string[];
58
59
  resetSequence: boolean;
59
60
  };
61
+ /** Writes the release of `artifact` (the app a release build made) and its envelope under `out`. */
62
+ export declare function publishRelease(ctx: BuildContext, platform: ReleasePlatform, artifact: string, out: string, channel: string, request?: RevocationRequest): Promise<PublishedRelease>;
60
63
  /**
61
- * Writes the release of `artifact` (the app a release build made) and its envelope under `out`. A desktop release also
62
- * gets the v1 pair when signed with the first key, the only one an app built before protocol v2 trusts: that is how
63
- * such an app takes a binary that reads envelopes.
64
+ * Signs a desktop release this folder published again, as its channel's newest: the same archive under a new sequence
65
+ * and bundle id, with no patch. Every app of the channel on another build takes it whole, one on a later build too,
66
+ * which is how a release is rolled back. The archive is the one in `out`, or fetched from updates.url when it is gone.
64
67
  */
65
- export declare function publishRelease(ctx: BuildContext, platform: ReleasePlatform, artifact: string, out: string, channel: string, request?: RevocationRequest): Promise<PublishedRelease>;
68
+ export declare function republishRelease(project: {
69
+ config: {
70
+ app: {
71
+ id: string;
72
+ };
73
+ updates?: UpdatesConfig | null;
74
+ };
75
+ }, platform: DesktopOs, bundle: string, out: string, channel: string, request?: RevocationRequest, arch?: DesktopArch): Promise<PublishedRelease & {
76
+ from: UpdateManifest;
77
+ }>;
66
78
  export {};
@@ -23,7 +23,7 @@ export interface UpdatesConfig {
23
23
  channel: string;
24
24
  /** How long a newly applied bundle has to call notifyReady() before it is rolled back, ms. Default 10000. */
25
25
  readyTimeout: number;
26
- /** Where a phone posts what became of each release (downloaded, applied, confirmed, rolled back, failed); null: no reports. */
26
+ /** Where an app posts what became of each release (downloaded, applied, confirmed, rolled back, failed); null: no reports. */
27
27
  reportUrl: string | null;
28
28
  /** Desktop: false leaves checking, downloading and applying to the app; a phone always takes a web bundle itself. */
29
29
  automatic: boolean;
@@ -140,7 +140,7 @@ export declare function signingKey(keyPath: string, publicKeys: readonly string[
140
140
  };
141
141
  /** A desktop app's base64 signature (protocol v1), with the key the app trusts: the first of updates.publicKeys. */
142
142
  export declare function signManifest(bytes: Uint8Array, keyPath: string, publicKeys: readonly string[]): string;
143
- /** A phone's envelope (protocol v2) for the manifest's exact bytes, signed with any key of `publicKeys`. */
143
+ /** The envelope (protocol v2) of the manifest's exact bytes, signed with the key at `keyPath`, any key of `publicKeys`. */
144
144
  export declare function sealManifest(bytes: Uint8Array, keyPath: string, publicKeys: readonly string[]): UpdateEnvelope;
145
145
  /**
146
146
  * The manifest bytes of an envelope, verified as a phone verifies it against `publicKeys` (minus `revoked`):
@@ -150,6 +150,33 @@ export declare function openEnvelope(text: string, publicKeys: readonly string[]
150
150
  manifest: Uint8Array;
151
151
  keyId: string;
152
152
  };
153
+ /** What whoever signs a pack decides: the rest of its manifest is the pack's `manifest.template.json`. */
154
+ export interface ManifestRelease {
155
+ channel: string;
156
+ /** Larger than every release the channel had; apps take no other. */
157
+ sequence: number;
158
+ /** A desktop app's defaults to `<version>-<sequence>`; a web bundle's is `<sequence>-<first 8 of web.hash>`. */
159
+ bundle?: string;
160
+ /** A desktop app: the deltas this release offers, instead of the template's. */
161
+ patches?: NonNullable<UpdateManifest["patches"]>;
162
+ revokeKeys?: readonly string[];
163
+ resetSequence?: boolean;
164
+ /** Unix seconds after which apps refuse the manifest. */
165
+ expiresAt?: number;
166
+ }
167
+ /**
168
+ * A pack's manifest template made the manifest of one release. Refuses what no app would take: a channel none could
169
+ * be configured for, a sequence or a bundle id that is not one, a revocation list a manifest may not hold.
170
+ */
171
+ export declare function fillManifest(template: UpdateManifest, release: ManifestRelease): UpdateManifest;
172
+ /** A manifest's exact bytes as `update publish` writes them: what the signature is over and the envelope holds. */
173
+ export declare function manifestBytes(manifest: UpdateManifest): Uint8Array;
174
+ /**
175
+ * The envelope of manifest bytes signed elsewhere (a key service, a host that signs in process): `signature` is Ed25519
176
+ * over `bytes` by the private half of `publicKey`. Verified as an app verifies it before it is returned, so another
177
+ * key's signature, or one over other bytes, is refused here and not by every installed app.
178
+ */
179
+ export declare function updateEnvelope(bytes: Uint8Array, publicKey: string, signature: string | Uint8Array): UpdateEnvelope;
153
180
  /** Verifies like the apps do: raw public key, base64 signature over the exact manifest bytes. */
154
181
  export declare function verifyManifest(bytes: Uint8Array, signature: string, publicKey: string): boolean;
155
182
  export declare const sha256: (data: Uint8Array | string) => string;
@@ -1,6 +1,14 @@
1
1
  import type { BuildContext } from "../lib/prepare.ts";
2
2
  import { type UpdateManifest } from "../lib/updates.ts";
3
3
  import { type DesktopOs } from "./desktop.ts";
4
+ type Patch = NonNullable<UpdateManifest["patches"]>[number];
5
+ /** A release's tar, named by its sha256: what a delta to the next release starts from. */
6
+ export interface AppArchive {
7
+ sha256: string;
8
+ tar: Uint8Array;
9
+ }
10
+ /** A pack's manifest, beside its `app/` or `files/`, with what the signer decides left empty. */
11
+ export declare const PACK_TEMPLATE = "manifest.template.json";
4
12
  /**
5
13
  * The release of `channel` in `dir`: the manifest of its envelope, else the v1 `<channel>.json` of a folder published
6
14
  * before protocol v2. Read unverified, as the publisher's own folder.
@@ -16,3 +24,31 @@ export declare function publishAppUpdate(ctx: BuildContext, os: DesktopOs, app:
16
24
  manifest: UpdateManifest;
17
25
  leftovers: string[];
18
26
  }>;
27
+ /**
28
+ * The archive a delta starts from, as a publish or a pack named it (`<tar sha256>.tar.gz`): a file, or a URL of the
29
+ * feed. Refused unless it unpacks to the tar its name says, since a delta from other bytes patches no installed app.
30
+ */
31
+ export declare function readAppArchive(source: string): Promise<AppArchive>;
32
+ /** Who signed an app's files: the one an installed copy's updater holds a release to (plugins/updates signer.ts). */
33
+ export interface AppSigner {
34
+ /** macOS: the certificate's team. */
35
+ teamId?: string;
36
+ /** Windows: the certificate's SHA-1, as updates.windowsSigners lists it, and its subject when that is plain ASCII. */
37
+ thumbprint?: string;
38
+ subject?: string;
39
+ }
40
+ /**
41
+ * The signer of a built app, read from the app as its updater reads it; null for an app signed ad hoc or not at all,
42
+ * which takes any release. Never the pack's failure: a tool that does not answer leaves no signer named.
43
+ */
44
+ export declare function appSigner(os: DesktopOs, app: string, fileName: string): Promise<AppSigner | null>;
45
+ /**
46
+ * An unsigned release under `out`: the archive, a delta from `previous` when one is given, and the manifest with
47
+ * `channel`, `sequence` and `bundle` left empty in `manifest.template.json`. It names updates.target, as an installed
48
+ * app refuses a release that does not; what a release revokes and when it expires are the signer's to add.
49
+ */
50
+ export declare function packAppUpdate(ctx: BuildContext, os: DesktopOs, app: string, out: string, previous?: AppArchive): Promise<{
51
+ manifest: UpdateManifest;
52
+ patch: Patch | null;
53
+ }>;
54
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { BuildContext } from "../lib/prepare.ts";
2
+ export interface LinuxInstallInput {
3
+ id: string;
4
+ name: string;
5
+ fileName: string;
6
+ version: string;
7
+ /** deepLinks.schemes: the launcher entry's x-scheme-handler MIME types. */
8
+ schemes: string[];
9
+ }
10
+ /** A POSIX sh single-quoted word: nothing in it expands, and a quote ends the word, is escaped, and starts it again. */
11
+ export declare const shellQuote: (value: string) => string;
12
+ export declare const installScript: (input: LinuxInstallInput) => string;
13
+ export declare const uninstallScript: (input: LinuxInstallInput) => string;
14
+ /** Writes the tar.gz beside the app folder and answers its path. */
15
+ export declare function buildLinuxInstaller(ctx: BuildContext, folder: string): Promise<string>;