hono 4.3.7 → 4.3.8
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/context.js +5 -1
- package/dist/cjs/utils/jwt/jwt.js +5 -1
- package/dist/context.js +5 -1
- package/dist/types/context.d.ts +1 -1
- package/dist/types/jsx/dom/index.d.ts +2 -2
- package/dist/types/jsx/hooks/index.d.ts +2 -2
- package/dist/types/jsx/index.d.ts +2 -2
- package/dist/types/middleware/jwt/index.d.ts +3 -3
- package/dist/types/middleware/secure-headers/index.d.ts +2 -2
- package/dist/types/middleware/timing/index.d.ts +6 -6
- package/dist/types/utils/jwt/index.d.ts +3 -3
- package/dist/types/utils/jwt/jwt.d.ts +6 -6
- package/dist/types/utils/jwt/types.d.ts +1 -1
- package/dist/utils/jwt/jwt.js +5 -1
- package/package.json +1 -1
package/dist/cjs/context.js
CHANGED
|
@@ -155,7 +155,11 @@ class Context {
|
|
|
155
155
|
const header = new Headers(arg.headers);
|
|
156
156
|
if (this.#headers) {
|
|
157
157
|
this.#headers.forEach((v, k) => {
|
|
158
|
-
|
|
158
|
+
if (k === "set-cookie") {
|
|
159
|
+
header.append(k, v);
|
|
160
|
+
} else {
|
|
161
|
+
header.set(k, v);
|
|
162
|
+
}
|
|
159
163
|
});
|
|
160
164
|
}
|
|
161
165
|
const headers2 = setHeaders(header, this.#preparedHeaders);
|
|
@@ -34,7 +34,11 @@ const encodeJwtPart = (part) => (0, import_encode.encodeBase64Url)(import_utf8.u
|
|
|
34
34
|
const encodeSignaturePart = (buf) => (0, import_encode.encodeBase64Url)(buf).replace(/=/g, "");
|
|
35
35
|
const decodeJwtPart = (part) => JSON.parse(import_utf8.utf8Decoder.decode((0, import_encode.decodeBase64Url)(part)));
|
|
36
36
|
function isTokenHeader(obj) {
|
|
37
|
-
|
|
37
|
+
if (typeof obj === "object" && obj !== null) {
|
|
38
|
+
const objWithAlg = obj;
|
|
39
|
+
return "alg" in objWithAlg && Object.values(import_jwa.AlgorithmTypes).includes(objWithAlg.alg) && (!("typ" in objWithAlg) || objWithAlg.typ === "JWT");
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
38
42
|
}
|
|
39
43
|
const sign = async (payload, privateKey, alg = "HS256") => {
|
|
40
44
|
const encodedPayload = encodeJwtPart(payload);
|
package/dist/context.js
CHANGED
|
@@ -132,7 +132,11 @@ var Context = class {
|
|
|
132
132
|
const header = new Headers(arg.headers);
|
|
133
133
|
if (this.#headers) {
|
|
134
134
|
this.#headers.forEach((v, k) => {
|
|
135
|
-
|
|
135
|
+
if (k === "set-cookie") {
|
|
136
|
+
header.append(k, v);
|
|
137
|
+
} else {
|
|
138
|
+
header.set(k, v);
|
|
139
|
+
}
|
|
136
140
|
});
|
|
137
141
|
}
|
|
138
142
|
const headers2 = setHeaders(header, this.#preparedHeaders);
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HonoRequest } from './request';
|
|
2
2
|
import type { Env, FetchEventLike, Input, NotFoundHandler, TypedResponse } from './types';
|
|
3
3
|
import type { RedirectStatusCode, StatusCode } from './utils/http-status';
|
|
4
|
-
import type {
|
|
4
|
+
import type { IsAny, JSONParsed, JSONValue, Simplify } from './utils/types';
|
|
5
5
|
type HeaderRecord = Record<string, string | string[]>;
|
|
6
6
|
export type Data = string | ArrayBuffer | ReadableStream;
|
|
7
7
|
export interface ExecutionContext {
|
|
@@ -31,8 +31,8 @@ declare const _default: {
|
|
|
31
31
|
useId: () => string;
|
|
32
32
|
useDebugValue: (_value: unknown, _formatter?: ((value: unknown) => string) | undefined) => void;
|
|
33
33
|
createRef: <T_8>() => import("../hooks").RefObject<T_8>;
|
|
34
|
-
forwardRef: <T_9, P = {}>(Component: (props: P, ref
|
|
35
|
-
ref
|
|
34
|
+
forwardRef: <T_9, P = {}>(Component: (props: P, ref?: import("../hooks").RefObject<T_9> | undefined) => JSX.Element) => (props: P & {
|
|
35
|
+
ref?: import("../hooks").RefObject<T_9> | undefined;
|
|
36
36
|
}) => JSX.Element;
|
|
37
37
|
useImperativeHandle: <T_10>(ref: import("../hooks").RefObject<T_10>, createHandle: () => T_10, deps: readonly unknown[]) => void;
|
|
38
38
|
useSyncExternalStore: <T_11>(subscribe: (callback: (value: T_11) => void) => () => void, getSnapshot: () => T_11, getServerSnapshot?: (() => T_11) | undefined) => T_11;
|
|
@@ -32,8 +32,8 @@ export declare const useMemo: <T>(factory: () => T, deps: readonly unknown[]) =>
|
|
|
32
32
|
export declare const useId: () => string;
|
|
33
33
|
export declare const useDebugValue: (_value: unknown, _formatter?: ((value: unknown) => string) | undefined) => void;
|
|
34
34
|
export declare const createRef: <T>() => RefObject<T>;
|
|
35
|
-
export declare const forwardRef: <T, P = {}>(Component: (props: P, ref
|
|
36
|
-
ref
|
|
35
|
+
export declare const forwardRef: <T, P = {}>(Component: (props: P, ref?: RefObject<T> | undefined) => JSX.Element) => (props: P & {
|
|
36
|
+
ref?: RefObject<T> | undefined;
|
|
37
37
|
}) => JSX.Element;
|
|
38
38
|
export declare const useImperativeHandle: <T>(ref: RefObject<T>, createHandle: () => T, deps: readonly unknown[]) => void;
|
|
39
39
|
export declare const useSyncExternalStore: <T>(subscribe: (callback: (value: T) => void) => () => void, getSnapshot: () => T, getServerSnapshot?: (() => T) | undefined) => T;
|
|
@@ -41,8 +41,8 @@ declare const _default: {
|
|
|
41
41
|
useMemo: <T_11>(factory: () => T_11, deps: readonly unknown[]) => T_11;
|
|
42
42
|
useLayoutEffect: (effect: () => void | (() => void), deps?: readonly unknown[] | undefined) => void;
|
|
43
43
|
createRef: <T_12>() => import("./hooks").RefObject<T_12>;
|
|
44
|
-
forwardRef: <T_13, P = {}>(Component: (props: P, ref
|
|
45
|
-
ref
|
|
44
|
+
forwardRef: <T_13, P = {}>(Component: (props: P, ref?: import("./hooks").RefObject<T_13> | undefined) => JSX.Element) => (props: P & {
|
|
45
|
+
ref?: import("./hooks").RefObject<T_13> | undefined;
|
|
46
46
|
}) => JSX.Element;
|
|
47
47
|
useImperativeHandle: <T_14>(ref: import("./hooks").RefObject<T_14>, createHandle: () => T_14, deps: readonly unknown[]) => void;
|
|
48
48
|
useSyncExternalStore: <T_15>(subscribe: (callback: (value: T_15) => void) => () => void, getSnapshot: () => T_15, getServerSnapshot?: (() => T_15) | undefined) => T_15;
|
|
@@ -11,9 +11,9 @@ export declare const jwt: (options: {
|
|
|
11
11
|
cookie?: string;
|
|
12
12
|
alg?: SignatureAlgorithm;
|
|
13
13
|
}) => MiddlewareHandler;
|
|
14
|
-
export declare const verify: (token: string, publicKey: import("../../utils/jwt/jws").SignatureKey, alg?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ES256" | "ES384" | "ES512" | "EdDSA") => Promise<
|
|
14
|
+
export declare const verify: (token: string, publicKey: import("../../utils/jwt/jws").SignatureKey, alg?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ES256" | "ES384" | "ES512" | "EdDSA") => Promise<import("../../utils/jwt/types").JWTPayload>;
|
|
15
15
|
export declare const decode: (token: string) => {
|
|
16
|
-
header:
|
|
17
|
-
payload:
|
|
16
|
+
header: import("../../utils/jwt/jwt").TokenHeader;
|
|
17
|
+
payload: import("../../utils/jwt/types").JWTPayload;
|
|
18
18
|
};
|
|
19
19
|
export declare const sign: (payload: import("../../utils/jwt/types").JWTPayload, privateKey: import("../../utils/jwt/jws").SignatureKey, alg?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ES256" | "ES384" | "ES512" | "EdDSA") => Promise<string>;
|
|
@@ -49,7 +49,7 @@ interface SecureHeadersOptions {
|
|
|
49
49
|
crossOriginEmbedderPolicy?: overridableHeader;
|
|
50
50
|
crossOriginResourcePolicy?: overridableHeader;
|
|
51
51
|
crossOriginOpenerPolicy?: overridableHeader;
|
|
52
|
-
originAgentCluster
|
|
52
|
+
originAgentCluster?: overridableHeader;
|
|
53
53
|
referrerPolicy?: overridableHeader;
|
|
54
54
|
reportingEndpoints?: ReportingEndpointOptions[];
|
|
55
55
|
reportTo?: ReportToOptions[];
|
|
@@ -62,5 +62,5 @@ interface SecureHeadersOptions {
|
|
|
62
62
|
xXssProtection?: overridableHeader;
|
|
63
63
|
}
|
|
64
64
|
export declare const NONCE: ContentSecurityPolicyOptionHandler;
|
|
65
|
-
export declare const secureHeaders: (customOptions?:
|
|
65
|
+
export declare const secureHeaders: (customOptions?: SecureHeadersOptions) => MiddlewareHandler;
|
|
66
66
|
export {};
|
|
@@ -14,13 +14,13 @@ interface Timer {
|
|
|
14
14
|
start: number;
|
|
15
15
|
}
|
|
16
16
|
interface TimingOptions {
|
|
17
|
-
total
|
|
18
|
-
enabled
|
|
19
|
-
totalDescription
|
|
20
|
-
autoEnd
|
|
21
|
-
crossOrigin
|
|
17
|
+
total?: boolean;
|
|
18
|
+
enabled?: boolean | ((c: Context) => boolean);
|
|
19
|
+
totalDescription?: string;
|
|
20
|
+
autoEnd?: boolean;
|
|
21
|
+
crossOrigin?: boolean | string | ((c: Context) => boolean | string);
|
|
22
22
|
}
|
|
23
|
-
export declare const timing: (config?:
|
|
23
|
+
export declare const timing: (config?: TimingOptions) => MiddlewareHandler;
|
|
24
24
|
interface SetMetric {
|
|
25
25
|
(c: Context, name: string, value: number, description?: string, precision?: number): void;
|
|
26
26
|
(c: Context, name: string, description?: string): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const Jwt: {
|
|
2
2
|
sign: (payload: import("./types").JWTPayload, privateKey: import("./jws").SignatureKey, alg?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ES256" | "ES384" | "ES512" | "EdDSA") => Promise<string>;
|
|
3
|
-
verify: (token: string, publicKey: import("./jws").SignatureKey, alg?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ES256" | "ES384" | "ES512" | "EdDSA") => Promise<
|
|
3
|
+
verify: (token: string, publicKey: import("./jws").SignatureKey, alg?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ES256" | "ES384" | "ES512" | "EdDSA") => Promise<import("./types").JWTPayload>;
|
|
4
4
|
decode: (token: string) => {
|
|
5
|
-
header:
|
|
6
|
-
payload:
|
|
5
|
+
header: import("./jwt").TokenHeader;
|
|
6
|
+
payload: import("./types").JWTPayload;
|
|
7
7
|
};
|
|
8
8
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type SignatureAlgorithm } from './jwa';
|
|
2
|
+
import { type SignatureKey } from './jws';
|
|
3
3
|
import { type JWTPayload } from './types';
|
|
4
4
|
export interface TokenHeader {
|
|
5
5
|
alg: SignatureAlgorithm;
|
|
6
6
|
typ?: 'JWT';
|
|
7
7
|
}
|
|
8
|
-
export declare function isTokenHeader(obj:
|
|
8
|
+
export declare function isTokenHeader(obj: unknown): obj is TokenHeader;
|
|
9
9
|
export declare const sign: (payload: JWTPayload, privateKey: SignatureKey, alg?: SignatureAlgorithm) => Promise<string>;
|
|
10
|
-
export declare const verify: (token: string, publicKey: SignatureKey, alg?: SignatureAlgorithm) => Promise<
|
|
10
|
+
export declare const verify: (token: string, publicKey: SignatureKey, alg?: SignatureAlgorithm) => Promise<JWTPayload>;
|
|
11
11
|
export declare const decode: (token: string) => {
|
|
12
|
-
header:
|
|
13
|
-
payload:
|
|
12
|
+
header: TokenHeader;
|
|
13
|
+
payload: JWTPayload;
|
|
14
14
|
};
|
package/dist/utils/jwt/jwt.js
CHANGED
|
@@ -15,7 +15,11 @@ var encodeJwtPart = (part) => encodeBase64Url(utf8Encoder.encode(JSON.stringify(
|
|
|
15
15
|
var encodeSignaturePart = (buf) => encodeBase64Url(buf).replace(/=/g, "");
|
|
16
16
|
var decodeJwtPart = (part) => JSON.parse(utf8Decoder.decode(decodeBase64Url(part)));
|
|
17
17
|
function isTokenHeader(obj) {
|
|
18
|
-
|
|
18
|
+
if (typeof obj === "object" && obj !== null) {
|
|
19
|
+
const objWithAlg = obj;
|
|
20
|
+
return "alg" in objWithAlg && Object.values(AlgorithmTypes).includes(objWithAlg.alg) && (!("typ" in objWithAlg) || objWithAlg.typ === "JWT");
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
19
23
|
}
|
|
20
24
|
var sign = async (payload, privateKey, alg = "HS256") => {
|
|
21
25
|
const encodedPayload = encodeJwtPart(payload);
|