@hot-updater/plugin-core 1.2.0-rc.4 → 1.2.0-rc.40
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.
- package/dist/coreApi.d.cts +157 -8
- package/dist/coreApi.d.mts +157 -8
- package/dist/engine/core/schema.cjs +167 -2
- package/dist/engine/core/schema.d.cts +115 -1
- package/dist/engine/core/schema.d.mts +115 -1
- package/dist/engine/core/schema.mjs +167 -2
- package/dist/engine/createEngine.cjs +1 -2
- package/dist/engine/createEngine.d.cts +1 -6
- package/dist/engine/createEngine.d.mts +1 -6
- package/dist/engine/createEngine.mjs +1 -2
- package/dist/engine/database/aggregateBatching.cjs +24 -116
- package/dist/engine/database/aggregateBatching.mjs +24 -116
- package/dist/engine/database/database.cjs +1 -4
- package/dist/engine/database/database.mjs +1 -4
- package/dist/engine/database/resolveSchema.cjs +6 -3
- package/dist/engine/database/resolveSchema.mjs +6 -3
- package/dist/index.cjs +1 -7
- package/dist/index.d.cts +5 -6
- package/dist/index.d.mts +5 -6
- package/dist/index.mjs +2 -3
- package/dist/serverPlugin/definitions.d.cts +4 -0
- package/dist/serverPlugin/definitions.d.mts +4 -0
- package/dist/serverPlugin/schema.d.cts +4 -0
- package/dist/serverPlugin/schema.d.mts +4 -0
- package/dist/types/databaseConfig.d.cts +8 -19
- package/dist/types/databaseConfig.d.mts +8 -19
- package/dist/types/databaseRows.d.cts +69 -2
- package/dist/types/databaseRows.d.mts +69 -2
- package/dist/types/index.cjs +3 -0
- package/dist/types/index.d.cts +118 -60
- package/dist/types/index.d.mts +118 -60
- package/dist/types/index.mjs +3 -1
- package/dist/types/models.d.cts +9 -1
- package/dist/types/models.d.mts +9 -1
- package/dist/types/public.d.cts +3 -3
- package/dist/types/public.d.mts +3 -3
- package/package.json +3 -9
- package/dist/remoteBundleSigning.cjs +0 -357
- package/dist/remoteBundleSigning.d.cts +0 -38
- package/dist/remoteBundleSigning.d.mts +0 -38
- package/dist/remoteBundleSigning.mjs +0 -352
package/dist/types/index.d.cts
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
|
-
import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.cjs";
|
|
1
|
+
import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, IosDeviceRow, IosDeviceStatus, NativeBuildArtifactKind, NativeBuildExportMethod, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.cjs";
|
|
2
2
|
import { AnyHotUpdaterPlugin } from "../serverPlugin/definePlugin.cjs";
|
|
3
3
|
import { AggregateBatching, ConfiguredDatabase, EngineDatabase, RemoteDatabase, isRemoteDatabase } from "./databaseConfig.cjs";
|
|
4
4
|
import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./utils.cjs";
|
|
5
5
|
import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./databaseOperations.cjs";
|
|
6
|
-
import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult } from "./models.cjs";
|
|
6
|
+
import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult, NativeBuildMarkResult } from "./models.cjs";
|
|
7
7
|
import "./public.cjs";
|
|
8
8
|
import { Bundle as Bundle$1, Platform, Platform as Platform$1 } from "@hot-updater/protocol";
|
|
9
9
|
//#region src/types/index.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* A value, or a function that returns it, called on first use: an
|
|
12
|
+
* adapter shared by servers and the CLI takes its credentials so, as a
|
|
13
|
+
* string from a server's own environment or as `secret("<name>")` from
|
|
14
|
+
* `hot-updater.config.ts`, which loads without reading a secret.
|
|
15
|
+
*/
|
|
16
|
+
type Lazy<T> = T | (() => T | Promise<T>);
|
|
17
|
+
/** The value of a `Lazy`, calling its function. */
|
|
18
|
+
declare const resolveLazy: <T>(value: Lazy<T>) => Promise<T>;
|
|
19
|
+
/**
|
|
20
|
+
* The brand of a `SecretRef`, `Symbol.for("@hot-updater/secret-ref")` at
|
|
21
|
+
* runtime: `hot-updater`'s `secret()` sets it, and the CLI recognizes a
|
|
22
|
+
* reference by it, so a plain string or function is none.
|
|
23
|
+
*/
|
|
24
|
+
declare const secretRefBrand: unique symbol;
|
|
25
|
+
/**
|
|
26
|
+
* `secret("<name>")` in `hot-updater.config.ts`: the secret the config's
|
|
27
|
+
* `secrets` adapter holds as `name`. Called, it reads the value, the
|
|
28
|
+
* environment first, so it is a `Lazy<string>` any adapter credential
|
|
29
|
+
* takes; the build credentials, such as `signing.keystore`, take only a
|
|
30
|
+
* reference, which the CLI resolves by `name` for its kind.
|
|
31
|
+
*/
|
|
32
|
+
type SecretRef = (() => Promise<string>) & {
|
|
33
|
+
readonly [secretRefBrand]: true;
|
|
34
|
+
/** The secret's name in the config's `secrets` adapter. */
|
|
35
|
+
readonly name: string;
|
|
36
|
+
};
|
|
10
37
|
interface BuildAdapterArgs {
|
|
11
38
|
cwd: string;
|
|
12
39
|
}
|
|
@@ -89,6 +116,11 @@ interface BuildAdapter {
|
|
|
89
116
|
readonly appVersion?: string;
|
|
90
117
|
/** The channel the native build would embed. */
|
|
91
118
|
readonly channel?: string;
|
|
119
|
+
/**
|
|
120
|
+
* The trust-anchor file the prebuild embeds as the bundle signing
|
|
121
|
+
* public key, such as the Expo config plugin's `publicKeyPath`.
|
|
122
|
+
*/
|
|
123
|
+
readonly publicKeyPath?: string;
|
|
92
124
|
}>;
|
|
93
125
|
prebuild?: (args: {
|
|
94
126
|
platform: Platform;
|
|
@@ -109,6 +141,19 @@ interface BuildAdapter {
|
|
|
109
141
|
/**
|
|
110
142
|
* Android native build gradle configuration.
|
|
111
143
|
*/
|
|
144
|
+
/** The options of a native build scheme's `sandbox`, which turn it on. */
|
|
145
|
+
interface NativeBuildSandboxOptions {
|
|
146
|
+
/**
|
|
147
|
+
* The URL scheme the sandbox build registers, which its preview links and
|
|
148
|
+
* QR codes open: lower case, a letter then up to 63 letters, digits, `+`,
|
|
149
|
+
* `.` or `-`, none the app registers itself, and not `http`, `https`,
|
|
150
|
+
* `file`, `data`, `javascript`, `true` or `false`. A build keeps the scheme it
|
|
151
|
+
* was built with, so a changed one takes effect at the next sandbox build.
|
|
152
|
+
*
|
|
153
|
+
* @default "hu-sandbox-<bundleIdentifier | packageName>"
|
|
154
|
+
*/
|
|
155
|
+
urlScheme?: string;
|
|
156
|
+
}
|
|
112
157
|
interface NativeBuildAndroidScheme {
|
|
113
158
|
/**
|
|
114
159
|
* Android application module build variant.
|
|
@@ -144,16 +189,28 @@ interface NativeBuildAndroidScheme {
|
|
|
144
189
|
applicationId?: string;
|
|
145
190
|
/**
|
|
146
191
|
* Signs a release variant with a keystore the CLI resolves: `keystore` is
|
|
147
|
-
* `secret
|
|
192
|
+
* `secret("<name>")`, the `android-keystore` the config's `secrets` adapter
|
|
148
193
|
* holds as `<name>`, which the `HOT_UPDATER_ANDROID_KEYSTORE_*`
|
|
149
194
|
* environment variables override. Debug variants keep the debug keystore
|
|
150
195
|
* and resolve nothing. Without it, the variant's own `signingConfig` signs.
|
|
151
196
|
*
|
|
152
|
-
* @example { keystore: "
|
|
197
|
+
* @example { keystore: secret("release-keystore") }
|
|
153
198
|
*/
|
|
154
199
|
signing?: {
|
|
155
|
-
keystore:
|
|
200
|
+
keystore: SecretRef;
|
|
156
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* Builds the app with the sandbox native layer, for testing OTA bundles on
|
|
204
|
+
* a device, as a separate app: the application ID gets a `.sandbox` suffix.
|
|
205
|
+
* It registers on the reserved channel `sandbox-<scheme>`, and reaches
|
|
206
|
+
* Google Play's internal testing only. No other build compiles the layer.
|
|
207
|
+
* An object turns it on with options: `urlScheme` is the URL scheme its
|
|
208
|
+
* preview links and QR codes open, `hu-sandbox-<packageName>` by default.
|
|
209
|
+
*
|
|
210
|
+
* @default false
|
|
211
|
+
* @example { urlScheme: "acme-preview" }
|
|
212
|
+
*/
|
|
213
|
+
sandbox?: boolean | NativeBuildSandboxOptions;
|
|
157
214
|
}
|
|
158
215
|
type IosBuildDestination = {
|
|
159
216
|
id: string;
|
|
@@ -241,17 +298,32 @@ interface NativeBuildIosScheme {
|
|
|
241
298
|
simulator?: boolean;
|
|
242
299
|
/**
|
|
243
300
|
* Signs a device build with automatic signing, authenticated by an App
|
|
244
|
-
* Store Connect API key the CLI resolves: `ascApiKey` is `secret
|
|
301
|
+
* Store Connect API key the CLI resolves: `ascApiKey` is `secret("<name>")`,
|
|
245
302
|
* the `asc-api-key` the config's `secrets` adapter holds as `<name>`,
|
|
246
303
|
* which the `HOT_UPDATER_ASC_KEY*` environment variables override.
|
|
247
304
|
* Simulator builds resolve nothing. Without it, the project's signing
|
|
248
305
|
* settings and Xcode's accounts sign.
|
|
249
306
|
*
|
|
250
|
-
* @example { ascApiKey: "
|
|
307
|
+
* @example { ascApiKey: secret("asc-api-key") }
|
|
251
308
|
*/
|
|
252
309
|
signing?: {
|
|
253
|
-
ascApiKey:
|
|
310
|
+
ascApiKey: SecretRef;
|
|
254
311
|
};
|
|
312
|
+
/**
|
|
313
|
+
* Builds the app with the sandbox native layer, for testing OTA bundles on
|
|
314
|
+
* a device. It has the bundle identifier its Xcode configuration builds,
|
|
315
|
+
* which `bundleIdentifier` must name: the store app's by default, which it
|
|
316
|
+
* replaces on a device, or its own from a separate configuration. It
|
|
317
|
+
* registers on the reserved channel `sandbox-<scheme>`, and its `.ipa` is for
|
|
318
|
+
* TestFlight internal testing only, never App Store review. No other build
|
|
319
|
+
* compiles the layer. An object turns it on with options: `urlScheme` is
|
|
320
|
+
* the URL scheme its preview links and QR codes open,
|
|
321
|
+
* `hu-sandbox-<bundleIdentifier>` by default.
|
|
322
|
+
*
|
|
323
|
+
* @default false
|
|
324
|
+
* @example { urlScheme: "acme-preview" }
|
|
325
|
+
*/
|
|
326
|
+
sandbox?: boolean | NativeBuildSandboxOptions;
|
|
255
327
|
}
|
|
256
328
|
interface PlatformConfig {
|
|
257
329
|
/**
|
|
@@ -362,28 +434,6 @@ interface StorageAdapter {
|
|
|
362
434
|
/** Deletes only the exact base-path-relative keys supplied by the caller. */
|
|
363
435
|
readonly deleteObjects?: (keys: readonly string[]) => Promise<void>;
|
|
364
436
|
}
|
|
365
|
-
interface BundleSigningAdapter {
|
|
366
|
-
readonly name: string;
|
|
367
|
-
/** Returns the RSA public key used by this provider in SPKI PEM format. */
|
|
368
|
-
readonly getPublicKey: (input?: {
|
|
369
|
-
readonly cwd?: string;
|
|
370
|
-
}) => Promise<{
|
|
371
|
-
readonly publicKey: string;
|
|
372
|
-
}>;
|
|
373
|
-
/**
|
|
374
|
-
* Signs `message` with RSA PKCS#1 v1.5 SHA-256.
|
|
375
|
-
*
|
|
376
|
-
* Hot Updater passes the 32 raw bytes decoded from a SHA-256 file hash.
|
|
377
|
-
* Remote signing services must treat this value as the raw message, not as
|
|
378
|
-
* an already-computed digest.
|
|
379
|
-
*/
|
|
380
|
-
readonly sign: (input: {
|
|
381
|
-
readonly message: Uint8Array;
|
|
382
|
-
readonly cwd?: string;
|
|
383
|
-
}) => Promise<{
|
|
384
|
-
readonly signature: Uint8Array;
|
|
385
|
-
}>;
|
|
386
|
-
}
|
|
387
437
|
/**
|
|
388
438
|
* What a secrets adapter is given with each call. It carries no secret: an
|
|
389
439
|
* adapter reads its own credentials, such as a token or a CLI sign-in.
|
|
@@ -393,11 +443,12 @@ interface SecretsContext {
|
|
|
393
443
|
readonly cwd: string;
|
|
394
444
|
}
|
|
395
445
|
/**
|
|
396
|
-
* Where the CLI reads secrets
|
|
397
|
-
*
|
|
446
|
+
* Where the CLI reads the secrets `secret("<name>")` names in a config: build
|
|
447
|
+
* credentials, such as a keystore, and adapter credentials. Values
|
|
398
448
|
* are strings: binary is base64, and a credential with several fields is one
|
|
399
449
|
* JSON value per name. `localSecrets()`, an export of `hot-updater`, keeps them
|
|
400
|
-
* in files on this machine
|
|
450
|
+
* in files on this machine, and `infisical()`, another, in an Infisical
|
|
451
|
+
* project; a store of your own implements this.
|
|
401
452
|
*/
|
|
402
453
|
interface SecretsAdapter {
|
|
403
454
|
readonly name: string;
|
|
@@ -408,10 +459,11 @@ interface SecretsAdapter {
|
|
|
408
459
|
*/
|
|
409
460
|
readonly get: (names: readonly string[], context: SecretsContext) => Promise<Readonly<Record<string, string | undefined>>>;
|
|
410
461
|
/**
|
|
411
|
-
* Stores `value` as `name`, replacing what it held.
|
|
412
|
-
*
|
|
462
|
+
* Stores `value` as `name`, replacing what it held. Every adapter stores:
|
|
463
|
+
* the CLI keeps the keys it issues and imports here, and nowhere else. A
|
|
464
|
+
* write the store refuses, such as with a read-only token, throws.
|
|
413
465
|
*/
|
|
414
|
-
readonly set
|
|
466
|
+
readonly set: (name: string, value: string, context: SecretsContext) => Promise<void>;
|
|
415
467
|
/** Where the user finds `name` in the store, such as a URL or a path, for messages. */
|
|
416
468
|
readonly describe?: (name: string) => string;
|
|
417
469
|
}
|
|
@@ -427,22 +479,27 @@ type LocalSigningConfig = {
|
|
|
427
479
|
} | {
|
|
428
480
|
readonly enabled: true;
|
|
429
481
|
/**
|
|
430
|
-
* `secret
|
|
431
|
-
* `secrets` adapter holds as `<name>`. The CLI reads it once
|
|
432
|
-
* when it first signs or derives the public key, and keeps it
|
|
433
|
-
* memory only.
|
|
482
|
+
* `secret("<name>")`, the RSA private key in PEM format that the
|
|
483
|
+
* config's `secrets` adapter holds as `<name>`. The CLI reads it once
|
|
484
|
+
* per run, when it first signs or derives the public key, and keeps it
|
|
485
|
+
* in memory only.
|
|
434
486
|
*
|
|
435
|
-
* @example { enabled: true, privateKey: "
|
|
487
|
+
* @example { enabled: true, privateKey: secret("bundle-signing-key") }
|
|
436
488
|
*/
|
|
437
|
-
readonly privateKey:
|
|
489
|
+
readonly privateKey: SecretRef;
|
|
438
490
|
readonly privateKeyPath?: never;
|
|
439
491
|
} | {
|
|
440
492
|
readonly enabled: false;
|
|
441
493
|
readonly privateKeyPath?: string;
|
|
442
|
-
readonly privateKey?:
|
|
494
|
+
readonly privateKey?: SecretRef;
|
|
443
495
|
};
|
|
444
|
-
/**
|
|
445
|
-
|
|
496
|
+
/**
|
|
497
|
+
* Bundle signing with an RSA private key in PEM. `secret("<name>")` is the
|
|
498
|
+
* shorthand of `{ enabled: true, privateKey: secret("<name>") }`. Without
|
|
499
|
+
* `signing`, bundles are unsigned and deploy warns; `enabled: false` turns
|
|
500
|
+
* signing off without the warning.
|
|
501
|
+
*/
|
|
502
|
+
type SigningConfig = SecretRef | LocalSigningConfig;
|
|
446
503
|
/**
|
|
447
504
|
* Extra fingerprint sources.
|
|
448
505
|
*
|
|
@@ -470,6 +527,9 @@ type ConfigInput = {
|
|
|
470
527
|
* If `appVersion`, the bundle will be updated if the target app version is valid.
|
|
471
528
|
* @docs https://hot-updater.dev/docs/guides/update-strategies/app-version
|
|
472
529
|
*
|
|
530
|
+
* `hot-updater init` writes `fingerprint` for a new project; a config that
|
|
531
|
+
* sets none keeps `appVersion`, so upgrading never retargets shipped apps.
|
|
532
|
+
*
|
|
473
533
|
* @default "appVersion"
|
|
474
534
|
*/
|
|
475
535
|
updateStrategy: "fingerprint" | "appVersion";
|
|
@@ -503,7 +563,8 @@ type ConfigInput = {
|
|
|
503
563
|
*/
|
|
504
564
|
nativeVersion?: string | number;
|
|
505
565
|
/**
|
|
506
|
-
*
|
|
566
|
+
* Passed to the build adapter's fingerprint, which may use it for its own
|
|
567
|
+
* diagnostics. fingerprint.json never records them.
|
|
507
568
|
*/
|
|
508
569
|
debug?: boolean;
|
|
509
570
|
};
|
|
@@ -546,26 +607,23 @@ type ConfigInput = {
|
|
|
546
607
|
platform?: PlatformConfig;
|
|
547
608
|
nativeBuild?: NativeBuildArgs;
|
|
548
609
|
/**
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
610
|
+
* Signs each bundle with RSA-SHA256, which the app verifies with the
|
|
611
|
+
* public key it embeds. `secret("bundle-signing-key")` reads the RSA
|
|
612
|
+
* private key in PEM from the config's `secrets` adapter; the object
|
|
613
|
+
* forms take it from a secret (`privateKey`) or a file
|
|
614
|
+
* (`privateKeyPath`). Without `signing`, bundles are unsigned and deploy
|
|
615
|
+
* warns; `{ enabled: false }` turns signing off without the warning.
|
|
553
616
|
*
|
|
554
617
|
* @example
|
|
555
618
|
* ```ts
|
|
556
|
-
* signing:
|
|
557
|
-
* enabled: true,
|
|
558
|
-
* privateKey: "secret:bundle-signing-key",
|
|
559
|
-
* }
|
|
619
|
+
* signing: secret("bundle-signing-key"),
|
|
560
620
|
* ```
|
|
561
621
|
*/
|
|
562
622
|
signing?: SigningConfig;
|
|
563
623
|
/**
|
|
564
|
-
* Where the CLI reads the secrets the config names
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
* `~/.hot-updater/secrets/<project-key>/<name>.json`, where keys Hot Updater
|
|
568
|
-
* issues go when the adapter stores nothing.
|
|
624
|
+
* Where the CLI reads the secrets the config names with `secret("<name>")`,
|
|
625
|
+
* after the environment, and stores the keys it issues. It is the only
|
|
626
|
+
* store: nothing is kept on this machine under it.
|
|
569
627
|
*
|
|
570
628
|
* @default localSecrets()
|
|
571
629
|
*/
|
|
@@ -592,4 +650,4 @@ interface NativeBuildOptions {
|
|
|
592
650
|
scheme?: string;
|
|
593
651
|
}
|
|
594
652
|
//#endregion
|
|
595
|
-
export { type AggregateBatching, ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle$1 as Bundle, type BundlePatchRow, type BundleRow, type BundleRowUpdate,
|
|
653
|
+
export { type AggregateBatching, ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle$1 as Bundle, type BundlePatchRow, type BundleRow, type BundleRowUpdate, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, ConfigInput, type ConfiguredDatabase, type DatabaseBundleMetadata, type DatabaseJsonObject, type DatabaseJsonValue, type EngineDatabase, FingerprintExtraSources, HasMultipleCallSignatures, IosBuildDestination, type IosDeviceRow, type IosDeviceStatus, Lazy, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildExportMethod, NativeBuildIosScheme, type NativeBuildMarkResult, NativeBuildOptions, type NativeBuildRow, NativeBuildSandboxOptions, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type Platform$1 as Platform, PlatformConfig, Primitive, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseRow, type ReleaseRowUpdate, type RemoteDatabase, RequiredDeep, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, isRemoteDatabase, resolveLazy, supportedIosPlatforms };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
|
-
import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.mjs";
|
|
1
|
+
import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, IosDeviceRow, IosDeviceStatus, NativeBuildArtifactKind, NativeBuildExportMethod, 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, NativeBuildDeleteResult } from "./models.mjs";
|
|
6
|
+
import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult, NativeBuildMarkResult } 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
|
|
10
|
+
/**
|
|
11
|
+
* A value, or a function that returns it, called on first use: an
|
|
12
|
+
* adapter shared by servers and the CLI takes its credentials so, as a
|
|
13
|
+
* string from a server's own environment or as `secret("<name>")` from
|
|
14
|
+
* `hot-updater.config.ts`, which loads without reading a secret.
|
|
15
|
+
*/
|
|
16
|
+
type Lazy<T> = T | (() => T | Promise<T>);
|
|
17
|
+
/** The value of a `Lazy`, calling its function. */
|
|
18
|
+
declare const resolveLazy: <T>(value: Lazy<T>) => Promise<T>;
|
|
19
|
+
/**
|
|
20
|
+
* The brand of a `SecretRef`, `Symbol.for("@hot-updater/secret-ref")` at
|
|
21
|
+
* runtime: `hot-updater`'s `secret()` sets it, and the CLI recognizes a
|
|
22
|
+
* reference by it, so a plain string or function is none.
|
|
23
|
+
*/
|
|
24
|
+
declare const secretRefBrand: unique symbol;
|
|
25
|
+
/**
|
|
26
|
+
* `secret("<name>")` in `hot-updater.config.ts`: the secret the config's
|
|
27
|
+
* `secrets` adapter holds as `name`. Called, it reads the value, the
|
|
28
|
+
* environment first, so it is a `Lazy<string>` any adapter credential
|
|
29
|
+
* takes; the build credentials, such as `signing.keystore`, take only a
|
|
30
|
+
* reference, which the CLI resolves by `name` for its kind.
|
|
31
|
+
*/
|
|
32
|
+
type SecretRef = (() => Promise<string>) & {
|
|
33
|
+
readonly [secretRefBrand]: true;
|
|
34
|
+
/** The secret's name in the config's `secrets` adapter. */
|
|
35
|
+
readonly name: string;
|
|
36
|
+
};
|
|
10
37
|
interface BuildAdapterArgs {
|
|
11
38
|
cwd: string;
|
|
12
39
|
}
|
|
@@ -89,6 +116,11 @@ interface BuildAdapter {
|
|
|
89
116
|
readonly appVersion?: string;
|
|
90
117
|
/** The channel the native build would embed. */
|
|
91
118
|
readonly channel?: string;
|
|
119
|
+
/**
|
|
120
|
+
* The trust-anchor file the prebuild embeds as the bundle signing
|
|
121
|
+
* public key, such as the Expo config plugin's `publicKeyPath`.
|
|
122
|
+
*/
|
|
123
|
+
readonly publicKeyPath?: string;
|
|
92
124
|
}>;
|
|
93
125
|
prebuild?: (args: {
|
|
94
126
|
platform: Platform;
|
|
@@ -109,6 +141,19 @@ interface BuildAdapter {
|
|
|
109
141
|
/**
|
|
110
142
|
* Android native build gradle configuration.
|
|
111
143
|
*/
|
|
144
|
+
/** The options of a native build scheme's `sandbox`, which turn it on. */
|
|
145
|
+
interface NativeBuildSandboxOptions {
|
|
146
|
+
/**
|
|
147
|
+
* The URL scheme the sandbox build registers, which its preview links and
|
|
148
|
+
* QR codes open: lower case, a letter then up to 63 letters, digits, `+`,
|
|
149
|
+
* `.` or `-`, none the app registers itself, and not `http`, `https`,
|
|
150
|
+
* `file`, `data`, `javascript`, `true` or `false`. A build keeps the scheme it
|
|
151
|
+
* was built with, so a changed one takes effect at the next sandbox build.
|
|
152
|
+
*
|
|
153
|
+
* @default "hu-sandbox-<bundleIdentifier | packageName>"
|
|
154
|
+
*/
|
|
155
|
+
urlScheme?: string;
|
|
156
|
+
}
|
|
112
157
|
interface NativeBuildAndroidScheme {
|
|
113
158
|
/**
|
|
114
159
|
* Android application module build variant.
|
|
@@ -144,16 +189,28 @@ interface NativeBuildAndroidScheme {
|
|
|
144
189
|
applicationId?: string;
|
|
145
190
|
/**
|
|
146
191
|
* Signs a release variant with a keystore the CLI resolves: `keystore` is
|
|
147
|
-
* `secret
|
|
192
|
+
* `secret("<name>")`, the `android-keystore` the config's `secrets` adapter
|
|
148
193
|
* holds as `<name>`, which the `HOT_UPDATER_ANDROID_KEYSTORE_*`
|
|
149
194
|
* environment variables override. Debug variants keep the debug keystore
|
|
150
195
|
* and resolve nothing. Without it, the variant's own `signingConfig` signs.
|
|
151
196
|
*
|
|
152
|
-
* @example { keystore: "
|
|
197
|
+
* @example { keystore: secret("release-keystore") }
|
|
153
198
|
*/
|
|
154
199
|
signing?: {
|
|
155
|
-
keystore:
|
|
200
|
+
keystore: SecretRef;
|
|
156
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* Builds the app with the sandbox native layer, for testing OTA bundles on
|
|
204
|
+
* a device, as a separate app: the application ID gets a `.sandbox` suffix.
|
|
205
|
+
* It registers on the reserved channel `sandbox-<scheme>`, and reaches
|
|
206
|
+
* Google Play's internal testing only. No other build compiles the layer.
|
|
207
|
+
* An object turns it on with options: `urlScheme` is the URL scheme its
|
|
208
|
+
* preview links and QR codes open, `hu-sandbox-<packageName>` by default.
|
|
209
|
+
*
|
|
210
|
+
* @default false
|
|
211
|
+
* @example { urlScheme: "acme-preview" }
|
|
212
|
+
*/
|
|
213
|
+
sandbox?: boolean | NativeBuildSandboxOptions;
|
|
157
214
|
}
|
|
158
215
|
type IosBuildDestination = {
|
|
159
216
|
id: string;
|
|
@@ -241,17 +298,32 @@ interface NativeBuildIosScheme {
|
|
|
241
298
|
simulator?: boolean;
|
|
242
299
|
/**
|
|
243
300
|
* Signs a device build with automatic signing, authenticated by an App
|
|
244
|
-
* Store Connect API key the CLI resolves: `ascApiKey` is `secret
|
|
301
|
+
* Store Connect API key the CLI resolves: `ascApiKey` is `secret("<name>")`,
|
|
245
302
|
* the `asc-api-key` the config's `secrets` adapter holds as `<name>`,
|
|
246
303
|
* which the `HOT_UPDATER_ASC_KEY*` environment variables override.
|
|
247
304
|
* Simulator builds resolve nothing. Without it, the project's signing
|
|
248
305
|
* settings and Xcode's accounts sign.
|
|
249
306
|
*
|
|
250
|
-
* @example { ascApiKey: "
|
|
307
|
+
* @example { ascApiKey: secret("asc-api-key") }
|
|
251
308
|
*/
|
|
252
309
|
signing?: {
|
|
253
|
-
ascApiKey:
|
|
310
|
+
ascApiKey: SecretRef;
|
|
254
311
|
};
|
|
312
|
+
/**
|
|
313
|
+
* Builds the app with the sandbox native layer, for testing OTA bundles on
|
|
314
|
+
* a device. It has the bundle identifier its Xcode configuration builds,
|
|
315
|
+
* which `bundleIdentifier` must name: the store app's by default, which it
|
|
316
|
+
* replaces on a device, or its own from a separate configuration. It
|
|
317
|
+
* registers on the reserved channel `sandbox-<scheme>`, and its `.ipa` is for
|
|
318
|
+
* TestFlight internal testing only, never App Store review. No other build
|
|
319
|
+
* compiles the layer. An object turns it on with options: `urlScheme` is
|
|
320
|
+
* the URL scheme its preview links and QR codes open,
|
|
321
|
+
* `hu-sandbox-<bundleIdentifier>` by default.
|
|
322
|
+
*
|
|
323
|
+
* @default false
|
|
324
|
+
* @example { urlScheme: "acme-preview" }
|
|
325
|
+
*/
|
|
326
|
+
sandbox?: boolean | NativeBuildSandboxOptions;
|
|
255
327
|
}
|
|
256
328
|
interface PlatformConfig {
|
|
257
329
|
/**
|
|
@@ -362,28 +434,6 @@ interface StorageAdapter {
|
|
|
362
434
|
/** Deletes only the exact base-path-relative keys supplied by the caller. */
|
|
363
435
|
readonly deleteObjects?: (keys: readonly string[]) => Promise<void>;
|
|
364
436
|
}
|
|
365
|
-
interface BundleSigningAdapter {
|
|
366
|
-
readonly name: string;
|
|
367
|
-
/** Returns the RSA public key used by this provider in SPKI PEM format. */
|
|
368
|
-
readonly getPublicKey: (input?: {
|
|
369
|
-
readonly cwd?: string;
|
|
370
|
-
}) => Promise<{
|
|
371
|
-
readonly publicKey: string;
|
|
372
|
-
}>;
|
|
373
|
-
/**
|
|
374
|
-
* Signs `message` with RSA PKCS#1 v1.5 SHA-256.
|
|
375
|
-
*
|
|
376
|
-
* Hot Updater passes the 32 raw bytes decoded from a SHA-256 file hash.
|
|
377
|
-
* Remote signing services must treat this value as the raw message, not as
|
|
378
|
-
* an already-computed digest.
|
|
379
|
-
*/
|
|
380
|
-
readonly sign: (input: {
|
|
381
|
-
readonly message: Uint8Array;
|
|
382
|
-
readonly cwd?: string;
|
|
383
|
-
}) => Promise<{
|
|
384
|
-
readonly signature: Uint8Array;
|
|
385
|
-
}>;
|
|
386
|
-
}
|
|
387
437
|
/**
|
|
388
438
|
* What a secrets adapter is given with each call. It carries no secret: an
|
|
389
439
|
* adapter reads its own credentials, such as a token or a CLI sign-in.
|
|
@@ -393,11 +443,12 @@ interface SecretsContext {
|
|
|
393
443
|
readonly cwd: string;
|
|
394
444
|
}
|
|
395
445
|
/**
|
|
396
|
-
* Where the CLI reads secrets
|
|
397
|
-
*
|
|
446
|
+
* Where the CLI reads the secrets `secret("<name>")` names in a config: build
|
|
447
|
+
* credentials, such as a keystore, and adapter credentials. Values
|
|
398
448
|
* are strings: binary is base64, and a credential with several fields is one
|
|
399
449
|
* JSON value per name. `localSecrets()`, an export of `hot-updater`, keeps them
|
|
400
|
-
* in files on this machine
|
|
450
|
+
* in files on this machine, and `infisical()`, another, in an Infisical
|
|
451
|
+
* project; a store of your own implements this.
|
|
401
452
|
*/
|
|
402
453
|
interface SecretsAdapter {
|
|
403
454
|
readonly name: string;
|
|
@@ -408,10 +459,11 @@ interface SecretsAdapter {
|
|
|
408
459
|
*/
|
|
409
460
|
readonly get: (names: readonly string[], context: SecretsContext) => Promise<Readonly<Record<string, string | undefined>>>;
|
|
410
461
|
/**
|
|
411
|
-
* Stores `value` as `name`, replacing what it held.
|
|
412
|
-
*
|
|
462
|
+
* Stores `value` as `name`, replacing what it held. Every adapter stores:
|
|
463
|
+
* the CLI keeps the keys it issues and imports here, and nowhere else. A
|
|
464
|
+
* write the store refuses, such as with a read-only token, throws.
|
|
413
465
|
*/
|
|
414
|
-
readonly set
|
|
466
|
+
readonly set: (name: string, value: string, context: SecretsContext) => Promise<void>;
|
|
415
467
|
/** Where the user finds `name` in the store, such as a URL or a path, for messages. */
|
|
416
468
|
readonly describe?: (name: string) => string;
|
|
417
469
|
}
|
|
@@ -427,22 +479,27 @@ type LocalSigningConfig = {
|
|
|
427
479
|
} | {
|
|
428
480
|
readonly enabled: true;
|
|
429
481
|
/**
|
|
430
|
-
* `secret
|
|
431
|
-
* `secrets` adapter holds as `<name>`. The CLI reads it once
|
|
432
|
-
* when it first signs or derives the public key, and keeps it
|
|
433
|
-
* memory only.
|
|
482
|
+
* `secret("<name>")`, the RSA private key in PEM format that the
|
|
483
|
+
* config's `secrets` adapter holds as `<name>`. The CLI reads it once
|
|
484
|
+
* per run, when it first signs or derives the public key, and keeps it
|
|
485
|
+
* in memory only.
|
|
434
486
|
*
|
|
435
|
-
* @example { enabled: true, privateKey: "
|
|
487
|
+
* @example { enabled: true, privateKey: secret("bundle-signing-key") }
|
|
436
488
|
*/
|
|
437
|
-
readonly privateKey:
|
|
489
|
+
readonly privateKey: SecretRef;
|
|
438
490
|
readonly privateKeyPath?: never;
|
|
439
491
|
} | {
|
|
440
492
|
readonly enabled: false;
|
|
441
493
|
readonly privateKeyPath?: string;
|
|
442
|
-
readonly privateKey?:
|
|
494
|
+
readonly privateKey?: SecretRef;
|
|
443
495
|
};
|
|
444
|
-
/**
|
|
445
|
-
|
|
496
|
+
/**
|
|
497
|
+
* Bundle signing with an RSA private key in PEM. `secret("<name>")` is the
|
|
498
|
+
* shorthand of `{ enabled: true, privateKey: secret("<name>") }`. Without
|
|
499
|
+
* `signing`, bundles are unsigned and deploy warns; `enabled: false` turns
|
|
500
|
+
* signing off without the warning.
|
|
501
|
+
*/
|
|
502
|
+
type SigningConfig = SecretRef | LocalSigningConfig;
|
|
446
503
|
/**
|
|
447
504
|
* Extra fingerprint sources.
|
|
448
505
|
*
|
|
@@ -470,6 +527,9 @@ type ConfigInput = {
|
|
|
470
527
|
* If `appVersion`, the bundle will be updated if the target app version is valid.
|
|
471
528
|
* @docs https://hot-updater.dev/docs/guides/update-strategies/app-version
|
|
472
529
|
*
|
|
530
|
+
* `hot-updater init` writes `fingerprint` for a new project; a config that
|
|
531
|
+
* sets none keeps `appVersion`, so upgrading never retargets shipped apps.
|
|
532
|
+
*
|
|
473
533
|
* @default "appVersion"
|
|
474
534
|
*/
|
|
475
535
|
updateStrategy: "fingerprint" | "appVersion";
|
|
@@ -503,7 +563,8 @@ type ConfigInput = {
|
|
|
503
563
|
*/
|
|
504
564
|
nativeVersion?: string | number;
|
|
505
565
|
/**
|
|
506
|
-
*
|
|
566
|
+
* Passed to the build adapter's fingerprint, which may use it for its own
|
|
567
|
+
* diagnostics. fingerprint.json never records them.
|
|
507
568
|
*/
|
|
508
569
|
debug?: boolean;
|
|
509
570
|
};
|
|
@@ -546,26 +607,23 @@ type ConfigInput = {
|
|
|
546
607
|
platform?: PlatformConfig;
|
|
547
608
|
nativeBuild?: NativeBuildArgs;
|
|
548
609
|
/**
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
610
|
+
* Signs each bundle with RSA-SHA256, which the app verifies with the
|
|
611
|
+
* public key it embeds. `secret("bundle-signing-key")` reads the RSA
|
|
612
|
+
* private key in PEM from the config's `secrets` adapter; the object
|
|
613
|
+
* forms take it from a secret (`privateKey`) or a file
|
|
614
|
+
* (`privateKeyPath`). Without `signing`, bundles are unsigned and deploy
|
|
615
|
+
* warns; `{ enabled: false }` turns signing off without the warning.
|
|
553
616
|
*
|
|
554
617
|
* @example
|
|
555
618
|
* ```ts
|
|
556
|
-
* signing:
|
|
557
|
-
* enabled: true,
|
|
558
|
-
* privateKey: "secret:bundle-signing-key",
|
|
559
|
-
* }
|
|
619
|
+
* signing: secret("bundle-signing-key"),
|
|
560
620
|
* ```
|
|
561
621
|
*/
|
|
562
622
|
signing?: SigningConfig;
|
|
563
623
|
/**
|
|
564
|
-
* Where the CLI reads the secrets the config names
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
* `~/.hot-updater/secrets/<project-key>/<name>.json`, where keys Hot Updater
|
|
568
|
-
* issues go when the adapter stores nothing.
|
|
624
|
+
* Where the CLI reads the secrets the config names with `secret("<name>")`,
|
|
625
|
+
* after the environment, and stores the keys it issues. It is the only
|
|
626
|
+
* store: nothing is kept on this machine under it.
|
|
569
627
|
*
|
|
570
628
|
* @default localSecrets()
|
|
571
629
|
*/
|
|
@@ -592,4 +650,4 @@ interface NativeBuildOptions {
|
|
|
592
650
|
scheme?: string;
|
|
593
651
|
}
|
|
594
652
|
//#endregion
|
|
595
|
-
export { type AggregateBatching, ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle$1 as Bundle, type BundlePatchRow, type BundleRow, type BundleRowUpdate,
|
|
653
|
+
export { type AggregateBatching, ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle$1 as Bundle, type BundlePatchRow, type BundleRow, type BundleRowUpdate, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, ConfigInput, type ConfiguredDatabase, type DatabaseBundleMetadata, type DatabaseJsonObject, type DatabaseJsonValue, type EngineDatabase, FingerprintExtraSources, HasMultipleCallSignatures, IosBuildDestination, type IosDeviceRow, type IosDeviceStatus, Lazy, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildExportMethod, NativeBuildIosScheme, type NativeBuildMarkResult, NativeBuildOptions, type NativeBuildRow, NativeBuildSandboxOptions, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type Platform$1 as Platform, PlatformConfig, Primitive, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseRow, type ReleaseRowUpdate, type RemoteDatabase, RequiredDeep, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, isRemoteDatabase, resolveLazy, supportedIosPlatforms };
|
package/dist/types/index.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { isRemoteDatabase } from "./databaseConfig.mjs";
|
|
2
2
|
//#region src/types/index.ts
|
|
3
|
+
/** The value of a `Lazy`, calling its function. */
|
|
4
|
+
const resolveLazy = async (value) => typeof value === "function" ? await value() : value;
|
|
3
5
|
/**
|
|
4
6
|
* Supported Apple platforms for building and deployment
|
|
5
7
|
*/
|
|
6
8
|
const supportedIosPlatforms = { ios: "ios" };
|
|
7
9
|
//#endregion
|
|
8
|
-
export { isRemoteDatabase, supportedIosPlatforms };
|
|
10
|
+
export { isRemoteDatabase, resolveLazy, supportedIosPlatforms };
|
package/dist/types/models.d.cts
CHANGED
|
@@ -21,5 +21,13 @@ type NativeBuildDeleteResult = {
|
|
|
21
21
|
readonly deleted: false;
|
|
22
22
|
readonly reason: "not_found";
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* A store build mark's result: the build, and the build whose mark it replaced,
|
|
26
|
+
* or null when it replaced none.
|
|
27
|
+
*/
|
|
28
|
+
interface NativeBuildMarkResult {
|
|
29
|
+
readonly nativeBuild: NativeBuildRow;
|
|
30
|
+
readonly previous: NativeBuildRow | null;
|
|
31
|
+
}
|
|
24
32
|
//#endregion
|
|
25
|
-
export { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult };
|
|
33
|
+
export { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult, NativeBuildMarkResult };
|
package/dist/types/models.d.mts
CHANGED
|
@@ -21,5 +21,13 @@ type NativeBuildDeleteResult = {
|
|
|
21
21
|
readonly deleted: false;
|
|
22
22
|
readonly reason: "not_found";
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* A store build mark's result: the build, and the build whose mark it replaced,
|
|
26
|
+
* or null when it replaced none.
|
|
27
|
+
*/
|
|
28
|
+
interface NativeBuildMarkResult {
|
|
29
|
+
readonly nativeBuild: NativeBuildRow;
|
|
30
|
+
readonly previous: NativeBuildRow | null;
|
|
31
|
+
}
|
|
24
32
|
//#endregion
|
|
25
|
-
export { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult };
|
|
33
|
+
export { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult, NativeBuildMarkResult };
|