hono-ban 0.3.1 → 1.1.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 (109) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/{LICENSE.md → LICENSE} +1 -1
  3. package/README.md +319 -469
  4. package/dist/ban-error-CPoKZS7g.js +102 -0
  5. package/dist/ban-error-CPoKZS7g.js.map +1 -0
  6. package/dist/definition-CDmfpcHf.js +263 -0
  7. package/dist/definition-CDmfpcHf.js.map +1 -0
  8. package/dist/formats/google-api.d.ts +117 -0
  9. package/dist/formats/google-api.d.ts.map +1 -0
  10. package/dist/formats/google-api.js +388 -0
  11. package/dist/formats/google-api.js.map +1 -0
  12. package/dist/formats/json-api.d.ts +53 -0
  13. package/dist/formats/json-api.d.ts.map +1 -0
  14. package/dist/formats/json-api.js +177 -0
  15. package/dist/formats/json-api.js.map +1 -0
  16. package/dist/formats/plain.d.ts +20 -0
  17. package/dist/formats/plain.d.ts.map +1 -0
  18. package/dist/formats/plain.js +76 -0
  19. package/dist/formats/plain.js.map +1 -0
  20. package/dist/formats/problem-details.d.ts +39 -0
  21. package/dist/formats/problem-details.d.ts.map +1 -0
  22. package/dist/formats/problem-details.js +2 -0
  23. package/dist/formats/stripe.d.ts +52 -0
  24. package/dist/formats/stripe.d.ts.map +1 -0
  25. package/dist/formats/stripe.js +117 -0
  26. package/dist/formats/stripe.js.map +1 -0
  27. package/dist/hook-DM38dR1V.js +23 -0
  28. package/dist/hook-DM38dR1V.js.map +1 -0
  29. package/dist/hook-TWCLnCmZ.d.ts +15 -0
  30. package/dist/hook-TWCLnCmZ.d.ts.map +1 -0
  31. package/dist/index.d.ts +129 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +661 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/issue-B-7iyCBE.js +41 -0
  36. package/dist/issue-B-7iyCBE.js.map +1 -0
  37. package/dist/json-Bjfm-jxl.js +17 -0
  38. package/dist/json-Bjfm-jxl.js.map +1 -0
  39. package/dist/member-name-k4VABr91.js +20 -0
  40. package/dist/member-name-k4VABr91.js.map +1 -0
  41. package/dist/openapi.d.ts +40 -0
  42. package/dist/openapi.d.ts.map +1 -0
  43. package/dist/openapi.js +75 -0
  44. package/dist/openapi.js.map +1 -0
  45. package/dist/otel.d.ts +29 -0
  46. package/dist/otel.d.ts.map +1 -0
  47. package/dist/otel.js +23 -0
  48. package/dist/otel.js.map +1 -0
  49. package/dist/problem-details-DeUg_NjG.js +164 -0
  50. package/dist/problem-details-DeUg_NjG.js.map +1 -0
  51. package/dist/schema-helpers-bwCFve8i.js +72 -0
  52. package/dist/schema-helpers-bwCFve8i.js.map +1 -0
  53. package/dist/standard-schema-types-Aa3pYPY1.d.ts +43 -0
  54. package/dist/standard-schema-types-Aa3pYPY1.d.ts.map +1 -0
  55. package/dist/standard-schema.d.ts +15 -0
  56. package/dist/standard-schema.d.ts.map +1 -0
  57. package/dist/standard-schema.js +23 -0
  58. package/dist/standard-schema.js.map +1 -0
  59. package/dist/testing.d.ts +21 -0
  60. package/dist/testing.d.ts.map +1 -0
  61. package/dist/testing.js +141 -0
  62. package/dist/testing.js.map +1 -0
  63. package/dist/types-DYr4CtCC.d.ts +337 -0
  64. package/dist/types-DYr4CtCC.d.ts.map +1 -0
  65. package/dist/types-WuQ-karh.d.ts +179 -0
  66. package/dist/types-WuQ-karh.d.ts.map +1 -0
  67. package/dist/valibot.d.ts +26 -0
  68. package/dist/valibot.d.ts.map +1 -0
  69. package/dist/valibot.js +31 -0
  70. package/dist/valibot.js.map +1 -0
  71. package/dist/validation-entries-9R5RK-AZ.js +53 -0
  72. package/dist/validation-entries-9R5RK-AZ.js.map +1 -0
  73. package/dist/validation-entries-nUGoBPKm.d.ts +17 -0
  74. package/dist/validation-entries-nUGoBPKm.d.ts.map +1 -0
  75. package/dist/zod.d.ts +27 -0
  76. package/dist/zod.d.ts.map +1 -0
  77. package/dist/zod.js +30 -0
  78. package/dist/zod.js.map +1 -0
  79. package/package.json +98 -66
  80. package/dist/esm/formatters/index.js +0 -1
  81. package/dist/esm/index.js +0 -1
  82. package/dist/types/constants/index.d.ts +0 -5
  83. package/dist/types/constants/status-codes.d.ts +0 -9
  84. package/dist/types/core/convert-error.d.ts +0 -17
  85. package/dist/types/core/create-error.d.ts +0 -23
  86. package/dist/types/core/format-error.d.ts +0 -18
  87. package/dist/types/core/index.d.ts +0 -7
  88. package/dist/types/factories/client-errors.d.ts +0 -179
  89. package/dist/types/factories/index.d.ts +0 -6
  90. package/dist/types/factories/server-errors.d.ts +0 -77
  91. package/dist/types/formatters/default/index.d.ts +0 -19
  92. package/dist/types/formatters/index.d.ts +0 -7
  93. package/dist/types/formatters/interfaces.d.ts +0 -5
  94. package/dist/types/formatters/rfc7807/formatter.d.ts +0 -40
  95. package/dist/types/formatters/rfc7807/hooks.d.ts +0 -40
  96. package/dist/types/formatters/rfc7807/index.d.ts +0 -7
  97. package/dist/types/formatters/rfc7807/schemas.d.ts +0 -162
  98. package/dist/types/index.d.ts +0 -11
  99. package/dist/types/middleware/ban-middleware.d.ts +0 -23
  100. package/dist/types/middleware/index.d.ts +0 -5
  101. package/dist/types/types/common.d.ts +0 -12
  102. package/dist/types/types/error.d.ts +0 -39
  103. package/dist/types/types/formatter.d.ts +0 -43
  104. package/dist/types/types/index.d.ts +0 -9
  105. package/dist/types/types/options.d.ts +0 -54
  106. package/dist/types/types/rfc7807.d.ts +0 -77
  107. package/dist/types/utils/index.d.ts +0 -6
  108. package/dist/types/utils/sanitize.d.ts +0 -10
  109. package/dist/types/utils/validate.d.ts +0 -10
