hono 4.11.4 → 4.11.6
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/adapter/bun/index.js +2 -0
- package/dist/cjs/adapter/bun/index.js +3 -0
- package/dist/cjs/helper/streaming/sse.js +1 -1
- package/dist/cjs/middleware/jwt/index.js +3 -0
- package/dist/helper/streaming/sse.js +1 -1
- package/dist/middleware/jwt/index.js +2 -0
- package/dist/types/adapter/bun/index.d.ts +1 -0
- package/dist/types/adapter/bun/server.d.ts +2 -14
- package/dist/types/client/types.d.ts +20 -2
- package/dist/types/middleware/jwt/index.d.ts +1 -0
- package/dist/types/middleware/jwt/jwt.d.ts +1 -1
- package/dist/types/request/constants.d.ts +1 -1
- package/dist/types/request.d.ts +1 -1
- package/dist/types/utils/jwt/index.d.ts +1 -1
- package/dist/types/utils/jwt/jwt.d.ts +1 -1
- package/dist/types/utils/jwt/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -3,9 +3,11 @@ import { serveStatic } from "./serve-static.js";
|
|
|
3
3
|
import { bunFileSystemModule, toSSG } from "./ssg.js";
|
|
4
4
|
import { createBunWebSocket, upgradeWebSocket, websocket } from "./websocket.js";
|
|
5
5
|
import { getConnInfo } from "./conninfo.js";
|
|
6
|
+
import { getBunServer } from "./server.js";
|
|
6
7
|
export {
|
|
7
8
|
bunFileSystemModule,
|
|
8
9
|
createBunWebSocket,
|
|
10
|
+
getBunServer,
|
|
9
11
|
getConnInfo,
|
|
10
12
|
serveStatic,
|
|
11
13
|
toSSG,
|
|
@@ -20,6 +20,7 @@ var bun_exports = {};
|
|
|
20
20
|
__export(bun_exports, {
|
|
21
21
|
bunFileSystemModule: () => import_ssg.bunFileSystemModule,
|
|
22
22
|
createBunWebSocket: () => import_websocket.createBunWebSocket,
|
|
23
|
+
getBunServer: () => import_server.getBunServer,
|
|
23
24
|
getConnInfo: () => import_conninfo.getConnInfo,
|
|
24
25
|
serveStatic: () => import_serve_static.serveStatic,
|
|
25
26
|
toSSG: () => import_ssg.toSSG,
|
|
@@ -31,10 +32,12 @@ var import_serve_static = require("./serve-static");
|
|
|
31
32
|
var import_ssg = require("./ssg");
|
|
32
33
|
var import_websocket = require("./websocket");
|
|
33
34
|
var import_conninfo = require("./conninfo");
|
|
35
|
+
var import_server = require("./server");
|
|
34
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
37
|
0 && (module.exports = {
|
|
36
38
|
bunFileSystemModule,
|
|
37
39
|
createBunWebSocket,
|
|
40
|
+
getBunServer,
|
|
38
41
|
getConnInfo,
|
|
39
42
|
serveStatic,
|
|
40
43
|
toSSG,
|
|
@@ -31,7 +31,7 @@ class SSEStreamingApi extends import_stream.StreamingApi {
|
|
|
31
31
|
}
|
|
32
32
|
async writeSSE(message) {
|
|
33
33
|
const data = await (0, import_html.resolveCallback)(message.data, import_html.HtmlEscapedCallbackPhase.Stringify, false, {});
|
|
34
|
-
const dataLines = data.split(
|
|
34
|
+
const dataLines = data.split(/\r\n|\r|\n/).map((line) => {
|
|
35
35
|
return `data: ${line}`;
|
|
36
36
|
}).join("\n");
|
|
37
37
|
const sseData = [
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var jwt_exports = {};
|
|
20
20
|
__export(jwt_exports, {
|
|
21
|
+
AlgorithmTypes: () => import_jwa.AlgorithmTypes,
|
|
21
22
|
decode: () => import_jwt.decode,
|
|
22
23
|
jwt: () => import_jwt.jwt,
|
|
23
24
|
sign: () => import_jwt.sign,
|
|
@@ -26,8 +27,10 @@ __export(jwt_exports, {
|
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(jwt_exports);
|
|
28
29
|
var import_jwt = require("./jwt");
|
|
30
|
+
var import_jwa = require("../../utils/jwt/jwa");
|
|
29
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
32
|
0 && (module.exports = {
|
|
33
|
+
AlgorithmTypes,
|
|
31
34
|
decode,
|
|
32
35
|
jwt,
|
|
33
36
|
sign,
|
|
@@ -8,7 +8,7 @@ var SSEStreamingApi = class extends StreamingApi {
|
|
|
8
8
|
}
|
|
9
9
|
async writeSSE(message) {
|
|
10
10
|
const data = await resolveCallback(message.data, HtmlEscapedCallbackPhase.Stringify, false, {});
|
|
11
|
-
const dataLines = data.split(
|
|
11
|
+
const dataLines = data.split(/\r\n|\r|\n/).map((line) => {
|
|
12
12
|
return `data: ${line}`;
|
|
13
13
|
}).join("\n");
|
|
14
14
|
const sseData = [
|
|
@@ -7,3 +7,4 @@ export { bunFileSystemModule, toSSG } from './ssg';
|
|
|
7
7
|
export { createBunWebSocket, upgradeWebSocket, websocket } from './websocket';
|
|
8
8
|
export type { BunWebSocketData, BunWebSocketHandler } from './websocket';
|
|
9
9
|
export { getConnInfo } from './conninfo';
|
|
10
|
+
export { getBunServer } from './server';
|
|
@@ -3,22 +3,10 @@
|
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
import type { Context } from '../../context';
|
|
6
|
-
/**
|
|
7
|
-
* Bun Server Object
|
|
8
|
-
*/
|
|
9
|
-
export interface BunServer {
|
|
10
|
-
requestIP?: (req: Request) => {
|
|
11
|
-
address: string;
|
|
12
|
-
family: string;
|
|
13
|
-
port: number;
|
|
14
|
-
} | null;
|
|
15
|
-
upgrade<T>(req: Request, options?: {
|
|
16
|
-
data: T;
|
|
17
|
-
}): boolean;
|
|
18
|
-
}
|
|
19
6
|
/**
|
|
20
7
|
* Get Bun Server Object from Context
|
|
8
|
+
* @template T - The type of Bun Server
|
|
21
9
|
* @param c Context
|
|
22
10
|
* @returns Bun Server
|
|
23
11
|
*/
|
|
24
|
-
export declare const getBunServer: (c: Context) =>
|
|
12
|
+
export declare const getBunServer: <T>(c: Context) => T | undefined;
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import type { Hono } from '../hono';
|
|
2
2
|
import type { HonoBase } from '../hono-base';
|
|
3
|
+
import type { METHODS, METHOD_NAME_ALL_LOWERCASE } from '../router';
|
|
3
4
|
import type { Endpoint, ResponseFormat, Schema } from '../types';
|
|
4
5
|
import type { StatusCode, SuccessStatusCode } from '../utils/http-status';
|
|
5
6
|
import type { HasRequiredKeys } from '../utils/types';
|
|
7
|
+
/**
|
|
8
|
+
* Type representing the '$all' method name
|
|
9
|
+
*/
|
|
10
|
+
type MethodNameAll = `$${typeof METHOD_NAME_ALL_LOWERCASE}`;
|
|
11
|
+
/**
|
|
12
|
+
* Type representing all standard HTTP methods prefixed with '$'
|
|
13
|
+
* e.g., '$get' | '$post' | '$put' | '$delete' | '$options' | '$patch'
|
|
14
|
+
*/
|
|
15
|
+
type StandardMethods = `$${(typeof METHODS)[number]}`;
|
|
16
|
+
/**
|
|
17
|
+
* Expands '$all' into all standard HTTP methods.
|
|
18
|
+
* If the schema contains '$all', it creates a type where all standard HTTP methods
|
|
19
|
+
* point to the same endpoint definition as '$all', while removing '$all' itself.
|
|
20
|
+
*/
|
|
21
|
+
type ExpandAllMethod<S> = MethodNameAll extends keyof S ? {
|
|
22
|
+
[M in StandardMethods]: S[MethodNameAll];
|
|
23
|
+
} & Omit<S, MethodNameAll> : S;
|
|
6
24
|
type HonoRequest = (typeof Hono.prototype)['request'];
|
|
7
25
|
export type BuildSearchParamsFn = (query: Record<string, string | string[]>) => URLSearchParams;
|
|
8
26
|
export type ClientRequestOptions<T = unknown> = {
|
|
@@ -36,9 +54,9 @@ export type ClientRequestOptions<T = unknown> = {
|
|
|
36
54
|
headers: T | (() => T | Promise<T>);
|
|
37
55
|
});
|
|
38
56
|
export type ClientRequest<Prefix extends string, Path extends string, S extends Schema> = {
|
|
39
|
-
[M in keyof S]: S[M] extends Endpoint & {
|
|
57
|
+
[M in keyof ExpandAllMethod<S>]: ExpandAllMethod<S>[M] extends Endpoint & {
|
|
40
58
|
input: infer R;
|
|
41
|
-
} ? R extends object ? HasRequiredKeys<R> extends true ? (args: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<S[M]>> : (args?: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<S[M]>> : never : never;
|
|
59
|
+
} ? R extends object ? HasRequiredKeys<R> extends true ? (args: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<ExpandAllMethod<S>[M]>> : (args?: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<ExpandAllMethod<S>[M]>> : never : never;
|
|
42
60
|
} & {
|
|
43
61
|
$url: <const Arg extends (S[keyof S] extends {
|
|
44
62
|
input: infer R;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { JwtVariables } from './jwt';
|
|
2
2
|
export type { JwtVariables };
|
|
3
3
|
export { jwt, verifyWithJwks, verify, decode, sign } from './jwt';
|
|
4
|
+
export { AlgorithmTypes } from '../../utils/jwt/jwa';
|
|
4
5
|
declare module '../..' {
|
|
5
6
|
interface ContextVariableMap extends JwtVariables {
|
|
6
7
|
}
|
|
@@ -57,7 +57,7 @@ export declare const verifyWithJwks: (token: string, options: {
|
|
|
57
57
|
keys?: import("../../utils/jwt/jws").HonoJsonWebKey[];
|
|
58
58
|
jwks_uri?: string;
|
|
59
59
|
verification?: VerifyOptions;
|
|
60
|
-
allowedAlgorithms: import("../../utils/jwt/jwa").AsymmetricAlgorithm[];
|
|
60
|
+
allowedAlgorithms: readonly import("../../utils/jwt/jwa").AsymmetricAlgorithm[];
|
|
61
61
|
}, init?: RequestInit) => Promise<import("../../utils/jwt/types").JWTPayload>;
|
|
62
62
|
export declare const verify: (token: string, publicKey: SignatureKey, algOrOptions: SignatureAlgorithm | import("../../utils/jwt/jwt").VerifyOptionsWithAlg) => Promise<import("../../utils/jwt/types").JWTPayload>;
|
|
63
63
|
export declare const decode: (token: string) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const GET_MATCH_RESULT: symbol;
|
|
1
|
+
export declare const GET_MATCH_RESULT: unique symbol;
|
package/dist/types/request.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ type BodyCache = Partial<Body & {
|
|
|
16
16
|
}>;
|
|
17
17
|
export declare class HonoRequest<P extends string = '/', I extends Input['out'] = {}> {
|
|
18
18
|
|
|
19
|
-
[GET_MATCH_RESULT]: Result<[unknown, RouterRoute]>;
|
|
20
19
|
/**
|
|
21
20
|
* `.raw` can get the raw Request object.
|
|
22
21
|
*
|
|
@@ -232,6 +231,7 @@ export declare class HonoRequest<P extends string = '/', I extends Input['out']
|
|
|
232
231
|
* ```
|
|
233
232
|
*/
|
|
234
233
|
get method(): string;
|
|
234
|
+
get [GET_MATCH_RESULT](): Result<[unknown, RouterRoute]>;
|
|
235
235
|
/**
|
|
236
236
|
* `.matchedRoutes()` can return a matched route in the handler
|
|
237
237
|
*
|
|
@@ -13,6 +13,6 @@ export declare const Jwt: {
|
|
|
13
13
|
keys?: import("./jws").HonoJsonWebKey[];
|
|
14
14
|
jwks_uri?: string;
|
|
15
15
|
verification?: import("./jwt").VerifyOptions;
|
|
16
|
-
allowedAlgorithms: import("./jwa").AsymmetricAlgorithm[];
|
|
16
|
+
allowedAlgorithms: readonly import("./jwa").AsymmetricAlgorithm[];
|
|
17
17
|
}, init?: RequestInit) => Promise<import("./types").JWTPayload>;
|
|
18
18
|
};
|
|
@@ -34,7 +34,7 @@ export declare const verifyWithJwks: (token: string, options: {
|
|
|
34
34
|
keys?: HonoJsonWebKey[];
|
|
35
35
|
jwks_uri?: string;
|
|
36
36
|
verification?: VerifyOptions;
|
|
37
|
-
allowedAlgorithms: AsymmetricAlgorithm[];
|
|
37
|
+
allowedAlgorithms: readonly AsymmetricAlgorithm[];
|
|
38
38
|
}, init?: RequestInit) => Promise<JWTPayload>;
|
|
39
39
|
export declare const decode: (token: string) => {
|
|
40
40
|
header: TokenHeader;
|
|
@@ -36,7 +36,7 @@ export declare class JwtSymmetricAlgorithmNotAllowed extends Error {
|
|
|
36
36
|
constructor(alg: string);
|
|
37
37
|
}
|
|
38
38
|
export declare class JwtAlgorithmNotAllowed extends Error {
|
|
39
|
-
constructor(alg: string, allowedAlgorithms: string[]);
|
|
39
|
+
constructor(alg: string, allowedAlgorithms: readonly string[]);
|
|
40
40
|
}
|
|
41
41
|
export declare class JwtTokenSignatureMismatched extends Error {
|
|
42
42
|
constructor(token: string);
|