cyberchef 10.22.0 → 10.23.0

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.
Files changed (121) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/CONTRIBUTING.md +37 -0
  3. package/Dockerfile +2 -0
  4. package/Gruntfile.js +0 -12
  5. package/README.md +1 -1
  6. package/babel.config.js +0 -6
  7. package/package.json +63 -62
  8. package/src/core/Chef.mjs +8 -1
  9. package/src/core/Ingredient.mjs +5 -2
  10. package/src/core/Operation.mjs +6 -1
  11. package/src/core/Recipe.mjs +10 -5
  12. package/src/core/config/Categories.json +18 -3
  13. package/src/core/config/OperationConfig.json +22310 -0
  14. package/src/core/config/modules/Bletchley.mjs +28 -0
  15. package/src/core/config/modules/Charts.mjs +24 -0
  16. package/src/core/config/modules/Ciphers.mjs +128 -0
  17. package/src/core/config/modules/Code.mjs +60 -0
  18. package/src/core/config/modules/Compression.mjs +52 -0
  19. package/src/core/config/modules/Crypto.mjs +134 -0
  20. package/src/core/config/modules/Default.mjs +424 -0
  21. package/src/core/config/modules/Diff.mjs +16 -0
  22. package/src/core/config/modules/Encodings.mjs +42 -0
  23. package/src/core/config/modules/Handlebars.mjs +16 -0
  24. package/src/core/config/modules/Hashing.mjs +30 -0
  25. package/src/core/config/modules/Image.mjs +70 -0
  26. package/src/core/config/modules/Jq.mjs +16 -0
  27. package/src/core/config/modules/OCR.mjs +16 -0
  28. package/src/core/config/modules/OpModules.mjs +63 -0
  29. package/src/core/config/modules/PGP.mjs +26 -0
  30. package/src/core/config/modules/Protobuf.mjs +18 -0
  31. package/src/core/config/modules/PublicKey.mjs +36 -0
  32. package/src/core/config/modules/Regex.mjs +40 -0
  33. package/src/core/config/modules/Serialise.mjs +26 -0
  34. package/src/core/config/modules/Shellcode.mjs +18 -0
  35. package/src/core/config/modules/URL.mjs +20 -0
  36. package/src/core/config/modules/UserAgent.mjs +16 -0
  37. package/src/core/config/modules/Yara.mjs +16 -0
  38. package/src/core/lib/AudioBytes.mjs +103 -0
  39. package/src/core/lib/AudioMetaSchema.mjs +82 -0
  40. package/src/core/lib/AudioParsers.mjs +630 -0
  41. package/src/core/lib/BigIntUtils.mjs +73 -0
  42. package/src/core/lib/Modhex.mjs +2 -0
  43. package/src/core/lib/QRCode.mjs +30 -10
  44. package/src/core/lib/RC6.mjs +625 -0
  45. package/src/core/operations/A1Z26CipherDecode.mjs +1 -1
  46. package/src/core/operations/AddTextToImage.mjs +116 -64
  47. package/src/core/operations/BlurImage.mjs +10 -12
  48. package/src/core/operations/ContainImage.mjs +50 -40
  49. package/src/core/operations/ConvertImageFormat.mjs +33 -39
  50. package/src/core/operations/CoverImage.mjs +39 -37
  51. package/src/core/operations/CropImage.mjs +35 -21
  52. package/src/core/operations/DisassembleARM.mjs +193 -0
  53. package/src/core/operations/DitherImage.mjs +8 -8
  54. package/src/core/operations/EscapeUnicodeCharacters.mjs +0 -17
  55. package/src/core/operations/ExtractAudioMetadata.mjs +175 -0
  56. package/src/core/operations/ExtractLSB.mjs +17 -11
  57. package/src/core/operations/ExtractRGBA.mjs +12 -10
  58. package/src/core/operations/FlaskSessionDecode.mjs +80 -0
  59. package/src/core/operations/FlaskSessionSign.mjs +89 -0
  60. package/src/core/operations/FlaskSessionVerify.mjs +136 -0
  61. package/src/core/operations/FlipImage.mjs +14 -10
  62. package/src/core/operations/GenerateImage.mjs +39 -32
  63. package/src/core/operations/ImageBrightnessContrast.mjs +10 -10
  64. package/src/core/operations/ImageFilter.mjs +14 -13
  65. package/src/core/operations/ImageHueSaturationLightness.mjs +22 -20
  66. package/src/core/operations/ImageOpacity.mjs +6 -8
  67. package/src/core/operations/InvertImage.mjs +4 -6
  68. package/src/core/operations/Jq.mjs +12 -4
  69. package/src/core/operations/NormaliseImage.mjs +5 -7
  70. package/src/core/operations/OffsetChecker.mjs +1 -1
  71. package/src/core/operations/ParseEthernetFrame.mjs +112 -0
  72. package/src/core/operations/ParseIPv4Header.mjs +23 -6
  73. package/src/core/operations/ParseQRCode.mjs +13 -13
  74. package/src/core/operations/PseudoRandomIntegerGenerator.mjs +164 -0
  75. package/src/core/operations/RC6Decrypt.mjs +119 -0
  76. package/src/core/operations/RC6Encrypt.mjs +119 -0
  77. package/src/core/operations/RandomizeColourPalette.mjs +11 -11
  78. package/src/core/operations/ResizeImage.mjs +30 -23
  79. package/src/core/operations/RotateImage.mjs +8 -9
  80. package/src/core/operations/SQLBeautify.mjs +21 -3
  81. package/src/core/operations/SharpenImage.mjs +94 -62
  82. package/src/core/operations/SplitColourChannels.mjs +47 -21
  83. package/src/core/operations/TextIntegerConverter.mjs +123 -0
  84. package/src/core/operations/UnescapeUnicodeCharacters.mjs +17 -0
  85. package/src/core/operations/ViewBitPlane.mjs +16 -20
  86. package/src/core/operations/index.mjs +960 -0
  87. package/src/node/index.mjs +2423 -0
  88. package/src/web/HTMLIngredient.mjs +24 -43
  89. package/src/web/Manager.mjs +1 -0
  90. package/src/web/html/index.html +6 -6
  91. package/src/web/static/fonts/bmfonts/Roboto72White.fnt +491 -485
  92. package/src/web/static/fonts/bmfonts/RobotoBlack72White.fnt +494 -488
  93. package/src/web/static/fonts/bmfonts/RobotoMono72White.fnt +110 -103
  94. package/src/web/static/fonts/bmfonts/RobotoSlab72White.fnt +498 -492
  95. package/src/web/stylesheets/layout/_banner.css +30 -0
  96. package/src/web/stylesheets/layout/_modals.css +5 -0
  97. package/src/web/stylesheets/utils/_overrides.css +7 -0
  98. package/src/web/waiters/ControlsWaiter.mjs +82 -0
  99. package/src/web/waiters/InputWaiter.mjs +12 -6
  100. package/src/web/waiters/RecipeWaiter.mjs +2 -2
  101. package/tests/browser/02_ops.js +23 -3
  102. package/tests/node/index.mjs +1 -0
  103. package/tests/node/tests/lib/BigIntUtils.mjs +150 -0
  104. package/tests/node/tests/operations.mjs +9 -7
  105. package/tests/operations/index.mjs +8 -0
  106. package/tests/operations/tests/A1Z26CipherDecode.mjs +33 -0
  107. package/tests/operations/tests/DisassembleARM.mjs +377 -0
  108. package/tests/operations/tests/ExtractAudioMetadata.mjs +287 -0
  109. package/tests/operations/tests/FlaskSession.mjs +246 -0
  110. package/tests/operations/tests/GenerateQRCode.mjs +67 -0
  111. package/tests/operations/tests/JWTSign.mjs +83 -8
  112. package/tests/operations/tests/Jq.mjs +32 -0
  113. package/tests/operations/tests/Modhex.mjs +20 -0
  114. package/tests/operations/tests/ParseEthernetFrame.mjs +45 -0
  115. package/tests/operations/tests/RC6.mjs +487 -0
  116. package/tests/operations/tests/SQLBeautify.mjs +54 -0
  117. package/tests/operations/tests/TextIntegerConverter.mjs +199 -0
  118. package/tests/samples/Audio.mjs +73 -0
  119. package/tests/samples/Images.mjs +0 -12
  120. package/webpack.config.js +10 -7
  121. package/src/core/lib/ImageManipulation.mjs +0 -251
