ipx 2.0.0 → 2.0.2

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  const listhen = require('listhen');
4
4
  const citty = require('citty');
5
5
  const cli = require('listhen/cli');
6
- const nodeFs = require('./shared/ipx.ebaf2d0c.cjs');
6
+ const nodeFs = require('./shared/ipx.cf456174.cjs');
7
7
  require('defu');
8
8
  require('ufo');
9
9
  require('h3');
@@ -15,7 +15,7 @@ require('ofetch');
15
15
  require('pathe');
16
16
 
17
17
  const name = "ipx";
18
- const version = "2.0.0";
18
+ const version = "2.0.2";
19
19
  const description = "High performance, secure and easy-to-use image optimizer.";
20
20
 
21
21
  const serve = citty.defineCommand({
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { listen } from 'listhen';
2
2
  import { defineCommand, runMain } from 'citty';
3
3
  import { getArgs, parseArgs } from 'listhen/cli';
4
- import { c as createIPX, g as ipxFSStorage, i as ipxHttpStorage, e as createIPXNodeServer } from './shared/ipx.4d79c6c9.mjs';
4
+ import { c as createIPX, g as ipxFSStorage, i as ipxHttpStorage, e as createIPXNodeServer } from './shared/ipx.8dfec2f9.mjs';
5
5
  import 'defu';
6
6
  import 'ufo';
7
7
  import 'h3';
@@ -13,7 +13,7 @@ import 'ofetch';
13
13
  import 'pathe';
14
14
 
15
15
  const name = "ipx";
16
- const version = "2.0.0";
16
+ const version = "2.0.2";
17
17
  const description = "High performance, secure and easy-to-use image optimizer.";
18
18
 
19
19
  const serve = defineCommand({
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const nodeFs = require('./shared/ipx.ebaf2d0c.cjs');
3
+ const nodeFs = require('./shared/ipx.cf456174.cjs');
4
4
  require('defu');
5
5
  require('ufo');
6
6
  require('h3');
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { c as createIPX, b as createIPXH3App, a as createIPXH3Handler, e as createIPXNodeServer, f as createIPXPlainServer, d as createIPXWebServer, g as ipxFSStorage, i as ipxHttpStorage } from './shared/ipx.4d79c6c9.mjs';
1
+ export { c as createIPX, b as createIPXH3App, a as createIPXH3Handler, e as createIPXNodeServer, f as createIPXPlainServer, d as createIPXWebServer, g as ipxFSStorage, i as ipxHttpStorage } from './shared/ipx.8dfec2f9.mjs';
2
2
  import 'defu';
3
3
  import 'ufo';
4
4
  import 'h3';
@@ -333,8 +333,7 @@ function createIPX(userOptions) {
333
333
  });
334
334
  const getSVGO = cachedPromise(async () => {
335
335
  const { optimize } = await import('svgo');
336
- const { xss } = await import('../chunks/svgo-xss.mjs');
337
- return { optimize, xss };
336
+ return { optimize };
338
337
  });
339
338
  return function ipx(id, modifiers = {}, opts = {}) {
340
339
  if (!id) {
@@ -409,10 +408,10 @@ function createIPX(userOptions) {
409
408
  meta: imageMeta$1
410
409
  };
411
410
  } else {
412
- const { optimize, xss } = await getSVGO();
411
+ const { optimize } = await getSVGO();
413
412
  const svg = optimize(sourceData.toString("utf8"), {
414
413
  ...options.svgo,
415
- plugins: [xss, ...options.svgo?.plugins || []]
414
+ plugins: ["removeScriptElement", ...options.svgo?.plugins || []]
416
415
  }).data;
417
416
  return {
418
417
  data: svg,
@@ -598,7 +597,7 @@ function safeString(input) {
598
597
 
599
598
  const HTTP_RE = /^https?:\/\//;
600
599
  function ipxHttpStorage(_options = {}) {
601
- const allowAllDomains = getEnv("IPX_HTTP_ALLOW_ALL_DOMAINS") ?? false;
600
+ const allowAllDomains = _options.allowAllDomains ?? getEnv("IPX_HTTP_ALLOW_ALL_DOMAINS") ?? false;
602
601
  let _domains = _options.domains || getEnv("IPX_HTTP_DOMAINS") || [];
603
602
  const defaultMaxAge = _options.maxAge || getEnv("IPX_HTTP_MAX_AGE");
604
603
  const fetchOptions = _options.fetchOptions || getEnv("IPX_HTTP_FETCH_OPTIONS") || {};
@@ -340,8 +340,7 @@ function createIPX(userOptions) {
340
340
  });
341
341
  const getSVGO = cachedPromise(async () => {
342
342
  const { optimize } = await import('svgo');
343
- const { xss } = await import('../chunks/svgo-xss.cjs');
344
- return { optimize, xss };
343
+ return { optimize };
345
344
  });
346
345
  return function ipx(id, modifiers = {}, opts = {}) {
347
346
  if (!id) {
@@ -416,10 +415,10 @@ function createIPX(userOptions) {
416
415
  meta: imageMeta$1
417
416
  };
418
417
  } else {
419
- const { optimize, xss } = await getSVGO();
418
+ const { optimize } = await getSVGO();
420
419
  const svg = optimize(sourceData.toString("utf8"), {
421
420
  ...options.svgo,
422
- plugins: [xss, ...options.svgo?.plugins || []]
421
+ plugins: ["removeScriptElement", ...options.svgo?.plugins || []]
423
422
  }).data;
424
423
  return {
425
424
  data: svg,
@@ -605,7 +604,7 @@ function safeString(input) {
605
604
 
606
605
  const HTTP_RE = /^https?:\/\//;
607
606
  function ipxHttpStorage(_options = {}) {
608
- const allowAllDomains = getEnv("IPX_HTTP_ALLOW_ALL_DOMAINS") ?? false;
607
+ const allowAllDomains = _options.allowAllDomains ?? getEnv("IPX_HTTP_ALLOW_ALL_DOMAINS") ?? false;
609
608
  let _domains = _options.domains || getEnv("IPX_HTTP_DOMAINS") || [];
610
609
  const defaultMaxAge = _options.maxAge || getEnv("IPX_HTTP_MAX_AGE");
611
610
  const fetchOptions = _options.fetchOptions || getEnv("IPX_HTTP_FETCH_OPTIONS") || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ipx",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "repository": "unjs/ipx",
5
5
  "description": "High performance, secure and easy-to-use image optimizer.",
6
6
  "license": "MIT",
@@ -40,8 +40,8 @@
40
40
  "@fastify/accept-negotiator": "^1.1.0",
41
41
  "citty": "^0.1.4",
42
42
  "consola": "^3.2.3",
43
- "defu": "^6.1.2",
44
- "destr": "^2.0.1",
43
+ "defu": "^6.1.3",
44
+ "destr": "^2.0.2",
45
45
  "etag": "^1.8.1",
46
46
  "h3": "^1.8.2",
47
47
  "image-meta": "^0.2.0",
@@ -49,24 +49,24 @@
49
49
  "ofetch": "^1.3.3",
50
50
  "pathe": "^1.1.1",
51
51
  "sharp": "^0.32.6",
52
- "svgo": "^3.0.2",
52
+ "svgo": "^3.0.3",
53
53
  "ufo": "^1.3.1",
54
54
  "unstorage": "^1.9.0",
55
55
  "xss": "^1.0.14"
56
56
  },
57
57
  "devDependencies": {
58
- "@types/etag": "^1.8.1",
59
- "@types/is-valid-path": "^0.1.0",
58
+ "@types/etag": "^1.8.2",
59
+ "@types/is-valid-path": "^0.1.1",
60
60
  "@vitest/coverage-v8": "^0.34.6",
61
61
  "changelogen": "^0.5.5",
62
- "eslint": "^8.51.0",
62
+ "eslint": "^8.53.0",
63
63
  "eslint-config-unjs": "^0.2.1",
64
- "jiti": "^1.20.0",
64
+ "jiti": "^1.21.0",
65
65
  "prettier": "^3.0.3",
66
66
  "serve-handler": "^6.1.5",
67
67
  "typescript": "^5.2.2",
68
68
  "unbuild": "^2.0.0",
69
69
  "vitest": "^0.34.6"
70
70
  },
71
- "packageManager": "pnpm@8.8.0"
71
+ "packageManager": "pnpm@8.10.2"
72
72
  }
@@ -1,103 +0,0 @@
1
- 'use strict';
2
-
3
- const xss = {
4
- name: "removeXSS",
5
- fn() {
6
- return {
7
- element: {
8
- enter: (node, parentNode) => {
9
- if (node.name === "script") {
10
- parentNode.children = parentNode.children.filter(
11
- (child) => child !== node
12
- );
13
- return;
14
- }
15
- for (const event of ALL_EVENTS) {
16
- for (const [name] of Object.entries(node.attributes)) {
17
- if (name === event) {
18
- delete node.attributes[name];
19
- }
20
- }
21
- }
22
- }
23
- }
24
- };
25
- }
26
- };
27
- const ALL_EVENTS = [
28
- "onbegin",
29
- "onend",
30
- "onrepeat",
31
- "onabort",
32
- "onerror",
33
- "onresize",
34
- "onscroll",
35
- "onunload",
36
- "onbegin",
37
- "onend",
38
- "onrepeat",
39
- "oncancel",
40
- "oncanplay",
41
- "oncanplaythrough",
42
- "onchange",
43
- "onclick",
44
- "onclose",
45
- "oncuechange",
46
- "ondblclick",
47
- "ondrag",
48
- "ondragend",
49
- "ondragenter",
50
- "ondragleave",
51
- "ondragover",
52
- "ondragstart",
53
- "ondrop",
54
- "ondurationchange",
55
- "onemptied",
56
- "onended",
57
- "onerror",
58
- "onfocus",
59
- "oninput",
60
- "oninvalid",
61
- "onkeydown",
62
- "onkeypress",
63
- "onkeyup",
64
- "onload",
65
- "onloadeddata",
66
- "onloadedmetadata",
67
- "onloadstart",
68
- "onmousedown",
69
- "onmouseenter",
70
- "onmouseleave",
71
- "onmousemove",
72
- "onmouseout",
73
- "onmouseover",
74
- "onmouseup",
75
- "onmousewheel",
76
- "onpause",
77
- "onplay",
78
- "onplaying",
79
- "onprogress",
80
- "onratechange",
81
- "onreset",
82
- "onresize",
83
- "onscroll",
84
- "onseeked",
85
- "onseeking",
86
- "onselect",
87
- "onshow",
88
- "onstalled",
89
- "onsubmit",
90
- "onsuspend",
91
- "ontimeupdate",
92
- "ontoggle",
93
- "onvolumechange",
94
- "onwaiting",
95
- "oncopy",
96
- "oncut",
97
- "onpaste",
98
- "onactivate",
99
- "onfocusin",
100
- "onfocusout"
101
- ];
102
-
103
- exports.xss = xss;
@@ -1,101 +0,0 @@
1
- const xss = {
2
- name: "removeXSS",
3
- fn() {
4
- return {
5
- element: {
6
- enter: (node, parentNode) => {
7
- if (node.name === "script") {
8
- parentNode.children = parentNode.children.filter(
9
- (child) => child !== node
10
- );
11
- return;
12
- }
13
- for (const event of ALL_EVENTS) {
14
- for (const [name] of Object.entries(node.attributes)) {
15
- if (name === event) {
16
- delete node.attributes[name];
17
- }
18
- }
19
- }
20
- }
21
- }
22
- };
23
- }
24
- };
25
- const ALL_EVENTS = [
26
- "onbegin",
27
- "onend",
28
- "onrepeat",
29
- "onabort",
30
- "onerror",
31
- "onresize",
32
- "onscroll",
33
- "onunload",
34
- "onbegin",
35
- "onend",
36
- "onrepeat",
37
- "oncancel",
38
- "oncanplay",
39
- "oncanplaythrough",
40
- "onchange",
41
- "onclick",
42
- "onclose",
43
- "oncuechange",
44
- "ondblclick",
45
- "ondrag",
46
- "ondragend",
47
- "ondragenter",
48
- "ondragleave",
49
- "ondragover",
50
- "ondragstart",
51
- "ondrop",
52
- "ondurationchange",
53
- "onemptied",
54
- "onended",
55
- "onerror",
56
- "onfocus",
57
- "oninput",
58
- "oninvalid",
59
- "onkeydown",
60
- "onkeypress",
61
- "onkeyup",
62
- "onload",
63
- "onloadeddata",
64
- "onloadedmetadata",
65
- "onloadstart",
66
- "onmousedown",
67
- "onmouseenter",
68
- "onmouseleave",
69
- "onmousemove",
70
- "onmouseout",
71
- "onmouseover",
72
- "onmouseup",
73
- "onmousewheel",
74
- "onpause",
75
- "onplay",
76
- "onplaying",
77
- "onprogress",
78
- "onratechange",
79
- "onreset",
80
- "onresize",
81
- "onscroll",
82
- "onseeked",
83
- "onseeking",
84
- "onselect",
85
- "onshow",
86
- "onstalled",
87
- "onsubmit",
88
- "onsuspend",
89
- "ontimeupdate",
90
- "ontoggle",
91
- "onvolumechange",
92
- "onwaiting",
93
- "oncopy",
94
- "oncut",
95
- "onpaste",
96
- "onactivate",
97
- "onfocusin",
98
- "onfocusout"
99
- ];
100
-
101
- export { xss };