package/CHANGELOG.md ADDED
@@ -0,0 +1,61 @@
1
+ # hono-ban
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`95a62e1`](https://github.com/ali-issa/hono-ban/commit/95a62e17f663f5f30522eda7fb76d4ef63b3487c) Thanks [@ali-issa](https://github.com/ali-issa)! - Validate options at construction instead of producing broken responses.
8
+
9
+ - `problemDetails()` throws `TypeError` when `traceIdMember` names a reserved member (`status`,
10
+ `id`, `errors`, ...) or is not an RFC 9457 extension member name; `jsonApi()` rejects a
11
+ `traceIdMetaKey` the format writes itself (`stack`, `location`, `code`, ...) or that is not a
12
+ JSON:API member name; `googleApi()` rejects a `traceIdMetadataKey` outside the
13
+ `ErrorInfo.metadata` key grammar. Previously `traceIdMember: 'status'` replaced the numeric status
14
+ with the trace id.
15
+ - `ban.onError()` throws `TypeError` when `errorIdHeader`, `requestIdHeader`, or `headers` holds a
16
+ name or value `Headers` rejects. Previously the failure surfaced inside the handler's last-resort
17
+ fallback and the handler rejected.
18
+ - `googleApi()` drops `meta` keys that do not match `[a-z][a-zA-Z0-9-_]+` or exceed 64 characters,
19
+ as `error_details.proto` requires for `ErrorInfo.metadata`, and the 2020-12 schema states the rule
20
+ with `propertyNames`. Keys such as `order.id` or `UserId` were previously sent as-is.
21
+
22
+ ### Patch Changes
23
+
24
+ - [`95a62e1`](https://github.com/ali-issa/hono-ban/commit/95a62e17f663f5f30522eda7fb76d4ef63b3487c) Thanks [@ali-issa](https://github.com/ali-issa)! - Keep every rendered validation body inside its own schema and the handler inside its guarantee.
25
+
26
+ - `jsonApi()` renders one summary error object for `ban.validation([])` instead of an empty `errors`
27
+ array its schema rejects; `googleApi()` omits `BadRequest` when there are no issues instead of
28
+ sending an empty `fieldViolations`.
29
+ - `assertFormatConformance` from `hono-ban/testing` now also renders a validation error with no
30
+ issues per location.
31
+ - `ban.onError()` gains a third fallback tier: when the header merge itself throws, the response
32
+ still carries `Content-Type`, `Cache-Control: no-store`, and the error id header.
33
+
34
+ ## 1.0.0
35
+
36
+ ### Major Changes
37
+
38
+ - [`efcb0b6`](https://github.com/ali-issa/hono-ban/commit/efcb0b6bd24a598bf0e8868bff9942ec248a7868) Thanks [@ali-issa](https://github.com/ali-issa)! - First 1.0 release. `createBan()` builds a typed error catalog with a factory per IANA status and per
39
+ custom entry, `ban.onError()` renders every thrown value once through a pluggable format (RFC 9457
40
+ Problem Details by default; JSON:API, Google API (AIP-193), Stripe, and plain built in;
41
+ `defineFormat()` for your own), validator hooks for Zod, Valibot, and Standard Schema throw into the
42
+ handler, `hono-ban/openapi` derives response schemas from the active format, and `hono-ban/otel`
43
+ adds trace ids. Error responses carry `Cache-Control: no-store` unless you set one, and
44
+ `bearerChallenge()` builds RFC 6750 and RFC 9728 `WWW-Authenticate` values. `hono` is the only peer
45
+ dependency.
46
+
47
+ ## 1.0.0-alpha.1
48
+
49
+ ### Major Changes
50
+
51
+ - First 1.0 release. `createBan()` builds a typed error catalog with a factory per IANA status and per
52
+ custom entry, `ban.onError()` renders every thrown value once through a pluggable format (RFC 9457
53
+ Problem Details by default; JSON:API, Google API (AIP-193), Stripe, and plain built in;
54
+ `defineFormat()` for your own), validator hooks for Zod, Valibot, and Standard Schema throw into the
55
+ handler, `hono-ban/openapi` derives response schemas from the active format, and `hono-ban/otel`
56
+ adds trace ids. Error responses carry `Cache-Control: no-store` unless you set one, and
57
+ `bearerChallenge()` builds RFC 6750 and RFC 9728 `WWW-Authenticate` values. `hono` is the only peer
58
+ dependency.
59
+
60
+ Release notes are generated by [Changesets](https://github.com/changesets/changesets) from the
61
+ entries in `.changeset/` when a version PR is merged.
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Ali Issa
3
+ Copyright (c) 2025-2026 Ali Issa
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal