@udibo/oauth2 0.14.1 → 0.15.0

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 (411) hide show
  1. package/README.md +45 -24
  2. package/{esm → dist}/adapters/hono/_common.d.ts +5 -5
  3. package/{esm → dist}/adapters/hono/_common.js +1 -1
  4. package/{esm → dist}/adapters/hono/authorization-server.d.ts +6 -7
  5. package/{esm → dist}/adapters/hono/authorization-server.js +0 -1
  6. package/{esm → dist}/adapters/hono/bff/auth-request-store.d.ts +2 -2
  7. package/{esm → dist}/adapters/hono/bff/auth-request-store.js +2 -2
  8. package/{esm → dist}/adapters/hono/bff/bff.d.ts +8 -8
  9. package/{esm → dist}/adapters/hono/bff/bff.js +31 -26
  10. package/{esm → dist}/adapters/hono/bff/cookie-prefix.js +1 -2
  11. package/{esm → dist}/adapters/hono/bff/mod.d.ts +5 -6
  12. package/{esm → dist}/adapters/hono/bff/mod.js +1 -2
  13. package/{esm → dist}/adapters/hono/bff/proxy.js +2 -1
  14. package/{esm → dist}/adapters/hono/bff/session-store.d.ts +2 -2
  15. package/{esm → dist}/adapters/hono/bff/session-store.js +7 -6
  16. package/{esm → dist}/adapters/hono/bff/testing.d.ts +7 -8
  17. package/{esm → dist}/adapters/hono/bff/testing.js +19 -22
  18. package/{esm → dist}/adapters/hono/identity.d.ts +1 -2
  19. package/{esm → dist}/adapters/hono/identity.js +10 -10
  20. package/{esm → dist}/adapters/hono/log.d.ts +0 -1
  21. package/{esm → dist}/adapters/hono/log.js +0 -6
  22. package/{esm → dist}/adapters/hono/resource-server.d.ts +5 -6
  23. package/{esm → dist}/adapters/hono/resource-server.js +0 -1
  24. package/dist/cli/bin.d.ts +2 -0
  25. package/dist/cli/bin.js +3 -0
  26. package/dist/cli/idp/config.d.ts +110 -0
  27. package/dist/cli/idp/config.js +269 -0
  28. package/dist/cli/idp/mod.d.ts +20 -0
  29. package/dist/cli/idp/mod.js +175 -0
  30. package/dist/cli/idp/pages.d.ts +56 -0
  31. package/dist/cli/idp/pages.js +190 -0
  32. package/dist/cli/idp/server.d.ts +93 -0
  33. package/dist/cli/idp/server.js +559 -0
  34. package/dist/cli/keygen.d.ts +13 -0
  35. package/dist/cli/keygen.js +30 -0
  36. package/dist/cli/mod.d.ts +34 -0
  37. package/dist/cli/mod.js +94 -0
  38. package/{esm → dist}/client/_http.d.ts +1 -1
  39. package/{esm → dist}/client/base.d.ts +1 -1
  40. package/{esm → dist}/client/bff-client.d.ts +1 -1
  41. package/{esm → dist}/client/bff-client.js +7 -6
  42. package/{esm → dist}/client/browser-storage.d.ts +1 -1
  43. package/{esm → dist}/client/check.js +1 -1
  44. package/{esm → dist}/client/direct-client.d.ts +6 -6
  45. package/{esm → dist}/client/direct-client.js +11 -13
  46. package/{esm → dist}/client/discovery-cache.d.ts +1 -1
  47. package/{esm → dist}/client/discovery-cache.js +2 -2
  48. package/{esm → dist}/client/events.d.ts +1 -1
  49. package/{esm → dist}/client/mod.d.ts +11 -12
  50. package/{esm → dist}/client/mod.js +1 -1
  51. package/{esm → dist}/errors.d.ts +1 -1
  52. package/{esm → dist}/errors.js +1 -1
  53. package/{esm → dist}/identity/events.d.ts +1 -1
  54. package/{esm → dist}/identity/external/_shared.d.ts +1 -1
  55. package/{esm → dist}/identity/external/_shared.js +1 -2
  56. package/{esm → dist}/identity/external/apple-client-secret.d.ts +1 -1
  57. package/{esm → dist}/identity/external/apple-client-secret.js +6 -7
  58. package/{esm → dist}/identity/external/apple.d.ts +5 -5
  59. package/{esm → dist}/identity/external/apple.js +10 -11
  60. package/{esm → dist}/identity/external/discord.d.ts +3 -3
  61. package/{esm → dist}/identity/external/discord.js +2 -2
  62. package/{esm → dist}/identity/external/flow.d.ts +1 -1
  63. package/{esm → dist}/identity/external/flow.js +2 -2
  64. package/{esm → dist}/identity/external/github.d.ts +3 -3
  65. package/{esm → dist}/identity/external/github.js +12 -17
  66. package/{esm → dist}/identity/external/google.d.ts +5 -5
  67. package/{esm → dist}/identity/external/google.js +2 -2
  68. package/{esm → dist}/identity/external/mod.d.ts +12 -13
  69. package/{esm → dist}/identity/external/mod.js +0 -1
  70. package/{esm → dist}/identity/external/oauth2.d.ts +1 -1
  71. package/{esm → dist}/identity/external/oauth2.js +8 -8
  72. package/{esm → dist}/identity/external/oidc.d.ts +4 -4
  73. package/{esm → dist}/identity/external/oidc.js +9 -8
  74. package/{esm → dist}/identity/hibp.d.ts +1 -1
  75. package/{esm → dist}/identity/hibp.js +1 -1
  76. package/{esm → dist}/identity/lockout.js +1 -2
  77. package/{esm → dist}/identity/mfa/mod.d.ts +4 -5
  78. package/{esm → dist}/identity/mfa/mod.js +1 -2
  79. package/{esm → dist}/identity/mfa/service.d.ts +3 -3
  80. package/{esm → dist}/identity/mfa/service.js +4 -3
  81. package/{esm → dist}/identity/mfa/totp.d.ts +1 -1
  82. package/{esm → dist}/identity/mfa/totp.js +2 -2
  83. package/{esm → dist}/identity/migration.d.ts +2 -3
  84. package/{esm → dist}/identity/migration.js +3 -4
  85. package/{esm → dist}/identity/mod.d.ts +14 -15
  86. package/{esm → dist}/identity/mod.js +0 -1
  87. package/{esm → dist}/identity/otp.d.ts +1 -1
  88. package/{esm → dist}/identity/otp.js +4 -2
  89. package/{esm → dist}/identity/password.js +8 -5
  90. package/{esm → dist}/identity/rate-limit.d.ts +1 -1
  91. package/{esm → dist}/identity/service.d.ts +10 -10
  92. package/{esm → dist}/identity/service.js +17 -18
  93. package/{esm → dist}/identity/session.js +2 -2
  94. package/{esm → dist}/identity/token-flow.js +3 -2
  95. package/{esm → dist}/models/authorization-code.d.ts +3 -3
  96. package/{esm → dist}/models/authorization.d.ts +1 -1
  97. package/{esm → dist}/models/authorization.js +1 -2
  98. package/{esm → dist}/models/device-authorization.d.ts +2 -2
  99. package/{esm → dist}/models/token.d.ts +3 -3
  100. package/{esm → dist}/react/callback.d.ts +1 -1
  101. package/{esm → dist}/react/callback.js +0 -1
  102. package/{esm → dist}/react/components/class-names.d.ts +1 -1
  103. package/{esm → dist}/react/components/class-names.js +3 -2
  104. package/{esm → dist}/react/components/internal.d.ts +2 -2
  105. package/{esm → dist}/react/components/internal.js +5 -11
  106. package/{esm → dist}/react/components/mfa-challenge-form.d.ts +2 -2
  107. package/{esm → dist}/react/components/mfa-challenge-form.js +4 -6
  108. package/{esm → dist}/react/components/mfa-enrollment-form.d.ts +2 -2
  109. package/{esm → dist}/react/components/mfa-enrollment-form.js +2 -6
  110. package/{esm → dist}/react/components/mod.d.ts +20 -21
  111. package/{esm → dist}/react/components/mod.js +1 -2
  112. package/{esm → dist}/react/components/request-password-reset-form.d.ts +2 -2
  113. package/{esm → dist}/react/components/request-password-reset-form.js +1 -3
  114. package/{esm → dist}/react/components/reset-password-form.d.ts +2 -2
  115. package/{esm → dist}/react/components/reset-password-form.js +2 -2
  116. package/{esm → dist}/react/components/sign-in-form.d.ts +2 -2
  117. package/{esm → dist}/react/components/sign-in-form.js +1 -5
  118. package/{esm → dist}/react/components/sign-up-form.d.ts +2 -2
  119. package/{esm → dist}/react/components/sign-up-form.js +4 -10
  120. package/{esm → dist}/react/components/types.d.ts +2 -2
  121. package/{esm → dist}/react/components/use-auth-form.d.ts +3 -3
  122. package/{esm → dist}/react/components/use-auth-form.js +4 -7
  123. package/{esm → dist}/react/components/user-menu.d.ts +2 -2
  124. package/{esm → dist}/react/components/user-menu.js +9 -14
  125. package/{esm → dist}/react/context.d.ts +1 -1
  126. package/{esm → dist}/react/mod.d.ts +6 -7
  127. package/{esm → dist}/react/mod.js +0 -1
  128. package/{esm → dist}/react/provider.d.ts +2 -2
  129. package/{esm → dist}/react/require-auth.js +1 -3
  130. package/{esm → dist}/react/testing.d.ts +2 -3
  131. package/{esm → dist}/react/testing.js +1 -2
  132. package/{esm → dist}/react/use-authorization.d.ts +1 -1
  133. package/{esm → dist}/react/use-oauth2.d.ts +8 -1
  134. package/{esm → dist}/react/use-oauth2.js +0 -1
  135. package/{esm → dist}/server/_clock-skew.js +2 -1
  136. package/{esm → dist}/server/authorization-server.d.ts +40 -41
  137. package/{esm → dist}/server/authorization-server.js +32 -42
  138. package/{esm → dist}/server/client-authentication.d.ts +2 -2
  139. package/{esm → dist}/server/grants/authorization-code.d.ts +9 -9
  140. package/{esm → dist}/server/grants/authorization-code.js +5 -6
  141. package/{esm → dist}/server/grants/client-credentials.d.ts +4 -4
  142. package/{esm → dist}/server/grants/device-authorization.d.ts +6 -6
  143. package/{esm → dist}/server/grants/device-authorization.js +4 -4
  144. package/{esm → dist}/server/grants/grant.d.ts +7 -7
  145. package/{esm → dist}/server/grants/grant.js +7 -7
  146. package/{esm → dist}/server/grants/password.d.ts +5 -5
  147. package/{esm → dist}/server/grants/refresh-token.d.ts +4 -4
  148. package/{esm → dist}/server/grants/refresh-token.js +5 -6
  149. package/{esm → dist}/server/introspection-token-reader.d.ts +5 -5
  150. package/{esm → dist}/server/introspection-token-reader.js +4 -4
  151. package/{esm → dist}/server/jwks-token-reader.d.ts +5 -5
  152. package/{esm → dist}/server/jwks-token-reader.js +4 -4
  153. package/{esm → dist}/server/mod.d.ts +12 -13
  154. package/{esm → dist}/server/mod.js +0 -1
  155. package/{esm → dist}/server/public-suffix/mod.d.ts +2 -3
  156. package/{esm → dist}/server/public-suffix/mod.js +1 -2
  157. package/{esm → dist}/server/public-suffix/rules.d.ts +1 -1
  158. package/{esm → dist}/server/public-suffix/rules.js +1 -1
  159. package/{esm → dist}/server/redirect-uri.js +5 -4
  160. package/{esm → dist}/server/resource-server.d.ts +11 -12
  161. package/{esm → dist}/server/resource-server.js +12 -14
  162. package/{esm → dist}/server/services/authorization-code.d.ts +5 -5
  163. package/{esm → dist}/server/services/client.d.ts +1 -1
  164. package/{esm → dist}/server/services/device-authorization.d.ts +3 -3
  165. package/{esm → dist}/server/services/token.d.ts +6 -6
  166. package/{esm → dist}/server/services/token.js +3 -1
  167. package/{esm → dist}/server/services/user.d.ts +1 -1
  168. package/{esm → dist}/server/signing-keys.d.ts +1 -1
  169. package/{esm → dist}/server/signing-keys.js +8 -2
  170. package/{esm → dist}/server/utils/hash.js +1 -1
  171. package/{esm → dist}/testing/contract/auth-request-storage.d.ts +1 -1
  172. package/{esm → dist}/testing/contract/auth-request-storage.js +24 -29
  173. package/{esm → dist}/testing/contract/authorization-code.d.ts +6 -6
  174. package/{esm → dist}/testing/contract/authorization-code.js +16 -17
  175. package/{esm → dist}/testing/contract/client.d.ts +4 -4
  176. package/{esm → dist}/testing/contract/client.js +14 -15
  177. package/{esm → dist}/testing/contract/device-authorization.d.ts +6 -6
  178. package/{esm → dist}/testing/contract/device-authorization.js +37 -39
  179. package/{esm → dist}/testing/contract/identity-session.d.ts +6 -1
  180. package/{esm → dist}/testing/contract/identity-session.js +44 -36
  181. package/{esm → dist}/testing/contract/identity-user-store.d.ts +8 -2
  182. package/{esm → dist}/testing/contract/identity-user-store.js +48 -46
  183. package/{esm → dist}/testing/contract/lockout-store.d.ts +1 -1
  184. package/{esm → dist}/testing/contract/lockout-store.js +23 -24
  185. package/{esm → dist}/testing/contract/mfa-store.d.ts +1 -1
  186. package/{esm → dist}/testing/contract/mfa-store.js +53 -54
  187. package/{esm → dist}/testing/contract/mod.d.ts +15 -16
  188. package/{esm → dist}/testing/contract/mod.js +0 -1
  189. package/{esm → dist}/testing/contract/otp-store.d.ts +1 -1
  190. package/{esm → dist}/testing/contract/otp-store.js +33 -34
  191. package/{esm → dist}/testing/contract/rate-limit-store.d.ts +1 -1
  192. package/{esm → dist}/testing/contract/rate-limit-store.js +15 -16
  193. package/{esm → dist}/testing/contract/tenant.js +361 -330
  194. package/{esm → dist}/testing/contract/token-flow-store.d.ts +1 -1
  195. package/{esm → dist}/testing/contract/token-flow-store.js +27 -32
  196. package/{esm → dist}/testing/contract/token-reader.d.ts +3 -3
  197. package/{esm → dist}/testing/contract/token-reader.js +6 -7
  198. package/{esm → dist}/testing/contract/token.d.ts +7 -7
  199. package/{esm → dist}/testing/contract/token.js +48 -53
  200. package/{esm → dist}/testing/contract/user.d.ts +2 -2
  201. package/{esm → dist}/testing/contract/user.js +8 -9
  202. package/{esm → dist}/testing/mod.d.ts +5 -6
  203. package/{esm → dist}/testing/mod.js +2 -3
  204. package/{esm → dist}/testing/server.d.ts +7 -6
  205. package/{esm → dist}/testing/server.js +2 -1
  206. package/{esm → dist}/testing/services.d.ts +11 -11
  207. package/{esm → dist}/testing/services.js +8 -8
  208. package/{esm → dist}/testing/tenant.d.ts +11 -7
  209. package/{esm → dist}/testing/tenant.js +109 -94
  210. package/dist/utils/_constant-time.d.ts +12 -0
  211. package/dist/utils/_constant-time.js +19 -0
  212. package/{esm → dist}/utils/_default-fetch.js +4 -1
  213. package/dist/utils/_delay.d.ts +13 -0
  214. package/dist/utils/_delay.js +28 -0
  215. package/dist/utils/_encoding.d.ts +39 -0
  216. package/dist/utils/_encoding.js +126 -0
  217. package/{esm → dist}/utils/authentication-context.d.ts +1 -1
  218. package/{esm → dist}/utils/crypto.d.ts +2 -3
  219. package/{esm → dist}/utils/crypto.js +3 -4
  220. package/{esm → dist}/utils/pkce.js +1 -1
  221. package/{esm → dist}/utils/text.js +1 -1
  222. package/{esm → dist}/utils/url.d.ts +0 -1
  223. package/{esm → dist}/utils/url.js +0 -1
  224. package/package.json +156 -33
  225. package/esm/_dnt.polyfills.d.ts +0 -31
  226. package/esm/_dnt.polyfills.js +0 -26
  227. package/esm/deps/jsr.io/@std/assert/1.0.19/almost_equals.d.ts +0 -29
  228. package/esm/deps/jsr.io/@std/assert/1.0.19/almost_equals.js +0 -47
  229. package/esm/deps/jsr.io/@std/assert/1.0.19/array_includes.d.ts +0 -28
  230. package/esm/deps/jsr.io/@std/assert/1.0.19/array_includes.js +0 -65
  231. package/esm/deps/jsr.io/@std/assert/1.0.19/assert.d.ts +0 -16
  232. package/esm/deps/jsr.io/@std/assert/1.0.19/assert.js +0 -23
  233. package/esm/deps/jsr.io/@std/assert/1.0.19/assertion_error.d.ts +0 -25
  234. package/esm/deps/jsr.io/@std/assert/1.0.19/assertion_error.js +0 -30
  235. package/esm/deps/jsr.io/@std/assert/1.0.19/equal.d.ts +0 -24
  236. package/esm/deps/jsr.io/@std/assert/1.0.19/equal.js +0 -193
  237. package/esm/deps/jsr.io/@std/assert/1.0.19/equals.d.ts +0 -36
  238. package/esm/deps/jsr.io/@std/assert/1.0.19/equals.js +0 -61
  239. package/esm/deps/jsr.io/@std/assert/1.0.19/exists.d.ts +0 -17
  240. package/esm/deps/jsr.io/@std/assert/1.0.19/exists.js +0 -27
  241. package/esm/deps/jsr.io/@std/assert/1.0.19/fail.d.ts +0 -14
  242. package/esm/deps/jsr.io/@std/assert/1.0.19/fail.js +0 -20
  243. package/esm/deps/jsr.io/@std/assert/1.0.19/false.d.ts +0 -18
  244. package/esm/deps/jsr.io/@std/assert/1.0.19/false.js +0 -23
  245. package/esm/deps/jsr.io/@std/assert/1.0.19/greater.d.ts +0 -19
  246. package/esm/deps/jsr.io/@std/assert/1.0.19/greater.js +0 -29
  247. package/esm/deps/jsr.io/@std/assert/1.0.19/greater_or_equal.d.ts +0 -19
  248. package/esm/deps/jsr.io/@std/assert/1.0.19/greater_or_equal.js +0 -29
  249. package/esm/deps/jsr.io/@std/assert/1.0.19/instance_of.d.ts +0 -22
  250. package/esm/deps/jsr.io/@std/assert/1.0.19/instance_of.js +0 -52
  251. package/esm/deps/jsr.io/@std/assert/1.0.19/is_error.d.ts +0 -24
  252. package/esm/deps/jsr.io/@std/assert/1.0.19/is_error.js +0 -53
  253. package/esm/deps/jsr.io/@std/assert/1.0.19/less.d.ts +0 -18
  254. package/esm/deps/jsr.io/@std/assert/1.0.19/less.js +0 -28
  255. package/esm/deps/jsr.io/@std/assert/1.0.19/less_or_equal.d.ts +0 -19
  256. package/esm/deps/jsr.io/@std/assert/1.0.19/less_or_equal.js +0 -29
  257. package/esm/deps/jsr.io/@std/assert/1.0.19/match.d.ts +0 -17
  258. package/esm/deps/jsr.io/@std/assert/1.0.19/match.js +0 -26
  259. package/esm/deps/jsr.io/@std/assert/1.0.19/mod.d.ts +0 -43
  260. package/esm/deps/jsr.io/@std/assert/1.0.19/mod.js +0 -45
  261. package/esm/deps/jsr.io/@std/assert/1.0.19/not_equals.d.ts +0 -26
  262. package/esm/deps/jsr.io/@std/assert/1.0.19/not_equals.js +0 -39
  263. package/esm/deps/jsr.io/@std/assert/1.0.19/not_instance_of.d.ts +0 -19
  264. package/esm/deps/jsr.io/@std/assert/1.0.19/not_instance_of.js +0 -29
  265. package/esm/deps/jsr.io/@std/assert/1.0.19/not_match.d.ts +0 -17
  266. package/esm/deps/jsr.io/@std/assert/1.0.19/not_match.js +0 -26
  267. package/esm/deps/jsr.io/@std/assert/1.0.19/not_strict_equals.d.ts +0 -22
  268. package/esm/deps/jsr.io/@std/assert/1.0.19/not_strict_equals.js +0 -32
  269. package/esm/deps/jsr.io/@std/assert/1.0.19/object_match.d.ts +0 -28
  270. package/esm/deps/jsr.io/@std/assert/1.0.19/object_match.js +0 -177
  271. package/esm/deps/jsr.io/@std/assert/1.0.19/rejects.d.ts +0 -41
  272. package/esm/deps/jsr.io/@std/assert/1.0.19/rejects.js +0 -53
  273. package/esm/deps/jsr.io/@std/assert/1.0.19/strict_equals.d.ts +0 -23
  274. package/esm/deps/jsr.io/@std/assert/1.0.19/strict_equals.js +0 -58
  275. package/esm/deps/jsr.io/@std/assert/1.0.19/string_includes.d.ts +0 -17
  276. package/esm/deps/jsr.io/@std/assert/1.0.19/string_includes.js +0 -26
  277. package/esm/deps/jsr.io/@std/assert/1.0.19/throws.d.ts +0 -44
  278. package/esm/deps/jsr.io/@std/assert/1.0.19/throws.js +0 -44
  279. package/esm/deps/jsr.io/@std/assert/1.0.19/unimplemented.d.ts +0 -14
  280. package/esm/deps/jsr.io/@std/assert/1.0.19/unimplemented.js +0 -20
  281. package/esm/deps/jsr.io/@std/assert/1.0.19/unreachable.d.ts +0 -14
  282. package/esm/deps/jsr.io/@std/assert/1.0.19/unreachable.js +0 -20
  283. package/esm/deps/jsr.io/@std/async/1.5.0/delay.d.ts +0 -44
  284. package/esm/deps/jsr.io/@std/async/1.5.0/delay.js +0 -84
  285. package/esm/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.d.ts +0 -39
  286. package/esm/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.js +0 -61
  287. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common16.d.ts +0 -22
  288. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common16.js +0 -51
  289. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common32.d.ts +0 -34
  290. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common32.js +0 -192
  291. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common64.d.ts +0 -34
  292. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common64.js +0 -113
  293. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common_detach.d.ts +0 -3
  294. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common_detach.js +0 -13
  295. package/esm/deps/jsr.io/@std/encoding/1.0.11/_types.d.ts +0 -8
  296. package/esm/deps/jsr.io/@std/encoding/1.0.11/_types.js +0 -2
  297. package/esm/deps/jsr.io/@std/encoding/1.0.11/_validate_binary_like.d.ts +0 -1
  298. package/esm/deps/jsr.io/@std/encoding/1.0.11/_validate_binary_like.js +0 -26
  299. package/esm/deps/jsr.io/@std/encoding/1.0.11/ascii85.d.ts +0 -60
  300. package/esm/deps/jsr.io/@std/encoding/1.0.11/ascii85.js +0 -152
  301. package/esm/deps/jsr.io/@std/encoding/1.0.11/base32.d.ts +0 -39
  302. package/esm/deps/jsr.io/@std/encoding/1.0.11/base32.js +0 -87
  303. package/esm/deps/jsr.io/@std/encoding/1.0.11/base58.d.ts +0 -39
  304. package/esm/deps/jsr.io/@std/encoding/1.0.11/base58.js +0 -131
  305. package/esm/deps/jsr.io/@std/encoding/1.0.11/base64.d.ts +0 -39
  306. package/esm/deps/jsr.io/@std/encoding/1.0.11/base64.js +0 -82
  307. package/esm/deps/jsr.io/@std/encoding/1.0.11/base64url.d.ts +0 -39
  308. package/esm/deps/jsr.io/@std/encoding/1.0.11/base64url.js +0 -72
  309. package/esm/deps/jsr.io/@std/encoding/1.0.11/hex.d.ts +0 -38
  310. package/esm/deps/jsr.io/@std/encoding/1.0.11/hex.js +0 -87
  311. package/esm/deps/jsr.io/@std/encoding/1.0.11/mod.d.ts +0 -97
  312. package/esm/deps/jsr.io/@std/encoding/1.0.11/mod.js +0 -99
  313. package/esm/deps/jsr.io/@std/encoding/1.0.11/varint.d.ts +0 -119
  314. package/esm/deps/jsr.io/@std/encoding/1.0.11/varint.js +0 -209
  315. package/esm/deps/jsr.io/@std/http/1.1.3/status.d.ts +0 -343
  316. package/esm/deps/jsr.io/@std/http/1.1.3/status.js +0 -343
  317. package/esm/deps/jsr.io/@std/internal/1.0.14/assertion_state.d.ts +0 -159
  318. package/esm/deps/jsr.io/@std/internal/1.0.14/assertion_state.js +0 -223
  319. package/esm/deps/jsr.io/@std/internal/1.0.14/build_message.d.ts +0 -79
  320. package/esm/deps/jsr.io/@std/internal/1.0.14/build_message.js +0 -116
  321. package/esm/deps/jsr.io/@std/internal/1.0.14/diff.d.ts +0 -139
  322. package/esm/deps/jsr.io/@std/internal/1.0.14/diff.js +0 -277
  323. package/esm/deps/jsr.io/@std/internal/1.0.14/diff_str.d.ts +0 -98
  324. package/esm/deps/jsr.io/@std/internal/1.0.14/diff_str.js +0 -181
  325. package/esm/deps/jsr.io/@std/internal/1.0.14/format.d.ts +0 -29
  326. package/esm/deps/jsr.io/@std/internal/1.0.14/format.js +0 -68
  327. package/esm/deps/jsr.io/@std/internal/1.0.14/styles.d.ts +0 -158
  328. package/esm/deps/jsr.io/@std/internal/1.0.14/styles.js +0 -206
  329. package/esm/deps/jsr.io/@std/internal/1.0.14/types.d.ts +0 -24
  330. package/esm/deps/jsr.io/@std/internal/1.0.14/types.js +0 -3
  331. package/esm/deps/jsr.io/@std/testing/1.0.20/_test_suite.d.ts +0 -91
  332. package/esm/deps/jsr.io/@std/testing/1.0.20/_test_suite.js +0 -347
  333. package/esm/deps/jsr.io/@std/testing/1.0.20/bdd.d.ts +0 -382
  334. package/esm/deps/jsr.io/@std/testing/1.0.20/bdd.js +0 -1110
  335. package/esm/deps/jsr.io/@udibo/http-error/0.11.1/mod.d.ts +0 -363
  336. package/esm/deps/jsr.io/@udibo/http-error/0.11.1/mod.js +0 -616
  337. package/esm/package.json +0 -3
  338. /package/{esm → dist}/adapters/hono/bff/cookie-prefix.d.ts +0 -0
  339. /package/{esm → dist}/adapters/hono/bff/proxy.d.ts +0 -0
  340. /package/{esm → dist}/client/_http.js +0 -0
  341. /package/{esm → dist}/client/base.js +0 -0
  342. /package/{esm → dist}/client/browser-storage.js +0 -0
  343. /package/{esm → dist}/client/check.d.ts +0 -0
  344. /package/{esm → dist}/client/events.js +0 -0
  345. /package/{esm → dist}/client/storage.d.ts +0 -0
  346. /package/{esm → dist}/client/storage.js +0 -0
  347. /package/{esm → dist}/identity/captcha.d.ts +0 -0
  348. /package/{esm → dist}/identity/captcha.js +0 -0
  349. /package/{esm → dist}/identity/delivery.d.ts +0 -0
  350. /package/{esm → dist}/identity/delivery.js +0 -0
  351. /package/{esm → dist}/identity/errors.d.ts +0 -0
  352. /package/{esm → dist}/identity/errors.js +0 -0
  353. /package/{esm → dist}/identity/events.js +0 -0
  354. /package/{esm → dist}/identity/external/_token-exchange.d.ts +0 -0
  355. /package/{esm → dist}/identity/external/_token-exchange.js +0 -0
  356. /package/{esm → dist}/identity/external/errors.d.ts +0 -0
  357. /package/{esm → dist}/identity/external/errors.js +0 -0
  358. /package/{esm → dist}/identity/external/provider.d.ts +0 -0
  359. /package/{esm → dist}/identity/external/provider.js +0 -0
  360. /package/{esm → dist}/identity/identifier.d.ts +0 -0
  361. /package/{esm → dist}/identity/identifier.js +0 -0
  362. /package/{esm → dist}/identity/lockout.d.ts +0 -0
  363. /package/{esm → dist}/identity/mfa/recovery-codes.d.ts +0 -0
  364. /package/{esm → dist}/identity/mfa/recovery-codes.js +0 -0
  365. /package/{esm → dist}/identity/password-policy.d.ts +0 -0
  366. /package/{esm → dist}/identity/password-policy.js +0 -0
  367. /package/{esm → dist}/identity/password.d.ts +0 -0
  368. /package/{esm → dist}/identity/rate-limit.js +0 -0
  369. /package/{esm → dist}/identity/session.d.ts +0 -0
  370. /package/{esm → dist}/identity/token-flow.d.ts +0 -0
  371. /package/{esm → dist}/models/authentication.d.ts +0 -0
  372. /package/{esm → dist}/models/authentication.js +0 -0
  373. /package/{esm → dist}/models/authorization-code.js +0 -0
  374. /package/{esm → dist}/models/client.d.ts +0 -0
  375. /package/{esm → dist}/models/client.js +0 -0
  376. /package/{esm → dist}/models/device-authorization.js +0 -0
  377. /package/{esm → dist}/models/responses.d.ts +0 -0
  378. /package/{esm → dist}/models/responses.js +0 -0
  379. /package/{esm → dist}/models/scope.d.ts +0 -0
  380. /package/{esm → dist}/models/scope.js +0 -0
  381. /package/{esm → dist}/models/token.js +0 -0
  382. /package/{esm → dist}/react/components/types.js +0 -0
  383. /package/{esm → dist}/react/context.js +0 -0
  384. /package/{esm → dist}/react/provider.js +0 -0
  385. /package/{esm → dist}/react/require-auth.d.ts +0 -0
  386. /package/{esm → dist}/react/use-authorization.js +0 -0
  387. /package/{esm → dist}/server/_clock-skew.d.ts +0 -0
  388. /package/{esm → dist}/server/client-authentication.js +0 -0
  389. /package/{esm → dist}/server/grants/client-credentials.js +0 -0
  390. /package/{esm → dist}/server/grants/password.js +0 -0
  391. /package/{esm → dist}/server/redirect-uri.d.ts +0 -0
  392. /package/{esm → dist}/server/services/authorization-code.js +0 -0
  393. /package/{esm → dist}/server/services/client.js +0 -0
  394. /package/{esm → dist}/server/services/device-authorization.js +0 -0
  395. /package/{esm → dist}/server/services/user.js +0 -0
  396. /package/{esm → dist}/server/utils/hash.d.ts +0 -0
  397. /package/{esm → dist}/testing/contract/_race.d.ts +0 -0
  398. /package/{esm → dist}/testing/contract/_race.js +0 -0
  399. /package/{esm → dist}/testing/contract/tenant.d.ts +0 -0
  400. /package/{esm → dist}/utils/_body.d.ts +0 -0
  401. /package/{esm → dist}/utils/_body.js +0 -0
  402. /package/{esm → dist}/utils/_buffer.d.ts +0 -0
  403. /package/{esm → dist}/utils/_buffer.js +0 -0
  404. /package/{esm → dist}/utils/_default-fetch.d.ts +0 -0
  405. /package/{esm → dist}/utils/_timing-safe.d.ts +0 -0
  406. /package/{esm → dist}/utils/_timing-safe.js +0 -0
  407. /package/{esm → dist}/utils/authentication-context.js +0 -0
  408. /package/{esm → dist}/utils/basic-auth.d.ts +0 -0
  409. /package/{esm → dist}/utils/basic-auth.js +0 -0
  410. /package/{esm → dist}/utils/pkce.d.ts +0 -0
  411. /package/{esm → dist}/utils/text.d.ts +0 -0
