hono 3.12.4 → 3.12.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.
@@ -45,6 +45,10 @@ var import_html = require("./utils/html");
45
45
  var import_stream = require("./utils/stream");
46
46
  var _status, _executionCtx, _headers, _preparedHeaders, _res, _isFresh;
47
47
  const TEXT_PLAIN = "text/plain; charset=UTF-8";
48
+ const setHeaders = (headers, map = {}) => {
49
+ Object.entries(map).forEach(([key, value]) => headers.set(key, value));
50
+ return headers;
51
+ };
48
52
  class Context {
49
53
  constructor(req, options) {
50
54
  this.env = {};
@@ -116,21 +120,21 @@ class Context {
116
120
  });
117
121
  }
118
122
  if (arg && typeof arg !== "number") {
119
- this.res = new Response(data, arg);
123
+ const headers2 = setHeaders(new Headers(arg.headers), __privateGet(this, _preparedHeaders));
124
+ return new Response(data, {
125
+ headers: headers2,
126
+ status: arg.status
127
+ });
120
128
  }
121
- const status = typeof arg === "number" ? arg : arg ? arg.status : __privateGet(this, _status);
129
+ const status = typeof arg === "number" ? arg : __privateGet(this, _status);
122
130
  __privateGet(this, _preparedHeaders) ?? __privateSet(this, _preparedHeaders, {});
123
131
  __privateGet(this, _headers) ?? __privateSet(this, _headers, new Headers());
124
- for (const [k, v] of Object.entries(__privateGet(this, _preparedHeaders))) {
125
- __privateGet(this, _headers).set(k, v);
126
- }
132
+ setHeaders(__privateGet(this, _headers), __privateGet(this, _preparedHeaders));
127
133
  if (__privateGet(this, _res)) {
128
134
  __privateGet(this, _res).headers.forEach((v, k) => {
129
135
  __privateGet(this, _headers)?.set(k, v);
130
136
  });
131
- for (const [k, v] of Object.entries(__privateGet(this, _preparedHeaders))) {
132
- __privateGet(this, _headers).set(k, v);
133
- }
137
+ setHeaders(__privateGet(this, _headers), __privateGet(this, _preparedHeaders));
134
138
  }
135
139
  headers ?? (headers = {});
