pst-extractor 1.8.0 → 1.10.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/dist/ColumnDescriptor.class.d.ts +26 -26
- package/dist/ColumnDescriptor.class.js +51 -48
- package/dist/DescriptorIndexNode.class.d.ts +25 -26
- package/dist/DescriptorIndexNode.class.js +53 -53
- package/dist/LZFu.class.d.ts +11 -12
- package/dist/LZFu.class.js +95 -95
- package/dist/NodeInfo.class.d.ts +33 -33
- package/dist/NodeInfo.class.js +52 -52
- package/dist/NodeMap.class.d.ts +35 -35
- package/dist/NodeMap.class.js +86 -83
- package/dist/OffsetIndexItem.class.d.ts +23 -24
- package/dist/OffsetIndexItem.class.js +45 -45
- package/dist/OutlookProperties.d.ts +275 -275
- package/dist/OutlookProperties.js +281 -281
- package/dist/PSTActivity.class.d.ts +103 -103
- package/dist/PSTActivity.class.js +144 -144
- package/dist/PSTAppointment.class.d.ts +270 -271
- package/dist/PSTAppointment.class.js +376 -376
- package/dist/PSTAttachment.class.d.ts +172 -172
- package/dist/PSTAttachment.class.js +317 -314
- package/dist/PSTContact.class.d.ts +884 -884
- package/dist/PSTContact.class.js +1227 -1227
- package/dist/PSTDescriptorItem.class.d.ts +45 -46
- package/dist/PSTDescriptorItem.class.js +99 -96
- package/dist/PSTFile.class.d.ts +215 -216
- package/dist/PSTFile.class.js +818 -792
- package/dist/PSTFolder.class.d.ts +129 -129
- package/dist/PSTFolder.class.js +318 -307
- package/dist/PSTMessage.class.d.ts +788 -789
- package/dist/PSTMessage.class.js +1321 -1318
- package/dist/PSTMessageStore.class.d.ts +13 -13
- package/dist/PSTMessageStore.class.js +17 -17
- package/dist/PSTNodeInputStream.class.d.ts +122 -123
- package/dist/PSTNodeInputStream.class.js +514 -488
- package/dist/PSTObject.class.d.ts +133 -134
- package/dist/PSTObject.class.js +326 -323
- package/dist/PSTRecipient.class.d.ts +65 -65
- package/dist/PSTRecipient.class.js +103 -103
- package/dist/PSTTable.class.d.ts +52 -52
- package/dist/PSTTable.class.js +175 -172
- package/dist/PSTTable7C.class.d.ts +45 -45
- package/dist/PSTTable7C.class.js +281 -278
- package/dist/PSTTableBC.class.d.ts +31 -31
- package/dist/PSTTableBC.class.js +111 -108
- package/dist/PSTTableItem.class.d.ts +47 -48
- package/dist/PSTTableItem.class.js +124 -121
- package/dist/PSTTask.class.d.ts +146 -146
- package/dist/PSTTask.class.js +205 -205
- package/dist/PSTUtil.class.d.ts +134 -135
- package/dist/PSTUtil.class.js +795 -790
- package/dist/RecurrencePattern.class.d.ts +49 -50
- package/dist/RecurrencePattern.class.js +120 -120
- package/dist/index.d.ts +6 -6
- package/dist/index.js +15 -15
- package/example/package.json +7 -7
- package/example/test-min.ts +31 -12
- package/example/{test-mem.ts → test.ts} +38 -30
- package/example/testdata/output.txt +278 -0
- package/example/testdata/outputBody.txt +3404 -0
- package/example/yarn.lock +112 -50
- package/junit.xml +36 -36
- package/package.json +28 -27
- package/readme.md +1 -3
- package/example/test-max.ts +0 -251
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { NodeInfo } from './NodeInfo.class';
|
|
2
|
-
export declare class ColumnDescriptor {
|
|
3
|
-
private _ibData;
|
|
4
|
-
get ibData(): number;
|
|
5
|
-
private _cbData;
|
|
6
|
-
get cbData(): number;
|
|
7
|
-
private _type;
|
|
8
|
-
get type(): number;
|
|
9
|
-
private _iBit;
|
|
10
|
-
get iBit(): number;
|
|
11
|
-
private _id;
|
|
12
|
-
get id(): number;
|
|
13
|
-
/**
|
|
14
|
-
* Creates an instance of ColumnDescriptor.
|
|
15
|
-
* @param {NodeInfo} nodeInfo
|
|
16
|
-
* @param {number} offset
|
|
17
|
-
* @memberof ColumnDescriptor
|
|
18
|
-
*/
|
|
19
|
-
constructor(nodeInfo: NodeInfo, offset: number);
|
|
20
|
-
/**
|
|
21
|
-
* JSON stringify the object properties.
|
|
22
|
-
* @returns {string}
|
|
23
|
-
* @memberof ColumnDescriptor
|
|
24
|
-
*/
|
|
25
|
-
toJSON(): any;
|
|
26
|
-
}
|
|
1
|
+
import { NodeInfo } from './NodeInfo.class';
|
|
2
|
+
export declare class ColumnDescriptor {
|
|
3
|
+
private _ibData;
|
|
4
|
+
get ibData(): number;
|
|
5
|
+
private _cbData;
|
|
6
|
+
get cbData(): number;
|
|
7
|
+
private _type;
|
|
8
|
+
get type(): number;
|
|
9
|
+
private _iBit;
|
|
10
|
+
get iBit(): number;
|
|
11
|
+
private _id;
|
|
12
|
+
get id(): number;
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of ColumnDescriptor.
|
|
15
|
+
* @param {NodeInfo} nodeInfo
|
|
16
|
+
* @param {number} offset
|
|
17
|
+
* @memberof ColumnDescriptor
|
|
18
|
+
*/
|
|
19
|
+
constructor(nodeInfo: NodeInfo, offset: number);
|
|
20
|
+
/**
|
|
21
|
+
* JSON stringify the object properties.
|
|
22
|
+
* @returns {string}
|
|
23
|
+
* @memberof ColumnDescriptor
|
|
24
|
+
*/
|
|
25
|
+
toJSON(): any;
|
|
26
|
+
}
|
|
@@ -1,48 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ColumnDescriptor = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
const long_1 = __importDefault(require("long"));
|
|
9
|
+
class ColumnDescriptor {
|
|
10
|
+
get ibData() {
|
|
11
|
+
return this._ibData;
|
|
12
|
+
}
|
|
13
|
+
get cbData() {
|
|
14
|
+
return this._cbData;
|
|
15
|
+
}
|
|
16
|
+
get type() {
|
|
17
|
+
return this._type;
|
|
18
|
+
}
|
|
19
|
+
get iBit() {
|
|
20
|
+
return this._iBit;
|
|
21
|
+
}
|
|
22
|
+
get id() {
|
|
23
|
+
return this._id;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates an instance of ColumnDescriptor.
|
|
27
|
+
* @param {NodeInfo} nodeInfo
|
|
28
|
+
* @param {number} offset
|
|
29
|
+
* @memberof ColumnDescriptor
|
|
30
|
+
*/
|
|
31
|
+
constructor(nodeInfo, offset) {
|
|
32
|
+
this._type = nodeInfo.seekAndReadLong(long_1.default.fromValue(offset), 2).toNumber(); // & 0xFFFF;
|
|
33
|
+
this._id = nodeInfo
|
|
34
|
+
.seekAndReadLong(long_1.default.fromValue(offset + 2), 2)
|
|
35
|
+
.toNumber(); // & 0xFFFF;
|
|
36
|
+
this._ibData = nodeInfo
|
|
37
|
+
.seekAndReadLong(long_1.default.fromValue(offset + 4), 2)
|
|
38
|
+
.toNumber(); // & 0xFFFF;
|
|
39
|
+
this._cbData = nodeInfo.pstNodeInputStream.read(); // & 0xFFFF;
|
|
40
|
+
this._iBit = nodeInfo.pstNodeInputStream.read(); // & 0xFFFF;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* JSON stringify the object properties.
|
|
44
|
+
* @returns {string}
|
|
45
|
+
* @memberof ColumnDescriptor
|
|
46
|
+
*/
|
|
47
|
+
toJSON() {
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.ColumnDescriptor = ColumnDescriptor;
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* @param {
|
|
16
|
-
* @
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
1
|
+
import Long from 'long';
|
|
2
|
+
export declare class DescriptorIndexNode {
|
|
3
|
+
private _descriptorIdentifier;
|
|
4
|
+
itemType: number;
|
|
5
|
+
get descriptorIdentifier(): number;
|
|
6
|
+
private _parentDescriptorIndexIdentifier;
|
|
7
|
+
get parentDescriptorIndexIdentifier(): number;
|
|
8
|
+
private _localDescriptorsOffsetIndexIdentifier;
|
|
9
|
+
get localDescriptorsOffsetIndexIdentifier(): Long;
|
|
10
|
+
private _dataOffsetIndexIdentifier;
|
|
11
|
+
get dataOffsetIndexIdentifier(): Long;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of DescriptorIndexNode, a component of the internal descriptor b-tree.
|
|
14
|
+
* @param {Buffer} buffer
|
|
15
|
+
* @param {number} pstFileType
|
|
16
|
+
* @memberof DescriptorIndexNode
|
|
17
|
+
*/
|
|
18
|
+
constructor(buffer: Buffer, pstFileType: number);
|
|
19
|
+
/**
|
|
20
|
+
* JSON stringify the object properties.
|
|
21
|
+
* @returns {string}
|
|
22
|
+
* @memberof DescriptorIndexNode
|
|
23
|
+
*/
|
|
24
|
+
toJSON(): any;
|
|
25
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DescriptorIndexNode = void 0;
|
|
4
|
-
const PSTFile_class_1 = require("./PSTFile.class");
|
|
5
|
-
const PSTUtil_class_1 = require("./PSTUtil.class");
|
|
6
|
-
// DescriptorIndexNode is a leaf item from the Descriptor index b-tree
|
|
7
|
-
// It is like a pointer to an element in the PST file, everything has one...
|
|
8
|
-
class DescriptorIndexNode {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* JSON stringify the object properties.
|
|
45
|
-
* @returns {string}
|
|
46
|
-
* @memberof DescriptorIndexNode
|
|
47
|
-
*/
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
toJSON() {
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.DescriptorIndexNode = DescriptorIndexNode;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DescriptorIndexNode = void 0;
|
|
4
|
+
const PSTFile_class_1 = require("./PSTFile.class");
|
|
5
|
+
const PSTUtil_class_1 = require("./PSTUtil.class");
|
|
6
|
+
// DescriptorIndexNode is a leaf item from the Descriptor index b-tree
|
|
7
|
+
// It is like a pointer to an element in the PST file, everything has one...
|
|
8
|
+
class DescriptorIndexNode {
|
|
9
|
+
get descriptorIdentifier() {
|
|
10
|
+
return this._descriptorIdentifier;
|
|
11
|
+
}
|
|
12
|
+
get parentDescriptorIndexIdentifier() {
|
|
13
|
+
return this._parentDescriptorIndexIdentifier;
|
|
14
|
+
}
|
|
15
|
+
get localDescriptorsOffsetIndexIdentifier() {
|
|
16
|
+
return this._localDescriptorsOffsetIndexIdentifier;
|
|
17
|
+
}
|
|
18
|
+
get dataOffsetIndexIdentifier() {
|
|
19
|
+
return this._dataOffsetIndexIdentifier;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instance of DescriptorIndexNode, a component of the internal descriptor b-tree.
|
|
23
|
+
* @param {Buffer} buffer
|
|
24
|
+
* @param {number} pstFileType
|
|
25
|
+
* @memberof DescriptorIndexNode
|
|
26
|
+
*/
|
|
27
|
+
constructor(buffer, pstFileType) {
|
|
28
|
+
this.itemType = 0;
|
|
29
|
+
if (pstFileType == PSTFile_class_1.PSTFile.PST_TYPE_ANSI) {
|
|
30
|
+
this._descriptorIdentifier = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(buffer, 0, 4).toNumber();
|
|
31
|
+
this._dataOffsetIndexIdentifier = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(buffer, 4, 8);
|
|
32
|
+
this._localDescriptorsOffsetIndexIdentifier = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(buffer, 8, 12);
|
|
33
|
+
this._parentDescriptorIndexIdentifier = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(buffer, 12, 16).toNumber();
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this._descriptorIdentifier = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(buffer, 0, 4).toNumber();
|
|
37
|
+
this._dataOffsetIndexIdentifier = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(buffer, 8, 16);
|
|
38
|
+
this._localDescriptorsOffsetIndexIdentifier = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(buffer, 16, 24);
|
|
39
|
+
this._parentDescriptorIndexIdentifier = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(buffer, 24, 28).toNumber();
|
|
40
|
+
this.itemType = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(buffer, 28, 32).toNumber();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* JSON stringify the object properties.
|
|
45
|
+
* @returns {string}
|
|
46
|
+
* @memberof DescriptorIndexNode
|
|
47
|
+
*/
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
toJSON() {
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.DescriptorIndexNode = DescriptorIndexNode;
|
package/dist/LZFu.class.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
export declare class LZFu {
|
|
2
|
+
private static LZFU_HEADER;
|
|
3
|
+
/**
|
|
4
|
+
* Decompress the buffer of RTF content using LZ
|
|
5
|
+
* @static
|
|
6
|
+
* @param {Buffer} data
|
|
7
|
+
* @returns {string}
|
|
8
|
+
* @memberof LZFu
|
|
9
|
+
*/
|
|
10
|
+
static decode(data: Buffer): string;
|
|
11
|
+
}
|
package/dist/LZFu.class.js
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LZFu = void 0;
|
|
4
|
-
const PSTUtil_class_1 = require("./PSTUtil.class");
|
|
5
|
-
// An implementation of the LZFu algorithm to decompress RTF content
|
|
6
|
-
class LZFu {
|
|
7
|
-
/**
|
|
8
|
-
* Decompress the buffer of RTF content using LZ
|
|
9
|
-
* @static
|
|
10
|
-
* @param {Buffer} data
|
|
11
|
-
* @returns {string}
|
|
12
|
-
* @memberof LZFu
|
|
13
|
-
*/
|
|
14
|
-
static decode(data) {
|
|
15
|
-
// const compressedSize: number = PSTUtil.convertLittleEndianBytesToLong(
|
|
16
|
-
// data,
|
|
17
|
-
// 0,
|
|
18
|
-
// 4
|
|
19
|
-
// ).toNumber()
|
|
20
|
-
const uncompressedSize = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(data, 4, 8).toNumber();
|
|
21
|
-
const compressionSig = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(data, 8, 12).toNumber();
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
-
const compressedCRC = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(data, 12, 16).toNumber();
|
|
24
|
-
if (compressionSig == 0x75465a4c) {
|
|
25
|
-
// we are compressed...
|
|
26
|
-
const output = Buffer.alloc(uncompressedSize);
|
|
27
|
-
let outputPosition = 0;
|
|
28
|
-
const lzBuffer = Buffer.alloc(4096);
|
|
29
|
-
// preload our buffer.
|
|
30
|
-
try {
|
|
31
|
-
const bytes = Buffer.from(LZFu.LZFU_HEADER); //getBytes("US-ASCII");
|
|
32
|
-
PSTUtil_class_1.PSTUtil.arraycopy(bytes, 0, lzBuffer, 0, LZFu.LZFU_HEADER.length);
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
console.error('LZFu::decode cant preload buffer\n' + err);
|
|
36
|
-
throw err;
|
|
37
|
-
}
|
|
38
|
-
let bufferPosition = LZFu.LZFU_HEADER.length;
|
|
39
|
-
let currentDataPosition = 16;
|
|
40
|
-
// next byte is the flags,
|
|
41
|
-
while (currentDataPosition < data.length - 2 &&
|
|
42
|
-
outputPosition < output.length) {
|
|
43
|
-
let flags = data[currentDataPosition++] & 0xff;
|
|
44
|
-
for (let x = 0; x < 8 && outputPosition < output.length; x++) {
|
|
45
|
-
const isRef = (flags & 1) == 1;
|
|
46
|
-
flags >>= 1;
|
|
47
|
-
if (isRef) {
|
|
48
|
-
// get the starting point for the buffer and the length to read
|
|
49
|
-
const refOffsetOrig = data[currentDataPosition++] & 0xff;
|
|
50
|
-
const refSizeOrig = data[currentDataPosition++] & 0xff;
|
|
51
|
-
const refOffset = (refOffsetOrig << 4) | (refSizeOrig >>> 4);
|
|
52
|
-
const refSize = (refSizeOrig & 0xf) + 2;
|
|
53
|
-
try {
|
|
54
|
-
// copy the data from the buffer
|
|
55
|
-
let index = refOffset;
|
|
56
|
-
for (let y = 0; y < refSize && outputPosition < output.length; y++) {
|
|
57
|
-
output[outputPosition++] = lzBuffer[index];
|
|
58
|
-
lzBuffer[bufferPosition] = lzBuffer[index];
|
|
59
|
-
bufferPosition++;
|
|
60
|
-
bufferPosition %= 4096;
|
|
61
|
-
++index;
|
|
62
|
-
index %= 4096;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
console.error('LZFu::decode copy the data from the buffer\n' + err);
|
|
67
|
-
throw err;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// copy the byte over
|
|
72
|
-
lzBuffer[bufferPosition] = data[currentDataPosition];
|
|
73
|
-
bufferPosition++;
|
|
74
|
-
bufferPosition %= 4096;
|
|
75
|
-
output[outputPosition++] = data[currentDataPosition++];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (outputPosition != uncompressedSize) {
|
|
80
|
-
throw new Error('LZFu::constructor decode Error decompressing RTF');
|
|
81
|
-
}
|
|
82
|
-
return new String(output).trim();
|
|
83
|
-
}
|
|
84
|
-
else if (compressionSig == 0x414c454d) {
|
|
85
|
-
// we are not compressed!
|
|
86
|
-
// just return the rest of the contents as a string
|
|
87
|
-
const output = Buffer.alloc(data.length - 16);
|
|
88
|
-
PSTUtil_class_1.PSTUtil.arraycopy(data, 16, output, 0, data.length - 16);
|
|
89
|
-
return new String(output).trim();
|
|
90
|
-
}
|
|
91
|
-
return '';
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.LZFu = LZFu;
|
|
95
|
-
LZFu.LZFU_HEADER = '{\\rtf1\\ansi\\mac\\deff0\\deftab720{\\fonttbl;}{\\f0\\fnil \\froman \\fswiss \\fmodern \\fscript \\fdecor MS Sans SerifSymbolArialTimes New RomanCourier{\\colortbl\\red0\\green0\\blue0\n\r\\par \\pard\\plain\\f0\\fs20\\b\\i\\u\\tab\\tx';
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LZFu = void 0;
|
|
4
|
+
const PSTUtil_class_1 = require("./PSTUtil.class");
|
|
5
|
+
// An implementation of the LZFu algorithm to decompress RTF content
|
|
6
|
+
class LZFu {
|
|
7
|
+
/**
|
|
8
|
+
* Decompress the buffer of RTF content using LZ
|
|
9
|
+
* @static
|
|
10
|
+
* @param {Buffer} data
|
|
11
|
+
* @returns {string}
|
|
12
|
+
* @memberof LZFu
|
|
13
|
+
*/
|
|
14
|
+
static decode(data) {
|
|
15
|
+
// const compressedSize: number = PSTUtil.convertLittleEndianBytesToLong(
|
|
16
|
+
// data,
|
|
17
|
+
// 0,
|
|
18
|
+
// 4
|
|
19
|
+
// ).toNumber()
|
|
20
|
+
const uncompressedSize = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(data, 4, 8).toNumber();
|
|
21
|
+
const compressionSig = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(data, 8, 12).toNumber();
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
+
const compressedCRC = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(data, 12, 16).toNumber();
|
|
24
|
+
if (compressionSig == 0x75465a4c) {
|
|
25
|
+
// we are compressed...
|
|
26
|
+
const output = Buffer.alloc(uncompressedSize);
|
|
27
|
+
let outputPosition = 0;
|
|
28
|
+
const lzBuffer = Buffer.alloc(4096);
|
|
29
|
+
// preload our buffer.
|
|
30
|
+
try {
|
|
31
|
+
const bytes = Buffer.from(LZFu.LZFU_HEADER); //getBytes("US-ASCII");
|
|
32
|
+
PSTUtil_class_1.PSTUtil.arraycopy(bytes, 0, lzBuffer, 0, LZFu.LZFU_HEADER.length);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
console.error('LZFu::decode cant preload buffer\n' + err);
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
let bufferPosition = LZFu.LZFU_HEADER.length;
|
|
39
|
+
let currentDataPosition = 16;
|
|
40
|
+
// next byte is the flags,
|
|
41
|
+
while (currentDataPosition < data.length - 2 &&
|
|
42
|
+
outputPosition < output.length) {
|
|
43
|
+
let flags = data[currentDataPosition++] & 0xff;
|
|
44
|
+
for (let x = 0; x < 8 && outputPosition < output.length; x++) {
|
|
45
|
+
const isRef = (flags & 1) == 1;
|
|
46
|
+
flags >>= 1;
|
|
47
|
+
if (isRef) {
|
|
48
|
+
// get the starting point for the buffer and the length to read
|
|
49
|
+
const refOffsetOrig = data[currentDataPosition++] & 0xff;
|
|
50
|
+
const refSizeOrig = data[currentDataPosition++] & 0xff;
|
|
51
|
+
const refOffset = (refOffsetOrig << 4) | (refSizeOrig >>> 4);
|
|
52
|
+
const refSize = (refSizeOrig & 0xf) + 2;
|
|
53
|
+
try {
|
|
54
|
+
// copy the data from the buffer
|
|
55
|
+
let index = refOffset;
|
|
56
|
+
for (let y = 0; y < refSize && outputPosition < output.length; y++) {
|
|
57
|
+
output[outputPosition++] = lzBuffer[index];
|
|
58
|
+
lzBuffer[bufferPosition] = lzBuffer[index];
|
|
59
|
+
bufferPosition++;
|
|
60
|
+
bufferPosition %= 4096;
|
|
61
|
+
++index;
|
|
62
|
+
index %= 4096;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
console.error('LZFu::decode copy the data from the buffer\n' + err);
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// copy the byte over
|
|
72
|
+
lzBuffer[bufferPosition] = data[currentDataPosition];
|
|
73
|
+
bufferPosition++;
|
|
74
|
+
bufferPosition %= 4096;
|
|
75
|
+
output[outputPosition++] = data[currentDataPosition++];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (outputPosition != uncompressedSize) {
|
|
80
|
+
throw new Error('LZFu::constructor decode Error decompressing RTF');
|
|
81
|
+
}
|
|
82
|
+
return new String(output).trim();
|
|
83
|
+
}
|
|
84
|
+
else if (compressionSig == 0x414c454d) {
|
|
85
|
+
// we are not compressed!
|
|
86
|
+
// just return the rest of the contents as a string
|
|
87
|
+
const output = Buffer.alloc(data.length - 16);
|
|
88
|
+
PSTUtil_class_1.PSTUtil.arraycopy(data, 16, output, 0, data.length - 16);
|
|
89
|
+
return new String(output).trim();
|
|
90
|
+
}
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.LZFu = LZFu;
|
|
95
|
+
LZFu.LZFU_HEADER = '{\\rtf1\\ansi\\mac\\deff0\\deftab720{\\fonttbl;}{\\f0\\fnil \\froman \\fswiss \\fmodern \\fscript \\fdecor MS Sans SerifSymbolArialTimes New RomanCourier{\\colortbl\\red0\\green0\\blue0\n\r\\par \\pard\\plain\\f0\\fs20\\b\\i\\u\\tab\\tx';
|
package/dist/NodeInfo.class.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PSTNodeInputStream } from './PSTNodeInputStream.class';
|
|
3
|
-
export declare class NodeInfo {
|
|
4
|
-
private _startOffset;
|
|
5
|
-
get startOffset(): number;
|
|
6
|
-
private _endOffset;
|
|
7
|
-
get endOffset(): number;
|
|
8
|
-
length(): number;
|
|
9
|
-
private _pstNodeInputStream;
|
|
10
|
-
get pstNodeInputStream(): PSTNodeInputStream;
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of NodeInfo, part of the node table.
|
|
13
|
-
* @param {number} start
|
|
14
|
-
* @param {number} end
|
|
15
|
-
* @param {PSTNodeInputStream} pstNodeInputStream
|
|
16
|
-
* @memberof NodeInfo
|
|
17
|
-
*/
|
|
18
|
-
constructor(start: number, end: number, pstNodeInputStream: PSTNodeInputStream);
|
|
19
|
-
/**
|
|
20
|
-
* Seek to position in node input stream and read a long
|
|
21
|
-
* @param {long} offset
|
|
22
|
-
* @param {number} length
|
|
23
|
-
* @returns {long}
|
|
24
|
-
* @memberof NodeInfo
|
|
25
|
-
*/
|
|
26
|
-
seekAndReadLong(offset:
|
|
27
|
-
/**
|
|
28
|
-
* JSON stringify the object properties.
|
|
29
|
-
* @returns {string}
|
|
30
|
-
* @memberof NodeInfo
|
|
31
|
-
*/
|
|
32
|
-
toJSON(): any;
|
|
33
|
-
}
|
|
1
|
+
import Long from 'long';
|
|
2
|
+
import { PSTNodeInputStream } from './PSTNodeInputStream.class';
|
|
3
|
+
export declare class NodeInfo {
|
|
4
|
+
private _startOffset;
|
|
5
|
+
get startOffset(): number;
|
|
6
|
+
private _endOffset;
|
|
7
|
+
get endOffset(): number;
|
|
8
|
+
length(): number;
|
|
9
|
+
private _pstNodeInputStream;
|
|
10
|
+
get pstNodeInputStream(): PSTNodeInputStream;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of NodeInfo, part of the node table.
|
|
13
|
+
* @param {number} start
|
|
14
|
+
* @param {number} end
|
|
15
|
+
* @param {PSTNodeInputStream} pstNodeInputStream
|
|
16
|
+
* @memberof NodeInfo
|
|
17
|
+
*/
|
|
18
|
+
constructor(start: number, end: number, pstNodeInputStream: PSTNodeInputStream);
|
|
19
|
+
/**
|
|
20
|
+
* Seek to position in node input stream and read a long
|
|
21
|
+
* @param {long} offset
|
|
22
|
+
* @param {number} length
|
|
23
|
+
* @returns {long}
|
|
24
|
+
* @memberof NodeInfo
|
|
25
|
+
*/
|
|
26
|
+
seekAndReadLong(offset: Long, length: number): Long;
|
|
27
|
+
/**
|
|
28
|
+
* JSON stringify the object properties.
|
|
29
|
+
* @returns {string}
|
|
30
|
+
* @memberof NodeInfo
|
|
31
|
+
*/
|
|
32
|
+
toJSON(): any;
|
|
33
|
+
}
|