hono-problem-details 0.3.0 → 0.5.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.
package/README.md CHANGED
@@ -380,7 +380,7 @@ problemDetailsHandler({
380
380
  // Default type URI (default: "about:blank")
381
381
  defaultType: "about:blank",
382
382
 
383
- // Include stack trace in detail (for development)
383
+ // Include stack trace in `extensions.stack` on 500 responses (development only)
384
384
  includeStack: process.env.NODE_ENV === "development",
385
385
 
386
386
  // Populate `instance` from `c.req.path` when the thrown problem didn't specify one
package/dist/index.cjs CHANGED
@@ -211,7 +211,8 @@ function problemDetailsHandler(options = {}) {
211
211
  status: 500,
212
212
  type: buildType(500, options),
213
213
  title: "Internal Server Error",
214
- detail: options.includeStack ? error.stack : void 0
214
+ detail: "An unexpected error occurred",
215
+ extensions: options.includeStack ? { stack: error.stack } : void 0
215
216
  },
216
217
  c,
217
218
  options
package/dist/index.d.cts CHANGED
@@ -38,7 +38,12 @@ interface ProblemDetailsHandlerOptions {
38
38
  typePrefix?: string;
39
39
  /** Default type URI. Defaults to "about:blank" */
40
40
  defaultType?: string;
41
- /** Include stack trace in detail (for development) */
41
+ /**
42
+ * Include the stack trace on unhandled `Error` responses (500). The stack is
43
+ * emitted as a top-level `stack` extension member per RFC 9457 §3.1 flattening,
44
+ * not in `detail`, to prevent leakage into UIs that render `detail` verbatim.
45
+ * Development-only.
46
+ */
42
47
  includeStack?: boolean;
43
48
  /**
44
49
  * When `true`, populate `instance` from the request path (`c.req.path`) if
package/dist/index.d.ts CHANGED
@@ -38,7 +38,12 @@ interface ProblemDetailsHandlerOptions {
38
38
  typePrefix?: string;
39
39
  /** Default type URI. Defaults to "about:blank" */
40
40
  defaultType?: string;
41
- /** Include stack trace in detail (for development) */
41
+ /**
42
+ * Include the stack trace on unhandled `Error` responses (500). The stack is
43
+ * emitted as a top-level `stack` extension member per RFC 9457 §3.1 flattening,
44
+ * not in `detail`, to prevent leakage into UIs that render `detail` verbatim.
45
+ * Development-only.
46
+ */
42
47
  includeStack?: boolean;
43
48
  /**
44
49
  * When `true`, populate `instance` from the request path (`c.req.path`) if
package/dist/index.js CHANGED
@@ -84,7 +84,8 @@ function problemDetailsHandler(options = {}) {
84
84
  status: 500,
85
85
  type: buildType(500, options),
86
86
  title: "Internal Server Error",
87
- detail: options.includeStack ? error.stack : void 0
87
+ detail: "An unexpected error occurred",
88
+ extensions: options.includeStack ? { stack: error.stack } : void 0
88
89
  },
89
90
  c,
90
91
  options
@@ -89,7 +89,7 @@ var ProblemDetailsSchema = import_zod_openapi.z.object({
89
89
  instance: import_zod_openapi.z.string().optional().openapi({ description: "URI identifying the occurrence" })
90
90
  }).openapi({ title: "ProblemDetails" });
91
91
  function createProblemDetailsSchema(extensions) {
92
- return ProblemDetailsSchema.merge(extensions).openapi({ title: "ProblemDetails" });
92
+ return ProblemDetailsSchema.extend(extensions.shape).openapi({ title: "ProblemDetails" });
93
93
  }
94
94
  function problemDetailsResponse(status, description, schema = ProblemDetailsSchema) {
95
95
  return {
@@ -15,15 +15,15 @@ declare const ProblemDetailsSchema: z.ZodObject<{
15
15
  * Create a Problem Details schema with typed extension members.
16
16
  * Extensions are merged at top level per RFC 9457.
17
17
  */
18
- declare function createProblemDetailsSchema<T extends z.ZodRawShape>(extensions: z.ZodObject<T>): z.AnyZodObject;
18
+ declare function createProblemDetailsSchema<T extends z.ZodRawShape>(extensions: z.ZodObject<T>): z.ZodObject;
19
19
  /**
20
20
  * Create an OpenAPI response object for Problem Details.
21
21
  * Use in createRoute() responses: { 422: problemDetailsResponse(422) }
22
22
  */
23
- declare function problemDetailsResponse(status: number, description?: string, schema?: z.ZodTypeAny): {
23
+ declare function problemDetailsResponse(status: number, description?: string, schema?: z.ZodType): {
24
24
  content: {
25
25
  "application/problem+json": {
26
- schema: z.ZodTypeAny;
26
+ schema: z.ZodType;
27
27
  };
28
28
  };
29
29
  description: string;
@@ -15,15 +15,15 @@ declare const ProblemDetailsSchema: z.ZodObject<{
15
15
  * Create a Problem Details schema with typed extension members.
16
16
  * Extensions are merged at top level per RFC 9457.
17
17
  */
18
- declare function createProblemDetailsSchema<T extends z.ZodRawShape>(extensions: z.ZodObject<T>): z.AnyZodObject;
18
+ declare function createProblemDetailsSchema<T extends z.ZodRawShape>(extensions: z.ZodObject<T>): z.ZodObject;
19
19
  /**
20
20
  * Create an OpenAPI response object for Problem Details.
21
21
  * Use in createRoute() responses: { 422: problemDetailsResponse(422) }
22
22
  */
23
- declare function problemDetailsResponse(status: number, description?: string, schema?: z.ZodTypeAny): {
23
+ declare function problemDetailsResponse(status: number, description?: string, schema?: z.ZodType): {
24
24
  content: {
25
25
  "application/problem+json": {
26
- schema: z.ZodTypeAny;
26
+ schema: z.ZodType;
27
27
  };
28
28
  };
29
29
  description: string;
@@ -12,7 +12,7 @@ var ProblemDetailsSchema = z.object({
12
12
  instance: z.string().optional().openapi({ description: "URI identifying the occurrence" })
13
13
  }).openapi({ title: "ProblemDetails" });
14
14
  function createProblemDetailsSchema(extensions) {
15
- return ProblemDetailsSchema.merge(extensions).openapi({ title: "ProblemDetails" });
15
+ return ProblemDetailsSchema.extend(extensions.shape).openapi({ title: "ProblemDetails" });
16
16
  }
17
17
  function problemDetailsResponse(status, description, schema = ProblemDetailsSchema) {
18
18
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-problem-details",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "RFC 9457 Problem Details middleware for Hono",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -102,12 +102,12 @@
102
102
  "peerDependencies": {
103
103
  "@hono/standard-validator": "^0.2.0",
104
104
  "@hono/valibot-validator": "^0.6.0",
105
- "@hono/zod-openapi": "^0.19.0",
105
+ "@hono/zod-openapi": "^1.0.0",
106
106
  "@hono/zod-validator": "^0.7.5",
107
107
  "@standard-schema/spec": "^1.0.0",
108
108
  "hono": ">=4.12.14",
109
109
  "valibot": "^1.0.0",
110
- "zod": "^3.25.0"
110
+ "zod": "^3.25.0 || ^4.0.0"
111
111
  },
112
112
  "peerDependenciesMeta": {
113
113
  "@hono/zod-validator": {
@@ -138,7 +138,7 @@
138
138
  "@changesets/cli": "2.30.0",
139
139
  "@hono/standard-validator": "0.2.2",
140
140
  "@hono/valibot-validator": "^0.6.1",
141
- "@hono/zod-openapi": "0.19.10",
141
+ "@hono/zod-openapi": "1.3.0",
142
142
  "@hono/zod-validator": "^0.7.6",
143
143
  "@standard-schema/spec": "1.1.0",
144
144
  "@vitest/coverage-v8": "^3.0.0",
@@ -146,9 +146,9 @@
146
146
  "lefthook": "2.1.5",
147
147
  "tsup": "^8.0.0",
148
148
  "typescript": "^5.7.0",
149
- "valibot": "^1.0.0",
149
+ "valibot": "^1.3.1",
150
150
  "vitest": "^3.0.0",
151
- "zod": "^3.25.0"
151
+ "zod": "^4.0.0"
152
152
  },
153
153
  "engines": {
154
154
  "node": ">=20"