@nocobase/plugin-idp-oauth 2.1.0-alpha.10

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 (451) hide show
  1. package/LICENSE.txt +107 -0
  2. package/README.md +14 -0
  3. package/build.config.ts +46 -0
  4. package/client.d.ts +2 -0
  5. package/client.js +1 -0
  6. package/dist/client/ErrorPage.d.ts +11 -0
  7. package/dist/client/InteractionPage.d.ts +11 -0
  8. package/dist/client/index.d.ts +9 -0
  9. package/dist/client/index.js +10 -0
  10. package/dist/client/locale.d.ts +10 -0
  11. package/dist/client/models/index.d.ts +11 -0
  12. package/dist/client/plugin.d.ts +13 -0
  13. package/dist/externalVersion.js +18 -0
  14. package/dist/index.d.ts +10 -0
  15. package/dist/index.js +48 -0
  16. package/dist/locale/en-US.json +1 -0
  17. package/dist/locale/zh-CN.json +1 -0
  18. package/dist/node_modules/eta/LICENSE +7 -0
  19. package/dist/node_modules/eta/README.md +185 -0
  20. package/dist/node_modules/eta/dist/core.d.ts +179 -0
  21. package/dist/node_modules/eta/dist/core.d.ts.map +1 -0
  22. package/dist/node_modules/eta/dist/core.js +42 -0
  23. package/dist/node_modules/eta/dist/core.js.map +1 -0
  24. package/dist/node_modules/eta/dist/index.cjs +542 -0
  25. package/dist/node_modules/eta/dist/index.cjs.map +1 -0
  26. package/dist/node_modules/eta/dist/index.d.cts +187 -0
  27. package/dist/node_modules/eta/dist/index.d.cts.map +1 -0
  28. package/dist/node_modules/eta/dist/index.d.mts +187 -0
  29. package/dist/node_modules/eta/dist/index.d.mts.map +1 -0
  30. package/dist/node_modules/eta/dist/index.mjs +512 -0
  31. package/dist/node_modules/eta/dist/index.mjs.map +1 -0
  32. package/dist/node_modules/eta/package.json +75 -0
  33. package/dist/node_modules/jose/LICENSE.md +21 -0
  34. package/dist/node_modules/jose/README.md +153 -0
  35. package/dist/node_modules/jose/dist/types/index.d.ts +55 -0
  36. package/dist/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +31 -0
  37. package/dist/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +65 -0
  38. package/dist/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +31 -0
  39. package/dist/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +83 -0
  40. package/dist/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +38 -0
  41. package/dist/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +74 -0
  42. package/dist/node_modules/jose/dist/types/jwk/embedded.d.ts +17 -0
  43. package/dist/node_modules/jose/dist/types/jwk/thumbprint.d.ts +32 -0
  44. package/dist/node_modules/jose/dist/types/jwks/local.d.ts +29 -0
  45. package/dist/node_modules/jose/dist/types/jwks/remote.d.ts +237 -0
  46. package/dist/node_modules/jose/dist/types/jws/compact/sign.d.ts +36 -0
  47. package/dist/node_modules/jose/dist/types/jws/compact/verify.d.ts +33 -0
  48. package/dist/node_modules/jose/dist/types/jws/flattened/sign.d.ts +42 -0
  49. package/dist/node_modules/jose/dist/types/jws/flattened/verify.d.ts +33 -0
  50. package/dist/node_modules/jose/dist/types/jws/general/sign.d.ts +53 -0
  51. package/dist/node_modules/jose/dist/types/jws/general/verify.d.ts +41 -0
  52. package/dist/node_modules/jose/dist/types/jwt/decrypt.d.ts +35 -0
  53. package/dist/node_modules/jose/dist/types/jwt/encrypt.d.ts +91 -0
  54. package/dist/node_modules/jose/dist/types/jwt/sign.d.ts +43 -0
  55. package/dist/node_modules/jose/dist/types/jwt/unsecured.d.ts +43 -0
  56. package/dist/node_modules/jose/dist/types/jwt/verify.d.ts +37 -0
  57. package/dist/node_modules/jose/dist/types/key/export.d.ts +33 -0
  58. package/dist/node_modules/jose/dist/types/key/generate_key_pair.d.ts +47 -0
  59. package/dist/node_modules/jose/dist/types/key/generate_secret.d.ts +35 -0
  60. package/dist/node_modules/jose/dist/types/key/import.d.ts +83 -0
  61. package/dist/node_modules/jose/dist/types/types.d.ts +852 -0
  62. package/dist/node_modules/jose/dist/types/util/base64url.d.ts +9 -0
  63. package/dist/node_modules/jose/dist/types/util/decode_jwt.d.ts +18 -0
  64. package/dist/node_modules/jose/dist/types/util/decode_protected_header.d.ts +17 -0
  65. package/dist/node_modules/jose/dist/types/util/errors.d.ts +213 -0
  66. package/dist/node_modules/jose/dist/webapi/index.js +32 -0
  67. package/dist/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +27 -0
  68. package/dist/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +27 -0
  69. package/dist/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +155 -0
  70. package/dist/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +165 -0
  71. package/dist/node_modules/jose/dist/webapi/jwe/general/decrypt.js +31 -0
  72. package/dist/node_modules/jose/dist/webapi/jwe/general/encrypt.js +182 -0
  73. package/dist/node_modules/jose/dist/webapi/jwk/embedded.js +17 -0
  74. package/dist/node_modules/jose/dist/webapi/jwk/thumbprint.js +68 -0
  75. package/dist/node_modules/jose/dist/webapi/jwks/local.js +119 -0
  76. package/dist/node_modules/jose/dist/webapi/jwks/remote.js +179 -0
  77. package/dist/node_modules/jose/dist/webapi/jws/compact/sign.js +18 -0
  78. package/dist/node_modules/jose/dist/webapi/jws/compact/verify.js +21 -0
  79. package/dist/node_modules/jose/dist/webapi/jws/flattened/sign.js +89 -0
  80. package/dist/node_modules/jose/dist/webapi/jws/flattened/verify.js +110 -0
  81. package/dist/node_modules/jose/dist/webapi/jws/general/sign.js +70 -0
  82. package/dist/node_modules/jose/dist/webapi/jws/general/verify.js +24 -0
  83. package/dist/node_modules/jose/dist/webapi/jwt/decrypt.js +23 -0
  84. package/dist/node_modules/jose/dist/webapi/jwt/encrypt.js +101 -0
  85. package/dist/node_modules/jose/dist/webapi/jwt/sign.js +52 -0
  86. package/dist/node_modules/jose/dist/webapi/jwt/unsecured.js +63 -0
  87. package/dist/node_modules/jose/dist/webapi/jwt/verify.js +15 -0
  88. package/dist/node_modules/jose/dist/webapi/key/export.js +11 -0
  89. package/dist/node_modules/jose/dist/webapi/key/generate_key_pair.js +97 -0
  90. package/dist/node_modules/jose/dist/webapi/key/generate_secret.js +40 -0
  91. package/dist/node_modules/jose/dist/webapi/key/import.js +57 -0
  92. package/dist/node_modules/jose/dist/webapi/lib/aesgcmkw.js +15 -0
  93. package/dist/node_modules/jose/dist/webapi/lib/aeskw.js +25 -0
  94. package/dist/node_modules/jose/dist/webapi/lib/asn1.js +243 -0
  95. package/dist/node_modules/jose/dist/webapi/lib/base64.js +22 -0
  96. package/dist/node_modules/jose/dist/webapi/lib/buffer_utils.js +43 -0
  97. package/dist/node_modules/jose/dist/webapi/lib/check_key_type.js +122 -0
  98. package/dist/node_modules/jose/dist/webapi/lib/content_encryption.js +217 -0
  99. package/dist/node_modules/jose/dist/webapi/lib/crypto_key.js +136 -0
  100. package/dist/node_modules/jose/dist/webapi/lib/deflate.js +44 -0
  101. package/dist/node_modules/jose/dist/webapi/lib/ecdhes.js +52 -0
  102. package/dist/node_modules/jose/dist/webapi/lib/helpers.js +19 -0
  103. package/dist/node_modules/jose/dist/webapi/lib/invalid_key_input.js +27 -0
  104. package/dist/node_modules/jose/dist/webapi/lib/is_key_like.js +17 -0
  105. package/dist/node_modules/jose/dist/webapi/lib/jwk_to_key.js +107 -0
  106. package/dist/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +238 -0
  107. package/dist/node_modules/jose/dist/webapi/lib/key_management.js +186 -0
  108. package/dist/node_modules/jose/dist/webapi/lib/key_to_jwk.js +31 -0
  109. package/dist/node_modules/jose/dist/webapi/lib/normalize_key.js +166 -0
  110. package/dist/node_modules/jose/dist/webapi/lib/pbes2kw.js +39 -0
  111. package/dist/node_modules/jose/dist/webapi/lib/rsaes.js +24 -0
  112. package/dist/node_modules/jose/dist/webapi/lib/signing.js +68 -0
  113. package/dist/node_modules/jose/dist/webapi/lib/type_checks.js +40 -0
  114. package/dist/node_modules/jose/dist/webapi/lib/validate_algorithms.js +10 -0
  115. package/dist/node_modules/jose/dist/webapi/lib/validate_crit.js +33 -0
  116. package/dist/node_modules/jose/dist/webapi/util/base64url.js +30 -0
  117. package/dist/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -0
  118. package/dist/node_modules/jose/dist/webapi/util/decode_protected_header.js +34 -0
  119. package/dist/node_modules/jose/dist/webapi/util/errors.js +99 -0
  120. package/dist/node_modules/jose/package.json +200 -0
  121. package/dist/node_modules/light-my-request/.gitattributes +2 -0
  122. package/dist/node_modules/light-my-request/.github/dependabot.yml +13 -0
  123. package/dist/node_modules/light-my-request/.github/stale.yml +21 -0
  124. package/dist/node_modules/light-my-request/.github/workflows/benchmark.yml +30 -0
  125. package/dist/node_modules/light-my-request/.github/workflows/ci.yml +23 -0
  126. package/dist/node_modules/light-my-request/LICENSE +32 -0
  127. package/dist/node_modules/light-my-request/benchmark/benchmark.js +164 -0
  128. package/dist/node_modules/light-my-request/build/build-validation.js +100 -0
  129. package/dist/node_modules/light-my-request/eslint.config.js +9 -0
  130. package/dist/node_modules/light-my-request/index.js +2 -0
  131. package/dist/node_modules/light-my-request/lib/config-validator.js +919 -0
  132. package/dist/node_modules/light-my-request/lib/form-data.js +79 -0
  133. package/dist/node_modules/light-my-request/lib/parse-url.js +47 -0
  134. package/dist/node_modules/light-my-request/lib/request.js +290 -0
  135. package/dist/node_modules/light-my-request/lib/response.js +240 -0
  136. package/dist/node_modules/light-my-request/node_modules/process-warning/.gitattributes +2 -0
  137. package/dist/node_modules/light-my-request/node_modules/process-warning/.github/dependabot.yml +13 -0
  138. package/dist/node_modules/light-my-request/node_modules/process-warning/.github/workflows/ci.yml +24 -0
  139. package/dist/node_modules/light-my-request/node_modules/process-warning/.taprc +2 -0
  140. package/dist/node_modules/light-my-request/node_modules/process-warning/benchmarks/warn.js +25 -0
  141. package/dist/node_modules/light-my-request/node_modules/process-warning/eslint.config.js +6 -0
  142. package/dist/node_modules/light-my-request/node_modules/process-warning/examples/example.js +11 -0
  143. package/dist/node_modules/light-my-request/node_modules/process-warning/index.js +124 -0
  144. package/dist/node_modules/light-my-request/node_modules/process-warning/package.json +73 -0
  145. package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-interpolated-string.test.js +29 -0
  146. package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-once-only.test.js +28 -0
  147. package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-reset.test.js +36 -0
  148. package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-set.test.js +30 -0
  149. package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-unlimited.test.js +37 -0
  150. package/dist/node_modules/light-my-request/node_modules/process-warning/test/index.test.js +99 -0
  151. package/dist/node_modules/light-my-request/node_modules/process-warning/test/issue-88.test.js +33 -0
  152. package/dist/node_modules/light-my-request/node_modules/process-warning/test/jest.test.js +22 -0
  153. package/dist/node_modules/light-my-request/node_modules/process-warning/test/no-warnings.test.js +80 -0
  154. package/dist/node_modules/light-my-request/node_modules/process-warning/types/index.d.ts +37 -0
  155. package/dist/node_modules/light-my-request/node_modules/process-warning/types/index.test-d.ts +36 -0
  156. package/dist/node_modules/light-my-request/package.json +1 -0
  157. package/dist/node_modules/light-my-request/test/async-await.test.js +55 -0
  158. package/dist/node_modules/light-my-request/test/index.test.js +2316 -0
  159. package/dist/node_modules/light-my-request/test/request.test.js +16 -0
  160. package/dist/node_modules/light-my-request/test/response.test.js +19 -0
  161. package/dist/node_modules/light-my-request/test/stream.test.js +359 -0
  162. package/dist/node_modules/light-my-request/types/index.d.ts +128 -0
  163. package/dist/node_modules/light-my-request/types/index.test-d.ts +149 -0
  164. package/dist/node_modules/oidc-provider/LICENSE.md +21 -0
  165. package/dist/node_modules/oidc-provider/README.md +174 -0
  166. package/dist/node_modules/oidc-provider/lib/actions/authorization/assign_claims.js +28 -0
  167. package/dist/node_modules/oidc-provider/lib/actions/authorization/assign_defaults.js +17 -0
  168. package/dist/node_modules/oidc-provider/lib/actions/authorization/authenticated_client_id.js +6 -0
  169. package/dist/node_modules/oidc-provider/lib/actions/authorization/backchannel_request_remap_errors.js +17 -0
  170. package/dist/node_modules/oidc-provider/lib/actions/authorization/backchannel_request_response.js +41 -0
  171. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_ciba_context.js +12 -0
  172. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_claims.js +68 -0
  173. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_client.js +21 -0
  174. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_client_grant_type.js +21 -0
  175. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_dpop_jkt.js +35 -0
  176. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_extra_params.js +18 -0
  177. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_id_token_hint.js +23 -0
  178. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_max_age.js +25 -0
  179. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_openid_scope.js +47 -0
  180. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_pkce.js +41 -0
  181. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_prompt.js +25 -0
  182. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_redirect_uri.js +41 -0
  183. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_requested_expiry.js +16 -0
  184. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_response_mode.js +54 -0
  185. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_response_type.js +26 -0
  186. package/dist/node_modules/oidc-provider/lib/actions/authorization/check_scope.js +53 -0
  187. package/dist/node_modules/oidc-provider/lib/actions/authorization/ciba_load_account.js +58 -0
  188. package/dist/node_modules/oidc-provider/lib/actions/authorization/ciba_required.js +13 -0
  189. package/dist/node_modules/oidc-provider/lib/actions/authorization/device_authorization_response.js +31 -0
  190. package/dist/node_modules/oidc-provider/lib/actions/authorization/device_user_flow.js +31 -0
  191. package/dist/node_modules/oidc-provider/lib/actions/authorization/device_user_flow_errors.js +37 -0
  192. package/dist/node_modules/oidc-provider/lib/actions/authorization/device_user_flow_response.js +55 -0
  193. package/dist/node_modules/oidc-provider/lib/actions/authorization/index.js +200 -0
  194. package/dist/node_modules/oidc-provider/lib/actions/authorization/interaction_emit.js +9 -0
  195. package/dist/node_modules/oidc-provider/lib/actions/authorization/interactions.js +149 -0
  196. package/dist/node_modules/oidc-provider/lib/actions/authorization/load_account.js +15 -0
  197. package/dist/node_modules/oidc-provider/lib/actions/authorization/load_grant.js +29 -0
  198. package/dist/node_modules/oidc-provider/lib/actions/authorization/load_pushed_authorization_request.js +36 -0
  199. package/dist/node_modules/oidc-provider/lib/actions/authorization/oauth_required.js +11 -0
  200. package/dist/node_modules/oidc-provider/lib/actions/authorization/oidc_required.js +27 -0
  201. package/dist/node_modules/oidc-provider/lib/actions/authorization/one_redirect_uri_clients.js +20 -0
  202. package/dist/node_modules/oidc-provider/lib/actions/authorization/process_request_object.js +214 -0
  203. package/dist/node_modules/oidc-provider/lib/actions/authorization/pushed_authorization_request_remap_errors.js +17 -0
  204. package/dist/node_modules/oidc-provider/lib/actions/authorization/pushed_authorization_request_response.js +65 -0
  205. package/dist/node_modules/oidc-provider/lib/actions/authorization/reject_registration.js +12 -0
  206. package/dist/node_modules/oidc-provider/lib/actions/authorization/reject_request_and_uri.js +12 -0
  207. package/dist/node_modules/oidc-provider/lib/actions/authorization/reject_unsupported.js +33 -0
  208. package/dist/node_modules/oidc-provider/lib/actions/authorization/respond.js +46 -0
  209. package/dist/node_modules/oidc-provider/lib/actions/authorization/resume.js +111 -0
  210. package/dist/node_modules/oidc-provider/lib/actions/authorization/strip_outside_jar_params.js +19 -0
  211. package/dist/node_modules/oidc-provider/lib/actions/authorization/unsupported_rar.js +9 -0
  212. package/dist/node_modules/oidc-provider/lib/actions/challenge.js +22 -0
  213. package/dist/node_modules/oidc-provider/lib/actions/code_verification.js +122 -0
  214. package/dist/node_modules/oidc-provider/lib/actions/discovery.js +151 -0
  215. package/dist/node_modules/oidc-provider/lib/actions/end_session.js +222 -0
  216. package/dist/node_modules/oidc-provider/lib/actions/grants/authorization_code.js +144 -0
  217. package/dist/node_modules/oidc-provider/lib/actions/grants/ciba.js +127 -0
  218. package/dist/node_modules/oidc-provider/lib/actions/grants/client_credentials.js +79 -0
  219. package/dist/node_modules/oidc-provider/lib/actions/grants/device_code.js +125 -0
  220. package/dist/node_modules/oidc-provider/lib/actions/grants/index.js +7 -0
  221. package/dist/node_modules/oidc-provider/lib/actions/grants/refresh_token.js +229 -0
  222. package/dist/node_modules/oidc-provider/lib/actions/index.js +25 -0
  223. package/dist/node_modules/oidc-provider/lib/actions/interaction.js +150 -0
  224. package/dist/node_modules/oidc-provider/lib/actions/introspection.js +164 -0
  225. package/dist/node_modules/oidc-provider/lib/actions/jwks.js +7 -0
  226. package/dist/node_modules/oidc-provider/lib/actions/registration.js +274 -0
  227. package/dist/node_modules/oidc-provider/lib/actions/revocation.js +81 -0
  228. package/dist/node_modules/oidc-provider/lib/actions/token.js +74 -0
  229. package/dist/node_modules/oidc-provider/lib/actions/userinfo.js +183 -0
  230. package/dist/node_modules/oidc-provider/lib/adapters/memory_adapter.js +95 -0
  231. package/dist/node_modules/oidc-provider/lib/consts/client_attributes.js +211 -0
  232. package/dist/node_modules/oidc-provider/lib/consts/dev_keystore.js +18 -0
  233. package/dist/node_modules/oidc-provider/lib/consts/index.js +13 -0
  234. package/dist/node_modules/oidc-provider/lib/consts/jwa.js +47 -0
  235. package/dist/node_modules/oidc-provider/lib/consts/non_rejectable_claims.js +1 -0
  236. package/dist/node_modules/oidc-provider/lib/consts/param_list.js +23 -0
  237. package/dist/node_modules/oidc-provider/lib/helpers/_/camel_case.js +1 -0
  238. package/dist/node_modules/oidc-provider/lib/helpers/_/defaults.js +28 -0
  239. package/dist/node_modules/oidc-provider/lib/helpers/_/difference.js +1 -0
  240. package/dist/node_modules/oidc-provider/lib/helpers/_/is_plain_object.js +1 -0
  241. package/dist/node_modules/oidc-provider/lib/helpers/_/map_keys.js +9 -0
  242. package/dist/node_modules/oidc-provider/lib/helpers/_/merge.js +25 -0
  243. package/dist/node_modules/oidc-provider/lib/helpers/_/omit_by.js +11 -0
  244. package/dist/node_modules/oidc-provider/lib/helpers/_/pick.js +10 -0
  245. package/dist/node_modules/oidc-provider/lib/helpers/_/pick_by.js +10 -0
  246. package/dist/node_modules/oidc-provider/lib/helpers/_/remove.js +9 -0
  247. package/dist/node_modules/oidc-provider/lib/helpers/_/set.js +18 -0
  248. package/dist/node_modules/oidc-provider/lib/helpers/_/snake_case.js +1 -0
  249. package/dist/node_modules/oidc-provider/lib/helpers/_/upper_first.js +1 -0
  250. package/dist/node_modules/oidc-provider/lib/helpers/account_claims.js +6 -0
  251. package/dist/node_modules/oidc-provider/lib/helpers/add_client.js +14 -0
  252. package/dist/node_modules/oidc-provider/lib/helpers/als.js +3 -0
  253. package/dist/node_modules/oidc-provider/lib/helpers/append_www_authenticate.js +9 -0
  254. package/dist/node_modules/oidc-provider/lib/helpers/attention.js +23 -0
  255. package/dist/node_modules/oidc-provider/lib/helpers/base64url.js +11 -0
  256. package/dist/node_modules/oidc-provider/lib/helpers/certificate_thumbprint.js +15 -0
  257. package/dist/node_modules/oidc-provider/lib/helpers/challenge.js +111 -0
  258. package/dist/node_modules/oidc-provider/lib/helpers/check_attest_binding.js +10 -0
  259. package/dist/node_modules/oidc-provider/lib/helpers/claims.js +79 -0
  260. package/dist/node_modules/oidc-provider/lib/helpers/client_id_metadata_document.js +198 -0
  261. package/dist/node_modules/oidc-provider/lib/helpers/client_schema.js +700 -0
  262. package/dist/node_modules/oidc-provider/lib/helpers/combined_scope.js +17 -0
  263. package/dist/node_modules/oidc-provider/lib/helpers/configuration.js +544 -0
  264. package/dist/node_modules/oidc-provider/lib/helpers/constant_equals.js +20 -0
  265. package/dist/node_modules/oidc-provider/lib/helpers/defaults.js +3510 -0
  266. package/dist/node_modules/oidc-provider/lib/helpers/epoch_time.js +1 -0
  267. package/dist/node_modules/oidc-provider/lib/helpers/err_out.js +17 -0
  268. package/dist/node_modules/oidc-provider/lib/helpers/errors.js +161 -0
  269. package/dist/node_modules/oidc-provider/lib/helpers/features.js +51 -0
  270. package/dist/node_modules/oidc-provider/lib/helpers/fetch_body_check.js +25 -0
  271. package/dist/node_modules/oidc-provider/lib/helpers/fetch_request.js +221 -0
  272. package/dist/node_modules/oidc-provider/lib/helpers/filter_claims.js +16 -0
  273. package/dist/node_modules/oidc-provider/lib/helpers/formatters.js +24 -0
  274. package/dist/node_modules/oidc-provider/lib/helpers/grant_common.js +214 -0
  275. package/dist/node_modules/oidc-provider/lib/helpers/html_safe.js +19 -0
  276. package/dist/node_modules/oidc-provider/lib/helpers/initialize_adapter.js +24 -0
  277. package/dist/node_modules/oidc-provider/lib/helpers/initialize_app.js +243 -0
  278. package/dist/node_modules/oidc-provider/lib/helpers/initialize_clients.js +24 -0
  279. package/dist/node_modules/oidc-provider/lib/helpers/initialize_keystore.js +310 -0
  280. package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/check.js +21 -0
  281. package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/index.js +43 -0
  282. package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/prompt.js +95 -0
  283. package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/prompts/consent.js +105 -0
  284. package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/prompts/login.js +162 -0
  285. package/dist/node_modules/oidc-provider/lib/helpers/jwt.js +211 -0
  286. package/dist/node_modules/oidc-provider/lib/helpers/keystore.js +301 -0
  287. package/dist/node_modules/oidc-provider/lib/helpers/nanoid.js +5 -0
  288. package/dist/node_modules/oidc-provider/lib/helpers/oidc_context.js +284 -0
  289. package/dist/node_modules/oidc-provider/lib/helpers/params.js +27 -0
  290. package/dist/node_modules/oidc-provider/lib/helpers/pkce.js +30 -0
  291. package/dist/node_modules/oidc-provider/lib/helpers/pkce_format.js +17 -0
  292. package/dist/node_modules/oidc-provider/lib/helpers/process_response_types.js +202 -0
  293. package/dist/node_modules/oidc-provider/lib/helpers/re_render_errors.js +39 -0
  294. package/dist/node_modules/oidc-provider/lib/helpers/redirect_uri.js +16 -0
  295. package/dist/node_modules/oidc-provider/lib/helpers/resolve_resource.js +33 -0
  296. package/dist/node_modules/oidc-provider/lib/helpers/resolve_response_mode.js +7 -0
  297. package/dist/node_modules/oidc-provider/lib/helpers/resource_server.js +20 -0
  298. package/dist/node_modules/oidc-provider/lib/helpers/revoke.js +27 -0
  299. package/dist/node_modules/oidc-provider/lib/helpers/script_src_sha.js +21 -0
  300. package/dist/node_modules/oidc-provider/lib/helpers/sector_identifier.js +19 -0
  301. package/dist/node_modules/oidc-provider/lib/helpers/sector_validate.js +55 -0
  302. package/dist/node_modules/oidc-provider/lib/helpers/set_rt_bindings.js +21 -0
  303. package/dist/node_modules/oidc-provider/lib/helpers/token_find.js +51 -0
  304. package/dist/node_modules/oidc-provider/lib/helpers/type_validators.js +8 -0
  305. package/dist/node_modules/oidc-provider/lib/helpers/user_code_form.js +19 -0
  306. package/dist/node_modules/oidc-provider/lib/helpers/user_codes.js +38 -0
  307. package/dist/node_modules/oidc-provider/lib/helpers/valid_url.js +8 -0
  308. package/dist/node_modules/oidc-provider/lib/helpers/validate_dpop.js +129 -0
  309. package/dist/node_modules/oidc-provider/lib/helpers/validate_presence.js +17 -0
  310. package/dist/node_modules/oidc-provider/lib/helpers/weak_cache.js +11 -0
  311. package/dist/node_modules/oidc-provider/lib/index.js +21 -0
  312. package/dist/node_modules/oidc-provider/lib/models/access_token.js +31 -0
  313. package/dist/node_modules/oidc-provider/lib/models/authorization_code.js +27 -0
  314. package/dist/node_modules/oidc-provider/lib/models/backchannel_authentication_request.js +26 -0
  315. package/dist/node_modules/oidc-provider/lib/models/base_model.js +141 -0
  316. package/dist/node_modules/oidc-provider/lib/models/base_token.js +86 -0
  317. package/dist/node_modules/oidc-provider/lib/models/client.js +593 -0
  318. package/dist/node_modules/oidc-provider/lib/models/client_credentials.js +19 -0
  319. package/dist/node_modules/oidc-provider/lib/models/device_code.js +44 -0
  320. package/dist/node_modules/oidc-provider/lib/models/formats/dynamic.js +21 -0
  321. package/dist/node_modules/oidc-provider/lib/models/formats/index.js +14 -0
  322. package/dist/node_modules/oidc-provider/lib/models/formats/jwt.js +198 -0
  323. package/dist/node_modules/oidc-provider/lib/models/formats/opaque.js +58 -0
  324. package/dist/node_modules/oidc-provider/lib/models/grant.js +243 -0
  325. package/dist/node_modules/oidc-provider/lib/models/id_token.js +271 -0
  326. package/dist/node_modules/oidc-provider/lib/models/index.js +37 -0
  327. package/dist/node_modules/oidc-provider/lib/models/initial_access_token.js +12 -0
  328. package/dist/node_modules/oidc-provider/lib/models/interaction.js +73 -0
  329. package/dist/node_modules/oidc-provider/lib/models/mixins/apply.js +4 -0
  330. package/dist/node_modules/oidc-provider/lib/models/mixins/consumable.js +17 -0
  331. package/dist/node_modules/oidc-provider/lib/models/mixins/has_format.js +46 -0
  332. package/dist/node_modules/oidc-provider/lib/models/mixins/has_grant_id.js +12 -0
  333. package/dist/node_modules/oidc-provider/lib/models/mixins/has_grant_type.js +8 -0
  334. package/dist/node_modules/oidc-provider/lib/models/mixins/has_policies.js +38 -0
  335. package/dist/node_modules/oidc-provider/lib/models/mixins/is_attestation_constrained.js +15 -0
  336. package/dist/node_modules/oidc-provider/lib/models/mixins/is_sender_constrained.js +50 -0
  337. package/dist/node_modules/oidc-provider/lib/models/mixins/is_session_bound.js +38 -0
  338. package/dist/node_modules/oidc-provider/lib/models/mixins/set_audience.js +21 -0
  339. package/dist/node_modules/oidc-provider/lib/models/mixins/stores_auth.js +16 -0
  340. package/dist/node_modules/oidc-provider/lib/models/mixins/stores_pkce.js +9 -0
  341. package/dist/node_modules/oidc-provider/lib/models/pushed_authorization_request.js +21 -0
  342. package/dist/node_modules/oidc-provider/lib/models/refresh_token.js +47 -0
  343. package/dist/node_modules/oidc-provider/lib/models/registration_access_token.js +8 -0
  344. package/dist/node_modules/oidc-provider/lib/models/replay_detection.js +31 -0
  345. package/dist/node_modules/oidc-provider/lib/models/session.js +192 -0
  346. package/dist/node_modules/oidc-provider/lib/provider.js +453 -0
  347. package/dist/node_modules/oidc-provider/lib/response_modes/form_post.js +36 -0
  348. package/dist/node_modules/oidc-provider/lib/response_modes/fragment.js +7 -0
  349. package/dist/node_modules/oidc-provider/lib/response_modes/index.js +15 -0
  350. package/dist/node_modules/oidc-provider/lib/response_modes/jwt.js +43 -0
  351. package/dist/node_modules/oidc-provider/lib/response_modes/query.js +7 -0
  352. package/dist/node_modules/oidc-provider/lib/response_modes/web_message.js +55 -0
  353. package/dist/node_modules/oidc-provider/lib/shared/assemble_params.js +7 -0
  354. package/dist/node_modules/oidc-provider/lib/shared/attest_client_auth.js +111 -0
  355. package/dist/node_modules/oidc-provider/lib/shared/authorization_error_handler.js +104 -0
  356. package/dist/node_modules/oidc-provider/lib/shared/check_rar.js +75 -0
  357. package/dist/node_modules/oidc-provider/lib/shared/check_resource.js +77 -0
  358. package/dist/node_modules/oidc-provider/lib/shared/client_auth.js +263 -0
  359. package/dist/node_modules/oidc-provider/lib/shared/conditional_body.js +9 -0
  360. package/dist/node_modules/oidc-provider/lib/shared/cors.js +49 -0
  361. package/dist/node_modules/oidc-provider/lib/shared/error_handler.js +59 -0
  362. package/dist/node_modules/oidc-provider/lib/shared/jwt_client_auth.js +79 -0
  363. package/dist/node_modules/oidc-provider/lib/shared/no_cache.js +4 -0
  364. package/dist/node_modules/oidc-provider/lib/shared/reject_dupes.js +45 -0
  365. package/dist/node_modules/oidc-provider/lib/shared/reject_structured_tokens.js +18 -0
  366. package/dist/node_modules/oidc-provider/lib/shared/selective_body.js +60 -0
  367. package/dist/node_modules/oidc-provider/lib/shared/session.js +68 -0
  368. package/dist/node_modules/oidc-provider/lib/shared/set_www_authenticate_header.js +52 -0
  369. package/dist/node_modules/oidc-provider/lib/views/index.js +22 -0
  370. package/dist/node_modules/oidc-provider/lib/views/interaction.js +171 -0
  371. package/dist/node_modules/oidc-provider/lib/views/layout.js +237 -0
  372. package/dist/node_modules/oidc-provider/lib/views/login.js +43 -0
  373. package/dist/node_modules/oidc-provider/node_modules/@koa/router/LICENSE +21 -0
  374. package/dist/node_modules/oidc-provider/node_modules/@koa/router/README.md +1370 -0
  375. package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.d.mts +1003 -0
  376. package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.d.ts +1003 -0
  377. package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.js +1616 -0
  378. package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.mjs +1573 -0
  379. package/dist/node_modules/oidc-provider/node_modules/@koa/router/package.json +122 -0
  380. package/dist/node_modules/oidc-provider/node_modules/debug/LICENSE +20 -0
  381. package/dist/node_modules/oidc-provider/node_modules/debug/README.md +481 -0
  382. package/dist/node_modules/oidc-provider/node_modules/debug/package.json +64 -0
  383. package/dist/node_modules/oidc-provider/node_modules/debug/src/browser.js +272 -0
  384. package/dist/node_modules/oidc-provider/node_modules/debug/src/common.js +292 -0
  385. package/dist/node_modules/oidc-provider/node_modules/debug/src/index.js +10 -0
  386. package/dist/node_modules/oidc-provider/node_modules/debug/src/node.js +263 -0
  387. package/dist/node_modules/oidc-provider/node_modules/http-errors/HISTORY.md +186 -0
  388. package/dist/node_modules/oidc-provider/node_modules/http-errors/LICENSE +23 -0
  389. package/dist/node_modules/oidc-provider/node_modules/http-errors/README.md +169 -0
  390. package/dist/node_modules/oidc-provider/node_modules/http-errors/index.js +290 -0
  391. package/dist/node_modules/oidc-provider/node_modules/http-errors/package.json +54 -0
  392. package/dist/node_modules/oidc-provider/node_modules/jsesc/LICENSE-MIT.txt +20 -0
  393. package/dist/node_modules/oidc-provider/node_modules/jsesc/README.md +422 -0
  394. package/dist/node_modules/oidc-provider/node_modules/jsesc/bin/jsesc +148 -0
  395. package/dist/node_modules/oidc-provider/node_modules/jsesc/jsesc.js +337 -0
  396. package/dist/node_modules/oidc-provider/node_modules/jsesc/man/jsesc.1 +94 -0
  397. package/dist/node_modules/oidc-provider/node_modules/jsesc/package.json +56 -0
  398. package/dist/node_modules/oidc-provider/node_modules/nanoid/LICENSE +20 -0
  399. package/dist/node_modules/oidc-provider/node_modules/nanoid/README.md +38 -0
  400. package/dist/node_modules/oidc-provider/node_modules/nanoid/bin/nanoid.js +55 -0
  401. package/dist/node_modules/oidc-provider/node_modules/nanoid/index.browser.js +29 -0
  402. package/dist/node_modules/oidc-provider/node_modules/nanoid/index.d.ts +106 -0
  403. package/dist/node_modules/oidc-provider/node_modules/nanoid/index.js +47 -0
  404. package/dist/node_modules/oidc-provider/node_modules/nanoid/nanoid.js +1 -0
  405. package/dist/node_modules/oidc-provider/node_modules/nanoid/non-secure/index.d.ts +48 -0
  406. package/dist/node_modules/oidc-provider/node_modules/nanoid/non-secure/index.js +21 -0
  407. package/dist/node_modules/oidc-provider/node_modules/nanoid/package.json +46 -0
  408. package/dist/node_modules/oidc-provider/node_modules/nanoid/url-alphabet/index.js +2 -0
  409. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/LICENSE +21 -0
  410. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/Readme.md +224 -0
  411. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.d.ts +144 -0
  412. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.js +409 -0
  413. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.js.map +1 -0
  414. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/package.json +64 -0
  415. package/dist/node_modules/oidc-provider/node_modules/statuses/HISTORY.md +87 -0
  416. package/dist/node_modules/oidc-provider/node_modules/statuses/LICENSE +23 -0
  417. package/dist/node_modules/oidc-provider/node_modules/statuses/README.md +139 -0
  418. package/dist/node_modules/oidc-provider/node_modules/statuses/codes.json +65 -0
  419. package/dist/node_modules/oidc-provider/node_modules/statuses/index.js +146 -0
  420. package/dist/node_modules/oidc-provider/node_modules/statuses/package.json +49 -0
  421. package/dist/node_modules/oidc-provider/package.json +95 -0
  422. package/dist/node_modules/quick-lru/index.d.ts +178 -0
  423. package/dist/node_modules/quick-lru/index.js +329 -0
  424. package/dist/node_modules/quick-lru/license +9 -0
  425. package/dist/node_modules/quick-lru/package.json +54 -0
  426. package/dist/node_modules/quick-lru/readme.md +236 -0
  427. package/dist/node_modules/statuses/HISTORY.md +65 -0
  428. package/dist/node_modules/statuses/LICENSE +23 -0
  429. package/dist/node_modules/statuses/README.md +127 -0
  430. package/dist/node_modules/statuses/codes.json +66 -0
  431. package/dist/node_modules/statuses/index.js +113 -0
  432. package/dist/node_modules/statuses/package.json +48 -0
  433. package/dist/server/cache-adapter.d.ts +33 -0
  434. package/dist/server/cache-adapter.js +159 -0
  435. package/dist/server/index.d.ts +10 -0
  436. package/dist/server/index.js +48 -0
  437. package/dist/server/interaction.d.ts +26 -0
  438. package/dist/server/interaction.js +172 -0
  439. package/dist/server/paths.d.ts +19 -0
  440. package/dist/server/paths.js +64 -0
  441. package/dist/server/plugin.d.ts +16 -0
  442. package/dist/server/plugin.js +108 -0
  443. package/dist/server/provider-dispatch.d.ts +32 -0
  444. package/dist/server/provider-dispatch.js +252 -0
  445. package/dist/server/service.d.ts +63 -0
  446. package/dist/server/service.js +540 -0
  447. package/dist/server/utils.d.ts +12 -0
  448. package/dist/server/utils.js +58 -0
  449. package/package.json +24 -0
  450. package/server.d.ts +2 -0
  451. package/server.js +1 -0
