h3 1.6.3 → 1.6.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/index.cjs +12 -5
- package/dist/index.mjs +3 -1
- package/package.json +15 -15
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,11 @@ const crypto = require('uncrypto');
|
|
|
8
8
|
const ironWebcrypto = require('iron-webcrypto');
|
|
9
9
|
const defu = require('defu');
|
|
10
10
|
|
|
11
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
12
|
+
|
|
13
|
+
const destr__default = /*#__PURE__*/_interopDefaultCompat(destr);
|
|
14
|
+
const crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
|
|
15
|
+
|
|
11
16
|
function useBase(base, handler) {
|
|
12
17
|
base = ufo.withoutTrailingSlash(base);
|
|
13
18
|
if (!base) {
|
|
@@ -278,7 +283,9 @@ function readRawBody(event, encoding = "utf8") {
|
|
|
278
283
|
assertMethod(event, PayloadMethods$1);
|
|
279
284
|
const _rawBody = event.node.req[RawBodySymbol] || event.node.req.body;
|
|
280
285
|
if (_rawBody) {
|
|
281
|
-
const promise2 = Promise.resolve(_rawBody)
|
|
286
|
+
const promise2 = Promise.resolve(_rawBody).then(
|
|
287
|
+
(_resolved) => Buffer.isBuffer(_resolved) ? _resolved : Buffer.from(_resolved)
|
|
288
|
+
);
|
|
282
289
|
return encoding ? promise2.then((buff) => buff.toString(encoding)) : promise2;
|
|
283
290
|
}
|
|
284
291
|
if (!Number.parseInt(event.node.req.headers["content-length"] || "")) {
|
|
@@ -319,7 +326,7 @@ async function readBody(event) {
|
|
|
319
326
|
}
|
|
320
327
|
return parsedForm;
|
|
321
328
|
}
|
|
322
|
-
const json =
|
|
329
|
+
const json = destr__default(body);
|
|
323
330
|
event.node.req[ParsedBodySymbol] = json;
|
|
324
331
|
return json;
|
|
325
332
|
}
|
|
@@ -803,7 +810,7 @@ async function getSession(event, config) {
|
|
|
803
810
|
Object.assign(session, unsealed);
|
|
804
811
|
}
|
|
805
812
|
if (!session.id) {
|
|
806
|
-
session.id = (config.crypto ||
|
|
813
|
+
session.id = (config.crypto || crypto__default).randomUUID();
|
|
807
814
|
session.createdAt = Date.now();
|
|
808
815
|
await updateSession(event, config);
|
|
809
816
|
}
|
|
@@ -831,7 +838,7 @@ async function updateSession(event, config, update) {
|
|
|
831
838
|
async function sealSession(event, config) {
|
|
832
839
|
const sessionName = config.name || DEFAULT_NAME;
|
|
833
840
|
const session = event.context.sessions?.[sessionName] || await getSession(event, config);
|
|
834
|
-
const sealed = await ironWebcrypto.seal(config.crypto ||
|
|
841
|
+
const sealed = await ironWebcrypto.seal(config.crypto || crypto__default, session, config.password, {
|
|
835
842
|
...ironWebcrypto.defaults,
|
|
836
843
|
ttl: config.maxAge ? config.maxAge * 1e3 : 0,
|
|
837
844
|
...config.seal
|
|
@@ -840,7 +847,7 @@ async function sealSession(event, config) {
|
|
|
840
847
|
}
|
|
841
848
|
async function unsealSession(_event, config, sealed) {
|
|
842
849
|
const unsealed = await ironWebcrypto.unseal(
|
|
843
|
-
config.crypto ||
|
|
850
|
+
config.crypto || crypto__default,
|
|
844
851
|
sealed,
|
|
845
852
|
config.password,
|
|
846
853
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -276,7 +276,9 @@ function readRawBody(event, encoding = "utf8") {
|
|
|
276
276
|
assertMethod(event, PayloadMethods$1);
|
|
277
277
|
const _rawBody = event.node.req[RawBodySymbol] || event.node.req.body;
|
|
278
278
|
if (_rawBody) {
|
|
279
|
-
const promise2 = Promise.resolve(_rawBody)
|
|
279
|
+
const promise2 = Promise.resolve(_rawBody).then(
|
|
280
|
+
(_resolved) => Buffer.isBuffer(_resolved) ? _resolved : Buffer.from(_resolved)
|
|
281
|
+
);
|
|
280
282
|
return encoding ? promise2.then((buff) => buff.toString(encoding)) : promise2;
|
|
281
283
|
}
|
|
282
284
|
if (!Number.parseInt(event.node.req.headers["content-length"] || "")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "h3",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "Tiny JavaScript Server",
|
|
5
5
|
"repository": "unjs/h3",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,37 +20,37 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"cookie-es": "^0.
|
|
23
|
+
"cookie-es": "^1.0.0",
|
|
24
24
|
"defu": "^6.1.2",
|
|
25
25
|
"destr": "^1.2.2",
|
|
26
|
-
"iron-webcrypto": "^0.
|
|
26
|
+
"iron-webcrypto": "^0.7.0",
|
|
27
27
|
"radix3": "^1.0.1",
|
|
28
|
-
"ufo": "^1.1.
|
|
28
|
+
"ufo": "^1.1.2",
|
|
29
29
|
"uncrypto": "^0.1.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"0x": "^5.5.0",
|
|
33
33
|
"@types/express": "^4.17.17",
|
|
34
|
-
"@types/node": "^
|
|
34
|
+
"@types/node": "^20.0.0",
|
|
35
35
|
"@types/supertest": "^2.0.12",
|
|
36
|
-
"@vitest/coverage-c8": "^0.
|
|
37
|
-
"autocannon": "^7.
|
|
38
|
-
"changelogen": "^0.5.
|
|
36
|
+
"@vitest/coverage-c8": "^0.31.0",
|
|
37
|
+
"autocannon": "^7.11.0",
|
|
38
|
+
"changelogen": "^0.5.3",
|
|
39
39
|
"connect": "^3.7.0",
|
|
40
|
-
"eslint": "^8.
|
|
40
|
+
"eslint": "^8.39.0",
|
|
41
41
|
"eslint-config-unjs": "^0.1.0",
|
|
42
42
|
"express": "^4.18.2",
|
|
43
43
|
"get-port": "^6.1.2",
|
|
44
44
|
"jiti": "^1.18.2",
|
|
45
45
|
"listhen": "^1.0.4",
|
|
46
|
-
"node-fetch-native": "^1.0
|
|
47
|
-
"prettier": "^2.8.
|
|
46
|
+
"node-fetch-native": "^1.1.0",
|
|
47
|
+
"prettier": "^2.8.8",
|
|
48
48
|
"supertest": "^6.3.3",
|
|
49
|
-
"typescript": "^5.0.
|
|
50
|
-
"unbuild": "^1.1
|
|
51
|
-
"vitest": "^0.
|
|
49
|
+
"typescript": "^5.0.4",
|
|
50
|
+
"unbuild": "^1.2.1",
|
|
51
|
+
"vitest": "^0.31.0"
|
|
52
52
|
},
|
|
53
|
-
"packageManager": "pnpm@8.
|
|
53
|
+
"packageManager": "pnpm@8.4.0",
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "unbuild",
|
|
56
56
|
"dev": "vitest",
|