@hot-updater/azure 1.2.0-rc.40 → 1.2.0-rc.41
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/functions/index.mjs +99 -13
- package/package.json +6 -6
package/dist/functions/index.mjs
CHANGED
|
@@ -8155,7 +8155,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
|
|
|
8155
8155
|
};
|
|
8156
8156
|
//#endregion
|
|
8157
8157
|
//#region ../../packages/server/dist/version.mjs
|
|
8158
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
8158
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.41";
|
|
8159
8159
|
//#endregion
|
|
8160
8160
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
8161
8161
|
const createVersionRouteHandlers = (plugins = []) => {
|
|
@@ -9389,6 +9389,11 @@ const createIosDeviceApi = (db, { now = Date.now } = {}) => {
|
|
|
9389
9389
|
tx.update("ios_devices", row, { build_id: buildId });
|
|
9390
9390
|
});
|
|
9391
9391
|
},
|
|
9392
|
+
async findIosDeviceAccount() {
|
|
9393
|
+
const existing = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
|
|
9394
|
+
const issuerId = existing === null ? await accountOfRows() : existing.apple_issuer_id;
|
|
9395
|
+
return issuerId === null ? null : { issuerId };
|
|
9396
|
+
},
|
|
9392
9397
|
async claimIosDeviceAccount(issuerId) {
|
|
9393
9398
|
if (typeof issuerId !== "string" || issuerId.trim().length === 0 || issuerId.length > ISSUER_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device account: issuerId must be an App Store Connect issuer of at most ${ISSUER_MAX_LENGTH} characters.`);
|
|
9394
9399
|
const answer = (held) => ({
|
|
@@ -9540,6 +9545,14 @@ const GIT_COMMIT_HASH_MAX_LENGTH = 255;
|
|
|
9540
9545
|
const BUILD_KEY = /^nbk1:[0-9a-f]{64}$/;
|
|
9541
9546
|
const SANDBOX_URL_SCHEME_MAX_LENGTH = 255;
|
|
9542
9547
|
const URL_SCHEME = new RegExp(`^[a-z][a-z0-9+.-]{0,254}$`);
|
|
9548
|
+
const APP_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/;
|
|
9549
|
+
const FINGERPRINT_HASH = /^[A-Za-z0-9._~-]{1,255}$/;
|
|
9550
|
+
const DISTRIBUTIONS = {
|
|
9551
|
+
apk: ["direct"],
|
|
9552
|
+
app: ["direct"],
|
|
9553
|
+
aab: ["store"],
|
|
9554
|
+
ipa: ["direct", "store"]
|
|
9555
|
+
};
|
|
9543
9556
|
var NativeBuildInputError = class extends TypeError {
|
|
9544
9557
|
name = "NativeBuildInputError";
|
|
9545
9558
|
};
|
|
@@ -9573,12 +9586,28 @@ const EXPORT_METHODS = /* @__PURE__ */ new Set([
|
|
|
9573
9586
|
"development",
|
|
9574
9587
|
"enterprise"
|
|
9575
9588
|
]);
|
|
9576
|
-
const SANDBOX_CHANNEL_PREFIX = "sandbox-";
|
|
9577
9589
|
const OLDER_BUILDS_PAGE = 20;
|
|
9578
9590
|
const MARK_ATTEMPTS = 8;
|
|
9579
9591
|
const BUILD_NUMBER_MAX_LENGTH = 64;
|
|
9580
9592
|
const SUBMITTED_VERSION_MAX_LENGTH = 255;
|
|
9593
|
+
const checkedScopeKey = (scopeKey) => {
|
|
9594
|
+
if (scopeKey.length > SCOPE_KEY_MAX_LENGTH) throw new NativeBuildInputError(`Invalid native build scope: its key is longer than ${SCOPE_KEY_MAX_LENGTH} characters; shorten the channel or app version.`);
|
|
9595
|
+
return scopeKey;
|
|
9596
|
+
};
|
|
9597
|
+
const registeredDistribution = (kind, exportMethod) => kind !== "ipa" ? DISTRIBUTIONS[kind][0] : exportMethod === void 0 || exportMethod === null ? "unknown" : exportMethod === "app-store" ? "store" : "direct";
|
|
9598
|
+
const sandboxScopeKey = (scope, sandbox) => {
|
|
9599
|
+
const { appId, urlScheme, artifactKind, distribution } = sandbox;
|
|
9600
|
+
const problem = typeof appId !== "string" || !APP_ID.test(appId) ? "its app ID must be a bundle identifier or application ID, up to 255 characters" : typeof urlScheme !== "string" || !URL_SCHEME.test(urlScheme) ? `its URL scheme must be a URL scheme in lower case, up to ${SANDBOX_URL_SCHEME_MAX_LENGTH} characters` : !ARTIFACT_KINDS[scope.platform]?.includes(artifactKind) ? `its artifact kind must be one an ${scope.platform} build makes` : distribution !== "unknown" && !DISTRIBUTIONS[artifactKind].includes(distribution) ? `an .${artifactKind} doesn't install as ${String(distribution)}` : scope.fingerprintHash !== null && !FINGERPRINT_HASH.test(scope.fingerprintHash) ? "its fingerprint hash must be 1-255 URL-safe ASCII characters" : null;
|
|
9601
|
+
if (problem !== null) throw new NativeBuildInputError(`Invalid sandbox build scope: ${problem}.`);
|
|
9602
|
+
const target = scope.fingerprintHash === null ? `app-version:${encodeURIComponent(scope.appVersion)}` : `fingerprint:${scope.fingerprintHash}`;
|
|
9603
|
+
return checkedScopeKey(`v1:sandbox:${scope.platform}:${appId}:${urlScheme}:${artifactKind}:${distribution}:${target}`);
|
|
9604
|
+
};
|
|
9581
9605
|
const nativeBuildScopeKey = (scope) => {
|
|
9606
|
+
const { sandbox } = scope;
|
|
9607
|
+
if (sandbox !== void 0 && sandbox !== null) {
|
|
9608
|
+
if (sandbox.distribution !== "direct" && sandbox.distribution !== "store") throw new NativeBuildInputError("Invalid sandbox build scope: its distribution must be direct or store.");
|
|
9609
|
+
return sandboxScopeKey(scope, sandbox);
|
|
9610
|
+
}
|
|
9582
9611
|
let scopeKey;
|
|
9583
9612
|
try {
|
|
9584
9613
|
const channelKey = encodeChannelKey(scope.channel);
|
|
@@ -9595,26 +9624,49 @@ const nativeBuildScopeKey = (scope) => {
|
|
|
9595
9624
|
} catch (error) {
|
|
9596
9625
|
throw new NativeBuildInputError(`Invalid native build scope: ${error instanceof Error ? error.message : String(error)}.`);
|
|
9597
9626
|
}
|
|
9598
|
-
|
|
9599
|
-
|
|
9627
|
+
return checkedScopeKey(scopeKey);
|
|
9628
|
+
};
|
|
9629
|
+
const channelIdOf = (channel) => {
|
|
9630
|
+
try {
|
|
9631
|
+
return `channel:${encodeChannelKey(channel)}`;
|
|
9632
|
+
} catch (error) {
|
|
9633
|
+
throw new NativeBuildInputError(`Invalid native build scope: ${error instanceof Error ? error.message : String(error)}.`);
|
|
9634
|
+
}
|
|
9635
|
+
};
|
|
9636
|
+
const registrationScopeKey = (registration) => {
|
|
9637
|
+
channelIdOf(registration.channel);
|
|
9638
|
+
return registration.isSandbox === true ? sandboxScopeKey(registration, {
|
|
9639
|
+
appId: registration.sandboxAppId,
|
|
9640
|
+
urlScheme: registration.sandboxUrlScheme,
|
|
9641
|
+
artifactKind: registration.artifact.kind,
|
|
9642
|
+
distribution: registeredDistribution(registration.artifact.kind, registration.exportMethod)
|
|
9643
|
+
}) : nativeBuildScopeKey({
|
|
9644
|
+
...registration,
|
|
9645
|
+
sandbox: null
|
|
9646
|
+
});
|
|
9600
9647
|
};
|
|
9601
9648
|
const refuseSandboxPatchBase = async (db, baseBundleId) => {
|
|
9602
9649
|
if ((await db.findOne("native_builds", { min_bundle_id: baseBundleId }))?.is_sandbox === true) throw new NativeBuildInputError("A sandbox build's built-in bundle is no patch base.");
|
|
9603
9650
|
};
|
|
9604
9651
|
const isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
|
|
9605
|
-
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, exportMethod, nativeAppVersion, artifact }) => {
|
|
9652
|
+
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, sandboxAppId, exportMethod, nativeAppVersion, artifact }) => {
|
|
9606
9653
|
if (!isUUIDv7(id)) return "id must be a UUIDv7";
|
|
9607
9654
|
if (!isUUIDv7(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
|
|
9608
9655
|
if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
|
|
9609
9656
|
if (channel.trim().length === 0) return "channel is required";
|
|
9610
9657
|
if (isSandbox !== void 0 && typeof isSandbox !== "boolean") return "isSandbox must be true or false";
|
|
9611
|
-
const reserved = channel.startsWith(SANDBOX_CHANNEL_PREFIX);
|
|
9612
|
-
if (isSandbox === true && !reserved) return `a sandbox build registers on a ${SANDBOX_CHANNEL_PREFIX}* channel, not ${channel}`;
|
|
9613
|
-
if (isSandbox !== true && reserved) return `channel ${channel} is reserved for sandbox builds`;
|
|
9614
9658
|
if (sandboxUrlScheme !== void 0 && sandboxUrlScheme !== null) {
|
|
9615
9659
|
if (isSandbox !== true) return "sandboxUrlScheme is a sandbox build's, and this isn't one";
|
|
9616
9660
|
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`;
|
|
9617
9661
|
}
|
|
9662
|
+
if (sandboxAppId !== void 0 && sandboxAppId !== null) {
|
|
9663
|
+
if (isSandbox !== true) return "sandboxAppId is a sandbox build's, and this isn't one";
|
|
9664
|
+
if (typeof sandboxAppId !== "string" || !APP_ID.test(sandboxAppId)) return "sandboxAppId must be the artifact's bundle identifier or application ID, up to 255 characters";
|
|
9665
|
+
}
|
|
9666
|
+
if (isSandbox === true) {
|
|
9667
|
+
if (sandboxUrlScheme === void 0 || sandboxUrlScheme === null) return "a sandbox build needs the sandboxUrlScheme its artifact registers";
|
|
9668
|
+
if (sandboxAppId === void 0 || sandboxAppId === null) return "a sandbox build needs the sandboxAppId its artifact reports, which an older hot-updater CLI doesn't send. Upgrade the hot-updater CLI to the version that matches this server, and build again";
|
|
9669
|
+
}
|
|
9618
9670
|
if (gitCommitHash !== null && gitCommitHash.length > GIT_COMMIT_HASH_MAX_LENGTH) return `gitCommitHash must be at most ${GIT_COMMIT_HASH_MAX_LENGTH} characters`;
|
|
9619
9671
|
if (fingerprintHash === null === (appVersion === null)) return "exactly one of fingerprintHash and appVersion is required";
|
|
9620
9672
|
if (buildKey !== null && !BUILD_KEY.test(buildKey)) return "buildKey must be nbk1: and a SHA-256, or null";
|
|
@@ -9633,8 +9685,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
9633
9685
|
async registerNativeBuild(registration) {
|
|
9634
9686
|
const problem = problemOf(registration);
|
|
9635
9687
|
if (problem !== null) throw new NativeBuildInputError(`Invalid native build: ${problem}.`);
|
|
9636
|
-
const scopeKey =
|
|
9637
|
-
const channelId =
|
|
9688
|
+
const scopeKey = registrationScopeKey(registration);
|
|
9689
|
+
const channelId = channelIdOf(registration.channel);
|
|
9638
9690
|
const { embeddedBundle } = registration;
|
|
9639
9691
|
const row = {
|
|
9640
9692
|
id: registration.id,
|
|
@@ -9720,7 +9772,7 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
9720
9772
|
});
|
|
9721
9773
|
};
|
|
9722
9774
|
const bundleId = options?.builtInOlderThan;
|
|
9723
|
-
if (bundleId !== void 0 && scope.
|
|
9775
|
+
if (bundleId !== void 0 && scope.sandbox !== void 0 && scope.sandbox !== null) return null;
|
|
9724
9776
|
const { rows } = await read(1);
|
|
9725
9777
|
const newest = rows[0];
|
|
9726
9778
|
if (newest === void 0) return null;
|
|
@@ -10683,7 +10735,8 @@ const nativeBuildScopeOf = (url) => {
|
|
|
10683
10735
|
const fingerprintHash = params.get("fingerprintHash");
|
|
10684
10736
|
const appVersion = params.get("appVersion");
|
|
10685
10737
|
if (platform === void 0 || !isText$2(channel) || fingerprintHash === null === (appVersion === null) || fingerprintHash === "" || appVersion === "") throw new HandlerBadRequestError("A native build lookup needs platform, channel, and fingerprintHash or appVersion.");
|
|
10686
|
-
|
|
10738
|
+
const sandbox = sandboxScopeOf(params);
|
|
10739
|
+
const scope = fingerprintHash !== null ? {
|
|
10687
10740
|
platform,
|
|
10688
10741
|
channel,
|
|
10689
10742
|
fingerprintHash,
|
|
@@ -10694,6 +10747,33 @@ const nativeBuildScopeOf = (url) => {
|
|
|
10694
10747
|
fingerprintHash: null,
|
|
10695
10748
|
appVersion
|
|
10696
10749
|
};
|
|
10750
|
+
return sandbox === null ? scope : {
|
|
10751
|
+
...scope,
|
|
10752
|
+
sandbox
|
|
10753
|
+
};
|
|
10754
|
+
};
|
|
10755
|
+
const SANDBOX_SCOPE_PARAMS = [
|
|
10756
|
+
"sandboxAppId",
|
|
10757
|
+
"sandboxUrlScheme",
|
|
10758
|
+
"artifactKind",
|
|
10759
|
+
"distribution"
|
|
10760
|
+
];
|
|
10761
|
+
const sandboxScopeOf = (params) => {
|
|
10762
|
+
const [appId, urlScheme, artifactKind, distribution] = SANDBOX_SCOPE_PARAMS.map((name) => params.get(name));
|
|
10763
|
+
const named = [
|
|
10764
|
+
appId,
|
|
10765
|
+
urlScheme,
|
|
10766
|
+
artifactKind,
|
|
10767
|
+
distribution
|
|
10768
|
+
].filter((value) => value !== null).length;
|
|
10769
|
+
if (named === 0) return null;
|
|
10770
|
+
if (named !== SANDBOX_SCOPE_PARAMS.length) throw new HandlerBadRequestError(`A sandbox build lookup needs ${SANDBOX_SCOPE_PARAMS.join(", ")}.`);
|
|
10771
|
+
return {
|
|
10772
|
+
appId,
|
|
10773
|
+
urlScheme,
|
|
10774
|
+
artifactKind,
|
|
10775
|
+
distribution
|
|
10776
|
+
};
|
|
10697
10777
|
};
|
|
10698
10778
|
const refusingInvalid = async (operation) => {
|
|
10699
10779
|
try {
|
|
@@ -10703,7 +10783,7 @@ const refusingInvalid = async (operation) => {
|
|
|
10703
10783
|
throw error;
|
|
10704
10784
|
}
|
|
10705
10785
|
};
|
|
10706
|
-
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)) && (value.exportMethod === void 0 || isTextOrNull$1(value.exportMethod)) && (value.nativeAppVersion === void 0 || isTextOrNull$1(value.nativeAppVersion)) && 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));
|
|
10786
|
+
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)) && (value.sandboxAppId === void 0 || isTextOrNull$1(value.sandboxAppId)) && (value.exportMethod === void 0 || isTextOrNull$1(value.exportMethod)) && (value.nativeAppVersion === void 0 || isTextOrNull$1(value.nativeAppVersion)) && 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));
|
|
10707
10787
|
const scopeKeyOf = (params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "";
|
|
10708
10788
|
const createAdminRouteHandlers = () => ({
|
|
10709
10789
|
listBundles: onCore(async (core, request) => {
|
|
@@ -10918,6 +10998,7 @@ const createAdminRouteHandlers = () => ({
|
|
|
10918
10998
|
if (!isText$2(issuerId)) throw new HandlerBadRequestError("Claiming the iOS device account needs issuerId.");
|
|
10919
10999
|
return json$2({ data: await refusingInvalid(() => core.claimIosDeviceAccount(issuerId)) });
|
|
10920
11000
|
}),
|
|
11001
|
+
findIosDeviceAccount: onCore(async (core) => json$2({ data: await core.findIosDeviceAccount() })),
|
|
10921
11002
|
markIosDevicesInBuild: onCore(async (core, request) => {
|
|
10922
11003
|
const { buildId, ids } = await body$1(request);
|
|
10923
11004
|
if (!isText$2(buildId) || !Array.isArray(ids) || !ids.every((id) => isText$2(id))) throw new HandlerBadRequestError("Marking iOS devices in a build needs buildId and ids.");
|
|
@@ -11110,6 +11191,11 @@ const ADMIN_ROUTES = [
|
|
|
11110
11191
|
path: "/ios-devices/in-build",
|
|
11111
11192
|
handler: "markIosDevicesInBuild"
|
|
11112
11193
|
},
|
|
11194
|
+
{
|
|
11195
|
+
method: "GET",
|
|
11196
|
+
path: "/ios-devices/account",
|
|
11197
|
+
handler: "findIosDeviceAccount"
|
|
11198
|
+
},
|
|
11113
11199
|
{
|
|
11114
11200
|
method: "POST",
|
|
11115
11201
|
path: "/ios-devices/account",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/azure",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.41",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": "^22.23.4 || ^24.22.1 || >=26.12.1"
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@azure/identity": "4.14.0",
|
|
45
45
|
"@azure/keyvault-secrets": "4.11.2",
|
|
46
46
|
"@azure/storage-blob": "12.34.0",
|
|
47
|
-
"@hot-updater/
|
|
48
|
-
"@hot-updater/
|
|
49
|
-
"@hot-updater/
|
|
50
|
-
"@hot-updater/
|
|
47
|
+
"@hot-updater/cli-tools": "1.2.0-rc.41",
|
|
48
|
+
"@hot-updater/plugin-core": "1.2.0-rc.41",
|
|
49
|
+
"@hot-updater/protocol": "1.2.0-rc.41",
|
|
50
|
+
"@hot-updater/server": "1.2.0-rc.41"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@azure/functions": "4.16.5",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"execa": "9.5.2",
|
|
56
56
|
"jszip": "^3.10.1",
|
|
57
57
|
"vitest": "4.1.4",
|
|
58
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
58
|
+
"@hot-updater/test-utils": "1.2.0-rc.41"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "tsdown",
|