@h3l1os/mp4vault 2.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 +661 -0
- package/README.md +228 -0
- package/dist/index.cjs +1525 -0
- package/dist/index.d.cts +261 -0
- package/dist/index.d.ts +261 -0
- package/dist/index.js +1479 -0
- package/package.json +69 -0
- package/src/AES.ts +134 -0
- package/src/Atom.ts +148 -0
- package/src/Convert.ts +28 -0
- package/src/Embed.ts +243 -0
- package/src/EmbedBinary.ts +204 -0
- package/src/EmbedObject.ts +231 -0
- package/src/MP4.ts +363 -0
- package/src/Pack.ts +11 -0
- package/src/constants.ts +3 -0
- package/src/index.ts +11 -0
- package/src/jspack.d.ts +10 -0
- package/src/jspack.js +319 -0
- package/src/node/Readable.ts +61 -0
- package/src/node/Writable.ts +85 -0
- package/src/types.ts +44 -0
- package/src/utils.ts +6 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
interface IReadable {
|
|
2
|
+
isPrepared(): boolean;
|
|
3
|
+
prepare(): Promise<void>;
|
|
4
|
+
close(): Promise<void>;
|
|
5
|
+
getSlice(offset: number, length: number): Promise<Uint8Array>;
|
|
6
|
+
size(): Promise<number>;
|
|
7
|
+
}
|
|
8
|
+
interface IWritable {
|
|
9
|
+
size(): number;
|
|
10
|
+
prepare(): Promise<void>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
write(data: Uint8Array | number[]): Promise<void>;
|
|
13
|
+
saveToFile(filename: string): Promise<void>;
|
|
14
|
+
toReadable(): Promise<IReadable>;
|
|
15
|
+
}
|
|
16
|
+
interface FileRecord {
|
|
17
|
+
filename: string;
|
|
18
|
+
size: number;
|
|
19
|
+
meta?: Record<string, unknown>;
|
|
20
|
+
isEncrypted?: boolean;
|
|
21
|
+
offset?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare class Atom {
|
|
25
|
+
readable: IReadable | null;
|
|
26
|
+
name: string;
|
|
27
|
+
start: number;
|
|
28
|
+
size: number;
|
|
29
|
+
header_size: number;
|
|
30
|
+
mother: Atom | null;
|
|
31
|
+
children: Atom[];
|
|
32
|
+
contents: number[] | null;
|
|
33
|
+
constructor(params: {
|
|
34
|
+
readable?: IReadable;
|
|
35
|
+
name: string;
|
|
36
|
+
start: number;
|
|
37
|
+
size: number;
|
|
38
|
+
header_size: number;
|
|
39
|
+
mother?: Atom | null;
|
|
40
|
+
});
|
|
41
|
+
findAtoms(atoms: Atom[] | null, name: string): Atom[];
|
|
42
|
+
unpackFromOffset(offset: number, length: number, fmt: string): Promise<number[]>;
|
|
43
|
+
isVideo(): boolean;
|
|
44
|
+
isAudio(): boolean;
|
|
45
|
+
getChunkOffsets(): Promise<number[]>;
|
|
46
|
+
writeHeader(writable: IWritable): Promise<void>;
|
|
47
|
+
writePayload(writable: IWritable): Promise<void>;
|
|
48
|
+
write(writable: IWritable): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare class MP4 {
|
|
52
|
+
private _analyzed;
|
|
53
|
+
_readable: IReadable | null;
|
|
54
|
+
private _embed;
|
|
55
|
+
private _key;
|
|
56
|
+
private _password;
|
|
57
|
+
_atoms: Atom[];
|
|
58
|
+
private _initialMdatStart;
|
|
59
|
+
private _initialEmbed;
|
|
60
|
+
getEmbedFiles(): FileRecord[];
|
|
61
|
+
setKey(key: Buffer): void;
|
|
62
|
+
setPassword(password: string): void;
|
|
63
|
+
loadFile(params: {
|
|
64
|
+
filename: string;
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
embedFile(params: {
|
|
67
|
+
filename?: string;
|
|
68
|
+
file?: {
|
|
69
|
+
name?: string;
|
|
70
|
+
};
|
|
71
|
+
meta?: Record<string, unknown>;
|
|
72
|
+
key?: Buffer | null;
|
|
73
|
+
password?: string | null;
|
|
74
|
+
}): Promise<void>;
|
|
75
|
+
getExpectedSize(): Promise<number>;
|
|
76
|
+
adjustSampleOffsets(offset: number): Promise<void>;
|
|
77
|
+
extractEmbedHeader(): Promise<void>;
|
|
78
|
+
extractFile(n: number, writable?: IWritable | null): Promise<IWritable>;
|
|
79
|
+
embed(writable?: IWritable): Promise<IWritable>;
|
|
80
|
+
analyzeFile(): Promise<Atom[]>;
|
|
81
|
+
printAtoms(atoms?: Atom[], level?: number): void;
|
|
82
|
+
findAtom(name: string): Atom | null;
|
|
83
|
+
findAtoms(atoms: Atom[] | null, name: string): Atom[];
|
|
84
|
+
parseAtoms(start: number, end: number, mother: Atom | null): Promise<Atom[]>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface AESParams {
|
|
88
|
+
key?: Buffer | Uint8Array;
|
|
89
|
+
password?: string;
|
|
90
|
+
iv?: Buffer;
|
|
91
|
+
salt?: Buffer;
|
|
92
|
+
authTag?: Buffer;
|
|
93
|
+
}
|
|
94
|
+
declare class AES {
|
|
95
|
+
static readonly ivByteLength = 12;
|
|
96
|
+
static readonly saltByteLength = 16;
|
|
97
|
+
static readonly authTagByteLength = 16;
|
|
98
|
+
private _key;
|
|
99
|
+
private _iv;
|
|
100
|
+
private _salt;
|
|
101
|
+
private _authTag;
|
|
102
|
+
private _cipher;
|
|
103
|
+
private _decipher;
|
|
104
|
+
constructor(params: AESParams);
|
|
105
|
+
private static _normalizeKey;
|
|
106
|
+
private static _algorithmForKey;
|
|
107
|
+
static deriveKey(password: string, salt: Buffer): Buffer;
|
|
108
|
+
encrypt(chunk: Buffer | null, finalize?: boolean): Buffer;
|
|
109
|
+
decrypt(chunk: Buffer | null, finalize?: boolean): Buffer;
|
|
110
|
+
getAuthTag(): Buffer;
|
|
111
|
+
getIV(): Buffer;
|
|
112
|
+
getSalt(): Buffer | null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
declare class Convert {
|
|
116
|
+
static randomByteIn(maxOptions: number, option: number): number;
|
|
117
|
+
static isByteIn(byte: number, maxOptions: number, option: number): boolean;
|
|
118
|
+
static objectToBuffer(object: unknown): Buffer;
|
|
119
|
+
static bufferToObject(buffer: Buffer | Uint8Array): unknown;
|
|
120
|
+
static hexStringToBuffer(str: string): Buffer;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
declare class EmbedObject {
|
|
124
|
+
_object: Record<string, unknown> | null;
|
|
125
|
+
private _binary;
|
|
126
|
+
private _key;
|
|
127
|
+
private _password;
|
|
128
|
+
private _iv;
|
|
129
|
+
private _salt;
|
|
130
|
+
private _readBytes;
|
|
131
|
+
private _encryptor;
|
|
132
|
+
constructor(params?: {
|
|
133
|
+
object?: Record<string, unknown>;
|
|
134
|
+
key?: Buffer | null;
|
|
135
|
+
password?: string | null;
|
|
136
|
+
iv?: Buffer | null;
|
|
137
|
+
salt?: Buffer | null;
|
|
138
|
+
readBytes?: number;
|
|
139
|
+
});
|
|
140
|
+
get readBytes(): number;
|
|
141
|
+
getExpectedSize(): Promise<number>;
|
|
142
|
+
get object(): Record<string, unknown> | null;
|
|
143
|
+
getEncryptor(): AES;
|
|
144
|
+
getIV(): Buffer;
|
|
145
|
+
static restoreFromReadable(readable: IReadable, params?: {
|
|
146
|
+
key?: Buffer;
|
|
147
|
+
password?: string | null;
|
|
148
|
+
object?: Record<string, unknown>;
|
|
149
|
+
readBytes?: number;
|
|
150
|
+
iv?: Buffer;
|
|
151
|
+
salt?: Buffer;
|
|
152
|
+
}, offset?: number): Promise<EmbedObject>;
|
|
153
|
+
writeTo(writable: IWritable): Promise<void>;
|
|
154
|
+
getBinary(): Uint8Array;
|
|
155
|
+
getRaw(): Uint8Array;
|
|
156
|
+
getEncrypted(): Uint8Array;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
declare class Embed {
|
|
160
|
+
private _files;
|
|
161
|
+
private _headerEmbed;
|
|
162
|
+
_publicHeaderEmbed: EmbedObject | null;
|
|
163
|
+
hasEncryptedFiles: boolean;
|
|
164
|
+
hasPublicFiles: boolean;
|
|
165
|
+
private _key;
|
|
166
|
+
private _password;
|
|
167
|
+
constructor(params?: {
|
|
168
|
+
mp4?: unknown;
|
|
169
|
+
key?: Buffer | null;
|
|
170
|
+
password?: string | null;
|
|
171
|
+
});
|
|
172
|
+
private basename;
|
|
173
|
+
addFile(params: {
|
|
174
|
+
file?: {
|
|
175
|
+
name?: string;
|
|
176
|
+
};
|
|
177
|
+
filename?: string | null;
|
|
178
|
+
meta?: Record<string, unknown>;
|
|
179
|
+
key?: Buffer | null;
|
|
180
|
+
password?: string | null;
|
|
181
|
+
}): Promise<void>;
|
|
182
|
+
composeHeader(): Promise<boolean>;
|
|
183
|
+
getExpectedSize(): Promise<number>;
|
|
184
|
+
writeTo(writable: IWritable): Promise<void>;
|
|
185
|
+
restoreFromReadable(readable: IReadable, params?: {
|
|
186
|
+
key?: Buffer;
|
|
187
|
+
password?: string | null;
|
|
188
|
+
}, offset?: number): Promise<void>;
|
|
189
|
+
getFilesToExtract(): FileRecord[];
|
|
190
|
+
restoreBinary(readable: IReadable, params: {
|
|
191
|
+
key?: Buffer;
|
|
192
|
+
password?: string | undefined;
|
|
193
|
+
}, n: number, offset: number, writable?: IWritable | null): Promise<IWritable>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
declare class EmbedBinary {
|
|
197
|
+
_readable: IReadable | null;
|
|
198
|
+
private _key;
|
|
199
|
+
private _password;
|
|
200
|
+
private _iv;
|
|
201
|
+
private _salt;
|
|
202
|
+
private _encryptor;
|
|
203
|
+
constructor(params?: {
|
|
204
|
+
readable?: IReadable;
|
|
205
|
+
filename?: string;
|
|
206
|
+
file?: {
|
|
207
|
+
name?: string;
|
|
208
|
+
};
|
|
209
|
+
key?: Buffer | null;
|
|
210
|
+
password?: string | null;
|
|
211
|
+
iv?: Buffer | null;
|
|
212
|
+
salt?: Buffer | null;
|
|
213
|
+
});
|
|
214
|
+
getExpectedSize(): Promise<number>;
|
|
215
|
+
getEncryptor(): AES;
|
|
216
|
+
getIV(): Buffer;
|
|
217
|
+
static restoreFromReadable(readable: IReadable, params?: {
|
|
218
|
+
key?: Buffer;
|
|
219
|
+
password?: string;
|
|
220
|
+
}, offset?: number, size?: number | null, writable?: IWritable | null): Promise<IWritable>;
|
|
221
|
+
writeTo(writable: IWritable): Promise<void>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
declare class Pack {
|
|
225
|
+
static pack(format: string, values: unknown[]): number[];
|
|
226
|
+
static unpack(format: string, buffer: Uint8Array | number[]): number[];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
declare class Readable implements IReadable {
|
|
230
|
+
private _filename;
|
|
231
|
+
private _prepared;
|
|
232
|
+
private _size;
|
|
233
|
+
private _fp;
|
|
234
|
+
constructor(params?: {
|
|
235
|
+
filename?: string;
|
|
236
|
+
});
|
|
237
|
+
isPrepared(): boolean;
|
|
238
|
+
prepare(): Promise<void>;
|
|
239
|
+
close(): Promise<void>;
|
|
240
|
+
getSlice(offset: number, length: number): Promise<Uint8Array>;
|
|
241
|
+
size(): Promise<number>;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare class Writable implements IWritable {
|
|
245
|
+
private _uint8Array;
|
|
246
|
+
private _filename;
|
|
247
|
+
private _prepared;
|
|
248
|
+
private _bytesWrote;
|
|
249
|
+
private _fp;
|
|
250
|
+
constructor(params?: {
|
|
251
|
+
filename?: string;
|
|
252
|
+
});
|
|
253
|
+
size(): number;
|
|
254
|
+
prepare(): Promise<void>;
|
|
255
|
+
close(): Promise<void>;
|
|
256
|
+
saveToFile(filename: string): Promise<void>;
|
|
257
|
+
write(append: Uint8Array | number[]): Promise<void>;
|
|
258
|
+
toReadable(): Promise<IReadable>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export { AES, Atom, Convert, Embed, EmbedBinary, EmbedObject, type FileRecord, type IReadable, type IWritable, MP4, Pack, Readable, Writable };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
interface IReadable {
|
|
2
|
+
isPrepared(): boolean;
|
|
3
|
+
prepare(): Promise<void>;
|
|
4
|
+
close(): Promise<void>;
|
|
5
|
+
getSlice(offset: number, length: number): Promise<Uint8Array>;
|
|
6
|
+
size(): Promise<number>;
|
|
7
|
+
}
|
|
8
|
+
interface IWritable {
|
|
9
|
+
size(): number;
|
|
10
|
+
prepare(): Promise<void>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
write(data: Uint8Array | number[]): Promise<void>;
|
|
13
|
+
saveToFile(filename: string): Promise<void>;
|
|
14
|
+
toReadable(): Promise<IReadable>;
|
|
15
|
+
}
|
|
16
|
+
interface FileRecord {
|
|
17
|
+
filename: string;
|
|
18
|
+
size: number;
|
|
19
|
+
meta?: Record<string, unknown>;
|
|
20
|
+
isEncrypted?: boolean;
|
|
21
|
+
offset?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare class Atom {
|
|
25
|
+
readable: IReadable | null;
|
|
26
|
+
name: string;
|
|
27
|
+
start: number;
|
|
28
|
+
size: number;
|
|
29
|
+
header_size: number;
|
|
30
|
+
mother: Atom | null;
|
|
31
|
+
children: Atom[];
|
|
32
|
+
contents: number[] | null;
|
|
33
|
+
constructor(params: {
|
|
34
|
+
readable?: IReadable;
|
|
35
|
+
name: string;
|
|
36
|
+
start: number;
|
|
37
|
+
size: number;
|
|
38
|
+
header_size: number;
|
|
39
|
+
mother?: Atom | null;
|
|
40
|
+
});
|
|
41
|
+
findAtoms(atoms: Atom[] | null, name: string): Atom[];
|
|
42
|
+
unpackFromOffset(offset: number, length: number, fmt: string): Promise<number[]>;
|
|
43
|
+
isVideo(): boolean;
|
|
44
|
+
isAudio(): boolean;
|
|
45
|
+
getChunkOffsets(): Promise<number[]>;
|
|
46
|
+
writeHeader(writable: IWritable): Promise<void>;
|
|
47
|
+
writePayload(writable: IWritable): Promise<void>;
|
|
48
|
+
write(writable: IWritable): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare class MP4 {
|
|
52
|
+
private _analyzed;
|
|
53
|
+
_readable: IReadable | null;
|
|
54
|
+
private _embed;
|
|
55
|
+
private _key;
|
|
56
|
+
private _password;
|
|
57
|
+
_atoms: Atom[];
|
|
58
|
+
private _initialMdatStart;
|
|
59
|
+
private _initialEmbed;
|
|
60
|
+
getEmbedFiles(): FileRecord[];
|
|
61
|
+
setKey(key: Buffer): void;
|
|
62
|
+
setPassword(password: string): void;
|
|
63
|
+
loadFile(params: {
|
|
64
|
+
filename: string;
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
embedFile(params: {
|
|
67
|
+
filename?: string;
|
|
68
|
+
file?: {
|
|
69
|
+
name?: string;
|
|
70
|
+
};
|
|
71
|
+
meta?: Record<string, unknown>;
|
|
72
|
+
key?: Buffer | null;
|
|
73
|
+
password?: string | null;
|
|
74
|
+
}): Promise<void>;
|
|
75
|
+
getExpectedSize(): Promise<number>;
|
|
76
|
+
adjustSampleOffsets(offset: number): Promise<void>;
|
|
77
|
+
extractEmbedHeader(): Promise<void>;
|
|
78
|
+
extractFile(n: number, writable?: IWritable | null): Promise<IWritable>;
|
|
79
|
+
embed(writable?: IWritable): Promise<IWritable>;
|
|
80
|
+
analyzeFile(): Promise<Atom[]>;
|
|
81
|
+
printAtoms(atoms?: Atom[], level?: number): void;
|
|
82
|
+
findAtom(name: string): Atom | null;
|
|
83
|
+
findAtoms(atoms: Atom[] | null, name: string): Atom[];
|
|
84
|
+
parseAtoms(start: number, end: number, mother: Atom | null): Promise<Atom[]>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface AESParams {
|
|
88
|
+
key?: Buffer | Uint8Array;
|
|
89
|
+
password?: string;
|
|
90
|
+
iv?: Buffer;
|
|
91
|
+
salt?: Buffer;
|
|
92
|
+
authTag?: Buffer;
|
|
93
|
+
}
|
|
94
|
+
declare class AES {
|
|
95
|
+
static readonly ivByteLength = 12;
|
|
96
|
+
static readonly saltByteLength = 16;
|
|
97
|
+
static readonly authTagByteLength = 16;
|
|
98
|
+
private _key;
|
|
99
|
+
private _iv;
|
|
100
|
+
private _salt;
|
|
101
|
+
private _authTag;
|
|
102
|
+
private _cipher;
|
|
103
|
+
private _decipher;
|
|
104
|
+
constructor(params: AESParams);
|
|
105
|
+
private static _normalizeKey;
|
|
106
|
+
private static _algorithmForKey;
|
|
107
|
+
static deriveKey(password: string, salt: Buffer): Buffer;
|
|
108
|
+
encrypt(chunk: Buffer | null, finalize?: boolean): Buffer;
|
|
109
|
+
decrypt(chunk: Buffer | null, finalize?: boolean): Buffer;
|
|
110
|
+
getAuthTag(): Buffer;
|
|
111
|
+
getIV(): Buffer;
|
|
112
|
+
getSalt(): Buffer | null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
declare class Convert {
|
|
116
|
+
static randomByteIn(maxOptions: number, option: number): number;
|
|
117
|
+
static isByteIn(byte: number, maxOptions: number, option: number): boolean;
|
|
118
|
+
static objectToBuffer(object: unknown): Buffer;
|
|
119
|
+
static bufferToObject(buffer: Buffer | Uint8Array): unknown;
|
|
120
|
+
static hexStringToBuffer(str: string): Buffer;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
declare class EmbedObject {
|
|
124
|
+
_object: Record<string, unknown> | null;
|
|
125
|
+
private _binary;
|
|
126
|
+
private _key;
|
|
127
|
+
private _password;
|
|
128
|
+
private _iv;
|
|
129
|
+
private _salt;
|
|
130
|
+
private _readBytes;
|
|
131
|
+
private _encryptor;
|
|
132
|
+
constructor(params?: {
|
|
133
|
+
object?: Record<string, unknown>;
|
|
134
|
+
key?: Buffer | null;
|
|
135
|
+
password?: string | null;
|
|
136
|
+
iv?: Buffer | null;
|
|
137
|
+
salt?: Buffer | null;
|
|
138
|
+
readBytes?: number;
|
|
139
|
+
});
|
|
140
|
+
get readBytes(): number;
|
|
141
|
+
getExpectedSize(): Promise<number>;
|
|
142
|
+
get object(): Record<string, unknown> | null;
|
|
143
|
+
getEncryptor(): AES;
|
|
144
|
+
getIV(): Buffer;
|
|
145
|
+
static restoreFromReadable(readable: IReadable, params?: {
|
|
146
|
+
key?: Buffer;
|
|
147
|
+
password?: string | null;
|
|
148
|
+
object?: Record<string, unknown>;
|
|
149
|
+
readBytes?: number;
|
|
150
|
+
iv?: Buffer;
|
|
151
|
+
salt?: Buffer;
|
|
152
|
+
}, offset?: number): Promise<EmbedObject>;
|
|
153
|
+
writeTo(writable: IWritable): Promise<void>;
|
|
154
|
+
getBinary(): Uint8Array;
|
|
155
|
+
getRaw(): Uint8Array;
|
|
156
|
+
getEncrypted(): Uint8Array;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
declare class Embed {
|
|
160
|
+
private _files;
|
|
161
|
+
private _headerEmbed;
|
|
162
|
+
_publicHeaderEmbed: EmbedObject | null;
|
|
163
|
+
hasEncryptedFiles: boolean;
|
|
164
|
+
hasPublicFiles: boolean;
|
|
165
|
+
private _key;
|
|
166
|
+
private _password;
|
|
167
|
+
constructor(params?: {
|
|
168
|
+
mp4?: unknown;
|
|
169
|
+
key?: Buffer | null;
|
|
170
|
+
password?: string | null;
|
|
171
|
+
});
|
|
172
|
+
private basename;
|
|
173
|
+
addFile(params: {
|
|
174
|
+
file?: {
|
|
175
|
+
name?: string;
|
|
176
|
+
};
|
|
177
|
+
filename?: string | null;
|
|
178
|
+
meta?: Record<string, unknown>;
|
|
179
|
+
key?: Buffer | null;
|
|
180
|
+
password?: string | null;
|
|
181
|
+
}): Promise<void>;
|
|
182
|
+
composeHeader(): Promise<boolean>;
|
|
183
|
+
getExpectedSize(): Promise<number>;
|
|
184
|
+
writeTo(writable: IWritable): Promise<void>;
|
|
185
|
+
restoreFromReadable(readable: IReadable, params?: {
|
|
186
|
+
key?: Buffer;
|
|
187
|
+
password?: string | null;
|
|
188
|
+
}, offset?: number): Promise<void>;
|
|
189
|
+
getFilesToExtract(): FileRecord[];
|
|
190
|
+
restoreBinary(readable: IReadable, params: {
|
|
191
|
+
key?: Buffer;
|
|
192
|
+
password?: string | undefined;
|
|
193
|
+
}, n: number, offset: number, writable?: IWritable | null): Promise<IWritable>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
declare class EmbedBinary {
|
|
197
|
+
_readable: IReadable | null;
|
|
198
|
+
private _key;
|
|
199
|
+
private _password;
|
|
200
|
+
private _iv;
|
|
201
|
+
private _salt;
|
|
202
|
+
private _encryptor;
|
|
203
|
+
constructor(params?: {
|
|
204
|
+
readable?: IReadable;
|
|
205
|
+
filename?: string;
|
|
206
|
+
file?: {
|
|
207
|
+
name?: string;
|
|
208
|
+
};
|
|
209
|
+
key?: Buffer | null;
|
|
210
|
+
password?: string | null;
|
|
211
|
+
iv?: Buffer | null;
|
|
212
|
+
salt?: Buffer | null;
|
|
213
|
+
});
|
|
214
|
+
getExpectedSize(): Promise<number>;
|
|
215
|
+
getEncryptor(): AES;
|
|
216
|
+
getIV(): Buffer;
|
|
217
|
+
static restoreFromReadable(readable: IReadable, params?: {
|
|
218
|
+
key?: Buffer;
|
|
219
|
+
password?: string;
|
|
220
|
+
}, offset?: number, size?: number | null, writable?: IWritable | null): Promise<IWritable>;
|
|
221
|
+
writeTo(writable: IWritable): Promise<void>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
declare class Pack {
|
|
225
|
+
static pack(format: string, values: unknown[]): number[];
|
|
226
|
+
static unpack(format: string, buffer: Uint8Array | number[]): number[];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
declare class Readable implements IReadable {
|
|
230
|
+
private _filename;
|
|
231
|
+
private _prepared;
|
|
232
|
+
private _size;
|
|
233
|
+
private _fp;
|
|
234
|
+
constructor(params?: {
|
|
235
|
+
filename?: string;
|
|
236
|
+
});
|
|
237
|
+
isPrepared(): boolean;
|
|
238
|
+
prepare(): Promise<void>;
|
|
239
|
+
close(): Promise<void>;
|
|
240
|
+
getSlice(offset: number, length: number): Promise<Uint8Array>;
|
|
241
|
+
size(): Promise<number>;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare class Writable implements IWritable {
|
|
245
|
+
private _uint8Array;
|
|
246
|
+
private _filename;
|
|
247
|
+
private _prepared;
|
|
248
|
+
private _bytesWrote;
|
|
249
|
+
private _fp;
|
|
250
|
+
constructor(params?: {
|
|
251
|
+
filename?: string;
|
|
252
|
+
});
|
|
253
|
+
size(): number;
|
|
254
|
+
prepare(): Promise<void>;
|
|
255
|
+
close(): Promise<void>;
|
|
256
|
+
saveToFile(filename: string): Promise<void>;
|
|
257
|
+
write(append: Uint8Array | number[]): Promise<void>;
|
|
258
|
+
toReadable(): Promise<IReadable>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export { AES, Atom, Convert, Embed, EmbedBinary, EmbedObject, type FileRecord, type IReadable, type IWritable, MP4, Pack, Readable, Writable };
|