@hot-updater/plugin-core 1.1.4 → 1.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/coreApi.d.cts +96 -5
- package/dist/coreApi.d.mts +96 -5
- package/dist/engine/core/schema.cjs +365 -235
- package/dist/engine/core/schema.d.cts +105 -0
- package/dist/engine/core/schema.d.mts +105 -0
- package/dist/engine/core/schema.mjs +365 -235
- package/dist/engine/createEngine.cjs +2 -2
- package/dist/engine/createEngine.mjs +2 -2
- package/dist/engine/database/fence.cjs +32 -6
- package/dist/engine/database/fence.mjs +32 -6
- package/dist/engine/db/engineMigrator.cjs +2 -2
- package/dist/engine/db/engineMigrator.mjs +2 -2
- package/dist/engine/db/engineSqlMigrator.cjs +2 -2
- package/dist/engine/db/engineSqlMigrator.mjs +2 -2
- package/dist/engine/db/settingsMigrator.cjs +2 -2
- package/dist/engine/db/settingsMigrator.mjs +2 -2
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/remoteBundleSigning.cjs +87 -24
- package/dist/remoteBundleSigning.d.cts +10 -2
- package/dist/remoteBundleSigning.d.mts +10 -2
- package/dist/remoteBundleSigning.mjs +87 -24
- package/dist/types/databaseRows.d.cts +41 -1
- package/dist/types/databaseRows.d.mts +41 -1
- package/dist/types/index.d.cts +110 -10
- package/dist/types/index.d.mts +110 -10
- package/dist/types/models.d.cts +13 -2
- package/dist/types/models.d.mts +13 -2
- package/dist/types/public.d.cts +3 -3
- package/dist/types/public.d.mts +3 -3
- package/package.json +3 -3
|
@@ -17,10 +17,18 @@ interface RemoteSigningOptions {
|
|
|
17
17
|
interface BundleSigningHandlerOptions {
|
|
18
18
|
/** Exact request pathname. Defaults to the root managed signing path. */
|
|
19
19
|
readonly endpointPath?: string;
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The SPKI public key in PEM, or a function that returns it, called only
|
|
22
|
+
* once the token is accepted, such as for a key chosen by the token.
|
|
23
|
+
*/
|
|
24
|
+
readonly publicKey: string | (() => string | Promise<string>);
|
|
21
25
|
readonly request: Request;
|
|
22
26
|
readonly sign: (message: Uint8Array) => Uint8Array | Promise<Uint8Array>;
|
|
23
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The dedicated signing token, or a function that accepts or refuses the
|
|
29
|
+
* token a request presents, such as one that looks it up in a store.
|
|
30
|
+
*/
|
|
31
|
+
readonly token: string | ((presented: string) => boolean | Promise<boolean>);
|
|
24
32
|
}
|
|
25
33
|
/** Signs through a server implementing the Hot Updater signing protocol. */
|
|
26
34
|
declare const remoteSigning: ({ endpoint, fetch: fetchImplementation, signingToken }: RemoteSigningOptions) => BundleSigningAdapter;
|
|
@@ -12,6 +12,23 @@ const REQUEST_TIMEOUT_MS = 3e4;
|
|
|
12
12
|
const JSON_CONTENT_TYPE_PATTERN = /^application\/json(?:\s*;|$)/iu;
|
|
13
13
|
const BASE64_PATTERN = /^(?:[A-Za-z\d+/]{4})*(?:[A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/u;
|
|
14
14
|
const PUBLIC_KEY_PATTERN = /^-----BEGIN PUBLIC KEY-----\s+([A-Za-z\d+/=\s]+)\s+-----END PUBLIC KEY-----$/u;
|
|
15
|
+
/**
|
|
16
|
+
* The name of the errors `remoteSigning` throws with a reason it wrote itself,
|
|
17
|
+
* which never holds the token or what an upstream library threw. The CLI
|
|
18
|
+
* shows these, and redacts any other signing adapter error, by this name.
|
|
19
|
+
*/
|
|
20
|
+
const REMOTE_SIGNING_ERROR_NAME = "HotUpdaterRemoteSigningError";
|
|
21
|
+
const ERROR_RESPONSE_BODY_LIMIT = 4096;
|
|
22
|
+
const ERROR_MESSAGE_LENGTH_LIMIT = 300;
|
|
23
|
+
const MISSING_TOKEN_MESSAGE = "remoteSigning requires signingToken or HOT_UPDATER_SIGNING_TOKEN.";
|
|
24
|
+
/** A failure whose reason is safe to show: it names no secret. */
|
|
25
|
+
var RemoteSigningFailure = class extends Error {};
|
|
26
|
+
const remoteSigningError = (summary, error) => {
|
|
27
|
+
if (!(error instanceof RemoteSigningFailure)) return new Error(summary);
|
|
28
|
+
const named = /* @__PURE__ */ new Error(`${summary} ${error.message}`);
|
|
29
|
+
named.name = REMOTE_SIGNING_ERROR_NAME;
|
|
30
|
+
return named;
|
|
31
|
+
};
|
|
15
32
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16
33
|
const hasExactKeys = (value, expected) => {
|
|
17
34
|
const actual = Object.keys(value).sort();
|
|
@@ -69,21 +86,26 @@ const assertSafePath = (path) => {
|
|
|
69
86
|
if (decoded === "." || decoded === ".." || decoded.includes("/") || decoded.includes("\\") || decoded.includes("\0")) throw new Error("invalid path");
|
|
70
87
|
}
|
|
71
88
|
};
|
|
89
|
+
const invalidEndpoint = () => {
|
|
90
|
+
const error = /* @__PURE__ */ new Error("Remote bundle signing requires a valid endpoint.");
|
|
91
|
+
error.name = REMOTE_SIGNING_ERROR_NAME;
|
|
92
|
+
return error;
|
|
93
|
+
};
|
|
72
94
|
const normalizeEndpoint = (endpoint) => {
|
|
73
95
|
let url;
|
|
74
96
|
try {
|
|
75
97
|
url = new URL(endpoint);
|
|
76
98
|
} catch {
|
|
77
|
-
throw
|
|
99
|
+
throw invalidEndpoint();
|
|
78
100
|
}
|
|
79
101
|
const rawPath = /^https?:\/\/[^/?#]*(\/[^?#]*)?/iu.exec(endpoint)?.[1] ?? "/";
|
|
80
102
|
try {
|
|
81
103
|
assertSafePath(rawPath);
|
|
82
104
|
} catch {
|
|
83
|
-
throw
|
|
105
|
+
throw invalidEndpoint();
|
|
84
106
|
}
|
|
85
107
|
const isLoopback = url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "[::1]";
|
|
86
|
-
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopback) || url.username || url.password || url.search || url.hash) throw
|
|
108
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopback) || url.username || url.password || url.search || url.hash) throw invalidEndpoint();
|
|
87
109
|
const prefix = url.pathname.replace(/\/+$/u, "");
|
|
88
110
|
url.pathname = `${prefix}${REMOTE_BUNDLE_SIGNING_PATH}`;
|
|
89
111
|
return url.href;
|
|
@@ -146,34 +168,67 @@ const parseMetadata = async (value) => {
|
|
|
146
168
|
const remoteRequest = async (fetchImplementation, endpoint, resolveToken, init) => {
|
|
147
169
|
const token = await resolveToken();
|
|
148
170
|
if (typeof token !== "string" || !token.trim()) throw new Error("missing token");
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
171
|
+
let response;
|
|
172
|
+
try {
|
|
173
|
+
response = await fetchImplementation(endpoint, {
|
|
174
|
+
...init,
|
|
175
|
+
headers: {
|
|
176
|
+
Accept: "application/json",
|
|
177
|
+
...init.headers,
|
|
178
|
+
[REMOTE_BUNDLE_SIGNING_TOKEN_HEADER]: token
|
|
179
|
+
},
|
|
180
|
+
redirect: "error",
|
|
181
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
182
|
+
});
|
|
183
|
+
} catch {
|
|
184
|
+
throw new RemoteSigningFailure(`Could not reach ${endpoint}.`);
|
|
185
|
+
}
|
|
186
|
+
if (response.status !== 200) {
|
|
187
|
+
const refusal = await describeRefusal(response, token);
|
|
188
|
+
throw new RemoteSigningFailure(`${endpoint} answered ${refusal}${/[.!?]$/u.test(refusal) ? "" : "."}`);
|
|
189
|
+
}
|
|
160
190
|
return parseJsonBody(response.body, response.headers, RESPONSE_BODY_LIMIT);
|
|
161
191
|
};
|
|
192
|
+
/**
|
|
193
|
+
* A refusal's status, with the `{ error }` or `{ error: { code, message } }`
|
|
194
|
+
* a signing server answers it with, such as a scope refusal.
|
|
195
|
+
* The token is masked and the message shortened to one line.
|
|
196
|
+
*/
|
|
197
|
+
const describeRefusal = async (response, token) => {
|
|
198
|
+
let code;
|
|
199
|
+
let message;
|
|
200
|
+
try {
|
|
201
|
+
const body = await parseJsonBody(response.body, response.headers, ERROR_RESPONSE_BODY_LIMIT);
|
|
202
|
+
const error = isRecord(body) ? body.error : void 0;
|
|
203
|
+
if (typeof error === "string") message = error;
|
|
204
|
+
else if (isRecord(error)) {
|
|
205
|
+
code = error.code;
|
|
206
|
+
message = error.message;
|
|
207
|
+
}
|
|
208
|
+
} catch {}
|
|
209
|
+
const status = typeof code === "string" && /^[a-z][a-z0-9_]{0,63}$/u.test(code) ? `${response.status} ${code}` : String(response.status);
|
|
210
|
+
if (typeof message !== "string") return status;
|
|
211
|
+
const text = message.split(token).join("********").replace(/\p{Cc}+/gu, " ").trim();
|
|
212
|
+
if (!text) return status;
|
|
213
|
+
return `${status}: ${text.length > ERROR_MESSAGE_LENGTH_LIMIT ? `${text.slice(0, ERROR_MESSAGE_LENGTH_LIMIT)}…` : text}`;
|
|
214
|
+
};
|
|
162
215
|
/** Signs through a server implementing the Hot Updater signing protocol. */
|
|
163
216
|
const remoteSigning = ({ endpoint, fetch: fetchImplementation = globalThis.fetch, signingToken }) => {
|
|
164
217
|
if (typeof fetchImplementation !== "function") throw new Error("Remote bundle signing requires fetch.");
|
|
165
|
-
|
|
218
|
+
let normalizedEndpoint;
|
|
219
|
+
const endpointUrl = () => normalizedEndpoint ??= normalizeEndpoint(endpoint);
|
|
166
220
|
let resolvedKey;
|
|
167
221
|
const resolveToken = async () => {
|
|
168
222
|
const token = typeof signingToken === "function" ? await signingToken() : signingToken ?? process.env.HOT_UPDATER_SIGNING_TOKEN;
|
|
169
|
-
if (!token?.trim()) throw new
|
|
223
|
+
if (!token?.trim()) throw new RemoteSigningFailure(MISSING_TOKEN_MESSAGE);
|
|
170
224
|
return token;
|
|
171
225
|
};
|
|
172
226
|
const getResolvedKey = () => {
|
|
173
227
|
if (resolvedKey) return resolvedKey;
|
|
174
|
-
|
|
228
|
+
const url = endpointUrl();
|
|
229
|
+
resolvedKey = remoteRequest(fetchImplementation, url, resolveToken, { method: "GET" }).then(parseMetadata).catch((error) => {
|
|
175
230
|
resolvedKey = void 0;
|
|
176
|
-
throw
|
|
231
|
+
throw remoteSigningError("Failed to load the remote bundle signing public key.", error);
|
|
177
232
|
});
|
|
178
233
|
return resolvedKey;
|
|
179
234
|
};
|
|
@@ -188,7 +243,7 @@ const remoteSigning = ({ endpoint, fetch: fetchImplementation = globalThis.fetch
|
|
|
188
243
|
const resolved = await getResolvedKey();
|
|
189
244
|
let value;
|
|
190
245
|
try {
|
|
191
|
-
value = await remoteRequest(fetchImplementation,
|
|
246
|
+
value = await remoteRequest(fetchImplementation, endpointUrl(), resolveToken, {
|
|
192
247
|
body: JSON.stringify({
|
|
193
248
|
algorithm: REMOTE_BUNDLE_SIGNING_ALGORITHM,
|
|
194
249
|
keyId: resolved.keyId,
|
|
@@ -198,8 +253,8 @@ const remoteSigning = ({ endpoint, fetch: fetchImplementation = globalThis.fetch
|
|
|
198
253
|
headers: { "Content-Type": "application/json" },
|
|
199
254
|
method: "POST"
|
|
200
255
|
});
|
|
201
|
-
} catch {
|
|
202
|
-
throw
|
|
256
|
+
} catch (error) {
|
|
257
|
+
throw remoteSigningError("Remote bundle signer failed to sign the message.", error);
|
|
203
258
|
}
|
|
204
259
|
if (!isRecord(value) || !hasExactKeys(value, [
|
|
205
260
|
"algorithm",
|
|
@@ -221,8 +276,9 @@ const jsonResponse = (value, status = 200, headers) => Response.json(value, {
|
|
|
221
276
|
},
|
|
222
277
|
status
|
|
223
278
|
});
|
|
279
|
+
const isTokenSized = (value) => new TextEncoder().encode(value).byteLength <= TOKEN_BYTES_LIMIT;
|
|
224
280
|
const tokensMatch = async (expected, actual) => {
|
|
225
|
-
if (!expected || actual === null ||
|
|
281
|
+
if (!expected || actual === null || !isTokenSized(expected) || !isTokenSized(actual)) return false;
|
|
226
282
|
const [expectedHash, actualHash] = await Promise.all([crypto.subtle.digest("SHA-256", new TextEncoder().encode(expected)), crypto.subtle.digest("SHA-256", new TextEncoder().encode(actual))]);
|
|
227
283
|
const left = new Uint8Array(expectedHash);
|
|
228
284
|
const right = new Uint8Array(actualHash);
|
|
@@ -236,11 +292,18 @@ const createBundleSigningHandler = async ({ endpointPath = REMOTE_BUNDLE_SIGNING
|
|
|
236
292
|
const url = new URL(request.url);
|
|
237
293
|
if (url.pathname !== normalizedEndpointPath) return null;
|
|
238
294
|
if (url.search || url.hash) return jsonResponse({ error: "Bad request" }, 400);
|
|
239
|
-
|
|
295
|
+
const presented = request.headers.get(REMOTE_BUNDLE_SIGNING_TOKEN_HEADER);
|
|
296
|
+
let accepted;
|
|
297
|
+
try {
|
|
298
|
+
accepted = typeof token === "function" ? presented !== null && presented.length > 0 && isTokenSized(presented) && await token(presented) === true : await tokensMatch(token, presented);
|
|
299
|
+
} catch {
|
|
300
|
+
return jsonResponse({ error: "Signing service unavailable" }, 503);
|
|
301
|
+
}
|
|
302
|
+
if (!accepted) return jsonResponse({ error: "Unauthorized" }, 401);
|
|
240
303
|
if (request.method !== "GET" && request.method !== "POST") return jsonResponse({ error: "Method not allowed" }, 405, { Allow: "GET, POST" });
|
|
241
304
|
let resolved;
|
|
242
305
|
try {
|
|
243
|
-
resolved = await canonicalizePublicKey(publicKey);
|
|
306
|
+
resolved = await canonicalizePublicKey(typeof publicKey === "function" ? await publicKey() : publicKey);
|
|
244
307
|
} catch {
|
|
245
308
|
return jsonResponse({ error: "Signing service unavailable" }, 503);
|
|
246
309
|
}
|
|
@@ -66,5 +66,45 @@ interface ChannelRow {
|
|
|
66
66
|
readonly id: string;
|
|
67
67
|
readonly name: string;
|
|
68
68
|
}
|
|
69
|
+
/** The kinds of artifact a native build registers. */
|
|
70
|
+
type NativeBuildArtifactKind = "apk" | "aab" | "ipa" | "app";
|
|
71
|
+
/** The store track a native build was submitted to. */
|
|
72
|
+
type NativeBuildSubmissionDestination = "testflight" | "play-internal";
|
|
73
|
+
/**
|
|
74
|
+
* A registered native build: its artifact in storage, the scope it serves,
|
|
75
|
+
* and `min_bundle_id`, the `bundles` row of the bundle built into it.
|
|
76
|
+
*/
|
|
77
|
+
interface NativeBuildRow {
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly scope_key: string;
|
|
80
|
+
readonly platform: Platform;
|
|
81
|
+
readonly channel_id: string;
|
|
82
|
+
readonly fingerprint_hash: string | null;
|
|
83
|
+
readonly app_version: string | null;
|
|
84
|
+
readonly min_bundle_id: string;
|
|
85
|
+
readonly artifact_kind: NativeBuildArtifactKind;
|
|
86
|
+
readonly artifact_storage_uri: string;
|
|
87
|
+
readonly byte_size: number;
|
|
88
|
+
readonly git_commit_hash: string | null;
|
|
89
|
+
readonly created_at_ms: number;
|
|
90
|
+
/** The native build key of the build's inputs, or null for none. */
|
|
91
|
+
readonly build_key: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* The build number the artifact reports, its `CFBundleVersion` or
|
|
94
|
+
* `versionCode`, which a store takes once per version; null when it can't
|
|
95
|
+
* be read.
|
|
96
|
+
*/
|
|
97
|
+
readonly build_number: string | null;
|
|
98
|
+
/** The store track the build went to, or null when it was submitted to none. */
|
|
99
|
+
readonly submitted_to: NativeBuildSubmissionDestination | null;
|
|
100
|
+
/** When Hot Updater recorded the store's build, in epoch milliseconds. */
|
|
101
|
+
readonly submitted_at_ms: number | null;
|
|
102
|
+
/**
|
|
103
|
+
* The store's label of the build, its version and build number, such as
|
|
104
|
+
* `1.7.0 (66)`: TestFlight and Google Play tell builds of one version apart
|
|
105
|
+
* by the build number, and a fingerprint build records no app version.
|
|
106
|
+
*/
|
|
107
|
+
readonly submitted_version: string | null;
|
|
108
|
+
}
|
|
69
109
|
//#endregion
|
|
70
|
-
export { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow };
|
|
110
|
+
export { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow };
|
|
@@ -66,5 +66,45 @@ interface ChannelRow {
|
|
|
66
66
|
readonly id: string;
|
|
67
67
|
readonly name: string;
|
|
68
68
|
}
|
|
69
|
+
/** The kinds of artifact a native build registers. */
|
|
70
|
+
type NativeBuildArtifactKind = "apk" | "aab" | "ipa" | "app";
|
|
71
|
+
/** The store track a native build was submitted to. */
|
|
72
|
+
type NativeBuildSubmissionDestination = "testflight" | "play-internal";
|
|
73
|
+
/**
|
|
74
|
+
* A registered native build: its artifact in storage, the scope it serves,
|
|
75
|
+
* and `min_bundle_id`, the `bundles` row of the bundle built into it.
|
|
76
|
+
*/
|
|
77
|
+
interface NativeBuildRow {
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly scope_key: string;
|
|
80
|
+
readonly platform: Platform;
|
|
81
|
+
readonly channel_id: string;
|
|
82
|
+
readonly fingerprint_hash: string | null;
|
|
83
|
+
readonly app_version: string | null;
|
|
84
|
+
readonly min_bundle_id: string;
|
|
85
|
+
readonly artifact_kind: NativeBuildArtifactKind;
|
|
86
|
+
readonly artifact_storage_uri: string;
|
|
87
|
+
readonly byte_size: number;
|
|
88
|
+
readonly git_commit_hash: string | null;
|
|
89
|
+
readonly created_at_ms: number;
|
|
90
|
+
/** The native build key of the build's inputs, or null for none. */
|
|
91
|
+
readonly build_key: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* The build number the artifact reports, its `CFBundleVersion` or
|
|
94
|
+
* `versionCode`, which a store takes once per version; null when it can't
|
|
95
|
+
* be read.
|
|
96
|
+
*/
|
|
97
|
+
readonly build_number: string | null;
|
|
98
|
+
/** The store track the build went to, or null when it was submitted to none. */
|
|
99
|
+
readonly submitted_to: NativeBuildSubmissionDestination | null;
|
|
100
|
+
/** When Hot Updater recorded the store's build, in epoch milliseconds. */
|
|
101
|
+
readonly submitted_at_ms: number | null;
|
|
102
|
+
/**
|
|
103
|
+
* The store's label of the build, its version and build number, such as
|
|
104
|
+
* `1.7.0 (66)`: TestFlight and Google Play tell builds of one version apart
|
|
105
|
+
* by the build number, and a fingerprint build records no app version.
|
|
106
|
+
*/
|
|
107
|
+
readonly submitted_version: string | null;
|
|
108
|
+
}
|
|
69
109
|
//#endregion
|
|
70
|
-
export { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow };
|
|
110
|
+
export { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow };
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 { 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 } from "./models.cjs";
|
|
6
|
+
import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult } 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
|
|
@@ -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 `
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
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 };
|