pst-extractor 1.9.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 (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 +818 -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 +514 -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 +281 -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 +95 -44
  57. package/junit.xml +68 -68
  58. package/package.json +26 -26
  59. package/readme.md +1 -3
@@ -1,795 +1,795 @@
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.PSTUtil = void 0;
7
- /* eslint-disable @typescript-eslint/no-explicit-any */
8
- const long_1 = __importDefault(require("long"));
9
- const PSTAppointment_class_1 = require("./PSTAppointment.class");
10
- const PSTContact_class_1 = require("./PSTContact.class");
11
- const PSTFolder_class_1 = require("./PSTFolder.class");
12
- const PSTMessage_class_1 = require("./PSTMessage.class");
13
- const PSTNodeInputStream_class_1 = require("./PSTNodeInputStream.class");
14
- const PSTTableBC_class_1 = require("./PSTTableBC.class");
15
- const PSTTask_class_1 = require("./PSTTask.class");
16
- const PSTActivity_class_1 = require("./PSTActivity.class");
17
- const iconv_lite_1 = __importDefault(require("iconv-lite"));
18
- /**
19
- * Utility functions for PST components
20
- * @export
21
- * @class PSTUtil
22
- */
23
- class PSTUtil {
24
- /**
25
- * Convert little endian bytes to long
26
- * @static
27
- * @param {Buffer} data
28
- * @param {number} [start]
29
- * @param {number} [end]
30
- * @returns {long}
31
- * @memberof PSTUtil
32
- */
33
- static convertLittleEndianBytesToLong(data, start, end) {
34
- if (!start) {
35
- start = 0;
36
- }
37
- if (!end) {
38
- end = data.length;
39
- }
40
- let offset = long_1.default.fromNumber(data[end - 1] & 0xff);
41
- let tmpLongValue;
42
- for (let x = end - 2; x >= start; x--) {
43
- offset = offset.shiftLeft(8);
44
- tmpLongValue = long_1.default.fromNumber(data[x] & 0xff);
45
- offset = offset.xor(tmpLongValue);
46
- }
47
- return offset;
48
- }
49
- /**
50
- * Convert big endian bytes to long
51
- * @static
52
- * @param {Buffer} data
53
- * @param {number} [start]
54
- * @param {number} [end]
55
- * @returns {long}
56
- * @memberof PSTUtil
57
- */
58
- static convertBigEndianBytesToLong(data, start, end) {
59
- if (!start) {
60
- start = 0;
61
- }
62
- if (!end) {
63
- end = data.length;
64
- }
65
- let offset = long_1.default.ZERO;
66
- for (let x = start; x < end; ++x) {
67
- offset = offset.shiftLeft(8);
68
- const tmpLongValue = long_1.default.fromNumber(data[x] & 0xff);
69
- offset = offset.xor(tmpLongValue);
70
- }
71
- return offset;
72
- }
73
- /**
74
- * Handle strings using codepages.
75
- * @static
76
- * @param {number} propertyId
77
- * @returns
78
- * @memberof PSTUtil
79
- */
80
- static getInternetCodePageCharset(propertyId) {
81
- return this.codePages.get(propertyId);
82
- }
83
- /**
84
- * Create JS string from buffer.
85
- * @static
86
- * @param {Buffer} data
87
- * @param {number} stringType
88
- * @param {string} codepage
89
- * @returns
90
- * @memberof PSTUtil
91
- */
92
- static createJavascriptString(data, stringType, codepage = 'utf8') {
93
- // TODO - codepage is not used...
94
- try {
95
- if (stringType == 0x1f) {
96
- // convert and trim any nulls
97
- return data.toString('utf16le').replace(/\0/g, '');
98
- }
99
- else {
100
- return iconv_lite_1.default.decode(data, codepage).toString();
101
- }
102
- }
103
- catch (err) {
104
- console.error('PSTUtil::createJavascriptString Unable to decode string\n' + err);
105
- throw err;
106
- }
107
- return '';
108
- }
109
- /**
110
- * Copy from one array to another
111
- * @static
112
- * @param {Buffer} src
113
- * @param {number} srcPos
114
- * @param {Buffer} dest
115
- * @param {number} destPos
116
- * @param {number} length
117
- * @memberof PSTUtil
118
- */
119
- static arraycopy(src, srcPos, dest, destPos, length) {
120
- // TODO FIX THIS - TOO SLOW?
121
- let s = srcPos;
122
- let d = destPos;
123
- let i = 0;
124
- while (i++ < length) {
125
- dest[d++] = src[s++];
126
- }
127
- }
128
- /**
129
- * Decode a lump of data that has been encrypted with the compressible encryption
130
- * @static
131
- * @param {Buffer} data
132
- * @returns {Buffer}
133
- * @memberof PSTUtil
134
- */
135
- static decode(data) {
136
- let temp;
137
- for (let x = 0; x < data.length; x++) {
138
- temp = data[x] & 0xff;
139
- data[x] = this.compEnc[temp];
140
- }
141
- return data;
142
- }
143
- static detectAndLoadPSTObject(theFile, arg) {
144
- let folderIndexNode = arg;
145
- if (typeof arg === 'object' && arg.hasOwnProperty('low')) {
146
- folderIndexNode = theFile.getDescriptorIndexNode(arg);
147
- }
148
- const nidType = folderIndexNode.descriptorIdentifier & 0x1f;
149
- if (nidType == 0x02 || nidType == 0x03 || nidType == 0x04) {
150
- const table = new PSTTableBC_class_1.PSTTableBC(new PSTNodeInputStream_class_1.PSTNodeInputStream(theFile, theFile.getOffsetIndexNode(folderIndexNode.dataOffsetIndexIdentifier)));
151
- let localDescriptorItems = undefined;
152
- if (folderIndexNode.localDescriptorsOffsetIndexIdentifier != 0) {
153
- localDescriptorItems = theFile.getPSTDescriptorItems(folderIndexNode.localDescriptorsOffsetIndexIdentifier);
154
- }
155
- if (nidType == 0x02 || nidType == 0x03) {
156
- return new PSTFolder_class_1.PSTFolder(theFile, folderIndexNode, table, localDescriptorItems);
157
- }
158
- else {
159
- return this.createAppropriatePSTMessageObject(theFile, folderIndexNode, table, localDescriptorItems);
160
- }
161
- }
162
- else {
163
- throw new Error('PSTUtil::detectAndLoadPSTObject Unknown child type with offset id: ' +
164
- folderIndexNode.localDescriptorsOffsetIndexIdentifier);
165
- }
166
- }
167
- /**
168
- * Creates object based on message class
169
- * https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/item-types-and-message-classes
170
- * @static
171
- * @param {PSTFile} theFile
172
- * @param {DescriptorIndexNode} folderIndexNode
173
- * @param {PSTTableBC} table
174
- * @param {Map<number, PSTDescriptorItem>} localDescriptorItems
175
- * @returns {PSTMessage}
176
- * @memberof PSTUtil
177
- */
178
- static createAppropriatePSTMessageObject(theFile, folderIndexNode, table, localDescriptorItems) {
179
- const item = table.getItems().get(0x001a);
180
- let messageClass = '';
181
- if (item != null) {
182
- messageClass = item.getStringValue();
183
- }
184
- switch (messageClass) {
185
- case 'IPM.Note':
186
- case 'IPM.Note.SMIME.MultipartSigned':
187
- case 'IPM.Note.Agenda':
188
- // email message
189
- const msg = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
190
- // Log.debug1(msg.body);
191
- // Log.debug1(msg.numberOfRecipients.toString());
192
- // Log.debug1(msg.colorCategories.toString());
193
- // Log.debug1(JSON.stringify(msg, null, 2));
194
- return msg;
195
- case 'IPM.Appointment':
196
- case 'IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}':
197
- case 'IPM.Schedule.Meeting.Canceled':
198
- case 'IPM.Schedule.Meeting.Resp.Pos':
199
- case 'IPM.Schedule.Meeting.Resp.Tent':
200
- case 'IPM.Schedule.Meeting.Notification.Forward':
201
- case 'IPM.Schedule.Meeting.Resp.Neg':
202
- // appointment
203
- // messageClass.startsWith('IPM.Schedule.Meeting')
204
- const apt = new PSTAppointment_class_1.PSTAppointment(theFile, folderIndexNode, table, localDescriptorItems);
205
- // Log.debug1(JSON.stringify(msg, null, 2));
206
- return apt;
207
- case 'IPM.Contact':
208
- // contact
209
- const contact = new PSTContact_class_1.PSTContact(theFile, folderIndexNode, table, localDescriptorItems);
210
- // Log.debug1(JSON.stringify(msg, null, 2));
211
- return contact;
212
- case 'IPM.Task':
213
- // task
214
- const task = new PSTTask_class_1.PSTTask(theFile, folderIndexNode, table, localDescriptorItems);
215
- // Log.debug1(JSON.stringify(msg, null, 2));
216
- return task;
217
- case 'IPM.Activity':
218
- // journal entry
219
- const activity = new PSTActivity_class_1.PSTActivity(theFile, folderIndexNode, table, localDescriptorItems);
220
- // Log.debug1(JSON.stringify(msg, null, 2));
221
- return activity;
222
- case 'IPM.Post.Rss':
223
- // debugger;
224
- // Rss Feed
225
- const rss = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
226
- // Log.debug1(JSON.stringify(msg, null, 2));
227
- return rss;
228
- case 'IPM.DistList':
229
- // debugger;
230
- // Distribution list
231
- const dl = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
232
- // Log.debug1(JSON.stringify(msg, null, 2));
233
- return dl;
234
- // return new PSTDistList(theFile, folderIndexNode, table, localDescriptorItems);
235
- case 'IPM.Note.Rules.OofTemplate.Microsoft':
236
- // debugger;
237
- // Out of Office rule
238
- const oof = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
239
- // Log.debug1(JSON.stringify(msg, null, 2));
240
- return oof;
241
- case 'IPM.Schedule.Meeting.Request':
242
- // Meeting request
243
- const meetReq = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
244
- // Log.debug1(JSON.stringify(msg, null, 2));
245
- return meetReq;
246
- case 'REPORT.IPM.Note.NDR':
247
- // Receipt of non-delivery
248
- const ndr = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
249
- // Log.debug1(JSON.stringify(msg, null, 2));
250
- return ndr;
251
- case 'IPM.StickyNote':
252
- // Sticky note
253
- const sticky = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
254
- // Log.debug1(JSON.stringify(msg, null, 2));
255
- return sticky;
256
- case 'REPORT.IPM.Note.IPNRN':
257
- // Read receipt
258
- // debugger;
259
- // console.log('PSTUtil::createAppropriatePSTMessageObject REPORT.IPM.Note.IPNRN');
260
- return new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
261
- case 'REPORT.IPM.Note.IPNNRN':
262
- // Not-read notification
263
- // debugger;
264
- // console.log('PSTUtil::createAppropriatePSTMessageObject REPORT.IPM.Note.IPNNRN');
265
- return new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
266
- case 'IPM.Schedule.Meeting.Request':
267
- // Meeting request
268
- // debugger;
269
- // console.log('PSTUtil::createAppropriatePSTMessageObject IPM.Schedule.Meeting.Request');
270
- return new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
271
- case 'REPORT.IPM.Note.DR':
272
- // Delivery receipt
273
- // debugger;
274
- // console.log('PSTUtil::createAppropriatePSTMessageObject REPORT.IPM.Note.DR');
275
- return new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
276
- default:
277
- console.error('PSTUtil::createAppropriatePSTMessageObject unknown message type: ' +
278
- messageClass);
279
- }
280
- return new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
281
- }
282
- /**
283
- * Converts a Windows FILETIME into a {@link Date}. The Windows FILETIME structure holds a date and time associated with a
284
- * file. The structure identifies a 64-bit integer specifying the number of 100-nanosecond intervals which have passed since
285
- * January 1, 1601. This 64-bit value is split into the two double words stored in the structure.
286
- *
287
- * @static
288
- * @param {long} hi
289
- * @param {long} low
290
- * @returns {Date}
291
- * @memberof PSTUtil
292
- */
293
- static filetimeToDate(hi, low) {
294
- const h = hi.shiftLeft(32);
295
- const l = low.and(0xffffffff);
296
- const filetime = h.or(l);
297
- const msSince16010101 = filetime.divide(1000 * 10);
298
- const epochDiff = long_1.default.fromValue('11644473600000');
299
- const msSince19700101 = msSince16010101.subtract(epochDiff);
300
- return new Date(msSince19700101.toNumber());
301
- }
302
- }
303
- exports.PSTUtil = PSTUtil;
304
- // substitution table for the compressible encryption type.
305
- PSTUtil.compEnc = [
306
- 0x47,
307
- 0xf1,
308
- 0xb4,
309
- 0xe6,
310
- 0x0b,
311
- 0x6a,
312
- 0x72,
313
- 0x48,
314
- 0x85,
315
- 0x4e,
316
- 0x9e,
317
- 0xeb,
318
- 0xe2,
319
- 0xf8,
320
- 0x94,
321
- 0x53,
322
- 0xe0,
323
- 0xbb,
324
- 0xa0,
325
- 0x02,
326
- 0xe8,
327
- 0x5a,
328
- 0x09,
329
- 0xab,
330
- 0xdb,
331
- 0xe3,
332
- 0xba,
333
- 0xc6,
334
- 0x7c,
335
- 0xc3,
336
- 0x10,
337
- 0xdd,
338
- 0x39,
339
- 0x05,
340
- 0x96,
341
- 0x30,
342
- 0xf5,
343
- 0x37,
344
- 0x60,
345
- 0x82,
346
- 0x8c,
347
- 0xc9,
348
- 0x13,
349
- 0x4a,
350
- 0x6b,
351
- 0x1d,
352
- 0xf3,
353
- 0xfb,
354
- 0x8f,
355
- 0x26,
356
- 0x97,
357
- 0xca,
358
- 0x91,
359
- 0x17,
360
- 0x01,
361
- 0xc4,
362
- 0x32,
363
- 0x2d,
364
- 0x6e,
365
- 0x31,
366
- 0x95,
367
- 0xff,
368
- 0xd9,
369
- 0x23,
370
- 0xd1,
371
- 0x00,
372
- 0x5e,
373
- 0x79,
374
- 0xdc,
375
- 0x44,
376
- 0x3b,
377
- 0x1a,
378
- 0x28,
379
- 0xc5,
380
- 0x61,
381
- 0x57,
382
- 0x20,
383
- 0x90,
384
- 0x3d,
385
- 0x83,
386
- 0xb9,
387
- 0x43,
388
- 0xbe,
389
- 0x67,
390
- 0xd2,
391
- 0x46,
392
- 0x42,
393
- 0x76,
394
- 0xc0,
395
- 0x6d,
396
- 0x5b,
397
- 0x7e,
398
- 0xb2,
399
- 0x0f,
400
- 0x16,
401
- 0x29,
402
- 0x3c,
403
- 0xa9,
404
- 0x03,
405
- 0x54,
406
- 0x0d,
407
- 0xda,
408
- 0x5d,
409
- 0xdf,
410
- 0xf6,
411
- 0xb7,
412
- 0xc7,
413
- 0x62,
414
- 0xcd,
415
- 0x8d,
416
- 0x06,
417
- 0xd3,
418
- 0x69,
419
- 0x5c,
420
- 0x86,
421
- 0xd6,
422
- 0x14,
423
- 0xf7,
424
- 0xa5,
425
- 0x66,
426
- 0x75,
427
- 0xac,
428
- 0xb1,
429
- 0xe9,
430
- 0x45,
431
- 0x21,
432
- 0x70,
433
- 0x0c,
434
- 0x87,
435
- 0x9f,
436
- 0x74,
437
- 0xa4,
438
- 0x22,
439
- 0x4c,
440
- 0x6f,
441
- 0xbf,
442
- 0x1f,
443
- 0x56,
444
- 0xaa,
445
- 0x2e,
446
- 0xb3,
447
- 0x78,
448
- 0x33,
449
- 0x50,
450
- 0xb0,
451
- 0xa3,
452
- 0x92,
453
- 0xbc,
454
- 0xcf,
455
- 0x19,
456
- 0x1c,
457
- 0xa7,
458
- 0x63,
459
- 0xcb,
460
- 0x1e,
461
- 0x4d,
462
- 0x3e,
463
- 0x4b,
464
- 0x1b,
465
- 0x9b,
466
- 0x4f,
467
- 0xe7,
468
- 0xf0,
469
- 0xee,
470
- 0xad,
471
- 0x3a,
472
- 0xb5,
473
- 0x59,
474
- 0x04,
475
- 0xea,
476
- 0x40,
477
- 0x55,
478
- 0x25,
479
- 0x51,
480
- 0xe5,
481
- 0x7a,
482
- 0x89,
483
- 0x38,
484
- 0x68,
485
- 0x52,
486
- 0x7b,
487
- 0xfc,
488
- 0x27,
489
- 0xae,
490
- 0xd7,
491
- 0xbd,
492
- 0xfa,
493
- 0x07,
494
- 0xf4,
495
- 0xcc,
496
- 0x8e,
497
- 0x5f,
498
- 0xef,
499
- 0x35,
500
- 0x9c,
501
- 0x84,
502
- 0x2b,
503
- 0x15,
504
- 0xd5,
505
- 0x77,
506
- 0x34,
507
- 0x49,
508
- 0xb6,
509
- 0x12,
510
- 0x0a,
511
- 0x7f,
512
- 0x71,
513
- 0x88,
514
- 0xfd,
515
- 0x9d,
516
- 0x18,
517
- 0x41,
518
- 0x7d,
519
- 0x93,
520
- 0xd8,
521
- 0x58,
522
- 0x2c,
523
- 0xce,
524
- 0xfe,
525
- 0x24,
526
- 0xaf,
527
- 0xde,
528
- 0xb8,
529
- 0x36,
530
- 0xc8,
531
- 0xa1,
532
- 0x80,
533
- 0xa6,
534
- 0x99,
535
- 0x98,
536
- 0xa8,
537
- 0x2f,
538
- 0x0e,
539
- 0x81,
540
- 0x65,
541
- 0x73,
542
- 0xe4,
543
- 0xc2,
544
- 0xa2,
545
- 0x8a,
546
- 0xd4,
547
- 0xe1,
548
- 0x11,
549
- 0xd0,
550
- 0x08,
551
- 0x8b,
552
- 0x2a,
553
- 0xf2,
554
- 0xed,
555
- 0x9a,
556
- 0x64,
557
- 0x3f,
558
- 0xc1,
559
- 0x6c,
560
- 0xf9,
561
- 0xec,
562
- ];
563
- PSTUtil.codePages = new Map([
564
- [28596, 'iso-8859-6'],
565
- [1256, 'windows-1256'],
566
- [28594, 'iso-8859-4'],
567
- [1257, 'windows-1257'],
568
- [28592, 'iso-8859-2'],
569
- [1250, 'windows-1250'],
570
- [936, 'gb2312'],
571
- [52936, 'hz-gb-2312'],
572
- [54936, 'gb18030'],
573
- [950, 'big5'],
574
- [28595, 'iso-8859-5'],
575
- [20866, 'koi8-r'],
576
- [21866, 'koi8-u'],
577
- [1251, 'windows-1251'],
578
- [28597, 'iso-8859-7'],
579
- [1253, 'windows-1253'],
580
- [38598, 'iso-8859-8-i'],
581
- [1255, 'windows-1255'],
582
- [51932, 'euc-jp'],
583
- [50220, 'iso-2022-jp'],
584
- [50221, 'csISO2022JP'],
585
- [932, 'iso-2022-jp'],
586
- [949, 'ks_c_5601-1987'],
587
- [51949, 'euc-kr'],
588
- [28593, 'iso-8859-3'],
589
- [28605, 'iso-8859-15'],
590
- [874, 'windows-874'],
591
- [28599, 'iso-8859-9'],
592
- [1254, 'windows-1254'],
593
- [65000, 'utf-7'],
594
- [65001, 'utf-8'],
595
- [20127, 'us-ascii'],
596
- [1258, 'windows-1258'],
597
- [28591, 'iso-8859-1'],
598
- [1252, 'Windows-1252'],
599
- ]);
600
- // maps hex codes to names for properties
601
- PSTUtil.propertyName = new Map([
602
- [0x0002, 'PidTagAlternateRecipientAllowed'],
603
- [0x0003, 'PidTagNameidStreamEntry'],
604
- [0x0004, 'PidTagNameidStreamString'],
605
- [0x0017, 'PidTagImportance'],
606
- [0x001a, 'PidTagMessageClass'],
607
- [0x0023, 'PidTagOriginatorDeliveryReportRequested'],
608
- [0x0026, 'PidTagPriority'],
609
- [0x0029, 'PidLidOldWhenStartWhole'],
610
- [0x002b, 'PidTagRecipientReassignmentProhibited'],
611
- [0x002e, 'PidTagOriginalSensitivity'],
612
- [0x0036, 'PidTagSensitivity'],
613
- [0x0037, 'PidTagSubject'],
614
- [0x0039, 'PidTagClientSubmitTime'],
615
- [0x003b, 'PidTagSentRepresentingSearchKey'],
616
- [0x003f, 'PidTagReceivedByEntryId'],
617
- [0x0040, 'PidTagReceivedByName'],
618
- [0x0041, 'PidTagSentRepresentingEntryId'],
619
- [0x0042, 'PidTagSentRepresentingName'],
620
- [0x0043, 'PidTagReceivedRepresentingEntryId'],
621
- [0x0044, 'PidTagReceivedRepresentingName'],
622
- [0x004d, 'PidTagOriginalAuthorName'],
623
- [0x0052, 'PidTagReceivedRepresentingSearchKey'],
624
- [0x0057, 'PidTagMessageToMe'],
625
- [0x0058, 'PidTagMessageCcMe'],
626
- [0x0060, 'PidTagStartDate'],
627
- [0x0061, 'PidTagEndDate'],
628
- [0x0062, 'PidTagOwnerAppointmentId'],
629
- [0x0063, 'PidTagResponseRequested'],
630
- [0x0064, 'PidTagSentRepresentingAddressType'],
631
- [0x0065, 'PidTagSentRepresentingEmailAddress'],
632
- [0x0070, 'PidTagConversationTopic'],
633
- [0x0071, 'PidTagConversationIndex'],
634
- [0x0075, 'PidTagReceivedByAddressType'],
635
- [0x0076, 'PidTagReceivedByEmailAddress'],
636
- [0x0077, 'PidTagReceivedRepresentingAddressType'],
637
- [0x0078, 'PidTagReceivedRepresentingEmailAddress'],
638
- [0x007d, 'PidTagTransportMessageHeaders'],
639
- [0x0c15, 'PidTagRecipientType'],
640
- [0x0c17, 'PidTagReplyRequested'],
641
- [0x0c19, 'PidTagSenderEntryId'],
642
- [0x0c1a, 'PidTagSenderName'],
643
- [0x0c1d, 'PidTagSenderSearchKey'],
644
- [0x0c1e, 'PidTagSenderAddressType'],
645
- [0x0c1f, 'PidTagSenderEmailAddress'],
646
- [0x0e01, 'PidTagDeleteAfterSubmit'],
647
- [0x0e02, 'PidTagDisplayBcc'],
648
- [0x0e03, 'PidTagDisplayCc'],
649
- [0x0e04, 'PidTagDisplayTo'],
650
- [0x0e06, 'PidTagMessageDeliveryTime'],
651
- [0x0e07, 'PidTagMessageFlags'],
652
- [0x0e08, 'PidTagMessageSize'],
653
- [0x0e0f, 'PidTagResponsibility'],
654
- [0x0e20, 'PidTagAttachSize'],
655
- [0x0e23, 'PidTagInternetArticleNumber'],
656
- [0x0e38, 'PidTagReplFlags'],
657
- [0x0e62, 'PidTagUrlCompNameSet'],
658
- [0x0e79, 'PidTagTrustSender'],
659
- [0x0ff9, 'PidTagRecordKey'],
660
- [0x0ffe, 'PidTagObjectType'],
661
- [0x0fff, 'PidTagEntryId'],
662
- [0x1000, 'PidTagBody'],
663
- [0x1009, 'PidTagRtfCompressed'],
664
- [0x1013, 'PidTagBodyHtml'],
665
- [0x1035, 'PidTagInternetMessageId'],
666
- [0x1039, 'PidTagInternetReferences'],
667
- [0x1042, 'PidTagInReplyToId'],
668
- [0x1080, 'PidTagIconIndex'],
669
- [0x1081, 'PidTagLastVerbExecuted'],
670
- [0x1082, 'PidTagLastVerbExecutionTime'],
671
- [0x1096, 'PidTagBlockStatus'],
672
- [0x10c3, 'PidTagICalendarStartTime'],
673
- [0x10c4, 'PidTagICalendarEndTime'],
674
- [0x10f2, 'Unknown_10F2'],
675
- [0x10f3, 'PidTagUrlCompName'],
676
- [0x10f4, 'PidTagAttributeHidden'],
677
- [0x10f5, 'PidTagAttributeSystem'],
678
- [0x10f6, 'PidTagAttributeReadOnly'],
679
- [0x3001, 'PidTagDisplayName'],
680
- [0x3002, 'PidTagAddressType'],
681
- [0x3003, 'PidTagEmailAddress'],
682
- [0x3007, 'PidTagCreationTime'],
683
- [0x3008, 'PidTagLastModificationTime'],
684
- [0x300b, 'PidTagSearchKey'],
685
- [0x3701, 'PidTagAttachDataBinary'],
686
- [0x3702, 'PidTagAttachEncoding'],
687
- [0x3703, 'PidTagAttachExtension'],
688
- [0x3704, 'PidTagAttachFilename'],
689
- [0x3705, 'PidTagAttachMethod'],
690
- [0x3709, 'PidTagAttachRendering'],
691
- [0x370b, 'PidTagRenderingPosition'],
692
- [0x370e, 'PidTagAttachMimeTag'],
693
- [0x370a, 'PidTagAttachTag'],
694
- [0x3712, 'PidTagAttachContentId'],
695
- [0x3714, 'PidTagAttachFlags'],
696
- [0x3900, 'PidTagDisplayType'],
697
- [0x39fe, 'PidTagPrimarySmtpAddress'],
698
- [0x39ff, 'PidTag7BitDisplayName'],
699
- [0x3a00, 'PidTagAccount'],
700
- [0x3a08, 'PidTagBusinessTelephoneNumber'],
701
- [0x3a20, 'PidTagTransmittableDisplayName'],
702
- [0x3a40, 'PidTagSendRichInfo'],
703
- [0x3a70, 'PidTagUserX509Certificate'],
704
- [0x3a71, 'PidTagSendInternetEncoding'],
705
- [0x3fde, 'PidTagInternetCodepage'],
706
- [0x3ff1, 'PidTagMessageLocaleId'],
707
- [0x3ffd, 'PidTagMessageCodepage'],
708
- [0x3ff9, 'PidTagCreatorName'],
709
- [0x4019, 'PidTagSenderFlags'],
710
- [0x401a, 'PidTagSentRepresentingFlags'],
711
- [0x401b, 'PidTagReceivedByFlags'],
712
- [0x401c, 'PidTagReceivedRepresentingFlags'],
713
- [0x403e, 'Unknown_403E'],
714
- [0x4a08, 'Unknown_4A08'],
715
- [0x5902, 'PidTagInternetMailOverrideFormat'],
716
- [0x5909, 'PidTagMessageEditorFormat'],
717
- [0x5fde, 'PidTagRecipientResourceState'],
718
- [0x5fdf, 'PidTagRecipientOrder'],
719
- [0x5feb, 'Unknown_5FEB'],
720
- [0x5fef, 'Unknown_5FEF'],
721
- [0x5ff2, 'Unknown_5FF2'],
722
- [0x5ff5, 'Unknown_5FF5'],
723
- [0x5ff6, 'PidTagRecipientDisplayName'],
724
- [0x5ff7, 'PidTagRecipientEntryId'],
725
- [0x5ffb, 'PidTagRecipientTrackStatusTime'],
726
- [0x5ffd, 'PidTagRecipientFlags'],
727
- [0x5fff, 'PidTagRecipientTrackStatus'],
728
- [0x6001, 'PidTagNickname'],
729
- [0x6610, 'Unknown_6610'],
730
- [0x6614, 'Unknown_6614'],
731
- [0x6617, 'Unknown_6617'],
732
- [0x6619, 'PidTagUserEntryId'],
733
- [0x6743, 'Unknown_6743'],
734
- [0x6744, 'Unknown_6744'],
735
- [0x67f2, 'PidTagLtpRowId'],
736
- [0x67f3, 'PidTagLtpRowVer'],
737
- [0x67f4, 'Unknown_67F4'],
738
- [0x7ffa, 'PidTagAttachmentLinkId'],
739
- [0x7ffb, 'PidTagExceptionStartTime'],
740
- [0x7ffc, 'PidTagExceptionEndTime'],
741
- [0x7ffd, 'PidTagAttachmentFlags'],
742
- [0x7ffe, 'PidTagAttachmentHidden'],
743
- [0x7fff, 'PidTagAttachmentContactPhoto'],
744
- [0x3ffa, 'PidTagLastModifiedName_W'],
745
- [0x3ffb, 'PidTagLastModifierEntryId'],
746
- ]);
747
- // Heap node
748
- PSTUtil.NID_TYPE_HID = 0x00;
749
- // Internal node (section 2.4.1)
750
- PSTUtil.NID_TYPE_INTERNAL = 0x01;
751
- // Normal Folder object (PC)
752
- PSTUtil.NID_TYPE_NORMAL_FOLDER = 0x02;
753
- // Search Folder object (PC)
754
- PSTUtil.NID_TYPE_SEARCH_FOLDER = 0x03;
755
- // Normal Message object (PC)
756
- PSTUtil.NID_TYPE_NORMAL_MESSAGE = 0x04;
757
- // Attachment object (PC)
758
- PSTUtil.NID_TYPE_ATTACHMENT = 0x05;
759
- // Queue of changed objects for search Folder objects
760
- PSTUtil.NID_TYPE_SEARCH_UPDATE_QUEUE = 0x06;
761
- // Defines the search criteria for a search folder object
762
- PSTUtil.NID_TYPE_SEARCH_CRITERIA_OBJECT = 0x07;
763
- // Folder associated info (FAI) message object (PC)
764
- PSTUtil.NID_TYPE_ASSOC_MESSAGE = 0x08;
765
- // Internal, persisted view-related
766
- PSTUtil.NID_TYPE_CONTENTS_TABLE_INDEX = 0x0a;
767
- // Receive Folder object (Inbox)
768
- PSTUtil.NID_TYPE_RECEIVE_FOLDER_TABLE = 0x0b;
769
- // Outbound queue (Outbox)
770
- PSTUtil.NID_TYPE_OUTGOING_QUEUE_TABLE = 0x0c;
771
- // Hierarchy table (TC)
772
- PSTUtil.NID_TYPE_HIERARCHY_TABLE = 0x0d;
773
- // Contents table (TC)
774
- PSTUtil.NID_TYPE_CONTENTS_TABLE = 0x0e;
775
- // FAI contents table (TC)
776
- PSTUtil.NID_TYPE_ASSOC_CONTENTS_TABLE = 0x0f;
777
- // Contents table (TC) of a search folder object
778
- PSTUtil.NID_TYPE_SEARCH_CONTENTS_TABLE = 0x10;
779
- // Attachment table (TC)
780
- PSTUtil.NID_TYPE_ATTACHMENT_TABLE = 0x11;
781
- // Recipient table (TC)
782
- PSTUtil.NID_TYPE_RECIPIENT_TABLE = 0x12;
783
- // Internal, persisted view-related
784
- PSTUtil.NID_TYPE_SEARCH_TABLE_INDEX = 0x13;
785
- // LTP
786
- PSTUtil.NID_TYPE_LTP = 0x1f;
787
- /**
788
- * Determine if character is alphanumeric
789
- *
790
- * @static
791
- * @memberof PSTUtil
792
- */
793
- PSTUtil.isAlphaNumeric = (ch) => {
794
- return ch.match(/^[a-z0-9]+$/i) !== null;
795
- };
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.PSTUtil = void 0;
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ const long_1 = __importDefault(require("long"));
9
+ const PSTAppointment_class_1 = require("./PSTAppointment.class");
10
+ const PSTContact_class_1 = require("./PSTContact.class");
11
+ const PSTFolder_class_1 = require("./PSTFolder.class");
12
+ const PSTMessage_class_1 = require("./PSTMessage.class");
13
+ const PSTNodeInputStream_class_1 = require("./PSTNodeInputStream.class");
14
+ const PSTTableBC_class_1 = require("./PSTTableBC.class");
15
+ const PSTTask_class_1 = require("./PSTTask.class");
16
+ const PSTActivity_class_1 = require("./PSTActivity.class");
17
+ const iconv_lite_1 = __importDefault(require("iconv-lite"));
18
+ /**
19
+ * Utility functions for PST components
20
+ * @export
21
+ * @class PSTUtil
22
+ */
23
+ class PSTUtil {
24
+ /**
25
+ * Convert little endian bytes to long
26
+ * @static
27
+ * @param {Buffer} data
28
+ * @param {number} [start]
29
+ * @param {number} [end]
30
+ * @returns {long}
31
+ * @memberof PSTUtil
32
+ */
33
+ static convertLittleEndianBytesToLong(data, start, end) {
34
+ if (!start) {
35
+ start = 0;
36
+ }
37
+ if (!end) {
38
+ end = data.length;
39
+ }
40
+ let offset = long_1.default.fromNumber(data[end - 1] & 0xff);
41
+ let tmpLongValue;
42
+ for (let x = end - 2; x >= start; x--) {
43
+ offset = offset.shiftLeft(8);
44
+ tmpLongValue = long_1.default.fromNumber(data[x] & 0xff);
45
+ offset = offset.xor(tmpLongValue);
46
+ }
47
+ return offset;
48
+ }
49
+ /**
50
+ * Convert big endian bytes to long
51
+ * @static
52
+ * @param {Buffer} data
53
+ * @param {number} [start]
54
+ * @param {number} [end]
55
+ * @returns {long}
56
+ * @memberof PSTUtil
57
+ */
58
+ static convertBigEndianBytesToLong(data, start, end) {
59
+ if (!start) {
60
+ start = 0;
61
+ }
62
+ if (!end) {
63
+ end = data.length;
64
+ }
65
+ let offset = long_1.default.ZERO;
66
+ for (let x = start; x < end; ++x) {
67
+ offset = offset.shiftLeft(8);
68
+ const tmpLongValue = long_1.default.fromNumber(data[x] & 0xff);
69
+ offset = offset.xor(tmpLongValue);
70
+ }
71
+ return offset;
72
+ }
73
+ /**
74
+ * Handle strings using codepages.
75
+ * @static
76
+ * @param {number} propertyId
77
+ * @returns
78
+ * @memberof PSTUtil
79
+ */
80
+ static getInternetCodePageCharset(propertyId) {
81
+ return this.codePages.get(propertyId);
82
+ }
83
+ /**
84
+ * Create JS string from buffer.
85
+ * @static
86
+ * @param {Buffer} data
87
+ * @param {number} stringType
88
+ * @param {string} codepage
89
+ * @returns
90
+ * @memberof PSTUtil
91
+ */
92
+ static createJavascriptString(data, stringType, codepage = 'utf8') {
93
+ // TODO - codepage is not used...
94
+ try {
95
+ if (stringType == 0x1f) {
96
+ // convert and trim any nulls
97
+ return data.toString('utf16le').replace(/\0/g, '');
98
+ }
99
+ else {
100
+ return iconv_lite_1.default.decode(data, codepage).toString();
101
+ }
102
+ }
103
+ catch (err) {
104
+ console.error('PSTUtil::createJavascriptString Unable to decode string\n' + err);
105
+ throw err;
106
+ }
107
+ return '';
108
+ }
109
+ /**
110
+ * Copy from one array to another
111
+ * @static
112
+ * @param {Buffer} src
113
+ * @param {number} srcPos
114
+ * @param {Buffer} dest
115
+ * @param {number} destPos
116
+ * @param {number} length
117
+ * @memberof PSTUtil
118
+ */
119
+ static arraycopy(src, srcPos, dest, destPos, length) {
120
+ // TODO FIX THIS - TOO SLOW?
121
+ let s = srcPos;
122
+ let d = destPos;
123
+ let i = 0;
124
+ while (i++ < length) {
125
+ dest[d++] = src[s++];
126
+ }
127
+ }
128
+ /**
129
+ * Decode a lump of data that has been encrypted with the compressible encryption
130
+ * @static
131
+ * @param {Buffer} data
132
+ * @returns {Buffer}
133
+ * @memberof PSTUtil
134
+ */
135
+ static decode(data) {
136
+ let temp;
137
+ for (let x = 0; x < data.length; x++) {
138
+ temp = data[x] & 0xff;
139
+ data[x] = this.compEnc[temp];
140
+ }
141
+ return data;
142
+ }
143
+ static detectAndLoadPSTObject(theFile, arg) {
144
+ let folderIndexNode = arg;
145
+ if (typeof arg === 'object' && arg.hasOwnProperty('low')) {
146
+ folderIndexNode = theFile.getDescriptorIndexNode(arg);
147
+ }
148
+ const nidType = folderIndexNode.descriptorIdentifier & 0x1f;
149
+ if (nidType == 0x02 || nidType == 0x03 || nidType == 0x04) {
150
+ const table = new PSTTableBC_class_1.PSTTableBC(new PSTNodeInputStream_class_1.PSTNodeInputStream(theFile, theFile.getOffsetIndexNode(folderIndexNode.dataOffsetIndexIdentifier)));
151
+ let localDescriptorItems = undefined;
152
+ if (folderIndexNode.localDescriptorsOffsetIndexIdentifier != 0) {
153
+ localDescriptorItems = theFile.getPSTDescriptorItems(folderIndexNode.localDescriptorsOffsetIndexIdentifier);
154
+ }
155
+ if (nidType == 0x02 || nidType == 0x03) {
156
+ return new PSTFolder_class_1.PSTFolder(theFile, folderIndexNode, table, localDescriptorItems);
157
+ }
158
+ else {
159
+ return this.createAppropriatePSTMessageObject(theFile, folderIndexNode, table, localDescriptorItems);
160
+ }
161
+ }
162
+ else {
163
+ throw new Error('PSTUtil::detectAndLoadPSTObject Unknown child type with offset id: ' +
164
+ folderIndexNode.localDescriptorsOffsetIndexIdentifier);
165
+ }
166
+ }
167
+ /**
168
+ * Creates object based on message class
169
+ * https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/item-types-and-message-classes
170
+ * @static
171
+ * @param {PSTFile} theFile
172
+ * @param {DescriptorIndexNode} folderIndexNode
173
+ * @param {PSTTableBC} table
174
+ * @param {Map<number, PSTDescriptorItem>} localDescriptorItems
175
+ * @returns {PSTMessage}
176
+ * @memberof PSTUtil
177
+ */
178
+ static createAppropriatePSTMessageObject(theFile, folderIndexNode, table, localDescriptorItems) {
179
+ const item = table.getItems().get(0x001a);
180
+ let messageClass = '';
181
+ if (item != null) {
182
+ messageClass = item.getStringValue();
183
+ }
184
+ switch (messageClass) {
185
+ case 'IPM.Note':
186
+ case 'IPM.Note.SMIME.MultipartSigned':
187
+ case 'IPM.Note.Agenda':
188
+ // email message
189
+ const msg = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
190
+ // Log.debug1(msg.body);
191
+ // Log.debug1(msg.numberOfRecipients.toString());
192
+ // Log.debug1(msg.colorCategories.toString());
193
+ // Log.debug1(JSON.stringify(msg, null, 2));
194
+ return msg;
195
+ case 'IPM.Appointment':
196
+ case 'IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}':
197
+ case 'IPM.Schedule.Meeting.Canceled':
198
+ case 'IPM.Schedule.Meeting.Resp.Pos':
199
+ case 'IPM.Schedule.Meeting.Resp.Tent':
200
+ case 'IPM.Schedule.Meeting.Notification.Forward':
201
+ case 'IPM.Schedule.Meeting.Resp.Neg':
202
+ // appointment
203
+ // messageClass.startsWith('IPM.Schedule.Meeting')
204
+ const apt = new PSTAppointment_class_1.PSTAppointment(theFile, folderIndexNode, table, localDescriptorItems);
205
+ // Log.debug1(JSON.stringify(msg, null, 2));
206
+ return apt;
207
+ case 'IPM.Contact':
208
+ // contact
209
+ const contact = new PSTContact_class_1.PSTContact(theFile, folderIndexNode, table, localDescriptorItems);
210
+ // Log.debug1(JSON.stringify(msg, null, 2));
211
+ return contact;
212
+ case 'IPM.Task':
213
+ // task
214
+ const task = new PSTTask_class_1.PSTTask(theFile, folderIndexNode, table, localDescriptorItems);
215
+ // Log.debug1(JSON.stringify(msg, null, 2));
216
+ return task;
217
+ case 'IPM.Activity':
218
+ // journal entry
219
+ const activity = new PSTActivity_class_1.PSTActivity(theFile, folderIndexNode, table, localDescriptorItems);
220
+ // Log.debug1(JSON.stringify(msg, null, 2));
221
+ return activity;
222
+ case 'IPM.Post.Rss':
223
+ // debugger;
224
+ // Rss Feed
225
+ const rss = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
226
+ // Log.debug1(JSON.stringify(msg, null, 2));
227
+ return rss;
228
+ case 'IPM.DistList':
229
+ // debugger;
230
+ // Distribution list
231
+ const dl = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
232
+ // Log.debug1(JSON.stringify(msg, null, 2));
233
+ return dl;
234
+ // return new PSTDistList(theFile, folderIndexNode, table, localDescriptorItems);
235
+ case 'IPM.Note.Rules.OofTemplate.Microsoft':
236
+ // debugger;
237
+ // Out of Office rule
238
+ const oof = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
239
+ // Log.debug1(JSON.stringify(msg, null, 2));
240
+ return oof;
241
+ case 'IPM.Schedule.Meeting.Request':
242
+ // Meeting request
243
+ const meetReq = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
244
+ // Log.debug1(JSON.stringify(msg, null, 2));
245
+ return meetReq;
246
+ case 'REPORT.IPM.Note.NDR':
247
+ // Receipt of non-delivery
248
+ const ndr = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
249
+ // Log.debug1(JSON.stringify(msg, null, 2));
250
+ return ndr;
251
+ case 'IPM.StickyNote':
252
+ // Sticky note
253
+ const sticky = new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
254
+ // Log.debug1(JSON.stringify(msg, null, 2));
255
+ return sticky;
256
+ case 'REPORT.IPM.Note.IPNRN':
257
+ // Read receipt
258
+ // debugger;
259
+ // console.log('PSTUtil::createAppropriatePSTMessageObject REPORT.IPM.Note.IPNRN');
260
+ return new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
261
+ case 'REPORT.IPM.Note.IPNNRN':
262
+ // Not-read notification
263
+ // debugger;
264
+ // console.log('PSTUtil::createAppropriatePSTMessageObject REPORT.IPM.Note.IPNNRN');
265
+ return new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
266
+ case 'IPM.Schedule.Meeting.Request':
267
+ // Meeting request
268
+ // debugger;
269
+ // console.log('PSTUtil::createAppropriatePSTMessageObject IPM.Schedule.Meeting.Request');
270
+ return new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
271
+ case 'REPORT.IPM.Note.DR':
272
+ // Delivery receipt
273
+ // debugger;
274
+ // console.log('PSTUtil::createAppropriatePSTMessageObject REPORT.IPM.Note.DR');
275
+ return new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
276
+ default:
277
+ console.error('PSTUtil::createAppropriatePSTMessageObject unknown message type: ' +
278
+ messageClass);
279
+ }
280
+ return new PSTMessage_class_1.PSTMessage(theFile, folderIndexNode, table, localDescriptorItems);
281
+ }
282
+ /**
283
+ * Converts a Windows FILETIME into a {@link Date}. The Windows FILETIME structure holds a date and time associated with a
284
+ * file. The structure identifies a 64-bit integer specifying the number of 100-nanosecond intervals which have passed since
285
+ * January 1, 1601. This 64-bit value is split into the two double words stored in the structure.
286
+ *
287
+ * @static
288
+ * @param {long} hi
289
+ * @param {long} low
290
+ * @returns {Date}
291
+ * @memberof PSTUtil
292
+ */
293
+ static filetimeToDate(hi, low) {
294
+ const h = hi.shiftLeft(32);
295
+ const l = low.and(0xffffffff);
296
+ const filetime = h.or(l);
297
+ const msSince16010101 = filetime.divide(1000 * 10);
298
+ const epochDiff = long_1.default.fromValue('11644473600000');
299
+ const msSince19700101 = msSince16010101.subtract(epochDiff);
300
+ return new Date(msSince19700101.toNumber());
301
+ }
302
+ }
303
+ exports.PSTUtil = PSTUtil;
304
+ // substitution table for the compressible encryption type.
305
+ PSTUtil.compEnc = [
306
+ 0x47,
307
+ 0xf1,
308
+ 0xb4,
309
+ 0xe6,
310
+ 0x0b,
311
+ 0x6a,
312
+ 0x72,
313
+ 0x48,
314
+ 0x85,
315
+ 0x4e,
316
+ 0x9e,
317
+ 0xeb,
318
+ 0xe2,
319
+ 0xf8,
320
+ 0x94,
321
+ 0x53,
322
+ 0xe0,
323
+ 0xbb,
324
+ 0xa0,
325
+ 0x02,
326
+ 0xe8,
327
+ 0x5a,
328
+ 0x09,
329
+ 0xab,
330
+ 0xdb,
331
+ 0xe3,
332
+ 0xba,
333
+ 0xc6,
334
+ 0x7c,
335
+ 0xc3,
336
+ 0x10,
337
+ 0xdd,
338
+ 0x39,
339
+ 0x05,
340
+ 0x96,
341
+ 0x30,
342
+ 0xf5,
343
+ 0x37,
344
+ 0x60,
345
+ 0x82,
346
+ 0x8c,
347
+ 0xc9,
348
+ 0x13,
349
+ 0x4a,
350
+ 0x6b,
351
+ 0x1d,
352
+ 0xf3,
353
+ 0xfb,
354
+ 0x8f,
355
+ 0x26,
356
+ 0x97,
357
+ 0xca,
358
+ 0x91,
359
+ 0x17,
360
+ 0x01,
361
+ 0xc4,
362
+ 0x32,
363
+ 0x2d,
364
+ 0x6e,
365
+ 0x31,
366
+ 0x95,
367
+ 0xff,
368
+ 0xd9,
369
+ 0x23,
370
+ 0xd1,
371
+ 0x00,
372
+ 0x5e,
373
+ 0x79,
374
+ 0xdc,
375
+ 0x44,
376
+ 0x3b,
377
+ 0x1a,
378
+ 0x28,
379
+ 0xc5,
380
+ 0x61,
381
+ 0x57,
382
+ 0x20,
383
+ 0x90,
384
+ 0x3d,
385
+ 0x83,
386
+ 0xb9,
387
+ 0x43,
388
+ 0xbe,
389
+ 0x67,
390
+ 0xd2,
391
+ 0x46,
392
+ 0x42,
393
+ 0x76,
394
+ 0xc0,
395
+ 0x6d,
396
+ 0x5b,
397
+ 0x7e,
398
+ 0xb2,
399
+ 0x0f,
400
+ 0x16,
401
+ 0x29,
402
+ 0x3c,
403
+ 0xa9,
404
+ 0x03,
405
+ 0x54,
406
+ 0x0d,
407
+ 0xda,
408
+ 0x5d,
409
+ 0xdf,
410
+ 0xf6,
411
+ 0xb7,
412
+ 0xc7,
413
+ 0x62,
414
+ 0xcd,
415
+ 0x8d,
416
+ 0x06,
417
+ 0xd3,
418
+ 0x69,
419
+ 0x5c,
420
+ 0x86,
421
+ 0xd6,
422
+ 0x14,
423
+ 0xf7,
424
+ 0xa5,
425
+ 0x66,
426
+ 0x75,
427
+ 0xac,
428
+ 0xb1,
429
+ 0xe9,
430
+ 0x45,
431
+ 0x21,
432
+ 0x70,
433
+ 0x0c,
434
+ 0x87,
435
+ 0x9f,
436
+ 0x74,
437
+ 0xa4,
438
+ 0x22,
439
+ 0x4c,
440
+ 0x6f,
441
+ 0xbf,
442
+ 0x1f,
443
+ 0x56,
444
+ 0xaa,
445
+ 0x2e,
446
+ 0xb3,
447
+ 0x78,
448
+ 0x33,
449
+ 0x50,
450
+ 0xb0,
451
+ 0xa3,
452
+ 0x92,
453
+ 0xbc,
454
+ 0xcf,
455
+ 0x19,
456
+ 0x1c,
457
+ 0xa7,
458
+ 0x63,
459
+ 0xcb,
460
+ 0x1e,
461
+ 0x4d,
462
+ 0x3e,
463
+ 0x4b,
464
+ 0x1b,
465
+ 0x9b,
466
+ 0x4f,
467
+ 0xe7,
468
+ 0xf0,
469
+ 0xee,
470
+ 0xad,
471
+ 0x3a,
472
+ 0xb5,
473
+ 0x59,
474
+ 0x04,
475
+ 0xea,
476
+ 0x40,
477
+ 0x55,
478
+ 0x25,
479
+ 0x51,
480
+ 0xe5,
481
+ 0x7a,
482
+ 0x89,
483
+ 0x38,
484
+ 0x68,
485
+ 0x52,
486
+ 0x7b,
487
+ 0xfc,
488
+ 0x27,
489
+ 0xae,
490
+ 0xd7,
491
+ 0xbd,
492
+ 0xfa,
493
+ 0x07,
494
+ 0xf4,
495
+ 0xcc,
496
+ 0x8e,
497
+ 0x5f,
498
+ 0xef,
499
+ 0x35,
500
+ 0x9c,
501
+ 0x84,
502
+ 0x2b,
503
+ 0x15,
504
+ 0xd5,
505
+ 0x77,
506
+ 0x34,
507
+ 0x49,
508
+ 0xb6,
509
+ 0x12,
510
+ 0x0a,
511
+ 0x7f,
512
+ 0x71,
513
+ 0x88,
514
+ 0xfd,
515
+ 0x9d,
516
+ 0x18,
517
+ 0x41,
518
+ 0x7d,
519
+ 0x93,
520
+ 0xd8,
521
+ 0x58,
522
+ 0x2c,
523
+ 0xce,
524
+ 0xfe,
525
+ 0x24,
526
+ 0xaf,
527
+ 0xde,
528
+ 0xb8,
529
+ 0x36,
530
+ 0xc8,
531
+ 0xa1,
532
+ 0x80,
533
+ 0xa6,
534
+ 0x99,
535
+ 0x98,
536
+ 0xa8,
537
+ 0x2f,
538
+ 0x0e,
539
+ 0x81,
540
+ 0x65,
541
+ 0x73,
542
+ 0xe4,
543
+ 0xc2,
544
+ 0xa2,
545
+ 0x8a,
546
+ 0xd4,
547
+ 0xe1,
548
+ 0x11,
549
+ 0xd0,
550
+ 0x08,
551
+ 0x8b,
552
+ 0x2a,
553
+ 0xf2,
554
+ 0xed,
555
+ 0x9a,
556
+ 0x64,
557
+ 0x3f,
558
+ 0xc1,
559
+ 0x6c,
560
+ 0xf9,
561
+ 0xec,
562
+ ];
563
+ PSTUtil.codePages = new Map([
564
+ [28596, 'iso-8859-6'],
565
+ [1256, 'windows-1256'],
566
+ [28594, 'iso-8859-4'],
567
+ [1257, 'windows-1257'],
568
+ [28592, 'iso-8859-2'],
569
+ [1250, 'windows-1250'],
570
+ [936, 'gb2312'],
571
+ [52936, 'hz-gb-2312'],
572
+ [54936, 'gb18030'],
573
+ [950, 'big5'],
574
+ [28595, 'iso-8859-5'],
575
+ [20866, 'koi8-r'],
576
+ [21866, 'koi8-u'],
577
+ [1251, 'windows-1251'],
578
+ [28597, 'iso-8859-7'],
579
+ [1253, 'windows-1253'],
580
+ [38598, 'iso-8859-8-i'],
581
+ [1255, 'windows-1255'],
582
+ [51932, 'euc-jp'],
583
+ [50220, 'iso-2022-jp'],
584
+ [50221, 'csISO2022JP'],
585
+ [932, 'iso-2022-jp'],
586
+ [949, 'ks_c_5601-1987'],
587
+ [51949, 'euc-kr'],
588
+ [28593, 'iso-8859-3'],
589
+ [28605, 'iso-8859-15'],
590
+ [874, 'windows-874'],
591
+ [28599, 'iso-8859-9'],
592
+ [1254, 'windows-1254'],
593
+ [65000, 'utf-7'],
594
+ [65001, 'utf-8'],
595
+ [20127, 'us-ascii'],
596
+ [1258, 'windows-1258'],
597
+ [28591, 'iso-8859-1'],
598
+ [1252, 'Windows-1252'],
599
+ ]);
600
+ // maps hex codes to names for properties
601
+ PSTUtil.propertyName = new Map([
602
+ [0x0002, 'PidTagAlternateRecipientAllowed'],
603
+ [0x0003, 'PidTagNameidStreamEntry'],
604
+ [0x0004, 'PidTagNameidStreamString'],
605
+ [0x0017, 'PidTagImportance'],
606
+ [0x001a, 'PidTagMessageClass'],
607
+ [0x0023, 'PidTagOriginatorDeliveryReportRequested'],
608
+ [0x0026, 'PidTagPriority'],
609
+ [0x0029, 'PidLidOldWhenStartWhole'],
610
+ [0x002b, 'PidTagRecipientReassignmentProhibited'],
611
+ [0x002e, 'PidTagOriginalSensitivity'],
612
+ [0x0036, 'PidTagSensitivity'],
613
+ [0x0037, 'PidTagSubject'],
614
+ [0x0039, 'PidTagClientSubmitTime'],
615
+ [0x003b, 'PidTagSentRepresentingSearchKey'],
616
+ [0x003f, 'PidTagReceivedByEntryId'],
617
+ [0x0040, 'PidTagReceivedByName'],
618
+ [0x0041, 'PidTagSentRepresentingEntryId'],
619
+ [0x0042, 'PidTagSentRepresentingName'],
620
+ [0x0043, 'PidTagReceivedRepresentingEntryId'],
621
+ [0x0044, 'PidTagReceivedRepresentingName'],
622
+ [0x004d, 'PidTagOriginalAuthorName'],
623
+ [0x0052, 'PidTagReceivedRepresentingSearchKey'],
624
+ [0x0057, 'PidTagMessageToMe'],
625
+ [0x0058, 'PidTagMessageCcMe'],
626
+ [0x0060, 'PidTagStartDate'],
627
+ [0x0061, 'PidTagEndDate'],
628
+ [0x0062, 'PidTagOwnerAppointmentId'],
629
+ [0x0063, 'PidTagResponseRequested'],
630
+ [0x0064, 'PidTagSentRepresentingAddressType'],
631
+ [0x0065, 'PidTagSentRepresentingEmailAddress'],
632
+ [0x0070, 'PidTagConversationTopic'],
633
+ [0x0071, 'PidTagConversationIndex'],
634
+ [0x0075, 'PidTagReceivedByAddressType'],
635
+ [0x0076, 'PidTagReceivedByEmailAddress'],
636
+ [0x0077, 'PidTagReceivedRepresentingAddressType'],
637
+ [0x0078, 'PidTagReceivedRepresentingEmailAddress'],
638
+ [0x007d, 'PidTagTransportMessageHeaders'],
639
+ [0x0c15, 'PidTagRecipientType'],
640
+ [0x0c17, 'PidTagReplyRequested'],
641
+ [0x0c19, 'PidTagSenderEntryId'],
642
+ [0x0c1a, 'PidTagSenderName'],
643
+ [0x0c1d, 'PidTagSenderSearchKey'],
644
+ [0x0c1e, 'PidTagSenderAddressType'],
645
+ [0x0c1f, 'PidTagSenderEmailAddress'],
646
+ [0x0e01, 'PidTagDeleteAfterSubmit'],
647
+ [0x0e02, 'PidTagDisplayBcc'],
648
+ [0x0e03, 'PidTagDisplayCc'],
649
+ [0x0e04, 'PidTagDisplayTo'],
650
+ [0x0e06, 'PidTagMessageDeliveryTime'],
651
+ [0x0e07, 'PidTagMessageFlags'],
652
+ [0x0e08, 'PidTagMessageSize'],
653
+ [0x0e0f, 'PidTagResponsibility'],
654
+ [0x0e20, 'PidTagAttachSize'],
655
+ [0x0e23, 'PidTagInternetArticleNumber'],
656
+ [0x0e38, 'PidTagReplFlags'],
657
+ [0x0e62, 'PidTagUrlCompNameSet'],
658
+ [0x0e79, 'PidTagTrustSender'],
659
+ [0x0ff9, 'PidTagRecordKey'],
660
+ [0x0ffe, 'PidTagObjectType'],
661
+ [0x0fff, 'PidTagEntryId'],
662
+ [0x1000, 'PidTagBody'],
663
+ [0x1009, 'PidTagRtfCompressed'],
664
+ [0x1013, 'PidTagBodyHtml'],
665
+ [0x1035, 'PidTagInternetMessageId'],
666
+ [0x1039, 'PidTagInternetReferences'],
667
+ [0x1042, 'PidTagInReplyToId'],
668
+ [0x1080, 'PidTagIconIndex'],
669
+ [0x1081, 'PidTagLastVerbExecuted'],
670
+ [0x1082, 'PidTagLastVerbExecutionTime'],
671
+ [0x1096, 'PidTagBlockStatus'],
672
+ [0x10c3, 'PidTagICalendarStartTime'],
673
+ [0x10c4, 'PidTagICalendarEndTime'],
674
+ [0x10f2, 'Unknown_10F2'],
675
+ [0x10f3, 'PidTagUrlCompName'],
676
+ [0x10f4, 'PidTagAttributeHidden'],
677
+ [0x10f5, 'PidTagAttributeSystem'],
678
+ [0x10f6, 'PidTagAttributeReadOnly'],
679
+ [0x3001, 'PidTagDisplayName'],
680
+ [0x3002, 'PidTagAddressType'],
681
+ [0x3003, 'PidTagEmailAddress'],
682
+ [0x3007, 'PidTagCreationTime'],
683
+ [0x3008, 'PidTagLastModificationTime'],
684
+ [0x300b, 'PidTagSearchKey'],
685
+ [0x3701, 'PidTagAttachDataBinary'],
686
+ [0x3702, 'PidTagAttachEncoding'],
687
+ [0x3703, 'PidTagAttachExtension'],
688
+ [0x3704, 'PidTagAttachFilename'],
689
+ [0x3705, 'PidTagAttachMethod'],
690
+ [0x3709, 'PidTagAttachRendering'],
691
+ [0x370b, 'PidTagRenderingPosition'],
692
+ [0x370e, 'PidTagAttachMimeTag'],
693
+ [0x370a, 'PidTagAttachTag'],
694
+ [0x3712, 'PidTagAttachContentId'],
695
+ [0x3714, 'PidTagAttachFlags'],
696
+ [0x3900, 'PidTagDisplayType'],
697
+ [0x39fe, 'PidTagPrimarySmtpAddress'],
698
+ [0x39ff, 'PidTag7BitDisplayName'],
699
+ [0x3a00, 'PidTagAccount'],
700
+ [0x3a08, 'PidTagBusinessTelephoneNumber'],
701
+ [0x3a20, 'PidTagTransmittableDisplayName'],
702
+ [0x3a40, 'PidTagSendRichInfo'],
703
+ [0x3a70, 'PidTagUserX509Certificate'],
704
+ [0x3a71, 'PidTagSendInternetEncoding'],
705
+ [0x3fde, 'PidTagInternetCodepage'],
706
+ [0x3ff1, 'PidTagMessageLocaleId'],
707
+ [0x3ffd, 'PidTagMessageCodepage'],
708
+ [0x3ff9, 'PidTagCreatorName'],
709
+ [0x4019, 'PidTagSenderFlags'],
710
+ [0x401a, 'PidTagSentRepresentingFlags'],
711
+ [0x401b, 'PidTagReceivedByFlags'],
712
+ [0x401c, 'PidTagReceivedRepresentingFlags'],
713
+ [0x403e, 'Unknown_403E'],
714
+ [0x4a08, 'Unknown_4A08'],
715
+ [0x5902, 'PidTagInternetMailOverrideFormat'],
716
+ [0x5909, 'PidTagMessageEditorFormat'],
717
+ [0x5fde, 'PidTagRecipientResourceState'],
718
+ [0x5fdf, 'PidTagRecipientOrder'],
719
+ [0x5feb, 'Unknown_5FEB'],
720
+ [0x5fef, 'Unknown_5FEF'],
721
+ [0x5ff2, 'Unknown_5FF2'],
722
+ [0x5ff5, 'Unknown_5FF5'],
723
+ [0x5ff6, 'PidTagRecipientDisplayName'],
724
+ [0x5ff7, 'PidTagRecipientEntryId'],
725
+ [0x5ffb, 'PidTagRecipientTrackStatusTime'],
726
+ [0x5ffd, 'PidTagRecipientFlags'],
727
+ [0x5fff, 'PidTagRecipientTrackStatus'],
728
+ [0x6001, 'PidTagNickname'],
729
+ [0x6610, 'Unknown_6610'],
730
+ [0x6614, 'Unknown_6614'],
731
+ [0x6617, 'Unknown_6617'],
732
+ [0x6619, 'PidTagUserEntryId'],
733
+ [0x6743, 'Unknown_6743'],
734
+ [0x6744, 'Unknown_6744'],
735
+ [0x67f2, 'PidTagLtpRowId'],
736
+ [0x67f3, 'PidTagLtpRowVer'],
737
+ [0x67f4, 'Unknown_67F4'],
738
+ [0x7ffa, 'PidTagAttachmentLinkId'],
739
+ [0x7ffb, 'PidTagExceptionStartTime'],
740
+ [0x7ffc, 'PidTagExceptionEndTime'],
741
+ [0x7ffd, 'PidTagAttachmentFlags'],
742
+ [0x7ffe, 'PidTagAttachmentHidden'],
743
+ [0x7fff, 'PidTagAttachmentContactPhoto'],
744
+ [0x3ffa, 'PidTagLastModifiedName_W'],
745
+ [0x3ffb, 'PidTagLastModifierEntryId'],
746
+ ]);
747
+ // Heap node
748
+ PSTUtil.NID_TYPE_HID = 0x00;
749
+ // Internal node (section 2.4.1)
750
+ PSTUtil.NID_TYPE_INTERNAL = 0x01;
751
+ // Normal Folder object (PC)
752
+ PSTUtil.NID_TYPE_NORMAL_FOLDER = 0x02;
753
+ // Search Folder object (PC)
754
+ PSTUtil.NID_TYPE_SEARCH_FOLDER = 0x03;
755
+ // Normal Message object (PC)
756
+ PSTUtil.NID_TYPE_NORMAL_MESSAGE = 0x04;
757
+ // Attachment object (PC)
758
+ PSTUtil.NID_TYPE_ATTACHMENT = 0x05;
759
+ // Queue of changed objects for search Folder objects
760
+ PSTUtil.NID_TYPE_SEARCH_UPDATE_QUEUE = 0x06;
761
+ // Defines the search criteria for a search folder object
762
+ PSTUtil.NID_TYPE_SEARCH_CRITERIA_OBJECT = 0x07;
763
+ // Folder associated info (FAI) message object (PC)
764
+ PSTUtil.NID_TYPE_ASSOC_MESSAGE = 0x08;
765
+ // Internal, persisted view-related
766
+ PSTUtil.NID_TYPE_CONTENTS_TABLE_INDEX = 0x0a;
767
+ // Receive Folder object (Inbox)
768
+ PSTUtil.NID_TYPE_RECEIVE_FOLDER_TABLE = 0x0b;
769
+ // Outbound queue (Outbox)
770
+ PSTUtil.NID_TYPE_OUTGOING_QUEUE_TABLE = 0x0c;
771
+ // Hierarchy table (TC)
772
+ PSTUtil.NID_TYPE_HIERARCHY_TABLE = 0x0d;
773
+ // Contents table (TC)
774
+ PSTUtil.NID_TYPE_CONTENTS_TABLE = 0x0e;
775
+ // FAI contents table (TC)
776
+ PSTUtil.NID_TYPE_ASSOC_CONTENTS_TABLE = 0x0f;
777
+ // Contents table (TC) of a search folder object
778
+ PSTUtil.NID_TYPE_SEARCH_CONTENTS_TABLE = 0x10;
779
+ // Attachment table (TC)
780
+ PSTUtil.NID_TYPE_ATTACHMENT_TABLE = 0x11;
781
+ // Recipient table (TC)
782
+ PSTUtil.NID_TYPE_RECIPIENT_TABLE = 0x12;
783
+ // Internal, persisted view-related
784
+ PSTUtil.NID_TYPE_SEARCH_TABLE_INDEX = 0x13;
785
+ // LTP
786
+ PSTUtil.NID_TYPE_LTP = 0x1f;
787
+ /**
788
+ * Determine if character is alphanumeric
789
+ *
790
+ * @static
791
+ * @memberof PSTUtil
792
+ */
793
+ PSTUtil.isAlphaNumeric = (ch) => {
794
+ return ch.match(/^[a-z0-9]+$/i) !== null;
795
+ };