roxify 1.5.3 → 1.5.4
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/minpng.d.ts +14 -0
- package/dist/minpng.js +14 -0
- package/dist/utils/decoder.d.ts +15 -0
- package/dist/utils/decoder.js +24 -3
- package/dist/utils/encoder.d.ts +21 -0
- package/dist/utils/encoder.js +21 -0
- package/dist/utils/inspection.d.ts +24 -6
- package/dist/utils/inspection.js +24 -6
- package/dist/utils/reconstitution.d.ts +7 -0
- package/dist/utils/reconstitution.js +7 -0
- package/libroxify_native-x86_64-unknown-linux-gnu.so +0 -0
- package/package.json +3 -2
package/dist/minpng.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode a buffer of raw RGB data into a minimal PNG (MinPNG format).
|
|
3
|
+
*
|
|
4
|
+
* @param rgb - Buffer of RGB data.
|
|
5
|
+
* @param width - Image width.
|
|
6
|
+
* @param height - Image height.
|
|
7
|
+
* @returns Promise resolving to a PNG Buffer.
|
|
8
|
+
*/
|
|
1
9
|
export declare function encodeMinPng(rgb: Buffer, width: number, height: number): Promise<Buffer>;
|
|
10
|
+
/**
|
|
11
|
+
* Decode a minimal PNG (MinPNG) buffer into raw RGB data and dimensions.
|
|
12
|
+
*
|
|
13
|
+
* @param pngBuf - Buffer containing a MinPNG image.
|
|
14
|
+
* @returns Promise resolving to an object with buf, width, and height, or null if invalid.
|
|
15
|
+
*/
|
|
2
16
|
export declare function decodeMinPng(pngBuf: Buffer): Promise<{
|
|
3
17
|
buf: Buffer;
|
|
4
18
|
width: number;
|
package/dist/minpng.js
CHANGED
|
@@ -51,6 +51,14 @@ function zigzagOrderIndices(width, height) {
|
|
|
51
51
|
}
|
|
52
52
|
return indices;
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Encode a buffer of raw RGB data into a minimal PNG (MinPNG format).
|
|
56
|
+
*
|
|
57
|
+
* @param rgb - Buffer of RGB data.
|
|
58
|
+
* @param width - Image width.
|
|
59
|
+
* @param height - Image height.
|
|
60
|
+
* @returns Promise resolving to a PNG Buffer.
|
|
61
|
+
*/
|
|
54
62
|
export async function encodeMinPng(rgb, width, height) {
|
|
55
63
|
const w = width, h = height;
|
|
56
64
|
const idx = (x, y) => (y * w + x) * 3;
|
|
@@ -177,6 +185,12 @@ export async function encodeMinPng(rgb, width, height) {
|
|
|
177
185
|
}
|
|
178
186
|
return Buffer.concat(output);
|
|
179
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Decode a minimal PNG (MinPNG) buffer into raw RGB data and dimensions.
|
|
190
|
+
*
|
|
191
|
+
* @param pngBuf - Buffer containing a MinPNG image.
|
|
192
|
+
* @returns Promise resolving to an object with buf, width, and height, or null if invalid.
|
|
193
|
+
*/
|
|
180
194
|
export async function decodeMinPng(pngBuf) {
|
|
181
195
|
const rawData = native.sharpToRaw(pngBuf);
|
|
182
196
|
const data = rawData.pixels;
|
package/dist/utils/decoder.d.ts
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
import { DecodeOptions, DecodeResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Decode a ROX PNG or buffer into the original binary payload or files list.
|
|
4
|
+
*
|
|
5
|
+
* @param input - Buffer or path to a PNG file.
|
|
6
|
+
* @param opts - Optional decode options.
|
|
7
|
+
* @returns A Promise resolving to DecodeResult ({ buf, meta } or { files }).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```js
|
|
11
|
+
* import { decodePngToBinary } from 'roxify';
|
|
12
|
+
* const png = fs.readFileSync('out.png');
|
|
13
|
+
* const res = await decodePngToBinary(png);
|
|
14
|
+
* console.log(res.meta?.name, res.buf.toString('utf8'));
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
2
17
|
export declare function decodePngToBinary(input: Buffer | string, opts?: DecodeOptions): Promise<DecodeResult>;
|
package/dist/utils/decoder.js
CHANGED
|
@@ -58,6 +58,21 @@ function convertToPng(buf, format) {
|
|
|
58
58
|
catch (e) { }
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Decode a ROX PNG or buffer into the original binary payload or files list.
|
|
63
|
+
*
|
|
64
|
+
* @param input - Buffer or path to a PNG file.
|
|
65
|
+
* @param opts - Optional decode options.
|
|
66
|
+
* @returns A Promise resolving to DecodeResult ({ buf, meta } or { files }).
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```js
|
|
70
|
+
* import { decodePngToBinary } from 'roxify';
|
|
71
|
+
* const png = fs.readFileSync('out.png');
|
|
72
|
+
* const res = await decodePngToBinary(png);
|
|
73
|
+
* console.log(res.meta?.name, res.buf.toString('utf8'));
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
61
76
|
export async function decodePngToBinary(input, opts = {}) {
|
|
62
77
|
let pngBuf;
|
|
63
78
|
if (Buffer.isBuffer(input)) {
|
|
@@ -347,11 +362,17 @@ export async function decodePngToBinary(input, opts = {}) {
|
|
|
347
362
|
logicalData = rawRGB;
|
|
348
363
|
}
|
|
349
364
|
else {
|
|
350
|
-
|
|
365
|
+
if (process.env.ROX_DEBUG || opts.debugDir) {
|
|
366
|
+
console.log('DEBUG: about to call cropAndReconstitute, debugDir=', opts.debugDir);
|
|
367
|
+
}
|
|
351
368
|
const reconstructed = await cropAndReconstitute(processedBuf, opts.debugDir);
|
|
352
|
-
|
|
369
|
+
if (process.env.ROX_DEBUG || opts.debugDir) {
|
|
370
|
+
console.log('DEBUG: cropAndReconstitute returned, reconstructed len=', reconstructed.length);
|
|
371
|
+
}
|
|
353
372
|
const rawData = native.sharpToRaw(reconstructed);
|
|
354
|
-
|
|
373
|
+
if (process.env.ROX_DEBUG || opts.debugDir) {
|
|
374
|
+
console.log('DEBUG: rawData from reconstructed:', rawData.width, 'x', rawData.height, 'pixels=', Math.floor(rawData.pixels.length / 3));
|
|
375
|
+
}
|
|
355
376
|
logicalWidth = rawData.width;
|
|
356
377
|
logicalHeight = rawData.height;
|
|
357
378
|
logicalData = Buffer.from(rawData.pixels);
|
package/dist/utils/encoder.d.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
1
|
import { EncodeOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Encode a buffer or array of buffers into a PNG image (ROX format).
|
|
4
|
+
*
|
|
5
|
+
* @param input - The buffer or array of buffers to encode.
|
|
6
|
+
* @param opts - Optional encoding options.
|
|
7
|
+
* @returns A Promise that resolves to a PNG Buffer containing the encoded data.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```js
|
|
11
|
+
* import { encodeBinaryToPng } from 'roxify';
|
|
12
|
+
*
|
|
13
|
+
* const png = await encodeBinaryToPng(Buffer.from('hello'), {
|
|
14
|
+
* mode: 'screenshot',
|
|
15
|
+
* name: 'hello.txt',
|
|
16
|
+
* compressionLevel: 19,
|
|
17
|
+
* outputFormat: 'png',
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // write to disk using fs.writeFileSync('out.png', png)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
2
23
|
export declare function encodeBinaryToPng(input: Buffer | Buffer[], opts?: EncodeOptions): Promise<Buffer>;
|
package/dist/utils/encoder.js
CHANGED
|
@@ -6,6 +6,27 @@ import { crc32 } from './crc.js';
|
|
|
6
6
|
import { colorsToBytes } from './helpers.js';
|
|
7
7
|
import { native } from './native.js';
|
|
8
8
|
import { parallelZstdCompress } from './zstd.js';
|
|
9
|
+
/**
|
|
10
|
+
* Encode a buffer or array of buffers into a PNG image (ROX format).
|
|
11
|
+
*
|
|
12
|
+
* @param input - The buffer or array of buffers to encode.
|
|
13
|
+
* @param opts - Optional encoding options.
|
|
14
|
+
* @returns A Promise that resolves to a PNG Buffer containing the encoded data.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```js
|
|
18
|
+
* import { encodeBinaryToPng } from 'roxify';
|
|
19
|
+
*
|
|
20
|
+
* const png = await encodeBinaryToPng(Buffer.from('hello'), {
|
|
21
|
+
* mode: 'screenshot',
|
|
22
|
+
* name: 'hello.txt',
|
|
23
|
+
* compressionLevel: 19,
|
|
24
|
+
* outputFormat: 'png',
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // write to disk using fs.writeFileSync('out.png', png)
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
9
30
|
export async function encodeBinaryToPng(input, opts = {}) {
|
|
10
31
|
let progressBar = null;
|
|
11
32
|
if (opts.showProgress) {
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* List files
|
|
3
|
-
* Returns
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
2
|
+
* List files stored inside a ROX PNG without fully extracting it.
|
|
3
|
+
* Returns `null` if no file list could be found.
|
|
4
|
+
*
|
|
5
|
+
* @param pngBuf - Buffer containing a PNG file.
|
|
6
|
+
* @param opts - Options to include sizes.
|
|
7
|
+
* @returns Promise resolving to an array of file names or objects with sizes.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```js
|
|
11
|
+
* import { listFilesInPng } from 'roxify';
|
|
12
|
+
* const files = await listFilesInPng(fs.readFileSync('out.png'), { includeSizes: true });
|
|
13
|
+
* console.log(files);
|
|
14
|
+
* ```
|
|
6
15
|
*/
|
|
7
16
|
export declare function listFilesInPng(pngBuf: Buffer, opts?: {
|
|
8
17
|
includeSizes?: boolean;
|
|
@@ -11,7 +20,16 @@ export declare function listFilesInPng(pngBuf: Buffer, opts?: {
|
|
|
11
20
|
size: number;
|
|
12
21
|
}[] | null>;
|
|
13
22
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
23
|
+
* Check if a PNG contains an encrypted payload requiring a passphrase.
|
|
24
|
+
*
|
|
25
|
+
* @param pngBuf - Buffer containing a PNG file.
|
|
26
|
+
* @returns Promise resolving to `true` if the PNG requires a passphrase.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```js
|
|
30
|
+
* import { hasPassphraseInPng } from 'roxify';
|
|
31
|
+
* const needPass = await hasPassphraseInPng(fs.readFileSync('out.png'));
|
|
32
|
+
* console.log('needs passphrase?', needPass);
|
|
33
|
+
* ```
|
|
16
34
|
*/
|
|
17
35
|
export declare function hasPassphraseInPng(pngBuf: Buffer): Promise<boolean>;
|
package/dist/utils/inspection.js
CHANGED
|
@@ -6,10 +6,19 @@ import { PassphraseRequiredError } from './errors.js';
|
|
|
6
6
|
import { native } from './native.js';
|
|
7
7
|
import { cropAndReconstitute } from './reconstitution.js';
|
|
8
8
|
/**
|
|
9
|
-
* List files
|
|
10
|
-
* Returns
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
9
|
+
* List files stored inside a ROX PNG without fully extracting it.
|
|
10
|
+
* Returns `null` if no file list could be found.
|
|
11
|
+
*
|
|
12
|
+
* @param pngBuf - Buffer containing a PNG file.
|
|
13
|
+
* @param opts - Options to include sizes.
|
|
14
|
+
* @returns Promise resolving to an array of file names or objects with sizes.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```js
|
|
18
|
+
* import { listFilesInPng } from 'roxify';
|
|
19
|
+
* const files = await listFilesInPng(fs.readFileSync('out.png'), { includeSizes: true });
|
|
20
|
+
* console.log(files);
|
|
21
|
+
* ```
|
|
13
22
|
*/
|
|
14
23
|
export async function listFilesInPng(pngBuf, opts = {}) {
|
|
15
24
|
try {
|
|
@@ -412,8 +421,17 @@ async function getFileSizesFromPng(pngBuf) {
|
|
|
412
421
|
return null;
|
|
413
422
|
}
|
|
414
423
|
/**
|
|
415
|
-
*
|
|
416
|
-
*
|
|
424
|
+
* Check if a PNG contains an encrypted payload requiring a passphrase.
|
|
425
|
+
*
|
|
426
|
+
* @param pngBuf - Buffer containing a PNG file.
|
|
427
|
+
* @returns Promise resolving to `true` if the PNG requires a passphrase.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```js
|
|
431
|
+
* import { hasPassphraseInPng } from 'roxify';
|
|
432
|
+
* const needPass = await hasPassphraseInPng(fs.readFileSync('out.png'));
|
|
433
|
+
* console.log('needs passphrase?', needPass);
|
|
434
|
+
* ```
|
|
417
435
|
*/
|
|
418
436
|
export async function hasPassphraseInPng(pngBuf) {
|
|
419
437
|
try {
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reconstitute a PNG buffer by cropping and reconstructing the image.
|
|
3
|
+
*
|
|
4
|
+
* @param input - Buffer containing the PNG image.
|
|
5
|
+
* @param debugDir - Optional directory to write debug images.
|
|
6
|
+
* @returns Promise resolving to the reconstituted PNG buffer.
|
|
7
|
+
*/
|
|
1
8
|
export declare function cropAndReconstitute(input: Buffer, debugDir?: string): Promise<Buffer>;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { writeFileSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import { native } from './native.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reconstitute a PNG buffer by cropping and reconstructing the image.
|
|
6
|
+
*
|
|
7
|
+
* @param input - Buffer containing the PNG image.
|
|
8
|
+
* @param debugDir - Optional directory to write debug images.
|
|
9
|
+
* @returns Promise resolving to the reconstituted PNG buffer.
|
|
10
|
+
*/
|
|
4
11
|
export async function cropAndReconstitute(input, debugDir) {
|
|
5
12
|
const out = Buffer.from(native.cropAndReconstitute(input));
|
|
6
13
|
if (debugDir) {
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "roxify",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"description": "Ultra-lightweight PNG steganography with native Rust acceleration. Encode binary data into PNG images with zstd compression.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
"build:native:windows": "cargo build --release --lib --target x86_64-pc-windows-msvc && cp target/x86_64-pc-windows-msvc/release/roxify_native.dll libroxify_native-x86_64-pc-windows-msvc.dll",
|
|
28
28
|
"build:cli": "cargo build --release --bin roxify_native && cp target/release/roxify_native dist/roxify-cli",
|
|
29
29
|
"build:all": "npm run build:native && npm run build && npm run build:cli",
|
|
30
|
+
"build:cross": "node scripts/build-all-platforms.js && npm run build && npm run build:cli",
|
|
30
31
|
"postbuild:native": "node scripts/copy-native.js",
|
|
31
|
-
"prepublishOnly": "npm run build:
|
|
32
|
+
"prepublishOnly": "npm run build:cross",
|
|
32
33
|
"test": "npm run build && node test/run-all-tests.js",
|
|
33
34
|
"cli": "node dist/cli.js"
|
|
34
35
|
},
|