@@ -9,13 +9,12 @@ import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
11
  import { isWorkerEnvironment } from "../Utils.mjs";
12
- import Jimp from "jimp/es/index.js";
12
+ import { Jimp, JimpMime } from "jimp";
13
13
 
14
14
  /**
15
15
  * Flip Image operation
16
16
  */
17
17
  class FlipImage extends Operation {
18
-
19
18
  /**
20
19
  * FlipImage constructor
21
20
  */
@@ -33,8 +32,8 @@ class FlipImage extends Operation {
33
32
  {
34
33
  name: "Axis",
35
34
  type: "option",
36
- value: ["Horizontal", "Vertical"]
37
- }
35
+ value: ["Horizontal", "Vertical"],
36
+ },
38
37
  ];
39
38
  }
40
39
 
@@ -60,18 +59,24 @@ class FlipImage extends Operation {
60
59
  self.sendStatusMessage("Flipping image...");
61
60
  switch (flipAxis) {
62
61
  case "Horizontal":
63
- image.flip(true, false);
62
+ image.flip({
63
+ horizontal: true,
64
+ vertical: false,
65
+ });
64
66
  break;
65
67
  case "Vertical":
66
- image.flip(false, true);
68
+ image.flip({
69
+ horizontal: false,
70
+ vertical: true,
71
+ });
67
72
  break;
68
73
  }
69
74
 
70
75
  let imageBuffer;
71
- if (image.getMIME() === "image/gif") {
72
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
76
+ if (image.mime === "image/gif") {
77
+ imageBuffer = await image.getBuffer(JimpMime.png);
73
78
  } else {
74
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
79
+ imageBuffer = await image.getBuffer(image.mime);
75
80
  }
76
81
  return imageBuffer.buffer;
77
82
  } catch (err) {
@@ -95,7 +100,6 @@ class FlipImage extends Operation {
95
100
 
96
101
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
97
102
  }
98
-
99
103
  }
100
104
 
101
105
  export default FlipImage;
@@ -7,16 +7,15 @@
7
7
  import Operation from "../Operation.mjs";
8
8
  import OperationError from "../errors/OperationError.mjs";
9
9
  import Utils from "../Utils.mjs";
10
- import {isImage} from "../lib/FileType.mjs";
11
- import {toBase64} from "../lib/Base64.mjs";
12
- import {isWorkerEnvironment} from "../Utils.mjs";
13
- import Jimp from "jimp/es/index.js";
10
+ import { isImage } from "../lib/FileType.mjs";
11
+ import { toBase64 } from "../lib/Base64.mjs";
12
+ import { isWorkerEnvironment } from "../Utils.mjs";
13
+ import { Jimp, JimpMime, ResizeStrategy, rgbaToInt } from "jimp";
14
14
 
15
15
  /**
16
16
  * Generate Image operation
17
17
  */
18
18
  class GenerateImage extends Operation {
19
-
20
19
  /**
21
20
  * GenerateImage constructor
22
21
  */
@@ -25,27 +24,28 @@ class GenerateImage extends Operation {
25
24
 
26
25
  this.name = "Generate Image";
27
26
  this.module = "Image";
28
- this.description = "Generates an image using the input as pixel values.";
27
+ this.description =
28
+ "Generates an image using the input as pixel values.";
29
29
  this.infoURL = "";
30
30
  this.inputType = "ArrayBuffer";
31
31
  this.outputType = "ArrayBuffer";
32
32
  this.presentType = "html";
33
33
  this.args = [
34
34
  {
35
- "name": "Mode",
36
- "type": "option",
37
- "value": ["Greyscale", "RG", "RGB", "RGBA", "Bits"]
35
+ name: "Mode",
36
+ type: "option",
37
+ value: ["Greyscale", "RG", "RGB", "RGBA", "Bits"],
38
38
  },
39
39
  {
40
- "name": "Pixel Scale Factor",
41
- "type": "number",
42
- "value": 8,
40
+ name: "Pixel Scale Factor",
41
+ type: "number",
42
+ value: 8,
43
43
  },
44
44
  {
45
- "name": "Pixels per row",
46
- "type": "number",
47
- "value": 64,
48
- }
45
+ name: "Pixels per row",
46
+ type: "number",
47
+ value: 64,
48
+ },
49
49
  ];
50
50
  }
51
51
 
@@ -67,21 +67,23 @@ class GenerateImage extends Operation {
67
67
  }
68
68
 
69
69
  const bytePerPixelMap = {
70
- "Greyscale": 1,
71
- "RG": 2,
72
- "RGB": 3,
73
- "RGBA": 4,
74
- "Bits": 1/8,
70
+ Greyscale: 1,
71
+ RG: 2,
72
+ RGB: 3,
73
+ RGBA: 4,
74
+ Bits: 1 / 8,
75
75
  };
76
76
 
77
77
  const bytesPerPixel = bytePerPixelMap[mode];
78
78
 
79
- if (bytesPerPixel > 0 && input.length % bytesPerPixel !== 0) {
80
- throw new OperationError(`Number of bytes is not a divisor of ${bytesPerPixel}`);
79
+ if (bytesPerPixel > 0 && input.length % bytesPerPixel !== 0) {
80
+ throw new OperationError(
81
+ `Number of bytes is not a divisor of ${bytesPerPixel}`,
82
+ );
81
83
  }
82
84
 
83
85
  const height = Math.ceil(input.length / bytesPerPixel / width);
84
- const image = await new Jimp(width, height, (err, image) => {});
86
+ const image = new Jimp({ width, height });
85
87
 
86
88
  if (isWorkerEnvironment())
87
89
  self.sendStatusMessage("Generating image from data...");
@@ -94,8 +96,8 @@ class GenerateImage extends Operation {
94
96
  const x = index % width;
95
97
  const y = Math.floor(index / width);
96
98
 
97
- const value = curByte[k] === "0" ? 0xFF : 0x00;
98
- const pixel = Jimp.rgbaToInt(value, value, value, 0xFF);
99
+ const value = curByte[k] === "0" ? 0xff : 0x00;
100
+ const pixel = rgbaToInt(value, value, value, 0xff);
99
101
  image.setPixelColor(pixel, x, y);
100
102
  }
101
103
  }
@@ -109,7 +111,7 @@ class GenerateImage extends Operation {
109
111
  let red = 0x00;
110
112
  let green = 0x00;
111
113
  let blue = 0x00;
112
- let alpha = 0xFF;
114
+ let alpha = 0xff;
113
115
 
114
116
  switch (mode) {
115
117
  case "Greyscale":
@@ -139,10 +141,12 @@ class GenerateImage extends Operation {
139
141
  }
140
142
 
141
143
  try {
142
- const pixel = Jimp.rgbaToInt(red, green, blue, alpha);
144
+ const pixel = rgbaToInt(red, green, blue, alpha);
143
145
  image.setPixelColor(pixel, x, y);
144
146
  } catch (err) {
145
- throw new OperationError(`Error while generating image from pixel values. (${err})`);
147
+ throw new OperationError(
148
+ `Error while generating image from pixel values. (${err})`,
149
+ );
146
150
  }
147
151
  }
148
152
  }
@@ -151,11 +155,15 @@ class GenerateImage extends Operation {
151
155
  if (isWorkerEnvironment())
152
156
  self.sendStatusMessage("Scaling image...");
153
157
 
154
- image.scaleToFit(width*scale, height*scale, Jimp.RESIZE_NEAREST_NEIGHBOR);
158
+ image.scaleToFit({
159
+ w: width * scale,
160
+ h: height * scale,
161
+ mode: ResizeStrategy.NEAREST_NEIGHBOR,
162
+ });
155
163
  }
156
164
 
157
165
  try {
158
- const imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
166
+ const imageBuffer = await image.getBuffer(JimpMime.png);
159
167
  return imageBuffer.buffer;
160
168
  } catch (err) {
161
169
  throw new OperationError(`Error generating image. (${err})`);
@@ -178,7 +186,6 @@ class GenerateImage extends Operation {
178
186
 
179
187
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
180
188
  }
181
-
182
189
  }
183
190
 
184
191
  export default GenerateImage;
@@ -9,13 +9,12 @@ import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
11
  import { isWorkerEnvironment } from "../Utils.mjs";
12
- import Jimp from "jimp/es/index.js";
12
+ import { Jimp, JimpMime } from "jimp";
13
13
 
14
14
  /**
15
15
  * Image Brightness / Contrast operation
16
16
  */
17
17
  class ImageBrightnessContrast extends Operation {
18
-
19
18
  /**
20
19
  * ImageBrightnessContrast constructor
21
20
  */
@@ -35,15 +34,15 @@ class ImageBrightnessContrast extends Operation {
35
34
  type: "number",
36
35
  value: 0,
37
36
  min: -100,
38
- max: 100
37
+ max: 100,
39
38
  },
40
39
  {
41
40
  name: "Contrast",
42
41
  type: "number",
43
42
  value: 0,
44
43
  min: -100,
45
- max: 100
46
- }
44
+ max: 100,
45
+ },
47
46
  ];