@@ -0,0 +1,1616 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Router: () => Router,
34
+ RouterEvents: () => RouterEvents,
35
+ createParameterValidationMiddleware: () => createParameterValidationMiddleware,
36
+ default: () => router_default
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+
40
+ // src/utils/router-events.ts
41
+ var import_koa_compose = __toESM(require("koa-compose"));
42
+ var RouterEvents = {
43
+ /**
44
+ * Fires when no route matched the request path + HTTP method.
45
+ */
46
+ NotFound: "not-found"
47
+ // /**
48
+ // * Fires when the request path matched a registered route but the HTTP
49
+ // * method did not match any of its allowed methods.
50
+ // *
51
+ // * @planned Not yet active — handlers are stored but not called.
52
+ // */
53
+ // MethodNotAllowed: 'method-not-allowed',
54
+ // /**
55
+ // * Fires after a route is matched and before its handlers run.
56
+ // * Useful for tracing and logging the matched route.
57
+ // *
58
+ // * @planned Not yet active — handlers are stored but not called.
59
+ // */
60
+ // Match: 'match',
61
+ // /**
62
+ // * Fires on every request that enters the router, before route matching.
63
+ // * Useful for per-router metrics and request logging.
64
+ // *
65
+ // * @planned Not yet active — handlers are stored but not called.
66
+ // */
67
+ // Dispatch: 'dispatch'
68
+ };
69
+ function resolveEvent(selector) {
70
+ return typeof selector === "function" ? selector(RouterEvents) : selector;
71
+ }
72
+ var RouterEventEmitter = class {
73
+ _handlers = /* @__PURE__ */ new Map();
74
+ /**
75
+ * Register a handler for the given event.
76
+ * Multiple handlers for the same event are composed in registration order.
77
+ */
78
+ register(event, handler) {
79
+ const existing = this._handlers.get(event) ?? [];
80
+ existing.push(handler);
81
+ this._handlers.set(event, existing);
82
+ }
83
+ /**
84
+ * Emit an event by composing and running all registered handlers.
85
+ * If no handlers are registered for the event, calls `next()` directly.
86
+ *
87
+ * @param event - The event to emit
88
+ * @param context - The router context
89
+ * @param next - The downstream next function
90
+ */
91
+ emit(event, context, next) {
92
+ const handlers = this._handlers.get(event);
93
+ if (handlers && handlers.length > 0) {
94
+ return (0, import_koa_compose.default)(handlers)(context, next);
95
+ }
96
+ return next();
97
+ }
98
+ };
99
+
100
+ // src/utils/parameter-match.ts
101
+ var import_http_errors = __toESM(require("http-errors"));
102
+ function createParameterValidationMiddleware(parameterName, pattern, options = {}) {
103
+ if (!(pattern instanceof RegExp)) {
104
+ throw new TypeError("pattern must be a RegExp instance");
105
+ }
106
+ const matcher = new RegExp(pattern.source, pattern.flags);
107
+ const createDefaultHttpError = (message) => {
108
+ const httpError = (0, import_http_errors.default)(options.status ?? 400, message);
109
+ if (options.expose !== void 0) {
110
+ httpError.expose = options.expose;
111
+ }
112
+ return httpError;
113
+ };
114
+ const validateValue = (value) => {
115
+ if (matcher.global || matcher.sticky) {
116
+ matcher.lastIndex = 0;
117
+ }
118
+ if (matcher.test(value)) {
119
+ return;
120
+ }
121
+ if (options.createError) {
122
+ throw options.createError(parameterName, value);
123
+ }
124
+ throw createDefaultHttpError(
125
+ options.message ?? `Invalid value for parameter "${parameterName}": "${value}"`
126
+ );
127
+ };
128
+ const middleware = async (argument1, argument2, argument3) => {
129
+ if (typeof argument1 !== "string") {
130
+ const context = argument1;
131
+ const next2 = argument2;
132
+ const parameterValue = context.params && parameterName in context.params ? context.params[parameterName] : void 0;
133
+ if (typeof parameterValue !== "string") {
134
+ throw createDefaultHttpError(
135
+ options.message ?? `Missing required parameter "${parameterName}" in route params`
136
+ );
137
+ }
138
+ validateValue(parameterValue);
139
+ return next2();
140
+ }
141
+ const value = argument1;
142
+ const next = argument3;
143
+ validateValue(value);
144
+ return next();
145
+ };
146
+ return middleware;
147
+ }
148
+
149
+ // src/router.ts
150
+ var import_koa_compose2 = __toESM(require("koa-compose"));
151
+ var import_http_errors2 = __toESM(require("http-errors"));
152
+
153
+ // src/layer.ts
154
+ var import_node_url = require("url");
155
+
156
+ // src/utils/path-to-regexp-wrapper.ts
157
+ var import_path_to_regexp = require("path-to-regexp");
158
+ function compilePathToRegexp(path, options = {}) {
159
+ const normalizedOptions = { ...options };
160
+ if ("strict" in normalizedOptions && !("trailing" in normalizedOptions)) {
161
+ normalizedOptions.trailing = normalizedOptions.strict !== true;
162
+ delete normalizedOptions.strict;
163
+ }
164
+ delete normalizedOptions.pathAsRegExp;
165
+ delete normalizedOptions.ignoreCaptures;
166
+ delete normalizedOptions.prefix;
167
+ const { regexp, keys } = (0, import_path_to_regexp.pathToRegexp)(path, normalizedOptions);
168
+ return { regexp, keys };
169
+ }
170
+ function compilePath(path, options = {}) {
171
+ return (0, import_path_to_regexp.compile)(path, options);
172
+ }
173
+ function parsePath(path, options) {
174
+ return (0, import_path_to_regexp.parse)(path, options);
175
+ }
176
+ function normalizeLayerOptionsToPathToRegexp(options = {}) {
177
+ const normalized = {
178
+ sensitive: options.sensitive,
179
+ end: options.end,
180
+ strict: options.strict,
181
+ trailing: options.trailing
182
+ };
183
+ if ("strict" in normalized && !("trailing" in normalized)) {
184
+ normalized.trailing = normalized.strict !== true;
185
+ delete normalized.strict;
186
+ }
187
+ for (const key of Object.keys(normalized)) {
188
+ if (normalized[key] === void 0) {
189
+ delete normalized[key];
190
+ }
191
+ }
192
+ return normalized;
193
+ }
194
+
195
+ // src/utils/safe-decode-uri-components.ts
196
+ function safeDecodeURIComponent(text) {
197
+ try {
198
+ return decodeURIComponent(text);
199
+ } catch {
200
+ return text;
201
+ }
202
+ }
203
+
204
+ // src/layer.ts
205
+ var Layer = class {
206
+ opts;
207
+ name;
208
+ methods;
209
+ paramNames;
210
+ stack;
211
+ path;
212
+ regexp;
213
+ /**
214
+ * Initialize a new routing Layer with given `method`, `path`, and `middleware`.
215
+ *
216
+ * @param path - Path string or regular expression
217
+ * @param methods - Array of HTTP verbs
218
+ * @param middleware - Layer callback/middleware or series of
219
+ * @param opts - Layer options
220
+ * @private
221
+ */
222
+ constructor(path, methods, middleware, options = {}) {
223
+ this.opts = options;
224
+ this.name = this.opts.name || void 0;
225
+ this.methods = this._normalizeHttpMethods(methods);
226
+ this.stack = this._normalizeAndValidateMiddleware(
227
+ middleware,
228
+ methods,
229
+ path
230
+ );
231
+ this.path = path;
232
+ this.paramNames = [];
233
+ this._configurePathMatching();
234
+ }
235
+ /**
236
+ * Normalize HTTP methods and add automatic HEAD support for GET
237
+ * @private
238
+ */
239
+ _normalizeHttpMethods(methods) {
240
+ const normalizedMethods = [];
241
+ for (const method of methods) {
242
+ const upperMethod = method.toUpperCase();
243
+ normalizedMethods.push(upperMethod);
244
+ if (upperMethod === "GET") {
245
+ normalizedMethods.unshift("HEAD");
246
+ }
247
+ }
248
+ return normalizedMethods;
249
+ }
250
+ /**
251
+ * Normalize middleware to array and validate all are functions
252
+ * @private
253
+ */
254
+ _normalizeAndValidateMiddleware(middleware, methods, path) {
255
+ const middlewareArray = Array.isArray(middleware) ? middleware : [middleware];
256
+ for (const middlewareFunction of middlewareArray) {
257
+ const middlewareType = typeof middlewareFunction;
258
+ if (middlewareType !== "function") {
259
+ const routeIdentifier = this.opts.name || path;
260
+ throw new Error(
261
+ `${methods.toString()} \`${routeIdentifier}\`: \`middleware\` must be a function, not \`${middlewareType}\``
262
+ );
263
+ }
264
+ }
265
+ return middlewareArray;
266
+ }
267
+ /**
268
+ * Configure path matching regexp and parameters
269
+ * @private
270
+ */
271
+ _configurePathMatching() {
272
+ if (this.opts.pathAsRegExp === true) {
273
+ this.regexp = this.path instanceof RegExp ? this.path : new RegExp(this.path);
274
+ } else if (this.path) {
275
+ this._configurePathToRegexp();
276
+ }
277
+ }
278
+ /**
279
+ * Configure path-to-regexp for string paths
280
+ * @private
281
+ */
282
+ _configurePathToRegexp() {
283
+ const options = normalizeLayerOptionsToPathToRegexp(this.opts);
284
+ const { regexp, keys } = compilePathToRegexp(this.path, options);
285
+ this.regexp = regexp;
286
+ this.paramNames = keys;
287
+ }
288
+ /**
289
+ * Returns whether request `path` matches route.
290
+ *
291
+ * @param path - Request path
292
+ * @returns Whether path matches
293
+ * @private
294
+ */
295
+ match(path) {
296
+ return this.regexp.test(path);
297
+ }
298
+ /**
299
+ * Returns map of URL parameters for given `path` and `paramNames`.
300
+ *
301
+ * @param _path - Request path (not used, kept for API compatibility)
302
+ * @param captures - Captured values from regexp
303
+ * @param existingParams - Existing params to merge with
304
+ * @returns Parameter map
305
+ * @private
306
+ */
307
+ params(_path, captures, existingParameters = {}) {
308
+ const parameterValues = { ...existingParameters };
309
+ for (const [captureIndex, capturedValue] of captures.entries()) {
310
+ const parameterDefinition = this.paramNames[captureIndex];
311
+ if (parameterDefinition && capturedValue && capturedValue.length > 0) {
312
+ const parameterName = parameterDefinition.name;
313
+ parameterValues[parameterName] = safeDecodeURIComponent(capturedValue);
314
+ }
315
+ }
316
+ return parameterValues;
317
+ }
318
+ /**
319
+ * Returns array of regexp url path captures.
320
+ *
321
+ * @param path - Request path
322
+ * @returns Array of captured values
323
+ * @private
324
+ */
325
+ captures(path) {
326
+ if (this.opts.ignoreCaptures) {
327
+ return [];
328
+ }
329
+ const match = path.match(this.regexp);
330
+ return match ? match.slice(1) : [];
331
+ }
332
+ /**
333
+ * Generate URL for route using given `params`.
334
+ *
335
+ * @example
336
+ *
337
+ * ```javascript
338
+ * const route = new Layer('/users/:id', ['GET'], fn);
339
+ *
340
+ * route.url({ id: 123 }); // => "/users/123"
341
+ * ```
342
+ *
343
+ * @param args - URL parameters (various formats supported)
344
+ * @returns Generated URL
345
+ * @throws Error if route path is a RegExp (cannot generate URL from RegExp)
346
+ * @private
347
+ */
348
+ url(...arguments_) {
349
+ if (this.path instanceof RegExp) {
350
+ throw new TypeError(
351
+ "Cannot generate URL for routes defined with RegExp paths. Use string paths with named parameters instead."
352
+ );
353
+ }
354
+ const { params, options } = this._parseUrlArguments(arguments_);
355
+ const cleanPath = this.path.replaceAll("(.*)", "");
356
+ const pathCompiler = compilePath(cleanPath, {
357
+ encode: encodeURIComponent,
358
+ ...options
359
+ });
360
+ const parameterReplacements = this._buildParamReplacements(
361
+ params,
362
+ cleanPath
363
+ );
364
+ const generatedUrl = pathCompiler(parameterReplacements);
365
+ if (options && options.query) {
366
+ return this._addQueryString(generatedUrl, options.query);
367
+ }
368
+ return generatedUrl;
369
+ }
370
+ /**
371
+ * Parse url() arguments into params and options
372
+ * Supports multiple call signatures:
373
+ * - url({ id: 1 })
374
+ * - url(1, 2, 3)
375
+ * - url({ query: {...} })
376
+ * - url({ id: 1 }, { query: {...} })
377
+ * @private
378
+ */
379
+ _parseUrlArguments(allArguments) {
380
+ let parameters = allArguments[0] ?? {};
381
+ let options = allArguments[1];
382
+ if (typeof parameters !== "object" || parameters === null) {
383
+ const argumentsList = [...allArguments];
384
+ const lastArgument = argumentsList.at(-1);
385
+ if (typeof lastArgument === "object" && lastArgument !== null) {
386
+ options = lastArgument;
387
+ parameters = argumentsList.slice(0, -1);
388
+ } else {
389
+ parameters = argumentsList;
390
+ }
391
+ } else if (parameters && !options) {
392
+ const parameterKeys = Object.keys(parameters);
393
+ const isOnlyOptions = parameterKeys.length === 1 && parameterKeys[0] === "query";
394
+ if (isOnlyOptions) {
395
+ options = parameters;
396
+ parameters = {};
397
+ } else if ("query" in parameters && parameters.query) {
398
+ const { query, ...restParameters } = parameters;
399
+ options = { query };
400
+ parameters = restParameters;
401
+ }
402
+ }
403
+ return { params: parameters, options };
404
+ }
405
+ /**
406
+ * Build parameter replacements for URL generation
407
+ * @private
408
+ */
409
+ _buildParamReplacements(parameters, cleanPath) {
410
+ const { tokens } = parsePath(cleanPath);
411
+ const hasNamedParameters = tokens.some(
412
+ (token) => "name" in token && token.name
413
+ );
414
+ const parameterReplacements = {};
415
+ if (Array.isArray(parameters)) {
416
+ let parameterIndex = 0;
417
+ for (const token of tokens) {
418
+ if ("name" in token && token.name) {
419
+ parameterReplacements[token.name] = String(
420
+ parameters[parameterIndex++]
421
+ );
422
+ }
423
+ }
424
+ } else if (hasNamedParameters && typeof parameters === "object" && !("query" in parameters)) {
425
+ for (const [parameterName, parameterValue] of Object.entries(
426
+ parameters
427
+ )) {
428
+ parameterReplacements[parameterName] = String(parameterValue);
429
+ }
430
+ }
431
+ return parameterReplacements;
432
+ }
433
+ /**
434
+ * Add query string to URL
435
+ * @private
436
+ */
437
+ _addQueryString(baseUrl, query) {
438
+ const parsed = (0, import_node_url.parse)(baseUrl);
439
+ const urlObject = {
440
+ ...parsed,
441
+ query: parsed.query ?? void 0
442
+ };
443
+ if (typeof query === "string") {
444
+ urlObject.search = query;
445
+ urlObject.query = void 0;
446
+ } else {
447
+ urlObject.search = void 0;
448
+ urlObject.query = query;
449
+ }
450
+ return (0, import_node_url.format)(urlObject);
451
+ }
452
+ /**
453
+ * Run validations on route named parameters.
454
+ *
455
+ * @example
456
+ *
457
+ * ```javascript
458
+ * router
459
+ * .param('user', function (id, ctx, next) {
460
+ * ctx.user = users[id];
461
+ * if (!ctx.user) return ctx.status = 404;
462
+ * next();
463
+ * })
464
+ * .get('/users/:user', function (ctx, next) {
465
+ * ctx.body = ctx.user;
466
+ * });
467
+ * ```
468
+ *
469
+ * @param paramName - Parameter name
470
+ * @param paramHandler - Middleware function
471
+ * @returns This layer instance
472
+ * @private
473
+ */
474
+ param(parameterName, parameterHandler) {
475
+ const middlewareStack = this.stack;
476
+ const routeParameterNames = this.paramNames;
477
+ const parameterMiddleware = this._createParamMiddleware(
478
+ parameterName,
479
+ parameterHandler
480
+ );
481
+ const parameterNamesList = routeParameterNames.map(
482
+ (parameterDefinition) => parameterDefinition.name
483
+ );
484
+ const parameterPosition = parameterNamesList.indexOf(parameterName);
485
+ if (parameterPosition !== -1) {
486
+ this._insertParamMiddleware(
487
+ middlewareStack,
488
+ parameterMiddleware,
489
+ parameterNamesList,
490
+ parameterPosition
491
+ );
492
+ }
493
+ return this;
494
+ }
495
+ /**
496
+ * Create param middleware with deduplication tracking
497
+ * @private
498
+ */
499
+ _createParamMiddleware(parameterName, parameterHandler) {
500
+ const middleware = ((context, next) => {
501
+ if (!context._matchedParams) {
502
+ context._matchedParams = /* @__PURE__ */ new WeakMap();
503
+ }
504
+ if (context._matchedParams.has(parameterHandler)) {
505
+ return next();
506
+ }
507
+ context._matchedParams.set(parameterHandler, true);
508
+ return parameterHandler(context.params[parameterName], context, next);
509
+ });
510
+ middleware.param = parameterName;
511
+ middleware._originalFn = parameterHandler;
512
+ return middleware;
513
+ }
514
+ /**
515
+ * Insert param middleware at the correct position in the stack
516
+ * @private
517
+ */
518
+ _insertParamMiddleware(middlewareStack, parameterMiddleware, parameterNamesList, currentParameterPosition) {
519
+ let inserted = false;
520
+ for (let stackIndex = 0; stackIndex < middlewareStack.length; stackIndex++) {
521
+ const existingMiddleware = middlewareStack[stackIndex];
522
+ if (!existingMiddleware.param) {
523
+ middlewareStack.splice(stackIndex, 0, parameterMiddleware);
524
+ inserted = true;
525
+ break;
526
+ }
527
+ const existingParameterPosition = parameterNamesList.indexOf(
528
+ existingMiddleware.param
529
+ );
530
+ if (existingParameterPosition > currentParameterPosition) {
531
+ middlewareStack.splice(stackIndex, 0, parameterMiddleware);
532
+ inserted = true;
533
+ break;
534
+ }
535
+ }
536
+ if (!inserted) {
537
+ middlewareStack.push(parameterMiddleware);
538
+ }
539
+ }
540
+ /**
541
+ * Prefix route path.
542
+ *
543
+ * @param prefixPath - Prefix to prepend
544
+ * @returns This layer instance
545
+ * @private
546
+ */
547
+ setPrefix(prefixPath) {
548
+ if (!this.path) {
549
+ return this;
550
+ }
551
+ if (this.path instanceof RegExp) {
552
+ return this;
553
+ }
554
+ this.path = this._applyPrefix(prefixPath);
555
+ this._reconfigurePathMatching(prefixPath);
556
+ return this;
557
+ }
558
+ /**
559
+ * Apply prefix to the current path
560
+ * @private
561
+ */
562
+ _applyPrefix(prefixPath) {
563
+ const isRootPath = this.path === "/";
564
+ const isStrictMode = this.opts.strict === true;
565
+ const prefixHasParameters = prefixPath.includes(":");
566
+ const pathIsRawRegex = this.opts.pathAsRegExp === true && typeof this.path === "string";
567
+ if (prefixHasParameters && pathIsRawRegex) {
568
+ const currentPath = this.path;
569
+ if (currentPath === String.raw`(?:\/|$)` || currentPath === String.raw`(?:\\\/|$)`) {
570
+ this.path = "{/*rest}";
571
+ this.opts.pathAsRegExp = false;
572
+ }
573
+ }
574
+ if (isRootPath && !isStrictMode) {
575
+ return prefixPath;
576
+ }
577
+ return `${prefixPath}${this.path}`;
578
+ }
579
+ /**
580
+ * Reconfigure path matching after prefix is applied
581
+ * @private
582
+ */
583
+ _reconfigurePathMatching(prefixPath) {
584
+ const treatAsRegExp = this.opts.pathAsRegExp === true;
585
+ const prefixHasParameters = prefixPath && prefixPath.includes(":");
586
+ if (prefixHasParameters && treatAsRegExp) {
587
+ const options = normalizeLayerOptionsToPathToRegexp(this.opts);
588
+ const { regexp, keys } = compilePathToRegexp(
589
+ this.path,
590
+ options
591
+ );
592
+ this.regexp = regexp;
593
+ this.paramNames = keys;
594
+ this.opts.pathAsRegExp = false;
595
+ } else if (treatAsRegExp) {
596
+ const pathString = this.path;
597
+ const anchoredPattern = pathString.startsWith("^") ? pathString : `^${pathString}`;
598
+ this.regexp = this.path instanceof RegExp ? this.path : new RegExp(anchoredPattern);
599
+ } else {
600
+ const options = normalizeLayerOptionsToPathToRegexp(this.opts);
601
+ const { regexp, keys } = compilePathToRegexp(
602
+ this.path,
603
+ options
604
+ );
605
+ this.regexp = regexp;
606
+ this.paramNames = keys;
607
+ }
608
+ }
609
+ };
610
+
611
+ // src/utils/http-methods.ts
612
+ var import_node_http = __toESM(require("http"));
613
+ function getAllHttpMethods() {
614
+ return import_node_http.default.METHODS.map((method) => method.toLowerCase());
615
+ }
616
+ var COMMON_HTTP_METHODS = [
617
+ "get",
618
+ "post",
619
+ "put",
620
+ "patch",
621
+ "delete",
622
+ "del",
623
+ "head",
624
+ "options"
625
+ ];
626
+
627
+ // src/utils/parameter-helpers.ts
628
+ function normalizeParameterMiddleware(parameterMiddleware) {
629
+ if (!parameterMiddleware) {
630
+ return [];
631
+ }
632
+ if (Array.isArray(parameterMiddleware)) {
633
+ return parameterMiddleware;
634
+ }
635
+ return [parameterMiddleware];
636
+ }
637
+ function applyParameterMiddlewareToRoute(route, parameterName, parameterMiddleware) {
638
+ const middlewareList = normalizeParameterMiddleware(
639
+ parameterMiddleware
640
+ );
641
+ for (const middleware of middlewareList) {
642
+ route.param(parameterName, middleware);
643
+ }
644
+ }
645
+ function applyAllParameterMiddleware(route, parametersObject) {
646
+ const parameterNames = Object.keys(parametersObject);
647
+ for (const parameterName of parameterNames) {
648
+ const parameterMiddleware = parametersObject[parameterName];
649
+ applyParameterMiddlewareToRoute(
650
+ route,
651
+ parameterName,
652
+ parameterMiddleware
653
+ );
654
+ }
655
+ }
656
+
657
+ // src/utils/path-helpers.ts
658
+ function hasPathParameters(path, options = {}) {
659
+ if (!path) {
660
+ return false;
661
+ }
662
+ const { keys } = compilePathToRegexp(path, options);
663
+ return keys.length > 0;
664
+ }
665
+ function determineMiddlewarePath(explicitPath, hasPrefixParameters) {
666
+ if (explicitPath !== void 0) {
667
+ if (typeof explicitPath === "string") {
668
+ if (explicitPath === "") {
669
+ return {
670
+ path: "{/*rest}",
671
+ pathAsRegExp: false
672
+ };
673
+ }
674
+ if (explicitPath === "/") {
675
+ return {
676
+ path: "/",
677
+ pathAsRegExp: false
678
+ };
679
+ }
680
+ return {
681
+ path: explicitPath,
682
+ pathAsRegExp: false
683
+ };
684
+ }
685
+ return {
686
+ path: explicitPath,
687
+ pathAsRegExp: true
688
+ };
689
+ }
690
+ if (hasPrefixParameters) {
691
+ return {
692
+ path: "{/*rest}",
693
+ pathAsRegExp: false
694
+ };
695
+ }
696
+ return {
697
+ path: String.raw`(?:\/|$)`,
698
+ pathAsRegExp: true
699
+ };
700
+ }
701
+
702
+ // src/utils/debug.ts
703
+ var import_debug = __toESM(require("debug"));
704
+ var debug = (0, import_debug.default)("koa-router");
705
+
706
+ // src/router.ts
707
+ var httpMethods = getAllHttpMethods();
708
+ var RouterImplementation = class {
709
+ opts;
710
+ methods;
711
+ exclusive;
712
+ params;
713
+ stack;
714
+ host;
715
+ /**
716
+ * Event emitter for router lifecycle events (experimental)
717
+ * @internal
718
+ */
719
+ _events = new RouterEventEmitter();
720
+ /**
721
+ * Create a new router.
722
+ *
723
+ * @example
724
+ *
725
+ * Basic usage:
726
+ *
727
+ * ```javascript
728
+ * const Koa = require('koa');
729
+ * const Router = require('@koa/router');
730
+ *
731
+ * const app = new Koa();
732
+ * const router = new Router();
733
+ *
734
+ * router.get('/', (ctx, next) => {
735
+ * // ctx.router available
736
+ * });
737
+ *
738
+ * app
739
+ * .use(router.routes())
740
+ * .use(router.allowedMethods());
741
+ * ```
742
+ *
743
+ * @alias module:koa-router
744
+ * @param opts - Router options
745
+ * @constructor
746
+ */
747
+ constructor(options = {}) {
748
+ this.opts = options;
749
+ this.methods = this.opts.methods || [
750
+ "HEAD",
751
+ "OPTIONS",
752
+ "GET",
753
+ "PUT",
754
+ "PATCH",
755
+ "POST",
756
+ "DELETE"
757
+ ];
758
+ this.exclusive = Boolean(this.opts.exclusive);
759
+ this.params = {};
760
+ this.stack = [];
761
+ this.host = this.opts.host;
762
+ }
763
+ /**
764
+ * Generate URL from url pattern and given `params`.
765
+ *
766
+ * @example
767
+ *
768
+ * ```javascript
769
+ * const url = Router.url('/users/:id', {id: 1});
770
+ * // => "/users/1"
771
+ * ```
772
+ *
773
+ * @param path - URL pattern
774
+ * @param args - URL parameters
775
+ * @returns Generated URL
776
+ */
777
+ static url(path, ...arguments_) {
778
+ const temporaryLayer = new Layer(path, [], () => {
779
+ });
780
+ return temporaryLayer.url(...arguments_);
781
+ }
782
+ use(...middleware) {
783
+ let explicitPath;
784
+ if (this._isPathArray(middleware[0])) {
785
+ return this._useWithPathArray(middleware);
786
+ }
787
+ const hasExplicitPath = this._hasExplicitPath(middleware[0]);
788
+ if (hasExplicitPath) {
789
+ explicitPath = middleware.shift();
790
+ }
791
+ if (middleware.length === 0) {
792
+ throw new Error(
793
+ "You must provide at least one middleware function to router.use()"
794
+ );
795
+ }
796
+ for (const currentMiddleware of middleware) {
797
+ if (this._isNestedRouter(currentMiddleware)) {
798
+ this._mountNestedRouter(
799
+ currentMiddleware,
800
+ explicitPath
801
+ );
802
+ } else {
803
+ this._registerMiddleware(
804
+ currentMiddleware,
805
+ explicitPath,
806
+ hasExplicitPath
807
+ );
808
+ }
809
+ }
810
+ return this;
811
+ }
812
+ /**
813
+ * Check if first argument is an array of paths (all elements must be strings)
814
+ * @private
815
+ */
816
+ _isPathArray(firstArgument) {
817
+ return Array.isArray(firstArgument) && firstArgument.length > 0 && firstArgument.every((item) => typeof item === "string");
818
+ }
819
+ /**
820
+ * Check if first argument is an explicit path (string or RegExp)
821
+ * Empty string counts as explicit path to enable param capture
822
+ * @private
823
+ */
824
+ _hasExplicitPath(firstArgument) {
825
+ return typeof firstArgument === "string" || firstArgument instanceof RegExp;
826
+ }
827
+ /**
828
+ * Check if middleware contains a nested router
829
+ * @private
830
+ */
831
+ _isNestedRouter(middleware) {
832
+ return typeof middleware === "function" && "router" in middleware && middleware.router !== void 0;
833
+ }
834
+ /**
835
+ * Apply middleware to multiple paths
836
+ * @private
837
+ */
838
+ _useWithPathArray(middleware) {
839
+ const pathArray = middleware[0];
840
+ const remainingMiddleware = middleware.slice(1);
841
+ for (const singlePath of pathArray) {
842
+ Reflect.apply(this.use, this, [singlePath, ...remainingMiddleware]);
843
+ }
844
+ return this;
845
+ }
846
+ /**
847
+ * Mount a nested router
848
+ * @private
849
+ */
850
+ _mountNestedRouter(middlewareWithRouter, mountPath) {
851
+ const nestedRouter = middlewareWithRouter.router;
852
+ const clonedRouter = this._cloneRouter(nestedRouter);
853
+ const mountPathHasParameters = mountPath && typeof mountPath === "string" && hasPathParameters(mountPath, this.opts);
854
+ for (let routeIndex = 0; routeIndex < clonedRouter.stack.length; routeIndex++) {
855
+ const nestedLayer = clonedRouter.stack[routeIndex];
856
+ const clonedLayer = this._cloneLayer(nestedLayer);
857
+ if (mountPath && typeof mountPath === "string") {
858
+ clonedLayer.setPrefix(mountPath);
859
+ }
860
+ if (this.opts.prefix) {
861
+ clonedLayer.setPrefix(this.opts.prefix);
862
+ }
863
+ if (clonedLayer.methods.length === 0 && mountPathHasParameters) {
864
+ clonedLayer.opts.ignoreCaptures = false;
865
+ }
866
+ this.stack.push(clonedLayer);
867
+ clonedRouter.stack[routeIndex] = clonedLayer;
868
+ }
869
+ if (this.params) {
870
+ this._applyParamMiddlewareToRouter(clonedRouter);
871
+ }
872
+ }
873
+ /**
874
+ * Clone a router instance
875
+ * @private
876
+ */
877
+ _cloneRouter(sourceRouter) {
878
+ return Object.assign(
879
+ Object.create(Object.getPrototypeOf(sourceRouter)),
880
+ sourceRouter,
881
+ {
882
+ stack: [...sourceRouter.stack]
883
+ }
884
+ );
885
+ }
886
+ /**
887
+ * Clone a layer instance (deep clone to avoid shared references)
888
+ * @private
889
+ */
890
+ _cloneLayer(sourceLayer) {
891
+ const cloned = Object.assign(
892
+ Object.create(Object.getPrototypeOf(sourceLayer)),
893
+ sourceLayer,
894
+ {
895
+ // Deep clone arrays and objects to avoid shared references
896
+ stack: [...sourceLayer.stack],
897
+ methods: [...sourceLayer.methods],
898
+ paramNames: [...sourceLayer.paramNames],
899
+ opts: { ...sourceLayer.opts }
900
+ }
901
+ );
902
+ return cloned;
903
+ }
904
+ /**
905
+ * Apply this router's param middleware to a nested router
906
+ * @private
907
+ */
908
+ _applyParamMiddlewareToRouter(targetRouter) {
909
+ const parameterNames = Object.keys(this.params);
910
+ for (const parameterName of parameterNames) {
911
+ const parameterMiddleware = this.params[parameterName];
912
+ applyParameterMiddlewareToRoute(
913
+ targetRouter,
914
+ parameterName,
915
+ parameterMiddleware
916
+ );
917
+ }
918
+ }
919
+ /**
920
+ * Register regular middleware (not nested router)
921
+ * @private
922
+ */
923
+ _registerMiddleware(middleware, explicitPath, hasExplicitPath) {
924
+ const prefixHasParameters = hasPathParameters(
925
+ this.opts.prefix || "",
926
+ this.opts
927
+ );
928
+ const effectiveExplicitPath = (() => {
929
+ if (explicitPath !== void 0) return explicitPath;
930
+ if (prefixHasParameters) return "";
931
+ return;
932
+ })();
933
+ const effectiveHasExplicitPath = hasExplicitPath || explicitPath === void 0 && prefixHasParameters;
934
+ const { path: middlewarePath, pathAsRegExp } = determineMiddlewarePath(
935
+ effectiveExplicitPath,
936
+ prefixHasParameters
937
+ );
938
+ let finalPath = middlewarePath;
939
+ let usePathToRegexp = pathAsRegExp;
940
+ const isRootPath = effectiveHasExplicitPath && middlewarePath === "/";
941
+ if (effectiveHasExplicitPath && typeof middlewarePath === "string") {
942
+ finalPath = middlewarePath;
943
+ usePathToRegexp = false;
944
+ }
945
+ this.register(finalPath, [], middleware, {
946
+ end: isRootPath,
947
+ ignoreCaptures: !effectiveHasExplicitPath && !prefixHasParameters,
948
+ pathAsRegExp: usePathToRegexp
949
+ });
950
+ }
951
+ /**
952
+ * Set the path prefix for a Router instance that was already initialized.
953
+ * Note: Calling this method multiple times will replace the prefix, not stack them.
954
+ *
955
+ * @example
956
+ *
957
+ * ```javascript
958
+ * router.prefix('/things/:thing_id')
959
+ * ```
960
+ *
961
+ * @param prefixPath - Prefix string
962
+ * @returns This router instance
963
+ */
964
+ prefix(prefixPath) {
965
+ const normalizedPrefix = prefixPath.replace(/\/$/, "");
966
+ const previousPrefix = this.opts.prefix || "";
967
+ this.opts.prefix = normalizedPrefix;
968
+ for (const route of this.stack) {
969
+ if (previousPrefix && typeof route.path === "string" && route.path.startsWith(previousPrefix)) {
970
+ route.path = route.path.slice(previousPrefix.length) || "/";
971
+ }
972
+ route.setPrefix(normalizedPrefix);
973
+ }
974
+ return this;
975
+ }
976
+ /**
977
+ * Returns router middleware which dispatches a route matching the request.
978
+ *
979
+ * @returns Router middleware
980
+ */
981
+ middleware() {
982
+ const dispatchMiddleware = function(context, next) {
983
+ debug("%s %s", context.method, context.path);
984
+ if (!this.matchHost(context.host)) {
985
+ return next();
986
+ }
987
+ const requestPath = this._getRequestPath(context);
988
+ const matchResult = this.match(requestPath, context.method);
989
+ this._storeMatchedRoutes(context, matchResult);
990
+ context.router = this;
991
+ context.routeMatched = matchResult.route;
992
+ if (!matchResult.route) {
993
+ return this._events.emit(
994
+ RouterEvents.NotFound,
995
+ context,
996
+ next
997
+ );
998
+ }
999
+ const matchedLayers = matchResult.pathAndMethod;
1000
+ this._setMatchedRouteInfo(context, matchedLayers);
1001
+ const middlewareChain = this._buildMiddlewareChain(
1002
+ matchedLayers,
1003
+ requestPath
1004
+ );
1005
+ return (0, import_koa_compose2.default)(middlewareChain)(
1006
+ context,
1007
+ next
1008
+ );
1009
+ }.bind(this);
1010
+ dispatchMiddleware.router = this;
1011
+ return dispatchMiddleware;
1012
+ }
1013
+ /**
1014
+ * Get the request path to use for routing
1015
+ * @private
1016
+ */
1017
+ _getRequestPath(context) {
1018
+ const context_ = context;
1019
+ return this.opts.routerPath || context_.newRouterPath || context_.path || context_.routerPath || "";
1020
+ }
1021
+ /**
1022
+ * Store matched routes on context
1023
+ * @private
1024
+ */
1025
+ _storeMatchedRoutes(context, matchResult) {
1026
+ const context_ = context;
1027
+ if (context_.matched) {
1028
+ context_.matched.push(...matchResult.path);
1029
+ } else {
1030
+ context_.matched = matchResult.path;
1031
+ }
1032
+ }
1033
+ /**
1034
+ * Set matched route information on context
1035
+ * @private
1036
+ */
1037
+ _setMatchedRouteInfo(context, matchedLayers) {
1038
+ const context_ = context;
1039
+ const routeLayer = matchedLayers.toReversed().find((layer) => layer.methods.length > 0);
1040
+ if (routeLayer) {
1041
+ context_._matchedRoute = routeLayer.path;
1042
+ if (routeLayer.name) {
1043
+ context_._matchedRouteName = routeLayer.name;
1044
+ }
1045
+ }
1046
+ }
1047
+ /**
1048
+ * Build middleware chain from matched layers
1049
+ * @private
1050
+ */
1051
+ _buildMiddlewareChain(matchedLayers, requestPath) {
1052
+ const layersToExecute = this.opts.exclusive ? [matchedLayers.at(-1)].filter(
1053
+ (layer) => layer !== void 0
1054
+ ) : matchedLayers;
1055
+ const middlewareChain = [];
1056
+ for (const layer of layersToExecute) {
1057
+ middlewareChain.push(
1058
+ (context, next) => {
1059
+ const routerContext = context;
1060
+ routerContext.captures = layer.captures(requestPath);
1061
+ routerContext.request.params = layer.params(
1062
+ requestPath,
1063
+ routerContext.captures || [],
1064
+ routerContext.params
1065
+ );
1066
+ routerContext.params = routerContext.request.params;
1067
+ routerContext.routerPath = layer.path;
1068
+ routerContext.routerName = layer.name || void 0;
1069
+ routerContext._matchedRoute = layer.path;
1070
+ if (layer.name) {
1071
+ routerContext._matchedRouteName = layer.name;
1072
+ }
1073
+ return next();
1074
+ },
1075
+ ...layer.stack
1076
+ );
1077
+ }
1078
+ return middlewareChain;
1079
+ }
1080
+ routes() {
1081
+ return this.middleware();
1082
+ }
1083
+ /**
1084
+ * Register an event handler on the router.
1085
+ *
1086
+ * @experimental This API is experimental and may change in future versions.
1087
+ *
1088
+ * **Active events:**
1089
+ * - `'not-found'` — fires when no route matched path + method. Handlers are
1090
+ * composed and called instead of `next()`, so they are responsible for
1091
+ * calling `next()` themselves if they want to pass control downstream.
1092
+ *
1093
+ * @example
1094
+ *
1095
+ * All three forms are equivalent:
1096
+ *
1097
+ * ```javascript
1098
+ * import { RouterEvents } from '@koa/router';
1099
+ *
1100
+ * // Named constant (recommended — autocomplete + refactor safe)
1101
+ * router.on(RouterEvents.NotFound, handler);
1102
+ *
1103
+ * // Selector function (fluent style)
1104
+ * router.on((events) => events.NotFound, handler);
1105
+ *
1106
+ * // Raw string (still accepted)
1107
+ * router.on('not-found', handler);
1108
+ * ```
1109
+ *
1110
+ * Multiple handlers compose in registration order:
1111
+ *
1112
+ * ```javascript
1113
+ * router.on(RouterEvents.NotFound, async (ctx, next) => {
1114
+ * console.log('no route matched', ctx.path);
1115
+ * await next();
1116
+ * });
1117
+ * router.on(RouterEvents.NotFound, (ctx) => {
1118
+ * ctx.status = 404;
1119
+ * ctx.body = { error: 'Not Found' };
1120
+ * });
1121
+ * ```
1122
+ *
1123
+ * @param event - Event name string, `RouterEvents` constant, or selector
1124
+ * function `(events) => events.NotFound` (see `RouterEventSelector`)
1125
+ * @param handler - Middleware to run when the event fires
1126
+ * @returns This router instance for chaining
1127
+ */
1128
+ on(event, handler) {
1129
+ this._events.register(resolveEvent(event), handler);
1130
+ return this;
1131
+ }
1132
+ /**
1133
+ * Returns separate middleware for responding to `OPTIONS` requests with
1134
+ * an `Allow` header containing the allowed methods, as well as responding
1135
+ * with `405 Method Not Allowed` and `501 Not Implemented` as appropriate.
1136
+ *
1137
+ * @example
1138
+ *
1139
+ * ```javascript
1140
+ * const Koa = require('koa');
1141
+ * const Router = require('@koa/router');
1142
+ *
1143
+ * const app = new Koa();
1144
+ * const router = new Router();
1145
+ *
1146
+ * app.use(router.routes());
1147
+ * app.use(router.allowedMethods());
1148
+ * ```
1149
+ *
1150
+ * **Example with [Boom](https://github.com/hapijs/boom)**
1151
+ *
1152
+ * ```javascript
1153
+ * const Koa = require('koa');
1154
+ * const Router = require('@koa/router');
1155
+ * const Boom = require('boom');
1156
+ *
1157
+ * const app = new Koa();
1158
+ * const router = new Router();
1159
+ *
1160
+ * app.use(router.routes());
1161
+ * app.use(router.allowedMethods({
1162
+ * throw: true,
1163
+ * notImplemented: () => new Boom.notImplemented(),
1164
+ * methodNotAllowed: () => new Boom.methodNotAllowed()
1165
+ * }));
1166
+ * ```
1167
+ *
1168
+ * @param options - Options object
1169
+ * @returns Middleware function
1170
+ */
1171
+ allowedMethods(options = {}) {
1172
+ const implementedMethods = this.methods;
1173
+ return (context, next) => {
1174
+ const routerContext = context;
1175
+ return next().then(() => {
1176
+ if (!this._shouldProcessAllowedMethods(routerContext)) {
1177
+ return;
1178
+ }
1179
+ const matchedRoutes = routerContext.matched || [];
1180
+ const allowedMethods = this._collectAllowedMethods(matchedRoutes);
1181
+ const allowedMethodsList = Object.keys(allowedMethods);
1182
+ const requestMethod = context.method.toUpperCase();
1183
+ if (!implementedMethods.includes(requestMethod)) {
1184
+ this._handleNotImplemented(
1185
+ routerContext,
1186
+ allowedMethodsList,
1187
+ options
1188
+ );
1189
+ return;
1190
+ }
1191
+ if (requestMethod === "OPTIONS" && allowedMethodsList.length > 0) {
1192
+ this._handleOptionsRequest(routerContext, allowedMethodsList);
1193
+ return;
1194
+ }
1195
+ if (allowedMethodsList.length > 0 && !allowedMethods[requestMethod]) {
1196
+ this._handleMethodNotAllowed(
1197
+ routerContext,
1198
+ allowedMethodsList,
1199
+ options
1200
+ );
1201
+ }
1202
+ });
1203
+ };
1204
+ }
1205
+ /**
1206
+ * Check if we should process allowed methods
1207
+ * @private
1208
+ */
1209
+ _shouldProcessAllowedMethods(context) {
1210
+ return !!(context.matched && (!context.status || context.status === 404));
1211
+ }
1212
+ /**
1213
+ * Collect all allowed methods from matched routes
1214
+ * @private
1215
+ */
1216
+ _collectAllowedMethods(matchedRoutes) {
1217
+ const allowedMethods = {};
1218
+ for (const route of matchedRoutes) {
1219
+ for (const method of route.methods) {
1220
+ allowedMethods[method] = method;
1221
+ }
1222
+ }
1223
+ return allowedMethods;
1224
+ }
1225
+ /**
1226
+ * Handle 501 Not Implemented response
1227
+ * @private
1228
+ */
1229
+ _handleNotImplemented(context, allowedMethodsList, options) {
1230
+ if (options.throw) {
1231
+ const error = typeof options.notImplemented === "function" ? options.notImplemented() : new import_http_errors2.default.NotImplemented();
1232
+ throw error;
1233
+ }
1234
+ context.status = 501;
1235
+ context.set("Allow", allowedMethodsList.join(", "));
1236
+ }
1237
+ /**
1238
+ * Handle OPTIONS request
1239
+ * @private
1240
+ */
1241
+ _handleOptionsRequest(context, allowedMethodsList) {
1242
+ context.status = 200;
1243
+ context.body = "";
1244
+ context.set("Allow", allowedMethodsList.join(", "));
1245
+ }
1246
+ /**
1247
+ * Handle 405 Method Not Allowed response
1248
+ * @private
1249
+ */
1250
+ _handleMethodNotAllowed(context, allowedMethodsList, options) {
1251
+ if (options.throw) {
1252
+ const error = typeof options.methodNotAllowed === "function" ? options.methodNotAllowed() : new import_http_errors2.default.MethodNotAllowed();
1253
+ throw error;
1254
+ }
1255
+ context.status = 405;
1256
+ context.set("Allow", allowedMethodsList.join(", "));
1257
+ }
1258
+ all(...arguments_) {
1259
+ let name;
1260
+ let path;
1261
+ let middleware;
1262
+ if (arguments_.length >= 2 && (typeof arguments_[1] === "string" || arguments_[1] instanceof RegExp)) {
1263
+ name = arguments_[0];
1264
+ path = arguments_[1];
1265
+ middleware = arguments_.slice(2);
1266
+ } else {
1267
+ name = void 0;
1268
+ path = arguments_[0];
1269
+ middleware = arguments_.slice(1);
1270
+ }
1271
+ if (typeof path !== "string" && !(path instanceof RegExp) && (!Array.isArray(path) || path.length === 0))
1272
+ throw new Error("You have to provide a path when adding an all handler");
1273
+ const routeOptions = {
1274
+ name,
1275
+ pathAsRegExp: path instanceof RegExp
1276
+ };
1277
+ this.register(path, httpMethods, middleware, {
1278
+ ...this.opts,
1279
+ ...routeOptions
1280
+ });
1281
+ return this;
1282
+ }
1283
+ /**
1284
+ * Redirect `source` to `destination` URL with optional 30x status `code`.
1285
+ *
1286
+ * Both `source` and `destination` can be route names.
1287
+ *
1288
+ * ```javascript
1289
+ * router.redirect('/login', 'sign-in');
1290
+ * ```
1291
+ *
1292
+ * This is equivalent to:
1293
+ *
1294
+ * ```javascript
1295
+ * router.all('/login', ctx => {
1296
+ * ctx.redirect('/sign-in');
1297
+ * ctx.status = 301;
1298
+ * });
1299
+ * ```
1300
+ *
1301
+ * @param source - URL or route name
1302
+ * @param destination - URL or route name
1303
+ * @param code - HTTP status code (default: 301)
1304
+ * @returns This router instance
1305
+ */
1306
+ redirect(source, destination, code) {
1307
+ let resolvedSource = source;
1308
+ let resolvedDestination = destination;
1309
+ if (typeof source === "symbol" || typeof source === "string" && source[0] !== "/") {
1310
+ const sourceUrl = this.url(source);
1311
+ if (sourceUrl instanceof Error) throw sourceUrl;
1312
+ resolvedSource = sourceUrl;
1313
+ }
1314
+ if (typeof destination === "symbol" || typeof destination === "string" && destination[0] !== "/" && !destination.includes("://")) {
1315
+ const destinationUrl = this.url(destination);
1316
+ if (destinationUrl instanceof Error) throw destinationUrl;
1317
+ resolvedDestination = destinationUrl;
1318
+ }
1319
+ const result = this.all(
1320
+ resolvedSource,
1321
+ (context) => {
1322
+ context.redirect(resolvedDestination);
1323
+ context.status = code || 301;
1324
+ }
1325
+ );
1326
+ return result;
1327
+ }
1328
+ /**
1329
+ * Create and register a route.
1330
+ *
1331
+ * @param path - Path string
1332
+ * @param methods - Array of HTTP verbs
1333
+ * @param middleware - Middleware functions
1334
+ * @param additionalOptions - Additional options
1335
+ * @returns Created layer
1336
+ * @private
1337
+ */
1338
+ register(path, methods, middleware, additionalOptions = {}) {
1339
+ const mergedOptions = { ...this.opts, ...additionalOptions };
1340
+ if (Array.isArray(path)) {
1341
+ return this._registerMultiplePaths(
1342
+ path,
1343
+ methods,
1344
+ middleware,
1345
+ mergedOptions
1346
+ );
1347
+ }
1348
+ const routeLayer = this._createRouteLayer(
1349
+ path,
1350
+ methods,
1351
+ middleware,
1352
+ mergedOptions
1353
+ );
1354
+ if (this.opts.prefix) {
1355
+ routeLayer.setPrefix(this.opts.prefix);
1356
+ }
1357
+ applyAllParameterMiddleware(routeLayer, this.params);
1358
+ this.stack.push(routeLayer);
1359
+ debug("defined route %s %s", routeLayer.methods, routeLayer.path);
1360
+ return routeLayer;
1361
+ }
1362
+ /**
1363
+ * Register multiple paths with the same configuration
1364
+ * @private
1365
+ */
1366
+ _registerMultiplePaths(pathArray, methods, middleware, options) {
1367
+ for (const singlePath of pathArray) {
1368
+ this.register.call(this, singlePath, methods, middleware, options);
1369
+ }
1370
+ return this;
1371
+ }
1372
+ /**
1373
+ * Create a route layer with given configuration
1374
+ * @private
1375
+ */
1376
+ _createRouteLayer(path, methods, middleware, options) {
1377
+ return new Layer(path, methods, middleware, {
1378
+ end: options.end === false ? options.end : true,
1379
+ name: options.name,
1380
+ sensitive: options.sensitive || false,
1381
+ strict: options.strict || false,
1382
+ prefix: options.prefix || "",
1383
+ ignoreCaptures: options.ignoreCaptures,
1384
+ pathAsRegExp: options.pathAsRegExp
1385
+ });
1386
+ }
1387
+ /**
1388
+ * Lookup route with given `name`.
1389
+ *
1390
+ * @param name - Route name
1391
+ * @returns Matched layer or false
1392
+ */
1393
+ route(name) {
1394
+ const matchingRoute = this.stack.find((route) => route.name === name);
1395
+ return matchingRoute || false;
1396
+ }
1397
+ /**
1398
+ * Generate URL for route. Takes a route name and map of named `params`.
1399
+ *
1400
+ * @example
1401
+ *
1402
+ * ```javascript
1403
+ * router.get('user', '/users/:id', (ctx, next) => {
1404
+ * // ...
1405
+ * });
1406
+ *
1407
+ * router.url('user', 3);
1408
+ * // => "/users/3"
1409
+ *
1410
+ * router.url('user', { id: 3 });
1411
+ * // => "/users/3"
1412
+ *
1413
+ * router.use((ctx, next) => {
1414
+ * // redirect to named route
1415
+ * ctx.redirect(ctx.router.url('sign-in'));
1416
+ * })
1417
+ *
1418
+ * router.url('user', { id: 3 }, { query: { limit: 1 } });
1419
+ * // => "/users/3?limit=1"
1420
+ *
1421
+ * router.url('user', { id: 3 }, { query: "limit=1" });
1422
+ * // => "/users/3?limit=1"
1423
+ * ```
1424
+ *
1425
+ * @param name - Route name
1426
+ * @param args - URL parameters
1427
+ * @returns Generated URL or Error
1428
+ */
1429
+ url(name, ...arguments_) {
1430
+ const route = this.route(name);
1431
+ if (route) return route.url(...arguments_);
1432
+ return new Error(`No route found for name: ${String(name)}`);
1433
+ }
1434
+ /**
1435
+ * Match given `path` and return corresponding routes.
1436
+ *
1437
+ * @param path - Request path
1438
+ * @param method - HTTP method
1439
+ * @returns Match result with matched layers
1440
+ * @private
1441
+ */
1442
+ match(path, method) {
1443
+ const matchResult = {
1444
+ path: [],
1445
+ pathAndMethod: [],
1446
+ route: false
1447
+ };
1448
+ const normalizedMethod = method.toUpperCase();
1449
+ for (const layer of this.stack) {
1450
+ debug("test %s %s", layer.path, layer.regexp);
1451
+ if (layer.match(path)) {
1452
+ matchResult.path.push(layer);
1453
+ const isMiddleware = layer.methods.length === 0;
1454
+ const matchesMethod = layer.methods.includes(normalizedMethod);
1455
+ if (isMiddleware || matchesMethod) {
1456
+ matchResult.pathAndMethod.push(layer);
1457
+ if (layer.methods.length > 0) {
1458
+ matchResult.route = true;
1459
+ }
1460
+ }
1461
+ }
1462
+ }
1463
+ return matchResult;
1464
+ }
1465
+ /**
1466
+ * Match given `input` to allowed host
1467
+ * @param input - Host to check
1468
+ * @returns Whether host matches
1469
+ */
1470
+ matchHost(input) {
1471
+ const { host } = this;
1472
+ if (!host) {
1473
+ return true;
1474
+ }
1475
+ if (!input) {
1476
+ return false;
1477
+ }
1478
+ if (typeof host === "string") {
1479
+ return input === host;
1480
+ }
1481
+ if (Array.isArray(host)) {
1482
+ return host.includes(input);
1483
+ }
1484
+ if (host instanceof RegExp) {
1485
+ return host.test(input);
1486
+ }
1487
+ return false;
1488
+ }
1489
+ /**
1490
+ * Run middleware for named route parameters. Useful for auto-loading or
1491
+ * validation.
1492
+ *
1493
+ * @example
1494
+ *
1495
+ * ```javascript
1496
+ * router
1497
+ * .param('user', (id, ctx, next) => {
1498
+ * ctx.user = users[id];
1499
+ * if (!ctx.user) return ctx.status = 404;
1500
+ * return next();
1501
+ * })
1502
+ * .get('/users/:user', ctx => {
1503
+ * ctx.body = ctx.user;
1504
+ * })
1505
+ * .get('/users/:user/friends', ctx => {
1506
+ * return ctx.user.getFriends().then(function(friends) {
1507
+ * ctx.body = friends;
1508
+ * });
1509
+ * })
1510
+ * // /users/3 => {"id": 3, "name": "Alex"}
1511
+ * // /users/3/friends => [{"id": 4, "name": "TJ"}]
1512
+ * ```
1513
+ *
1514
+ * @param param - Parameter name
1515
+ * @param middleware - Parameter middleware
1516
+ * @returns This router instance
1517
+ */
1518
+ param(parameter, middleware) {
1519
+ if (!this.params[parameter]) {
1520
+ this.params[parameter] = [];
1521
+ }
1522
+ if (!Array.isArray(this.params[parameter])) {
1523
+ this.params[parameter] = [
1524
+ this.params[parameter]
1525
+ ];
1526
+ }
1527
+ this.params[parameter].push(middleware);
1528
+ for (const route of this.stack) {
1529
+ route.param(parameter, middleware);
1530
+ }
1531
+ return this;
1532
+ }
1533
+ /**
1534
+ * Helper method for registering HTTP verb routes
1535
+ * @internal - Used by dynamically added HTTP methods
1536
+ */
1537
+ _registerMethod(method, ...arguments_) {
1538
+ let name;
1539
+ let path;
1540
+ let middleware;
1541
+ if (arguments_.length >= 2 && (typeof arguments_[1] === "string" || arguments_[1] instanceof RegExp)) {
1542
+ name = arguments_[0];
1543
+ path = arguments_[1];
1544
+ middleware = arguments_.slice(2);
1545
+ } else {
1546
+ name = void 0;
1547
+ path = arguments_[0];
1548
+ middleware = arguments_.slice(1);
1549
+ }
1550
+ if (typeof path !== "string" && !(path instanceof RegExp) && (!Array.isArray(path) || path.length === 0))
1551
+ throw new Error(
1552
+ `You have to provide a path when adding a ${method} handler`
1553
+ );
1554
+ const options = {
1555
+ name,
1556
+ pathAsRegExp: path instanceof RegExp
1557
+ };
1558
+ this.register(path, [method], middleware, {
1559
+ ...this.opts,
1560
+ ...options
1561
+ });
1562
+ return this;
1563
+ }
1564
+ get(...arguments_) {
1565
+ return this._registerMethod("get", ...arguments_);
1566
+ }
1567
+ post(...arguments_) {
1568
+ return this._registerMethod("post", ...arguments_);
1569
+ }
1570
+ put(...arguments_) {
1571
+ return this._registerMethod("put", ...arguments_);
1572
+ }
1573
+ patch(...arguments_) {
1574
+ return this._registerMethod("patch", ...arguments_);
1575
+ }
1576
+ delete(...arguments_) {
1577
+ return this._registerMethod("delete", ...arguments_);
1578
+ }
1579
+ del(...arguments_) {
1580
+ return this.delete.apply(
1581
+ this,
1582
+ arguments_
1583
+ );
1584
+ }
1585
+ head(...arguments_) {
1586
+ return this._registerMethod("head", ...arguments_);
1587
+ }
1588
+ options(...arguments_) {
1589
+ return this._registerMethod("options", ...arguments_);
1590
+ }
1591
+ };
1592
+ var Router = RouterImplementation;
1593
+ var router_default = Router;
1594
+ for (const httpMethod of httpMethods) {
1595
+ const isAlreadyDefined = COMMON_HTTP_METHODS.includes(httpMethod) || httpMethod in RouterImplementation.prototype;
1596
+ if (!isAlreadyDefined) {
1597
+ Object.defineProperty(RouterImplementation.prototype, httpMethod, {
1598
+ value: function(...arguments_) {
1599
+ return this._registerMethod(httpMethod, ...arguments_);
1600
+ },
1601
+ writable: true,
1602
+ configurable: true,
1603
+ enumerable: false
1604
+ });
1605
+ }
1606
+ }
1607
+ // Annotate the CommonJS export names for ESM import in node:
1608
+ 0 && (module.exports = {
1609
+ Router,
1610
+ RouterEvents,
1611
+ createParameterValidationMiddleware
1612
+ });
1613
+ if (module.exports.default) {
1614
+ Object.assign(module.exports.default, module.exports);
1615
+ module.exports = module.exports.default;
1616
+ }