hono 4.12.17 → 4.12.19

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.
@@ -48,14 +48,14 @@ var parse = (cookie, name) => {
48
48
  return {};
49
49
  }
50
50
  const pairs = cookie.split(";");
51
- const parsedCookie = {};
51
+ const parsedCookie = /* @__PURE__ */ Object.create(null);
52
52
  for (const pairStr of pairs) {
53
53
  const valueStartPos = pairStr.indexOf("=");
54
54
  if (valueStartPos === -1) {
55
55
  continue;
56
56
  }
57
57
  const cookieName = trimCookieWhitespace(pairStr.substring(0, valueStartPos));
58
- if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName)) {
58
+ if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) {
59
59
  continue;
60
60
  }
61
61
  let cookieValue = trimCookieWhitespace(pairStr.substring(valueStartPos + 1));
@@ -72,7 +72,7 @@ var parse = (cookie, name) => {
72
72
  return parsedCookie;
73
73
  };
74
74
  var parseSigned = async (cookie, secret, name) => {
75
- const parsedCookie = {};
75
+ const parsedCookie = /* @__PURE__ */ Object.create(null);
76
76
  const secretKey = await getCryptoKey(secret);
77
77
  for (const [key, value] of Object.entries(parse(cookie, name))) {
78
78
  const signatureStartPos = value.lastIndexOf(".");
@@ -70,14 +70,20 @@ var verify = async (token, publicKey, algOrOptions) => {
70
70
  throw new JwtAlgorithmMismatch(alg, header.alg);
71
71
  }
72
72
  const now = Math.floor(Date.now() / 1e3);
73
- if (nbf && payload.nbf && payload.nbf > now) {
74
- throw new JwtTokenNotBefore(token);
73
+ if (nbf && payload.nbf !== void 0) {
74
+ if (typeof payload.nbf !== "number" || !Number.isFinite(payload.nbf) || payload.nbf > now) {
75
+ throw new JwtTokenNotBefore(token);
76
+ }
75
77
  }
76
- if (exp && payload.exp && payload.exp <= now) {
77
- throw new JwtTokenExpired(token);
78
+ if (exp && payload.exp !== void 0) {
79
+ if (typeof payload.exp !== "number" || !Number.isFinite(payload.exp) || payload.exp <= now) {
80
+ throw new JwtTokenExpired(token);
81
+ }
78
82
  }
79
- if (iat && payload.iat && now < payload.iat) {
80
- throw new JwtTokenIssuedAt(now, payload.iat);
83
+ if (iat && payload.iat !== void 0) {
84
+ if (typeof payload.iat !== "number" || !Number.isFinite(payload.iat) || now < payload.iat) {
85
+ throw new JwtTokenIssuedAt(now, payload.iat);
86
+ }
81
87
  }
82
88
  if (iss) {
83
89
  if (!payload.iss) {
@@ -27,7 +27,9 @@ var StreamingApi = class {
27
27
  done ? controller.close() : controller.enqueue(value);
28
28
  },
29
29
  cancel: () => {
30
- this.abort();
30
+ if (!this.closed) {
31
+ this.abort();
32
+ }
31
33
  }
32
34
  });
33
35
  }
@@ -49,11 +51,11 @@ var StreamingApi = class {
49
51
  return new Promise((res) => setTimeout(res, ms));
50
52
  }
51
53
  async close() {
54
+ this.closed = true;
52
55
  try {
53
56
  await this.writer.close();
54
57
  } catch {
55
58
  }
56
- this.closed = true;
57
59
  }
58
60
  async pipe(body) {
59
61
  this.writer.releaseLock();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.12.17",
3
+ "version": "4.12.19",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",
@@ -657,7 +657,7 @@
657
657
  ],
658
658
  "devDependencies": {
659
659
  "@hono/eslint-config": "^2.1.0",
660
- "@hono/node-server": "^1.13.5",
660
+ "@hono/node-server": "^2.0.2",
661
661
  "@types/glob": "^9.0.0",
662
662
  "@types/jsdom": "^21.1.7",
663
663
  "@types/node": "^24.3.0",