@hot-updater/firebase 1.2.0-rc.24 → 1.2.0-rc.25
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/firebase/functions/index.cjs +43 -14
- package/dist/index.cjs +5 -5
- package/dist/index.mjs +5 -5
- package/package.json +7 -7
|
@@ -2375,7 +2375,9 @@ const channels = defineTable({
|
|
|
2375
2375
|
* for that build alone, so `byStoreBuild` holds one entry per scope at most,
|
|
2376
2376
|
* on every store, while any number of a scope's builds hold none.
|
|
2377
2377
|
* `is_sandbox` is true on a sandbox build, set when it registers and never
|
|
2378
|
-
* changed
|
|
2378
|
+
* changed, and `sandbox_url_scheme` is the URL scheme its artifact registers,
|
|
2379
|
+
* which its preview links open; null on any other build, and on a sandbox
|
|
2380
|
+
* build registered before the column, which registered the derived one. Boolean columns follow one rule: `is_*` for a fact about the row or
|
|
2379
2381
|
* `should_*` for an instruction to the client, never null; a unique index over
|
|
2380
2382
|
* the rows where one is true keys a derived slot, not the boolean.
|
|
2381
2383
|
*/
|
|
@@ -2456,7 +2458,13 @@ const nativeBuilds = defineTable({
|
|
|
2456
2458
|
required: false
|
|
2457
2459
|
},
|
|
2458
2460
|
is_store_build: { type: "boolean" },
|
|
2459
|
-
is_sandbox: { type: "boolean" }
|
|
2461
|
+
is_sandbox: { type: "boolean" },
|
|
2462
|
+
sandbox_url_scheme: {
|
|
2463
|
+
type: "string",
|
|
2464
|
+
maxLength: 255,
|
|
2465
|
+
ascii: true,
|
|
2466
|
+
required: false
|
|
2467
|
+
}
|
|
2460
2468
|
}, {
|
|
2461
2469
|
key: ["id"],
|
|
2462
2470
|
derived: {
|
|
@@ -4617,7 +4625,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
|
|
|
4617
4625
|
};
|
|
4618
4626
|
//#endregion
|
|
4619
4627
|
//#region ../../packages/server/dist/version.mjs
|
|
4620
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
4628
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.25";
|
|
4621
4629
|
//#endregion
|
|
4622
4630
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
4623
4631
|
/**
|
|
@@ -5684,6 +5692,18 @@ const createCoreReads = (db, storage) => {
|
|
|
5684
5692
|
};
|
|
5685
5693
|
};
|
|
5686
5694
|
//#endregion
|
|
5695
|
+
//#region ../../packages/server/dist/core/nativeBuildDestinations.mjs
|
|
5696
|
+
/** Store destinations accepted for each native platform. */
|
|
5697
|
+
const NATIVE_BUILD_SUBMISSION_DESTINATIONS = {
|
|
5698
|
+
android: [
|
|
5699
|
+
"play-internal",
|
|
5700
|
+
"play-closed",
|
|
5701
|
+
"play-open",
|
|
5702
|
+
"play-production"
|
|
5703
|
+
],
|
|
5704
|
+
ios: ["testflight"]
|
|
5705
|
+
};
|
|
5706
|
+
//#endregion
|
|
5687
5707
|
//#region ../../packages/server/dist/core/writes.mjs
|
|
5688
5708
|
const PAGE$2 = 500;
|
|
5689
5709
|
/** Moves one bundle into or out of its platform's total and the overall total. */
|
|
@@ -5801,6 +5821,13 @@ const GIT_COMMIT_HASH_MAX_LENGTH = 255;
|
|
|
5801
5821
|
* and looks up nothing else.
|
|
5802
5822
|
*/
|
|
5803
5823
|
const BUILD_KEY = /^nbk1:[0-9a-f]{64}$/;
|
|
5824
|
+
/** `native_builds.sandbox_url_scheme`'s bound in core's schema. */
|
|
5825
|
+
const SANDBOX_URL_SCHEME_MAX_LENGTH = 255;
|
|
5826
|
+
/**
|
|
5827
|
+
* A URL scheme as RFC 3986 spells it, in lower case: what a sandbox build's
|
|
5828
|
+
* artifact registers, as `@hot-updater/protocol/native-artifact` reads it.
|
|
5829
|
+
*/
|
|
5830
|
+
const URL_SCHEME = new RegExp(`^[a-z][a-z0-9+.-]{0,254}$`);
|
|
5804
5831
|
/** A native build or scope core cannot store or look up: the caller's input. */
|
|
5805
5832
|
var NativeBuildInputError = class extends TypeError {
|
|
5806
5833
|
name = "NativeBuildInputError";
|
|
@@ -5824,7 +5851,8 @@ const pick = (row) => ({
|
|
|
5824
5851
|
submitted_at_ms: row.submitted_at_ms ?? null,
|
|
5825
5852
|
submitted_version: row.submitted_version ?? null,
|
|
5826
5853
|
is_store_build: row.is_store_build === true,
|
|
5827
|
-
is_sandbox: row.is_sandbox === true
|
|
5854
|
+
is_sandbox: row.is_sandbox === true,
|
|
5855
|
+
sandbox_url_scheme: row.sandbox_url_scheme ?? null
|
|
5828
5856
|
});
|
|
5829
5857
|
/**
|
|
5830
5858
|
* The channels only sandbox builds register on: a registration's `sandbox`
|
|
@@ -5839,11 +5867,6 @@ const SANDBOX_CHANNEL_PREFIX = "sandbox-";
|
|
|
5839
5867
|
const OLDER_BUILDS_PAGE = 20;
|
|
5840
5868
|
/** How many times a mark runs again after losing its scope's mark to another. */
|
|
5841
5869
|
const MARK_ATTEMPTS = 8;
|
|
5842
|
-
/** The store track each platform's builds are submitted to. */
|
|
5843
|
-
const SUBMISSION_DESTINATIONS = {
|
|
5844
|
-
android: "play-internal",
|
|
5845
|
-
ios: "testflight"
|
|
5846
|
-
};
|
|
5847
5870
|
/** `native_builds.build_number`'s bound in core's schema. */
|
|
5848
5871
|
const BUILD_NUMBER_MAX_LENGTH = 64;
|
|
5849
5872
|
/** `native_builds.submitted_version`'s bound in core's schema. */
|
|
@@ -5876,7 +5899,7 @@ const nativeBuildScopeKey = (scope) => {
|
|
|
5876
5899
|
};
|
|
5877
5900
|
/** Whether `bundleId` is a native build's built-in bundle: one unique read. */
|
|
5878
5901
|
const isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
|
|
5879
|
-
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, artifact }) => {
|
|
5902
|
+
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, artifact }) => {
|
|
5880
5903
|
if (!isUUIDv7(id)) return "id must be a UUIDv7";
|
|
5881
5904
|
if (!isUUIDv7(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
|
|
5882
5905
|
if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
|
|
@@ -5885,6 +5908,10 @@ const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVer
|
|
|
5885
5908
|
const reserved = channel.startsWith(SANDBOX_CHANNEL_PREFIX);
|
|
5886
5909
|
if (isSandbox === true && !reserved) return `a sandbox build registers on a ${SANDBOX_CHANNEL_PREFIX}* channel, not ${channel}`;
|
|
5887
5910
|
if (isSandbox !== true && reserved) return `channel ${channel} is reserved for sandbox builds`;
|
|
5911
|
+
if (sandboxUrlScheme !== void 0 && sandboxUrlScheme !== null) {
|
|
5912
|
+
if (isSandbox !== true) return "sandboxUrlScheme is a sandbox build's, and this isn't one";
|
|
5913
|
+
if (typeof sandboxUrlScheme !== "string" || !URL_SCHEME.test(sandboxUrlScheme)) return `sandboxUrlScheme must be a URL scheme in lower case, up to ${SANDBOX_URL_SCHEME_MAX_LENGTH} characters, or null`;
|
|
5914
|
+
}
|
|
5888
5915
|
if (gitCommitHash !== null && gitCommitHash.length > GIT_COMMIT_HASH_MAX_LENGTH) return `gitCommitHash must be at most ${GIT_COMMIT_HASH_MAX_LENGTH} characters`;
|
|
5889
5916
|
if (fingerprintHash === null === (appVersion === null)) return "exactly one of fingerprintHash and appVersion is required";
|
|
5890
5917
|
if (buildKey !== null && !BUILD_KEY.test(buildKey)) return "buildKey must be nbk1: and a SHA-256, or null";
|
|
@@ -5921,7 +5948,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
5921
5948
|
submitted_at_ms: null,
|
|
5922
5949
|
submitted_version: null,
|
|
5923
5950
|
is_store_build: false,
|
|
5924
|
-
is_sandbox: registration.isSandbox === true
|
|
5951
|
+
is_sandbox: registration.isSandbox === true,
|
|
5952
|
+
sandbox_url_scheme: registration.sandboxUrlScheme ?? null
|
|
5925
5953
|
};
|
|
5926
5954
|
for (let attempt = 1;; attempt += 1) {
|
|
5927
5955
|
await insertChannel(db, {
|
|
@@ -6002,7 +6030,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
6002
6030
|
const row = await tx.findOne("native_builds", { id });
|
|
6003
6031
|
if (row === null) return null;
|
|
6004
6032
|
const build = pick(row);
|
|
6005
|
-
if (
|
|
6033
|
+
if (!NATIVE_BUILD_SUBMISSION_DESTINATIONS[build.platform].includes(destination)) throw new NativeBuildInputError(`Invalid native build submission: an ${build.platform} build is submitted to ${NATIVE_BUILD_SUBMISSION_DESTINATIONS[build.platform].join(" or ")}, not ${destination}.`);
|
|
6034
|
+
if (build.is_sandbox && destination !== "testflight" && destination !== "play-internal") throw new NativeBuildInputError("A sandbox build can submit only to TestFlight or Play internal testing.");
|
|
6006
6035
|
const set = {
|
|
6007
6036
|
submitted_to: destination,
|
|
6008
6037
|
submitted_at_ms: now(),
|
|
@@ -7008,7 +7037,7 @@ const refusingInvalid = async (operation) => {
|
|
|
7008
7037
|
throw error;
|
|
7009
7038
|
}
|
|
7010
7039
|
};
|
|
7011
|
-
const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
|
|
7040
|
+
const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull$1(value.sandboxUrlScheme)) && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
|
|
7012
7041
|
const scopeKeyOf = (params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "";
|
|
7013
7042
|
/** Every admin route's handler, by the name `ADMIN_ROUTES` mounts it under. */
|
|
7014
7043
|
const createAdminRouteHandlers = () => ({
|
|
@@ -7157,7 +7186,7 @@ const createAdminRouteHandlers = () => ({
|
|
|
7157
7186
|
}),
|
|
7158
7187
|
recordNativeBuildSubmission: onCore(async (core, request, params) => {
|
|
7159
7188
|
const input = await body(request);
|
|
7160
|
-
if (!isRecord$5(input) ||
|
|
7189
|
+
if (!isRecord$5(input) || !Object.values(NATIVE_BUILD_SUBMISSION_DESTINATIONS).flat().includes(input.destination) || !isText$2(input.version)) throw new HandlerBadRequestError("A native build submission needs a valid store destination and version.");
|
|
7161
7190
|
const submission = {
|
|
7162
7191
|
destination: input.destination,
|
|
7163
7192
|
version: input.version
|
package/dist/index.cjs
CHANGED
|
@@ -404,9 +404,9 @@ const signInHint = (credentials) => {
|
|
|
404
404
|
if (variable) return [`Fix or unset ${variable}.`];
|
|
405
405
|
return process.env["CI"] ? ["Use google-github-actions/auth."] : ["Sign in:", "gcloud auth application-default login"];
|
|
406
406
|
};
|
|
407
|
-
const hint = (response, permission, signIn) => {
|
|
407
|
+
const hint = (response, permission, signIn, projectId) => {
|
|
408
408
|
const { status, error } = response;
|
|
409
|
-
if (error.details?.some((detail) => detail.reason === "SERVICE_DISABLED")) return ["Enable the Secret Manager API in the project:",
|
|
409
|
+
if (error.details?.some((detail) => detail.reason === "SERVICE_DISABLED")) return ["Enable the Secret Manager API in the project:", `gcloud services enable secretmanager.googleapis.com --project ${projectId}`];
|
|
410
410
|
if (status === 401) return ["Google rejected the access token.", ...signIn];
|
|
411
411
|
if (status === 403) return [`The identity needs ${permission}.`];
|
|
412
412
|
if (status === 429) return ["Secret Manager's quota is exhausted: try again later."];
|
|
@@ -417,9 +417,9 @@ const hint = (response, permission, signIn) => {
|
|
|
417
417
|
* the resource, `notes`, and what to fix, or Google's own status and message,
|
|
418
418
|
* which name resources but never a value, when nothing here says what to fix.
|
|
419
419
|
*/
|
|
420
|
-
const requestErrorOf = (signIn, action, resource, response, permission, notes = []) => {
|
|
420
|
+
const requestErrorOf = (signIn, projectId, action, resource, response, permission, notes = []) => {
|
|
421
421
|
const { status, message } = response.error;
|
|
422
|
-
const fix = hint(response, permission, signIn);
|
|
422
|
+
const fix = hint(response, permission, signIn, projectId);
|
|
423
423
|
if (response.status === 401 && notes.length === 0) return failure(fix);
|
|
424
424
|
return failure([
|
|
425
425
|
`${ADAPTER_NAME} couldn't ${action} (${response.status}).`,
|
|
@@ -509,7 +509,7 @@ const createAccessToken = (credentials, projectId) => {
|
|
|
509
509
|
*/
|
|
510
510
|
const secretManager = ({ projectId, prefix = "hot-updater-", credentials }) => {
|
|
511
511
|
const accessToken = createAccessToken(credentials, projectId);
|
|
512
|
-
const requestError = (action, resource, response, permission, notes) => requestErrorOf(signInHint(credentials), action, resource, response, permission, notes);
|
|
512
|
+
const requestError = (action, resource, response, permission, notes) => requestErrorOf(signInHint(credentials), projectId, action, resource, response, permission, notes);
|
|
513
513
|
const projectPath = () => {
|
|
514
514
|
if (typeof projectId !== "string" || !PROJECT_PATTERN.test(projectId)) throw failure([`${ADAPTER_NAME} can't use the projectId ${JSON.stringify(projectId)}.`, "Set the Google Cloud project's ID or number."]);
|
|
515
515
|
if (!PREFIX_PATTERN.test(prefix)) throw failure([`${ADAPTER_NAME} can't use the prefix ${JSON.stringify(prefix)}.`, "It takes letters, digits, \"-\", and \"_\"."]);
|
package/dist/index.mjs
CHANGED
|
@@ -403,9 +403,9 @@ const signInHint = (credentials) => {
|
|
|
403
403
|
if (variable) return [`Fix or unset ${variable}.`];
|
|
404
404
|
return process.env["CI"] ? ["Use google-github-actions/auth."] : ["Sign in:", "gcloud auth application-default login"];
|
|
405
405
|
};
|
|
406
|
-
const hint = (response, permission, signIn) => {
|
|
406
|
+
const hint = (response, permission, signIn, projectId) => {
|
|
407
407
|
const { status, error } = response;
|
|
408
|
-
if (error.details?.some((detail) => detail.reason === "SERVICE_DISABLED")) return ["Enable the Secret Manager API in the project:",
|
|
408
|
+
if (error.details?.some((detail) => detail.reason === "SERVICE_DISABLED")) return ["Enable the Secret Manager API in the project:", `gcloud services enable secretmanager.googleapis.com --project ${projectId}`];
|
|
409
409
|
if (status === 401) return ["Google rejected the access token.", ...signIn];
|
|
410
410
|
if (status === 403) return [`The identity needs ${permission}.`];
|
|
411
411
|
if (status === 429) return ["Secret Manager's quota is exhausted: try again later."];
|
|
@@ -416,9 +416,9 @@ const hint = (response, permission, signIn) => {
|
|
|
416
416
|
* the resource, `notes`, and what to fix, or Google's own status and message,
|
|
417
417
|
* which name resources but never a value, when nothing here says what to fix.
|
|
418
418
|
*/
|
|
419
|
-
const requestErrorOf = (signIn, action, resource, response, permission, notes = []) => {
|
|
419
|
+
const requestErrorOf = (signIn, projectId, action, resource, response, permission, notes = []) => {
|
|
420
420
|
const { status, message } = response.error;
|
|
421
|
-
const fix = hint(response, permission, signIn);
|
|
421
|
+
const fix = hint(response, permission, signIn, projectId);
|
|
422
422
|
if (response.status === 401 && notes.length === 0) return failure(fix);
|
|
423
423
|
return failure([
|
|
424
424
|
`${ADAPTER_NAME} couldn't ${action} (${response.status}).`,
|
|
@@ -508,7 +508,7 @@ const createAccessToken = (credentials, projectId) => {
|
|
|
508
508
|
*/
|
|
509
509
|
const secretManager = ({ projectId, prefix = "hot-updater-", credentials }) => {
|
|
510
510
|
const accessToken = createAccessToken(credentials, projectId);
|
|
511
|
-
const requestError = (action, resource, response, permission, notes) => requestErrorOf(signInHint(credentials), action, resource, response, permission, notes);
|
|
511
|
+
const requestError = (action, resource, response, permission, notes) => requestErrorOf(signInHint(credentials), projectId, action, resource, response, permission, notes);
|
|
512
512
|
const projectPath = () => {
|
|
513
513
|
if (typeof projectId !== "string" || !PROJECT_PATTERN.test(projectId)) throw failure([`${ADAPTER_NAME} can't use the projectId ${JSON.stringify(projectId)}.`, "Set the Google Cloud project's ID or number."]);
|
|
514
514
|
if (!PREFIX_PATTERN.test(prefix)) throw failure([`${ADAPTER_NAME} can't use the prefix ${JSON.stringify(prefix)}.`, "It takes letters, digits, \"-\", and \"_\"."]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/firebase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.25",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"types": "dist/index.d.cts",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"hono": "4.12.34",
|
|
40
40
|
"google-auth-library": "10.7.0",
|
|
41
|
-
"@hot-updater/cli-tools": "1.2.0-rc.
|
|
42
|
-
"@hot-updater/
|
|
43
|
-
"@hot-updater/
|
|
44
|
-
"@hot-updater/
|
|
41
|
+
"@hot-updater/cli-tools": "1.2.0-rc.25",
|
|
42
|
+
"@hot-updater/plugin-core": "1.2.0-rc.25",
|
|
43
|
+
"@hot-updater/server": "1.2.0-rc.25",
|
|
44
|
+
"@hot-updater/protocol": "1.2.0-rc.25"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"firebase-tools": "15.29.0",
|
|
57
57
|
"fkill": "^9.0.0",
|
|
58
58
|
"mime": "^4.0.4",
|
|
59
|
-
"@hot-updater/mock": "1.2.0-rc.
|
|
60
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
59
|
+
"@hot-updater/mock": "1.2.0-rc.25",
|
|
60
|
+
"@hot-updater/test-utils": "1.2.0-rc.25"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"firebase-admin": ">=11.10.0",
|