@hot-updater/cloudflare 0.20.11 → 0.20.12

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": "0.20.11",
4
+ "version": "0.20.12",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -40,9 +40,9 @@
40
40
  ],
41
41
  "dependencies": {
42
42
  "cloudflare": "4.2.0",
43
- "@hot-updater/core": "0.20.11",
44
- "@hot-updater/js": "0.20.11",
45
- "@hot-updater/plugin-core": "0.20.11"
43
+ "@hot-updater/js": "0.20.12",
44
+ "@hot-updater/core": "0.20.12",
45
+ "@hot-updater/plugin-core": "0.20.12"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@clack/prompts": "0.10.0",
package/sql/prepareSql.ts CHANGED
@@ -1,5 +1,5 @@
1
- import path from "path";
2
1
  import fs from "fs/promises";
2
+ import path from "path";
3
3
 
4
4
  export const prepareSql = async () => {
5
5
  const files = await fs.readdir(__dirname);
@@ -1 +1 @@
1
- This folder contains the built output assets for the worker "hot-updater" generated at 2025-09-15T01:29:53.413Z.
1
+ This folder contains the built output assets for the worker "hot-updater" generated at 2025-10-09T07:31:43.509Z.
@@ -1298,8 +1298,7 @@ var require_diff = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semver
1298
1298
  const highVersion = v1Higher ? v1 : v2;
1299
1299
  const lowVersion = v1Higher ? v2 : v1;
1300
1300
  const highHasPre = !!highVersion.prerelease.length;
1301
- const lowHasPre = !!lowVersion.prerelease.length;
1302
- if (lowHasPre && !highHasPre) {
1301
+ if (!!lowVersion.prerelease.length && !highHasPre) {
1303
1302
  if (!lowVersion.patch && !lowVersion.minor) return "major";
1304
1303
  if (lowVersion.compareMain(highVersion) === 0) {
1305
1304
  if (lowVersion.minor && !lowVersion.patch) return "minor";
@@ -1460,11 +1459,7 @@ var require_coerce = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semv
1460
1459
  }
1461
1460
  if (match === null) return null;
1462
1461
  const major$2 = match[2];
1463
- const minor$2 = match[3] || "0";
1464
- const patch$2 = match[4] || "0";
1465
- const prerelease$2 = options.includePrerelease && match[5] ? `-${match[5]}` : "";
1466
- const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
1467
- return parse$1(`${major$2}.${minor$2}.${patch$2}${prerelease$2}${build}`, options);
1462
+ return parse$1(`${major$2}.${match[3] || "0"}.${match[4] || "0"}${options.includePrerelease && match[5] ? `-${match[5]}` : ""}${options.includePrerelease && match[6] ? `+${match[6]}` : ""}`, options);
1468
1463
  }, "coerce$1");
1469
1464
  module.exports = coerce$1;
1470
1465
  }, "../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/coerce.js") });
@@ -1479,7 +1474,7 @@ var require_lrucache = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
1479
1474
  }
