@hot-updater/aws 0.36.4 → 0.36.6

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.
@@ -926,7 +926,7 @@ var require_isexe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
926
926
  //#region ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
927
927
  var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
928
928
  const isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
929
- const path$9 = require("path");
929
+ const path$10 = require("path");
930
930
  const COLON = isWindows ? ";" : ":";
931
931
  const isexe = require_isexe();
932
932
  const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -956,7 +956,7 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
956
956
  if (i === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
957
957
  const ppRaw = pathEnv[i];
958
958
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
959
- const pCmd = path$9.join(pathPart, cmd);
959
+ const pCmd = path$10.join(pathPart, cmd);
960
960
  resolve(subStep(!pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd, i, 0));
961
961
  });
962
962
  const subStep = (p, i, ii) => new Promise((resolve, reject) => {
@@ -977,7 +977,7 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
977
977
  for (let i = 0; i < pathEnv.length; i++) {
978
978
  const ppRaw = pathEnv[i];
979
979
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
980
- const pCmd = path$9.join(pathPart, cmd);
980
+ const pCmd = path$10.join(pathPart, cmd);
981
981
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
982
982
  for (let j = 0; j < pathExt.length; j++) {
983
983
  const cur = p + pathExt[j];
@@ -1008,7 +1008,7 @@ var require_path_key = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1008
1008
  //#endregion
1009
1009
  //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
1010
1010
  var require_resolveCommand = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1011
- const path$8 = require("path");
1011
+ const path$9 = require("path");
1012
1012
  const which = require_which();
1013
1013
  const getPathKey = require_path_key();
1014
1014
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -1023,12 +1023,12 @@ var require_resolveCommand = /* @__PURE__ */ __commonJSMin(((exports, module) =>
1023
1023
  try {
1024
1024
  resolved = which.sync(parsed.command, {
1025
1025
  path: env[getPathKey({ env })],
1026
- pathExt: withoutPathExt ? path$8.delimiter : void 0
1026
+ pathExt: withoutPathExt ? path$9.delimiter : void 0
1027
1027
  });
1028
1028
  } catch (e) {} finally {
1029
1029
  if (shouldSwitchCwd) process.chdir(cwd);
1030
1030
  }
1031
- if (resolved) resolved = path$8.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
1031
+ if (resolved) resolved = path$9.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
1032
1032
  return resolved;
1033
1033
  }
1034
1034
  function resolveCommand(parsed) {
@@ -1095,7 +1095,7 @@ var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1095
1095
  //#endregion
1096
1096
  //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
1097
1097
  var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1098
- const path$7 = require("path");
1098
+ const path$8 = require("path");
1099
1099
  const resolveCommand = require_resolveCommand();
1100
1100
  const escape = require_escape();
1101
1101
  const readShebang = require_readShebang();
@@ -1118,7 +1118,7 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1118
1118
  const needsShell = !isExecutableRegExp.test(commandFile);
1119
1119
  if (parsed.options.forceShell || needsShell) {
1120
1120
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
1121
- parsed.command = path$7.normalize(parsed.command);
1121
+ parsed.command = path$8.normalize(parsed.command);
1122
1122
  parsed.command = escape.command(parsed.command);
1123
1123
  parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
1124
1124
  parsed.args = [
@@ -7307,7 +7307,29 @@ var IAMManager = class {
7307
7307
  }
7308
7308
  };
7309
7309
  //#endregion
7310
+ //#region iac/lambdaAsset.ts
7311
+ /**
7312
+ * Resolves the directory holding the bundled Lambda@Edge runtime.
7313
+ * Kept in its own module so it can be mocked in tests without requiring a
7314
+ * built `dist/`.
7315
+ */
7316
+ const resolveLambdaDir = () => path.default.dirname(require.resolve("@hot-updater/aws/lambda"));
7317
+ //#endregion
7310
7318
  //#region iac/lambdaEdge.ts
7319
+ const LAMBDA_EDGE_MEMORY_SIZE = 256;
7320
+ const LAMBDA_EDGE_TIMEOUT = 10;
7321
+ const waitForFunctionUpdate = async (lambdaClient, lambdaName) => {
7322
+ while (true) {
7323
+ try {
7324
+ const status = await lambdaClient.getFunctionConfiguration({ FunctionName: lambdaName });
7325
+ if (status.LastUpdateStatus === "Successful") return;
7326
+ if (status.LastUpdateStatus === "Failed") throw new Error(`Lambda update failed: ${status.LastUpdateStatusReason}`);
7327
+ } catch (err) {
7328
+ if (!(err instanceof Error && err.name === "ResourceConflictException")) throw err;
7329
+ }
7330
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
7331
+ }
7332
+ };
7311
7333
  var LambdaEdgeDeployer = class {
7312
7334
  credentials;
7313
7335
  constructor(credentials) {
@@ -7315,8 +7337,7 @@ var LambdaEdgeDeployer = class {
7315
7337
  }
7316
7338
  async deploy(lambdaRoleArn, lambdaName, config) {
7317
7339
  const cwd = (0, _hot_updater_cli_tools.getCwd)();
7318
- const lambdaPath = require.resolve("@hot-updater/aws/lambda");
7319
- const { tmpDir, removeTmpDir } = await (0, _hot_updater_cli_tools.copyDirToTmp)(path.default.dirname(lambdaPath));
7340
+ const { tmpDir, removeTmpDir } = await (0, _hot_updater_cli_tools.copyDirToTmp)(resolveLambdaDir());
7320
7341
  const indexPath = path.default.join(tmpDir, "index.cjs");
7321
7342
  const code = (0, _hot_updater_cli_tools.transformEnv)(indexPath, {
7322
7343
  CLOUDFRONT_KEY_PAIR_ID: config.publicKeyId,
@@ -7361,7 +7382,8 @@ var LambdaEdgeDeployer = class {
7361
7382
  Code: { ZipFile: await fs_promises.default.readFile(zipFilePath) },
7362
7383
  Description: "Hot Updater Lambda@Edge function",
7363
7384
  Publish: true,
7364
- Timeout: 10
7385
+ MemorySize: LAMBDA_EDGE_MEMORY_SIZE,
7386
+ Timeout: LAMBDA_EDGE_TIMEOUT
7365
7387
  });
7366
7388
  functionArn.arn = createResp.FunctionArn || null;
7367
7389
  functionArn.version = createResp.Version || "1";
@@ -7369,33 +7391,23 @@ var LambdaEdgeDeployer = class {
7369
7391
  } catch (error) {
7370
7392
  if (error instanceof Error && error.name === "ResourceConflictException") {
7371
7393
  message(`Function "${lambdaName}" already exists. Updating function code...`);
7372
- const updateResp = await lambdaClient.updateFunctionCode({
7394
+ await lambdaClient.updateFunctionCode({
7373
7395
  FunctionName: lambdaName,
7374
7396
  ZipFile: await fs_promises.default.readFile(zipFilePath),
7375
- Publish: true
7397
+ Publish: false
7376
7398
  });
7377
7399
  message("Waiting for Lambda function update to complete...");
7378
- let isUpdateComplete = false;
7379
- while (!isUpdateComplete) try {
7380
- const status = await lambdaClient.getFunctionConfiguration({ FunctionName: lambdaName });
7381
- if (status.LastUpdateStatus === "Successful") isUpdateComplete = true;
7382
- else if (status.LastUpdateStatus === "Failed") throw new Error(`Lambda update failed: ${status.LastUpdateStatusReason}`);
7383
- else await new Promise((resolve) => setTimeout(resolve, 2e3));
7384
- } catch (err) {
7385
- if (err instanceof Error && err.name === "ResourceConflictException") await new Promise((resolve) => setTimeout(resolve, 2e3));
7386
- else throw err;
7387
- }
7388
- try {
7389
- await lambdaClient.updateFunctionConfiguration({
7390
- FunctionName: lambdaName,
7391
- MemorySize: 256,
7392
- Timeout: 10
7393
- });
7394
- } catch (error) {
7395
- _hot_updater_cli_tools.p.log.error(`Failed to update Lambda configuration: ${error instanceof Error ? error.message : String(error)}`);
7396
- }
7397
- functionArn.arn = updateResp.FunctionArn || null;
7398
- functionArn.version = updateResp.Version || "1";
7400
+ await waitForFunctionUpdate(lambdaClient, lambdaName);
7401
+ await lambdaClient.updateFunctionConfiguration({
7402
+ FunctionName: lambdaName,
7403
+ MemorySize: LAMBDA_EDGE_MEMORY_SIZE,
7404
+ Timeout: LAMBDA_EDGE_TIMEOUT
7405
+ });
7406
+ message("Waiting for Lambda configuration update to complete...");
7407
+ await waitForFunctionUpdate(lambdaClient, lambdaName);
7408
+ const publishResp = await lambdaClient.publishVersion({ FunctionName: lambdaName });
7409
+ functionArn.arn = publishResp.FunctionArn || null;
7410
+ functionArn.version = publishResp.Version || "1";
7399
7411
  } else {
7400
7412
  if (error instanceof Error) _hot_updater_cli_tools.p.log.error(`Failed to create or update Lambda function: ${error.message}`);
7401
7413
  throw error;
@@ -7302,7 +7302,29 @@ var IAMManager = class {
7302
7302
  }
7303
7303
  };
7304
7304
  //#endregion
7305
+ //#region iac/lambdaAsset.ts
7306
+ /**
7307
+ * Resolves the directory holding the bundled Lambda@Edge runtime.
7308
+ * Kept in its own module so it can be mocked in tests without requiring a
7309
+ * built `dist/`.
7310
+ */
7311
+ const resolveLambdaDir = () => path$1.dirname(__require.resolve("@hot-updater/aws/lambda"));
7312
+ //#endregion
7305
7313
  //#region iac/lambdaEdge.ts
7314
+ const LAMBDA_EDGE_MEMORY_SIZE = 256;
7315
+ const LAMBDA_EDGE_TIMEOUT = 10;
7316
+ const waitForFunctionUpdate = async (lambdaClient, lambdaName) => {
7317
+ while (true) {
7318
+ try {
7319
+ const status = await lambdaClient.getFunctionConfiguration({ FunctionName: lambdaName });
7320
+ if (status.LastUpdateStatus === "Successful") return;
7321
+ if (status.LastUpdateStatus === "Failed") throw new Error(`Lambda update failed: ${status.LastUpdateStatusReason}`);
7322
+ } catch (err) {
7323
+ if (!(err instanceof Error && err.name === "ResourceConflictException")) throw err;
7324
+ }
7325
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
7326
+ }
7327
+ };
7306
7328
  var LambdaEdgeDeployer = class {
7307
7329
  credentials;
7308
7330
  constructor(credentials) {
@@ -7310,8 +7332,7 @@ var LambdaEdgeDeployer = class {
7310
7332
  }
7311
7333
  async deploy(lambdaRoleArn, lambdaName, config) {
7312
7334
  const cwd = getCwd();
7313
- const lambdaPath = __require.resolve("@hot-updater/aws/lambda");
7314
- const { tmpDir, removeTmpDir } = await copyDirToTmp(path$1.dirname(lambdaPath));
7335
+ const { tmpDir, removeTmpDir } = await copyDirToTmp(resolveLambdaDir());
7315
7336
  const indexPath = path$1.join(tmpDir, "index.cjs");
7316
7337
  const code = transformEnv(indexPath, {
7317
7338
  CLOUDFRONT_KEY_PAIR_ID: config.publicKeyId,
@@ -7356,7 +7377,8 @@ var LambdaEdgeDeployer = class {
7356
7377
  Code: { ZipFile: await fs.readFile(zipFilePath) },
7357
7378
  Description: "Hot Updater Lambda@Edge function",
7358
7379
  Publish: true,
7359
- Timeout: 10
7380
+ MemorySize: LAMBDA_EDGE_MEMORY_SIZE,
7381
+ Timeout: LAMBDA_EDGE_TIMEOUT
7360
7382
  });
7361
7383
  functionArn.arn = createResp.FunctionArn || null;
7362
7384
  functionArn.version = createResp.Version || "1";
@@ -7364,33 +7386,23 @@ var LambdaEdgeDeployer = class {
7364
7386
  } catch (error) {
7365
7387
  if (error instanceof Error && error.name === "ResourceConflictException") {
7366
7388
  message(`Function "${lambdaName}" already exists. Updating function code...`);
7367
- const updateResp = await lambdaClient.updateFunctionCode({
7389
+ await lambdaClient.updateFunctionCode({
7368
7390
  FunctionName: lambdaName,
7369
7391
  ZipFile: await fs.readFile(zipFilePath),
7370
- Publish: true
7392
+ Publish: false
7371
7393
  });
7372
7394
  message("Waiting for Lambda function update to complete...");
7373
- let isUpdateComplete = false;
7374
- while (!isUpdateComplete) try {
7375
- const status = await lambdaClient.getFunctionConfiguration({ FunctionName: lambdaName });
7376
- if (status.LastUpdateStatus === "Successful") isUpdateComplete = true;
7377
- else if (status.LastUpdateStatus === "Failed") throw new Error(`Lambda update failed: ${status.LastUpdateStatusReason}`);
7378
- else await new Promise((resolve) => setTimeout(resolve, 2e3));
7379
- } catch (err) {
7380
- if (err instanceof Error && err.name === "ResourceConflictException") await new Promise((resolve) => setTimeout(resolve, 2e3));
7381
- else throw err;
7382
- }
7383
- try {
7384
- await lambdaClient.updateFunctionConfiguration({
7385
- FunctionName: lambdaName,
7386
- MemorySize: 256,
7387
- Timeout: 10
7388
- });
7389
- } catch (error) {
7390
- p.log.error(`Failed to update Lambda configuration: ${error instanceof Error ? error.message : String(error)}`);
7391
- }
7392
- functionArn.arn = updateResp.FunctionArn || null;
7393
- functionArn.version = updateResp.Version || "1";
7395
+ await waitForFunctionUpdate(lambdaClient, lambdaName);
7396
+ await lambdaClient.updateFunctionConfiguration({
7397
+ FunctionName: lambdaName,
7398
+ MemorySize: LAMBDA_EDGE_MEMORY_SIZE,
7399
+ Timeout: LAMBDA_EDGE_TIMEOUT
7400
+ });
7401
+ message("Waiting for Lambda configuration update to complete...");
7402
+ await waitForFunctionUpdate(lambdaClient, lambdaName);
7403
+ const publishResp = await lambdaClient.publishVersion({ FunctionName: lambdaName });
7404
+ functionArn.arn = publishResp.FunctionArn || null;
7405
+ functionArn.version = publishResp.Version || "1";
7394
7406
  } else {
7395
7407
  if (error instanceof Error) p.log.error(`Failed to create or update Lambda function: ${error.message}`);
7396
7408
  throw error;
@@ -35,7 +35,7 @@ let _aws_sdk_client_ssm = require("@aws-sdk/client-ssm");
35
35
  let _aws_sdk_cloudfront_signer = require("@aws-sdk/cloudfront-signer");
36
36
  //#endregion
37
37
  //#region ../../packages/server/dist/version.mjs
38
- const HOT_UPDATER_SERVER_VERSION = "0.36.4";
38
+ const HOT_UPDATER_SERVER_VERSION = "0.36.6";
39
39
  //#endregion
40
40
  //#region ../../packages/server/dist/internalRouter.mjs
41
41
  const normalizePath = (path) => {
@@ -4621,7 +4621,7 @@ function createHotUpdater(options) {
4621
4621
  return createHotUpdaterCore(options).api;
4622
4622
  }
4623
4623
  //#endregion
4624
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/compose.js
4624
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/compose.js
4625
4625
  var compose = (middleware, onError, onNotFound) => {
4626
4626
  return (context, next) => {
4627
4627
  let index = -1;
@@ -4652,21 +4652,31 @@ var compose = (middleware, onError, onNotFound) => {
4652
4652
  };
4653
4653
  };
4654
4654
  //#endregion
4655
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/request/constants.js
4655
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/request/constants.js
4656
4656
  var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
4657
4657
  //#endregion
4658
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/utils/body.js
4658
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/buffer.js
4659
+ var bufferToFormData = (arrayBuffer, contentType) => {
4660
+ return new Response(arrayBuffer, { headers: { "Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase()) } }).formData();
4661
+ };
4662
+ //#endregion
4663
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/body.js
4664
+ var isRawRequest = (request) => "headers" in request;
4659
4665
  var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
4660
4666
  const { all = false, dot = false } = options;
4661
- const contentType = (request instanceof HonoRequest ? request.raw.headers : request.headers).get("Content-Type");
4662
- if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) return parseFormData(request, {
4667
+ const mediaType = (isRawRequest(request) ? request.headers : request.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
4668
+ if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") return parseFormData(request, {
4663
4669
  all,
4664
4670
  dot
4665
4671
  });
4666
4672
  return {};
4667
4673
  };
4668
4674
  async function parseFormData(request, options) {
4669
- const formData = await request.formData();
4675
+ if (!isRawRequest(request) && request.bodyCache.formData) return convertFormDataToBodyData(await request.bodyCache.formData, options);
4676
+ const headers = isRawRequest(request) ? request.headers : request.raw.headers;
4677
+ const formDataPromise = bufferToFormData(await request.arrayBuffer(), headers.get("Content-Type") || "");
4678
+ if (!isRawRequest(request)) request.bodyCache.formData = formDataPromise;
4679
+ const formData = await formDataPromise;
4670
4680
  if (formData) return convertFormDataToBodyData(formData, options);
4671
4681
  return {};
4672
4682
  }
@@ -4703,7 +4713,7 @@ var handleParsingNestedValues = (form, key, value) => {
4703
4713
  });
4704
4714
  };
4705
4715
  //#endregion
4706
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/utils/url.js
4716
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/url.js
4707
4717
  var splitPath = (path) => {
4708
4718
  const paths = path.split("/");
4709
4719
  if (paths[0] === "") paths.shift();
@@ -4837,7 +4847,7 @@ var _getQueryParam = (url, key, multiple) => {
4837
4847
  encoded = /[%+]/.test(url);
4838
4848
  if (!encoded) return;
4839
4849
  }
4840
- const results = {};
4850
+ const results = /* @__PURE__ */ Object.create(null);
4841
4851
  encoded ??= /[%+]/.test(url);
4842
4852
  let keyIndex = url.indexOf("?", 8);
4843
4853
  while (keyIndex !== -1) {
@@ -4867,7 +4877,7 @@ var getQueryParams = (url, key) => {
4867
4877
  };
4868
4878
  var decodeURIComponent_ = decodeURIComponent;
4869
4879
  //#endregion
4870
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/request.js
4880
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/request.js
4871
4881
  var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
4872
4882
  var HonoRequest = class {
4873
4883
  /**
@@ -4936,7 +4946,7 @@ var HonoRequest = class {
4936
4946
  }
4937
4947
  header(name) {
4938
4948
  if (name) return this.raw.headers.get(name) ?? void 0;
4939
- const headerData = {};
4949
+ const headerData = /* @__PURE__ */ Object.create(null);
4940
4950
  this.raw.headers.forEach((value, key) => {
4941
4951
  headerData[key] = value;
4942
4952
  });
@@ -5002,6 +5012,21 @@ var HonoRequest = class {
5002
5012
  return this.#cachedBody("arrayBuffer");
5003
5013
  }
5004
5014
  /**
5015
+ * `.bytes()` parses the request body as a `Uint8Array`.
5016
+ *
5017
+ * @see {@link https://hono.dev/docs/api/request#bytes}
5018
+ *
5019
+ * @example
5020
+ * ```ts
5021
+ * app.post('/entry', async (c) => {
5022
+ * const body = await c.req.bytes()
5023
+ * })
5024
+ * ```
5025
+ */
5026
+ bytes() {
5027
+ return this.#cachedBody("arrayBuffer").then((buffer) => new Uint8Array(buffer));
5028
+ }
5029
+ /**
5005
5030
  * Parses the request body as a `Blob`.
5006
5031
  * @example
5007
5032
  * ```ts
@@ -5124,7 +5149,7 @@ var HonoRequest = class {
5124
5149
  }
5125
5150
  };
5126
5151
  //#endregion
5127
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/utils/html.js
5152
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/html.js
5128
5153
  var HtmlEscapedCallbackPhase = {
5129
5154
  Stringify: 1,
5130
5155
  BeforeStream: 2,
@@ -5154,7 +5179,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
5154
5179
  else return resStr;
5155
5180
  };
5156
5181
  //#endregion
5157
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/context.js
5182
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/context.js
5158
5183
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
5159
5184
  var setDefaultContentType = (contentType, headers) => {
5160
5185
  return {
@@ -5515,7 +5540,7 @@ var Context = class {
5515
5540
  };
5516
5541
  };
5517
5542
  //#endregion
5518
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router.js
5543
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router.js
5519
5544
  var METHODS = [
5520
5545
  "get",
5521
5546
  "post",
@@ -5527,10 +5552,10 @@ var METHODS = [
5527
5552
  var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
5528
5553
  var UnsupportedPathError = class extends Error {};
5529
5554
  //#endregion
5530
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/utils/constants.js
5555
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/constants.js
5531
5556
  var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
5532
5557
  //#endregion
5533
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/hono-base.js
5558
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/hono-base.js
5534
5559
  var notFoundHandler = (c) => {
5535
5560
  return c.text("404 Not Found", 404);
5536
5561
  };
@@ -5631,7 +5656,7 @@ var Hono$1 = class _Hono {
5631
5656
  handler = async (c, next) => (await compose([], app.errorHandler)(c, () => r.handler(c, next))).res;
5632
5657
  handler[COMPOSED_HANDLER] = r.handler;
5633
5658
  }
5634
- subApp.#addRoute(r.method, r.path, handler);
5659
+ subApp.#addRoute(r.method, r.path, handler, r.basePath);
5635
5660
  });
5636
5661
  return this;
5637
5662
  }
@@ -5748,7 +5773,7 @@ var Hono$1 = class _Hono {
5748
5773
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
5749
5774
  return (request) => {
5750
5775
  const url = new URL(request.url);
5751
- url.pathname = url.pathname.slice(pathPrefixLength) || "/";
5776
+ url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
5752
5777
  return new Request(url, request);
5753
5778
  };
5754
5779
  })();
@@ -5760,11 +5785,11 @@ var Hono$1 = class _Hono {
5760
5785
  this.#addRoute("ALL", mergePath(path, "*"), handler);
5761
5786
  return this;
5762
5787
  }
5763
- #addRoute(method, path, handler) {
5788
+ #addRoute(method, path, handler, baseRoutePath) {
5764
5789
  method = method.toUpperCase();
5765
5790
  path = mergePath(this._basePath, path);
5766
5791
  const r = {
5767
- basePath: this._basePath,
5792
+ basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
5768
5793
  path,
5769
5794
  method,
5770
5795
  handler
@@ -5864,7 +5889,7 @@ var Hono$1 = class _Hono {
5864
5889
  };
5865
5890
  };
5866
5891
  //#endregion
5867
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/matcher.js
5892
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/reg-exp-router/matcher.js
5868
5893
  var emptyParam = [];
5869
5894
  function match(method, path) {
5870
5895
  const matchers = this.buildAllMatchers();
@@ -5881,7 +5906,7 @@ function match(method, path) {
5881
5906
  return match2(method, path);
5882
5907
  }
5883
5908
  //#endregion
5884
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/node.js
5909
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/reg-exp-router/node.js
5885
5910
  var LABEL_REG_EXP_STR = "[^/]+";
5886
5911
  var ONLY_WILDCARD_REG_EXP_STR = ".*";
5887
5912
  var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
@@ -5960,7 +5985,7 @@ var Node$1 = class _Node {
5960
5985
  }
5961
5986
  };
5962
5987
  //#endregion
5963
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/trie.js
5988
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/reg-exp-router/trie.js
5964
5989
  var Trie = class {
5965
5990
  #context = { varIndex: 0 };
5966
5991
  #root = new Node$1();
@@ -6018,7 +6043,7 @@ var Trie = class {
6018
6043
  }
6019
6044
  };
6020
6045
  //#endregion
6021
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/router.js
6046
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/reg-exp-router/router.js
6022
6047
  var nullMatcher = [
6023
6048
  /^$/,
6024
6049
  [],
@@ -6149,7 +6174,7 @@ var RegExpRouter = class {
6149
6174
  }
6150
6175
  };
6151
6176
  //#endregion
6152
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/smart-router/router.js
6177
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/smart-router/router.js
6153
6178
  var SmartRouter = class {
6154
6179
  name = "SmartRouter";
6155
6180
  #routers = [];
@@ -6196,7 +6221,7 @@ var SmartRouter = class {
6196
6221
  }
6197
6222
  };
6198
6223
  //#endregion
6199
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/trie-router/node.js
6224
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/trie-router/node.js
6200
6225
  var emptyParams = /* @__PURE__ */ Object.create(null);
6201
6226
  var hasChildren = (children) => {
6202
6227
  for (const _ in children) return true;
@@ -6319,6 +6344,7 @@ var Node = class _Node {
6319
6344
  if (m) {
6320
6345
  params[name] = m[0];
6321
6346
  this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
6347
+ if (m[0].length === restPathString.length && child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, node.#params, params);
6322
6348
  if (hasChildren(child.#children)) {
6323
6349
  child.#params = params;
6324
6350
  const componentCount = m[0].match(/\//)?.length ?? 0;
@@ -6349,7 +6375,7 @@ var Node = class _Node {
6349
6375
  }
6350
6376
  };
6351
6377
  //#endregion
6352
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/trie-router/router.js
6378
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/trie-router/router.js
6353
6379
  var TrieRouter = class {
6354
6380
  name = "TrieRouter";
6355
6381
  #node;
@@ -6369,7 +6395,7 @@ var TrieRouter = class {
6369
6395
  }
6370
6396
  };
6371
6397
  //#endregion
6372
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/hono.js
6398
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/hono.js
6373
6399
  var Hono = class extends Hono$1 {
6374
6400
  /**
6375
6401
  * Creates an instance of the Hono class.
@@ -6382,7 +6408,7 @@ var Hono = class extends Hono$1 {
6382
6408
  }
6383
6409
  };
6384
6410
  //#endregion
6385
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/utils/encode.js
6411
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/encode.js
6386
6412
  var encodeBase64 = (buf) => {
6387
6413
  let binary = "";
6388
6414
  const bytes = new Uint8Array(buf);
@@ -6400,7 +6426,7 @@ var decodeBase64 = (str) => {
6400
6426
  return bytes;
6401
6427
  };
6402
6428
  //#endregion
6403
- //#region ../../node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/adapter/lambda-edge/handler.js
6429
+ //#region ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/adapter/lambda-edge/handler.js
6404
6430
  globalThis.crypto ??= node_crypto.default;
6405
6431
  var convertHeaders = (headers) => {
6406
6432
  const cfHeaders = {};
@@ -6415,20 +6441,29 @@ var convertHeaders = (headers) => {
6415
6441
  var handle = (app) => {
6416
6442
  return async (event, ...args) => {
6417
6443
  const [context, callback] = args;
6418
- return createResult(await app.fetch(createRequest(event), {
6444
+ let callbackError = null;
6445
+ let callbackResult;
6446
+ const res = await app.fetch(createRequest(event), {
6419
6447
  event,
6420
6448
  context,
6421
6449
  callback: (err, result) => {
6450
+ if (!callbackError && !callbackResult) {
6451
+ callbackError = err;
6452
+ callbackResult = result;
6453
+ }
6422
6454
  callback?.(err, result);
6423
6455
  },
6424
6456
  config: event.Records[0].cf.config,
6425
6457
  request: event.Records[0].cf.request,
6426
6458
  response: event.Records[0].cf.response
6427
- }));
6459
+ });
6460
+ if (callbackError) throw callbackError;
6461
+ return callbackResult ?? createResult(res);
6428
6462
  };
6429
6463
  };
6430
6464
  var createResult = async (res) => {
6431
- const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || "");
6465
+ const contentEncoding = res.headers.get("content-encoding");
6466
+ const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || "") || !!contentEncoding && !/^identity$/i.test(contentEncoding);
6432
6467
  const body = isBase64Encoded ? encodeBase64(await res.arrayBuffer()) : await res.text();
6433
6468
  return {
6434
6469
  status: res.status.toString(),
@@ -6443,11 +6478,17 @@ var createRequest = (event) => {
6443
6478
  const url = queryString ? `${urlPath}?${queryString}` : urlPath;
6444
6479
  const headers = new Headers();
6445
6480
  Object.entries(event.Records[0].cf.request.headers).forEach(([k, v]) => {
6446
- v.forEach((header) => headers.set(k, header.value));
6481
+ v.forEach((header) => headers.append(k, header.value));
6447
6482
  });
6448
6483
  const requestBody = event.Records[0].cf.request.body;
6449
6484
  const method = event.Records[0].cf.request.method;
6450
- const body = createBody(method, requestBody);
6485
+ const rawBody = createBody(method, requestBody);
6486
+ let body = rawBody;
6487
+ if (rawBody !== void 0) {
6488
+ const bytes = typeof rawBody === "string" ? new TextEncoder().encode(rawBody) : rawBody;
6489
+ body = bytes;
6490
+ headers.set("content-length", bytes.length.toString());
6491
+ }
6451
6492
  return new Request(url, {
6452
6493
  headers,
6453
6494
  method,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/aws",
3
3
  "type": "module",
4
- "version": "0.36.4",
4
+ "version": "0.36.6",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -50,10 +50,10 @@
50
50
  "es-toolkit": "^1.32.0",
51
51
  "execa": "9.5.2",
52
52
  "mime": "^4.0.4",
53
- "@hot-updater/core": "0.36.4",
54
- "@hot-updater/js": "0.36.4",
55
- "@hot-updater/test-utils": "0.36.4",
56
- "@hot-updater/mock": "0.36.4"
53
+ "@hot-updater/core": "0.36.6",
54
+ "@hot-updater/js": "0.36.6",
55
+ "@hot-updater/mock": "0.36.6",
56
+ "@hot-updater/test-utils": "0.36.6"
57
57
  },
58
58
  "dependencies": {
59
59
  "@aws-sdk/client-cloudfront": "3.1066.0",
@@ -66,11 +66,11 @@
66
66
  "@aws-sdk/client-sts": "3.1066.0",
67
67
  "@aws-sdk/credential-providers": "3.1066.0",
68
68
  "@aws-sdk/lib-storage": "3.1066.0",
69
- "hono": "4.12.9",
69
+ "hono": "4.12.34",
70
70
  "aws-lambda": "1.0.7",
71
- "@hot-updater/cli-tools": "0.36.4",
72
- "@hot-updater/plugin-core": "0.36.4",
73
- "@hot-updater/server": "0.36.4"
71
+ "@hot-updater/server": "0.36.6",
72
+ "@hot-updater/plugin-core": "0.36.6",
73
+ "@hot-updater/cli-tools": "0.36.6"
74
74
  },
75
75
  "scripts": {
76
76
  "build": "tsdown",