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