48
47
  }
49
48
 
@@ -77,14 +76,16 @@ class ImageBrightnessContrast extends Operation {
77
76
  }
78
77
 
79
78
  let imageBuffer;
80
- if (image.getMIME() === "image/gif") {
81
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
79
+ if (image.mime === "image/gif") {
80
+ imageBuffer = await image.getBuffer(JimpMime.png);
82
81
  } else {
83
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
82
+ imageBuffer = await image.getBuffer(image.mime);
84
83
  }
85
84
  return imageBuffer.buffer;
86
85
  } catch (err) {
87
- throw new OperationError(`Error adjusting image brightness or contrast. (${err})`);
86
+ throw new OperationError(
87
+ `Error adjusting image brightness or contrast. (${err})`,
88
+ );
88
89
  }
89
90
  }
90
91
 
@@ -104,7 +105,6 @@ class ImageBrightnessContrast extends Operation {
104
105
 
105
106
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
106
107
  }
107
-
108
108
  }
109
109
 
110
110
  export default ImageBrightnessContrast;
@@ -9,13 +9,12 @@ import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
11
  import { isWorkerEnvironment } from "../Utils.mjs";
12
- import Jimp from "jimp/es/index.js";
12
+ import { Jimp, JimpMime } from "jimp";
13
13
 
