@zuplo/cli 6.70.31 → 6.70.33

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.
Files changed (62) hide show
  1. package/dist/common/middleware/check-pnpm-lifecycle.test.js.map +1 -1
  2. package/node_modules/@zuplo/core/package.json +1 -1
  3. package/node_modules/@zuplo/graphql/package.json +1 -1
  4. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  5. package/node_modules/@zuplo/otel/package.json +1 -1
  6. package/node_modules/@zuplo/runtime/out/esm/{chunk-JAEQKE5H.js → chunk-2VLXJLVI.js} +6 -6
  7. package/node_modules/@zuplo/runtime/out/esm/chunk-2VLXJLVI.js.map +1 -0
  8. package/node_modules/@zuplo/runtime/out/esm/chunk-A2CSR4RF.js +26 -0
  9. package/node_modules/@zuplo/runtime/out/esm/{chunk-F7DJMBWH.js.map → chunk-A2CSR4RF.js.map} +1 -1
  10. package/node_modules/@zuplo/runtime/out/esm/{chunk-TEXCCTJT.js → chunk-SFFHEDT5.js} +68 -68
  11. package/node_modules/@zuplo/runtime/out/esm/{chunk-TEXCCTJT.js.map → chunk-SFFHEDT5.js.map} +1 -1
  12. package/node_modules/@zuplo/runtime/out/esm/chunk-TOF2KNST.js +26 -0
  13. package/node_modules/@zuplo/runtime/out/esm/{chunk-W6JQ5D4W.js.map → chunk-TOF2KNST.js.map} +1 -1
  14. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  15. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  16. package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
  17. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +19 -19
  18. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
  19. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
  20. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js.map +1 -1
  21. package/node_modules/@zuplo/runtime/out/types/index.d.ts +5 -0
  22. package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +5 -0
  23. package/node_modules/@zuplo/runtime/out/types/mocks/index.d.ts +5 -0
  24. package/node_modules/@zuplo/runtime/package.json +1 -1
  25. package/node_modules/hono/dist/cjs/hono-base.js +9 -4
  26. package/node_modules/hono/dist/cjs/middleware/ip-restriction/index.js +58 -28
  27. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +1 -1
  28. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +1 -1
  29. package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
  30. package/node_modules/hono/dist/cjs/utils/ipaddr.js +186 -8
  31. package/node_modules/hono/dist/hono-base.js +9 -4
  32. package/node_modules/hono/dist/middleware/ip-restriction/index.js +60 -29
  33. package/node_modules/hono/dist/middleware/jwk/jwk.js +1 -1
  34. package/node_modules/hono/dist/middleware/jwt/jwt.js +1 -1
  35. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +1 -1
  36. package/node_modules/hono/dist/types/jsx/base.d.ts +2 -2
  37. package/node_modules/hono/dist/types/jsx/index.d.ts +1 -1
  38. package/node_modules/hono/dist/types/utils/ipaddr.d.ts +4 -0
  39. package/node_modules/hono/dist/utils/cookie.js +1 -1
  40. package/node_modules/hono/dist/utils/ipaddr.js +185 -8
  41. package/node_modules/hono/package.json +1 -1
  42. package/node_modules/protobufjs/README.md +1 -1
  43. package/node_modules/protobufjs/dist/light/protobuf.js +8 -6
  44. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  45. package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  46. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  47. package/node_modules/protobufjs/dist/minimal/protobuf.js +2 -2
  48. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
  49. package/node_modules/protobufjs/dist/protobuf.js +8 -6
  50. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  51. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  52. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  53. package/node_modules/protobufjs/index.d.ts +2 -1
  54. package/node_modules/protobufjs/package.json +2 -2
  55. package/node_modules/protobufjs/src/converter.js +5 -3
  56. package/node_modules/protobufjs/src/type.js +1 -1
  57. package/package.json +6 -6
  58. package/node_modules/@zuplo/runtime/out/esm/chunk-F7DJMBWH.js +0 -26
  59. package/node_modules/@zuplo/runtime/out/esm/chunk-JAEQKE5H.js.map +0 -1
  60. package/node_modules/@zuplo/runtime/out/esm/chunk-W6JQ5D4W.js +0 -26
  61. /package/node_modules/@zuplo/runtime/out/esm/{chunk-JAEQKE5H.js.LEGAL.txt → chunk-2VLXJLVI.js.LEGAL.txt} +0 -0
  62. /package/node_modules/@zuplo/runtime/out/esm/{chunk-TEXCCTJT.js.LEGAL.txt → chunk-SFFHEDT5.js.LEGAL.txt} +0 -0