@@ -1,1110 +0,0 @@
1
- // Copyright 2018-2026 the Deno authors. MIT license.
2
- /**
3
- * A {@link https://en.wikipedia.org/wiki/Behavior-driven_development | BDD} interface
4
- * to `Deno.test()` API.
5
- *
6
- * > [!WARNING]
7
- * > **Deprecated**: A BDD interface is available through the `node:test`
8
- * > module, which is supported first-class by `deno test`. Use `node:test`'s
9
- * > `describe()` and `it()`, or the flat `Deno.test()` style with the
10
- * > `Deno.test.beforeAll()`/`beforeEach()`/`afterEach()`/`afterAll()` hooks
11
- * > (Deno 2.5+), instead. This module will be removed in 2.0.0.
12
- *
13
- * Migration is mostly a matter of changing the import:
14
- *
15
- * ```ts ignore
16
- * // Before
17
- * import { describe, it, beforeEach } from "@std/testing/bdd";
18
- *
19
- * // After
20
- * import { describe, it, beforeEach } from "node:test";
21
- * ```
22
- *
23
- * `it.only`, `it.skip` and `it.todo` (and the `describe` equivalents) are
24
- * available in `node:test` as well. Note that `node:test` suites don't accept
25
- * `Deno.test` options such as `sanitizeOps`, `sanitizeResources` or
26
- * `permissions`; tests that rely on per-suite options can migrate to the flat
27
- * `Deno.test()` style instead, which accepts them per test.
28
- *
29
- * With `@std/testing/bdd` module you can write your tests in a familiar format for
30
- * grouping tests and adding setup/teardown hooks used by other JavaScript testing
31
- * frameworks like Jasmine, Jest, and Mocha.
32
- *
33
- * The `describe` function creates a block that groups together several related
34
- * tests. The `it` function registers an individual test case.
35
- *
36
- * ## Hooks
37
- *
38
- * There are 4 types of hooks available for test suites. A test suite can have
39
- * multiples of each type of hook, they will be called in the order that they are
40
- * registered. The `afterEach` and `afterAll` hooks will be called whether or not
41
- * the test case passes. The *All hooks will be called once for the whole group
42
- * while the *Each hooks will be called for each individual test case.
43
- *
44
- * - `beforeAll`: Runs before all of the tests in the group.
45
- * - `afterAll`: Runs after all of the tests in the group finish.
46
- * - `beforeEach`: Runs before each of the individual test cases in the group.
47
- * - `afterEach`: Runs after each of the individual test cases in the group.
48
- *
49
- * If a hook is registered at the top level, a global test suite will be registered
50
- * and all tests will belong to it. Hooks registered at the top level must be
51
- * registered before any individual test cases or test suites.
52
- *
53
- * ## Focusing tests
54
- *
55
- * If you would like to run only specific test cases, you can do so by calling
56
- * `it.only` instead of `it`. If you would like to run only specific test suites,
57
- * you can do so by calling `describe.only` instead of `describe`.
58
- *
59
- * There is one limitation to this when using the flat test grouping style. When
60
- * `describe` is called without being nested, it registers the test with
61
- * `Deno.test`. If a child test case or suite is registered with `it.only` or
62
- * `describe.only`, it will be scoped to the top test suite instead of the file. To
63
- * make them the only tests that run in the file, you would need to register the
64
- * top test suite with `describe.only` too.
65
- *
66
- * ## Ignoring tests
67
- *
68
- * If you would like to not run specific individual test cases, you can do so by
69
- * calling `it.ignore` instead of `it`. If you would like to not run specific test
70
- * suites, you can do so by calling `describe.ignore` instead of `describe`.
71
- *
72
- * ## Sanitization options
73
- *
74
- * Like `Deno.TestDefinition`, the `DescribeDefinition` and `ItDefinition` have
75
- * sanitization options. They work in the same way.
76
- *
77
- * - `sanitizeExit`: Ensure the test case does not prematurely cause the process to
78
- * exit, for example via a call to Deno.exit. Defaults to true.
79
- * - `sanitizeOps`: Check that the number of async completed ops after the test is
80
- * the same as number of dispatched ops. Defaults to true.
81
- * - `sanitizeResources`: Ensure the test case does not "leak" resources - ie. the
82
- * resource table after the test has exactly the same contents as before the
83
- * test. Defaults to true.
84
- *
85
- * ## Permissions option
86
- *
87
- * Like `Deno.TestDefinition`, the `DescribeDefinition` and `ItDefinition` have a
88
- * `permissions` option. They specify the permissions that should be used to run an
89
- * individual test case or test suite. Set this to `"inherit"` to keep the calling
90
- * thread's permissions. Set this to `"none"` to revoke all permissions.
91
- *
92
- * This setting defaults to `"inherit"`.
93
- *
94
- * There is currently one limitation to this, you cannot use the permissions option
95
- * on an individual test case or test suite that belongs to another test suite.
96
- * That's because internally those tests are registered with `t.step` which does
97
- * not support the permissions option.
98
- *
99
- * ## Comparing to Deno\.test
100
- *
101
- * The default way of writing tests is using `Deno.test` and `t.step`. The
102
- * `describe` and `it` functions have similar call signatures to `Deno.test`,
103
- * making it easy to switch between the default style and the behavior-driven
104
- * development style of writing tests. Internally, `describe` and `it` are
105
- * registering tests with `Deno.test` and `t.step`.
106
- *
107
- * Below is an example of a test file using `Deno.test` and `t.step`. In the
108
- * following sections there are examples of how the same test could be written with
109
- * `describe` and `it` using nested test grouping, flat test grouping, or a mix of
110
- * both styles.
111
- *
112
- * ```ts
113
- * import {
114
- * assertEquals,
115
- * assertStrictEquals,
116
- * assertThrows,
117
- * } from "@std/assert";
118
- *
119
- * class User {
120
- * static users: Map<string, User> = new Map();
121
- * name: string;
122
- * age?: number;
123
- *
124
- * constructor(name: string) {
125
- * if (User.users.has(name)) {
126
- * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
127
- * }
128
- * this.name = name;
129
- * User.users.set(name, this);
130
- * }
131
- *
132
- * getAge(): number {
133
- * if (!this.age) {
134
- * throw new Error("Age unknown");
135
- * }
136
- * return this.age;
137
- * }
138
- *
139
- * setAge(age: number) {
140
- * this.age = age;
141
- * }
142
- * }
143
- *
144
- * Deno.test("User.users initially empty", () => {
145
- * assertEquals(User.users.size, 0);
146
- * });
147
- *
148
- * Deno.test("User constructor", () => {
149
- * try {
150
- * const user = new User("Kyle");
151
- * assertEquals(user.name, "Kyle");
152
- * assertStrictEquals(User.users.get("Kyle"), user);
153
- * } finally {
154
- * User.users.clear();
155
- * }
156
- * });
157
- *
158
- * Deno.test("User age", async (t) => {
159
- * const user = new User("Kyle");
160
- *
161
- * await t.step("getAge", () => {
162
- * assertThrows(() => user.getAge(), Error, "Age unknown");
163
- * user.age = 18;
164
- * assertEquals(user.getAge(), 18);
165
- * });
166
- *
167
- * await t.step("setAge", () => {
168
- * user.setAge(18);
169
- * assertEquals(user.getAge(), 18);
170
- * });
171
- * });
172
- * ```
173
- *
174
- * ### Nested test grouping
175
- *
176
- * Tests created within the callback of a `describe` function call will belong to
177
- * the new test suite it creates. The hooks can be created within it or be added to
178
- * the options argument for describe.
179
- *
180
- * ```ts ignore
181
- * import {
182
- * assertEquals,
183
- * assertStrictEquals,
184
- * assertThrows,
185
- * } from "@std/assert";
186
- * import {
187
- * afterEach,
188
- * beforeEach,
189
- * describe,
190
- * it,
191
- * } from "@std/testing/bdd";
192
- *
193
- * class User {
194
- * static users: Map<string, User> = new Map();
195
- * name: string;
196
- * age?: number;
197
- *
198
- * constructor(name: string) {
199
- * if (User.users.has(name)) {
200
- * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
201
- * }
202
- * this.name = name;
203
- * User.users.set(name, this);
204
- * }
205
- *
206
- * getAge(): number {
207
- * if (!this.age) {
208
- * throw new Error("Age unknown");
209
- * }
210
- * return this.age;
211
- * }
212
- *
213
- * setAge(age: number) {
214
- * this.age = age;
215
- * }
216
- * }
217
- *
218
- * describe("User", () => {
219
- * it("users initially empty", () => {
220
- * assertEquals(User.users.size, 0);
221
- * });
222
- *
223
- * it("constructor", () => {
224
- * try {
225
- * const user = new User("Kyle");
226
- * assertEquals(user.name, "Kyle");
227
- * assertStrictEquals(User.users.get("Kyle"), user);
228
- * } finally {
229
- * User.users.clear();
230
- * }
231
- * });
232
- *
233
- * describe("age", () => {
234
- * let user: User;
235
- *
236
- * beforeEach(() => {
237
- * user = new User("Kyle");
238
- * });
239
- *
240
- * afterEach(() => {
241
- * User.users.clear();
242
- * });
243
- *
244
- * it("getAge", function () {
245
- * assertThrows(() => user.getAge(), Error, "Age unknown");
246
- * user.age = 18;
247
- * assertEquals(user.getAge(), 18);
248
- * });
249
- *
250
- * it("setAge", function () {
251
- * user.setAge(18);
252
- * assertEquals(user.getAge(), 18);
253
- * });
254
- * });
255
- * });
256
- * ```
257
- *
258
- * ### Flat test grouping
259
- *
260
- * The `describe` function returns a unique symbol that can be used to reference
261
- * the test suite for adding tests to it without having to create them within a
262
- * callback. The gives you the ability to have test grouping without any extra
263
- * indentation in front of the grouped tests.
264
- *
265
- * ```ts ignore
266
- * import {
267
- * assertEquals,
268
- * assertStrictEquals,
269
- * assertThrows,
270
- * } from "@std/assert";
271
- * import {
272
- * describe,
273
- * it,
274
- * } from "@std/testing/bdd";
275
- *
276
- * class User {
277
- * static users: Map<string, User> = new Map();
278
- * name: string;
279
- * age?: number;
280
- *
281
- * constructor(name: string) {
282
- * if (User.users.has(name)) {
283
- * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
284
- * }
285
- * this.name = name;
286
- * User.users.set(name, this);
287
- * }
288
- *
289
- * getAge(): number {
290
- * if (!this.age) {
291
- * throw new Error("Age unknown");
292
- * }
293
- * return this.age;
294
- * }
295
- *
296
- * setAge(age: number) {
297
- * this.age = age;
298
- * }
299
- * }
300
- *
301
- * const userTests = describe("User");
302
- *
303
- * it(userTests, "users initially empty", () => {
304
- * assertEquals(User.users.size, 0);
305
- * });
306
- *
307
- * it(userTests, "constructor", () => {
308
- * try {
309
- * const user = new User("Kyle");
310
- * assertEquals(user.name, "Kyle");
311
- * assertStrictEquals(User.users.get("Kyle"), user);
312
- * } finally {
313
- * User.users.clear();
314
- * }
315
- * });
316
- *
317
- * const ageTests = describe({
318
- * name: "age",
319
- * suite: userTests,
320
- * beforeEach(this: { user: User }) {
321
- * this.user = new User("Kyle");
322
- * },
323
- * afterEach() {
324
- * User.users.clear();
325
- * },
326
- * });
327
- *
328
- * it(ageTests, "getAge", function () {
329
- * const { user } = this;
330
- * assertThrows(() => user.getAge(), Error, "Age unknown");
331
- * user.age = 18;
332
- * assertEquals(user.getAge(), 18);
333
- * });
334
- *
335
- * it(ageTests, "setAge", function () {
336
- * const { user } = this;
337
- * user.setAge(18);
338
- * assertEquals(user.getAge(), 18);
339
- * });
340
- * ```
341
- *
342
- * ### Mixed test grouping
343
- *
344
- * Both nested test grouping and flat test grouping can be used together. This can
345
- * be useful if you'd like to create deep groupings without all the extra
346
- * indentation in front of each line.
347
- *
348
- * ```ts ignore
349
- * import {
350
- * assertEquals,
351
- * assertStrictEquals,
352
- * assertThrows,
353
- * } from "@std/assert";
354
- * import {
355
- * describe,
356
- * it,
357
- * } from "@std/testing/bdd";
358
- *
359
- * class User {
360
- * static users: Map<string, User> = new Map();
361
- * name: string;
362
- * age?: number;
363
- *
364
- * constructor(name: string) {
365
- * if (User.users.has(name)) {
366
- * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
367
- * }
368
- * this.name = name;
369
- * User.users.set(name, this);
370
- * }
371
- *
372
- * getAge(): number {
373
- * if (!this.age) {
374
- * throw new Error("Age unknown");
375
- * }
376
- * return this.age;
377
- * }
378
- *
379
- * setAge(age: number) {
380
- * this.age = age;
381
- * }
382
- * }
383
- *
384
- * describe("User", () => {
385
- * it("users initially empty", () => {
386
- * assertEquals(User.users.size, 0);
387
- * });
388
- *
389
- * it("constructor", () => {
390
- * try {
391
- * const user = new User("Kyle");
392
- * assertEquals(user.name, "Kyle");
393
- * assertStrictEquals(User.users.get("Kyle"), user);
394
- * } finally {
395
- * User.users.clear();
396
- * }
397
- * });
398
- *
399
- * const ageTests = describe({
400
- * name: "age",
401
- * beforeEach(this: { user: User }) {
402
- * this.user = new User("Kyle");
403
- * },
404
- * afterEach() {
405
- * User.users.clear();
406
- * },
407
- * });
408
- *
409
- * it(ageTests, "getAge", function () {
410
- * const { user } = this;
411
- * assertThrows(() => user.getAge(), Error, "Age unknown");
412
- * user.age = 18;
413
- * assertEquals(user.getAge(), 18);
414
- * });
415
- *
416
- * it(ageTests, "setAge", function () {
417
- * const { user } = this;
418
- * user.setAge(18);
419
- * assertEquals(user.getAge(), 18);
420
- * });
421
- * });
422
- * ```
423
- *
424
- * @deprecated This will be removed in 2.0.0. Use `node:test`'s BDD interface
425
- * or the flat `Deno.test()` style instead.
426
- *
427
- * @module
428
- */
429
- import { getAssertionState } from "../../internal/1.0.14/assertion_state.js";
430
- import { AssertionError } from "../../assert/1.0.19/assertion_error.js";
431
- import { globalSanitizersState, TestSuiteInternal, } from "./_test_suite.js";
432
- /** Generates an ItDefinition from ItArgs. */
433
- function itDefinition(...args) {
434
- let [suiteOptionsOrNameOrFn, optionsOrNameOrFn, optionsOrFn, fn,] = args;
435
- let suite = undefined;
436
- let name;
437
- let options;
438
- if (typeof suiteOptionsOrNameOrFn === "object" &&
439
- typeof suiteOptionsOrNameOrFn.symbol === "symbol") {
440
- suite = suiteOptionsOrNameOrFn;
441
- }
442
- else {
443
- fn = optionsOrFn;
444
- optionsOrFn = optionsOrNameOrFn;
445
- optionsOrNameOrFn = suiteOptionsOrNameOrFn;
446
- }
447
- if (typeof optionsOrNameOrFn === "string") {
448
- name = optionsOrNameOrFn;
449
- if (typeof optionsOrFn === "function") {
450
- fn = optionsOrFn;
451
- options = {};
452
- }
453
- else {
454
- options = optionsOrFn;
455
- if (!fn)
456
- fn = options.fn;
457
- }
458
- }
459
- else if (typeof optionsOrNameOrFn === "function") {
460
- fn = optionsOrNameOrFn;
461
- name = fn.name;
462
- options = {};
463
- }
464
- else {
465
- options = optionsOrNameOrFn;
466
- if (typeof optionsOrFn === "function") {
467
- fn = optionsOrFn;
468
- }
469
- else {
470
- fn = options.fn;
471
- }
472
- name = options.name ?? fn.name;
473
- }
474
- return {
475
- ...(suite !== undefined ? { suite } : {}),
476
- ...options,
477
- name,
478
- fn,
479
- };
480
- }
481
- /**
482
- * Registers an individual test case.
483
- *
484
- * @example Usage
485
- * ```ts ignore
486
- * import { describe, it } from "@std/testing/bdd";
487
- * import { assertEquals } from "@std/assert";
488
- *
489
- * describe("example", () => {
490
- * it("should pass", () => {
491
- * // test case
492
- * assertEquals(2 + 2, 4);
493
- * });
494
- * });
495
- * ```
496
- *
497
- * @typeParam T The self type of the function to implement the test case
498
- * @param args The test case
499
- *
500
- * @deprecated This will be removed in 2.0.0. Use `node:test`'s `it()` or
501
- * `Deno.test()` instead.
502
- */
503
- export function it(...args) {
504
- if (TestSuiteInternal.runningCount > 0) {
505
- throw new Error("Cannot register new test cases after already registered test cases start running");
506
- }
507
- const assertionState = getAssertionState();
508
- const options = itDefinition(...args);
509
- const { suite } = options;
510
- const testSuite = suite
511
- ? TestSuiteInternal.suites.get(suite.symbol)
512
- : TestSuiteInternal.current;
513
- if (!TestSuiteInternal.started)
514
- TestSuiteInternal.started = true;
515
- if (testSuite) {
516
- TestSuiteInternal.addStep(testSuite, options);
517
- }
518
- else {
519
- const { name, fn, ignore, only, permissions, sanitizeExit = globalSanitizersState.sanitizeExit, sanitizeOps = globalSanitizersState.sanitizeOps, sanitizeResources = globalSanitizersState.sanitizeResources, } = options;
520
- const opts = {
521
- name,
522
- async fn(t) {
523
- TestSuiteInternal.runningCount++;
524
- try {
525
- await fn.call({}, t);
526
- }
527
- finally {
528
- TestSuiteInternal.runningCount--;
529
- }
530
- try {
531
- if (assertionState.checkAssertionErrorState()) {
532
- throw new AssertionError("Expected at least one assertion to be called but received none");
533
- }
534
- if (assertionState.checkAssertionCountSatisfied()) {
535
- throw new AssertionError(`Expected exactly ${assertionState.assertionCount} ${assertionState.assertionCount === 1 ? "assertion" : "assertions"} to be called, ` +
536
- `but received ${assertionState.assertionTriggeredCount}`);
537
- }
538
- }
539
- finally {
540
- assertionState.resetAssertionState();
541
- }
542
- },
543
- };
544
- if (ignore !== undefined) {
545
- opts.ignore = ignore;
546
- }
547
- if (only !== undefined) {
548
- opts.only = only;
549
- }
550
- if (permissions !== undefined) {
551
- opts.permissions = permissions;
552
- }
553
- if (sanitizeExit !== undefined) {
554
- opts.sanitizeExit = sanitizeExit;
555
- }
556
- if (sanitizeOps !== undefined) {
557
- opts.sanitizeOps = sanitizeOps;
558
- }
559
- if (sanitizeResources !== undefined) {
560
- opts.sanitizeResources = sanitizeResources;
561
- }
562
- TestSuiteInternal.registerTest(opts);
563
- }
564
- }
565
- /**
566
- * Only execute this test case.
567
- *
568
- * @example Usage
569
- * ```ts ignore
570
- * import { describe, it } from "@std/testing/bdd";
571
- * import { assertEquals } from "@std/assert";
572
- *
573
- * describe("example", () => {
574
- * it("should pass", () => {
575
- * assertEquals(2 + 2, 4);
576
- * });
577
- *
578
- * it.only("should pass too", () => {
579
- * assertEquals(3 + 4, 7);
580
- * });
581
- * });
582
- * ```
583
- *
584
- * @param args The test case
585
- */
586
- it.only = function itOnly(...args) {
587
- const options = itDefinition(...args);
588
- return it({
589
- ...options,
590
- only: true,
591
- });
592
- };
593
- /**
594
- * Ignore this test case.
595
- *
596
- * @example Usage
597
- * ```ts ignore
598
- * import { describe, it } from "@std/testing/bdd";
599
- * import { assertEquals } from "@std/assert";
600
- *
601
- * describe("example", () => {
602
- * it("should pass", () => {
603
- * assertEquals(2 + 2, 4);
604
- * });
605
- *
606
- * it.ignore("should pass too", () => {
607
- * assertEquals(3 + 4, 7);
608
- * });
609
- * });
610
- * ```
611
- *
612
- * @param args The test case
613
- */
614
- it.ignore = function itIgnore(...args) {
615
- const options = itDefinition(...args);
616
- return it({
617
- ...options,
618
- ignore: true,
619
- });
620
- };
621
- /** Skip this test case.
622
- *
623
- * @example Usage
624
- * ```ts ignore
625
- * import { describe, it } from "@std/testing/bdd";
626
- * import { assertEquals } from "@std/assert";
627
- *
628
- * describe("example", () => {
629
- * it("should pass", () => {
630
- * assertEquals(2 + 2, 4);
631
- * });
632
- *
633
- * it.skip("should pass too", () => {
634
- * assertEquals(3 + 4, 7);
635
- * });
636
- * });
637
- * ```
638
- *
639
- * @param args The test case
640
- */
641
- it.skip = function itSkip(...args) {
642
- it.ignore(...args);
643
- };
644
- /**
645
- * Alias of {@linkcode it}
646
- *
647
- * Registers an individual test case.
648
- *
649
- * @example Usage
650
- * ```ts ignore
651
- * import { test } from "@std/testing/bdd";
652
- * import { assertEquals } from "@std/assert";
653
- *
654
- * test("a test case", () => {
655
- * // test case
656
- * assertEquals(2 + 2, 4);
657
- * });
658
- * ```
659
- *
660
- * @typeParam T The self type of the function to implement the test case
661
- * @param args The test case
662
- *
663
- * @deprecated This will be removed in 2.0.0. Use `node:test`'s `test()` or
664
- * `Deno.test()` instead.
665
- */
666
- export function test(...args) {
667
- it(...args);
668
- }
669
- /**
670
- * Only execute this test case.
671
- *
672
- * @example Usage
673
- * ```ts ignore
674
- * import { describe, test } from "@std/testing/bdd";
675
- * import { assertEquals } from "@std/assert";
676
- *
677
- * describe("example", () => {
678
- * test("should pass", () => {
679
- * assertEquals(2 + 2, 4);
680
- * });
681
- *
682
- * test.only("should pass too", () => {
683
- * assertEquals(3 + 4, 7);
684
- * });
685
- * });
686
- * ```
687
- *
688
- * @param args The test case
689
- */
690
- test.only = function itOnly(...args) {
691
- it.only(...args);
692
- };
693
- /**
694
- * Ignore this test case.
695
- *
696
- * @example Usage
697
- * ```ts ignore
698
- * import { describe, test } from "@std/testing/bdd";
699
- * import { assertEquals } from "@std/assert";
700
- *
701
- * describe("example", () => {
702
- * test("should pass", () => {
703
- * assertEquals(2 + 2, 4);
704
- * });
705
- *
706
- * test.ignore("should pass too", () => {
707
- * assertEquals(3 + 4, 7);
708
- * });
709
- * });
710
- * ```
711
- *
712
- * @param args The test case
713
- */
714
- test.ignore = function itIgnore(...args) {
715
- it.ignore(...args);
716
- };
717
- /** Skip this test case.
718
- *
719
- * @example Usage
720
- * ```ts ignore
721
- * import { describe, test } from "@std/testing/bdd";
722
- * import { assertEquals } from "@std/assert";
723
- *
724
- * describe("example", () => {
725
- * test("should pass", () => {
726
- * assertEquals(2 + 2, 4);
727
- * });
728
- *
729
- * test.skip("should pass too", () => {
730
- * assertEquals(3 + 4, 7);
731
- * });
732
- * });
733
- * ```
734
- *
735
- * @param args The test case
736
- */
737
- test.skip = function itSkip(...args) {
738
- it.ignore(...args);
739
- };
740
- function addHook(name, fn) {
741
- if (!TestSuiteInternal.current) {
742
- if (TestSuiteInternal.started) {
743
- throw new Error("Cannot add global hooks after a global test is registered");
744
- }
745
- TestSuiteInternal.current = new TestSuiteInternal({
746
- name: "global",
747
- [name]: fn,
748
- });
749
- }
750
- else {
751
- TestSuiteInternal.setHook(TestSuiteInternal.current, name, fn);
752
- }
753
- }
754
- /**
755
- * Run some shared setup before all of the tests in the group.
756
- * Useful for async setup in `describe` blocks. Outside them,
757
- * top-level initialization code should be used instead.
758
- *
759
- * @example Usage
760
- * ```ts ignore
761
- * import { describe, it, beforeAll } from "@std/testing/bdd";
762
- * import { assertEquals } from "@std/assert";
763
- *
764
- * beforeAll(() => {
765
- * console.log("beforeAll");
766
- * });
767
- *
768
- * describe("example", () => {
769
- * it("should pass", () => {
770
- * // test case
771
- * assertEquals(2 + 2, 4);
772
- * });
773
- * });
774
- * ```
775
- *
776
- * @typeParam T The self type of the function
777
- * @param fn The function to implement the setup behavior.
778
- *
779
- * @deprecated This will be removed in 2.0.0. Use `node:test`'s `before()` or
780
- * `Deno.test.beforeAll()` (Deno 2.5+) instead.
781
- */
782
- export function beforeAll(fn) {
783
- addHook("beforeAll", fn);
784
- }
785
- /**
786
- * Alias of {@linkcode beforeAll}
787
- *
788
- * Run some shared setup before all of the tests in the suite.
789
- *
790
- * @example Usage
791
- * ```ts ignore
792
- * import { describe, it, before } from "@std/testing/bdd";
793
- * import { assertEquals } from "@std/assert";
794
- *
795
- * before(() => {
796
- * console.log("before");
797
- * });
798
- *
799
- * describe("example", () => {
800
- * it("should pass", () => {
801
- * // test case
802
- * assertEquals(2 + 2, 4);
803
- * });
804
- * });
805
- * ```
806
- *
807
- * @typeParam T The self type of the function
808
- * @param fn The function to implement the setup behavior.
809
- *
810
- * @deprecated This will be removed in 2.0.0. Use `node:test`'s `before()` or
811
- * `Deno.test.beforeAll()` (Deno 2.5+) instead.
812
- */
813
- export function before(fn) {
814
- beforeAll(fn);
815
- }
816
- /**
817
- * Run some shared teardown after all of the tests in the suite.
818
- *
819
- * @example Usage
820
- * ```ts ignore
821
- * import { describe, it, afterAll } from "@std/testing/bdd";
822
- * import { assertEquals } from "@std/assert";
823
- *
824
- * afterAll(() => {
825
- * console.log("afterAll");
826
- * });
827
- *
828
- * describe("example", () => {
829
- * it("should pass", () => {
830
- * // test case
831
- * assertEquals(2 + 2, 4);
832
- * });
833
- * });
834
- * ```
835
- *
836
- * @typeParam T The self type of the function
837
- * @param fn The function to implement the teardown behavior.
838
- *
839
- * @deprecated This will be removed in 2.0.0. Use `node:test`'s `after()` or
840
- * `Deno.test.afterAll()` (Deno 2.5+) instead.
841
- */
842
- export function afterAll(fn) {
843
- addHook("afterAll", fn);
844
- }
845
- /**
846
- * Alias of {@linkcode afterAll}.
847
- *
848
- * Run some shared teardown after all of the tests in the suite.
849
- *
850
- * @example Usage
851
- * ```ts ignore
852
- * import { describe, it, after } from "@std/testing/bdd";
853
- * import { assertEquals } from "@std/assert";
854
- *
855
- * after(() => {
856
- * console.log("after");
857
- * });
858
- *
859
- * describe("example", () => {
860
- * it("should pass", () => {
861
- * // test case
862
- * assertEquals(2 + 2, 4);
863
- * });
864
- * });
865
- * ```
866
- *
867
- * @typeParam T The self type of the function
868
- * @param fn The function to implement the teardown behavior.
869
- *
870
- * @deprecated This will be removed in 2.0.0. Use `node:test`'s `after()` or
871
- * `Deno.test.afterAll()` (Deno 2.5+) instead.
872
- */
873
- export function after(fn) {
874
- afterAll(fn);
875
- }
876
- /**
877
- * Run some shared setup before each test in the suite.
878
- *
879
- * @example Usage
880
- * ```ts ignore
881
- * import { describe, it, beforeEach } from "@std/testing/bdd";
882
- * import { assertEquals } from "@std/assert";
883
- *
884
- * beforeEach(() => {
885
- * console.log("beforeEach");
886
- * });
887
- *
888
- * describe("example", () => {
889
- * it("should pass", () => {
890
- * // test case
891
- * assertEquals(2 + 2, 4);
892
- * });
893
- * });
894
- * ```
895
- *
896
- * @typeParam T The self type of the function
897
- * @param fn The function to implement the shared setup behavior
898
- *
899
- * @deprecated This will be removed in 2.0.0. Use `node:test`'s `beforeEach()`
900
- * or `Deno.test.beforeEach()` (Deno 2.5+) instead.
901
- */
902
- export function beforeEach(fn) {
903
- addHook("beforeEach", fn);
904
- }
905
- /**
906
- * Run some shared teardown after each test in the suite.
907
- *
908
- * @example Usage
909
- * ```ts ignore
910
- * import { describe, it, afterEach } from "@std/testing/bdd";
911
- * import { assertEquals } from "@std/assert";
912
- *
913
- * afterEach(() => {
914
- * console.log("afterEach");
915
- * });
916
- *
917
- * describe("example", () => {
918
- * it("should pass", () => {
919
- * // test case
920
- * assertEquals(2 + 2, 4);
921
- * });
922
- * });
923
- * ```
924
- *
925
- * @typeParam T The self type of the function
926
- * @param fn The function to implement the shared teardown behavior
927
- *
928
- * @deprecated This will be removed in 2.0.0. Use `node:test`'s `afterEach()`
929
- * or `Deno.test.afterEach()` (Deno 2.5+) instead.
930
- */
931
- export function afterEach(fn) {
932
- addHook("afterEach", fn);
933
- }
934
- /** Generates a DescribeDefinition from DescribeArgs. */
935
- function describeDefinition(...args) {
936
- let [suiteOptionsOrNameOrFn, optionsOrNameOrFn, optionsOrFn, fn,] = args;
937
- let suite = undefined;
938
- let name;
939
- let options;
940
- if (typeof suiteOptionsOrNameOrFn === "object" &&
941
- typeof suiteOptionsOrNameOrFn.symbol === "symbol") {
942
- suite = suiteOptionsOrNameOrFn;
943
- }
944
- else {
945
- fn = optionsOrFn;
946
- optionsOrFn = optionsOrNameOrFn;
947
- optionsOrNameOrFn = suiteOptionsOrNameOrFn;
948
- }
949
- if (typeof optionsOrNameOrFn === "string") {
950
- name = optionsOrNameOrFn;
951
- if (typeof optionsOrFn === "function") {
952
- fn = optionsOrFn;
953
- options = {};
954
- }
955
- else {
956
- options = optionsOrFn ?? {};
957
- if (fn === undefined) {
958
- fn = options.fn;
959
- }
960
- }
961
- }
962
- else if (typeof optionsOrNameOrFn === "function") {
963
- fn = optionsOrNameOrFn;
964
- name = fn.name;
965
- options = {};
966
- }
967
- else {
968
- options = optionsOrNameOrFn ?? {};
969
- if (typeof optionsOrFn === "function") {
970
- fn = optionsOrFn;
971
- }
972
- else {
973
- fn = options.fn;
974
- }
975
- name = options.name ?? fn?.name ?? "";
976
- }
977
- if (suite === undefined) {
978
- suite = options.suite;
979
- }
980
- if (suite === undefined && TestSuiteInternal.current) {
981
- const { symbol } = TestSuiteInternal.current;
982
- suite = { symbol };
983
- }
984
- return {
985
- ...options,
986
- suite: suite,
987
- name,
988
- fn: fn,
989
- };
990
- }
991
- /**
992
- * Registers a test suite.
993
- *
994
- * @example Usage
995
- * ```ts ignore
996
- * import { describe, it } from "@std/testing/bdd";
997
- * import { assertEquals } from "@std/assert";
998
- *
999
- * describe("example", () => {
1000
- * it("should pass", () => {
1001
- * // test case
1002
- * assertEquals(2 + 2, 4);
1003
- * });
1004
- * });
1005
- * ```
1006
- *
1007
- * @typeParam T The self type of the test suite body.
1008
- * @param args The test suite body.
1009
- * @returns The test suite
1010
- *
1011
- * @deprecated This will be removed in 2.0.0. Use `node:test`'s `describe()`
1012
- * instead.
1013
- */
1014
- export function describe(...args) {
1015
- if (TestSuiteInternal.runningCount > 0) {
1016
- throw new Error("Cannot register new test suites after already registered test cases start running");
1017
- }
1018
- const options = describeDefinition(...args);
1019
- if (!TestSuiteInternal.started)
1020
- TestSuiteInternal.started = true;
1021
- const { symbol } = new TestSuiteInternal(options);
1022
- return { symbol };
1023
- }
1024
- /**
1025
- * Only execute this test suite.
1026
- *
1027
- * @example Usage
1028
- * ```ts ignore
1029
- * import { describe, it, beforeAll } from "@std/testing/bdd";
1030
- * import { assertEquals } from "@std/assert";
1031
- *
1032
- * describe("example", () => {
1033
- * it("should pass", () => {
1034
- * assertEquals(2 + 2, 4);
1035
- * });
1036
- * });
1037
- *
1038
- * // Only this test suite will run
1039
- * describe.only("example 2", () => {
1040
- * it("should pass too", () => {
1041
- * assertEquals(3 + 4, 7);
1042
- * });
1043
- * });
1044
- * ```
1045
- *
1046
- * @param args The test suite body
1047
- */
1048
- describe.only = function describeOnly(...args) {
1049
- const options = describeDefinition(...args);
1050
- return describe({
1051
- ...options,
1052
- only: true,
1053
- });
1054
- };
1055
- /**
1056
- * Ignore the test suite.
1057
- *
1058
- * @example Usage
1059
- * ```ts ignore
1060
- * import { describe, it, beforeAll } from "@std/testing/bdd";
1061
- * import { assertEquals } from "@std/assert";
1062
- *
1063
- * describe("example", () => {
1064
- * it("should pass", () => {
1065
- * assertEquals(2 + 2, 4);
1066
- * });
1067
- * });
1068
- *
1069
- * describe.ignore("example 2", () => {
1070
- * it("should pass too", () => {
1071
- * assertEquals(3 + 4, 7);
1072
- * });
1073
- * });
1074
- * ```
1075
- *
1076
- * @param args The test suite body
1077
- */
1078
- describe.ignore = function describeIgnore(...args) {
1079
- const options = describeDefinition(...args);
1080
- return describe({
1081
- ...options,
1082
- ignore: true,
1083
- });
1084
- };
1085
- /**
1086
- * Skip the test suite.
1087
- *
1088
- * @example Usage
1089
- * ```ts ignore
1090
- * import { describe, it, beforeAll } from "@std/testing/bdd";
1091
- * import { assertEquals } from "@std/assert";
1092
- *
1093
- * describe("example", () => {
1094
- * it("should pass", () => {
1095
- * assertEquals(2 + 2, 4);
1096
- * });
1097
- * });
1098
- *
1099
- * describe.skip("example 2", () => {
1100
- * it("should pass too", () => {
1101
- * assertEquals(3 + 4, 7);
1102
- * });
1103
- * });
1104
- * ```
1105
- *
1106
- * @param args The test suite body
1107
- */
1108
- describe.skip = function describeSkip(...args) {
1109
- return describe.ignore(...args);
1110
- };