hono 4.3.9 → 4.3.11

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.
@@ -31,7 +31,11 @@ class HTTPException extends Error {
31
31
  }
32
32
  getResponse() {
33
33
  if (this.res) {
34
- return this.res;
34
+ const newResponse = new Response(this.res.body, {
35
+ status: this.status,
36
+ headers: this.res.headers
37
+ });
38
+ return newResponse;
35
39
  }
36
40
  return new Response(this.message, {
37
41
  status: this.status
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var etag_exports = {};
20
20
  __export(etag_exports, {
21
+ RETAINED_304_HEADERS: () => RETAINED_304_HEADERS,
21
22
  etag: () => etag
22
23
  });
23
24
  module.exports = __toCommonJS(etag_exports);
@@ -66,5 +67,6 @@ const etag = (options) => {
66
67
  };
67
68
  // Annotate the CommonJS export names for ESM import in node:
68
69
  0 && (module.exports = {
70
+ RETAINED_304_HEADERS,
69
71
  etag
70
72
  });
@@ -29,7 +29,7 @@ var import_http_exception = require("../../http-exception");
29
29
  var import_jwt = require("../../utils/jwt");
30
30
  var import_context = require("../../context");
31
31
  const jwt = (options) => {
32
- if (!options) {
32
+ if (!options || !options.secret) {
33
33
  throw new Error('JWT auth middleware requires options for "secret');
34
34
  }
35
35
  if (!crypto.subtle || !crypto.subtle.importKey) {
@@ -22,6 +22,7 @@ __export(secure_headers_exports, {
22
22
  secureHeaders: () => secureHeaders
23
23
  });
24
24
  module.exports = __toCommonJS(secure_headers_exports);
25
+ var import_encode = require("../../utils/encode");
25
26
  const HEADERS_MAP = {
26
27
  crossOriginEmbedderPolicy: ["Cross-Origin-Embedder-Policy", "require-corp"],
27
28
  crossOriginResourcePolicy: ["Cross-Origin-Resource-Policy", "same-origin"],
@@ -53,7 +54,7 @@ const DEFAULT_OPTIONS = {
53
54
  const generateNonce = () => {
54
55
  const buffer = new Uint8Array(16);
55
56
  crypto.getRandomValues(buffer);
56
- return Buffer.from(buffer).toString("base64");
57
+ return (0, import_encode.encodeBase64)(buffer);
57
58
  };
58
59
  const NONCE = (ctx) => {
59
60
  const nonce = ctx.get("secureHeadersNonce") || (() => {
@@ -9,7 +9,11 @@ var HTTPException = class extends Error {
9
9
  }
10
10
  getResponse() {
11
11
  if (this.res) {
12
- return this.res;
12
+ const newResponse = new Response(this.res.body, {
13
+ status: this.status,
14
+ headers: this.res.headers
15
+ });
16
+ return newResponse;
13
17
  }
14
18
  return new Response(this.message, {
15
19
  status: this.status
@@ -43,5 +43,6 @@ var etag = (options) => {
43
43
  };
44
44
  };
45
45
  export {
46
+ RETAINED_304_HEADERS,
46
47
  etag
47
48
  };
@@ -4,7 +4,7 @@ import { HTTPException } from "../../http-exception.js";
4
4
  import { Jwt } from "../../utils/jwt/index.js";
5
5
  import "../../context.js";
6
6
  var jwt = (options) => {
7
- if (!options) {
7
+ if (!options || !options.secret) {
8
8
  throw new Error('JWT auth middleware requires options for "secret');
9
9
  }
10
10
  if (!crypto.subtle || !crypto.subtle.importKey) {
@@ -1,4 +1,5 @@
1
1
  // src/middleware/secure-headers/index.ts
2
+ import { encodeBase64 } from "../../utils/encode.js";
2
3
  var HEADERS_MAP = {
3
4
  crossOriginEmbedderPolicy: ["Cross-Origin-Embedder-Policy", "require-corp"],
4
5
  crossOriginResourcePolicy: ["Cross-Origin-Resource-Policy", "same-origin"],
@@ -30,7 +31,7 @@ var DEFAULT_OPTIONS = {
30
31
  var generateNonce = () => {
31
32
  const buffer = new Uint8Array(16);
32
33
  crypto.getRandomValues(buffer);
33
- return Buffer.from(buffer).toString("base64");
34
+ return encodeBase64(buffer);
34
35
  };
35
36
  var NONCE = (ctx) => {
36
37
  const nonce = ctx.get("secureHeadersNonce") || (() => {
@@ -3,5 +3,12 @@ type ETagOptions = {
3
3
  retainedHeaders?: string[];
4
4
  weak?: boolean;
5
5
  };
6
+ /**
7
+ * Default headers to pass through on 304 responses. From the spec:
8
+ * > The response must not contain a body and must include the headers that
9
+ * > would have been sent in an equivalent 200 OK response: Cache-Control,
10
+ * > Content-Location, Date, ETag, Expires, and Vary.
11
+ */
12
+ export declare const RETAINED_304_HEADERS: string[];
6
13
  export declare const etag: (options?: ETagOptions) => MiddlewareHandler;
7
14
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.3.9",
3
+ "version": "4.3.11",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",