@hot-updater/plugin-core 1.1.4 → 1.2.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.
@@ -1,9 +1,9 @@
1
- import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.mjs";
1
+ import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.mjs";
2
2
  import { AnyHotUpdaterPlugin } from "../serverPlugin/definePlugin.mjs";
3
3
  import { AggregateBatching, ConfiguredDatabase, EngineDatabase, RemoteDatabase, isRemoteDatabase } from "./databaseConfig.mjs";
4
4
  import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./utils.mjs";
5
5
  import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./databaseOperations.mjs";
6
- import { ChannelDeleteResult, ChannelInsertResult } from "./models.mjs";
6
+ import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult } from "./models.mjs";
7
7
  import "./public.mjs";
8
8
  import { Bundle as Bundle$1, Platform, Platform as Platform$1 } from "@hot-updater/protocol";
9
9
  //#region src/types/index.d.ts
@@ -72,6 +72,24 @@ interface BuildAdapter {
72
72
  } | null>;
73
73
  /** Resolves native configuration files that must affect the fingerprint. */
74
74
  getFingerprintExtraSources?: () => Promise<readonly string[]>;
75
+ /**
76
+ * What `prebuild` would write into a platform's native project, read
77
+ * without writing it, for commands that only look the project up, such
78
+ * as `native-build find`. A value it leaves out is read from the native
79
+ * project as it is.
80
+ */
81
+ getNativeProjectValues?: (args: {
82
+ platform: Platform;
83
+ }) => Promise<{
84
+ /**
85
+ * The app version the prebuild writes as the app's own: Android's
86
+ * `defaultConfig` `versionName`, which a product flavor's still
87
+ * overrides, and the iOS app's Info.plist.
88
+ */
89
+ readonly appVersion?: string;
90
+ /** The channel the native build would embed. */
91
+ readonly channel?: string;
92
+ }>;
75
93
  prebuild?: (args: {
76
94
  platform: Platform;
77
95
  }) => Promise<void>;
