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.
Files changed (64) hide show
  1. package/dist/ColumnDescriptor.class.d.ts +26 -26
  2. package/dist/ColumnDescriptor.class.js +51 -48
  3. package/dist/DescriptorIndexNode.class.d.ts +25 -26
  4. package/dist/DescriptorIndexNode.class.js +53 -53
  5. package/dist/LZFu.class.d.ts +11 -12
  6. package/dist/LZFu.class.js +95 -95
  7. package/dist/NodeInfo.class.d.ts +33 -33
  8. package/dist/NodeInfo.class.js +52 -52
  9. package/dist/NodeMap.class.d.ts +35 -35
  10. package/dist/NodeMap.class.js +86 -83
  11. package/dist/OffsetIndexItem.class.d.ts +23 -24
  12. package/dist/OffsetIndexItem.class.js +45 -45
  13. package/dist/OutlookProperties.d.ts +275 -275
  14. package/dist/OutlookProperties.js +281 -281
  15. package/dist/PSTActivity.class.d.ts +103 -103
  16. package/dist/PSTActivity.class.js +144 -144
  17. package/dist/PSTAppointment.class.d.ts +270 -271
  18. package/dist/PSTAppointment.class.js +376 -376
  19. package/dist/PSTAttachment.class.d.ts +172 -172
  20. package/dist/PSTAttachment.class.js +317 -314
  21. package/dist/PSTContact.class.d.ts +884 -884
  22. package/dist/PSTContact.class.js +1227 -1227
  23. package/dist/PSTDescriptorItem.class.d.ts +45 -46
  24. package/dist/PSTDescriptorItem.class.js +99 -96
  25. package/dist/PSTFile.class.d.ts +215 -216
  26. package/dist/PSTFile.class.js +818 -792
  27. package/dist/PSTFolder.class.d.ts +129 -129
  28. package/dist/PSTFolder.class.js +318 -307
  29. package/dist/PSTMessage.class.d.ts +788 -789
  30. package/dist/PSTMessage.class.js +1321 -1318
  31. package/dist/PSTMessageStore.class.d.ts +13 -13
  32. package/dist/PSTMessageStore.class.js +17 -17
  33. package/dist/PSTNodeInputStream.class.d.ts +122 -123
  34. package/dist/PSTNodeInputStream.class.js +514 -488
  35. package/dist/PSTObject.class.d.ts +133 -134
  36. package/dist/PSTObject.class.js +326 -323
  37. package/dist/PSTRecipient.class.d.ts +65 -65
  38. package/dist/PSTRecipient.class.js +103 -103
  39. package/dist/PSTTable.class.d.ts +52 -52
  40. package/dist/PSTTable.class.js +175 -172
  41. package/dist/PSTTable7C.class.d.ts +45 -45
  42. package/dist/PSTTable7C.class.js +281 -278
  43. package/dist/PSTTableBC.class.d.ts +31 -31
  44. package/dist/PSTTableBC.class.js +111 -108
  45. package/dist/PSTTableItem.class.d.ts +47 -48
  46. package/dist/PSTTableItem.class.js +124 -121
  47. package/dist/PSTTask.class.d.ts +146 -146
  48. package/dist/PSTTask.class.js +205 -205
  49. package/dist/PSTUtil.class.d.ts +134 -135
  50. package/dist/PSTUtil.class.js +795 -790
  51. package/dist/RecurrencePattern.class.d.ts +49 -50
  52. package/dist/RecurrencePattern.class.js +120 -120
  53. package/dist/index.d.ts +6 -6
  54. package/dist/index.js +15 -15
  55. package/example/package.json +7 -7
  56. package/example/test-min.ts +31 -12
  57. package/example/{test-mem.ts → test.ts} +38 -30
  58. package/example/testdata/output.txt +278 -0
  59. package/example/testdata/outputBody.txt +3404 -0
  60. package/example/yarn.lock +112 -50
  61. package/junit.xml +36 -36
  62. package/package.json +28 -27
  63. package/readme.md +1 -3
  64. package/example/test-max.ts +0 -251