14
14
  /**
15
15
  * Image Filter operation
16
16
  */
17
17
  class ImageFilter extends Operation {
18
-
19
18
  /**
20
19
  * ImageFilter constructor
21
20
  */
@@ -33,11 +32,8 @@ class ImageFilter extends Operation {
33
32
  {
34
33
  name: "Filter type",
35
34
  type: "option",
36
- value: [
37
- "Greyscale",
38
- "Sepia"
39
- ]
40
- }
35
+ value: ["Greyscale", "Sepia"],
36
+ },
41
37
  ];
42
38
  }
43
39
 
@@ -60,7 +56,11 @@ class ImageFilter extends Operation {
60
56
  }
61
57
  try {
62
58
  if (isWorkerEnvironment())
63
- self.sendStatusMessage("Applying " + filterType.toLowerCase() + " filter to image...");
59
+ self.sendStatusMessage(
60
+ "Applying " +
61
+ filterType.toLowerCase() +
62
+ " filter to image...",
63
+ );
64
64
  if (filterType === "Greyscale") {
65
65
  image.greyscale();
66
66
  } else {
@@ -68,14 +68,16 @@ class ImageFilter extends Operation {
68
68
  }
69
69
 
70
70
  let imageBuffer;
71
- if (image.getMIME() === "image/gif") {
72
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
71
+ if (image.mime === "image/gif") {
72
+ imageBuffer = await image.getBuffer(JimpMime.png);
73
73
  } else {
74
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
74
+ imageBuffer = await image.getBuffer(image.mime);
75
75
  }
76
76
  return imageBuffer.buffer;
77
77
  } catch (err) {
78
- throw new OperationError(`Error applying filter to image. (${err})`);
78
+ throw new OperationError(
79
+ `Error applying filter to image. (${err})`,
80
+ );
79
81
  }
80
82
  }
81
83
 
@@ -95,7 +97,6 @@ class ImageFilter extends Operation {
95
97
 
96
98
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
97
99
  }
98
-
99
100
  }