@@ -22,5 +22,5 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{b as d}from"../chunk-F7DJMBWH.js";import{_ as n,a as t}from"../chunk-JAEQKE5H.js";function g(u={request:new Request("https://api.example.com")}){let e=[];function o(i){e.push(Promise.resolve(i))}return t(o,"waitUntil"),{context:new s({event:{waitUntil:o},route:u.route}),invokeResponse:t(async()=>{await Promise.all(e)},"invokeResponse")}}t(g,"createMockContext");var p={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:t(()=>({}),"raw")},s=class extends EventTarget{static{t(this,"MockZuploContext")}#e;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:o=p,parentContext:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:n.console.info,log:n.console.log,debug:n.console.debug,warn:n.console.warn,error:n.console.error,setLogProperties:t(()=>{},"setLogProperties")},this.custom={},this.route=o,this.incomingRequestProperties={asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0},this.parentContext=r,this.#e=e,this.analyticsContext=new d(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,o){throw new Error("Not implemented")}invokeOutboundPolicy(e,o,r){throw new Error("Not implemented")}invokeRoute(e,o){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addEventListener(e,o,r){let l=t(i=>{try{typeof o=="function"?o(i):o.handleEvent(i)}catch(a){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),a}},"wrapped");super.addEventListener(e,l,r)}};export{s as MockZuploContext,g as createMockContext};
25
+ import{b as l}from"../chunk-A2CSR4RF.js";import{a as o,da as n}from"../chunk-2VLXJLVI.js";function g(u={request:new Request("https://api.example.com")}){let e=[];function t(i){e.push(Promise.resolve(i))}return o(t,"waitUntil"),{context:new s({event:{waitUntil:t},route:u.route}),invokeResponse:o(async()=>{await Promise.all(e)},"invokeResponse")}}o(g,"createMockContext");var p={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:o(()=>({}),"raw")},s=class extends EventTarget{static{o(this,"MockZuploContext")}#e;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:t=p,parentContext:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:n.console.info,log:n.console.log,debug:n.console.debug,warn:n.console.warn,error:n.console.error,setLogProperties:o(()=>{},"setLogProperties")},this.custom={},this.route=t,this.incomingRequestProperties={asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0,clientCertFingerprintSha256:void 0,clientCertNotBefore:void 0,clientCertNotAfter:void 0,clientCertIssuerDn:void 0,clientCertSubjectDn:void 0},this.parentContext=r,this.#e=e,this.analyticsContext=new l(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,t){throw new Error("Not implemented")}invokeOutboundPolicy(e,t,r){throw new Error("Not implemented")}invokeRoute(e,t){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addEventListener(e,t,r){let d=o(i=>{try{typeof t=="function"?t(i):t.handleEvent(i)}catch(a){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),a}},"wrapped");super.addEventListener(e,d,r)}};export{s as MockZuploContext,g as createMockContext};
26
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@zuplo/runtime/mocks/context.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;yFA4BO,SAASA,EACdC,EAA6D,CAC3D,QAAS,IAAI,QAAQ,yBAAyB,CAChD,EACA,CACA,IAAMC,EAAwC,CAAC,EAG/C,SAASC,EAAUC,EAA6B,CAC9CF,EAAkB,KAAK,QAAQ,QAAQE,CAAO,CAAC,CACjD,CAFS,OAAAC,EAAAF,EAAA,aAaF,CAAE,QATO,IAAIG,EAAiB,CACnC,MAAO,CAAE,UAAAH,CAAU,EACnB,MAAOF,EAAQ,KACjB,CAAC,EAMiB,eAJKI,EAAA,SAAY,CACjC,MAAM,QAAQ,IAAIH,CAAiB,CACrC,EAFuB,iBAIU,CACnC,CAtBgBG,EAAAL,EAAA,qBAwBhB,IAAMO,EAA2C,CAC/C,KAAM,IACN,QAAS,CAAC,KAAK,EACf,QAAS,CACP,OAAQ,CAAC,EACT,OAAQ,SACV,EACA,IAAKF,EAAA,KAAU,CAAC,GAAX,MACP,EAMaC,EAAN,cAA+B,WAAoC,CAlE1E,MAkE0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AAaA,EAAQE,CAAC,EAAIF,EAAQ,YAAYE,CAAC,CACpE,OAASC,EAAK,CACZ,WAAK,IAAI,MACP,wBAAwBJ,CAAI,mCAC9B,EACMI,CACR,CACF,EAToD,WAUpD,MAAM,iBAAiBJ,EAAME,EAASrB,CAAO,CAC/C,CACF","names":["createMockContext","options","waitUntilPromises","waitUntil","promise","__name","MockZuploContext","DEFAULT_ROUTE_CONFIG","#event","event","route","parentContext","internals_default","ZuploGatewayAnalyticsContext","policyName","request","response","input","init","hook","type","handler","wrapped","e","err"]}
1
+ {"version":3,"sources":["@zuplo/runtime/mocks/context.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;0FA4BO,SAASA,EACdC,EAA6D,CAC3D,QAAS,IAAI,QAAQ,yBAAyB,CAChD,EACA,CACA,IAAMC,EAAwC,CAAC,EAG/C,SAASC,EAAUC,EAA6B,CAC9CF,EAAkB,KAAK,QAAQ,QAAQE,CAAO,CAAC,CACjD,CAFS,OAAAC,EAAAF,EAAA,aAaF,CAAE,QATO,IAAIG,EAAiB,CACnC,MAAO,CAAE,UAAAH,CAAU,EACnB,MAAOF,EAAQ,KACjB,CAAC,EAMiB,eAJKI,EAAA,SAAY,CACjC,MAAM,QAAQ,IAAIH,CAAiB,CACrC,EAFuB,iBAIU,CACnC,CAtBgBG,EAAAL,EAAA,qBAwBhB,IAAMO,EAA2C,CAC/C,KAAM,IACN,QAAS,CAAC,KAAK,EACf,QAAS,CACP,OAAQ,CAAC,EACT,OAAQ,SACV,EACA,IAAKF,EAAA,KAAU,CAAC,GAAX,MACP,EAMaC,EAAN,cAA+B,WAAoC,CAlE1E,MAkE0E,CAAAD,EAAA,yBAC/DG,GACA,UACA,UACA,IACA,MAEA,OACA,0BACA,cACA,iBAET,YAAY,CACV,MAAAC,EACA,MAAAC,EAAQH,EACR,cAAAI,CACF,EAIG,CACD,MAAM,EACN,KAAK,UAAY,OAAO,WAAW,EACnC,KAAK,UAAY,OAAO,WAAW,EAEnC,KAAK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D,MAAM,iBAAiBJ,EAAME,EAASrB,CAAO,CAC/C,CACF","names":["createMockContext","options","waitUntilPromises","waitUntil","promise","__name","MockZuploContext","DEFAULT_ROUTE_CONFIG","#event","event","route","parentContext","internals_default","ZuploGatewayAnalyticsContext","policyName","request","response","input","init","hook","type","handler","wrapped","e","err"]}
@@ -5051,6 +5051,11 @@ declare interface IncomingRequestProperties {
5051
5051
  /* Excluded from this release type: clientCert */
5052
5052
  /* Excluded from this release type: clientMtlsVerificationStatus */
5053
5053
  /* Excluded from this release type: clientMtlsVerificationReason */
5054
+ /* Excluded from this release type: clientCertFingerprintSha256 */
5055
+ /* Excluded from this release type: clientCertNotBefore */
5056
+ /* Excluded from this release type: clientCertNotAfter */
5057
+ /* Excluded from this release type: clientCertIssuerDn */
5058
+ /* Excluded from this release type: clientCertSubjectDn */
5054
5059
  }
5055
5060
 
5056
5061
  /**
@@ -618,6 +618,11 @@ declare interface IncomingRequestProperties {
618
618
  /* Excluded from this release type: clientCert */
619
619
  /* Excluded from this release type: clientMtlsVerificationStatus */
620
620
  /* Excluded from this release type: clientMtlsVerificationReason */
621
+ /* Excluded from this release type: clientCertFingerprintSha256 */
622
+ /* Excluded from this release type: clientCertNotBefore */
623
+ /* Excluded from this release type: clientCertNotAfter */
624
+ /* Excluded from this release type: clientCertIssuerDn */
625
+ /* Excluded from this release type: clientCertSubjectDn */
621
626
  }
622
627
 
623
628
  /**
@@ -549,6 +549,11 @@ declare interface IncomingRequestProperties {
549
549
  /* Excluded from this release type: clientCert */
550
550
  /* Excluded from this release type: clientMtlsVerificationStatus */
551
551
  /* Excluded from this release type: clientMtlsVerificationReason */
552
+ /* Excluded from this release type: clientCertFingerprintSha256 */
553
+ /* Excluded from this release type: clientCertNotBefore */
554
+ /* Excluded from this release type: clientCertNotAfter */
555
+ /* Excluded from this release type: clientCertIssuerDn */
556
+ /* Excluded from this release type: clientCertSubjectDn */
552
557
  }
553
558
 
554
559
  /**
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.70.31",
4
+ "version": "6.70.33",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -139,7 +139,7 @@ class Hono {
139
139
  handler = async (c, next) => (await (0, import_compose.compose)([], app.errorHandler)(c, () => r.handler(c, next))).res;
140
140
  handler[import_constants.COMPOSED_HANDLER] = r.handler;
141
141
  }
142
- subApp.#addRoute(r.method, r.path, handler);
142
+ subApp.#addRoute(r.method, r.path, handler, r.basePath);
143
143
  });
144
144
  return this;
145
145
  }
@@ -263,7 +263,7 @@ class Hono {
263
263
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
264
264
  return (request) => {
265
265
  const url = new URL(request.url);
266
- url.pathname = url.pathname.slice(pathPrefixLength) || "/";
266
+ url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
267
267
  return new Request(url, request);
268
268
  };
269
269
  })();
@@ -277,10 +277,15 @@ class Hono {
277
277
  this.#addRoute(import_router.METHOD_NAME_ALL, (0, import_url.mergePath)(path, "*"), handler);
278
278
  return this;
279
279
  }
280
- #addRoute(method, path, handler) {
280
+ #addRoute(method, path, handler, baseRoutePath) {
281
281
  method = method.toUpperCase();
282
282
  path = (0, import_url.mergePath)(this._basePath, path);
283
- const r = { basePath: this._basePath, path, method, handler };
283
+ const r = {
284
+ basePath: baseRoutePath !== void 0 ? (0, import_url.mergePath)(this._basePath, baseRoutePath) : this._basePath,
285
+ path,
286
+ method,
287
+ handler
288
+ };
284
289
  this.router.add(method, path, [handler, r]);
285
290
  this.routes.push(r);
286
291
  }
@@ -22,11 +22,45 @@ __export(ip_restriction_exports, {
22
22
  module.exports = __toCommonJS(ip_restriction_exports);
23
23
  var import_http_exception = require("../../http-exception");
24
24
  var import_ipaddr = require("../../utils/ipaddr");
25
- const IS_CIDR_NOTATION_REGEX = /\/[0-9]{0,3}$/;
25
+ const IS_CIDR_NOTATION_REGEX = /\/[^/]*$/;
26
+ const parseCidrPrefix = (rule, prefix, max) => {
27
+ if (!/^[0-9]{1,3}$/.test(prefix)) {
28
+ throw new TypeError(`Invalid rule: ${rule}`);
29
+ }
30
+ const parsedPrefix = parseInt(prefix);
31
+ if (parsedPrefix > max) {
32
+ throw new TypeError(`Invalid rule: ${rule}`);
33
+ }
34
+ return parsedPrefix;
35
+ };
26
36
  const buildMatcher = (rules) => {
27
37
  const functionRules = [];
28
38
  const staticRules = /* @__PURE__ */ new Set();
39
+ const staticIPv4Rules = /* @__PURE__ */ new Set();
40
+ const staticIPv6Rules = /* @__PURE__ */ new Set();
29
41
  const cidrRules = [];
42
+ const registerStaticRule = (rule) => {
43
+ const type = (0, import_ipaddr.distinctRemoteAddr)(rule);
44
+ if (type === void 0) {
45
+ throw new TypeError(`Invalid rule: ${rule}`);
46
+ }
47
+ if (type === "IPv4") {
48
+ const ipv4binary = (0, import_ipaddr.convertIPv4ToBinary)(rule);
49
+ staticRules.add(rule);
50
+ staticRules.add(`::ffff:${rule}`);
51
+ staticIPv4Rules.add(ipv4binary);
52
+ staticIPv6Rules.add(0xffffn << 32n | ipv4binary);
53
+ } else {
54
+ const ipv6binary = (0, import_ipaddr.convertIPv6ToBinary)(rule);
55
+ const ipv6Addr = (0, import_ipaddr.convertIPv6BinaryToString)(ipv6binary);
56
+ staticRules.add(ipv6Addr);
57
+ staticIPv6Rules.add(ipv6binary);
58
+ if ((0, import_ipaddr.isIPv4MappedIPv6)(ipv6binary)) {
59
+ staticRules.add(ipv6Addr.substring(7));
60
+ staticIPv4Rules.add((0, import_ipaddr.convertIPv4MappedIPv6ToIPv4)(ipv6binary));
61
+ }
62
+ }
63
+ };
30
64
  for (let rule of rules) {
31
65
  if (rule === "*") {
32
66
  return () => true;
@@ -36,17 +70,17 @@ const buildMatcher = (rules) => {
36
70
  if (IS_CIDR_NOTATION_REGEX.test(rule)) {
37
71
  const separatedRule = rule.split("/");
38
72
  const addrStr = separatedRule[0];
39
- const type2 = (0, import_ipaddr.distinctRemoteAddr)(addrStr);
40
- if (type2 === void 0) {
73
+ const type = (0, import_ipaddr.distinctRemoteAddr)(addrStr);
74
+ if (type === void 0) {
41
75
  throw new TypeError(`Invalid rule: ${rule}`);
42
76
  }
43
- let isIPv4 = type2 === "IPv4";
44
- let prefix = parseInt(separatedRule[1]);
77
+ let isIPv4 = type === "IPv4";
78
+ let prefix = parseCidrPrefix(rule, separatedRule[1], isIPv4 ? 32 : 128);
45
79
  if (isIPv4 ? prefix === 32 : prefix === 128) {
46
80
  rule = addrStr;
47
81
  } else {
48
82
  let addr = (isIPv4 ? import_ipaddr.convertIPv4ToBinary : import_ipaddr.convertIPv6ToBinary)(addrStr);
49
- if (type2 === "IPv6" && (0, import_ipaddr.isIPv4MappedIPv6)(addr) && prefix >= 96) {
83
+ if (type === "IPv6" && (0, import_ipaddr.isIPv4MappedIPv6)(addr) && prefix >= 96) {
50
84
  isIPv4 = true;
51
85
  addr = (0, import_ipaddr.convertIPv4MappedIPv6ToIPv4)(addr);
52
86
  prefix -= 96;
@@ -56,21 +90,7 @@ const buildMatcher = (rules) => {
56
90
  continue;
57
91
  }
58
92
  }
59
- const type = (0, import_ipaddr.distinctRemoteAddr)(rule);
60
- if (type === void 0) {
61
- throw new TypeError(`Invalid rule: ${rule}`);
62
- }
63
- if (type === "IPv4") {
64
- staticRules.add(rule);
65
- staticRules.add(`::ffff:${rule}`);
66
- } else {
67
- const ipv6binary = (0, import_ipaddr.convertIPv6ToBinary)(rule);
68
- const ipv6Addr = (0, import_ipaddr.convertIPv6BinaryToString)(ipv6binary);
69
- staticRules.add(ipv6Addr);
70
- if ((0, import_ipaddr.isIPv4MappedIPv6)(ipv6binary)) {
71
- staticRules.add(ipv6Addr.substring(7));
72
- }
73
- }
93
+ registerStaticRule(rule);
74
94
  }
75
95
  }
76
96
  return (remote) => {
@@ -79,6 +99,9 @@ const buildMatcher = (rules) => {
79
99
  }
80
100
  const remoteAddr = remote.binaryAddr ||= (remote.isIPv4 ? import_ipaddr.convertIPv4ToBinary : import_ipaddr.convertIPv6ToBinary)(remote.addr);
81
101
  const remoteIPv4Addr = remote.isIPv4 || (0, import_ipaddr.isIPv4MappedIPv6)(remoteAddr) ? remote.isIPv4 ? remoteAddr : (0, import_ipaddr.convertIPv4MappedIPv6ToIPv4)(remoteAddr) : void 0;
102
+ if ((remote.isIPv4 ? staticIPv4Rules : staticIPv6Rules).has(remoteAddr)) {
103
+ return true;
104
+ }
82
105
  for (const [isIPv4, addr, mask] of cidrRules) {
83
106
  if (isIPv4) {
84
107
  if (remoteIPv4Addr === void 0) {
@@ -121,14 +144,21 @@ const ipRestriction = (getIP, { denyList = [], allowList = [] }, onError) => {
121
144
  }
122
145
  const type = typeof connInfo !== "string" && connInfo.remote.addressType || (0, import_ipaddr.distinctRemoteAddr)(addr);
123
146
  const remoteData = { addr, type, isIPv4: type === "IPv4" };
124
- if (denyMatcher(remoteData)) {
125
- if (onError) {
126
- return onError({ addr, type }, c);
147
+ try {
148
+ if (denyMatcher(remoteData)) {
149
+ if (onError) {
150
+ return onError({ addr, type }, c);
151
+ }
152
+ throw blockError(c);
127
153
  }
128
- throw blockError(c);
129
- }
130
- if (allowMatcher(remoteData)) {
131
- return await next();
154
+ if (allowMatcher(remoteData)) {
155
+ return await next();
156
+ }
157
+ } catch (e) {
158
+ if (e instanceof TypeError && e.code === import_ipaddr.INVALID_IP_ADDRESS_ERROR_CODE) {
159
+ throw blockError(c);
160
+ }
161
+ throw e;
132
162
  }
133
163
  if (allowLength === 0) {
134
164
  return await next();
@@ -38,7 +38,7 @@ const jwk = (options, init) => {
38
38
  let token;
39
39
  if (credentials) {
40
40
  const parts = credentials.split(/\s+/);
41
- if (parts.length !== 2) {
41
+ if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer") {
42
42
  const errDescription = "invalid credentials structure";
43
43
  throw new import_http_exception.HTTPException(401, {
44
44
  message: errDescription,
@@ -45,7 +45,7 @@ const jwt = (options) => {
45
45
  let token;
46
46
  if (credentials) {
47
47
  const parts = credentials.split(/\s+/);
48
- if (parts.length !== 2) {
48
+ if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer") {
49
49
  const errDescription = "invalid credentials structure";
50
50
  throw new import_http_exception.HTTPException(401, {
51
51
  message: errDescription,
@@ -132,7 +132,7 @@ const _serialize = (name, value, opt = {}) => {
132
132
  throw new Error("__Host- Cookie must not have Domain attributes");
133
133
  }
134
134
  }
135
- for (const key of ["domain", "path"]) {
135
+ for (const key of ["domain", "path", "sameSite", "priority"]) {
136
136
  if (opt[key] && /[;\r\n]/.test(opt[key])) {
137
137
  throw new Error(`${key} must not contain ";", "\\r", or "\\n"`);
138
138
  }
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var ipaddr_exports = {};
19
19
  __export(ipaddr_exports, {
20
+ INVALID_IP_ADDRESS_ERROR_CODE: () => INVALID_IP_ADDRESS_ERROR_CODE,
20
21
  convertIPv4BinaryToString: () => convertIPv4BinaryToString,
21
22
  convertIPv4MappedIPv6ToIPv4: () => convertIPv4MappedIPv6ToIPv4,
22
23
  convertIPv4ToBinary: () => convertIPv4ToBinary,
@@ -50,6 +51,16 @@ const expandIPv6 = (ipV6) => {
50
51
  };
51
52
  const IPV4_OCTET_PART = "(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])";
52
53
  const IPV4_REGEX = new RegExp(`^(?:${IPV4_OCTET_PART}\\.){3}${IPV4_OCTET_PART}$`);
54
+ const INVALID_IP_ADDRESS_ERROR_CODE = "ERR_INVALID_IP_ADDRESS";
55
+ const CHAR_CODE_0 = 48;
56
+ const CHAR_CODE_9 = 57;
57
+ const CHAR_CODE_A = 65;
58
+ const CHAR_CODE_F = 70;
59
+ const CHAR_CODE_a = 97;
60
+ const CHAR_CODE_f = 102;
61
+ const CHAR_CODE_DOT = 46;
62
+ const CHAR_CODE_COLON = 58;
63
+ const CHAR_CODE_PERCENT = 37;
53
64
  const distinctRemoteAddr = (remoteAddr) => {
54
65
  if (IPV4_REGEX.test(remoteAddr)) {
55
66
  return "IPv4";
@@ -58,21 +69,187 @@ const distinctRemoteAddr = (remoteAddr) => {
58
69
  return "IPv6";
59
70
  }
60
71
  };
61
- const convertIPv4ToBinary = (ipv4) => {
62
- const parts = ipv4.split(".");
72
+ const createInvalidIPAddressError = (message) => {
73
+ const error = new TypeError(message);
74
+ error.code = INVALID_IP_ADDRESS_ERROR_CODE;
75
+ return error;
76
+ };
77
+ const throwInvalidIPv4Address = (ipv4) => {
78
+ throw createInvalidIPAddressError(`Invalid IPv4 address: ${ipv4}`);
79
+ };
80
+ const throwInvalidIPv6Address = (ipv6) => {
81
+ throw createInvalidIPAddressError(`Invalid IPv6 address: ${ipv6}`);
82
+ };
83
+ const parseIPv4ToBinary = (ipv4, start, end, onInvalid) => {
63
84
  let result = 0n;
64
- for (let i = 0; i < 4; i++) {
65
- result <<= 8n;
66
- result += BigInt(parts[i]);
85
+ let octets = 0;
86
+ let octet = 0;
87
+ let digits = 0;
88
+ let firstDigit = 0;
89
+ for (let i = start; i <= end; i++) {
90
+ const code = i < end ? ipv4.charCodeAt(i) : CHAR_CODE_DOT;
91
+ if (code >= CHAR_CODE_0 && code <= CHAR_CODE_9) {
92
+ if (digits === 0) {
93
+ firstDigit = code;
94
+ } else if (firstDigit === CHAR_CODE_0) {
95
+ onInvalid();
96
+ }
97
+ octet = octet * 10 + code - CHAR_CODE_0;
98
+ if (octet > 255) {
99
+ onInvalid();
100
+ }
101
+ digits++;
102
+ continue;
103
+ }
104
+ if (code !== CHAR_CODE_DOT || digits === 0 || octets === 4) {
105
+ onInvalid();
106
+ }
107
+ result = (result << 8n) + BigInt(octet);
108
+ octets++;
109
+ octet = 0;
110
+ digits = 0;
111
+ }
112
+ if (octets !== 4) {
113
+ onInvalid();
67
114
  }
68
115
  return result;
69
116
  };
117
+ const parseIPv6HexCode = (code) => {
118
+ if (code >= CHAR_CODE_0 && code <= CHAR_CODE_9) {
119
+ return code - CHAR_CODE_0;
120
+ }
121
+ if (code >= CHAR_CODE_A && code <= CHAR_CODE_F) {
122
+ return code - CHAR_CODE_A + 10;
123
+ }
124
+ if (code >= CHAR_CODE_a && code <= CHAR_CODE_f) {
125
+ return code - CHAR_CODE_a + 10;
126
+ }
127
+ return -1;
128
+ };
129
+ const isIPv6LinkLocal = (ipv6binary) => ipv6binary >> 118n === 0x3fan;
130
+ const convertIPv4ToBinary = (ipv4) => {
131
+ return parseIPv4ToBinary(ipv4, 0, ipv4.length, () => throwInvalidIPv4Address(ipv4));
132
+ };
70
133
  const convertIPv6ToBinary = (ipv6) => {
71
- const sections = expandIPv6(ipv6).split(":");
134
+ const length = ipv6.length;
135
+ const sections = [];
136
+ let hasZoneId = false;
137
+ let compressAt = -1;
138
+ let index = 0;
139
+ if (length === 0) {
140
+ throwInvalidIPv6Address(ipv6);
141
+ }
142
+ while (index < length) {
143
+ if (sections.length > 8) {
144
+ throwInvalidIPv6Address(ipv6);
145
+ }
146
+ let code = ipv6.charCodeAt(index);
147
+ if (code === CHAR_CODE_PERCENT) {
148
+ if (index + 1 === length) {
149
+ throwInvalidIPv6Address(ipv6);
150
+ }
151
+ hasZoneId = true;
152
+ break;
153
+ }
154
+ if (code === CHAR_CODE_COLON) {
155
+ if (index + 1 < length && ipv6.charCodeAt(index + 1) === CHAR_CODE_COLON) {
156
+ if (compressAt !== -1) {
157
+ throwInvalidIPv6Address(ipv6);
158
+ }
159
+ compressAt = sections.length;
160
+ index += 2;
161
+ continue;
162
+ }
163
+ throwInvalidIPv6Address(ipv6);
164
+ }
165
+ let value = 0;
166
+ let digits = 0;
167
+ const sectionStart = index;
168
+ while (index < length) {
169
+ code = ipv6.charCodeAt(index);
170
+ const hex = parseIPv6HexCode(code);
171
+ if (hex === -1) {
172
+ break;
173
+ }
174
+ if (digits === 4) {
175
+ throwInvalidIPv6Address(ipv6);
176
+ }
177
+ value = value << 4 | hex;
178
+ digits++;
179
+ index++;
180
+ }
181
+ if (index < length && ipv6.charCodeAt(index) === CHAR_CODE_DOT) {
182
+ let ipv4End = length;
183
+ for (let i = index; i < length; i++) {
184
+ if (ipv6.charCodeAt(i) === CHAR_CODE_PERCENT) {
185
+ if (i + 1 === length) {
186
+ throwInvalidIPv6Address(ipv6);
187
+ }
188
+ hasZoneId = true;
189
+ ipv4End = i;
190
+ break;
191
+ }
192
+ }
193
+ const ipv4 = parseIPv4ToBinary(
194
+ ipv6,
195
+ sectionStart,
196
+ ipv4End,
197
+ () => throwInvalidIPv6Address(ipv6)
198
+ );
199
+ sections.push(Number(ipv4 >> 16n & 0xffffn), Number(ipv4 & 0xffffn));
200
+ index = length;
201
+ break;
202
+ }
203
+ if (digits === 0) {
204
+ throwInvalidIPv6Address(ipv6);
205
+ }
206
+ sections.push(value);
207
+ if (index === length) {
208
+ break;
209
+ }
210
+ code = ipv6.charCodeAt(index);
211
+ if (code === CHAR_CODE_PERCENT) {
212
+ if (index + 1 === length) {
213
+ throwInvalidIPv6Address(ipv6);
214
+ }
215
+ hasZoneId = true;
216
+ break;
217
+ }
218
+ if (code !== CHAR_CODE_COLON) {
219
+ throwInvalidIPv6Address(ipv6);
220
+ }
221
+ if (index + 1 < length && ipv6.charCodeAt(index + 1) === CHAR_CODE_COLON) {
222
+ if (compressAt !== -1) {
223
+ throwInvalidIPv6Address(ipv6);
224
+ }
225
+ compressAt = sections.length;
226
+ index += 2;
227
+ continue;
228
+ }
229
+ index++;
230
+ if (index === length) {
231
+ throwInvalidIPv6Address(ipv6);
232
+ }
233
+ }
234
+ if (compressAt === -1 ? sections.length !== 8 : sections.length >= 8) {
235
+ throwInvalidIPv6Address(ipv6);
236
+ }
72
237
  let result = 0n;
73
- for (let i = 0; i < 8; i++) {
238
+ const zeros = compressAt === -1 ? 0 : 8 - sections.length;
239
+ const firstSectionEnd = compressAt === -1 ? sections.length : compressAt;
240
+ for (let i = 0; i < firstSectionEnd; i++) {
74
241
  result <<= 16n;
75
- result += BigInt(parseInt(sections[i], 16));
242
+ result += BigInt(sections[i]);
243
+ }
244
+ for (let i = 0; i < zeros; i++) {
245
+ result <<= 16n;
246
+ }
247
+ for (let i = firstSectionEnd; i < sections.length; i++) {
248
+ result <<= 16n;
249
+ result += BigInt(sections[i]);
250
+ }
251
+ if (hasZoneId && !isIPv6LinkLocal(result)) {
252
+ throwInvalidIPv6Address(ipv6);
76
253
  }
77
254
  return result;
78
255
  };
@@ -124,6 +301,7 @@ const convertIPv6BinaryToString = (ipV6) => {
124
301
  };
125
302
  // Annotate the CommonJS export names for ESM import in node:
126
303
  0 && (module.exports = {
304
+ INVALID_IP_ADDRESS_ERROR_CODE,
127
305
  convertIPv4BinaryToString,
128
306
  convertIPv4MappedIPv6ToIPv4,
129
307
  convertIPv4ToBinary,
@@ -118,7 +118,7 @@ var Hono = class _Hono {
118
118
  handler = async (c, next) => (await compose([], app.errorHandler)(c, () => r.handler(c, next))).res;
119
119
  handler[COMPOSED_HANDLER] = r.handler;
120
120
  }
121
- subApp.#addRoute(r.method, r.path, handler);
121
+ subApp.#addRoute(r.method, r.path, handler, r.basePath);
122
122
  });
123
123
  return this;
124
124
  }
@@ -242,7 +242,7 @@ var Hono = class _Hono {
242
242
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
243
243
  return (request) => {
244
244
  const url = new URL(request.url);
245
- url.pathname = url.pathname.slice(pathPrefixLength) || "/";
245
+ url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
246
246
  return new Request(url, request);
247
247
  };
248
248
  })();
@@ -256,10 +256,15 @@ var Hono = class _Hono {
256
256
  this.#addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler);
257
257
  return this;
258
258
  }
259
- #addRoute(method, path, handler) {
259
+ #addRoute(method, path, handler, baseRoutePath) {
260
260
  method = method.toUpperCase();
261
261
  path = mergePath(this._basePath, path);
262
- const r = { basePath: this._basePath, path, method, handler };
262
+ const r = {
263
+ basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
264
+ path,
265
+ method,
266
+ handler
267
+ };
263
268
  this.router.add(method, path, [handler, r]);
264
269
  this.routes.push(r);
265
270
  }