@suveren/gateway 0.7.4 → 0.7.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.
Files changed (171) hide show
  1. package/dist/control-plane/index.mjs +248 -58
  2. package/dist/mcp-server/http.mjs +408 -65
  3. package/dist/ui/assets/{index-CkWaRck1.css → index-BYVb_0oG.css} +1 -1
  4. package/dist/ui/assets/index-CsrM6RQr.js +110 -0
  5. package/dist/ui/index.html +2 -2
  6. package/node_modules/@hap/core/dist/index.d.mts +258 -9
  7. package/node_modules/@hap/core/dist/index.d.ts +258 -9
  8. package/node_modules/@hap/core/dist/index.js +227 -5
  9. package/node_modules/@hap/core/dist/index.mjs +213 -4
  10. package/node_modules/@hap/core/package.json +3 -2
  11. package/node_modules/@hap/core/src/did-key.ts +126 -0
  12. package/node_modules/@hap/core/src/identity.ts +21 -5
  13. package/node_modules/@hap/core/src/index.ts +3 -0
  14. package/node_modules/@hap/core/src/mandate.ts +207 -0
  15. package/node_modules/@hap/core/src/receipt.ts +74 -0
  16. package/node_modules/@hap/core/src/types.ts +81 -5
  17. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/accept.js +54 -0
  18. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/charset.js +10 -34
  19. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/encoding.js +9 -30
  20. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/language.js +15 -36
  21. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/mediaType.js +16 -134
  22. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
  23. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/README.md +71 -0
  24. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
  25. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
  26. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
  27. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/package.json +52 -0
  28. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/package.json +16 -10
  29. package/node_modules/@types/node/README.md +1 -1
  30. package/node_modules/@types/node/buffer.buffer.d.ts +5 -5
  31. package/node_modules/@types/node/crypto.d.ts +2 -2
  32. package/node_modules/@types/node/http.d.ts +16 -0
  33. package/node_modules/@types/node/http2.d.ts +10 -2
  34. package/node_modules/@types/node/package.json +2 -2
  35. package/node_modules/@types/node/process.d.ts +52 -0
  36. package/node_modules/@types/node/quic.d.ts +210 -28
  37. package/node_modules/@types/node/sqlite.d.ts +6 -2
  38. package/node_modules/@types/node/test.d.ts +36 -0
  39. package/node_modules/fast-uri/index.js +201 -48
  40. package/node_modules/fast-uri/lib/schemes.js +9 -4
  41. package/node_modules/fast-uri/lib/utils.js +388 -91
  42. package/node_modules/fast-uri/package.json +1 -1
  43. package/node_modules/fast-uri/test/component-safe-serialization.test.js +105 -0
  44. package/node_modules/fast-uri/test/equal.test.js +31 -3
  45. package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +2 -0
  46. package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
  47. package/node_modules/fast-uri/test/ipv6-validation.test.js +90 -0
  48. package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
  49. package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
  50. package/node_modules/fast-uri/test/parse.test.js +7 -3
  51. package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
  52. package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
  53. package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
  54. package/node_modules/fast-uri/test/security-normalization.test.js +101 -0
  55. package/node_modules/fast-uri/test/security.test.js +75 -3
  56. package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
  57. package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
  58. package/node_modules/hono/dist/cjs/client/client.js +25 -11
  59. package/node_modules/hono/dist/cjs/client/utils.js +4 -1
  60. package/node_modules/hono/dist/cjs/context.js +4 -0
  61. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +36 -2
  62. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +1 -1
  63. package/node_modules/hono/dist/cjs/helper/ssg/utils.js +30 -10
  64. package/node_modules/hono/dist/cjs/jsx/dom/render.js +2 -0
  65. package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
  66. package/node_modules/hono/dist/cjs/middleware/cors/index.js +1 -1
  67. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
  68. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +1 -1
  69. package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -3
  70. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
  71. package/node_modules/hono/dist/cjs/request.js +8 -4
  72. package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
  73. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
  74. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +10 -3
  75. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +47 -83
  76. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +2 -1
  77. package/node_modules/hono/dist/cjs/router/trie-router/node.js +46 -69
  78. package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
  79. package/node_modules/hono/dist/cjs/router/utils.js +27 -0
  80. package/node_modules/hono/dist/cjs/utils/body.js +15 -3
  81. package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
  82. package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
  83. package/node_modules/hono/dist/cjs/utils/stream.js +7 -1
  84. package/node_modules/hono/dist/cjs/utils/url.js +9 -1
  85. package/node_modules/hono/dist/client/client.js +25 -11
  86. package/node_modules/hono/dist/client/utils.js +4 -1
  87. package/node_modules/hono/dist/context.js +4 -0
  88. package/node_modules/hono/dist/helper/accepts/accepts.js +36 -2
  89. package/node_modules/hono/dist/helper/ssg/ssg.js +1 -1
  90. package/node_modules/hono/dist/helper/ssg/utils.js +30 -10
  91. package/node_modules/hono/dist/jsx/dom/render.js +2 -0
  92. package/node_modules/hono/dist/middleware/cache/index.js +1 -1
  93. package/node_modules/hono/dist/middleware/cors/index.js +1 -1
  94. package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
  95. package/node_modules/hono/dist/middleware/etag/digest.js +1 -1
  96. package/node_modules/hono/dist/middleware/etag/index.js +3 -3
  97. package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
  98. package/node_modules/hono/dist/request.js +8 -4
  99. package/node_modules/hono/dist/router/linear-router/router.js +7 -2
  100. package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
  101. package/node_modules/hono/dist/router/reg-exp-router/node.js +6 -2
  102. package/node_modules/hono/dist/router/reg-exp-router/router.js +53 -84
  103. package/node_modules/hono/dist/router/reg-exp-router/trie.js +2 -1
  104. package/node_modules/hono/dist/router/trie-router/node.js +46 -69
  105. package/node_modules/hono/dist/router/trie-router/router.js +3 -11
  106. package/node_modules/hono/dist/router/utils.js +5 -0
  107. package/node_modules/hono/dist/types/context.d.ts +4 -0
  108. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -0
  109. package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
  110. package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
  111. package/node_modules/hono/dist/types/router/utils.d.ts +1 -0
  112. package/node_modules/hono/dist/types/utils/url.d.ts +4 -0
  113. package/node_modules/hono/dist/utils/body.js +15 -3
  114. package/node_modules/hono/dist/utils/cookie.js +1 -1
  115. package/node_modules/hono/dist/utils/ipaddr.js +5 -3
  116. package/node_modules/hono/dist/utils/stream.js +7 -1
  117. package/node_modules/hono/dist/utils/url.js +9 -1
  118. package/node_modules/hono/package.json +1 -1
  119. package/node_modules/is-plain-object/README.md +39 -95
  120. package/node_modules/is-plain-object/dist/is-plain-object.js +0 -2
  121. package/node_modules/is-plain-object/is-plain-object.d.ts +6 -1
  122. package/node_modules/is-plain-object/package.json +8 -34
  123. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
  124. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
  125. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
  126. package/node_modules/jose/dist/types/jwks/remote.d.ts +4 -4
  127. package/node_modules/jose/dist/types/jws/general/verify.d.ts +3 -3
  128. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +12 -17
  129. package/node_modules/jose/dist/types/jwt/sign.d.ts +8 -14
  130. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +9 -15
  131. package/node_modules/jose/dist/types/types.d.ts +4 -2
  132. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +30 -8
  133. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +8 -4
  134. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +6 -13
  135. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +19 -19
  136. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +32 -21
  137. package/node_modules/jose/dist/webapi/jwk/embedded.js +15 -1
  138. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +11 -5
  139. package/node_modules/jose/dist/webapi/jwks/local.js +45 -53
  140. package/node_modules/jose/dist/webapi/jwks/remote.js +82 -103
  141. package/node_modules/jose/dist/webapi/jws/compact/sign.js +10 -9
  142. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +2 -1
  143. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +8 -7
  144. package/node_modules/jose/dist/webapi/jws/general/sign.js +5 -3
  145. package/node_modules/jose/dist/webapi/jws/general/verify.js +51 -21
  146. package/node_modules/jose/dist/webapi/jwt/decrypt.js +7 -9
  147. package/node_modules/jose/dist/webapi/jwt/encrypt.js +21 -50
  148. package/node_modules/jose/dist/webapi/jwt/sign.js +8 -41
  149. package/node_modules/jose/dist/webapi/jwt/unsecured.js +21 -42
  150. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +6 -2
  151. package/node_modules/jose/dist/webapi/key/generate_secret.js +7 -6
  152. package/node_modules/jose/dist/webapi/key/import.js +16 -12
  153. package/node_modules/jose/dist/webapi/lib/asn1.js +7 -2
  154. package/node_modules/jose/dist/webapi/lib/content_encryption.js +7 -15
  155. package/node_modules/jose/dist/webapi/lib/deflate.js +8 -0
  156. package/node_modules/jose/dist/webapi/lib/helpers.js +1 -1
  157. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +85 -28
  158. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +45 -13
  159. package/node_modules/jose/dist/webapi/lib/jwk_metadata.js +20 -0
  160. package/node_modules/jose/dist/webapi/lib/jws_sign.js +47 -36
  161. package/node_modules/jose/dist/webapi/lib/jws_verify.js +77 -45
  162. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +82 -47
  163. package/node_modules/jose/dist/webapi/lib/key.js +24 -9
  164. package/node_modules/jose/dist/webapi/lib/key_management.js +10 -4
  165. package/node_modules/jose/dist/webapi/lib/key_options.js +6 -0
  166. package/node_modules/jose/dist/webapi/lib/options.js +26 -0
  167. package/node_modules/jose/dist/webapi/lib/type_checks.js +11 -13
  168. package/node_modules/jose/package.json +1 -1
  169. package/package.json +2 -2
  170. package/dist/ui/assets/index-0Q2eNytX.js +0 -110
  171. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/HISTORY.md +0 -114
