hono 4.7.2 → 4.7.4
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/dist/cjs/hono-base.js +3 -4
- package/dist/cjs/middleware/secure-headers/secure-headers.js +3 -3
- package/dist/cjs/router/pattern-router/router.js +5 -3
- package/dist/cjs/utils/jwt/jwt.js +1 -1
- package/dist/cjs/utils/url.js +1 -1
- package/dist/hono-base.js +3 -4
- package/dist/middleware/secure-headers/secure-headers.js +3 -3
- package/dist/router/pattern-router/router.js +5 -3
- package/dist/types/adapter/bun/websocket.d.ts +2 -2
- package/dist/types/helper/adapter/index.d.ts +1 -1
- package/dist/types/helper/websocket/index.d.ts +1 -1
- package/dist/utils/jwt/jwt.js +1 -1
- package/dist/utils/url.js +1 -1
- package/package.json +1 -1
package/dist/cjs/hono-base.js
CHANGED
|
@@ -89,10 +89,9 @@ class Hono {
|
|
|
89
89
|
});
|
|
90
90
|
return this;
|
|
91
91
|
};
|
|
92
|
-
const strict = options
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this.getPath = strict ? options.getPath ?? import_url.getPath : import_url.getPathNoStrict;
|
|
92
|
+
const { strict, ...optionsWithoutStrict } = options;
|
|
93
|
+
Object.assign(this, optionsWithoutStrict);
|
|
94
|
+
this.getPath = strict ?? true ? options.getPath ?? import_url.getPath : import_url.getPathNoStrict;
|
|
96
95
|
}
|
|
97
96
|
#clone() {
|
|
98
97
|
const clone = new Hono({
|
|
@@ -54,9 +54,9 @@ const DEFAULT_OPTIONS = {
|
|
|
54
54
|
permissionsPolicy: {}
|
|
55
55
|
};
|
|
56
56
|
const generateNonce = () => {
|
|
57
|
-
const
|
|
58
|
-
crypto.getRandomValues(
|
|
59
|
-
return (0, import_encode.encodeBase64)(buffer);
|
|
57
|
+
const arrayBuffer = new Uint8Array(16);
|
|
58
|
+
crypto.getRandomValues(arrayBuffer);
|
|
59
|
+
return (0, import_encode.encodeBase64)(arrayBuffer.buffer);
|
|
60
60
|
};
|
|
61
61
|
const NONCE = (ctx) => {
|
|
62
62
|
const key = "secureHeadersNonce";
|
|
@@ -41,13 +41,15 @@ class PatternRouter {
|
|
|
41
41
|
return match ? `/(?<${match[1]}>${match[2] || "[^/]+"})` : part === "/*" ? "/[^/]+" : part.replace(/[.\\+*[^\]$()]/g, "\\$&");
|
|
42
42
|
}
|
|
43
43
|
);
|
|
44
|
-
let re;
|
|
45
44
|
try {
|
|
46
|
-
|
|
45
|
+
this.#routes.push([
|
|
46
|
+
new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`),
|
|
47
|
+
method,
|
|
48
|
+
handler
|
|
49
|
+
]);
|
|
47
50
|
} catch {
|
|
48
51
|
throw new import_router.UnsupportedPathError();
|
|
49
52
|
}
|
|
50
|
-
this.#routes.push([re, method, handler]);
|
|
51
53
|
}
|
|
52
54
|
match(method, path) {
|
|
53
55
|
const handlers = [];
|
|
@@ -31,7 +31,7 @@ var import_jwa = require("./jwa");
|
|
|
31
31
|
var import_jws = require("./jws");
|
|
32
32
|
var import_types = require("./types");
|
|
33
33
|
var import_utf8 = require("./utf8");
|
|
34
|
-
const encodeJwtPart = (part) => (0, import_encode.encodeBase64Url)(import_utf8.utf8Encoder.encode(JSON.stringify(part))).replace(/=/g, "");
|
|
34
|
+
const encodeJwtPart = (part) => (0, import_encode.encodeBase64Url)(import_utf8.utf8Encoder.encode(JSON.stringify(part)).buffer).replace(/=/g, "");
|
|
35
35
|
const encodeSignaturePart = (buf) => (0, import_encode.encodeBase64Url)(buf).replace(/=/g, "");
|
|
36
36
|
const decodeJwtPart = (part) => JSON.parse(import_utf8.utf8Decoder.decode((0, import_encode.decodeBase64Url)(part)));
|
|
37
37
|
function isTokenHeader(obj) {
|
package/dist/cjs/utils/url.js
CHANGED
|
@@ -129,7 +129,7 @@ const mergePath = (base, sub, ...rest) => {
|
|
|
129
129
|
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
130
130
|
};
|
|
131
131
|
const checkOptionalParameter = (path) => {
|
|
132
|
-
if (!path.
|
|
132
|
+
if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) {
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
135
|
const segments = path.split("/");
|
package/dist/hono-base.js
CHANGED
|
@@ -67,10 +67,9 @@ var Hono = class {
|
|
|
67
67
|
});
|
|
68
68
|
return this;
|
|
69
69
|
};
|
|
70
|
-
const strict = options
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.getPath = strict ? options.getPath ?? getPath : getPathNoStrict;
|
|
70
|
+
const { strict, ...optionsWithoutStrict } = options;
|
|
71
|
+
Object.assign(this, optionsWithoutStrict);
|
|
72
|
+
this.getPath = strict ?? true ? options.getPath ?? getPath : getPathNoStrict;
|
|
74
73
|
}
|
|
75
74
|
#clone() {
|
|
76
75
|
const clone = new Hono({
|
|
@@ -31,9 +31,9 @@ var DEFAULT_OPTIONS = {
|
|
|
31
31
|
permissionsPolicy: {}
|
|
32
32
|
};
|
|
33
33
|
var generateNonce = () => {
|
|
34
|
-
const
|
|
35
|
-
crypto.getRandomValues(
|
|
36
|
-
return encodeBase64(buffer);
|
|
34
|
+
const arrayBuffer = new Uint8Array(16);
|
|
35
|
+
crypto.getRandomValues(arrayBuffer);
|
|
36
|
+
return encodeBase64(arrayBuffer.buffer);
|
|
37
37
|
};
|
|
38
38
|
var NONCE = (ctx) => {
|
|
39
39
|
const key = "secureHeadersNonce";
|
|
@@ -19,13 +19,15 @@ var PatternRouter = class {
|
|
|
19
19
|
return match ? `/(?<${match[1]}>${match[2] || "[^/]+"})` : part === "/*" ? "/[^/]+" : part.replace(/[.\\+*[^\]$()]/g, "\\$&");
|
|
20
20
|
}
|
|
21
21
|
);
|
|
22
|
-
let re;
|
|
23
22
|
try {
|
|
24
|
-
|
|
23
|
+
this.#routes.push([
|
|
24
|
+
new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`),
|
|
25
|
+
method,
|
|
26
|
+
handler
|
|
27
|
+
]);
|
|
25
28
|
} catch {
|
|
26
29
|
throw new UnsupportedPathError();
|
|
27
30
|
}
|
|
28
|
-
this.#routes.push([re, method, handler]);
|
|
29
31
|
}
|
|
30
32
|
match(method, path) {
|
|
31
33
|
const handlers = [];
|
|
@@ -4,12 +4,12 @@ import { WSContext } from '../../helper/websocket';
|
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
6
6
|
export interface BunServerWebSocket<T> {
|
|
7
|
-
send(data: string |
|
|
7
|
+
send(data: string | ArrayBuffer | Uint8Array, compress?: boolean): void;
|
|
8
8
|
close(code?: number, reason?: string): void;
|
|
9
9
|
data: T;
|
|
10
10
|
readyState: 0 | 1 | 2 | 3;
|
|
11
11
|
}
|
|
12
|
-
interface BunWebSocketHandler<T> {
|
|
12
|
+
export interface BunWebSocketHandler<T> {
|
|
13
13
|
open(ws: BunServerWebSocket<T>): void;
|
|
14
14
|
close(ws: BunServerWebSocket<T>, code?: number, reason?: string): void;
|
|
15
15
|
message(ws: BunServerWebSocket<T>, message: string | {
|
|
@@ -6,7 +6,7 @@ import type { Context } from '../../context';
|
|
|
6
6
|
export type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other";
|
|
7
7
|
export declare const env: <T extends Record<string, unknown>, C extends Context = Context<{
|
|
8
8
|
Bindings: T;
|
|
9
|
-
}
|
|
9
|
+
}>>(c: T extends Record<string, unknown> ? Context : C, runtime?: Runtime) => T & C["env"];
|
|
10
10
|
export declare const knownUserAgents: Partial<Record<Runtime, string>>;
|
|
11
11
|
export declare const getRuntimeKey: () => Runtime;
|
|
12
12
|
export declare const checkUserAgentEquals: (platform: string) => boolean;
|
|
@@ -27,7 +27,7 @@ export type WSReadyState = 0 | 1 | 2 | 3;
|
|
|
27
27
|
* An argument for WSContext class
|
|
28
28
|
*/
|
|
29
29
|
export interface WSContextInit<T = unknown> {
|
|
30
|
-
send(data: string | ArrayBuffer, options: SendOptions): void;
|
|
30
|
+
send(data: string | ArrayBuffer | Uint8Array, options: SendOptions): void;
|
|
31
31
|
close(code?: number, reason?: string): void;
|
|
32
32
|
raw?: T;
|
|
33
33
|
readyState: WSReadyState;
|
package/dist/utils/jwt/jwt.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
JwtTokenSignatureMismatched
|
|
13
13
|
} from "./types.js";
|
|
14
14
|
import { utf8Decoder, utf8Encoder } from "./utf8.js";
|
|
15
|
-
var encodeJwtPart = (part) => encodeBase64Url(utf8Encoder.encode(JSON.stringify(part))).replace(/=/g, "");
|
|
15
|
+
var encodeJwtPart = (part) => encodeBase64Url(utf8Encoder.encode(JSON.stringify(part)).buffer).replace(/=/g, "");
|
|
16
16
|
var encodeSignaturePart = (buf) => encodeBase64Url(buf).replace(/=/g, "");
|
|
17
17
|
var decodeJwtPart = (part) => JSON.parse(utf8Decoder.decode(decodeBase64Url(part)));
|
|
18
18
|
function isTokenHeader(obj) {
|
package/dist/utils/url.js
CHANGED
|
@@ -96,7 +96,7 @@ var mergePath = (base, sub, ...rest) => {
|
|
|
96
96
|
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
97
97
|
};
|
|
98
98
|
var checkOptionalParameter = (path) => {
|
|
99
|
-
if (!path.
|
|
99
|
+
if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) {
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
102
|
const segments = path.split("/");
|