roxify 1.0.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.
- package/LICENSE +21 -0
- package/README.md +368 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +255 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.js +1042 -0
- package/package.json +50 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
export declare class PassphraseRequiredError extends Error {
|
|
4
|
+
constructor(message?: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class IncorrectPassphraseError extends Error {
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class DataFormatError extends Error {
|
|
10
|
+
constructor(message?: string);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options for encoding binary data into PNG format.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface EncodeOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Compression algorithm to use.
|
|
19
|
+
* - `'br'`: Brotli compression (default for most modes)
|
|
20
|
+
* - `'none'`: No compression
|
|
21
|
+
* @defaultValue `'br'` for most modes
|
|
22
|
+
*/
|
|
23
|
+
compression?: 'br' | 'none';
|
|
24
|
+
/**
|
|
25
|
+
* Passphrase for encryption. If provided without `encrypt` option, defaults to AES-256-GCM.
|
|
26
|
+
*/
|
|
27
|
+
passphrase?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Original filename to embed in the encoded data.
|
|
30
|
+
*/
|
|
31
|
+
name?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Encoding mode to use:
|
|
34
|
+
* - `'compact'`: Minimal 1x1 PNG with data in custom chunk (smallest, fastest)
|
|
35
|
+
* - `'pixel'`: Encode data as RGB pixel values
|
|
36
|
+
* - `'screenshot'`: Optimized for screenshot-like appearance (recommended)
|
|
37
|
+
* @defaultValue `'screenshot'`
|
|
38
|
+
*/
|
|
39
|
+
mode?: 'compact' | 'pixel' | 'screenshot';
|
|
40
|
+
/**
|
|
41
|
+
* Encryption method:
|
|
42
|
+
* - `'auto'`: Try all methods and pick smallest result
|
|
43
|
+
* - `'aes'`: AES-256-GCM authenticated encryption (secure)
|
|
44
|
+
* - `'xor'`: Simple XOR cipher (legacy, not recommended)
|
|
45
|
+
* - `'none'`: No encryption
|
|
46
|
+
* @defaultValue `'aes'` when passphrase is provided
|
|
47
|
+
*/
|
|
48
|
+
encrypt?: 'auto' | 'aes' | 'xor' | 'none';
|
|
49
|
+
/**
|
|
50
|
+
* Internal flag to skip auto-detection. Not for public use.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
_skipAuto?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Output format:
|
|
56
|
+
* - `'auto'`: Choose best format automatically
|
|
57
|
+
* - `'png'`: Force PNG output
|
|
58
|
+
* - `'rox'`: Force raw ROX binary format (no PNG wrapper)
|
|
59
|
+
* @defaultValue `'auto'`
|
|
60
|
+
*/
|
|
61
|
+
output?: 'auto' | 'png' | 'rox';
|
|
62
|
+
/**
|
|
63
|
+
* Whether to include the filename in the encoded metadata.
|
|
64
|
+
* @defaultValue `true`
|
|
65
|
+
*/
|
|
66
|
+
includeName?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Brotli compression quality (0-11).
|
|
69
|
+
* - Lower values = faster compression, larger output
|
|
70
|
+
* - Higher values = slower compression, smaller output
|
|
71
|
+
* @defaultValue `1` (optimized for speed)
|
|
72
|
+
*/
|
|
73
|
+
brQuality?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Result of decoding a PNG back to binary data.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export interface DecodeResult {
|
|
80
|
+
/**
|
|
81
|
+
* The decoded binary data.
|
|
82
|
+
*/
|
|
83
|
+
buf: Buffer;
|
|
84
|
+
/**
|
|
85
|
+
* Metadata extracted from the encoded image.
|
|
86
|
+
*/
|
|
87
|
+
meta?: {
|
|
88
|
+
/**
|
|
89
|
+
* Original filename, if it was embedded during encoding.
|
|
90
|
+
*/
|
|
91
|
+
name?: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export declare function cropAndReconstitute(input: Buffer): Promise<Buffer>;
|
|
95
|
+
/**
|
|
96
|
+
* Encode a Buffer into a PNG wrapper. Supports optional compression and
|
|
97
|
+
* encryption. Defaults are chosen for a good balance between speed and size.
|
|
98
|
+
*
|
|
99
|
+
* @param input - Data to encode
|
|
100
|
+
* @param opts - Encoding options
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export declare function encodeBinaryToPng(input: Buffer, opts?: EncodeOptions): Promise<Buffer>;
|
|
104
|
+
/**
|
|
105
|
+
* Decode a PNG produced by this library back to the original Buffer.
|
|
106
|
+
* Supports the ROX binary format, rXDT chunk, and pixel encodings.
|
|
107
|
+
*
|
|
108
|
+
* @param pngBuf - PNG data
|
|
109
|
+
* @param opts - Options (passphrase for encrypted inputs)
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
export declare function decodePngToBinary(pngBuf: Buffer, opts?: {
|
|
113
|
+
passphrase?: string;
|
|
114
|
+
}): Promise<DecodeResult>;
|