@@ -103,7 +121,7 @@ interface NativeBuildAndroidScheme {
103
121
  * Artifact type.
104
122
  *
105
123
  * If `true`, the generated artifact type is `.aab`.
106
- * If `flase`, the generated artifact type is `apk`.
124
+ * If `false`, the generated artifact type is `.apk`.
107
125
  *
108
126
  * @default true
109
127
  */
@@ -124,6 +142,18 @@ interface NativeBuildAndroidScheme {
124
142
  * @default same as packageName
125
143
  */
126
144
  applicationId?: string;
145
+ /**
146
+ * Signs a release variant with a keystore the CLI resolves: `keystore` is
147
+ * `secret:<name>`, the `android-keystore` the config's `secrets` adapter
148
+ * holds as `<name>`, which the `HOT_UPDATER_ANDROID_KEYSTORE_*`
149
+ * environment variables override. Debug variants keep the debug keystore
150
+ * and resolve nothing. Without it, the variant's own `signingConfig` signs.
151
+ *
152
+ * @example { keystore: "secret:release-keystore" }
153
+ */
154
+ signing?: {
155
+ keystore: `secret:${string}`;
156
+ };
127
157
  }
128
158
  type IosBuildDestination = {
129
159
  id: string;
@@ -173,7 +203,9 @@ interface NativeBuildIosScheme {
173
203
  */
174
204
  destination?: IosBuildDestination[];
175
205
  /**
176
- * Path to a plist file that specifies options for exporting the archive.
206
+ * Path to a plist file that specifies options for exporting the archive
207
+ * into an `.ipa`. A device build needs it unless `signing.ascApiKey` is
208
+ * set, which exports for App Store Connect with automatic signing.
177
209
  *
178
210
  * @example "exportOptions.plist"
179
211
  */
@@ -204,11 +236,22 @@ interface NativeBuildIosScheme {
204
236
  * Convenience shortcut option for simulator builds.
205
237
  * When true, this option should not be used together with the destination option.
206
238
  *
207
- * This option only affects build:ios, not run:ios.
208
- *
209
239
  * @default false
210
240
  */
211
241
  simulator?: boolean;
242
+ /**
243
+ * Signs a device build with automatic signing, authenticated by an App
244
+ * Store Connect API key the CLI resolves: `ascApiKey` is `secret:<name>`,
245
+ * the `asc-api-key` the config's `secrets` adapter holds as `<name>`,
246
+ * which the `HOT_UPDATER_ASC_KEY*` environment variables override.
247
+ * Simulator builds resolve nothing. Without it, the project's signing
248
+ * settings and Xcode's accounts sign.
249
+ *
250
+ * @example { ascApiKey: "secret:asc-api-key" }
251
+ */
252
+ signing?: {
253
+ ascApiKey: `secret:${string}`;
254
+ };
212
255
  }
213
256
  interface PlatformConfig {
214
257
  /**
@@ -341,14 +384,62 @@ interface BundleSigningAdapter {
341
384
  readonly signature: Uint8Array;
342
385
  }>;
343
386
  }
344
- /** Built-in local PEM signing. */
387
+ /**
388
+ * What a secrets adapter is given with each call. It carries no secret: an
389
+ * adapter reads its own credentials, such as a token or a CLI sign-in.
390
+ */
391
+ interface SecretsContext {
392
+ /** The project directory the CLI runs in. */
393
+ readonly cwd: string;
394
+ }
395
+ /**
396
+ * Where the CLI reads secrets by name: the build credentials `secret:<name>`
397
+ * references, and the deploy credentials `secretEnv([...])` names. Values
398
+ * are strings: binary is base64, and a credential with several fields is one
399
+ * JSON value per name. `localSecrets()`, an export of `hot-updater`, keeps them
400
+ * in files on this machine; a store of your own implements this.
401
+ */
402
+ interface SecretsAdapter {
403
+ readonly name: string;
404
+ /**
405
+ * Reads `names` in one call. A name the store does not hold maps to
406
+ * `undefined`; any other failure, such as a missing permission or an
407
+ * unreachable store, throws.
408
+ */
409
+ readonly get: (names: readonly string[], context: SecretsContext) => Promise<Readonly<Record<string, string | undefined>>>;
410
+ /**
411
+ * Stores `value` as `name`, replacing what it held. Absent when the store
412
+ * is read-only to Hot Updater.
413
+ */
414
+ readonly set?: (name: string, value: string, context: SecretsContext) => Promise<void>;
415
+ /** Where the user finds `name` in the store, such as a URL or a path, for messages. */
416
+ readonly describe?: (name: string) => string;
417
+ }
418
+ /**
419
+ * Built-in local PEM signing, with the RSA private key from a file or from
420
+ * the config's `secrets` adapter.
421
+ */
345
422
  type LocalSigningConfig = {
346
423
  readonly enabled: true;
347
424
  /** Path to an RSA private key in PEM format. */
348
425
  readonly privateKeyPath: string;
426
+ readonly privateKey?: never;
427
+ } | {
428
+ readonly enabled: true;
429
+ /**
430
+ * `secret:<name>`, the RSA private key in PEM format that the config's
431
+ * `secrets` adapter holds as `<name>`. The CLI reads it once per run,
432
+ * when it first signs or derives the public key, and keeps it in
433
+ * memory only.
434
+ *
435
+ * @example { enabled: true, privateKey: "secret:bundle-signing-key" }
436
+ */
437
+ readonly privateKey: `secret:${string}`;
438
+ readonly privateKeyPath?: never;
349
439
  } | {
350
440
  readonly enabled: false;
351
441
  readonly privateKeyPath?: string;
442
+ readonly privateKey?: `secret:${string}`;
352
443
  };
353
444
  /** Local config or signing adapter. Signing is disabled when omitted. */
354
445
  type SigningConfig = BundleSigningAdapter | LocalSigningConfig;
@@ -464,11 +555,21 @@ type ConfigInput = {
464
555
  * ```ts
465
556
  * signing: {
466
557
  * enabled: true,
467
- * privateKeyPath: './keys/private-key.pem',
558
+ * privateKey: "secret:bundle-signing-key",
468
559
  * }
469
560
  * ```
470
561
  */
471
562
  signing?: SigningConfig;
563
+ /**
564
+ * Where the CLI reads the secrets the config names: `secret:<name>` build
565
+ * credentials and `secretEnv([...])` deploy credentials. Builds read a
566
+ * credential this adapter does not hold from `localSecrets()`'s store,
567
+ * `~/.hot-updater/secrets/<project-key>/<name>.json`, where keys Hot Updater
568
+ * issues go when the adapter stores nothing.
569
+ *
570
+ * @default localSecrets()
571
+ */
572
+ secrets?: SecretsAdapter;
472
573
  build: (args: BuildAdapterArgs) => Promise<BuildAdapter> | BuildAdapter;
473
574
  /** Where the CLI uploads bundles: the same adapter as the server's `storage`. */
474
575
  storage: StorageAdapter;
@@ -488,8 +589,7 @@ type ConfigInput = {
488
589
  interface NativeBuildOptions {
489
590
  outputPath?: string;
490
591
  interactive: boolean;
491
- message?: string;
492
592
  scheme?: string;
493
593
  }
494
594
  //#endregion
495
- export { type AggregateBatching, ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle$1 as Bundle, type BundlePatchRow, type BundleRow, type BundleRowUpdate, BundleSigningAdapter, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, ConfigInput, type ConfiguredDatabase, type DatabaseBundleMetadata, type DatabaseJsonObject, type DatabaseJsonValue, type EngineDatabase, FingerprintExtraSources, HasMultipleCallSignatures, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type Platform$1 as Platform, PlatformConfig, Primitive, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseRow, type ReleaseRowUpdate, type RemoteDatabase, RequiredDeep, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, isRemoteDatabase, supportedIosPlatforms };
595
+ export { type AggregateBatching, ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle$1 as Bundle, type BundlePatchRow, type BundleRow, type BundleRowUpdate, BundleSigningAdapter, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, ConfigInput, type ConfiguredDatabase, type DatabaseBundleMetadata, type DatabaseJsonObject, type DatabaseJsonValue, type EngineDatabase, FingerprintExtraSources, HasMultipleCallSignatures, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, NativeBuildIosScheme, NativeBuildOptions, type NativeBuildRow, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type Platform$1 as Platform, PlatformConfig, Primitive, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseRow, type ReleaseRowUpdate, type RemoteDatabase, RequiredDeep, SecretsAdapter, SecretsContext, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, isRemoteDatabase, supportedIosPlatforms };
@@ -1,4 +1,4 @@
1
- import { ChannelRow } from "./databaseRows.cjs";
1
+ import { ChannelRow, NativeBuildRow } from "./databaseRows.cjs";
2
2
  //#region src/types/models.d.ts
3
3
  interface ChannelInsertResult {
4
4
  readonly row: ChannelRow;
@@ -10,5 +10,16 @@ type ChannelDeleteResult = {
10
10
  readonly deleted: false;
11
11
  readonly reason: "not_found" | "not_empty";
12
12
  };
13
+ /**
14
+ * What `deleteNativeBuild` did: the deleted build, whose artifact the caller
15
+ * deletes from storage, since no row names it any more.
16
+ */
17
+ type NativeBuildDeleteResult = {
18
+ readonly deleted: true;
19
+ readonly nativeBuild: NativeBuildRow;
20
+ } | {
21
+ readonly deleted: false;
22
+ readonly reason: "not_found";
23
+ };
13
24
  //#endregion
14
- export { ChannelDeleteResult, ChannelInsertResult };
25
+ export { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult };
@@ -1,4 +1,4 @@
1
- import { ChannelRow } from "./databaseRows.mjs";
1
+ import { ChannelRow, NativeBuildRow } from "./databaseRows.mjs";
2
2
  //#region src/types/models.d.ts
3
3
  interface ChannelInsertResult {
4
4
  readonly row: ChannelRow;
@@ -10,5 +10,16 @@ type ChannelDeleteResult = {
10
10
  readonly deleted: false;
11
11
  readonly reason: "not_found" | "not_empty";
12
12
  };
13
+ /**
14
+ * What `deleteNativeBuild` did: the deleted build, whose artifact the caller
15
+ * deletes from storage, since no row names it any more.
16
+ */
17
+ type NativeBuildDeleteResult = {
18
+ readonly deleted: true;
19
+ readonly nativeBuild: NativeBuildRow;
20
+ } | {
21
+ readonly deleted: false;
22
+ readonly reason: "not_found";
23
+ };
13
24
  //#endregion
14
- export { ChannelDeleteResult, ChannelInsertResult };
25
+ export { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult };
@@ -1,5 +1,5 @@
1
- import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.cjs";
1
+ import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.cjs";
2
2
  import { AggregateBatching, ConfiguredDatabase, EngineDatabase, RemoteDatabase, isRemoteDatabase } from "./databaseConfig.cjs";
3
3
  import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./databaseOperations.cjs";
4
- import { ChannelDeleteResult, ChannelInsertResult } from "./models.cjs";
5
- export { type AggregateBatching, type BundlePatchRow, type BundleRow, type BundleRowUpdate, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ConfiguredDatabase, type DatabaseBundleMetadata, type DatabaseJsonObject, type DatabaseJsonValue, type EngineDatabase, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseRow, type ReleaseRowUpdate, type RemoteDatabase, isRemoteDatabase };
4
+ import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult } from "./models.cjs";
5
+ export { type AggregateBatching, type BundlePatchRow, type BundleRow, type BundleRowUpdate, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ConfiguredDatabase, type DatabaseBundleMetadata, type DatabaseJsonObject, type DatabaseJsonValue, type EngineDatabase, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildRow, type NativeBuildSubmissionDestination, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseRow, type ReleaseRowUpdate, type RemoteDatabase, isRemoteDatabase };
@@ -1,5 +1,5 @@
1
- import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.mjs";
1
+ import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.mjs";
2
2
  import { AggregateBatching, ConfiguredDatabase, EngineDatabase, RemoteDatabase, isRemoteDatabase } from "./databaseConfig.mjs";
3
3
  import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./databaseOperations.mjs";
4
- import { ChannelDeleteResult, ChannelInsertResult } from "./models.mjs";
5
- export { type AggregateBatching, type BundlePatchRow, type BundleRow, type BundleRowUpdate, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ConfiguredDatabase, type DatabaseBundleMetadata, type DatabaseJsonObject, type DatabaseJsonValue, type EngineDatabase, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseRow, type ReleaseRowUpdate, type RemoteDatabase, isRemoteDatabase };
4
+ import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult } from "./models.mjs";
5
+ export { type AggregateBatching, type BundlePatchRow, type BundleRow, type BundleRowUpdate, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ConfiguredDatabase, type DatabaseBundleMetadata, type DatabaseJsonObject, type DatabaseJsonValue, type EngineDatabase, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildRow, type NativeBuildSubmissionDestination, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseRow, type ReleaseRowUpdate, type RemoteDatabase, isRemoteDatabase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/plugin-core",
3
- "version": "1.1.4",
3
+ "version": "1.2.0-rc.0",
4
4
  "type": "module",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "sideEffects": false,
@@ -45,14 +45,14 @@
45
45
  "es-toolkit": "^1.32.0",
46
46
  "mime": "^4.0.4",
47
47
  "verkit": "0.4.0",
48
- "@hot-updater/protocol": "1.1.4"
48
+ "@hot-updater/protocol": "1.2.0-rc.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@electric-sql/pglite": "0.4.1",
52
52
  "@types/node": "^20",
53
53
  "@typescript/native": "npm:typescript@7.0.2",
54
54
  "typescript": "npm:@typescript/typescript6@6.0.2",
55
- "@hot-updater/test-utils": "1.1.4"
55
+ "@hot-updater/test-utils": "1.2.0-rc.0"
56
56
  },
57
57
  "nx": {
58
58
  "implicitDependencies": [