@@ -1,11 +1,12 @@
1
1
  // src/router/reg-exp-router/trie.ts
2
+ import { createNullObject } from "../utils.js";
2
3
  import { Node } from "./node.js";
3
4
  var Trie = class {
4
5
  #context = { varIndex: 0 };
5
6
  #root = new Node();
6
7
  #index = 0;
7
8
  // dynamic path -> [handler index, param assoc]; static paths are not registered
8
- paths = /* @__PURE__ */ Object.create(null);
9
+ paths = createNullObject();
9
10
  insert(path, isStatic) {
10
11
  if (isStatic) {
11
12
  this.#root.insert(path.split(""), 0, [], this.#context, true);
@@ -1,77 +1,53 @@
1
1
  // src/router/trie-router/node.ts
2
2
  import { METHOD_NAME_ALL } from "../../router.js";
3
3
  import { getPattern, splitPath, splitRoutingPath } from "../../utils/url.js";
4
- var emptyParams = /* @__PURE__ */ Object.create(null);
5
- var hasChildren = (children) => {
6
- for (const _ in children) {
7
- return true;
8
- }
9
- return false;
10
- };
4
+ import { createNullObject } from "../utils.js";
5
+ var emptyParams = createNullObject();
6
+ var order = 0;
11
7
  var Node = class _Node {
12
- #methods;
13
- #children;
14
- #patterns;
15
- #order = 0;
8
+ #methods = [];
9
+ #children = createNullObject();
10
+ #patterns = [];
11
+ #pattern;
16
12
  #params = emptyParams;
17
- constructor(method, handler, children) {
18
- this.#children = children || /* @__PURE__ */ Object.create(null);
19
- this.#methods = [];
20
- if (method && handler) {
21
- const m = /* @__PURE__ */ Object.create(null);
22
- m[method] = { handler, possibleKeys: [], score: 0 };
23
- this.#methods = [m];
24
- }
25
- this.#patterns = [];
26
- }
27
13
  insert(method, path, handler) {
28
- this.#order = ++this.#order;
29
14
  let curNode = this;
30
15
  const parts = splitRoutingPath(path);
31
- const possibleKeys = [];
32
- for (let i = 0, len = parts.length; i < len; i++) {
33
- const p = parts[i];
34
- const nextP = parts[i + 1];
35
- const pattern = getPattern(p, nextP);
36
- const key = Array.isArray(pattern) ? pattern[0] : p;
37
- if (key in curNode.#children) {
38
- curNode = curNode.#children[key];
39
- if (pattern) {
40
- possibleKeys.push(pattern[1]);
41
- }
42
- continue;
16
+ const possibleKeys = /* @__PURE__ */ new Set();
17
+ let i = 0;
18
+ for (const p of parts) {
19
+ const nextP = parts[++i];
20
+ const pattern = getPattern(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
21
+ const isParam = Array.isArray(pattern);
22
+ const key = isParam ? pattern[0] : pattern || p;
23
+ const child = curNode.#children[key] ||= new _Node();
24
+ if (pattern && !child.#pattern) {
25
+ child.#pattern = pattern;
26
+ curNode.#patterns.push(child);
43
27
  }
44
- curNode.#children[key] = new _Node();
45
- if (pattern) {
46
- curNode.#patterns.push(pattern);
47
- possibleKeys.push(pattern[1]);
28
+ curNode = child;
29
+ if (isParam) {
30
+ possibleKeys.add(pattern[1]);
48
31
  }
49
- curNode = curNode.#children[key];
50
32
  }
51
33
  curNode.#methods.push({
52
34
  [method]: {
53
35
  handler,
54
- possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
55
- score: this.#order
36
+ possibleKeys: [...possibleKeys],
37
+ score: ++order
56
38
  }
57
39
  });
58
- return curNode;
59
40
  }
60
41
  #pushHandlerSets(handlerSets, node, method, nodeParams, params) {
61
42
  for (let i = 0, len = node.#methods.length; i < len; i++) {
62
43
  const m = node.#methods[i];
63
44
  const handlerSet = m[method] || m[METHOD_NAME_ALL];
64
- const processedSet = {};
65
- if (handlerSet !== void 0) {
66
- handlerSet.params = /* @__PURE__ */ Object.create(null);
45
+ if (handlerSet) {
46
+ handlerSet.params = createNullObject();
67
47
  handlerSets.push(handlerSet);
68
- if (nodeParams !== emptyParams || params && params !== emptyParams) {
69
- for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
70
- const key = handlerSet.possibleKeys[i2];
71
- const processed = processedSet[handlerSet.score];
72
- handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key];
73
- processedSet[handlerSet.score] = true;
74
- }
48
+ for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
49
+ const key = handlerSet.possibleKeys[i2];
50
+ handlerSet.params[key] = params?.[key] && !i2 ? params[key] : nodeParams[key] ?? params?.[key];
75
51
  }
76
52
  }
77
53
  }
@@ -103,33 +79,33 @@ var Node = class _Node {
103
79
  tempNodes.push(nextNode);
104
80
  }
105
81
  }
106
- for (let k = 0, len3 = node.#patterns.length; k < len3; k++) {
107
- const pattern = node.#patterns[k];
82
+ for (const child of node.#patterns) {
83
+ const pattern = child.#pattern;
108
84
  const params = node.#params === emptyParams ? {} : { ...node.#params };
109
- if (pattern === "*") {
110
- const astNode = node.#children["*"];
111
- if (astNode) {
112
- this.#pushHandlerSets(handlerSets, astNode, method, node.#params);
113
- astNode.#params = params;
114
- tempNodes.push(astNode);
85
+ if (typeof pattern === "string") {
86
+ if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
87
+ this.#pushHandlerSets(handlerSets, child, method, node.#params);
88
+ if (pattern === "*") {
89
+ child.#params = params;
90
+ tempNodes.push(child);
91
+ }
115
92
  }
116
93
  continue;
117
94
  }
118
- const [key, name, matcher] = pattern;
119
- if (!part && !(matcher instanceof RegExp)) {
95
+ const [, name, matcher] = pattern;
96
+ if (!part && matcher === true) {
120
97
  continue;
121
98
  }
122
- const child = node.#children[key];
123
- if (matcher instanceof RegExp) {
124
- if (partOffsets === null) {
125
- partOffsets = new Array(len);
99
+ if (matcher !== true) {
100
+ if (!partOffsets) {
101
+ partOffsets = [];
126
102
  let offset = path[0] === "/" ? 1 : 0;
127
103
  for (let p = 0; p < len; p++) {
128
104
  partOffsets[p] = offset;
129
105
  offset += parts[p].length + 1;
130
106
  }
131
107
  }
132
- const restPathString = path.substring(partOffsets[i]);
108
+ const restPathString = path.slice(partOffsets[i]);
133
109
  const m = matcher.exec(restPathString);
134
110
  if (m) {
135
111
  params[name] = m[0];
@@ -143,11 +119,12 @@ var Node = class _Node {
143
119
  params
144
120
  );
145
121
  }
146
- if (hasChildren(child.#children)) {
122
+ for (const _ in child.#children) {
147
123
  child.#params = params;
148
124
  const componentCount = m[0].match(/\//g)?.length ?? 0;
149
125
  const targetCurNodes = curNodesQueue[componentCount] ||= [];
150
126
  targetCurNodes.push(child);
127
+ break;
151
128
  }
152
129
  continue;
153
130
  }
@@ -175,7 +152,7 @@ var Node = class _Node {
175
152
  const shifted = curNodesQueue.shift();
176
153
  curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
177
154
  }
178
- if (handlerSets.length > 1) {
155
+ if (handlerSets[1]) {
179
156
  handlerSets.sort((a, b) => {
180
157
  return a.score - b.score;
181
158
  });
@@ -3,19 +3,11 @@ import { checkOptionalParameter } from "../../utils/url.js";
3
3
  import { Node } from "./node.js";
4
4
  var TrieRouter = class {
5
5
  name = "TrieRouter";
6
- #node;
7
- constructor() {
8
- this.#node = new Node();
9
- }
6
+ #node = new Node();
10
7
  add(method, path, handler) {
11
- const results = checkOptionalParameter(path);
12
- if (results) {
13
- for (let i = 0, len = results.length; i < len; i++) {
14
- this.#node.insert(method, results[i], handler);
15
- }
16
- return;
8
+ for (const result of checkOptionalParameter(path) || [path]) {
9
+ this.#node.insert(method, result, handler);
17
10
  }
18
- this.#node.insert(method, path, handler);
19
11
  }
20
12
  match(method, path) {
21
13
  return this.#node.search(method, path);
@@ -0,0 +1,5 @@
1
+ // src/router/utils.ts
2
+ var createNullObject = () => /* @__PURE__ */ Object.create(null);
3
+ export {
4
+ createNullObject
5
+ };
@@ -323,6 +323,10 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
323
323
  * c.header('X-Message', 'Hello!')
324
324
  * c.header('Content-Type', 'text/plain')
325
325
  *
326
+ * // Append multiple headers using the append option (e.g. Vary)
327
+ * c.header('Vary', 'Accept-Encoding', { append: true })
328
+ * c.header('Vary', 'User-Agent', { append: true })
329
+ *
326
330
  * return c.body('Thank you for coming')
327
331
  * })
328
332
  * ```
@@ -1,3 +1,6 @@
1
+ export declare const LABEL_REG_EXP_STR = "[^/]+";
2
+ export declare const ONLY_WILDCARD_REG_EXP_STR = ".*";
3
+ export declare const TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
1
4
  export declare const PATH_ERROR: unique symbol;
2
5
  export type ParamAssocArray = [string, number][];
3
6
  export interface Context {
@@ -1,7 +1,6 @@
1
1
  import type { Params } from '../../router';
2
2
  export declare class Node<T> {
3
3
 
4
- constructor(method?: string, handler?: T, children?: Record<string, Node<T>>);
5
- insert(method: string, path: string, handler: T): Node<T>;
4
+ insert(method: string, path: string, handler: T): void;
6
5
  search(method: string, path: string): [[T, Params][]];
7
6
  }
@@ -2,7 +2,6 @@ import type { Result, Router } from '../../router';
2
2
  export declare class TrieRouter<T> implements Router<T> {
3
3
 
4
4
  name: string;
5
- constructor();
6
5
  add(method: string, path: string, handler: T): void;
7
6
  match(method: string, path: string): Result<T>;
8
7
  }
@@ -0,0 +1 @@
1
+ export declare const createNullObject: () => any;
@@ -19,6 +19,10 @@ export declare const tryDecode: (str: string, decoder: Decoder) => string;
19
19
  */
20
20
  export declare const tryDecodeURI: (str: string) => string;
21
21
  export declare const getPath: (request: Request) => string;
22
+ /**
23
+ * @deprecated
24
+ * Use the `URL` API instead.
25
+ */
22
26
  export declare const getQueryStrings: (url: string) => string;
23
27
  export declare const getPathNoStrict: (request: Request) => string;
24
28
  /**
@@ -1,5 +1,7 @@
1
1
  // src/utils/body.ts
2
2
  import { bufferToFormData } from "./buffer.js";
3
+ var MAX_NESTING_DEPTH = 32;
4
+ var MAX_NESTED_OBJECTS = 1e4;
3
5
  var isRawRequest = (request) => "headers" in request;
4
6
  var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
5
7
  const { all = false, dot = false } = options;
@@ -32,6 +34,7 @@ async function parseFormData(request, options) {
32
34
  }
33
35
  function convertFormDataToBodyData(formData, options) {
34
36
  const form = /* @__PURE__ */ Object.create(null);
37
+ const nestingState = { count: 0 };
35
38
  formData.forEach((value, key) => {
36
39
  const shouldParseAllValues = options.all || key.endsWith("[]");
37
40
  if (!shouldParseAllValues) {
@@ -44,7 +47,7 @@ function convertFormDataToBodyData(formData, options) {
44
47
  Object.entries(form).forEach(([key, value]) => {
45
48
  const shouldParseDotValues = key.includes(".");
46
49
  if (shouldParseDotValues) {
47
- handleParsingNestedValues(form, key, value);
50
+ handleParsingNestedValues(form, key, value, nestingState);
48
51
  delete form[key];
49
52
  }
50
53
  });
@@ -67,23 +70,32 @@ var handleParsingAllValues = (form, key, value) => {
67
70
  }
68
71
  }
69
72
  };
70
- var handleParsingNestedValues = (form, key, value) => {
73
+ var handleParsingNestedValues = (form, key, value, state) => {
71
74
  if (/(?:^|\.)__proto__\./.test(key)) {
72
75
  return;
73
76
  }
74
77
  let nestedForm = form;
75
- const keys = key.split(".");
78
+ const keys = key.split(".", MAX_NESTING_DEPTH + 2);
79
+ if (keys.length > MAX_NESTING_DEPTH + 1) {
80
+ throwNestingLimitExceeded();
81
+ }
76
82
  keys.forEach((key2, index) => {
77
83
  if (index === keys.length - 1) {
78
84
  nestedForm[key2] = value;
79
85
  } else {
80
86
  if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {
87
+ if (state.count++ >= MAX_NESTED_OBJECTS) {
88
+ throwNestingLimitExceeded();
89
+ }
81
90
  nestedForm[key2] = /* @__PURE__ */ Object.create(null);
82
91
  }
83
92
  nestedForm = nestedForm[key2];
84
93
  }
85
94
  });
86
95
  };
96
+ var throwNestingLimitExceeded = () => {
97
+ throw new Error("Nesting limit exceeded");
98
+ };
87
99
  export {
88
100
  parseBody
89
101
  };
@@ -77,7 +77,7 @@ var parseSigned = async (cookie, secret, name) => {
77
77
  const secretKey = await getCryptoKey(secret);
78
78
  for (const [key, value] of Object.entries(parse(cookie, name))) {
79
79
  const signatureStartPos = value.lastIndexOf(".");
80
- if (signatureStartPos < 1) {
80
+ if (signatureStartPos < 0) {
81
81
  continue;
82
82
  }
83
83
  const signedValue = value.substring(0, signatureStartPos);
@@ -1,12 +1,14 @@
1
1
  // src/utils/ipaddr.ts
2
2
  var expandIPv6 = (ipV6) => {
3
3
  const sections = ipV6.split(":");
4
- if (IPV4_REGEX.test(sections.at(-1))) {
4
+ const lastSection = sections.at(-1);
5
+ if (IPV4_REGEX.test(lastSection)) {
6
+ const octets = lastSection.split(".").map(Number);
5
7
  sections.splice(
6
8
  -1,
7
9
  1,
8
- ...convertIPv6BinaryToString(convertIPv4ToBinary(sections.at(-1))).substring(2).split(":")
9
- // => ['7f00', '0001']
10
+ (octets[0] << 8 | octets[1]).toString(16),
11
+ (octets[2] << 8 | octets[3]).toString(16)
10
12
  );
11
13
  }
12
14
  for (let i = 0; i < sections.length; i++) {
@@ -75,7 +75,13 @@ var StreamingApi = class {
75
75
  abort() {
76
76
  if (!this.aborted) {
77
77
  this.aborted = true;
78
- this.abortSubscribers.forEach((subscriber) => subscriber());
78
+ this.abortSubscribers.forEach((subscriber) => {
79
+ try {
80
+ void Promise.resolve(subscriber()).catch(() => {
81
+ });
82
+ } catch {
83
+ }
84
+ });
79
85
  }
80
86
  }
81
87
  };
@@ -85,7 +85,11 @@ var getPath = (request) => {
85
85
  };
86
86
  var getQueryStrings = (url) => {
87
87
  const queryIndex = url.indexOf("?", 8);
88
- return queryIndex === -1 ? "" : "?" + url.slice(queryIndex + 1);
88
+ if (queryIndex === -1) {
89
+ return "";
90
+ }
91
+ const hashIndex = url.indexOf("#", 8);
92
+ return hashIndex === -1 ? url.slice(queryIndex) : queryIndex < hashIndex ? url.slice(queryIndex, hashIndex) : "";
89
93
  };
90
94
  var getPathNoStrict = (request) => {
91
95
  const result = getPath(request);
@@ -132,6 +136,10 @@ var _decodeURI = (value) => {
132
136
  return tryDecodeURIComponent(value);
133
137
  };
134
138
  var _getQueryParam = (url, key, multiple) => {
139
+ const hashIndex = url.indexOf("#", 8);
140
+ if (hashIndex !== -1) {
141
+ url = url.slice(0, hashIndex);
142
+ }
135
143
  let encoded;
136
144
  if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
137
145
  let keyIndex2 = url.indexOf("?", 8);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.13.2",
3
+ "version": "4.13.5",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",
@@ -1,125 +1,69 @@
1
- # is-plain-object [![NPM version](https://img.shields.io/npm/v/is-plain-object.svg?style=flat)](https://www.npmjs.com/package/is-plain-object) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-plain-object.svg?style=flat)](https://npmjs.org/package/is-plain-object) [![NPM total downloads](https://img.shields.io/npm/dt/is-plain-object.svg?style=flat)](https://npmjs.org/package/is-plain-object) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/is-plain-object.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/is-plain-object)
1
+ # is-plain-object
2
2
 
3
- > Returns true if an object was created by the `Object` constructor, or Object.create(null).
3
+ [![npm version](https://img.shields.io/npm/v/is-plain-object.svg)](https://www.npmjs.com/package/is-plain-object)
4
+ [![npm downloads](https://img.shields.io/npm/dm/is-plain-object.svg)](https://www.npmjs.com/package/is-plain-object)
5
+ [![CI](https://github.com/jonschlinkert/is-plain-object/actions/workflows/ci.yml/badge.svg)](https://github.com/jonschlinkert/is-plain-object/actions/workflows/ci.yml)
4
6
 
5
- Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
7
+ > Returns `true` if an object was created by the `Object` constructor or with a `null` prototype.
6
8
 
7
- ## Install
9
+ Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and starring the project to show your ❤️ and support.
10
+
11
+ Use [isobject](https://github.com/jonschlinkert/isobject) if you only want to check whether a value is an object and not an array or `null`.
8
12
 
9
- Install with [npm](https://www.npmjs.com/):
13
+ ## Install
10
14
 
11
15
  ```sh
12
- $ npm install --save is-plain-object
16
+ npm install is-plain-object
13
17
  ```
14
18
 
15
- Use [isobject](https://github.com/jonschlinkert/isobject) if you only want to check if the value is an object and not an array or null.
16
-
17
19
  ## Usage
18
20
 
19
- with es modules
20
- ```js
21
- import { isPlainObject } from 'is-plain-object';
22
- ```
21
+ With ES modules:
23
22
 
24
- or with commonjs
25
23
  ```js
26
- const { isPlainObject } = require('is-plain-object');
27
- ```
28
-
29
- **true** when created by the `Object` constructor, or Object.create(null).
24
+ import { isPlainObject } from 'is-plain-object';
30
25
 
31
- ```js
32
- isPlainObject(Object.create({}));
33
- //=> true
34
- isPlainObject(Object.create(Object.prototype));
35
- //=> true
36
- isPlainObject({foo: 'bar'});
37
- //=> true
38
- isPlainObject({});
39
- //=> true
40
- isPlainObject(null);
41
- //=> true
26
+ isPlainObject({}); // true
27
+ isPlainObject({ foo: 'bar' }); // true
28
+ isPlainObject(Object.create(null)); // true
29
+ isPlainObject(Object.create({})); // true
30
+
31
+ isPlainObject(); // false
32
+ isPlainObject(null); // false
33
+ isPlainObject([]); // false
34
+ isPlainObject(new Date()); // false
35
+ isPlainObject(/foo/); // false
36
+ isPlainObject(() => {}); // false
42
37
  ```
43
38
 
44
- **false** when not created by the `Object` constructor.
39
+ With CommonJS:
45
40
 
46
41
  ```js
47
- isPlainObject(1);
48
- //=> false
49
- isPlainObject(['foo', 'bar']);
50
- //=> false
51
- isPlainObject([]);
52
- //=> false
53
- isPlainObject(new Foo);
54
- //=> false
55
- isPlainObject(Object.create(null));
56
- //=> false
42
+ const { isPlainObject } = require('is-plain-object');
57
43
  ```
58
44
 
59
- ## About
60
-
61
- <details>
62
- <summary><strong>Contributing</strong></summary>
63
-
64
- Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
45
+ ## API
65
46
 
66
- </details>
47
+ ### `isPlainObject(value)`
67
48
 
68
- <details>
69
- <summary><strong>Running Tests</strong></summary>
49
+ Returns `true` when `value` is a plain object. Objects created by the `Object` constructor and objects with a `null` prototype are considered plain.
70
50
 
71
- Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
51
+ ## Development
72
52
 
73
- ```sh
74
- $ npm install && npm test
75
- ```
76
-
77
- </details>
78
-
79
- <details>
80
- <summary><strong>Building docs</strong></summary>
81
-
82
- _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
83
-
84
- To generate the readme, run the following command:
53
+ Install dependencies, build the CommonJS and ES module bundles, and run the tests:
85
54
 
86
55
  ```sh
87
- $ npm install -g verbose/verb#dev verb-generate-readme && verb
56
+ npm install
57
+ npm run build
58
+ npm test
88
59
  ```
89
60
 
90
- </details>
91
-
92
- ### Related projects
93
-
94
- You might also be interested in these projects:
95
-
96
- * [is-number](https://www.npmjs.com/package/is-number): Returns true if a number or string value is a finite number. Useful for regex… [more](https://github.com/jonschlinkert/is-number) | [homepage](https://github.com/jonschlinkert/is-number "Returns true if a number or string value is a finite number. Useful for regex matches, parsing, user input, etc.")
97
- * [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.")
98
- * [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
99
-
100
- ### Contributors
101
-
102
- | **Commits** | **Contributor** |
103
- | --- | --- |
104
- | 19 | [jonschlinkert](https://github.com/jonschlinkert) |
105
- | 6 | [TrySound](https://github.com/TrySound) |
106
- | 6 | [stevenvachon](https://github.com/stevenvachon) |
107
- | 3 | [onokumus](https://github.com/onokumus) |
108
- | 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
109
-
110
- ### Author
111
-
112
- **Jon Schlinkert**
113
-
114
- * [GitHub Profile](https://github.com/jonschlinkert)
115
- * [Twitter Profile](https://twitter.com/jonschlinkert)
116
- * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
117
-
118
- ### License
61
+ ## Related projects
119
62
 
120
- Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
121
- Released under the [MIT License](LICENSE).
63
+ - [is-number](https://www.npmjs.com/package/is-number): Check if a value is a finite number.
64
+ - [isobject](https://www.npmjs.com/package/isobject): Check if a value is an object and not an array or `null`.
65
+ - [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value.
122
66
 
123
- ***
67
+ ## License
124
68
 
125
- _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on April 28, 2019._
69
+ [MIT](LICENSE) © Jon Schlinkert
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  /*!
6
4
  * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
7
5
  *
@@ -1 +1,6 @@
1
- export function isPlainObject(o: any): boolean;
1
+ /**
2
+ * Returns true if an object was created by the `Object` constructor, or Object.create(null).
3
+ *
4
+ * @param value The value to test
5
+ */
6
+ export function isPlainObject(value: unknown): value is Record<PropertyKey, unknown>;