100
101
 
101
102
  export default ImageFilter;
@@ -9,13 +9,12 @@ import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
11
  import { isWorkerEnvironment } from "../Utils.mjs";
12
- import Jimp from "jimp/es/index.js";
12
+ import { Jimp, JimpMime } from "jimp";
13
13
 
14
14
  /**
15
15
  * Image Hue/Saturation/Lightness operation
16
16
  */
17
17
  class ImageHueSaturationLightness extends Operation {
18
-
19
18
  /**
20
19
  * ImageHueSaturationLightness constructor
21
20
  */
@@ -24,7 +23,8 @@ class ImageHueSaturationLightness extends Operation {
24
23
 
25
24
  this.name = "Image Hue/Saturation/Lightness";
26
25
  this.module = "Image";
27
- this.description = "Adjusts the hue / saturation / lightness (HSL) values of an image.";
26
+ this.description =
27
+ "Adjusts the hue / saturation / lightness (HSL) values of an image.";
28
28
  this.infoURL = "";
29
29
  this.inputType = "ArrayBuffer";
30
30
  this.outputType = "ArrayBuffer";
@@ -35,22 +35,22 @@ class ImageHueSaturationLightness extends Operation {
35
35
  type: "number",
36
36
  value: 0,
37
37
  min: -360,
38
- max: 360
38
+ max: 360,
39
39
  },
40
40
  {
41
41
  name: "Saturation",
42
42
  type: "number",
43
43
  value: 0,
44
44
  min: -100,
45
- max: 100
45
+ max: 100,
46
46
  },
47
47
  {
48
48
  name: "Lightness",
49
49
  type: "number",
50
50
  value: 0,
51
51
  min: -100,
52
- max: 100
53
- }
52
+ max: 100,
53
+ },
54
54
  ];
