@psnext/slingcli 3.0.20260811-3 → 3.0.20260820-1

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 (197) hide show
  1. package/node_modules/@aws-sdk/core/dist-types/submodules/client/util-endpoints/lib/aws/partitions.d.ts +54 -54
  2. package/node_modules/@aws-sdk/core/dist-types/submodules/client/util-user-agent-browser/defaultUserAgent.d.ts +1 -1
  3. package/node_modules/@aws-sdk/core/dist-types/submodules/client/util-user-agent-browser/defaultUserAgent.native.d.ts +1 -1
  4. package/node_modules/@aws-sdk/core/dist-types/submodules/client/util-user-agent-node/defaultUserAgent.d.ts +1 -1
  5. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partitions.d.ts +54 -54
  6. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.d.ts +1 -4
  7. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.native.d.ts +1 -4
  8. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/defaultUserAgent.d.ts +1 -4
  9. package/node_modules/@aws-sdk/core/package.json +4 -4
  10. package/node_modules/@aws-sdk/credential-provider-env/package.json +4 -4
  11. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-cjs/index.js +9 -2
  12. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +9 -2
  13. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +1 -1
  14. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-handler.d.ts +1 -1
  15. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/package.json +5 -13
  16. package/node_modules/@aws-sdk/credential-provider-http/package.json +4 -4
  17. package/node_modules/@aws-sdk/credential-provider-ini/package.json +11 -11
  18. package/node_modules/@aws-sdk/credential-provider-login/package.json +5 -5
  19. package/node_modules/@aws-sdk/credential-provider-node/package.json +9 -9
  20. package/node_modules/@aws-sdk/credential-provider-process/package.json +4 -4
  21. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +5 -5
  22. package/node_modules/@aws-sdk/credential-provider-sso/package.json +6 -6
  23. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +5 -5
  24. package/node_modules/@aws-sdk/eventstream-handler-node/package.json +3 -3
  25. package/node_modules/@aws-sdk/middleware-eventstream/package.json +3 -3
  26. package/node_modules/@aws-sdk/middleware-websocket/package.json +4 -4
  27. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  28. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  29. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  30. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  31. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  32. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.browser.d.ts +42 -42
  33. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.d.ts +42 -42
  34. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.native.d.ts +41 -41
  35. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.shared.d.ts +2 -2
  36. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.browser.d.ts +43 -43
  37. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.d.ts +43 -43
  38. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.native.d.ts +42 -42
  39. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.shared.d.ts +2 -2
  40. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.browser.d.ts +42 -42
  41. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.d.ts +42 -42
  42. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.native.d.ts +41 -41
  43. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.shared.d.ts +2 -2
  44. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.browser.d.ts +42 -42
  45. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.d.ts +42 -42
  46. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.native.d.ts +41 -41
  47. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.shared.d.ts +2 -2
  48. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.browser.d.ts +44 -44
  49. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.d.ts +35 -35
  50. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.native.d.ts +43 -43
  51. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.shared.d.ts +2 -2
  52. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.browser.d.ts +64 -66
  53. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.d.ts +65 -65
  54. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.native.d.ts +68 -70
  55. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.shared.d.ts +3 -3
  56. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.browser.d.ts +67 -69
  57. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.d.ts +66 -66
  58. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.native.d.ts +71 -73
  59. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.shared.d.ts +3 -3
  60. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.browser.d.ts +64 -66
  61. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.d.ts +65 -65
  62. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.native.d.ts +68 -70
  63. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.shared.d.ts +3 -3
  64. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.browser.d.ts +64 -66
  65. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.d.ts +65 -65
  66. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.native.d.ts +68 -70
  67. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.shared.d.ts +3 -3
  68. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.browser.d.ts +68 -70
  69. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.d.ts +68 -68
  70. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.native.d.ts +72 -74
  71. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.shared.d.ts +3 -3
  72. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-cjs/index.js +9 -2
  73. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +9 -2
  74. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +1 -1
  75. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-handler.d.ts +1 -1
  76. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/package.json +5 -13
  77. package/node_modules/@aws-sdk/nested-clients/package.json +5 -5
  78. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +3 -3
  79. package/node_modules/@aws-sdk/types/package.json +2 -2
  80. package/node_modules/@aws-sdk/util-locate-window/package.json +27 -27
  81. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  82. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +4 -1
  83. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  84. package/node_modules/@hono/node-server/dist/index.cjs +151 -9
  85. package/node_modules/@hono/node-server/dist/index.mjs +151 -9
  86. package/node_modules/@hono/node-server/package.json +1 -1
  87. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +1 -2
  88. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +23 -23
  89. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +23 -23
  90. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +17 -13
  91. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +0 -10
  92. package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +1 -2
  93. package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +4 -4
  94. package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js +19 -19
  95. package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +3 -4
  96. package/node_modules/@smithy/core/dist-es/submodules/protocols/middleware-content-length/contentLengthMiddleware.js +6 -4
  97. package/node_modules/@smithy/core/dist-es/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.js +8 -5
  98. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js +0 -2
  99. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js +0 -2
  100. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/OperationSchema.js +0 -2
  101. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +0 -2
  102. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js +0 -2
  103. package/node_modules/@smithy/core/dist-types/submodules/client/smithy-client/extensions/defaultExtensionConfiguration.d.ts +1 -7
  104. package/node_modules/@smithy/core/dist-types/submodules/config/config-resolver/regionConfig/checkRegion.d.ts +2 -1
  105. package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/evaluateCondition.d.ts +1 -1
  106. package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/evaluateConditions.d.ts +1 -1
  107. package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/evaluateExpression.d.ts +2 -2
  108. package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/evaluateRules.d.ts +2 -2
  109. package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/getEndpointProperties.d.ts +2 -2
  110. package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/getReferenceValue.d.ts +2 -2
  111. package/node_modules/@smithy/core/dist-types/submodules/event-streams/EventStreamSerde.d.ts +14 -2
  112. package/node_modules/@smithy/core/dist-types/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +7 -2
  113. package/node_modules/@smithy/core/dist-types/submodules/retry/util-retry/retries-2026-config.d.ts +2 -2
  114. package/node_modules/@smithy/core/dist-types/submodules/schema/TypeRegistry.d.ts +1 -1
  115. package/node_modules/@smithy/core/dist-types/submodules/serde/parse-utils.d.ts +5 -5
  116. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/client/smithy-client/extensions/defaultExtensionConfiguration.d.ts +1 -7
  117. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/config/config-resolver/regionConfig/checkRegion.d.ts +2 -1
  118. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/evaluateCondition.d.ts +1 -1
  119. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/evaluateConditions.d.ts +1 -1
  120. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/evaluateExpression.d.ts +2 -2
  121. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/evaluateRules.d.ts +2 -2
  122. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/getEndpointProperties.d.ts +2 -2
  123. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/getReferenceValue.d.ts +2 -2
  124. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/event-streams/EventStreamSerde.d.ts +14 -2
  125. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +7 -2
  126. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/retry/util-retry/retries-2026-config.d.ts +2 -2
  127. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/TypeRegistry.d.ts +1 -1
  128. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/serde/parse-utils.d.ts +5 -5
  129. package/node_modules/@smithy/core/package.json +3 -11
  130. package/node_modules/@smithy/credential-provider-imds/package.json +4 -12
  131. package/node_modules/@smithy/fetch-http-handler/package.json +5 -13
  132. package/node_modules/@smithy/signature-v4/dist-cjs/index.js +9 -9
  133. package/node_modules/@smithy/signature-v4/dist-es/HeaderFormatter.js +9 -9
  134. package/node_modules/@smithy/signature-v4/package.json +4 -12
  135. package/node_modules/@smithy/types/dist-types/schema/sentinels.d.ts +14 -14
  136. package/node_modules/@smithy/types/package.json +29 -39
  137. package/node_modules/body-parser/node_modules/content-type/README.md +2 -0
  138. package/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
  139. package/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
  140. package/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
  141. package/node_modules/body-parser/node_modules/content-type/package.json +1 -1
  142. package/node_modules/gaxios/build/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  143. package/node_modules/gaxios/build/esm/tsconfig.tsbuildinfo +1 -1
  144. package/node_modules/gaxios/package.json +3 -3
  145. package/node_modules/hono/dist/cjs/client/client.js +3 -3
  146. package/node_modules/hono/dist/cjs/client/utils.js +1 -1
  147. package/node_modules/hono/dist/cjs/context.js +4 -0
  148. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +1 -1
  149. package/node_modules/hono/dist/cjs/middleware/cors/index.js +16 -13
  150. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
  151. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +47 -1
  152. package/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -2
  153. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
  154. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
  155. package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
  156. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
  157. package/node_modules/hono/dist/cjs/router/trie-router/node.js +43 -67
  158. package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
  159. package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
  160. package/node_modules/hono/dist/cjs/utils/url.js +2 -2
  161. package/node_modules/hono/dist/client/client.js +3 -3
  162. package/node_modules/hono/dist/client/utils.js +1 -1
  163. package/node_modules/hono/dist/context.js +4 -0
  164. package/node_modules/hono/dist/jsx/intrinsic-element/components.js +1 -1
  165. package/node_modules/hono/dist/middleware/cors/index.js +16 -13
  166. package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
  167. package/node_modules/hono/dist/middleware/etag/digest.js +47 -1
  168. package/node_modules/hono/dist/middleware/etag/index.js +2 -2
  169. package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
  170. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
  171. package/node_modules/hono/dist/router/linear-router/router.js +7 -2
  172. package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
  173. package/node_modules/hono/dist/router/trie-router/node.js +43 -67
  174. package/node_modules/hono/dist/router/trie-router/router.js +3 -11
  175. package/node_modules/hono/dist/types/context.d.ts +4 -0
  176. package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
  177. package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
  178. package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
  179. package/node_modules/hono/dist/utils/ipaddr.js +5 -3
  180. package/node_modules/hono/dist/utils/url.js +2 -2
  181. package/node_modules/hono/package.json +1 -1
  182. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
  183. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
  184. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
  185. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +4 -3
  186. package/node_modules/jose/dist/types/types.d.ts +4 -2
  187. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +7 -3
  188. package/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  189. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +6 -2
  190. package/node_modules/jose/package.json +1 -1
  191. package/node_modules/type-is/node_modules/content-type/README.md +2 -0
  192. package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
  193. package/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
  194. package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
  195. package/node_modules/type-is/node_modules/content-type/package.json +1 -1
  196. package/package.json +2 -2
  197. package/slingshot/index.js +295 -279
