@hot-updater/cloudflare 1.2.0-rc.40 → 1.2.0-rc.42

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/cloudflare",
3
3
  "type": "module",
4
- "version": "1.2.0-rc.40",
4
+ "version": "1.2.0-rc.42",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -52,11 +52,11 @@
52
52
  "cloudflare": "4.2.0",
53
53
  "hono": "4.12.34",
54
54
  "uuidv7": "^1.0.2",
55
- "@hot-updater/plugin-core": "1.2.0-rc.40",
56
- "@hot-updater/protocol": "1.2.0-rc.40",
57
- "@hot-updater/cli-tools": "1.2.0-rc.40",
58
- "@hot-updater/storage-s3": "1.2.0-rc.40",
59
- "@hot-updater/server": "1.2.0-rc.40"
55
+ "@hot-updater/cli-tools": "1.2.0-rc.42",
56
+ "@hot-updater/protocol": "1.2.0-rc.42",
57
+ "@hot-updater/server": "1.2.0-rc.42",
58
+ "@hot-updater/plugin-core": "1.2.0-rc.42",
59
+ "@hot-updater/storage-s3": "1.2.0-rc.42"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@aws-sdk/client-s3": "3.1066.0",
@@ -75,7 +75,7 @@
75
75
  "vitest": "4.1.4",
76
76
  "wrangler": "^4.69.0",
77
77
  "xdg-app-paths": "^8.3.0",
78
- "@hot-updater/test-utils": "1.2.0-rc.40"
78
+ "@hot-updater/test-utils": "1.2.0-rc.42"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsdown && pnpm build:worker",
@@ -1 +1 @@
1
- This folder contains the built output assets for the worker "hot-updater" generated at 2026-11-13T03:43:23.274Z.
1
+ This folder contains the built output assets for the worker "hot-updater" generated at 2026-11-13T12:43:17.237Z.
@@ -4672,7 +4672,7 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
4672
4672
  }, "createSqlAdapter");
4673
4673
 
4674
4674
  // ../../packages/server/dist/package.mjs
4675
- var version = "1.2.0-rc.40";
4675
+ var version = "1.2.0-rc.42";
4676
4676
 
4677
4677
  // ../../packages/server/dist/version.mjs
4678
4678
  var HOT_UPDATER_SERVER_VERSION = version;
@@ -5973,6 +5973,11 @@ var createIosDeviceApi = /* @__PURE__ */ __name((db, { now = Date.now } = {}) =>
5973
5973
  tx.update("ios_devices", row, { build_id: buildId });
5974
5974
  });
5975
5975
  },