55
55
  }
56
56
 
@@ -76,43 +76,45 @@ class ImageHueSaturationLightness extends Operation {
76
76
  if (hue !== 0) {
77
77
  if (isWorkerEnvironment())
78
78
  self.sendStatusMessage("Changing image hue...");
79
- image.colour([
79
+ image.color([
80
80
  {
81
81
  apply: "hue",
82
- params: [hue]
83
- }
82
+ params: [hue],
83
+ },
84
84
  ]);
85
85
  }
86
86
  if (saturation !== 0) {
87
87
  if (isWorkerEnvironment())
88
88
  self.sendStatusMessage("Changing image saturation...");
89
- image.colour([
89
+ image.color([
90
90
  {
91
91
  apply: "saturate",
92
- params: [saturation]
93
- }
92
+ params: [saturation],
93
+ },
94
94
  ]);
95
95
  }
96
96
  if (lightness !== 0) {
97
97
  if (isWorkerEnvironment())
98
98
  self.sendStatusMessage("Changing image lightness...");
99
- image.colour([
99
+ image.color([
100
100
  {
101
101
  apply: "lighten",
102
- params: [lightness]
103
- }
102
+ params: [lightness],
103
+ },
104
104
  ]);
105
105
  }
106
106
 
107
107
  let imageBuffer;
108
- if (image.getMIME() === "image/gif") {
109
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
108
+ if (image.mime === "image/gif") {
109
+ imageBuffer = await image.getBuffer(JimpMime.png);
110
110
  } else {
111
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
111
+ imageBuffer = await image.getBuffer(image.mime);
112
112
  }
113
113
  return imageBuffer.buffer;
114
114
  } catch (err) {
115
- throw new OperationError(`Error adjusting image hue / saturation / lightness. (${err})`);
115
+ throw new OperationError(
116
+ `Error adjusting image hue / saturation / lightness. (${err})`,
117
+ );
116
118
  }
117
119
  }
118
120
 
@@ -9,13 +9,12 @@ import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
11
  import { isWorkerEnvironment } from "../Utils.mjs";
12
- import Jimp from "jimp/es/index.js";
12
+ import { Jimp, JimpMime } from "jimp";
13
13
 
14
14
  /**
15
15
  * Image Opacity operation
16
16
  */
17
17
  class ImageOpacity extends Operation {
18
-
19
18
  /**
20
19
  * ImageOpacity constructor
21
20
  */
@@ -35,8 +34,8 @@ class ImageOpacity extends Operation {
35
34
  type: "number",
36
35
  value: 100,
37
36
  min: 0,
38
- max: 100
39
- }
37
+ max: 100,
38
+ },
40
39
  ];
41
40
  }
42
41
 
@@ -63,10 +62,10 @@ class ImageOpacity extends Operation {
63
62
  image.opacity(opacity / 100);
64
63
 
65
64
  let imageBuffer;
66
- if (image.getMIME() === "image/gif") {
67
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
65
+ if (image.mime === "image/gif") {
66
+ imageBuffer = await image.getBuffer(JimpMime.png);
68
67
  } else {
69
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
68
+ imageBuffer = await image.getBuffer(image.mime);
70
69
  }
71
70
  return imageBuffer.buffer;
72
71
  } catch (err) {
@@ -90,7 +89,6 @@ class ImageOpacity extends Operation {
90
89
 
91
90
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
92
91
  }
93
-
94
92
  }
95
93
 
96
94
  export default ImageOpacity;
@@ -9,13 +9,12 @@ import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
11
  import { isWorkerEnvironment } from "../Utils.mjs";
12
- import Jimp from "jimp/es/index.js";
12
+ import { Jimp, JimpMime } from "jimp";
13
13
 
14
14
  /**
15
15
  * Invert Image operation
16
16
  */
17
17
  class InvertImage extends Operation {
18
-
19
18
  /**
20
19
  * InvertImage constructor
21
20
  */
@@ -54,10 +53,10 @@ class InvertImage extends Operation {
54
53
  image.invert();
55
54
 
56
55
  let imageBuffer;
57
- if (image.getMIME() === "image/gif") {
58
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
56
+ if (image.mime === "image/gif") {
57
+ imageBuffer = await image.getBuffer(JimpMime.png);
59
58
  } else {
60
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
59
+ imageBuffer = await image.getBuffer(image.mime);
61
60
  }
62
61
  return imageBuffer.buffer;
63
62
  } catch (err) {
@@ -81,7 +80,6 @@ class InvertImage extends Operation {
81
80
 
82
81
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
83
82
  }
84
-
85
83
  }
86
84
 
87
85
  export default InvertImage;
@@ -30,7 +30,12 @@ class Jq extends Operation {
30
30
  name: "Query",
31
31
  type: "string",
32
32
  value: ""
33
- }
33
+ },
34
+ {
35
+ name: "Raw",
36
+ type: "boolean",
37
+ value: false
38
+ },
34
39
  ];
35
40
  }
36
41
 
@@ -40,7 +45,7 @@ class Jq extends Operation {
40
45
  * @returns {string}
41
46
  */
42
47
  run(input, args) {
43
- const [query] = args;
48
+ const [query, raw] = args;
44
49
  let result;
45
50
 
46
51
  try {
@@ -48,8 +53,11 @@ class Jq extends Operation {
48
53
  } catch (err) {
49
54
  throw new OperationError(`Invalid jq expression: ${err.message}`);
50
55
  }
51
-
52
- return JSON.stringify(result);
56
+ if (raw && typeof result === "string") {
57
+ return result;
58
+ } else {
59
+ return JSON.stringify(result);
60
+ }
53
61
  }
54
62
 
55
63
  }
@@ -8,13 +8,12 @@ import Operation from "../Operation.mjs";
8
8
  import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
- import Jimp from "jimp/es/index.js";
11
+ import { Jimp, JimpMime } from "jimp";
12
12
 
13
13
  /**
14
14
  * Normalise Image operation
15
15
  */
16
16
  class NormaliseImage extends Operation {
17
-
18
17
  /**
19
18
  * NormaliseImage constructor
20
19
  */
@@ -27,7 +26,7 @@ class NormaliseImage extends Operation {
27
26
  this.infoURL = "";
28
27
  this.inputType = "ArrayBuffer";
29
28
  this.outputType = "ArrayBuffer";
30
- this.presentType= "html";
29
+ this.presentType = "html";
31
30
  this.args = [];
32
31
  }
33
32
 
@@ -52,10 +51,10 @@ class NormaliseImage extends Operation {
52
51
  image.normalize();
53
52
 
54
53
  let imageBuffer;
55
- if (image.getMIME() === "image/gif") {
56
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
54
+ if (image.mime === "image/gif") {
55
+ imageBuffer = await image.getBuffer(JimpMime.png);
57
56
  } else {
58
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
57
+ imageBuffer = await image.getBuffer(image.mime);
59
58
  }
60
59
  return imageBuffer.buffer;
61
60
  } catch (err) {
@@ -79,7 +78,6 @@ class NormaliseImage extends Operation {
79
78
 
80
79
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
81
80
  }
82
-
83
81
  }
84
82
 
85
83
  export default NormaliseImage;
@@ -99,7 +99,7 @@ class OffsetChecker extends Operation {
99
99
  }
100
100
  }
101
101
 
102
- return outputs.join(sampleDelim);
102
+ return outputs.join(Utils.escapeHtml(sampleDelim));
103
103
  }
104
104
 
105
105
  }