@@ -2,76 +2,51 @@
2
2
  import { METHOD_NAME_ALL } from "../../router.js";
3
3
  import { getPattern, splitPath, splitRoutingPath } from "../../utils/url.js";
4
4
  var emptyParams = /* @__PURE__ */ Object.create(null);
5
- var hasChildren = (children) => {
6
- for (const _ in children) {
7
- return true;
8
- }
9
- return false;
10
- };
5
+ var order = 0;
11
6
  var Node = class _Node {
12
- #methods;
13
- #children;
14
- #patterns;
15
- #order = 0;
7
+ #methods = [];
8
+ #children = /* @__PURE__ */ Object.create(null);
9
+ #patterns = [];
10
+ #pattern;
16
11
  #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
12
  insert(method, path, handler) {
28
- this.#order = ++this.#order;
29
13
  let curNode = this;
30
14
  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;
15
+ const possibleKeys = /* @__PURE__ */ new Set();
16
+ let i = 0;
17
+ for (const p of parts) {
18
+ const nextP = parts[++i];
19
+ const pattern = getPattern(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
20
+ const isParam = Array.isArray(pattern);
21
+ const key = isParam ? pattern[0] : pattern || p;
22
+ const child = curNode.#children[key] ||= new _Node();
23
+ if (pattern && !child.#pattern) {
24
+ child.#pattern = pattern;
25
+ curNode.#patterns.push(child);
43
26
  }
44
- curNode.#children[key] = new _Node();
45
- if (pattern) {
46
- curNode.#patterns.push(pattern);
47
- possibleKeys.push(pattern[1]);
27
+ curNode = child;
28
+ if (isParam) {
29
+ possibleKeys.add(pattern[1]);
48
30
  }
49
- curNode = curNode.#children[key];
50
31
  }
51
32
  curNode.#methods.push({
52
33
  [method]: {
53
34
  handler,
54
- possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
55
- score: this.#order
35
+ possibleKeys: [...possibleKeys],
36
+ score: ++order
56
37
  }
57
38
  });
58
- return curNode;
59
39
  }
60
40
  #pushHandlerSets(handlerSets, node, method, nodeParams, params) {
61
41
  for (let i = 0, len = node.#methods.length; i < len; i++) {
62
42
  const m = node.#methods[i];
63
43
  const handlerSet = m[method] || m[METHOD_NAME_ALL];
64
- const processedSet = {};
65
- if (handlerSet !== void 0) {
44
+ if (handlerSet) {
66
45
  handlerSet.params = /* @__PURE__ */ Object.create(null);
67
46
  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
- }
47
+ for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
48
+ const key = handlerSet.possibleKeys[i2];
49
+ handlerSet.params[key] = params?.[key] && !i2 ? params[key] : nodeParams[key] ?? params?.[key];
75
50
  }
76
51
  }
77
52
  }
