hono 2.0.0 → 2.0.3
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/README.md +11 -11
- package/dist/compose.js +2 -2
- package/dist/context.d.ts +7 -6
- package/dist/context.js +17 -6
- package/dist/hono.js +2 -2
- package/dist/middleware/cache/index.d.ts +7 -0
- package/dist/middleware/cache/index.js +32 -0
- package/dist/middleware/compress/index.d.ts +2 -1
- package/dist/middleware/jsx/index.d.ts +2 -2
- package/dist/middleware/jsx/index.js +3 -3
- package/dist/middleware/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/middleware/jsx/jsx-dev-runtime.js +10 -0
- package/dist/middleware/jsx/jsx-runtime.d.ts +2 -0
- package/dist/middleware/jsx/jsx-runtime.js +7 -0
- package/dist/middleware/logger/index.d.ts +3 -5
- package/dist/middleware/logger/index.js +15 -16
- package/dist/middleware/serve-static/module.mjs +1 -0
- package/dist/router/trie-router/node.js +18 -12
- package/dist/utils/jwt/jwt.js +1 -1
- package/dist/utils/jwt/types.d.ts +6 -1
- package/dist/utils/jwt/types.js +9 -4
- package/package.json +18 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<a href="https://honojs.dev">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/honojs/hono/
|
|
3
|
+
<img src="https://raw.githubusercontent.com/honojs/hono/main/docs/images/hono-title.png" width="500" height="auto" alt="Hono"/>
|
|
4
4
|
</a>
|
|
5
5
|
</div>
|
|
6
6
|
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
<hr />
|
|
15
15
|
|
|
16
16
|
[](https://github.com/honojs/hono/actions)
|
|
17
|
-
[](https://github.com/honojs/hono/blob/
|
|
17
|
+
[](https://github.com/honojs/hono/blob/main/LICENSE)
|
|
18
18
|
[](https://www.npmjs.com/package/hono)
|
|
19
19
|
[](https://www.npmjs.com/package/hono)
|
|
20
20
|
[](https://www.npmjs.com/package/hono)
|
|
21
21
|
[](https://github.com/honojs/hono/pulse)
|
|
22
|
-
[](https://github.com/honojs/hono/commits/
|
|
22
|
+
[](https://github.com/honojs/hono/commits/main)
|
|
23
23
|
[](https://doc.deno.land/https/deno.land/x/hono/mod.ts)
|
|
24
24
|
|
|
25
25
|
Hono - _**[炎] means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework for Cloudflare Workers, Deno, Bun, and others.
|
|
@@ -61,19 +61,19 @@ The documentation is available on [honojs.dev](https://honojs.dev).
|
|
|
61
61
|
|
|
62
62
|
## Migration
|
|
63
63
|
|
|
64
|
-
Migration guide is available on [docs/MIGRATION.md](docs/MIGRATION.md)
|
|
64
|
+
Migration guide is available on [docs/MIGRATION.md](docs/MIGRATION.md).
|
|
65
65
|
|
|
66
66
|
## Contributing
|
|
67
67
|
|
|
68
68
|
Contributions Welcome! You can contribute in the following ways.
|
|
69
69
|
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
- Create an Issue - Propose a new feature. Report a bug.
|
|
71
|
+
- Pull Request - Fix a bug and typo. Refactor the code.
|
|
72
|
+
- Create third-party middleware - Instruct below.
|
|
73
|
+
- Share - Share your thoughts on the Blog, Twitter, and others.
|
|
74
|
+
- Make your application - Please try to use Hono.
|
|
75
|
+
|
|
76
|
+
For more details, see [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md).
|
|
77
77
|
|
|
78
78
|
## Contributors
|
|
79
79
|
|
package/dist/compose.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.compose = void 0;
|
|
|
4
4
|
const context_1 = require("./context");
|
|
5
5
|
// Based on the code in the MIT licensed `koa-compose` package.
|
|
6
6
|
const compose = (middleware, onError, onNotFound) => {
|
|
7
|
-
return
|
|
7
|
+
return (context, next) => {
|
|
8
8
|
let index = -1;
|
|
9
9
|
return dispatch(0);
|
|
10
10
|
async function dispatch(i) {
|
|
@@ -22,7 +22,7 @@ const compose = (middleware, onError, onNotFound) => {
|
|
|
22
22
|
return Promise.resolve(context);
|
|
23
23
|
}
|
|
24
24
|
return Promise.resolve(handler(context, () => dispatch(i + 1)))
|
|
25
|
-
.then(
|
|
25
|
+
.then((res) => {
|
|
26
26
|
// If handler return Response like `return c.text('foo')`
|
|
27
27
|
if (res && context instanceof context_1.HonoContext) {
|
|
28
28
|
context.res = res;
|
package/dist/context.d.ts
CHANGED
|
@@ -8,15 +8,15 @@ declare type Env = Record<string, any>;
|
|
|
8
8
|
export interface Context<RequestParamKeyType extends string = string, E = Env> {
|
|
9
9
|
req: Request<RequestParamKeyType>;
|
|
10
10
|
env: E;
|
|
11
|
-
event: FetchEvent
|
|
12
|
-
executionCtx: ExecutionContext
|
|
11
|
+
event: FetchEvent;
|
|
12
|
+
executionCtx: ExecutionContext;
|
|
13
13
|
finalized: boolean;
|
|
14
14
|
get res(): Response;
|
|
15
15
|
set res(_res: Response);
|
|
16
16
|
header: (name: string, value: string) => void;
|
|
17
17
|
status: (status: StatusCode) => void;
|
|
18
18
|
set: (key: string, value: any) => void;
|
|
19
|
-
get: (key: string) =>
|
|
19
|
+
get: <T = any>(key: string) => T;
|
|
20
20
|
pretty: (prettyJSON: boolean, space?: number) => void;
|
|
21
21
|
newResponse: (data: Data | null, status: StatusCode, headers: Headers) => Response;
|
|
22
22
|
body: (data: Data | null, status?: StatusCode, headers?: Headers) => Response;
|
|
@@ -30,17 +30,18 @@ export interface Context<RequestParamKeyType extends string = string, E = Env> {
|
|
|
30
30
|
export declare class HonoContext<RequestParamKeyType extends string = string, E = Env> implements Context<RequestParamKeyType, E> {
|
|
31
31
|
req: Request<RequestParamKeyType>;
|
|
32
32
|
env: E;
|
|
33
|
-
event: FetchEvent | undefined;
|
|
34
|
-
executionCtx: ExecutionContext | undefined;
|
|
35
33
|
finalized: boolean;
|
|
36
34
|
_status: StatusCode;
|
|
35
|
+
private _executionCtx;
|
|
37
36
|
private _pretty;
|
|
38
37
|
private _prettySpace;
|
|
39
38
|
private _map;
|
|
40
39
|
private _headers;
|
|
41
40
|
private _res;
|
|
42
41
|
private notFoundHandler;
|
|
43
|
-
constructor(req: Request, env?: E | undefined,
|
|
42
|
+
constructor(req: Request, env?: E | undefined, executionCtx?: FetchEvent | ExecutionContext | undefined, notFoundHandler?: NotFoundHandler);
|
|
43
|
+
get event(): FetchEvent;
|
|
44
|
+
get executionCtx(): ExecutionContext;
|
|
44
45
|
get res(): Response;
|
|
45
46
|
set res(_res: Response);
|
|
46
47
|
header(name: string, value: string): void;
|
package/dist/context.js
CHANGED
|
@@ -4,20 +4,31 @@ exports.HonoContext = void 0;
|
|
|
4
4
|
const cookie_1 = require("./utils/cookie");
|
|
5
5
|
const url_1 = require("./utils/url");
|
|
6
6
|
class HonoContext {
|
|
7
|
-
constructor(req, env = undefined,
|
|
7
|
+
constructor(req, env = undefined, executionCtx = undefined, notFoundHandler = () => new Response()) {
|
|
8
8
|
this._status = 200;
|
|
9
9
|
this._pretty = false;
|
|
10
10
|
this._prettySpace = 2;
|
|
11
|
+
this._executionCtx = executionCtx;
|
|
11
12
|
this.req = req;
|
|
12
13
|
this.env = env ? env : {};
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
this.notFoundHandler = notFoundHandler;
|
|
15
|
+
this.finalized = false;
|
|
16
|
+
}
|
|
17
|
+
get event() {
|
|
18
|
+
if (this._executionCtx instanceof FetchEvent) {
|
|
19
|
+
return this._executionCtx;
|
|
15
20
|
}
|
|
16
21
|
else {
|
|
17
|
-
|
|
22
|
+
throw Error('This context has no FetchEvent');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
get executionCtx() {
|
|
26
|
+
if (this._executionCtx) {
|
|
27
|
+
return this._executionCtx;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw Error('This context has no ExecutionContext');
|
|
18
31
|
}
|
|
19
|
-
this.notFoundHandler = notFoundHandler;
|
|
20
|
-
this.finalized = false;
|
|
21
32
|
}
|
|
22
33
|
get res() {
|
|
23
34
|
return (this._res || (this._res = new Response()));
|
package/dist/hono.js
CHANGED
|
@@ -29,7 +29,7 @@ class Hono extends defineDynamicClass() {
|
|
|
29
29
|
const message = 'Internal Server Error';
|
|
30
30
|
return c.text(message, 500);
|
|
31
31
|
};
|
|
32
|
-
this.fetch =
|
|
32
|
+
this.fetch = (request, env, executionCtx) => {
|
|
33
33
|
return this.dispatch(request, executionCtx, env);
|
|
34
34
|
};
|
|
35
35
|
(0, request_1.extendRequestPrototype)();
|
|
@@ -117,7 +117,7 @@ class Hono extends defineDynamicClass() {
|
|
|
117
117
|
}
|
|
118
118
|
return context.res;
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
handleEvent(event) {
|
|
121
121
|
return this.dispatch(event.request, event);
|
|
122
122
|
}
|
|
123
123
|
request(input, requestInit) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cache = void 0;
|
|
4
|
+
const cache = (options) => {
|
|
5
|
+
if (options.wait === undefined) {
|
|
6
|
+
options.wait = false;
|
|
7
|
+
}
|
|
8
|
+
const addHeader = (response) => {
|
|
9
|
+
if (options.cacheControl)
|
|
10
|
+
response.headers.append('Cache-Control', options.cacheControl);
|
|
11
|
+
};
|
|
12
|
+
return async (c, next) => {
|
|
13
|
+
const key = c.req;
|
|
14
|
+
const cache = await caches.open(options.cacheName);
|
|
15
|
+
const response = await cache.match(key);
|
|
16
|
+
if (!response) {
|
|
17
|
+
await next();
|
|
18
|
+
addHeader(c.res);
|
|
19
|
+
const response = c.res.clone();
|
|
20
|
+
if (options.wait) {
|
|
21
|
+
await cache.put(key, response);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
c.executionCtx.waitUntil(cache.put(key, response));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return response;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.cache = cache;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Context } from '../../context';
|
|
2
2
|
import type { Next } from '../../hono';
|
|
3
|
+
declare type EncodingType = 'gzip' | 'deflate';
|
|
3
4
|
interface CompressionOptions {
|
|
4
|
-
encoding?:
|
|
5
|
+
encoding?: EncodingType;
|
|
5
6
|
}
|
|
6
7
|
export declare const compress: (options?: CompressionOptions | undefined) => (ctx: Context, next: Next) => Promise<void>;
|
|
7
8
|
export {};
|
|
@@ -6,11 +6,11 @@ declare global {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export { jsxFn as jsx };
|
|
10
|
+
declare const jsxFn: (tag: string | Function, props: Record<string, any>, ...children: (string | HtmlEscapedString)[]) => HtmlEscapedString;
|
|
10
11
|
declare type FC<T = Record<string, any>> = (props: T) => HtmlEscapedString;
|
|
11
12
|
export declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
|
|
12
13
|
export declare const Fragment: (props: {
|
|
13
14
|
key?: string;
|
|
14
15
|
children?: any;
|
|
15
16
|
}) => HtmlEscapedString;
|
|
16
|
-
export {};
|
|
@@ -19,7 +19,7 @@ const emptyTags = [
|
|
|
19
19
|
'track',
|
|
20
20
|
'wbr',
|
|
21
21
|
];
|
|
22
|
-
const
|
|
22
|
+
const jsxFn = (tag, props, ...children) => {
|
|
23
23
|
if (typeof tag === 'function') {
|
|
24
24
|
return tag.call(null, { ...props, children: children.length <= 1 ? children[0] : children });
|
|
25
25
|
}
|
|
@@ -67,7 +67,7 @@ const jsx = (tag, props, ...children) => {
|
|
|
67
67
|
escapedString.isEscaped = true;
|
|
68
68
|
return escapedString;
|
|
69
69
|
};
|
|
70
|
-
exports.jsx =
|
|
70
|
+
exports.jsx = jsxFn;
|
|
71
71
|
const shallowEqual = (a, b) => {
|
|
72
72
|
if (a === b) {
|
|
73
73
|
return true;
|
|
@@ -97,6 +97,6 @@ const memo = (component, propsAreEqual = shallowEqual) => {
|
|
|
97
97
|
};
|
|
98
98
|
exports.memo = memo;
|
|
99
99
|
const Fragment = (props) => {
|
|
100
|
-
return (
|
|
100
|
+
return jsxFn('', {}, ...(props.children || []));
|
|
101
101
|
};
|
|
102
102
|
exports.Fragment = Fragment;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jsxDEV = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
function jsxDEV(tag, props) {
|
|
6
|
+
const children = props.children ?? [];
|
|
7
|
+
delete props['children'];
|
|
8
|
+
return (0, _1.jsx)(tag, props, ...children);
|
|
9
|
+
}
|
|
10
|
+
exports.jsxDEV = jsxDEV;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jsxs = exports.jsx = void 0;
|
|
4
|
+
var jsx_dev_runtime_1 = require("./jsx-dev-runtime");
|
|
5
|
+
Object.defineProperty(exports, "jsx", { enumerable: true, get: function () { return jsx_dev_runtime_1.jsxDEV; } });
|
|
6
|
+
var jsx_dev_runtime_2 = require("./jsx-dev-runtime");
|
|
7
|
+
Object.defineProperty(exports, "jsxs", { enumerable: true, get: function () { return jsx_dev_runtime_2.jsxDEV; } });
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Context } from '../../context';
|
|
2
2
|
import type { Next } from '../../hono';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
7
|
-
}) => (c: Context, next: Next) => Promise<void>;
|
|
3
|
+
declare type PrintFunc = (str: string, ...rest: string[]) => void;
|
|
4
|
+
export declare const logger: (fn?: PrintFunc) => (c: Context, next: Next) => Promise<void>;
|
|
5
|
+
export {};
|
|
@@ -2,24 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logger = void 0;
|
|
4
4
|
const url_1 = require("../../utils/url");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
var LogPrefix;
|
|
6
|
+
(function (LogPrefix) {
|
|
7
|
+
LogPrefix["Outgoing"] = "-->";
|
|
8
|
+
LogPrefix["Incoming"] = "<--";
|
|
9
|
+
LogPrefix["Error"] = "xxx";
|
|
10
|
+
})(LogPrefix || (LogPrefix = {}));
|
|
11
|
+
const humanize = (times) => {
|
|
12
|
+
const [delimiter, separator] = [',', '.'];
|
|
13
|
+
const orderTimes = times.map((v) => v.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + delimiter));
|
|
14
|
+
return orderTimes.join(separator);
|
|
12
15
|
};
|
|
13
16
|
const time = (start) => {
|
|
14
17
|
const delta = Date.now() - start;
|
|
15
|
-
return humanize([delta <
|
|
18
|
+
return humanize([delta < 1000 ? delta + 'ms' : Math.round(delta / 1000) + 's']);
|
|
16
19
|
};
|
|
17
|
-
const
|
|
18
|
-
Outgoing: '-->',
|
|
19
|
-
Incoming: '<--',
|
|
20
|
-
Error: 'xxx',
|
|
21
|
-
};
|
|
22
|
-
const colorStatus = (status = 0) => {
|
|
20
|
+
const colorStatus = (status) => {
|
|
23
21
|
const out = {
|
|
24
22
|
7: `\x1b[35m${status}\x1b[0m`,
|
|
25
23
|
5: `\x1b[31m${status}\x1b[0m`,
|
|
@@ -29,9 +27,10 @@ const colorStatus = (status = 0) => {
|
|
|
29
27
|
1: `\x1b[32m${status}\x1b[0m`,
|
|
30
28
|
0: `\x1b[33m${status}\x1b[0m`,
|
|
31
29
|
};
|
|
32
|
-
|
|
30
|
+
const calculateStatus = (status / 100) | 0;
|
|
31
|
+
return out[calculateStatus];
|
|
33
32
|
};
|
|
34
|
-
function log(fn, prefix, method, path, status, elapsed) {
|
|
33
|
+
function log(fn, prefix, method, path, status = 0, elapsed) {
|
|
35
34
|
const out = prefix === LogPrefix.Incoming
|
|
36
35
|
? ` ${prefix} ${method} ${path}`
|
|
37
36
|
: ` ${prefix} ${method} ${path} ${colorStatus(status)} ${elapsed}`;
|
|
@@ -102,8 +102,21 @@ class Node {
|
|
|
102
102
|
const part = parts[i];
|
|
103
103
|
const isLast = i === len - 1;
|
|
104
104
|
const tempNodes = [];
|
|
105
|
+
let matched = false;
|
|
105
106
|
for (let j = 0, len2 = curNodes.length; j < len2; j++) {
|
|
106
107
|
const node = curNodes[j];
|
|
108
|
+
const nextNode = node.children[part];
|
|
109
|
+
if (nextNode) {
|
|
110
|
+
if (isLast === true) {
|
|
111
|
+
// '/hello/*' => match '/hello'
|
|
112
|
+
if (nextNode.children['*']) {
|
|
113
|
+
handlerSets.push(...this.getHandlerSets(nextNode.children['*'], method, true));
|
|
114
|
+
}
|
|
115
|
+
handlerSets.push(...this.getHandlerSets(nextNode, method));
|
|
116
|
+
matched = true;
|
|
117
|
+
}
|
|
118
|
+
tempNodes.push(nextNode);
|
|
119
|
+
}
|
|
107
120
|
for (let k = 0, len3 = node.patterns.length; k < len3; k++) {
|
|
108
121
|
const pattern = node.patterns[k];
|
|
109
122
|
// Wildcard
|
|
@@ -128,22 +141,15 @@ class Node {
|
|
|
128
141
|
}
|
|
129
142
|
tempNodes.push(node.children[key]);
|
|
130
143
|
}
|
|
131
|
-
|
|
144
|
+
// '/book/a' => not-slug
|
|
145
|
+
// '/book/:slug' => slug
|
|
146
|
+
// GET /book/a ~> no-slug, param['slug'] => undefined
|
|
147
|
+
// GET /book/foo ~> slug, param['slug'] => foo
|
|
148
|
+
if (typeof name === 'string' && !matched) {
|
|
132
149
|
params[name] = part;
|
|
133
150
|
}
|
|
134
151
|
}
|
|
135
152
|
}
|
|
136
|
-
const nextNode = node.children[part];
|
|
137
|
-
if (nextNode) {
|
|
138
|
-
if (isLast === true) {
|
|
139
|
-
// '/hello/*' => match '/hello'
|
|
140
|
-
if (nextNode.children['*']) {
|
|
141
|
-
handlerSets.push(...this.getHandlerSets(nextNode.children['*'], method, true));
|
|
142
|
-
}
|
|
143
|
-
handlerSets.push(...this.getHandlerSets(nextNode, method));
|
|
144
|
-
}
|
|
145
|
-
tempNodes.push(nextNode);
|
|
146
|
-
}
|
|
147
153
|
}
|
|
148
154
|
curNodes = tempNodes;
|
|
149
155
|
}
|
package/dist/utils/jwt/jwt.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class JwtAlgorithmNotImplemented extends Error {
|
|
2
2
|
constructor(token: string);
|
|
3
3
|
}
|
|
4
|
+
/**
|
|
5
|
+
* Export for backward compatibility
|
|
6
|
+
* @deprecated Use JwtAlgorithmNotImplemented instead
|
|
7
|
+
**/
|
|
8
|
+
export declare const JwtAlorithmNotImplemented: typeof JwtAlgorithmNotImplemented;
|
|
4
9
|
export declare class JwtTokenInvalid extends Error {
|
|
5
10
|
constructor(token: string);
|
|
6
11
|
}
|
package/dist/utils/jwt/types.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AlgorithmTypes = exports.JwtTokenSignatureMismatched = exports.JwtTokenExpired = exports.JwtTokenNotBefore = exports.JwtTokenInvalid = exports.JwtAlorithmNotImplemented = void 0;
|
|
4
|
-
class
|
|
3
|
+
exports.AlgorithmTypes = exports.JwtTokenSignatureMismatched = exports.JwtTokenExpired = exports.JwtTokenNotBefore = exports.JwtTokenInvalid = exports.JwtAlorithmNotImplemented = exports.JwtAlgorithmNotImplemented = void 0;
|
|
4
|
+
class JwtAlgorithmNotImplemented extends Error {
|
|
5
5
|
constructor(token) {
|
|
6
6
|
super(`invalid JWT token: ${token}`);
|
|
7
|
-
this.name = '
|
|
7
|
+
this.name = 'JwtAlgorithmNotImplemented';
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
exports.
|
|
10
|
+
exports.JwtAlgorithmNotImplemented = JwtAlgorithmNotImplemented;
|
|
11
|
+
/**
|
|
12
|
+
* Export for backward compatibility
|
|
13
|
+
* @deprecated Use JwtAlgorithmNotImplemented instead
|
|
14
|
+
**/
|
|
15
|
+
exports.JwtAlorithmNotImplemented = JwtAlgorithmNotImplemented;
|
|
11
16
|
class JwtTokenInvalid extends Error {
|
|
12
17
|
constructor(token) {
|
|
13
18
|
super(`invalid JWT token: ${token}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Ultrafast web framework for Cloudflare Workers.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "jest",
|
|
12
12
|
"test:deno": "deno test --allow-read deno_test",
|
|
13
|
-
"test:bun": "bun
|
|
13
|
+
"test:bun": "bun wiptest --jsx-import-source ../src/middleware/jsx/jsx-dev-runtime bun_test/index.test.tsx",
|
|
14
|
+
"test:all": "yarn test && yarn test:deno && yarn test:bun",
|
|
14
15
|
"lint": "eslint --ext js,ts src .eslintrc.js",
|
|
15
16
|
"lint:fix": "eslint --ext js,ts src .eslintrc.js --fix",
|
|
16
17
|
"denoify": "rimraf deno_dist && denoify && rimraf 'deno_dist/**/*.test.ts'",
|
|
@@ -23,10 +24,14 @@
|
|
|
23
24
|
".": "./dist/index.js",
|
|
24
25
|
"./basic-auth": "./dist/middleware/basic-auth/index.js",
|
|
25
26
|
"./bearer-auth": "./dist/middleware/bearer-auth/index.js",
|
|
27
|
+
"./cache": "./dist/middleware/cache/index.js",
|
|
28
|
+
"./compress": "./dist/middleware/compress/index.js",
|
|
26
29
|
"./cors": "./dist/middleware/cors/index.js",
|
|
27
30
|
"./etag": "./dist/middleware/etag/index.js",
|
|
28
31
|
"./html": "./dist/middleware/html/index.js",
|
|
29
32
|
"./jsx": "./dist/middleware/jsx/index.js",
|
|
33
|
+
"./jsx/jsx-dev-runtime": "./dist/middleware/jsx/jsx-dev-runtime.js",
|
|
34
|
+
"./jsx/jsx-runtime": "./dist/middleware/jsx/jsx-runtime.js",
|
|
30
35
|
"./jwt": "./dist/middleware/jwt/index.js",
|
|
31
36
|
"./logger": "./dist/middleware/logger/index.js",
|
|
32
37
|
"./powered-by": "./dist/middleware/powered-by/index.js",
|
|
@@ -47,8 +52,11 @@
|
|
|
47
52
|
"bearer-auth": [
|
|
48
53
|
"./dist/middleware/bearer-auth"
|
|
49
54
|
],
|
|
50
|
-
"
|
|
51
|
-
"./dist/middleware/
|
|
55
|
+
"cache": [
|
|
56
|
+
"./dist/middleware/cache"
|
|
57
|
+
],
|
|
58
|
+
"compress": [
|
|
59
|
+
"./dist/middleware/compress"
|
|
52
60
|
],
|
|
53
61
|
"cors": [
|
|
54
62
|
"./dist/middleware/cors"
|
|
@@ -62,6 +70,12 @@
|
|
|
62
70
|
"jsx": [
|
|
63
71
|
"./dist/middleware/jsx"
|
|
64
72
|
],
|
|
73
|
+
"jsx-runtime": [
|
|
74
|
+
"./dist/middleware/jsx/jsx-runtime.d.ts"
|
|
75
|
+
],
|
|
76
|
+
"jsx-dev-runtime": [
|
|
77
|
+
"./dist/middleware/jsx/jsx-dev-runtime.d.ts"
|
|
78
|
+
],
|
|
65
79
|
"jwt": [
|
|
66
80
|
"./dist/middleware/jwt"
|
|
67
81
|
],
|
|
@@ -126,7 +140,6 @@
|
|
|
126
140
|
"@cloudflare/workers-types": "^3.7.1",
|
|
127
141
|
"@types/crypto-js": "^4.1.1",
|
|
128
142
|
"@types/jest": "^27.4.1",
|
|
129
|
-
"@types/mustache": "^4.1.2",
|
|
130
143
|
"@types/node": "^17.0.29",
|
|
131
144
|
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
|
132
145
|
"@typescript-eslint/parser": "^5.21.0",
|
|
@@ -143,7 +156,6 @@
|
|
|
143
156
|
"form-data": "^4.0.0",
|
|
144
157
|
"jest": "27.5.1",
|
|
145
158
|
"jest-environment-miniflare": "^2.6.0",
|
|
146
|
-
"mustache": "^4.2.0",
|
|
147
159
|
"np": "^7.6.2",
|
|
148
160
|
"prettier": "^2.6.2",
|
|
149
161
|
"rimraf": "^3.0.2",
|