5976
+ async findIosDeviceAccount() {
5977
+ const existing = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
5978
+ const issuerId = existing === null ? await accountOfRows() : existing.apple_issuer_id;
5979
+ return issuerId === null ? null : { issuerId };
5980
+ },
5976
5981
  async claimIosDeviceAccount(issuerId) {
5977
5982
  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.`);
5978
5983
  const answer2 = /* @__PURE__ */ __name((held) => ({
@@ -6124,6 +6129,14 @@ var GIT_COMMIT_HASH_MAX_LENGTH = 255;
6124
6129
  var BUILD_KEY = /^nbk1:[0-9a-f]{64}$/;
6125
6130
  var SANDBOX_URL_SCHEME_MAX_LENGTH = 255;
6126
6131
  var URL_SCHEME = new RegExp(`^[a-z][a-z0-9+.-]{0,254}$`);
6132
+ var APP_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/;
6133
+ var FINGERPRINT_HASH = /^[A-Za-z0-9._~-]{1,255}$/;
6134
+ var DISTRIBUTIONS = {
6135
+ apk: ["direct"],
6136
+ app: ["direct"],
6137
+ aab: ["store"],
6138
+ ipa: ["direct", "store"]
6139
+ };
6127
6140
  var NativeBuildInputError = class extends TypeError {
6128
6141
  static {
6129
6142
  __name(this, "NativeBuildInputError");
@@ -6160,12 +6173,28 @@ var EXPORT_METHODS = /* @__PURE__ */ new Set([
6160
6173
  "development",
6161
6174
  "enterprise"
6162
6175
  ]);
6163
- var SANDBOX_CHANNEL_PREFIX = "sandbox-";
6164
6176
  var OLDER_BUILDS_PAGE = 20;
6165
6177
  var MARK_ATTEMPTS = 8;
6166
6178
  var BUILD_NUMBER_MAX_LENGTH = 64;
6167
6179
  var SUBMITTED_VERSION_MAX_LENGTH = 255;
6180
+ var checkedScopeKey = /* @__PURE__ */ __name((scopeKey) => {
6181
+ 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.`);
6182
+ return scopeKey;
6183
+ }, "checkedScopeKey");
6184
+ var registeredDistribution = /* @__PURE__ */ __name((kind, exportMethod) => kind !== "ipa" ? DISTRIBUTIONS[kind][0] : exportMethod === void 0 || exportMethod === null ? "unknown" : exportMethod === "app-store" ? "store" : "direct", "registeredDistribution");
6185
+ var sandboxScopeKey = /* @__PURE__ */ __name((scope, sandbox) => {
6186
+ const { appId, urlScheme, artifactKind, distribution } = sandbox;
6187
+ 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;
6188
+ if (problem !== null) throw new NativeBuildInputError(`Invalid sandbox build scope: ${problem}.`);
6189
+ const target = scope.fingerprintHash === null ? `app-version:${encodeURIComponent(scope.appVersion)}` : `fingerprint:${scope.fingerprintHash}`;
6190
+ return checkedScopeKey(`v1:sandbox:${scope.platform}:${appId}:${urlScheme}:${artifactKind}:${distribution}:${target}`);
6191
+ }, "sandboxScopeKey");
6168
6192
  var nativeBuildScopeKey = /* @__PURE__ */ __name((scope) => {
6193
+ const { sandbox } = scope;
6194
+ if (sandbox !== void 0 && sandbox !== null) {
6195
+ if (sandbox.distribution !== "direct" && sandbox.distribution !== "store") throw new NativeBuildInputError("Invalid sandbox build scope: its distribution must be direct or store.");
6196
+ return sandboxScopeKey(scope, sandbox);
6197
+ }
6169
6198
  let scopeKey;
6170
6199
  try {
6171
6200
  const channelKey = encodeChannelKey(scope.channel);
@@ -6182,26 +6211,49 @@ var nativeBuildScopeKey = /* @__PURE__ */ __name((scope) => {
6182
6211
  } catch (error) {
6183
6212
  throw new NativeBuildInputError(`Invalid native build scope: ${error instanceof Error ? error.message : String(error)}.`);
6184
6213
  }
6185
- 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.`);
6186
- return scopeKey;
6214
+ return checkedScopeKey(scopeKey);
6187
6215
  }, "nativeBuildScopeKey");
6216
+ var channelIdOf = /* @__PURE__ */ __name((channel) => {
6217
+ try {
6218
+ return `channel:${encodeChannelKey(channel)}`;
6219
+ } catch (error) {
6220
+ throw new NativeBuildInputError(`Invalid native build scope: ${error instanceof Error ? error.message : String(error)}.`);
6221
+ }
6222
+ }, "channelIdOf");
6223
+ var registrationScopeKey = /* @__PURE__ */ __name((registration) => {
6224
+ channelIdOf(registration.channel);
6225
+ return registration.isSandbox === true ? sandboxScopeKey(registration, {
6226
+ appId: registration.sandboxAppId,
6227
+ urlScheme: registration.sandboxUrlScheme,
6228
+ artifactKind: registration.artifact.kind,
6229
+ distribution: registeredDistribution(registration.artifact.kind, registration.exportMethod)
6230
+ }) : nativeBuildScopeKey({
6231
+ ...registration,
6232
+ sandbox: null
6233
+ });
6234
+ }, "registrationScopeKey");
6188
6235
  var refuseSandboxPatchBase = /* @__PURE__ */ __name(async (db, baseBundleId) => {
6189
6236
  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.");
6190
6237
  }, "refuseSandboxPatchBase");
6191
6238
  var isBuiltInBundle = /* @__PURE__ */ __name(async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null, "isBuiltInBundle");
6192
- var problemOf = /* @__PURE__ */ __name(({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, exportMethod, nativeAppVersion, artifact }) => {
6239
+ var problemOf = /* @__PURE__ */ __name(({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, sandboxAppId, exportMethod, nativeAppVersion, artifact }) => {
6193
6240
  if (!isUUIDv7(id)) return "id must be a UUIDv7";
6194
6241
  if (!isUUIDv7(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
6195
6242
  if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
6196
6243
  if (channel.trim().length === 0) return "channel is required";
6197
6244
  if (isSandbox !== void 0 && typeof isSandbox !== "boolean") return "isSandbox must be true or false";
6198
- const reserved = channel.startsWith(SANDBOX_CHANNEL_PREFIX);
6199
- if (isSandbox === true && !reserved) return `a sandbox build registers on a ${SANDBOX_CHANNEL_PREFIX}* channel, not ${channel}`;
6200
- if (isSandbox !== true && reserved) return `channel ${channel} is reserved for sandbox builds`;
6201
6245
  if (sandboxUrlScheme !== void 0 && sandboxUrlScheme !== null) {
6202
6246
  if (isSandbox !== true) return "sandboxUrlScheme is a sandbox build's, and this isn't one";
6203
6247
  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`;
6204
6248
  }
6249
+ if (sandboxAppId !== void 0 && sandboxAppId !== null) {
6250
+ if (isSandbox !== true) return "sandboxAppId is a sandbox build's, and this isn't one";
6251
+ if (typeof sandboxAppId !== "string" || !APP_ID.test(sandboxAppId)) return "sandboxAppId must be the artifact's bundle identifier or application ID, up to 255 characters";
6252
+ }
6253
+ if (isSandbox === true) {
6254
+ if (sandboxUrlScheme === void 0 || sandboxUrlScheme === null) return "a sandbox build needs the sandboxUrlScheme its artifact registers";
6255
+ 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";
6256
+ }
6205
6257
  if (gitCommitHash !== null && gitCommitHash.length > GIT_COMMIT_HASH_MAX_LENGTH) return `gitCommitHash must be at most ${GIT_COMMIT_HASH_MAX_LENGTH} characters`;
6206
6258
  if (fingerprintHash === null === (appVersion === null)) return "exactly one of fingerprintHash and appVersion is required";
6207
6259
  if (buildKey !== null && !BUILD_KEY.test(buildKey)) return "buildKey must be nbk1: and a SHA-256, or null";
@@ -6220,8 +6272,8 @@ var createNativeBuildApi = /* @__PURE__ */ __name((db, { now = Date.now } = {})
6220
6272
  async registerNativeBuild(registration) {
6221
6273
  const problem = problemOf(registration);
6222
6274
  if (problem !== null) throw new NativeBuildInputError(`Invalid native build: ${problem}.`);
6223
- const scopeKey = nativeBuildScopeKey(registration);
6224
- const channelId = `channel:${encodeChannelKey(registration.channel)}`;
6275
+ const scopeKey = registrationScopeKey(registration);
6276
+ const channelId = channelIdOf(registration.channel);
6225
6277
  const { embeddedBundle } = registration;
6226
6278
  const row = {
6227
6279
  id: registration.id,
@@ -6307,7 +6359,7 @@ var createNativeBuildApi = /* @__PURE__ */ __name((db, { now = Date.now } = {})
6307
6359
  });
6308
6360
  }, "read");
6309
6361
  const bundleId = options?.builtInOlderThan;
6310
- if (bundleId !== void 0 && scope.channel.startsWith(SANDBOX_CHANNEL_PREFIX)) return null;
6362
+ if (bundleId !== void 0 && scope.sandbox !== void 0 && scope.sandbox !== null) return null;
6311
6363
  const { rows } = await read(1);
6312
6364
  const newest = rows[0];
6313
6365
  if (newest === void 0) return null;
@@ -7277,7 +7329,8 @@ var nativeBuildScopeOf = /* @__PURE__ */ __name((url) => {
7277
7329
  const fingerprintHash = params.get("fingerprintHash");
7278
7330
  const appVersion = params.get("appVersion");
7279
7331
  if (platform === void 0 || !isText(channel) || fingerprintHash === null === (appVersion === null) || fingerprintHash === "" || appVersion === "") throw new HandlerBadRequestError("A native build lookup needs platform, channel, and fingerprintHash or appVersion.");
7280
- return fingerprintHash !== null ? {
7332
+ const sandbox = sandboxScopeOf(params);
7333
+ const scope = fingerprintHash !== null ? {
7281
7334
  platform,
7282
7335
  channel,
7283
7336
  fingerprintHash,
@@ -7288,7 +7341,34 @@ var nativeBuildScopeOf = /* @__PURE__ */ __name((url) => {
7288
7341
  fingerprintHash: null,
7289
7342
  appVersion
7290
7343
  };
7344
+ return sandbox === null ? scope : {
7345
+ ...scope,
7346
+ sandbox
7347
+ };
7291
7348
  }, "nativeBuildScopeOf");
7349
+ var SANDBOX_SCOPE_PARAMS = [
7350
+ "sandboxAppId",
7351
+ "sandboxUrlScheme",
7352
+ "artifactKind",
7353
+ "distribution"
7354
+ ];
7355
+ var sandboxScopeOf = /* @__PURE__ */ __name((params) => {
7356
+ const [appId, urlScheme, artifactKind, distribution] = SANDBOX_SCOPE_PARAMS.map((name) => params.get(name));
7357
+ const named = [
7358
+ appId,
7359
+ urlScheme,
7360
+ artifactKind,
7361
+ distribution
7362
+ ].filter((value) => value !== null).length;
7363
+ if (named === 0) return null;
7364
+ if (named !== SANDBOX_SCOPE_PARAMS.length) throw new HandlerBadRequestError(`A sandbox build lookup needs ${SANDBOX_SCOPE_PARAMS.join(", ")}.`);
7365
+ return {
7366
+ appId,
7367
+ urlScheme,
7368
+ artifactKind,
7369
+ distribution
7370
+ };
7371
+ }, "sandboxScopeOf");
7292
7372
  var refusingInvalid = /* @__PURE__ */ __name(async (operation) => {
7293
7373
  try {
7294
7374
  return await operation();
@@ -7297,7 +7377,7 @@ var refusingInvalid = /* @__PURE__ */ __name(async (operation) => {
7297
7377
  throw error;
7298
7378
  }
7299
7379
  }, "refusingInvalid");
7300
- var isNativeBuildRegistration = /* @__PURE__ */ __name((value) => isRecord3(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText(value.channel) && isTextOrNull(value.fingerprintHash) && isTextOrNull(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull(value.gitCommitHash) && isTextOrNull(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull(value.sandboxUrlScheme)) && (value.exportMethod === void 0 || isTextOrNull(value.exportMethod)) && (value.nativeAppVersion === void 0 || isTextOrNull(value.nativeAppVersion)) && isRecord3(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord3(value.embeddedBundle) && isText(value.embeddedBundle.manifestStorageUri) && isText(value.embeddedBundle.manifestFileHash) && isText(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord3(value.embeddedBundle.metadata)), "isNativeBuildRegistration");
7380
+ var isNativeBuildRegistration = /* @__PURE__ */ __name((value) => isRecord3(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText(value.channel) && isTextOrNull(value.fingerprintHash) && isTextOrNull(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull(value.gitCommitHash) && isTextOrNull(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull(value.sandboxUrlScheme)) && (value.sandboxAppId === void 0 || isTextOrNull(value.sandboxAppId)) && (value.exportMethod === void 0 || isTextOrNull(value.exportMethod)) && (value.nativeAppVersion === void 0 || isTextOrNull(value.nativeAppVersion)) && isRecord3(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord3(value.embeddedBundle) && isText(value.embeddedBundle.manifestStorageUri) && isText(value.embeddedBundle.manifestFileHash) && isText(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord3(value.embeddedBundle.metadata)), "isNativeBuildRegistration");
7301
7381
  var scopeKeyOf = /* @__PURE__ */ __name((params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "", "scopeKeyOf");
7302
7382
  var createAdminRouteHandlers = /* @__PURE__ */ __name(() => ({
7303
7383
  listBundles: onCore(async (core, request) => {
@@ -7516,6 +7596,7 @@ var createAdminRouteHandlers = /* @__PURE__ */ __name(() => ({
7516
7596
  if (!isText(issuerId)) throw new HandlerBadRequestError("Claiming the iOS device account needs issuerId.");
7517
7597
  return json({ data: await refusingInvalid(() => core.claimIosDeviceAccount(issuerId)) });
7518
7598
  }),
7599
+ findIosDeviceAccount: onCore(async (core) => json({ data: await core.findIosDeviceAccount() })),
7519
7600
  markIosDevicesInBuild: onCore(async (core, request) => {
7520
7601
  const { buildId, ids } = await body(request);
7521
7602
  if (!isText(buildId) || !Array.isArray(ids) || !ids.every((id) => isText(id))) throw new HandlerBadRequestError("Marking iOS devices in a build needs buildId and ids.");
@@ -7708,6 +7789,11 @@ var ADMIN_ROUTES = [
7708
7789
  path: "/ios-devices/in-build",
7709
7790
  handler: "markIosDevicesInBuild"
7710
7791
  },
7792
+ {
7793
+ method: "GET",
7794
+ path: "/ios-devices/account",
7795
+ handler: "findIosDeviceAccount"
7796
+ },
7711
7797
  {
7712
7798
  method: "POST",
7713
7799
  path: "/ios-devices/account",