@@ -1,323 +1,326 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PSTObject = void 0;
4
- /* eslint-disable @typescript-eslint/no-explicit-any */
5
- const long = require("long");
6
- const OutlookProperties_1 = require("./OutlookProperties");
7
- const PSTNodeInputStream_class_1 = require("./PSTNodeInputStream.class");
8
- const PSTTableBC_class_1 = require("./PSTTableBC.class");
9
- const PSTUtil_class_1 = require("./PSTUtil.class");
10
- class PSTObject {
11
- /**
12
- * Creates an instance of PSTObject, the root class of most PST Items.
13
- * @memberof PSTObject
14
- */
15
- constructor(pstFile, descriptorIndexNode, pstTableItems) {
16
- this.descriptorIndexNode = null;
17
- this.localDescriptorItems = null;
18
- this.pstTableBC = null;
19
- this.pstTableItems = null;
20
- this.pstFile = pstFile;
21
- if (descriptorIndexNode) {
22
- this.loadDescriptor(descriptorIndexNode);
23
- }
24
- if (pstTableItems) {
25
- this.pstTableItems = pstTableItems;
26
- }
27
- }
28
- /**
29
- * Load a descriptor from the PST.
30
- * @protected
31
- * @param {PSTFile} pstFile
32
- * @param {DescriptorIndexNode} descriptorIndexNode
33
- * @memberof PSTObject
34
- */
35
- loadDescriptor(descriptorIndexNode) {
36
- this.descriptorIndexNode = descriptorIndexNode;
37
- // get the table items for this descriptor
38
- const offsetIndexItem = this.pstFile.getOffsetIndexNode(descriptorIndexNode.dataOffsetIndexIdentifier);
39
- const pstNodeInputStream = new PSTNodeInputStream_class_1.PSTNodeInputStream(this.pstFile, offsetIndexItem);
40
- this.pstTableBC = new PSTTableBC_class_1.PSTTableBC(pstNodeInputStream);
41
- this.pstTableItems = this.pstTableBC.getItems();
42
- if (descriptorIndexNode.localDescriptorsOffsetIndexIdentifier.notEquals(long.ZERO)) {
43
- this.localDescriptorItems = this.pstFile.getPSTDescriptorItems(descriptorIndexNode.localDescriptorsOffsetIndexIdentifier);
44
- }
45
- }
46
- /**
47
- * Get table items.
48
- * @protected
49
- * @param {PSTFile} theFile
50
- * @param {DescriptorIndexNode} folderIndexNode
51
- * @param {PSTTableBC} pstTableBC
52
- * @param {Map<number, PSTDescriptorItem>} localDescriptorItems
53
- * @memberof PSTObject
54
- */
55
- prePopulate(folderIndexNode, pstTableBC, localDescriptorItems) {
56
- this.descriptorIndexNode = folderIndexNode;
57
- this.pstTableItems = pstTableBC.getItems();
58
- this.pstTableBC = pstTableBC;
59
- this.localDescriptorItems = localDescriptorItems
60
- ? localDescriptorItems
61
- : null;
62
- }
63
- /**
64
- * Get the descriptor identifier for this item which can be used for loading objects
65
- * through detectAndLoadPSTObject(PSTFile theFile, long descriptorIndex)
66
- * @readonly
67
- * @type {long}
68
- * @memberof PSTObject
69
- */
70
- get descriptorNodeId() {
71
- // Prevent null pointer exceptions for embedded messages
72
- if (this.descriptorIndexNode != null) {
73
- return long.fromNumber(this.descriptorIndexNode.descriptorIdentifier);
74
- }
75
- else {
76
- return long.ZERO;
77
- }
78
- }
79
- /**
80
- * Get the node type for the descriptor id.
81
- * @param {number} [descriptorIdentifier]
82
- * @returns {number}
83
- * @memberof PSTObject
84
- */
85
- getNodeType(descriptorIdentifier) {
86
- if (descriptorIdentifier) {
87
- return descriptorIdentifier & 0x1f;
88
- }
89
- else if (this.descriptorIndexNode) {
90
- return this.descriptorIndexNode.descriptorIdentifier & 0x1f;
91
- }
92
- else {
93
- return -1;
94
- }
95
- }
96
- /**
97
- * Get a number.
98
- * @protected
99
- * @param {number} identifier
100
- * @param {number} [defaultValue]
101
- * @returns {number}
102
- * @memberof PSTObject
103
- */
104
- getIntItem(identifier, defaultValue) {
105
- if (!defaultValue) {
106
- defaultValue = 0;
107
- }
108
- if (this.pstTableItems && this.pstTableItems.has(identifier)) {
109
- const item = this.pstTableItems.get(identifier);
110
- if (item) {
111
- return item.entryValueReference;
112
- }
113
- }
114
- return defaultValue;
115
- }
116
- /**
117
- * Get a boolean.
118
- * @protected
119
- * @param {number} identifier
120
- * @param {boolean} [defaultValue]
121
- * @returns {boolean}
122
- * @memberof PSTObject
123
- */
124
- getBooleanItem(identifier, defaultValue) {
125
- if (defaultValue === undefined) {
126
- defaultValue = false;
127
- }
128
- if (this.pstTableItems && this.pstTableItems.has(identifier)) {
129
- const item = this.pstTableItems.get(identifier);
130
- if (item) {
131
- return item.entryValueReference != 0;
132
- }
133
- }
134
- return defaultValue;
135
- }
136
- /**
137
- * Get a double.
138
- * @protected
139
- * @param {number} identifier
140
- * @param {number} [defaultValue]
141
- * @returns {number}
142
- * @memberof PSTObject
143
- */
144
- getDoubleItem(identifier, defaultValue) {
145
- if (defaultValue === undefined) {
146
- defaultValue = 0;
147
- }
148
- if (this.pstTableItems && this.pstTableItems.has(identifier)) {
149
- const item = this.pstTableItems.get(identifier);
150
- if (item) {
151
- const longVersion = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(item.data);
152
- // interpret {low, high} signed 32 bit integers as double
153
- return new Float64Array(new Int32Array([longVersion.low, longVersion.high]).buffer)[0];
154
- }
155
- }
156
- return defaultValue;
157
- }
158
- /**
159
- * Get a long.
160
- * @protected
161
- * @param {number} identifier
162
- * @param {long} [defaultValue]
163
- * @returns {long}
164
- * @memberof PSTObject
165
- */
166
- getLongItem(identifier, defaultValue) {
167
- if (defaultValue === undefined) {
168
- defaultValue = long.ZERO;
169
- }
170
- if (this.pstTableItems && this.pstTableItems.has(identifier)) {
171
- const item = this.pstTableItems.get(identifier);
172
- if (item && item.entryValueType == 0x0003) {
173
- // we are really just an int
174
- return long.fromNumber(item.entryValueReference);
175
- }
176
- else if (item && item.entryValueType == 0x0014) {
177
- // we are a long
178
- if (item.data != null && item.data.length == 8) {
179
- return PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(item.data, 0, 8);
180
- }
181
- else {
182
- console.error('PSTObject::getLongItem Invalid data length for long id ' +
183
- identifier);
184
- // Return the default value for now...
185
- }
186
- }
187
- }
188
- return defaultValue;
189
- }
190
- /**
191
- * Get a string.
192
- * @protected
193
- * @param {number} identifier
194
- * @param {number} [stringType]
195
- * @param {string} [codepage]
196
- * @returns {string}
197
- * @memberof PSTObject
198
- */
199
- getStringItem(identifier, stringType, codepage) {
200
- if (!stringType) {
201
- stringType = 0;
202
- }
203
- const item = this.pstTableItems
204
- ? this.pstTableItems.get(identifier)
205
- : undefined;
206
- if (item) {
207
- if (!codepage) {
208
- codepage = this.stringCodepage;
209
- }
210
- // get the string type from the item if not explicitly set
211
- if (!stringType) {
212
- stringType = item.entryValueType;
213
- }
214
- // see if there is a descriptor entry
215
- if (!item.isExternalValueReference) {
216
- return PSTUtil_class_1.PSTUtil.createJavascriptString(item.data, stringType, codepage);
217
- }
218
- if (this.localDescriptorItems != null &&
219
- this.localDescriptorItems.has(item.entryValueReference)) {
220
- // we have a hit!
221
- const descItem = this.localDescriptorItems.get(item.entryValueReference);
222
- try {
223
- const data = descItem ? descItem.getData() : null;
224
- if (data == null) {
225
- return '';
226
- }
227
- return PSTUtil_class_1.PSTUtil.createJavascriptString(data, stringType, codepage);
228
- }
229
- catch (err) {
230
- console.error('PSTObject::getStringItem error decoding string\n' + err);
231
- return '';
232
- }
233
- }
234
- }
235
- return '';
236
- }
237
- /**
238
- * Get a codepage.
239
- * @readonly
240
- * @type {string}
241
- * @memberof PSTObject
242
- */
243
- get stringCodepage() {
244
- // try and get the codepage
245
- let cpItem = this.pstTableItems ? this.pstTableItems.get(0x3ffd) : null; // PidTagMessageCodepage
246
- if (cpItem == null) {
247
- cpItem = this.pstTableItems ? this.pstTableItems.get(0x3fde) : null; // PidTagInternetCodepage
248
- }
249
- if (cpItem != null) {
250
- return PSTUtil_class_1.PSTUtil.getInternetCodePageCharset(cpItem.entryValueReference);
251
- }
252
- return '';
253
- }
254
- /**
255
- * Get a date.
256
- * @param {number} identifier
257
- * @returns {Date}
258
- * @memberof PSTObject
259
- */
260
- getDateItem(identifier) {
261
- if (this.pstTableItems && this.pstTableItems.has(identifier)) {
262
- const item = this.pstTableItems.get(identifier);
263
- if (item && item.data.length == 0) {
264
- return new Date(0);
265
- }
266
- if (item) {
267
- const hi = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(item.data, 4, 8);
268
- const low = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(item.data, 0, 4);
269
- return PSTUtil_class_1.PSTUtil.filetimeToDate(hi, low);
270
- }
271
- }
272
- return null;
273
- }
274
- /**
275
- * Get a blob.
276
- * @protected
277
- * @param {number} identifier
278
- * @returns {Buffer}
279
- * @memberof PSTObject
280
- */
281
- getBinaryItem(identifier) {
282
- if (this.pstTableItems && this.pstTableItems.has(identifier)) {
283
- const item = this.pstTableItems.get(identifier);
284
- if (item && item.entryValueType == 0x0102) {
285
- if (!item.isExternalValueReference) {
286
- return item.data;
287
- }
288
- if (this.localDescriptorItems != null &&
289
- this.localDescriptorItems.has(item.entryValueReference)) {
290
- // we have a hit!
291
- const descItem = this.localDescriptorItems.get(item.entryValueReference);
292
- try {
293
- return descItem ? descItem.getData() : null;
294
- }
295
- catch (err) {
296
- console.error('PSTObject::Exception reading binary item\n' + err);
297
- throw err;
298
- }
299
- }
300
- }
301
- }
302
- return null;
303
- }
304
- /**
305
- * Get the display name of this object.
306
- * https://msdn.microsoft.com/en-us/library/office/cc842383.aspx
307
- * @readonly
308
- * @type {string}
309
- * @memberof PSTObject
310
- */
311
- get displayName() {
312
- return this.getStringItem(OutlookProperties_1.OutlookProperties.PR_DISPLAY_NAME);
313
- }
314
- /**
315
- * JSON the object.
316
- * @returns {string}
317
- * @memberof PSTObject
318
- */
319
- toJSON() {
320
- return this;
321
- }
322
- }
323
- exports.PSTObject = PSTObject;
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.PSTObject = void 0;
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ const long_1 = __importDefault(require("long"));
9
+ const OutlookProperties_1 = require("./OutlookProperties");
10
+ const PSTNodeInputStream_class_1 = require("./PSTNodeInputStream.class");
11
+ const PSTTableBC_class_1 = require("./PSTTableBC.class");
12
+ const PSTUtil_class_1 = require("./PSTUtil.class");
13
+ class PSTObject {
14
+ /**
15
+ * Creates an instance of PSTObject, the root class of most PST Items.
16
+ * @memberof PSTObject
17
+ */
18
+ constructor(pstFile, descriptorIndexNode, pstTableItems) {
19
+ this.descriptorIndexNode = null;
20
+ this.localDescriptorItems = null;
21
+ this.pstTableBC = null;
22
+ this.pstTableItems = null;
23
+ this.pstFile = pstFile;
24
+ if (descriptorIndexNode) {
25
+ this.loadDescriptor(descriptorIndexNode);
26
+ }
27
+ if (pstTableItems) {
28
+ this.pstTableItems = pstTableItems;
29
+ }
30
+ }
31
+ /**
32
+ * Load a descriptor from the PST.
33
+ * @protected
34
+ * @param {PSTFile} pstFile
35
+ * @param {DescriptorIndexNode} descriptorIndexNode
36
+ * @memberof PSTObject
37
+ */
38
+ loadDescriptor(descriptorIndexNode) {
39
+ this.descriptorIndexNode = descriptorIndexNode;
40
+ // get the table items for this descriptor
41
+ const offsetIndexItem = this.pstFile.getOffsetIndexNode(descriptorIndexNode.dataOffsetIndexIdentifier);
42
+ const pstNodeInputStream = new PSTNodeInputStream_class_1.PSTNodeInputStream(this.pstFile, offsetIndexItem);
43
+ this.pstTableBC = new PSTTableBC_class_1.PSTTableBC(pstNodeInputStream);
44
+ this.pstTableItems = this.pstTableBC.getItems();
45
+ if (descriptorIndexNode.localDescriptorsOffsetIndexIdentifier.notEquals(long_1.default.ZERO)) {
46
+ this.localDescriptorItems = this.pstFile.getPSTDescriptorItems(descriptorIndexNode.localDescriptorsOffsetIndexIdentifier);
47
+ }
48
+ }
49
+ /**
50
+ * Get table items.
51
+ * @protected
52
+ * @param {PSTFile} theFile
53
+ * @param {DescriptorIndexNode} folderIndexNode
54
+ * @param {PSTTableBC} pstTableBC
55
+ * @param {Map<number, PSTDescriptorItem>} localDescriptorItems
56
+ * @memberof PSTObject
57
+ */
58
+ prePopulate(folderIndexNode, pstTableBC, localDescriptorItems) {
59
+ this.descriptorIndexNode = folderIndexNode;
60
+ this.pstTableItems = pstTableBC.getItems();
61
+ this.pstTableBC = pstTableBC;
62
+ this.localDescriptorItems = localDescriptorItems
63
+ ? localDescriptorItems
64
+ : null;
65
+ }
66
+ /**
67
+ * Get the descriptor identifier for this item which can be used for loading objects
68
+ * through detectAndLoadPSTObject(PSTFile theFile, long descriptorIndex)
69
+ * @readonly
70
+ * @type {long}
71
+ * @memberof PSTObject
72
+ */
73
+ get descriptorNodeId() {
74
+ // Prevent null pointer exceptions for embedded messages
75
+ if (this.descriptorIndexNode != null) {
76
+ return long_1.default.fromNumber(this.descriptorIndexNode.descriptorIdentifier);
77
+ }
78
+ else {
79
+ return long_1.default.ZERO;
80
+ }
81
+ }
82
+ /**
83
+ * Get the node type for the descriptor id.
84
+ * @param {number} [descriptorIdentifier]
85
+ * @returns {number}
86
+ * @memberof PSTObject
87
+ */
88
+ getNodeType(descriptorIdentifier) {
89
+ if (descriptorIdentifier) {
90
+ return descriptorIdentifier & 0x1f;
91
+ }
92
+ else if (this.descriptorIndexNode) {
93
+ return this.descriptorIndexNode.descriptorIdentifier & 0x1f;
94
+ }
95
+ else {
96
+ return -1;
97
+ }
98
+ }
99
+ /**
100
+ * Get a number.
101
+ * @protected
102
+ * @param {number} identifier
103
+ * @param {number} [defaultValue]
104
+ * @returns {number}
105
+ * @memberof PSTObject
106
+ */
107
+ getIntItem(identifier, defaultValue) {
108
+ if (!defaultValue) {
109
+ defaultValue = 0;
110
+ }
111
+ if (this.pstTableItems && this.pstTableItems.has(identifier)) {
112
+ const item = this.pstTableItems.get(identifier);
113
+ if (item) {
114
+ return item.entryValueReference;
115
+ }
116
+ }
117
+ return defaultValue;
118
+ }
119
+ /**
120
+ * Get a boolean.
121
+ * @protected
122
+ * @param {number} identifier
123
+ * @param {boolean} [defaultValue]
124
+ * @returns {boolean}
125
+ * @memberof PSTObject
126
+ */
127
+ getBooleanItem(identifier, defaultValue) {
128
+ if (defaultValue === undefined) {
129
+ defaultValue = false;
130
+ }
131
+ if (this.pstTableItems && this.pstTableItems.has(identifier)) {
132
+ const item = this.pstTableItems.get(identifier);
133
+ if (item) {
134
+ return item.entryValueReference != 0;
135
+ }
136
+ }
137
+ return defaultValue;
138
+ }
139
+ /**
140
+ * Get a double.
141
+ * @protected
142
+ * @param {number} identifier
143
+ * @param {number} [defaultValue]
144
+ * @returns {number}
145
+ * @memberof PSTObject
146
+ */
147
+ getDoubleItem(identifier, defaultValue) {
148
+ if (defaultValue === undefined) {
149
+ defaultValue = 0;
150
+ }
151
+ if (this.pstTableItems && this.pstTableItems.has(identifier)) {
152
+ const item = this.pstTableItems.get(identifier);
153
+ if (item) {
154
+ const longVersion = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(item.data);
155
+ // interpret {low, high} signed 32 bit integers as double
156
+ return new Float64Array(new Int32Array([longVersion.low, longVersion.high]).buffer)[0];
157
+ }
158
+ }
159
+ return defaultValue;
160
+ }
161
+ /**
162
+ * Get a long.
163
+ * @protected
164
+ * @param {number} identifier
165
+ * @param {long} [defaultValue]
166
+ * @returns {long}
167
+ * @memberof PSTObject
168
+ */
169
+ getLongItem(identifier, defaultValue) {
170
+ if (defaultValue === undefined) {
171
+ defaultValue = long_1.default.ZERO;
172
+ }
173
+ if (this.pstTableItems && this.pstTableItems.has(identifier)) {
174
+ const item = this.pstTableItems.get(identifier);
175
+ if (item && item.entryValueType == 0x0003) {
176
+ // we are really just an int
177
+ return long_1.default.fromNumber(item.entryValueReference);
178
+ }
179
+ else if (item && item.entryValueType == 0x0014) {
180
+ // we are a long
181
+ if (item.data != null && item.data.length == 8) {
182
+ return PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(item.data, 0, 8);
183
+ }
184
+ else {
185
+ console.error('PSTObject::getLongItem Invalid data length for long id ' +
186
+ identifier);
187
+ // Return the default value for now...
188
+ }
189
+ }
190
+ }
191
+ return defaultValue;
192
+ }
193
+ /**
194
+ * Get a string.
195
+ * @protected
196
+ * @param {number} identifier
197
+ * @param {number} [stringType]
198
+ * @param {string} [codepage]
199
+ * @returns {string}
200
+ * @memberof PSTObject
201
+ */
202
+ getStringItem(identifier, stringType, codepage) {
203
+ if (!stringType) {
204
+ stringType = 0;
205
+ }
206
+ const item = this.pstTableItems
207
+ ? this.pstTableItems.get(identifier)
208
+ : undefined;
209
+ if (item) {
210
+ if (!codepage) {
211
+ codepage = this.stringCodepage;
212
+ }
213
+ // get the string type from the item if not explicitly set
214
+ if (!stringType) {
215
+ stringType = item.entryValueType;
216
+ }
217
+ // see if there is a descriptor entry
218
+ if (!item.isExternalValueReference) {
219
+ return PSTUtil_class_1.PSTUtil.createJavascriptString(item.data, stringType, codepage);
220
+ }
221
+ if (this.localDescriptorItems != null &&
222
+ this.localDescriptorItems.has(item.entryValueReference)) {
223
+ // we have a hit!
224
+ const descItem = this.localDescriptorItems.get(item.entryValueReference);
225
+ try {
226
+ const data = descItem ? descItem.getData() : null;
227
+ if (data == null) {
228
+ return '';
229
+ }
230
+ return PSTUtil_class_1.PSTUtil.createJavascriptString(data, stringType, codepage);
231
+ }
232
+ catch (err) {
233
+ console.error('PSTObject::getStringItem error decoding string\n' + err);
234
+ return '';
235
+ }
236
+ }
237
+ }
238
+ return '';
239
+ }
240
+ /**
241
+ * Get a codepage.
242
+ * @readonly
243
+ * @type {string}
244
+ * @memberof PSTObject
245
+ */
246
+ get stringCodepage() {
247
+ // try and get the codepage
248
+ let cpItem = this.pstTableItems ? this.pstTableItems.get(0x3ffd) : null; // PidTagMessageCodepage
249
+ if (cpItem == null) {
250
+ cpItem = this.pstTableItems ? this.pstTableItems.get(0x3fde) : null; // PidTagInternetCodepage
251
+ }
252
+ if (cpItem != null) {
253
+ return PSTUtil_class_1.PSTUtil.getInternetCodePageCharset(cpItem.entryValueReference);
254
+ }
255
+ return '';
256
+ }
257
+ /**
258
+ * Get a date.
259
+ * @param {number} identifier
260
+ * @returns {Date}
261
+ * @memberof PSTObject
262
+ */
263
+ getDateItem(identifier) {
264
+ if (this.pstTableItems && this.pstTableItems.has(identifier)) {
265
+ const item = this.pstTableItems.get(identifier);
266
+ if (item && item.data.length == 0) {
267
+ return new Date(0);
268
+ }
269
+ if (item) {
270
+ const hi = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(item.data, 4, 8);
271
+ const low = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(item.data, 0, 4);
272
+ return PSTUtil_class_1.PSTUtil.filetimeToDate(hi, low);
273
+ }
274
+ }
275
+ return null;
276
+ }
277
+ /**
278
+ * Get a blob.
279
+ * @protected
280
+ * @param {number} identifier
281
+ * @returns {Buffer}
282
+ * @memberof PSTObject
283
+ */
284
+ getBinaryItem(identifier) {
285
+ if (this.pstTableItems && this.pstTableItems.has(identifier)) {
286
+ const item = this.pstTableItems.get(identifier);
287
+ if (item && item.entryValueType == 0x0102) {
288
+ if (!item.isExternalValueReference) {
289
+ return item.data;
290
+ }
291
+ if (this.localDescriptorItems != null &&
292
+ this.localDescriptorItems.has(item.entryValueReference)) {
293
+ // we have a hit!
294
+ const descItem = this.localDescriptorItems.get(item.entryValueReference);
295
+ try {
296
+ return descItem ? descItem.getData() : null;
297
+ }
298
+ catch (err) {
299
+ console.error('PSTObject::Exception reading binary item\n' + err);
300
+ throw err;
301
+ }
302
+ }
303
+ }
304
+ }
305
+ return null;
306
+ }
307
+ /**
308
+ * Get the display name of this object.
309
+ * https://msdn.microsoft.com/en-us/library/office/cc842383.aspx
310
+ * @readonly
311
+ * @type {string}
312
+ * @memberof PSTObject
313
+ */
314
+ get displayName() {
315
+ return this.getStringItem(OutlookProperties_1.OutlookProperties.PR_DISPLAY_NAME);
316
+ }
317
+ /**
318
+ * JSON the object.
319
+ * @returns {string}
320
+ * @memberof PSTObject
321
+ */
322
+ toJSON() {
323
+ return this;
324
+ }
325
+ }
326
+ exports.PSTObject = PSTObject;