pst-extractor 1.9.0 → 1.11.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 (59) hide show
  1. package/dist/ColumnDescriptor.class.d.ts +26 -26
  2. package/dist/ColumnDescriptor.class.js +51 -51
  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 -86
  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 -317
  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 -99
  25. package/dist/PSTFile.class.d.ts +215 -216
  26. package/dist/PSTFile.class.js +830 -818
  27. package/dist/PSTFolder.class.d.ts +129 -129
  28. package/dist/PSTFolder.class.js +318 -310
  29. package/dist/PSTMessage.class.d.ts +788 -789
  30. package/dist/PSTMessage.class.js +1321 -1321
  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 +524 -514
  35. package/dist/PSTObject.class.d.ts +133 -134
  36. package/dist/PSTObject.class.js +326 -326
  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 -175
  41. package/dist/PSTTable7C.class.d.ts +45 -45
  42. package/dist/PSTTable7C.class.js +282 -281
  43. package/dist/PSTTableBC.class.d.ts +31 -31
  44. package/dist/PSTTableBC.class.js +111 -111
  45. package/dist/PSTTableItem.class.d.ts +47 -48
  46. package/dist/PSTTableItem.class.js +124 -124
  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 -795
  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 +6 -6
  56. package/example/yarn.lock +120 -67
  57. package/junit.xml +68 -68
  58. package/package.json +26 -26
  59. package/readme.md +3 -3
@@ -1,326 +1,326 @@
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;
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;