1480
1475
  get(key) {
1481
1476
  const value = this.map.get(key);
1482
- if (value === void 0) return void 0;
1477
+ if (value === void 0) return;
1483
1478
  else {
1484
1479
  this.map.delete(key);
1485
1480
  this.map.set(key, value);
@@ -1490,8 +1485,7 @@ var require_lrucache = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
1490
1485
  return this.map.delete(key);
1491
1486
  }
1492
1487
  set(key, value) {
1493
- const deleted = this.delete(key);
1494
- if (!deleted && value !== void 0) {
1488
+ if (!this.delete(key) && value !== void 0) {
1495
1489
  if (this.map.size >= this.max) {
1496
1490
  const firstKey = this.map.keys().next().value;
1497
1491
  this.delete(firstKey);
@@ -1559,8 +1553,7 @@ var require_range = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semve
1559
1553
  return this.range;
1560
1554
  }
1561
1555
  parseRange(range) {
1562
- const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
1563
- const memoKey = memoOpts + ":" + range;
1556
+ const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
1564
1557
  const cached = cache$1.get(memoKey);
1565
1558
  if (cached) return cached;
1566
1559
  const loose = this.options.loose;
@@ -1614,8 +1607,7 @@ var require_range = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/semve
1614
1607
  }
1615
1608
  };
1616
1609
  module.exports = Range$11;
1617
- const LRU = require_lrucache();
1618
- const cache$1 = new LRU();
1610
+ const cache$1 = new (require_lrucache())();
1619
1611
  const parseOptions$1 = require_parse_options();
1620
1612
  const Comparator$4 = require_comparator();
1621
1613
  const debug$1 = require_debug();
@@ -2044,16 +2036,13 @@ var require_simplify = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/se
2044
2036
  let first = null;
2045
2037
  let prev = null;
2046
2038
  const v = versions2.sort((a, b) => compare$2(a, b, options));
2047
- for (const version2 of v) {
2048
- const included = satisfies$2(version2, range, options);
2049
- if (included) {
2050
- prev = version2;
2051
- if (!first) first = version2;
2052
- } else {
2053
- if (prev) set.push([first, prev]);
2054
- prev = null;
2055
- first = null;
2056
- }
2039
+ for (const version2 of v) if (satisfies$2(version2, range, options)) {
2040
+ prev = version2;
2041
+ if (!first) first = version2;
2042
+ } else {
2043
+ if (prev) set.push([first, prev]);
2044
+ prev = null;
2045
+ first = null;
2057
2046
  }
2058
2047
  if (first) set.push([first, null]);
2059
2048
  const ranges = [];
@@ -2257,8 +2246,7 @@ var semverSatisfies = /* @__PURE__ */ __name((targetAppVersion, currentVersion)
2257
2246
  return import_semver.default.satisfies(currentCoerce.version, targetAppVersion);
2258
2247
  }, "semverSatisfies");
2259
2248
  var filterCompatibleAppVersions = /* @__PURE__ */ __name((targetAppVersionList, currentVersion) => {
2260
- const compatibleAppVersionList = targetAppVersionList.filter((version2) => semverSatisfies(version2, currentVersion));
2261
- return compatibleAppVersionList.sort((a, b) => b.localeCompare(a));
2249
+ return targetAppVersionList.filter((version2) => semverSatisfies(version2, currentVersion)).sort((a, b) => b.localeCompare(a));
2262
2250
  }, "filterCompatibleAppVersions");
2263
2251
  var encoder = new TextEncoder();
2264
2252
  var decoder = new TextDecoder();
@@ -2438,8 +2426,7 @@ function checkSigCryptoKey(key, alg, usage) {
2438
2426
  case "HS512": {
2439
2427
  if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
2440
2428
  const expected = parseInt(alg.slice(2), 10);
2441
- const actual = getHashLength(key.algorithm.hash);
2442
- if (actual !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
2429
+ if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
2443
2430
  break;
2444
2431
  }
2445
2432
  case "RS256":
@@ -2447,8 +2434,7 @@ function checkSigCryptoKey(key, alg, usage) {
2447
2434
  case "RS512": {
2448
2435
  if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
2449
2436
  const expected = parseInt(alg.slice(2), 10);
2450
- const actual = getHashLength(key.algorithm.hash);
2451
- if (actual !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
2437
+ if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
2452
2438
  break;
2453
2439
  }
2454
2440
  case "PS256":
@@ -2456,8 +2442,7 @@ function checkSigCryptoKey(key, alg, usage) {
2456
2442
  case "PS512": {
2457
2443
  if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
2458
2444
  const expected = parseInt(alg.slice(2), 10);
2459
- const actual = getHashLength(key.algorithm.hash);
2460
- if (actual !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
2445
+ if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
2461
2446
  break;
2462
2447
  }
2463
2448
  case "Ed25519":
@@ -2469,8 +2454,7 @@ function checkSigCryptoKey(key, alg, usage) {
2469
2454
  case "ES512": {
2470
2455
  if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
2471
2456
  const expected = getNamedCurve(alg);
2472
- const actual = key.algorithm.namedCurve;
2473
- if (actual !== expected) throw unusable(expected, "algorithm.namedCurve");
2457
+ if (key.algorithm.namedCurve !== expected) throw unusable(expected, "algorithm.namedCurve");
2474
2458
  break;
2475
2459
  }
2476
2460
  default:
@@ -2672,7 +2656,7 @@ var validate_crit_default = /* @__PURE__ */ __name((Err, recognizedDefault, reco
2672
2656
  }, "validate_crit_default");
2673
2657
  var validate_algorithms_default = /* @__PURE__ */ __name((option, algorithms) => {
2674
2658
  if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) throw new TypeError(`"${option}" option must be an array of strings`);
2675
- if (!algorithms) return void 0;
2659
+ if (!algorithms) return;
2676
2660
  return new Set(algorithms);
2677
2661
  }, "validate_algorithms_default");
2678
2662
  function isJWK(key) {
@@ -2762,12 +2746,11 @@ var handleKeyObject = /* @__PURE__ */ __name((keyObject, alg) => {
2762
2746
  }, extractable, [isPublic ? "verify" : "sign"]);
2763
2747
  }
2764
2748
  if (keyObject.asymmetricKeyType === "ec") {
2765
- const nist = /* @__PURE__ */ new Map([
2749
+ const namedCurve = (/* @__PURE__ */ new Map([
2766
2750
  ["prime256v1", "P-256"],
2767
2751
  ["secp384r1", "P-384"],
2768
2752
  ["secp521r1", "P-521"]
2769
- ]);
2770
- const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);
2753
+ ])).get(keyObject.asymmetricKeyDetails?.namedCurve);
2771
2754
  if (!namedCurve) throw new TypeError("given KeyObject instance cannot be used for this algorithm");
2772
2755
  if (alg === "ES256" && namedCurve === "P-256") cryptoKey = keyObject.toCryptoKey({
2773
2756
  name: "ECDSA",
@@ -2801,8 +2784,7 @@ var normalize_key_default = /* @__PURE__ */ __name(async (key, alg) => {
2801
2784
  } catch (err) {
2802
2785
  if (err instanceof TypeError) throw err;
2803
2786
  }
2804
- let jwk = key.export({ format: "jwk" });
2805
- return handleJWK(key, jwk, alg);
2787
+ return handleJWK(key, key.export({ format: "jwk" }), alg);
2806
2788
  }
2807
2789
  if (isJWK(key)) {
2808
2790
  if (key.k) return decode(key.k);
@@ -2893,8 +2875,7 @@ var asymmetricTypeCheck = /* @__PURE__ */ __name((alg, key, usage) => {
2893
2875
  }
2894
2876
  }, "asymmetricTypeCheck");
2895
2877
  var check_key_type_default = /* @__PURE__ */ __name((alg, key, usage) => {
2896
- const symmetric = alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(alg) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(alg);
2897
- if (symmetric) symmetricTypeCheck(alg, key, usage);
2878
+ if (alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(alg) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(alg)) symmetricTypeCheck(alg, key, usage);
2898
2879
  else asymmetricTypeCheck(alg, key, usage);
2899
2880
  }, "check_key_type_default");
2900
2881
  var subtle_dsa_default = /* @__PURE__ */ __name((alg, algorithm) => {
@@ -3004,8 +2985,7 @@ async function flattenedVerify(jws, key, options) {
3004
2985
  throw new JWSInvalid("Failed to base64url decode the signature");
3005
2986
  }
3006
2987
  const k = await normalize_key_default(key, alg);
3007
- const verified = await verify_default(alg, k, signature, data);
3008
- if (!verified) throw new JWSSignatureVerificationFailed();
2988
+ if (!await verify_default(alg, k, signature, data)) throw new JWSSignatureVerificationFailed();
3009
2989
  let payload;
3010
2990
  if (b64) try {
3011
2991
  payload = decode(jws.payload);
@@ -3214,9 +3194,8 @@ var JWTClaimsBuilder = class {
3214
3194
  async function jwtVerify(jwt, key, options) {
3215
3195
  const verified = await compactVerify(jwt, key, options);
3216
3196
  if (verified.protectedHeader.crit?.includes("b64") && verified.protectedHeader.b64 === false) throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
3217
- const payload = validateClaimsSet(verified.protectedHeader, verified.payload, options);
3218
3197
  const result = {
3219
- payload,
3198
+ payload: validateClaimsSet(verified.protectedHeader, verified.payload, options),
3220
3199
  protectedHeader: verified.protectedHeader
3221
3200
  };
3222
3201
  if (typeof key === "function") return {
@@ -3275,10 +3254,8 @@ var FlattenedSign = class {
3275
3254
  if (this.#protectedHeader) protectedHeader = encoder.encode(encode(JSON.stringify(this.#protectedHeader)));
3276
3255
  else protectedHeader = encoder.encode("");
3277
3256
  const data = concat(protectedHeader, encoder.encode("."), payload);
3278
- const k = await normalize_key_default(key, alg);
3279
- const signature = await sign_default(alg, k, data);
3280
3257
  const jws = {
3281
- signature: encode(signature),
3258
+ signature: encode(await sign_default(alg, await normalize_key_default(key, alg), data)),
3282
3259
  payload: ""
3283
3260
  };
3284
3261
  if (b64) jws.payload = decoder.decode(payload);
@@ -3353,29 +3330,6 @@ var SignJWT = class {
3353
3330
  return sig.sign(key, options);
3354
3331
  }
3355
3332
  };
3356
- var withJwtSignedUrl = /* @__PURE__ */ __name(async ({ data, reqUrl, jwtSecret }) => {
3357
- if (!data) return null;
3358
- const { storageUri, ...rest } = data;
3359
- if (data.id === NIL_UUID || !storageUri) return {
3360
- ...rest,
3361
- fileUrl: null
3362
- };
3363
- const storageUrl = new URL(storageUri);
3364
- const key = `${storageUrl.host}${storageUrl.pathname}`;
3365
- const token = await signToken(key, jwtSecret);
3366
- const url = new URL(reqUrl);
3367
- url.pathname = key;
3368
- url.searchParams.set("token", token);
3369
- return {
3370
- ...rest,
3371
- fileUrl: url.toString()
3372
- };
3373
- }, "withJwtSignedUrl");
3374
- var signToken = /* @__PURE__ */ __name(async (key, jwtSecret) => {
3375
- const secretKey = new TextEncoder().encode(jwtSecret);
3376
- const token = await new SignJWT({ key }).setProtectedHeader({ alg: "HS256" }).setExpirationTime("60s").sign(secretKey);
3377
- return token;
3378
- }, "signToken");
3379
3333
  var verifyJwtToken = /* @__PURE__ */ __name(async ({ path, token, jwtSecret }) => {
3380
3334
  const key = path.replace(/^\/+/, "");
3381
3335
  if (!token) return {
@@ -3383,8 +3337,7 @@ var verifyJwtToken = /* @__PURE__ */ __name(async ({ path, token, jwtSecret }) =
3383
3337
  error: "Missing token"
3384
3338
  };
3385
3339
  try {
3386
- const secretKey = new TextEncoder().encode(jwtSecret);
3387
- const { payload } = await jwtVerify(token, secretKey);
3340
+ const { payload } = await jwtVerify(token, new TextEncoder().encode(jwtSecret));
3388
3341
  if (!payload || payload.key !== key) return {
3389
3342
  valid: false,
3390
3343
  error: "Token does not match requested file"
@@ -3393,7 +3346,7 @@ var verifyJwtToken = /* @__PURE__ */ __name(async ({ path, token, jwtSecret }) =
3393
3346
  valid: true,
3394
3347
  key
3395
3348
  };
3396
- } catch (error3) {
3349
+ } catch {
3397
3350
  return {
3398
3351
  valid: false,
3399
3352
  error: "Invalid or expired token"
@@ -3408,13 +3361,12 @@ var getFileResponse = /* @__PURE__ */ __name(async ({ key, handler }) => {
3408
3361
  };
3409
3362
  const pathParts = key.split("/");
3410
3363
  const fileName = pathParts[pathParts.length - 1];
3411
- const headers = {
3412
- "Content-Type": object.contentType || "application/octet-stream",
3413
- "Content-Disposition": `attachment; filename=${fileName}`
3414
- };
3415
3364
  return {
3416
3365
  status: 200,
3417
- responseHeaders: headers,
3366
+ responseHeaders: {
3367
+ "Content-Type": object.contentType || "application/octet-stream",
3368
+ "Content-Disposition": `attachment; filename=${fileName}`
3369
+ },
3418
3370
  responseBody: object.body
3419
3371
  };
3420
3372
  }, "getFileResponse");
@@ -3439,6 +3391,28 @@ var verifyJwtSignedUrl = /* @__PURE__ */ __name(async ({ path, token, jwtSecret,
3439
3391
  handler
3440
3392
  });
3441
3393
  }, "verifyJwtSignedUrl");
3394
+ var withJwtSignedUrl = /* @__PURE__ */ __name(async ({ data, reqUrl, jwtSecret }) => {
3395
+ if (!data) return null;
3396
+ const { storageUri, ...rest } = data;
3397
+ if (data.id === NIL_UUID || !storageUri) return {
3398
+ ...rest,
3399
+ fileUrl: null
3400
+ };
3401
+ const storageUrl = new URL(storageUri);
3402
+ const key = `${storageUrl.host}${storageUrl.pathname}`;
3403
+ const token = await signToken(key, jwtSecret);
3404
+ const url = new URL(reqUrl);
3405
+ url.pathname = key;
3406
+ url.searchParams.set("token", token);
3407
+ return {
3408
+ ...rest,
3409
+ fileUrl: url.toString()
3410
+ };
3411
+ }, "withJwtSignedUrl");
3412
+ var signToken = /* @__PURE__ */ __name(async (key, jwtSecret) => {
3413
+ const secretKey = new TextEncoder().encode(jwtSecret);
3414
+ return await new SignJWT({ key }).setProtectedHeader({ alg: "HS256" }).setExpirationTime("60s").sign(secretKey);
3415
+ }, "signToken");
3442
3416
 
3443
3417
  // ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/utils/body.js
3444
3418
  var parseBody = /* @__PURE__ */ __name(async (request, options = /* @__PURE__ */ Object.create(null)) => {