136
140
  for (const [k, v] of Object.entries(headers)) {
@@ -54,16 +54,10 @@ const basicAuth = (options, ...users) => {
54
54
  const requestUser = auth(ctx.req);
55
55
  if (requestUser) {
56
56
  for (const user of users) {
57
- const usernameEqual = await (0, import_buffer.timingSafeEqual)(
58
- user.username,
59
- requestUser.username,
60
- options.hashFunction
61
- );
62
- const passwordEqual = await (0, import_buffer.timingSafeEqual)(
63
- user.password,
64
- requestUser.password,
65
- options.hashFunction
66
- );
57
+ const [usernameEqual, passwordEqual] = await Promise.all([
58
+ (0, import_buffer.timingSafeEqual)(user.username, requestUser.username, options.hashFunction),
59
+ (0, import_buffer.timingSafeEqual)(user.password, requestUser.password, options.hashFunction)
60
+ ]);
67
61
  if (usernameEqual && passwordEqual) {
68
62
  await next();
69
63
  return;
@@ -42,21 +42,20 @@ const cache = (options) => {
42
42
  const key = c.req.url;
43
43
  const cache3 = await caches.open(options.cacheName);
44
44
  const response = await cache3.match(key);
45
- if (!response) {
46
- await next();
47
- if (!c.res.ok) {
48
- return;
49
- }
50
- addHeader(c);
51
- const response2 = c.res.clone();
52
- if (options.wait) {
53
- await cache3.put(key, response2);
54
- } else {
55
- c.executionCtx.waitUntil(cache3.put(key, response2));
56
- }
57
- } else {
45
+ if (response) {
58
46
  return new Response(response.body, response);
59
47
  }
48
+ await next();
49
+ if (!c.res.ok) {
50
+ return;
51
+ }
52
+ addHeader(c);
53
+ const res = c.res.clone();
54
+ if (options.wait) {
55
+ await cache3.put(key, res);
56
+ } else {
57
+ c.executionCtx.waitUntil(cache3.put(key, res));
58
+ }
60
59
  };
61
60
  };
62
61
  // Annotate the CommonJS export names for ESM import in node:
@@ -58,9 +58,7 @@ const cors = (options) => {
58
58
  if (opts.exposeHeaders?.length) {
59
59
  set("Access-Control-Expose-Headers", opts.exposeHeaders.join(","));
60
60
  }
61
- if (c.req.method !== "OPTIONS") {
62
- await next();
63
- } else {
61
+ if (c.req.method === "OPTIONS") {
64
62
  if (opts.maxAge != null) {
65
63
  set("Access-Control-Max-Age", opts.maxAge.toString());
66
64
  }
@@ -86,6 +84,7 @@ const cors = (options) => {
86
84
  statusText: c.res.statusText
87
85
  });
88
86
  }
87
+ await next();
89
88
  };
90
89
  };
91
90
  // Annotate the CommonJS export names for ESM import in node:
@@ -40,13 +40,13 @@ const jwt = (options) => {
40
40
  if (credentials) {
41
41
  const parts = credentials.split(/\s+/);
42
42
  if (parts.length !== 2) {
43
- const res = new Response("Unauthorized", {
44
- status: 401,
45
- headers: {
46
- "WWW-Authenticate": `Bearer realm="${ctx.req.url}",error="invalid_request",error_description="invalid credentials structure"`
47
- }
43
+ throw new import_http_exception.HTTPException(401, {
44
+ res: unauthorizedResponse({
45
+ ctx,
46
+ error: "invalid_request",
47
+ errDescription: "invalid credentials structure"
48
+ })
48
49
  });
49
- throw new import_http_exception.HTTPException(401, { res });
50
50
  } else {
51
51
  token = parts[1];
52
52
  }
@@ -54,13 +54,13 @@ const jwt = (options) => {
54
54
  token = ctx.req.cookie(options.cookie);
55
55
  }
56
56
  if (!token) {
57
- const res = new Response("Unauthorized", {
58
- status: 401,
59
- headers: {
60
- "WWW-Authenticate": `Bearer realm="${ctx.req.url}",error="invalid_request",error_description="no authorization included in request"`
61
- }
57
+ throw new import_http_exception.HTTPException(401, {
58
+ res: unauthorizedResponse({
59
+ ctx,
60
+ error: "invalid_request",
61
+ errDescription: "no authorization included in request"
62
+ })
62
63
  });
63
- throw new import_http_exception.HTTPException(401, { res });
64
64
  }
65
65
  let payload;
66
66
  let msg = "";
@@ -70,19 +70,28 @@ const jwt = (options) => {
70
70
  msg = `${e}`;
71
71
  }
72
72
  if (!payload) {
73
- const res = new Response("Unauthorized", {
74
- status: 401,
75
- statusText: msg,
76
- headers: {
77
- "WWW-Authenticate": `Bearer realm="${ctx.req.url}",error="invalid_token",error_description="token verification failure"`
78
- }
73
+ throw new import_http_exception.HTTPException(401, {
74
+ res: unauthorizedResponse({
75
+ ctx,
76
+ error: "invalid_token",
77
+ statusText: msg,
78
+ errDescription: "token verification failure"
79
+ })
79
80
  });
80
- throw new import_http_exception.HTTPException(401, { res });
81
81
  }
82
82
  ctx.set("jwtPayload", payload);
83
83
  await next();
84
84
  };
85
85
  };
86
+ function unauthorizedResponse(opts) {
87
+ return new Response("Unauthorized", {
88
+ status: 401,
89
+ statusText: opts.statusText,
90
+ headers: {
91
+ "WWW-Authenticate": `Bearer realm="${opts.ctx.req.url}",error="${opts.error}",error_description="${opts.errDescription}"`
92
+ }
93
+ });
94
+ }
86
95
  const verify = import_jwt.Jwt.verify;
87
96
  const decode = import_jwt.Jwt.decode;
88
97
  const sign = import_jwt.Jwt.sign;
@@ -70,7 +70,7 @@ class Node {
70
70
  const m = {};
71
71
  const handlerSet = {
72
72
  handler,
73
- possibleKeys,
73
+ possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
74
74
  name: this.name,
75
75
  score: this.order
76
76
  };
@@ -78,15 +78,18 @@ class Node {
78
78
  curNode.methods.push(m);
79
79
  return curNode;
80
80
  }
81
- gHSets(node, method, params) {
81
+ gHSets(node, method, nodeParams, params) {
82
82
  const handlerSets = [];
83
83
  for (let i = 0, len = node.methods.length; i < len; i++) {
84
84
  const m = node.methods[i];
85
85
  const handlerSet = m[method] || m[import_router.METHOD_NAME_ALL];
86
+ const processedSet = {};
86
87
  if (handlerSet !== void 0) {
87
88
  handlerSet.params = {};
88
- handlerSet.possibleKeys.map((key) => {
89
- handlerSet.params[key] = params[key];
89
+ handlerSet.possibleKeys.forEach((key) => {
90
+ const processed = processedSet[handlerSet.name];
91
+ handlerSet.params[key] = params[key] && !processed ? params[key] : nodeParams[key] ?? params[key];
92
+ processedSet[handlerSet.name] = true;
90
93
  });
91
94
  handlerSets.push(handlerSet);
92
95
  }
@@ -96,6 +99,7 @@ class Node {
96
99
  search(method, path) {
97
100
  const handlerSets = [];
98
101
  this.params = {};
102
+ const params = {};
99
103
  const curNode = this;
100
104
  let curNodes = [curNode];
101
105
  const parts = (0, import_url.splitPath)(path);
@@ -110,20 +114,19 @@ class Node {
110
114
  nextNode.params = node.params;
111
115
  if (isLast === true) {
112
116
  if (nextNode.children["*"]) {
113
- handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params));
117
+ handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params, {}));
114
118
  }
115
- handlerSets.push(...this.gHSets(nextNode, method, node.params));
119
+ handlerSets.push(...this.gHSets(nextNode, method, node.params, {}));
116
120
  } else {
117
121
  tempNodes.push(nextNode);
118
122
  }
119
123
  }
120
124
  for (let k = 0, len3 = node.patterns.length; k < len3; k++) {
121
- const params = {};
122
125
  const pattern = node.patterns[k];
123
126
  if (pattern === "*") {
124
127
  const astNode = node.children["*"];
125
128
  if (astNode) {
126
- handlerSets.push(...this.gHSets(astNode, method, node.params));
129
+ handlerSets.push(...this.gHSets(astNode, method, node.params, {}));
127
130
  tempNodes.push(astNode);
128
131
  }
129
132
  continue;
@@ -135,18 +138,16 @@ class Node {
135
138
  const restPathString = parts.slice(i).join("/");
136
139
  if (matcher instanceof RegExp && matcher.test(restPathString)) {
137
140
  params[name] = restPathString;
138
- handlerSets.push(...this.gHSets(child, method, { ...params, ...node.params }));
141
+ handlerSets.push(...this.gHSets(child, method, node.params, params));
139
142
  continue;
140
143
  }
141
144
  if (matcher === true || matcher instanceof RegExp && matcher.test(part)) {
142
145
  if (typeof key === "string") {
143
146
  params[name] = part;
144
147
  if (isLast === true) {
145
- handlerSets.push(...this.gHSets(child, method, { ...params, ...node.params }));
148
+ handlerSets.push(...this.gHSets(child, method, params, node.params));
146
149
  if (child.children["*"]) {
147
- handlerSets.push(
148
- ...this.gHSets(child.children["*"], method, { ...params, ...node.params })
149
- );
150
+ handlerSets.push(...this.gHSets(child.children["*"], method, node.params, params));
150
151
  }
151
152
  } else {
152
153
  child.params = { ...params };
@@ -161,7 +162,7 @@ class Node {
161
162
  const results = handlerSets.sort((a, b) => {
162
163
  return a.score - b.score;
163
164
  });
164
- return [results.map(({ handler, params }) => [handler, params])];
165
+ return [results.map(({ handler, params: params2 }) => [handler, params2])];
165
166
  }
166
167
  }
167
168
  // Annotate the CommonJS export names for ESM import in node:
package/dist/context.js CHANGED
@@ -22,6 +22,10 @@ import { serialize } from "./utils/cookie.js";
22
22
  import { resolveCallback, HtmlEscapedCallbackPhase } from "./utils/html.js";
23
23
  import { StreamingApi } from "./utils/stream.js";
24
24
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
25
+ var setHeaders = (headers, map = {}) => {
26
+ Object.entries(map).forEach(([key, value]) => headers.set(key, value));
27
+ return headers;
28
+ };
25
29
  var _status, _executionCtx, _headers, _preparedHeaders, _res, _isFresh;
26
30
  var Context = class {
27
31
  constructor(req, options) {
@@ -94,21 +98,21 @@ var Context = class {
94
98
  });
95
99
  }
96
100
  if (arg && typeof arg !== "number") {
97
- this.res = new Response(data, arg);
101
+ const headers2 = setHeaders(new Headers(arg.headers), __privateGet(this, _preparedHeaders));
102
+ return new Response(data, {
103
+ headers: headers2,
104
+ status: arg.status
105
+ });
98
106
  }
99
- const status = typeof arg === "number" ? arg : arg ? arg.status : __privateGet(this, _status);
107
+ const status = typeof arg === "number" ? arg : __privateGet(this, _status);
100
108
  __privateGet(this, _preparedHeaders) ?? __privateSet(this, _preparedHeaders, {});
101
109
  __privateGet(this, _headers) ?? __privateSet(this, _headers, new Headers());
102
- for (const [k, v] of Object.entries(__privateGet(this, _preparedHeaders))) {
103
- __privateGet(this, _headers).set(k, v);
104
- }
110
+ setHeaders(__privateGet(this, _headers), __privateGet(this, _preparedHeaders));
105
111
  if (__privateGet(this, _res)) {
106
112
  __privateGet(this, _res).headers.forEach((v, k) => {
107
113
  __privateGet(this, _headers)?.set(k, v);
108
114
  });
109
- for (const [k, v] of Object.entries(__privateGet(this, _preparedHeaders))) {
110
- __privateGet(this, _headers).set(k, v);
111
- }
115
+ setHeaders(__privateGet(this, _headers), __privateGet(this, _preparedHeaders));
112
116
  }
113
117
  headers ?? (headers = {});
114
118
  for (const [k, v] of Object.entries(headers)) {
@@ -32,16 +32,10 @@ var basicAuth = (options, ...users) => {
32
32
  const requestUser = auth(ctx.req);
33
33
  if (requestUser) {
34
34
  for (const user of users) {
35
- const usernameEqual = await timingSafeEqual(
36
- user.username,
37
- requestUser.username,
38
- options.hashFunction
39
- );
40
- const passwordEqual = await timingSafeEqual(
41
- user.password,
42
- requestUser.password,
43
- options.hashFunction
44
- );
35
+ const [usernameEqual, passwordEqual] = await Promise.all([
36
+ timingSafeEqual(user.username, requestUser.username, options.hashFunction),
37
+ timingSafeEqual(user.password, requestUser.password, options.hashFunction)
38
+ ]);
45
39
  if (usernameEqual && passwordEqual) {
46
40
  await next();
47
41
  return;
@@ -20,21 +20,20 @@ var cache = (options) => {
20
20
  const key = c.req.url;
21
21
  const cache3 = await caches.open(options.cacheName);
22
22
  const response = await cache3.match(key);
23
- if (!response) {
24
- await next();
25
- if (!c.res.ok) {
26
- return;
27
- }
28
- addHeader(c);
29
- const response2 = c.res.clone();
30
- if (options.wait) {
31
- await cache3.put(key, response2);
32
- } else {
33
- c.executionCtx.waitUntil(cache3.put(key, response2));
34
- }
35
- } else {
23
+ if (response) {
36
24
  return new Response(response.body, response);
37
25
  }
26
+ await next();
27
+ if (!c.res.ok) {
28
+ return;
29
+ }
30
+ addHeader(c);
31
+ const res = c.res.clone();
32
+ if (options.wait) {
33
+ await cache3.put(key, res);
34
+ } else {
35
+ c.executionCtx.waitUntil(cache3.put(key, res));
36
+ }
38
37
  };
39
38
  };
40
39
  export {
@@ -36,9 +36,7 @@ var cors = (options) => {
36
36
  if (opts.exposeHeaders?.length) {
37
37
  set("Access-Control-Expose-Headers", opts.exposeHeaders.join(","));
38
38
  }
39
- if (c.req.method !== "OPTIONS") {
40
- await next();
41
- } else {
39
+ if (c.req.method === "OPTIONS") {
42
40
  if (opts.maxAge != null) {
43
41
  set("Access-Control-Max-Age", opts.maxAge.toString());
44
42
  }
@@ -64,6 +62,7 @@ var cors = (options) => {
64
62
  statusText: c.res.statusText
65
63
  });
66
64
  }
65
+ await next();
67
66
  };
68
67
  };
69
68
  export {
@@ -15,13 +15,13 @@ var jwt = (options) => {
15
15
  if (credentials) {
16
16
  const parts = credentials.split(/\s+/);
17
17
  if (parts.length !== 2) {
18
- const res = new Response("Unauthorized", {
19
- status: 401,
20
- headers: {
21
- "WWW-Authenticate": `Bearer realm="${ctx.req.url}",error="invalid_request",error_description="invalid credentials structure"`
22
- }
18
+ throw new HTTPException(401, {
19
+ res: unauthorizedResponse({
20
+ ctx,
21
+ error: "invalid_request",
22
+ errDescription: "invalid credentials structure"
23
+ })
23
24
  });
24
- throw new HTTPException(401, { res });
25
25
  } else {
26
26
  token = parts[1];
27
27
  }
@@ -29,13 +29,13 @@ var jwt = (options) => {
29
29
  token = ctx.req.cookie(options.cookie);
30
30
  }
31
31
  if (!token) {
32
- const res = new Response("Unauthorized", {
33
- status: 401,
34
- headers: {
35
- "WWW-Authenticate": `Bearer realm="${ctx.req.url}",error="invalid_request",error_description="no authorization included in request"`
36
- }
32
+ throw new HTTPException(401, {
33
+ res: unauthorizedResponse({
34
+ ctx,
35
+ error: "invalid_request",
36
+ errDescription: "no authorization included in request"
37
+ })
37
38
  });
38
- throw new HTTPException(401, { res });
39
39
  }
40
40
  let payload;
41
41
  let msg = "";
@@ -45,19 +45,28 @@ var jwt = (options) => {
45
45
  msg = `${e}`;
46
46
  }
47
47
  if (!payload) {
48
- const res = new Response("Unauthorized", {
49
- status: 401,
50
- statusText: msg,
51
- headers: {
52
- "WWW-Authenticate": `Bearer realm="${ctx.req.url}",error="invalid_token",error_description="token verification failure"`
53
- }
48
+ throw new HTTPException(401, {
49
+ res: unauthorizedResponse({
50
+ ctx,
51
+ error: "invalid_token",
52
+ statusText: msg,
53
+ errDescription: "token verification failure"
54
+ })
54
55
  });
55
- throw new HTTPException(401, { res });
56
56
  }
57
57
  ctx.set("jwtPayload", payload);
58
58
  await next();
59
59
  };
60
60
  };
61
+ function unauthorizedResponse(opts) {
62
+ return new Response("Unauthorized", {
63
+ status: 401,
64
+ statusText: opts.statusText,
65
+ headers: {
66
+ "WWW-Authenticate": `Bearer realm="${opts.ctx.req.url}",error="${opts.error}",error_description="${opts.errDescription}"`
67
+ }
68
+ });
69
+ }
61
70
  var verify = Jwt.verify;
62
71
  var decode = Jwt.decode;
63
72
  var sign = Jwt.sign;
@@ -48,7 +48,7 @@ var Node = class {
48
48
  const m = {};
49
49
  const handlerSet = {
50
50
  handler,
51
- possibleKeys,
51
+ possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
52
52
  name: this.name,
53
53
  score: this.order
54
54
  };
@@ -56,15 +56,18 @@ var Node = class {
56
56
  curNode.methods.push(m);
57
57
  return curNode;
58
58
  }
59
- gHSets(node, method, params) {
59
+ gHSets(node, method, nodeParams, params) {
60
60
  const handlerSets = [];
61
61
  for (let i = 0, len = node.methods.length; i < len; i++) {
62
62
  const m = node.methods[i];
63
63
  const handlerSet = m[method] || m[METHOD_NAME_ALL];
64
+ const processedSet = {};
64
65
  if (handlerSet !== void 0) {
65
66
  handlerSet.params = {};
66
- handlerSet.possibleKeys.map((key) => {
67
- handlerSet.params[key] = params[key];
67
+ handlerSet.possibleKeys.forEach((key) => {
68
+ const processed = processedSet[handlerSet.name];
69
+ handlerSet.params[key] = params[key] && !processed ? params[key] : nodeParams[key] ?? params[key];
70
+ processedSet[handlerSet.name] = true;
68
71
  });
69
72
  handlerSets.push(handlerSet);
70
73
  }
@@ -74,6 +77,7 @@ var Node = class {
74
77
  search(method, path) {
75
78
  const handlerSets = [];
76
79
  this.params = {};
80
+ const params = {};
77
81
  const curNode = this;
78
82
  let curNodes = [curNode];
79
83
  const parts = splitPath(path);
@@ -88,20 +92,19 @@ var Node = class {
88
92
  nextNode.params = node.params;
89
93
  if (isLast === true) {
90
94
  if (nextNode.children["*"]) {
91
- handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params));
95
+ handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params, {}));
92
96
  }
93
- handlerSets.push(...this.gHSets(nextNode, method, node.params));
97
+ handlerSets.push(...this.gHSets(nextNode, method, node.params, {}));
94
98
  } else {
95
99
  tempNodes.push(nextNode);
96
100
  }
97
101
  }
98
102
  for (let k = 0, len3 = node.patterns.length; k < len3; k++) {
99
- const params = {};
100
103
  const pattern = node.patterns[k];
101
104
  if (pattern === "*") {
102
105
  const astNode = node.children["*"];
103
106
  if (astNode) {
104
- handlerSets.push(...this.gHSets(astNode, method, node.params));
107
+ handlerSets.push(...this.gHSets(astNode, method, node.params, {}));
105
108
  tempNodes.push(astNode);
106
109
  }
107
110
  continue;
@@ -113,18 +116,16 @@ var Node = class {
113
116
  const restPathString = parts.slice(i).join("/");
114
117
  if (matcher instanceof RegExp && matcher.test(restPathString)) {
115
118
  params[name] = restPathString;
116
- handlerSets.push(...this.gHSets(child, method, { ...params, ...node.params }));
119
+ handlerSets.push(...this.gHSets(child, method, node.params, params));
117
120
  continue;
118
121
  }
119
122
  if (matcher === true || matcher instanceof RegExp && matcher.test(part)) {
120
123
  if (typeof key === "string") {
121
124
  params[name] = part;
122
125
  if (isLast === true) {
123
- handlerSets.push(...this.gHSets(child, method, { ...params, ...node.params }));
126
+ handlerSets.push(...this.gHSets(child, method, params, node.params));
124
127
  if (child.children["*"]) {
125
- handlerSets.push(
126
- ...this.gHSets(child.children["*"], method, { ...params, ...node.params })
127
- );
128
+ handlerSets.push(...this.gHSets(child.children["*"], method, node.params, params));
128
129
  }
129
130
  } else {
130
131
  child.params = { ...params };
@@ -139,7 +140,7 @@ var Node = class {
139
140
  const results = handlerSets.sort((a, b) => {
140
141
  return a.score - b.score;
141
142
  });
142
- return [results.map(({ handler, params }) => [handler, params])];
143
+ return [results.map(({ handler, params: params2 }) => [handler, params2])];
143
144
  }
144
145
  };
145
146
  export {
@@ -16,6 +16,20 @@ interface CloudFrontCustomOrigin {
16
16
  readTimeout: number;
17
17
  sslProtocols: string[];
18
18
  }
19
+ interface CloudFrontS3Origin {
20
+ authMethod: 'origin-access-identity' | 'none';
21
+ customHeaders: CloudFrontHeaders;
22
+ domainName: string;
23
+ path: string;
24
+ region: string;
25
+ }
26
+ type CloudFrontOrigin = {
27
+ s3: CloudFrontS3Origin;
28
+ custom?: never;
29
+ } | {
30
+ custom: CloudFrontCustomOrigin;
31
+ s3?: never;
32
+ };
19
33
  export interface CloudFrontRequest {
20
34
  clientIp: string;
21
35
  headers: CloudFrontHeaders;
@@ -28,9 +42,7 @@ export interface CloudFrontRequest {
28
42
  encoding: string;
29
43
  data: string;
30
44
  };
31
- origin?: {
32
- custom: CloudFrontCustomOrigin;
33
- };
45
+ origin?: CloudFrontOrigin;
34
46
  }
35
47
  export interface CloudFrontResponse {
36
48
  headers: CloudFrontHeaders;
@@ -152,7 +152,73 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
152
152
  <P extends string, I extends Input = {}, R extends HandlerResponse<any> = any>(path: P, ...handlers: H<E, MergePath<BasePath, P>, I, R>[]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I['in'], MergeTypedResponseData<R>>, BasePath>;
153
153
  }
154
154
  export interface MiddlewareHandlerInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {
155
- <E2 extends Env = E>(...handlers: MiddlewareHandler<E2, MergePath<BasePath, ExtractKey<S>>>[]): Hono<E, S, BasePath>;
155
+ <E2 extends Env = E>(...handlers: MiddlewareHandler<E2, MergePath<BasePath, ExtractKey<S>>>[]): Hono<IntersectNonAnyTypes<[E, E2]>, S, BasePath>;
156
+ <E2 extends Env = E>(handler: MiddlewareHandler<E2, MergePath<BasePath, ExtractKey<S>>>): Hono<IntersectNonAnyTypes<[E, E2]>, S, BasePath>;
157
+ <E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>, P extends string = MergePath<BasePath, ExtractKey<S>>>(...handlers: [MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>]): Hono<IntersectNonAnyTypes<[E, E2, E3]>, S, BasePath>;
158
+ <E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>, P extends string = MergePath<BasePath, ExtractKey<S>>>(...handlers: [MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4]>, S, BasePath>;
159
+ <E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>, P extends string = MergePath<BasePath, ExtractKey<S>>>(...handlers: [
160
+ MiddlewareHandler<E2, P>,
161
+ MiddlewareHandler<E3, P>,
162
+ MiddlewareHandler<E4, P>,
163
+ MiddlewareHandler<E5, P>
164
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, S, BasePath>;
165
+ <E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, P extends string = MergePath<BasePath, ExtractKey<S>>>(...handlers: [
166
+ MiddlewareHandler<E2, P>,
167
+ MiddlewareHandler<E3, P>,
168
+ MiddlewareHandler<E4, P>,
169
+ MiddlewareHandler<E5, P>,
170
+ MiddlewareHandler<E6, P>
171
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, S, BasePath>;
172
+ <E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, P extends string = MergePath<BasePath, ExtractKey<S>>>(...handlers: [
173
+ MiddlewareHandler<E2, P>,
174
+ MiddlewareHandler<E3, P>,
175
+ MiddlewareHandler<E4, P>,
176
+ MiddlewareHandler<E5, P>,
177
+ MiddlewareHandler<E6, P>,
178
+ MiddlewareHandler<E7, P>
179
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, S, BasePath>;
180
+ <E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, P extends string = MergePath<BasePath, ExtractKey<S>>>(...handlers: [
181
+ MiddlewareHandler<E2, P>,
182
+ MiddlewareHandler<E3, P>,
183
+ MiddlewareHandler<E4, P>,
184
+ MiddlewareHandler<E5, P>,
185
+ MiddlewareHandler<E6, P>,
186
+ MiddlewareHandler<E7, P>,
187
+ MiddlewareHandler<E8, P>
188
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, S, BasePath>;
189
+ <E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, P extends string = MergePath<BasePath, ExtractKey<S>>>(...handlers: [
190
+ MiddlewareHandler<E2, P>,
191
+ MiddlewareHandler<E3, P>,
192
+ MiddlewareHandler<E4, P>,
193
+ MiddlewareHandler<E5, P>,
194
+ MiddlewareHandler<E6, P>,
195
+ MiddlewareHandler<E7, P>,
196
+ MiddlewareHandler<E8, P>,
197
+ MiddlewareHandler<E9, P>
198
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, S, BasePath>;
199
+ <E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = E, E10 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, P extends string = MergePath<BasePath, ExtractKey<S>>>(...handlers: [
200
+ MiddlewareHandler<E2, P>,
201
+ MiddlewareHandler<E3, P>,
202
+ MiddlewareHandler<E4, P>,
203
+ MiddlewareHandler<E5, P>,
204
+ MiddlewareHandler<E6, P>,
205
+ MiddlewareHandler<E7, P>,
206
+ MiddlewareHandler<E8, P>,
207
+ MiddlewareHandler<E9, P>,
208
+ MiddlewareHandler<E10, P>
209
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>, S, BasePath>;
210
+ <E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = E, E10 extends Env = E, E11 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>, P extends string = MergePath<BasePath, ExtractKey<S>>>(...handlers: [
211
+ MiddlewareHandler<E2, P>,
212
+ MiddlewareHandler<E3, P>,
213
+ MiddlewareHandler<E4, P>,
214
+ MiddlewareHandler<E5, P>,
215
+ MiddlewareHandler<E6, P>,
216
+ MiddlewareHandler<E7, P>,
217
+ MiddlewareHandler<E8, P>,
218
+ MiddlewareHandler<E9, P>,
219
+ MiddlewareHandler<E10, P>,
220
+ MiddlewareHandler<E11, P>
221
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]>, S, BasePath>;
156
222
  <P extends string, E2 extends Env = E>(path: P, ...handlers: MiddlewareHandler<E2, MergePath<BasePath, P>>[]): Hono<E, S, BasePath>;
157
223
  }
158
224
  export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "3.12.4",
3
+ "version": "3.12.6",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",
@@ -11,6 +11,7 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "test": "tsc --noEmit && vitest --run",
14
+ "test:watch": "vitest --watch",
14
15
  "test:deno": "env NAME=Deno deno test --allow-read --allow-env runtime_tests/deno && deno test --no-lock -c runtime_tests/deno-jsx/deno.precompile.json runtime_tests/deno-jsx && deno test --no-lock -c runtime_tests/deno-jsx/deno.react-jsx.json runtime_tests/deno-jsx",
15
16
  "test:bun": "env NAME=Bun bun test --jsx-import-source ../../src/jsx runtime_tests/bun/index.test.tsx",
16
17
  "test:fastly": "vitest --run --config ./runtime_tests/fastly/vitest.config.ts",