ipx 0.9.8 → 0.9.11
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/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{chunks/middleware.mjs → shared/ipx.72b0591f.mjs} +9 -2
- package/dist/{chunks/middleware.cjs → shared/ipx.eadce322.cjs} +9 -2
- package/package.json +21 -20
package/dist/cli.cjs
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import consola from 'consola';
|
|
2
2
|
import { listen } from 'listhen';
|
|
3
|
-
import { c as createIPX, a as createIPXMiddleware } from './
|
|
3
|
+
import { c as createIPX, a as createIPXMiddleware } from './shared/ipx.72b0591f.mjs';
|
|
4
4
|
import 'defu';
|
|
5
5
|
import 'image-meta';
|
|
6
6
|
import 'ufo';
|
package/dist/index.cjs
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,6 @@ interface IPXHResponse {
|
|
|
49
49
|
body: any;
|
|
50
50
|
}
|
|
51
51
|
declare function handleRequest(req: IPXHRequest, ipx: IPX): Promise<IPXHResponse>;
|
|
52
|
-
declare function createIPXMiddleware(ipx: IPX): (req: IncomingMessage, res: ServerResponse) => void
|
|
52
|
+
declare function createIPXMiddleware(ipx: IPX): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
53
53
|
|
|
54
54
|
export { IPX, IPXCTX, IPXHRequest, IPXHResponse, IPXOptions, ImageMeta, Source, SourceData, SourceFactory, createIPX, createIPXMiddleware, handleRequest };
|
package/dist/index.mjs
CHANGED
|
@@ -106,6 +106,7 @@ function isValidPath(fp) {
|
|
|
106
106
|
return true;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
const HTTP_RE = /^https?:\/\//;
|
|
109
110
|
const createHTTPSource = (options) => {
|
|
110
111
|
const httpsAgent = new https.Agent({ keepAlive: true });
|
|
111
112
|
const httpAgent = new http.Agent({ keepAlive: true });
|
|
@@ -113,7 +114,12 @@ const createHTTPSource = (options) => {
|
|
|
113
114
|
if (typeof _domains === "string") {
|
|
114
115
|
_domains = _domains.split(",").map((s) => s.trim());
|
|
115
116
|
}
|
|
116
|
-
const domains = _domains.map((d) =>
|
|
117
|
+
const domains = _domains.map((d) => {
|
|
118
|
+
if (!HTTP_RE.test(d)) {
|
|
119
|
+
d = "http://" + d;
|
|
120
|
+
}
|
|
121
|
+
return new URL(d).hostname;
|
|
122
|
+
}).filter(Boolean);
|
|
117
123
|
return async (id, reqOptions) => {
|
|
118
124
|
const hostname = new URL(id).hostname;
|
|
119
125
|
if (!hostname) {
|
|
@@ -524,6 +530,7 @@ async function _handleRequest(req, ipx) {
|
|
|
524
530
|
if (format) {
|
|
525
531
|
res.headers["Content-Type"] = `image/${format}`;
|
|
526
532
|
}
|
|
533
|
+
res.headers["Content-Security-Policy"] = "default-src 'none'";
|
|
527
534
|
res.body = data;
|
|
528
535
|
return sanetizeReponse(res);
|
|
529
536
|
}
|
|
@@ -544,7 +551,7 @@ function handleRequest(req, ipx) {
|
|
|
544
551
|
}
|
|
545
552
|
function createIPXMiddleware(ipx) {
|
|
546
553
|
return function IPXMiddleware(req, res) {
|
|
547
|
-
handleRequest({ url: req.url, headers: req.headers }, ipx).then((_res) => {
|
|
554
|
+
return handleRequest({ url: req.url, headers: req.headers }, ipx).then((_res) => {
|
|
548
555
|
res.statusCode = _res.statusCode;
|
|
549
556
|
res.statusMessage = _res.statusMessage;
|
|
550
557
|
for (const name in _res.headers) {
|
|
@@ -117,6 +117,7 @@ function isValidPath(fp) {
|
|
|
117
117
|
return true;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
const HTTP_RE = /^https?:\/\//;
|
|
120
121
|
const createHTTPSource = (options) => {
|
|
121
122
|
const httpsAgent = new https__default.Agent({ keepAlive: true });
|
|
122
123
|
const httpAgent = new http__default.Agent({ keepAlive: true });
|
|
@@ -124,7 +125,12 @@ const createHTTPSource = (options) => {
|
|
|
124
125
|
if (typeof _domains === "string") {
|
|
125
126
|
_domains = _domains.split(",").map((s) => s.trim());
|
|
126
127
|
}
|
|
127
|
-
const domains = _domains.map((d) =>
|
|
128
|
+
const domains = _domains.map((d) => {
|
|
129
|
+
if (!HTTP_RE.test(d)) {
|
|
130
|
+
d = "http://" + d;
|
|
131
|
+
}
|
|
132
|
+
return new URL(d).hostname;
|
|
133
|
+
}).filter(Boolean);
|
|
128
134
|
return async (id, reqOptions) => {
|
|
129
135
|
const hostname = new URL(id).hostname;
|
|
130
136
|
if (!hostname) {
|
|
@@ -535,6 +541,7 @@ async function _handleRequest(req, ipx) {
|
|
|
535
541
|
if (format) {
|
|
536
542
|
res.headers["Content-Type"] = `image/${format}`;
|
|
537
543
|
}
|
|
544
|
+
res.headers["Content-Security-Policy"] = "default-src 'none'";
|
|
538
545
|
res.body = data;
|
|
539
546
|
return sanetizeReponse(res);
|
|
540
547
|
}
|
|
@@ -555,7 +562,7 @@ function handleRequest(req, ipx) {
|
|
|
555
562
|
}
|
|
556
563
|
function createIPXMiddleware(ipx) {
|
|
557
564
|
return function IPXMiddleware(req, res) {
|
|
558
|
-
handleRequest({ url: req.url, headers: req.headers }, ipx).then((_res) => {
|
|
565
|
+
return handleRequest({ url: req.url, headers: req.headers }, ipx).then((_res) => {
|
|
559
566
|
res.statusCode = _res.statusCode;
|
|
560
567
|
res.statusMessage = _res.statusMessage;
|
|
561
568
|
for (const name in _res.headers) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ipx",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.11",
|
|
4
4
|
"repository": "unjs/ipx",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
@@ -19,34 +19,35 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"consola": "^2.15.3",
|
|
22
|
-
"defu": "^6.
|
|
22
|
+
"defu": "^6.1.0",
|
|
23
23
|
"destr": "^1.1.1",
|
|
24
24
|
"etag": "^1.8.1",
|
|
25
25
|
"image-meta": "^0.1.1",
|
|
26
|
-
"listhen": "^0.2.
|
|
26
|
+
"listhen": "^0.2.15",
|
|
27
27
|
"ohmyfetch": "^0.4.18",
|
|
28
|
-
"pathe": "^0.3.
|
|
28
|
+
"pathe": "^0.3.5",
|
|
29
29
|
"sharp": "^0.30.7",
|
|
30
|
-
"ufo": "^0.8.
|
|
31
|
-
"xss": "^1.0.
|
|
30
|
+
"ufo": "^0.8.5",
|
|
31
|
+
"xss": "^1.0.14"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@nuxtjs/eslint-config-typescript": "
|
|
35
|
-
"@types/etag": "
|
|
36
|
-
"@types/is-valid-path": "
|
|
37
|
-
"@types/node-fetch": "
|
|
38
|
-
"@types/sharp": "
|
|
39
|
-
"c8": "
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
34
|
+
"@nuxtjs/eslint-config-typescript": "^11.0.0",
|
|
35
|
+
"@types/etag": "^1.8.1",
|
|
36
|
+
"@types/is-valid-path": "^0.1.0",
|
|
37
|
+
"@types/node-fetch": "^2.6.2",
|
|
38
|
+
"@types/sharp": "^0.30.5",
|
|
39
|
+
"@vitest/coverage-c8": "^0.22.1",
|
|
40
|
+
"changelogen": "^0.3.0",
|
|
41
|
+
"eslint": "^8.23.0",
|
|
42
|
+
"jiti": "^1.14.0",
|
|
43
|
+
"nodemon": "^2.0.19",
|
|
43
44
|
"serve-handler": "^6.1.3",
|
|
44
|
-
"standard-version": "
|
|
45
|
-
"typescript": "
|
|
46
|
-
"unbuild": "
|
|
47
|
-
"vitest": "
|
|
45
|
+
"standard-version": "^9.5.0",
|
|
46
|
+
"typescript": "^4.8.2",
|
|
47
|
+
"unbuild": "^0.8.10",
|
|
48
|
+
"vitest": "^0.22.1"
|
|
48
49
|
},
|
|
49
|
-
"packageManager": "pnpm@7.
|
|
50
|
+
"packageManager": "pnpm@7.9.5",
|
|
50
51
|
"scripts": {
|
|
51
52
|
"build": "unbuild",
|
|
52
53
|
"dev": "nodemon",
|