@@ -103,33 +78,33 @@ var Node = class _Node {
103
78
  tempNodes.push(nextNode);
104
79
  }
105
80
  }
106
- for (let k = 0, len3 = node.#patterns.length; k < len3; k++) {
107
- const pattern = node.#patterns[k];
81
+ for (const child of node.#patterns) {
82
+ const pattern = child.#pattern;
108
83
  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);
84
+ if (typeof pattern === "string") {
85
+ if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
86
+ this.#pushHandlerSets(handlerSets, child, method, node.#params);
87
+ if (pattern === "*") {
88
+ child.#params = params;
89
+ tempNodes.push(child);
90
+ }
115
91
  }
116
92
  continue;
117
93
  }
118
- const [key, name, matcher] = pattern;
119
- if (!part && !(matcher instanceof RegExp)) {
94
+ const [, name, matcher] = pattern;
95
+ if (!part && matcher === true) {
120
96
  continue;
121
97
  }
122
- const child = node.#children[key];
123
- if (matcher instanceof RegExp) {
124
- if (partOffsets === null) {
125
- partOffsets = new Array(len);
98
+ if (matcher !== true) {
99
+ if (!partOffsets) {
100
+ partOffsets = [];
126
101
  let offset = path[0] === "/" ? 1 : 0;
127
102
  for (let p = 0; p < len; p++) {
128
103
  partOffsets[p] = offset;
129
104
  offset += parts[p].length + 1;
130
105
  }
131
106
  }
132
- const restPathString = path.substring(partOffsets[i]);
107
+ const restPathString = path.slice(partOffsets[i]);
133
108
  const m = matcher.exec(restPathString);
134
109
  if (m) {
135
110
  params[name] = m[0];
@@ -143,11 +118,12 @@ var Node = class _Node {
143
118
  params
144
119
  );
145
120
  }
146
- if (hasChildren(child.#children)) {
121
+ for (const _ in child.#children) {
147
122
  child.#params = params;
148
123
  const componentCount = m[0].match(/\//g)?.length ?? 0;
149
124
  const targetCurNodes = curNodesQueue[componentCount] ||= [];
150
125
  targetCurNodes.push(child);
126
+ break;
151
127
  }
152
128
  continue;
153
129
  }
@@ -175,7 +151,7 @@ var Node = class _Node {
175
151
  const shifted = curNodesQueue.shift();
176
152
  curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
177
153
  }
178
- if (handlerSets.length > 1) {
154
+ if (handlerSets[1]) {
179
155
  handlerSets.sort((a, b) => {
180
156
  return a.score - b.score;
181
157
  });
@@ -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);
@@ -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
  * ```
@@ -2,13 +2,13 @@ export type PermissionsPolicyDirective = StandardizedFeatures | ProposedFeatures
2
2
  /**
3
3
  * These features have been declared in a published version of the respective specification.
4
4
  */
5
- type StandardizedFeatures = 'accelerometer' | 'ambientLightSensor' | 'attributionReporting' | 'autoplay' | 'battery' | 'bluetooth' | 'camera' | 'chUa' | 'chUaArch' | 'chUaBitness' | 'chUaFullVersion' | 'chUaFullVersionList' | 'chUaMobile' | 'chUaModel' | 'chUaPlatform' | 'chUaPlatformVersion' | 'chUaWow64' | 'computePressure' | 'crossOriginIsolated' | 'directSockets' | 'displayCapture' | 'encryptedMedia' | 'executionWhileNotRendered' | 'executionWhileOutOfViewport' | 'fullscreen' | 'geolocation' | 'gyroscope' | 'hid' | 'identityCredentialsGet' | 'idleDetection' | 'keyboardMap' | 'magnetometer' | 'microphone' | 'midi' | 'navigationOverride' | 'payment' | 'pictureInPicture' | 'publickeyCredentialsGet' | 'screenWakeLock' | 'serial' | 'storageAccess' | 'syncXhr' | 'usb' | 'webShare' | 'windowManagement' | 'xrSpatialTracking';
5
+ type StandardizedFeatures = 'accelerometer' | 'ambientLightSensor' | 'attributionReporting' | 'autoplay' | 'battery' | 'bluetooth' | 'camera' | 'chUa' | 'chUaArch' | 'chUaBitness' | 'chUaFullVersion' | 'chUaFullVersionList' | 'chUaHighEntropyValues' | 'chUaMobile' | 'chUaModel' | 'chUaPlatform' | 'chUaPlatformVersion' | 'chUaWow64' | 'computePressure' | 'crossOriginIsolated' | 'directSockets' | 'displayCapture' | 'encryptedMedia' | 'executionWhileNotRendered' | 'executionWhileOutOfViewport' | 'fullscreen' | 'geolocation' | 'gyroscope' | 'hid' | 'identityCredentialsGet' | 'idleDetection' | 'keyboardMap' | 'magnetometer' | 'mediasession' | 'microphone' | 'midi' | 'navigationOverride' | 'otpCredentials' | 'payment' | 'pictureInPicture' | 'publickeyCredentialsGet' | 'screenWakeLock' | 'serial' | 'storageAccess' | 'syncXhr' | 'tools' | 'usb' | 'webShare' | 'windowManagement' | 'xrSpatialTracking';
6
6
  /**
7
7
  * These features have been proposed, but the definitions have not yet been integrated into their respective specs.
8
8
  */
9
- type ProposedFeatures = 'clipboardRead' | 'clipboardWrite' | 'gamepad' | 'sharedAutofill' | 'speakerSelection';
9
+ type ProposedFeatures = 'autofill' | 'clipboardRead' | 'clipboardWrite' | 'deferredFetch' | 'gamepad' | 'languageDetector' | 'languageModel' | 'manualText' | 'rewriter' | 'sharedAutofill' | 'speakerSelection' | 'summarizer' | 'translator' | 'writer';
10
10
  /**
11
11
  * These features generally have an explainer only, but may be available for experimentation by web developers.
12
12
  */
13
- type ExperimentalFeatures = 'allScreensCapture' | 'browsingTopics' | 'capturedSurfaceControl' | 'conversionMeasurement' | 'digitalCredentialsGet' | 'focusWithoutUserActivation' | 'joinAdInterestGroup' | 'localFonts' | 'runAdAuction' | 'smartCard' | 'syncScript' | 'trustTokenRedemption' | 'unload' | 'verticalScroll';
13
+ type ExperimentalFeatures = 'allScreensCapture' | 'browsingTopics' | 'capturedSurfaceControl' | 'conversionMeasurement' | 'digitalCredentialsCreate' | 'digitalCredentialsGet' | 'focusWithoutUserActivation' | 'joinAdInterestGroup' | 'localFonts' | 'monetization' | 'runAdAuction' | 'smartCard' | 'syncScript' | 'trustTokenRedemption' | 'unload' | 'verticalScroll';
14
14
  export {};
@@ -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
  }
@@ -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++) {
@@ -108,13 +108,13 @@ var checkOptionalParameter = (path) => {
108
108
  if (segment !== "" && !/\:/.test(segment)) {
109
109
  basePath += "/" + segment;
110
110
  } else if (/\:/.test(segment)) {
111
- if (/\?/.test(segment)) {
111
+ if (segment.charCodeAt(segment.length - 1) === 63) {
112
112
  if (results.length === 0 && basePath === "") {
113
113
  results.push("/");
114
114
  } else {
115
115
  results.push(basePath);
116
116
  }
117
- const optionalSegment = segment.replace("?", "");
117
+ const optionalSegment = segment.slice(0, -1);
118
118
  basePath += "/" + optionalSegment;
119
119
  results.push(basePath);
120
120
  } else {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.13.1",
3
+ "version": "4.13.3",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",
@@ -35,9 +35,10 @@ export declare class CompactEncrypt {
35
35
  */
36
36
  setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this;
37
37
  /**
38
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
39
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
40
- * parameters.
38
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
39
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
40
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
41
+ * appropriate JOSE Header.
41
42
  *
42
43
  * @param parameters JWE Key Management parameters.
43
44
  */
@@ -9,9 +9,10 @@ export declare class FlattenedEncrypt {
9
9
  */
10
10
  constructor(plaintext: Uint8Array);
11
11
  /**
12
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
13
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
14
- * parameters.
12
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
13
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
14
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
15
+ * appropriate JOSE Header.
15
16
  *
16
17
  * @param parameters JWE Key Management parameters.
17
18
  */
@@ -8,9 +8,10 @@ export interface Recipient {
8
8
  */
9
9
  setUnprotectedHeader(unprotectedHeader: types.JWEHeaderParameters): Recipient;
10
10
  /**
11
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
12
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
13
- * parameters.
11
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
12
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
13
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
14
+ * appropriate JOSE Header.
14
15
  *
15
16
  * @param parameters JWE Key Management parameters.
16
17
  */
@@ -23,9 +23,10 @@ export declare class EncryptJWT implements types.ProduceJWT {
23
23
  */
24
24
  setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this;
25
25
  /**
26
- * Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
27
- * use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
28
- * parameters.
26
+ * Sets the JWE Key Management parameters to be used when encrypting. Use this method instead of
27
+ * the header setters to configure algorithm inputs such as ECDH-ES "apu" (Agreement PartyUInfo)
28
+ * and "apv" (Agreement PartyVInfo), or PBES2 "p2c" (PBES2 Count). The parameters are added to the
29
+ * appropriate JOSE Header.
29
30
  *
30
31
  * @param parameters JWE Key Management parameters.
31
32
  */
@@ -417,11 +417,13 @@ export interface JWEKeyManagementHeaderParameters {
417
417
  * used in ECDH's ConcatKDF.
418
418
  */
419
419
  apv?: Uint8Array
420
+
420
421
  /**
421
- * @deprecated You should not use this parameter. It is only intended for testing and vector
422
- * validation purposes.
422
+ * PBES2 "p2c" (PBES2 Count). This will be used as a JOSE Header Parameter and as the PBKDF2
423
+ * iteration count.
423
424
  */
424
425
  p2c?: number
426
+
425
427
  /**
426
428
  * @deprecated You should not use this parameter. It is only intended for testing and vector
427
429
  * validation purposes.
@@ -5,7 +5,7 @@ import { generateCek } from '../../lib/content_encryption.js';
5
5
  import { encryptKeyManagement } from '../../lib/key_management.js';
6
6
  import { encode as b64u } from '../../util/base64url.js';
7
7
  import { validateCritDuplicates } from '../../lib/options.js';
8
- import { checkEncryptHeaders, encryptJWE } from '../../lib/jwe_encrypt.js';
8
+ import { checkDisjoint, checkEncryptHeaders, encryptJWE } from '../../lib/jwe_encrypt.js';
9
9
  import { prepareKey } from '../../lib/key.js';
10
10
  import { jweAlgorithm } from '../../lib/jwe_algorithms.js';
11
11
  class IndividualRecipient {
@@ -158,8 +158,12 @@ export class GeneralEncrypt {
158
158
  const k = await prepareKey(jweAlgorithm(alg), key, 'encrypt');
159
159
  const [, encryptedKey, parameters] = await encryptKeyManagement(alg, encEntry, k, cek, keyManagementParameters);
160
160
  target.encrypted_key = b64u(encryptedKey);
161
- if (unprotectedHeader || parameters)
162
- target.header = { ...unprotectedHeader, ...parameters };
161
+ if (unprotectedHeader || parameters) {
162
+ const header = { ...unprotectedHeader, ...parameters };
163
+ if (parameters)
164
+ checkDisjoint(this.#protectedHeader, header, this.#unprotectedHeader);
165
+ target.header = header;
166
+ }
163
167
  }
164
168
  return jwe;
165
169
  }
@@ -9,7 +9,7 @@ function isCloudflareWorkers() {
9
9
  let USER_AGENT;
10
10
  if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
11
11
  const NAME = 'jose';
12
- const VERSION = 'v6.2.8';
12
+ const VERSION = 'v6.2.9';
13
13
  USER_AGENT = `${NAME}/${VERSION}`;
14
14
  }
15
15
  export const customFetch = Symbol();
@@ -8,11 +8,14 @@ import { validateCrit, JWE_RECOGNIZED } from './options.js';
8
8
  import { prepareKey } from './key.js';
9
9
  import { jweAlgorithm, jweEncryption } from './jwe_algorithms.js';
10
10
  import { compress } from './deflate.js';
11
- export function checkEncryptHeaders(input) {
12
- const [, protectedHeader, unprotectedHeader, sharedUnprotectedHeader, , , , , crit] = input;
11
+ export function checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader) {
13
12
  if (!isDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader)) {
14
13
  throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');
15
14
  }
15
+ }
16
+ export function checkEncryptHeaders(input) {
17
+ const [, protectedHeader, unprotectedHeader, sharedUnprotectedHeader, , , , , crit] = input;
18
+ checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader);
16
19
  const joseHeader = {
17
20
  ...protectedHeader,
18
21
  ...unprotectedHeader,
@@ -52,6 +55,7 @@ export async function encryptJWE(input, checked, key) {
52
55
  else {
53
56
  protectedHeader = protectedHeader ? { ...protectedHeader, ...parameters } : parameters;
54
57
  }
58
+ checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader);
55
59
  }
56
60
  let protectedHeaderS;
57
61
  let protectedHeaderB;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jose",
3
- "version": "6.2.8",
3
+ "version": "6.2.9",
4
4
  "description": "JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",
5
5
  "keywords": [
6
6
  "akp",
@@ -36,6 +36,8 @@ The parser is lenient and does not error. You should validate `type` and `parame
36
36
  #### Options
37
37
 
38
38
  - `parameters` (default: `true`): Set to `false` to skip parameters.
39
+ - `comma` (default: `false`): Set to `true` to stop on a comma. This can be used to parse the media range in an `Accept` header.
40
+ - `start` (default: `0`): Set index to start parsing from.
39
41
 
40
42
  ### contentType.format(obj)
41
43
 
@@ -8,6 +8,7 @@
8
8
  */
9
9
  export interface ContentType {
10
10
  type: string;
11
+ index: number;
11
12
  parameters: Record<string, string>;
12
13
  }
13
14
  /**
@@ -18,7 +19,26 @@ export declare function format(obj: Partial<ContentType>): string;
18
19
  * Options for parsing a `Content-Type` header.
19
20
  */
20
21
  export interface ParseOptions {
22
+ /**
23
+ * Exit early on the first semicolon, returning only the type.
24
+ * This is useful for parsing the MIME from `Content-Type` headers.
25
+ *
26
+ * @default false
27
+ */
21
28
  parameters?: boolean;
29
+ /**
30
+ * Exits early on a comma, returning the first value and parameters.
31
+ * This is useful for parsing `Accept` headers.
32
+ *
33
+ * @default false
34
+ */
35
+ comma?: boolean;
36
+ /**
37
+ * The index to start parsing from.
38
+ *
39
+ * @default 0
40
+ */
41
+ start?: number;
22
42
  }
23
43
  /**
24
44
  * Parse a `Content-Type` header.
@@ -52,16 +52,17 @@ function format(obj) {
52
52
  * Parse a `Content-Type` header.
53
53
  */
54
54
  function parse(header, options) {
55
+ const stopChar = options?.comma === true ? COMMA : 65536; // Sentinel for "no stop char".
55
56
  const len = header.length;
56
- let index = skipOWS(header, 0, len);
57
+ let index = skipOWS(header, options?.start ?? 0, len);
57
58
  const valueStart = index;
58
- index = skipValue(header, index, len);
59
+ index = skipValue(header, index, len, stopChar);
59
60
  const valueEnd = trailingOWS(header, valueStart, index);
60
61
  const type = header.slice(valueStart, valueEnd).toLowerCase();
61
- const parameters = options?.parameters === false
62
- ? new NullObject()
63
- : parseParameters(header, index, len);
64
- return { type, parameters };
62
+ if (options?.parameters === false) {
63
+ return { type, index, parameters: new NullObject() };
64
+ }
65
+ return parseParameters(header, type, index, len, stopChar);
65
66
  }
66
67
  const SP = 32; // " "
67
68
  const HTAB = 9; // "\t"
@@ -69,16 +70,21 @@ const SEMI = 59; // ";"
69
70
  const EQ = 61; // "="
70
71
  const DQUOTE = 34; // '"'
71
72
  const BSLASH = 92; // "\\"
73
+ const COMMA = 44; // ","
72
74
  /**
73
75
  * Parses the parameters of a `Content-Type` header starting at the given index.
74
76
  */
75
- function parseParameters(header, index, len) {
77
+ function parseParameters(header, type, index, len, stopChar) {
76
78
  const parameters = new NullObject();
77
79
  parameter: while (index < len) {
80
+ if (header.charCodeAt(index) === stopChar)
81
+ break;
78
82
  index = skipOWS(header, index + 1 /* Skip over ; */, len);
79
83
  const keyStart = index;
80
84
  while (index < len) {
81
85
  const code = header.charCodeAt(index);
86
+ if (code === stopChar)
87
+ break parameter;
82
88
  if (code === SEMI)
83
89
  continue parameter;
84
90
  if (code === EQ) {
@@ -91,7 +97,7 @@ function parseParameters(header, index, len) {
91
97
  while (index < len) {
92
98
  const code = header.charCodeAt(index++);
93
99
  if (code === DQUOTE) {
94
- index = skipValue(header, index, len);
100
+ index = skipValue(header, index, len, stopChar);
95
101
  if (parameters[key] === undefined)
96
102
  parameters[key] = value;
97
103
  break;
@@ -105,7 +111,7 @@ function parseParameters(header, index, len) {
105
111
  continue parameter;
106
112
  }
107
113
  const valueStart = index;
108
- index = skipValue(header, index, len);
114
+ index = skipValue(header, index, len, stopChar);
109
115
  if (parameters[key] === undefined) {
110
116
  const valueEnd = trailingOWS(header, valueStart, index);
111
117
  parameters[key] = header.slice(valueStart, valueEnd);
@@ -115,15 +121,15 @@ function parseParameters(header, index, len) {
115
121
  index++;
116
122
  }
117
123
  }
118
- return parameters;
124
+ return { type, index, parameters };
119
125
  }
120
126
  /**
121
- * Skip over characters until a semicolon.
127
+ * Skip over characters until a semicolon or other exit character.
122
128
  */
123
- function skipValue(str, index, len) {
129
+ function skipValue(str, index, len, stopChar) {
124
130
  while (index < len) {
125
- const char = str.charCodeAt(index);
126
- if (char === SEMI)
131
+ const code = str.charCodeAt(index);
132
+ if (code === SEMI || code === stopChar)
127
133
  break;
128
134
  index++;
129
135
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAwCH,wBAoBC;AAYD,sBAcC;AApFD,MAAM,WAAW,GAAG,uCAAuC,CAAC;AAC5D,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD;;GAEG;AACH,MAAM,YAAY,GAAG,QAAQ,CAAC;AAE9B;;;;;;GAMG;AACH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AO,CAAC,GAAW;IAC1B,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACvC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC;IAE3E,MAAM,IAAI,SAAS,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * content-type\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nconst TEXT_REGEXP = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]*$/;\nconst TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4\n */\nconst QUOTE_REGEXP = /[\\\\\"]/g;\n\n/**\n * RegExp to match type in RFC 9110 sec 8.3.1\n *\n * media-type = type \"/\" subtype\n * type = token\n * subtype = token\n */\nconst TYPE_REGEXP =\n /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`.\n */\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () {};\n C.prototype = Object.create(null);\n return C;\n})() as unknown as { new (): any };\n\n/**\n * The content type object contains a type string and optional parameters.\n */\nexport interface ContentType {\n type: string;\n parameters: Record<string, string>;\n}\n\n/**\n * Format an object into a `Content-Type` header.\n */\nexport function format(obj: Partial<ContentType>): string {\n const { type, parameters } = obj;\n\n if (!type || !TYPE_REGEXP.test(type)) {\n throw new TypeError(`Invalid type: ${type}`);\n }\n\n let result = type;\n\n if (parameters) {\n for (const param of Object.keys(parameters)) {\n if (!TOKEN_REGEXP.test(param)) {\n throw new TypeError(`Invalid parameter name: ${param}`);\n }\n\n result += `; ${param}=${qstring(parameters[param])}`;\n }\n }\n\n return result;\n}\n\n/**\n * Options for parsing a `Content-Type` header.\n */\nexport interface ParseOptions {\n parameters?: boolean;\n}\n\n/**\n * Parse a `Content-Type` header.\n */\nexport function parse(header: string, options?: ParseOptions): ContentType {\n const len = header.length;\n let index = skipOWS(header, 0, len);\n\n const valueStart = index;\n index = skipValue(header, index, len);\n const valueEnd = trailingOWS(header, valueStart, index);\n const type = header.slice(valueStart, valueEnd).toLowerCase();\n const parameters =\n options?.parameters === false\n ? new NullObject()\n : parseParameters(header, index, len);\n\n return { type, parameters };\n}\n\nconst SP = 32; // \" \"\nconst HTAB = 9; // \"\\t\"\nconst SEMI = 59; // \";\"\nconst EQ = 61; // \"=\"\nconst DQUOTE = 34; // '\"'\nconst BSLASH = 92; // \"\\\\\"\n\n/**\n * Parses the parameters of a `Content-Type` header starting at the given index.\n */\nfunction parseParameters(\n header: string,\n index: number,\n len: number,\n): Record<string, string> {\n const parameters: Record<string, string> = new NullObject();\n\n parameter: while (index < len) {\n index = skipOWS(header, index + 1 /* Skip over ; */, len);\n\n const keyStart = index;\n\n while (index < len) {\n const code = header.charCodeAt(index);\n if (code === SEMI) continue parameter;\n\n if (code === EQ) {\n const keyEnd = trailingOWS(header, keyStart, index);\n const key = header.slice(keyStart, keyEnd).toLowerCase();\n\n index = skipOWS(header, index + 1, len);\n\n if (index < len && header.charCodeAt(index) === DQUOTE) {\n index++;\n\n let value = \"\";\n while (index < len) {\n const code = header.charCodeAt(index++);\n if (code === DQUOTE) {\n index = skipValue(header, index, len);\n if (parameters[key] === undefined) parameters[key] = value;\n break;\n }\n\n if (code === BSLASH && index < len) {\n value += header[index++];\n continue;\n }\n\n value += String.fromCharCode(code);\n }\n\n continue parameter;\n }\n\n const valueStart = index;\n index = skipValue(header, index, len);\n\n if (parameters[key] === undefined) {\n const valueEnd = trailingOWS(header, valueStart, index);\n parameters[key] = header.slice(valueStart, valueEnd);\n }\n\n continue parameter;\n }\n\n index++;\n }\n }\n\n return parameters;\n}\n\n/**\n * Skip over characters until a semicolon.\n */\nfunction skipValue(str: string, index: number, len: number): number {\n while (index < len) {\n const char = str.charCodeAt(index);\n if (char === SEMI) break;\n index++;\n }\n return index;\n}\n\n/**\n * Skip optional whitespace (OWS) in an HTTP header value.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction skipOWS(header: string, index: number, len: number): number {\n while (index < len) {\n const char = header.charCodeAt(index);\n if (char !== SP && char !== HTAB) break;\n index++;\n }\n return index;\n}\n\n/**\n * Trim optional whitespace (OWS) from the end of a substring.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction trailingOWS(header: string, start: number, end: number): number {\n while (end > start) {\n const char = header.charCodeAt(end - 1);\n if (char !== SP && char !== HTAB) break;\n end--;\n }\n return end;\n}\n\n/**\n * Serialize a parameter value.\n */\nfunction qstring(str: string): string {\n if (TOKEN_REGEXP.test(str)) return str;\n if (TEXT_REGEXP.test(str)) return `\"${str.replace(QUOTE_REGEXP, \"\\\\$&\")}\"`;\n\n throw new TypeError(`Invalid parameter value: ${str}`);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAyCH,wBAoBC;AA+BD,sBAeC;AAzGD,MAAM,WAAW,GAAG,uCAAuC,CAAC;AAC5D,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD;;GAEG;AACH,MAAM,YAAY,GAAG,QAAQ,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,WAAW,GACf,4DAA4D,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE;IACvC,MAAM,CAAC,GAAG,cAAa,CAAC,CAAC;IACzB,CAAC,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,CAAC,CAAC;AACX,C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AAK,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACxC,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,IAAI;YAAE,MAAM;QACxC,GAAG,EAAE,CAAC;IACR,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,GAAW;IAC1B,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACvC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC;IAE3E,MAAM,IAAI,SAAS,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * content-type\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nconst TEXT_REGEXP = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]*$/;\nconst TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4\n */\nconst QUOTE_REGEXP = /[\\\\\"]/g;\n\n/**\n * RegExp to match type in RFC 9110 sec 8.3.1\n *\n * media-type = type \"/\" subtype\n * type = token\n * subtype = token\n */\nconst TYPE_REGEXP =\n /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`.\n */\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () {};\n C.prototype = Object.create(null);\n return C;\n})() as unknown as { new (): any };\n\n/**\n * The content type object contains a type string and optional parameters.\n */\nexport interface ContentType {\n type: string;\n index: number;\n parameters: Record<string, string>;\n}\n\n/**\n * Format an object into a `Content-Type` header.\n */\nexport function format(obj: Partial<ContentType>): string {\n const { type, parameters } = obj;\n\n if (!type || !TYPE_REGEXP.test(type)) {\n throw new TypeError(`Invalid type: ${type}`);\n }\n\n let result = type;\n\n if (parameters) {\n for (const param of Object.keys(parameters)) {\n if (!TOKEN_REGEXP.test(param)) {\n throw new TypeError(`Invalid parameter name: ${param}`);\n }\n\n result += `; ${param}=${qstring(parameters[param])}`;\n }\n }\n\n return result;\n}\n\n/**\n * Options for parsing a `Content-Type` header.\n */\nexport interface ParseOptions {\n /**\n * Exit early on the first semicolon, returning only the type.\n * This is useful for parsing the MIME from `Content-Type` headers.\n *\n * @default false\n */\n parameters?: boolean;\n /**\n * Exits early on a comma, returning the first value and parameters.\n * This is useful for parsing `Accept` headers.\n *\n * @default false\n */\n comma?: boolean;\n /**\n * The index to start parsing from.\n *\n * @default 0\n */\n start?: number;\n}\n\n/**\n * Parse a `Content-Type` header.\n */\nexport function parse(header: string, options?: ParseOptions): ContentType {\n const stopChar = options?.comma === true ? COMMA : 65_536; // Sentinel for \"no stop char\".\n const len = header.length;\n let index = skipOWS(header, options?.start ?? 0, len);\n\n const valueStart = index;\n index = skipValue(header, index, len, stopChar);\n const valueEnd = trailingOWS(header, valueStart, index);\n const type = header.slice(valueStart, valueEnd).toLowerCase();\n\n if (options?.parameters === false) {\n return { type, index, parameters: new NullObject() };\n }\n\n return parseParameters(header, type, index, len, stopChar);\n}\n\nconst SP = 32; // \" \"\nconst HTAB = 9; // \"\\t\"\nconst SEMI = 59; // \";\"\nconst EQ = 61; // \"=\"\nconst DQUOTE = 34; // '\"'\nconst BSLASH = 92; // \"\\\\\"\nconst COMMA = 44; // \",\"\n\n/**\n * Parses the parameters of a `Content-Type` header starting at the given index.\n */\nfunction parseParameters(\n header: string,\n type: string,\n index: number,\n len: number,\n stopChar: number,\n): ContentType {\n const parameters: Record<string, string> = new NullObject();\n\n parameter: while (index < len) {\n if (header.charCodeAt(index) === stopChar) break;\n\n index = skipOWS(header, index + 1 /* Skip over ; */, len);\n\n const keyStart = index;\n\n while (index < len) {\n const code = header.charCodeAt(index);\n if (code === stopChar) break parameter;\n\n if (code === SEMI) continue parameter;\n\n if (code === EQ) {\n const keyEnd = trailingOWS(header, keyStart, index);\n const key = header.slice(keyStart, keyEnd).toLowerCase();\n\n index = skipOWS(header, index + 1, len);\n\n if (index < len && header.charCodeAt(index) === DQUOTE) {\n index++;\n\n let value = \"\";\n while (index < len) {\n const code = header.charCodeAt(index++);\n if (code === DQUOTE) {\n index = skipValue(header, index, len, stopChar);\n if (parameters[key] === undefined) parameters[key] = value;\n break;\n }\n\n if (code === BSLASH && index < len) {\n value += header[index++];\n continue;\n }\n\n value += String.fromCharCode(code);\n }\n\n continue parameter;\n }\n\n const valueStart = index;\n index = skipValue(header, index, len, stopChar);\n\n if (parameters[key] === undefined) {\n const valueEnd = trailingOWS(header, valueStart, index);\n parameters[key] = header.slice(valueStart, valueEnd);\n }\n\n continue parameter;\n }\n\n index++;\n }\n }\n\n return { type, index, parameters };\n}\n\n/**\n * Skip over characters until a semicolon or other exit character.\n */\nfunction skipValue(\n str: string,\n index: number,\n len: number,\n stopChar: number,\n): number {\n while (index < len) {\n const code = str.charCodeAt(index);\n if (code === SEMI || code === stopChar) break;\n index++;\n }\n return index;\n}\n\n/**\n * Skip optional whitespace (OWS) in an HTTP header value.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction skipOWS(header: string, index: number, len: number): number {\n while (index < len) {\n const char = header.charCodeAt(index);\n if (char !== SP && char !== HTAB) break;\n index++;\n }\n return index;\n}\n\n/**\n * Trim optional whitespace (OWS) from the end of a substring.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction trailingOWS(header: string, start: number, end: number): number {\n while (end > start) {\n const char = header.charCodeAt(end - 1);\n if (char !== SP && char !== HTAB) break;\n end--;\n }\n return end;\n}\n\n/**\n * Serialize a parameter value.\n */\nfunction qstring(str: string): string {\n if (TOKEN_REGEXP.test(str)) return str;\n if (TEXT_REGEXP.test(str)) return `\"${str.replace(QUOTE_REGEXP, \"\\\\$&\")}\"`;\n\n throw new TypeError(`Invalid parameter value: ${str}`);\n}\n"]}