hono 4.2.3 → 4.2.5
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/aws-lambda/handler.js +13 -4
- package/dist/adapter/cloudflare-workers/utils.js +1 -1
- package/dist/cjs/adapter/aws-lambda/handler.js +13 -4
- package/dist/cjs/adapter/cloudflare-workers/utils.js +1 -1
- package/dist/cjs/client/client.js +14 -3
- package/dist/cjs/client/utils.js +3 -0
- package/dist/cjs/helper/ssg/ssg.js +1 -1
- package/dist/cjs/helper/testing/index.js +1 -1
- package/dist/cjs/jsx/dom/render.js +1 -1
- package/dist/cjs/jsx/streaming.js +37 -27
- package/dist/cjs/middleware/serve-static/index.js +1 -1
- package/dist/cjs/router/trie-router/node.js +0 -4
- package/dist/cjs/utils/jwt/jwt.js +1 -1
- package/dist/client/client.js +14 -3
- package/dist/client/utils.js +3 -0
- package/dist/helper/ssg/ssg.js +1 -1
- package/dist/helper/testing/index.js +1 -1
- package/dist/jsx/dom/render.js +1 -1
- package/dist/jsx/streaming.js +37 -27
- package/dist/middleware/serve-static/index.js +1 -1
- package/dist/router/trie-router/node.js +0 -4
- package/dist/types/adapter/aws-lambda/handler.d.ts +3 -1
- package/dist/types/jsx/streaming.d.ts +1 -1
- package/dist/types/utils/jwt/jwt.d.ts +1 -1
- package/dist/types/validator/validator.d.ts +2 -2
- package/dist/utils/jwt/jwt.js +1 -1
- package/package.json +1 -1
|
@@ -77,15 +77,24 @@ var createResult = async (event, res) => {
|
|
|
77
77
|
};
|
|
78
78
|
var createRequest = (event) => {
|
|
79
79
|
const queryString = extractQueryString(event);
|
|
80
|
-
const domainName = event.requestContext && "domainName" in event.requestContext ? event.requestContext.domainName : event.headers["host"];
|
|
80
|
+
const domainName = event.requestContext && "domainName" in event.requestContext ? event.requestContext.domainName : event.headers?.["host"] ?? event.multiValueHeaders?.["host"]?.[0];
|
|
81
81
|
const path = isProxyEventV2(event) ? event.rawPath : event.path;
|
|
82
82
|
const urlPath = `https://${domainName}${path}`;
|
|
83
83
|
const url = queryString ? `${urlPath}?${queryString}` : urlPath;
|
|
84
84
|
const headers = new Headers();
|
|
85
85
|
getCookies(event, headers);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
if (event.headers) {
|
|
87
|
+
for (const [k, v] of Object.entries(event.headers)) {
|
|
88
|
+
if (v) {
|
|
89
|
+
headers.set(k, v);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (event.multiValueHeaders) {
|
|
94
|
+
for (const [k, values] of Object.entries(event.multiValueHeaders)) {
|
|
95
|
+
if (values) {
|
|
96
|
+
values.forEach((v) => headers.append(k, v));
|
|
97
|
+
}
|
|
89
98
|
}
|
|
90
99
|
}
|
|
91
100
|
const method = isProxyEventV2(event) ? event.requestContext.http.method : event.httpMethod;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/adapter/cloudflare-workers/utils.ts
|
|
2
2
|
var getContentFromKVAsset = async (path, options) => {
|
|
3
|
-
let ASSET_MANIFEST
|
|
3
|
+
let ASSET_MANIFEST;
|
|
4
4
|
if (options && options.manifest) {
|
|
5
5
|
if (typeof options.manifest === "string") {
|
|
6
6
|
ASSET_MANIFEST = JSON.parse(options.manifest);
|
|
@@ -108,15 +108,24 @@ const createResult = async (event, res) => {
|
|
|
108
108
|
};
|
|
109
109
|
const createRequest = (event) => {
|
|
110
110
|
const queryString = extractQueryString(event);
|
|
111
|
-
const domainName = event.requestContext && "domainName" in event.requestContext ? event.requestContext.domainName : event.headers["host"];
|
|
111
|
+
const domainName = event.requestContext && "domainName" in event.requestContext ? event.requestContext.domainName : event.headers?.["host"] ?? event.multiValueHeaders?.["host"]?.[0];
|
|
112
112
|
const path = isProxyEventV2(event) ? event.rawPath : event.path;
|
|
113
113
|
const urlPath = `https://${domainName}${path}`;
|
|
114
114
|
const url = queryString ? `${urlPath}?${queryString}` : urlPath;
|
|
115
115
|
const headers = new Headers();
|
|
116
116
|
getCookies(event, headers);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
if (event.headers) {
|
|
118
|
+
for (const [k, v] of Object.entries(event.headers)) {
|
|
119
|
+
if (v) {
|
|
120
|
+
headers.set(k, v);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (event.multiValueHeaders) {
|
|
125
|
+
for (const [k, values] of Object.entries(event.multiValueHeaders)) {
|
|
126
|
+
if (values) {
|
|
127
|
+
values.forEach((v) => headers.append(k, v));
|
|
128
|
+
}
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
131
|
const method = isProxyEventV2(event) ? event.requestContext.http.method : event.httpMethod;
|
|
@@ -22,7 +22,7 @@ __export(utils_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(utils_exports);
|
|
24
24
|
const getContentFromKVAsset = async (path, options) => {
|
|
25
|
-
let ASSET_MANIFEST
|
|
25
|
+
let ASSET_MANIFEST;
|
|
26
26
|
if (options && options.manifest) {
|
|
27
27
|
if (typeof options.manifest === "string") {
|
|
28
28
|
ASSET_MANIFEST = JSON.parse(options.manifest);
|
|
@@ -85,7 +85,6 @@ class ClientRequestImpl {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
let methodUpperCase = this.method.toUpperCase();
|
|
88
|
-
let setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
89
88
|
const headerValues = {
|
|
90
89
|
...args?.header ?? {},
|
|
91
90
|
...typeof opt?.headers === "function" ? await opt.headers() : opt?.headers ? opt.headers : {}
|
|
@@ -108,7 +107,7 @@ class ClientRequestImpl {
|
|
|
108
107
|
url = url + "?" + this.queryParams.toString();
|
|
109
108
|
}
|
|
110
109
|
methodUpperCase = this.method.toUpperCase();
|
|
111
|
-
setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
110
|
+
const setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
112
111
|
return (opt?.fetch || fetch)(url, {
|
|
113
112
|
body: setBody ? this.rBody : void 0,
|
|
114
113
|
method: methodUpperCase,
|
|
@@ -116,8 +115,20 @@ class ClientRequestImpl {
|
|
|
116
115
|
});
|
|
117
116
|
};
|
|
118
117
|
}
|
|
119
|
-
const hc = (baseUrl, options) => createProxy((opts)
|
|
118
|
+
const hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
|
|
120
119
|
const parts = [...opts.path];
|
|
120
|
+
if (parts[parts.length - 1] === "toString") {
|
|
121
|
+
if (parts[parts.length - 2] === "name") {
|
|
122
|
+
return parts[parts.length - 3] || "";
|
|
123
|
+
}
|
|
124
|
+
return proxyCallback.toString();
|
|
125
|
+
}
|
|
126
|
+
if (parts[parts.length - 1] === "valueOf") {
|
|
127
|
+
if (parts[parts.length - 2] === "name") {
|
|
128
|
+
return parts[parts.length - 3] || "";
|
|
129
|
+
}
|
|
130
|
+
return proxyCallback;
|
|
131
|
+
}
|
|
121
132
|
let method = "";
|
|
122
133
|
if (/^\$/.test(parts[parts.length - 1])) {
|
|
123
134
|
const last = parts.pop();
|
package/dist/cjs/client/utils.js
CHANGED
|
@@ -47,6 +47,9 @@ const replaceUrlProtocol = (urlString, protocol) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
const removeIndexString = (urlSting) => {
|
|
50
|
+
if (/^https?:\/\/[^\/]+?\/index$/.test(urlSting)) {
|
|
51
|
+
return urlSting.replace(/\/index$/, "/");
|
|
52
|
+
}
|
|
50
53
|
return urlSting.replace(/\/index$/, "");
|
|
51
54
|
};
|
|
52
55
|
function isObject(item) {
|
|
@@ -165,7 +165,7 @@ const saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
|
|
|
165
165
|
return filePath;
|
|
166
166
|
};
|
|
167
167
|
const toSSG = async (app, fs, options) => {
|
|
168
|
-
let result
|
|
168
|
+
let result;
|
|
169
169
|
const getInfoPromises = [];
|
|
170
170
|
const savePromises = [];
|
|
171
171
|
try {
|
|
@@ -26,7 +26,7 @@ const testClient = (app, Env, executionCtx) => {
|
|
|
26
26
|
const customFetch = (input, init) => {
|
|
27
27
|
return app.request(input, init, Env, executionCtx);
|
|
28
28
|
};
|
|
29
|
-
return (0, import_client.hc)("", { fetch: customFetch });
|
|
29
|
+
return (0, import_client.hc)("http://localhost", { fetch: customFetch });
|
|
30
30
|
};
|
|
31
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
32
|
0 && (module.exports = {
|
|
@@ -40,7 +40,7 @@ const buildDataStack = [];
|
|
|
40
40
|
let nameSpaceContext = void 0;
|
|
41
41
|
const isNodeString = (node) => Array.isArray(node);
|
|
42
42
|
const getEventSpec = (key) => {
|
|
43
|
-
const match = key.match(/^on([A-Z][a-zA-Z]+?)(
|
|
43
|
+
const match = key.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);
|
|
44
44
|
if (match) {
|
|
45
45
|
const [, eventName, capture] = match;
|
|
46
46
|
return [(eventAliasMap[eventName] || eventName).toLowerCase(), !!capture];
|
|
@@ -110,36 +110,46 @@ d.replaceWith(c.content)
|
|
|
110
110
|
};
|
|
111
111
|
Suspense[import_constants.DOM_RENDERER] = import_components2.Suspense;
|
|
112
112
|
const textEncoder = new TextEncoder();
|
|
113
|
-
const renderToReadableStream = (str) => {
|
|
113
|
+
const renderToReadableStream = (str, onError = console.trace) => {
|
|
114
114
|
const reader = new ReadableStream({
|
|
115
115
|
async start(controller) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
controller.enqueue(textEncoder.encode(resolved));
|
|
125
|
-
let resolvedCount = 0;
|
|
126
|
-
const callbacks = [];
|
|
127
|
-
const then = (promise) => {
|
|
128
|
-
callbacks.push(
|
|
129
|
-
promise.catch((err) => {
|
|
130
|
-
console.trace(err);
|
|
131
|
-
return "";
|
|
132
|
-
}).then(async (res) => {
|
|
133
|
-
res = await (0, import_html2.resolveCallback)(res, import_html2.HtmlEscapedCallbackPhase.BeforeStream, true, context);
|
|
134
|
-
res.callbacks?.map((c) => c({ phase: import_html2.HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then);
|
|
135
|
-
resolvedCount++;
|
|
136
|
-
controller.enqueue(textEncoder.encode(res));
|
|
137
|
-
})
|
|
116
|
+
try {
|
|
117
|
+
const tmp = str instanceof Promise ? await str : await str.toString();
|
|
118
|
+
const context = typeof tmp === "object" ? tmp : {};
|
|
119
|
+
const resolved = await (0, import_html2.resolveCallback)(
|
|
120
|
+
tmp,
|
|
121
|
+
import_html2.HtmlEscapedCallbackPhase.BeforeStream,
|
|
122
|
+
true,
|
|
123
|
+
context
|
|
138
124
|
);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
125
|
+
controller.enqueue(textEncoder.encode(resolved));
|
|
126
|
+
let resolvedCount = 0;
|
|
127
|
+
const callbacks = [];
|
|
128
|
+
const then = (promise) => {
|
|
129
|
+
callbacks.push(
|
|
130
|
+
promise.catch((err) => {
|
|
131
|
+
console.log(err);
|
|
132
|
+
onError(err);
|
|
133
|
+
return "";
|
|
134
|
+
}).then(async (res) => {
|
|
135
|
+
res = await (0, import_html2.resolveCallback)(
|
|
136
|
+
res,
|
|
137
|
+
import_html2.HtmlEscapedCallbackPhase.BeforeStream,
|
|
138
|
+
true,
|
|
139
|
+
context
|
|
140
|
+
);
|
|
141
|
+
res.callbacks?.map((c) => c({ phase: import_html2.HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then);
|
|
142
|
+
resolvedCount++;
|
|
143
|
+
controller.enqueue(textEncoder.encode(res));
|
|
144
|
+
})
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
resolved.callbacks?.map((c) => c({ phase: import_html2.HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then);
|
|
148
|
+
while (resolvedCount !== callbacks.length) {
|
|
149
|
+
await Promise.all(callbacks);
|
|
150
|
+
}
|
|
151
|
+
} catch (e) {
|
|
152
|
+
onError(e);
|
|
143
153
|
}
|
|
144
154
|
controller.close();
|
|
145
155
|
}
|
|
@@ -47,11 +47,9 @@ class Node {
|
|
|
47
47
|
let curNode = this;
|
|
48
48
|
const parts = (0, import_url.splitRoutingPath)(path);
|
|
49
49
|
const possibleKeys = [];
|
|
50
|
-
const parentPatterns = [];
|
|
51
50
|
for (let i = 0, len = parts.length; i < len; i++) {
|
|
52
51
|
const p = parts[i];
|
|
53
52
|
if (Object.keys(curNode.children).includes(p)) {
|
|
54
|
-
parentPatterns.push(...curNode.patterns);
|
|
55
53
|
curNode = curNode.children[p];
|
|
56
54
|
const pattern2 = (0, import_url.getPattern)(p);
|
|
57
55
|
if (pattern2) {
|
|
@@ -63,10 +61,8 @@ class Node {
|
|
|
63
61
|
const pattern = (0, import_url.getPattern)(p);
|
|
64
62
|
if (pattern) {
|
|
65
63
|
curNode.patterns.push(pattern);
|
|
66
|
-
parentPatterns.push(...curNode.patterns);
|
|
67
64
|
possibleKeys.push(pattern[1]);
|
|
68
65
|
}
|
|
69
|
-
parentPatterns.push(...curNode.patterns);
|
|
70
66
|
curNode = curNode.children[p];
|
|
71
67
|
}
|
|
72
68
|
if (!curNode.methods.length) {
|
|
@@ -34,7 +34,7 @@ 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
|
-
return typeof obj === "object" && obj !== null && "alg" in obj && Object.values(import_jwa.AlgorithmTypes).includes(obj.alg) && "typ" in obj
|
|
37
|
+
return typeof obj === "object" && obj !== null && "alg" in obj && Object.values(import_jwa.AlgorithmTypes).includes(obj.alg) && (!("typ" in obj) || obj.typ === "JWT");
|
|
38
38
|
}
|
|
39
39
|
const sign = async (payload, privateKey, alg = "HS256") => {
|
|
40
40
|
const encodedPayload = encodeJwtPart(payload);
|
package/dist/client/client.js
CHANGED
|
@@ -69,7 +69,6 @@ var ClientRequestImpl = class {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
let methodUpperCase = this.method.toUpperCase();
|
|
72
|
-
let setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
73
72
|
const headerValues = {
|
|
74
73
|
...args?.header ?? {},
|
|
75
74
|
...typeof opt?.headers === "function" ? await opt.headers() : opt?.headers ? opt.headers : {}
|
|
@@ -92,7 +91,7 @@ var ClientRequestImpl = class {
|
|
|
92
91
|
url = url + "?" + this.queryParams.toString();
|
|
93
92
|
}
|
|
94
93
|
methodUpperCase = this.method.toUpperCase();
|
|
95
|
-
setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
94
|
+
const setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
96
95
|
return (opt?.fetch || fetch)(url, {
|
|
97
96
|
body: setBody ? this.rBody : void 0,
|
|
98
97
|
method: methodUpperCase,
|
|
@@ -100,8 +99,20 @@ var ClientRequestImpl = class {
|
|
|
100
99
|
});
|
|
101
100
|
};
|
|
102
101
|
};
|
|
103
|
-
var hc = (baseUrl, options) => createProxy((opts)
|
|
102
|
+
var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
|
|
104
103
|
const parts = [...opts.path];
|
|
104
|
+
if (parts[parts.length - 1] === "toString") {
|
|
105
|
+
if (parts[parts.length - 2] === "name") {
|
|
106
|
+
return parts[parts.length - 3] || "";
|
|
107
|
+
}
|
|
108
|
+
return proxyCallback.toString();
|
|
109
|
+
}
|
|
110
|
+
if (parts[parts.length - 1] === "valueOf") {
|
|
111
|
+
if (parts[parts.length - 2] === "name") {
|
|
112
|
+
return parts[parts.length - 3] || "";
|
|
113
|
+
}
|
|
114
|
+
return proxyCallback;
|
|
115
|
+
}
|
|
105
116
|
let method = "";
|
|
106
117
|
if (/^\$/.test(parts[parts.length - 1])) {
|
|
107
118
|
const last = parts.pop();
|
package/dist/client/utils.js
CHANGED
|
@@ -21,6 +21,9 @@ var replaceUrlProtocol = (urlString, protocol) => {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
var removeIndexString = (urlSting) => {
|
|
24
|
+
if (/^https?:\/\/[^\/]+?\/index$/.test(urlSting)) {
|
|
25
|
+
return urlSting.replace(/\/index$/, "/");
|
|
26
|
+
}
|
|
24
27
|
return urlSting.replace(/\/index$/, "");
|
|
25
28
|
};
|
|
26
29
|
function isObject(item) {
|
package/dist/helper/ssg/ssg.js
CHANGED
|
@@ -140,7 +140,7 @@ var saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
|
|
|
140
140
|
return filePath;
|
|
141
141
|
};
|
|
142
142
|
var toSSG = async (app, fs, options) => {
|
|
143
|
-
let result
|
|
143
|
+
let result;
|
|
144
144
|
const getInfoPromises = [];
|
|
145
145
|
const savePromises = [];
|
|
146
146
|
try {
|
|
@@ -4,7 +4,7 @@ var testClient = (app, Env, executionCtx) => {
|
|
|
4
4
|
const customFetch = (input, init) => {
|
|
5
5
|
return app.request(input, init, Env, executionCtx);
|
|
6
6
|
};
|
|
7
|
-
return hc("", { fetch: customFetch });
|
|
7
|
+
return hc("http://localhost", { fetch: customFetch });
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
10
|
testClient
|
package/dist/jsx/dom/render.js
CHANGED
|
@@ -15,7 +15,7 @@ var buildDataStack = [];
|
|
|
15
15
|
var nameSpaceContext = void 0;
|
|
16
16
|
var isNodeString = (node) => Array.isArray(node);
|
|
17
17
|
var getEventSpec = (key) => {
|
|
18
|
-
const match = key.match(/^on([A-Z][a-zA-Z]+?)(
|
|
18
|
+
const match = key.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);
|
|
19
19
|
if (match) {
|
|
20
20
|
const [, eventName, capture] = match;
|
|
21
21
|
return [(eventAliasMap[eventName] || eventName).toLowerCase(), !!capture];
|
package/dist/jsx/streaming.js
CHANGED
|
@@ -87,36 +87,46 @@ d.replaceWith(c.content)
|
|
|
87
87
|
};
|
|
88
88
|
Suspense[DOM_RENDERER] = SuspenseDomRenderer;
|
|
89
89
|
var textEncoder = new TextEncoder();
|
|
90
|
-
var renderToReadableStream = (str) => {
|
|
90
|
+
var renderToReadableStream = (str, onError = console.trace) => {
|
|
91
91
|
const reader = new ReadableStream({
|
|
92
92
|
async start(controller) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
controller.enqueue(textEncoder.encode(resolved));
|
|
102
|
-
let resolvedCount = 0;
|
|
103
|
-
const callbacks = [];
|
|
104
|
-
const then = (promise) => {
|
|
105
|
-
callbacks.push(
|
|
106
|
-
promise.catch((err) => {
|
|
107
|
-
console.trace(err);
|
|
108
|
-
return "";
|
|
109
|
-
}).then(async (res) => {
|
|
110
|
-
res = await resolveCallback(res, HtmlEscapedCallbackPhase.BeforeStream, true, context);
|
|
111
|
-
res.callbacks?.map((c) => c({ phase: HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then);
|
|
112
|
-
resolvedCount++;
|
|
113
|
-
controller.enqueue(textEncoder.encode(res));
|
|
114
|
-
})
|
|
93
|
+
try {
|
|
94
|
+
const tmp = str instanceof Promise ? await str : await str.toString();
|
|
95
|
+
const context = typeof tmp === "object" ? tmp : {};
|
|
96
|
+
const resolved = await resolveCallback(
|
|
97
|
+
tmp,
|
|
98
|
+
HtmlEscapedCallbackPhase.BeforeStream,
|
|
99
|
+
true,
|
|
100
|
+
context
|
|
115
101
|
);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
102
|
+
controller.enqueue(textEncoder.encode(resolved));
|
|
103
|
+
let resolvedCount = 0;
|
|
104
|
+
const callbacks = [];
|
|
105
|
+
const then = (promise) => {
|
|
106
|
+
callbacks.push(
|
|
107
|
+
promise.catch((err) => {
|
|
108
|
+
console.log(err);
|
|
109
|
+
onError(err);
|
|
110
|
+
return "";
|
|
111
|
+
}).then(async (res) => {
|
|
112
|
+
res = await resolveCallback(
|
|
113
|
+
res,
|
|
114
|
+
HtmlEscapedCallbackPhase.BeforeStream,
|
|
115
|
+
true,
|
|
116
|
+
context
|
|
117
|
+
);
|
|
118
|
+
res.callbacks?.map((c) => c({ phase: HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then);
|
|
119
|
+
resolvedCount++;
|
|
120
|
+
controller.enqueue(textEncoder.encode(res));
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
resolved.callbacks?.map((c) => c({ phase: HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then);
|
|
125
|
+
while (resolvedCount !== callbacks.length) {
|
|
126
|
+
await Promise.all(callbacks);
|
|
127
|
+
}
|
|
128
|
+
} catch (e) {
|
|
129
|
+
onError(e);
|
|
120
130
|
}
|
|
121
131
|
controller.close();
|
|
122
132
|
}
|
|
@@ -25,11 +25,9 @@ var Node = class {
|
|
|
25
25
|
let curNode = this;
|
|
26
26
|
const parts = splitRoutingPath(path);
|
|
27
27
|
const possibleKeys = [];
|
|
28
|
-
const parentPatterns = [];
|
|
29
28
|
for (let i = 0, len = parts.length; i < len; i++) {
|
|
30
29
|
const p = parts[i];
|
|
31
30
|
if (Object.keys(curNode.children).includes(p)) {
|
|
32
|
-
parentPatterns.push(...curNode.patterns);
|
|
33
31
|
curNode = curNode.children[p];
|
|
34
32
|
const pattern2 = getPattern(p);
|
|
35
33
|
if (pattern2) {
|
|
@@ -41,10 +39,8 @@ var Node = class {
|
|
|
41
39
|
const pattern = getPattern(p);
|
|
42
40
|
if (pattern) {
|
|
43
41
|
curNode.patterns.push(pattern);
|
|
44
|
-
parentPatterns.push(...curNode.patterns);
|
|
45
42
|
possibleKeys.push(pattern[1]);
|
|
46
43
|
}
|
|
47
|
-
parentPatterns.push(...curNode.patterns);
|
|
48
44
|
curNode = curNode.children[p];
|
|
49
45
|
}
|
|
50
46
|
if (!curNode.methods.length) {
|
|
@@ -7,6 +7,7 @@ export interface APIGatewayProxyEventV2 {
|
|
|
7
7
|
version: string;
|
|
8
8
|
routeKey: string;
|
|
9
9
|
headers: Record<string, string | undefined>;
|
|
10
|
+
multiValueHeaders?: undefined;
|
|
10
11
|
cookies?: string[];
|
|
11
12
|
rawPath: string;
|
|
12
13
|
rawQueryString: string;
|
|
@@ -44,7 +45,8 @@ export interface APIGatewayProxyEvent {
|
|
|
44
45
|
}
|
|
45
46
|
export interface ALBProxyEvent {
|
|
46
47
|
httpMethod: string;
|
|
47
|
-
headers
|
|
48
|
+
headers?: Record<string, string | undefined>;
|
|
49
|
+
multiValueHeaders?: Record<string, string[] | undefined>;
|
|
48
50
|
path: string;
|
|
49
51
|
body: string | null;
|
|
50
52
|
isBase64Encoded: boolean;
|
|
@@ -13,4 +13,4 @@ export declare const Suspense: FC<PropsWithChildren<{
|
|
|
13
13
|
* `renderToReadableStream()` is an experimental feature.
|
|
14
14
|
* The API might be changed.
|
|
15
15
|
*/
|
|
16
|
-
export declare const renderToReadableStream: (str: HtmlEscapedString | Promise<HtmlEscapedString
|
|
16
|
+
export declare const renderToReadableStream: (str: HtmlEscapedString | Promise<HtmlEscapedString>, onError?: (e: unknown) => void) => ReadableStream<Uint8Array>;
|
|
@@ -3,7 +3,7 @@ import type { SignatureKey } from './jws';
|
|
|
3
3
|
import { type JWTPayload } from './types';
|
|
4
4
|
export interface TokenHeader {
|
|
5
5
|
alg: SignatureAlgorithm;
|
|
6
|
-
typ
|
|
6
|
+
typ?: 'JWT';
|
|
7
7
|
}
|
|
8
8
|
export declare function isTokenHeader(obj: any): obj is TokenHeader;
|
|
9
9
|
export declare const sign: (payload: JWTPayload, privateKey: SignatureKey, alg?: SignatureAlgorithm) => Promise<string>;
|
|
@@ -5,10 +5,10 @@ type ValidationTargetByMethod<M> = M extends 'get' | 'head' ? Exclude<keyof Vali
|
|
|
5
5
|
export type ValidationFunction<InputType, OutputType, E extends Env = {}, P extends string = string> = (value: InputType, c: Context<E, P>) => OutputType | Response | Promise<OutputType> | Promise<Response>;
|
|
6
6
|
type ExcludeResponseType<T> = T extends Response & TypedResponse<any> ? never : T;
|
|
7
7
|
export declare const validator: <InputType, P extends string, M extends string, U extends ValidationTargetByMethod<M>, OutputType = ValidationTargets[U], OutputTypeExcludeResponseType = ExcludeResponseType<OutputType>, P2 extends string = P, V extends {
|
|
8
|
-
in: { [K in U]: K extends "json" ? InputType : { [K2 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K][K2]; }; };
|
|
8
|
+
in: { [K in U]: K extends "json" ? unknown extends InputType ? OutputTypeExcludeResponseType : InputType : { [K2 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K][K2]; }; };
|
|
9
9
|
out: { [K_1 in U]: OutputTypeExcludeResponseType; };
|
|
10
10
|
} = {
|
|
11
|
-
in: { [K_2 in U]: K_2 extends "json" ? InputType : { [K2_1 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K_2][K2_1]; }; };
|
|
11
|
+
in: { [K_2 in U]: K_2 extends "json" ? unknown extends InputType ? OutputTypeExcludeResponseType : InputType : { [K2_1 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K_2][K2_1]; }; };
|
|
12
12
|
out: { [K_3 in U]: OutputTypeExcludeResponseType; };
|
|
13
13
|
}, E extends Env = any>(target: U, validationFunc: ValidationFunction<unknown extends InputType ? ValidationTargets[U] : InputType, OutputType, E, P2>) => MiddlewareHandler<E, P, V>;
|
|
14
14
|
export {};
|
package/dist/utils/jwt/jwt.js
CHANGED
|
@@ -15,7 +15,7 @@ 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
|
-
return typeof obj === "object" && obj !== null && "alg" in obj && Object.values(AlgorithmTypes).includes(obj.alg) && "typ" in obj
|
|
18
|
+
return typeof obj === "object" && obj !== null && "alg" in obj && Object.values(AlgorithmTypes).includes(obj.alg) && (!("typ" in obj) || obj.typ === "JWT");
|
|
19
19
|
}
|
|
20
20
|
var sign = async (payload, privateKey, alg = "HS256") => {
|
|
21
21
|
const encodedPayload = encodeJwtPart(payload);
|