@hiraokahypertools/pst-extractor 0.1.0-alpha.1

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 (90) hide show
  1. package/dist/BTHeap.d.ts +15 -0
  2. package/dist/BTHeap.js +76 -0
  3. package/dist/CollectionAsyncProvider.d.ts +15 -0
  4. package/dist/CollectionAsyncProvider.js +44 -0
  5. package/dist/KeyedDelay.d.ts +8 -0
  6. package/dist/KeyedDelay.js +37 -0
  7. package/dist/LZFu.class.d.ts +12 -0
  8. package/dist/LZFu.class.js +95 -0
  9. package/dist/NodeMap.class.d.ts +35 -0
  10. package/dist/NodeMap.class.js +86 -0
  11. package/dist/OutlookProperties.d.ts +278 -0
  12. package/dist/OutlookProperties.js +284 -0
  13. package/dist/PAUtil.d.ts +17 -0
  14. package/dist/PAUtil.js +145 -0
  15. package/dist/PHNodeHeap.d.ts +16 -0
  16. package/dist/PHNodeHeap.js +2 -0
  17. package/dist/PHNodeHeapReader.d.ts +6 -0
  18. package/dist/PHNodeHeapReader.js +5 -0
  19. package/dist/PHUtil.d.ts +6 -0
  20. package/dist/PHUtil.js +103 -0
  21. package/dist/PLMisc.d.ts +8 -0
  22. package/dist/PLMisc.js +16 -0
  23. package/dist/PLNode.d.ts +11 -0
  24. package/dist/PLNode.js +5 -0
  25. package/dist/PLStore.d.ts +9 -0
  26. package/dist/PLStore.js +5 -0
  27. package/dist/PLSubNode.d.ts +8 -0
  28. package/dist/PLSubNode.js +5 -0
  29. package/dist/PLUtil.d.ts +29 -0
  30. package/dist/PLUtil.js +683 -0
  31. package/dist/PSTActivity.class.d.ts +103 -0
  32. package/dist/PSTActivity.class.js +144 -0
  33. package/dist/PSTAppointment.class.d.ts +275 -0
  34. package/dist/PSTAppointment.class.js +381 -0
  35. package/dist/PSTAttachment.class.d.ts +168 -0
  36. package/dist/PSTAttachment.class.js +286 -0
  37. package/dist/PSTContact.class.d.ts +900 -0
  38. package/dist/PSTContact.class.js +1253 -0
  39. package/dist/PSTFile.class.d.ts +144 -0
  40. package/dist/PSTFile.class.js +221 -0
  41. package/dist/PSTFolder.class.d.ts +111 -0
  42. package/dist/PSTFolder.class.js +269 -0
  43. package/dist/PSTMessage.class.d.ts +773 -0
  44. package/dist/PSTMessage.class.js +1264 -0
  45. package/dist/PSTMessageStore.class.d.ts +16 -0
  46. package/dist/PSTMessageStore.class.js +18 -0
  47. package/dist/PSTObject.class.d.ts +107 -0
  48. package/dist/PSTObject.class.js +208 -0
  49. package/dist/PSTOpts.d.ts +24 -0
  50. package/dist/PSTOpts.js +2 -0
  51. package/dist/PSTRecipient.class.d.ts +68 -0
  52. package/dist/PSTRecipient.class.js +105 -0
  53. package/dist/PSTTask.class.d.ts +146 -0
  54. package/dist/PSTTask.class.js +206 -0
  55. package/dist/PSTUtil.class.d.ts +134 -0
  56. package/dist/PSTUtil.class.js +804 -0
  57. package/dist/Property.d.ts +38 -0
  58. package/dist/Property.js +2 -0
  59. package/dist/PropertyContext.d.ts +6 -0
  60. package/dist/PropertyContext.js +2 -0
  61. package/dist/PropertyContextUtil.d.ts +4 -0
  62. package/dist/PropertyContextUtil.js +77 -0
  63. package/dist/PropertyTypeObject.d.ts +12 -0
  64. package/dist/PropertyTypeObject.js +21 -0
  65. package/dist/PropertyValueResolver.d.ts +4 -0
  66. package/dist/PropertyValueResolver.js +2 -0
  67. package/dist/PropertyValueResolverV1.d.ts +7 -0
  68. package/dist/PropertyValueResolverV1.js +253 -0
  69. package/dist/RawProperty.d.ts +8 -0
  70. package/dist/RawProperty.js +2 -0
  71. package/dist/RecurrencePattern.class.d.ts +50 -0
  72. package/dist/RecurrencePattern.class.js +120 -0
  73. package/dist/RootProvider.d.ts +12 -0
  74. package/dist/RootProvider.js +2 -0
  75. package/dist/SingleAsyncProvider.d.ts +5 -0
  76. package/dist/SingleAsyncProvider.js +30 -0
  77. package/dist/TableContext.d.ts +4 -0
  78. package/dist/TableContext.js +2 -0
  79. package/dist/TableContextUtil.d.ts +4 -0
  80. package/dist/TableContextUtil.js +147 -0
  81. package/dist/TableRow.d.ts +6 -0
  82. package/dist/TableRow.js +2 -0
  83. package/dist/index.d.ts +15 -0
  84. package/dist/index.js +28 -0
  85. package/dist/msftUuidStringify.d.ts +17 -0
  86. package/dist/msftUuidStringify.js +48 -0
  87. package/dist/openPstFile.d.ts +19 -0
  88. package/dist/openPstFile.js +67 -0
  89. package/package.json +105 -0
  90. package/readme.md +16 -0
@@ -0,0 +1,144 @@
1
+ import Long from 'long';
2
+ import { PSTFolder } from './PSTFolder.class';
3
+ import { PSTMessageStore } from './PSTMessageStore.class';
4
+ import { NodeMap } from './NodeMap.class';
5
+ import { PSTOpts } from './PSTOpts';
6
+ import { PLStore } from './PLStore';
7
+ export declare class PSTFile {
8
+ /**
9
+ * @internal
10
+ */
11
+ static ENCRYPTION_TYPE_NONE: number;
12
+ /**
13
+ * @internal
14
+ */
15
+ static ENCRYPTION_TYPE_COMPRESSIBLE: number;
16
+ static MESSAGE_STORE_DESCRIPTOR_IDENTIFIER: number;
17
+ static ROOT_FOLDER_DESCRIPTOR_IDENTIFIER: number;
18
+ /**
19
+ * @internal
20
+ */
21
+ static PST_TYPE_ANSI: number;
22
+ /**
23
+ * @internal
24
+ */
25
+ static PST_TYPE_ANSI_2: number;
26
+ /**
27
+ * @internal
28
+ */
29
+ static PST_TYPE_UNICODE: number;
30
+ /**
31
+ * @internal
32
+ */
33
+ static PST_TYPE_2013_UNICODE: number;
34
+ /**
35
+ * @internal
36
+ */
37
+ static PS_PUBLIC_STRINGS: number;
38
+ /**
39
+ * @internal
40
+ */
41
+ static PS_INTERNET_HEADERS: number;
42
+ /**
43
+ * @internal
44
+ */
45
+ static PSETID_Messaging: number;
46
+ /**
47
+ * @internal
48
+ */
49
+ static PSETID_Note: number;
50
+ /**
51
+ * @internal
52
+ */
53
+ static PSETID_PostRss: number;
54
+ /**
55
+ * @internal
56
+ */
57
+ static PSETID_Task: number;
58
+ /**
59
+ * @internal
60
+ */
61
+ static PSETID_UnifiedMessaging: number;
62
+ /**
63
+ * @internal
64
+ */
65
+ static PS_MAPI: number;
66
+ /**
67
+ * @internal
68
+ */
69
+ static PSETID_AirSync: number;
70
+ /**
71
+ * @internal
72
+ */
73
+ static PSETID_Sharing: number;
74
+ private _store;
75
+ private _resolver;
76
+ private static nodeMap;
77
+ /**
78
+ * Creates an instance of PSTFile. File is opened in constructor.
79
+ * @internal
80
+ * @param {string} fileName
81
+ * @memberof PSTFile
82
+ */
83
+ constructor(store: PLStore, nodeMap: NodeMap, opts?: PSTOpts);
84
+ /**
85
+ * Close the file.
86
+ * @memberof PSTFile
87
+ */
88
+ close(): Promise<void>;
89
+ /**
90
+ * Get name to ID map item.
91
+ * @param {number} key
92
+ * @param {number} idx
93
+ * @returns {number}
94
+ * @memberof PSTFile
95
+ */
96
+ getNameToIdMapItem(key: number, idx: number): number;
97
+ /**
98
+ * Get public string to id map item.
99
+ * @static
100
+ * @param {string} key
101
+ * @returns {number}
102
+ * @memberof PSTFile
103
+ */
104
+ static getPublicStringToIdMapItem(key: string): number;
105
+ /**
106
+ * Get property name from id.
107
+ * @static
108
+ * @param {number} propertyId
109
+ * @param {boolean} bNamed
110
+ * @returns {string}
111
+ * @memberof PSTFile
112
+ */
113
+ static getPropertyName(propertyId: number, bNamed: boolean): string | undefined;
114
+ /**
115
+ * Get name to id map key.
116
+ * @static
117
+ * @param {number} propId
118
+ * @returns {long}
119
+ * @memberof PSTFile
120
+ */
121
+ static getNameToIdMapKey(propId: number): Long | undefined;
122
+ /**
123
+ * Get the message store of the PST file. Note that this doesn't really
124
+ * have much information, better to look under the root folder.
125
+ * @returns {PSTMessageStore}
126
+ * @memberof PSTFile
127
+ */
128
+ getMessageStore(): Promise<PSTMessageStore>;
129
+ private getFolderOf;
130
+ private getItemOf;
131
+ /**
132
+ * Get the root folder for the PST file
133
+ * @returns {PSTFolder}
134
+ * @memberof PSTFile
135
+ */
136
+ getRootFolder(): Promise<PSTFolder>;
137
+ private getRootProvider;
138
+ /**
139
+ * JSON stringify the object properties.
140
+ * @returns {string}
141
+ * @memberof PSTFile
142
+ */
143
+ toJSON(): any;
144
+ }
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PSTFile = void 0;
16
+ const PSTFolder_class_1 = require("./PSTFolder.class");
17
+ const PSTMessageStore_class_1 = require("./PSTMessageStore.class");
18
+ const PSTUtil_class_1 = require("./PSTUtil.class");
19
+ const NodeMap_class_1 = require("./NodeMap.class");
20
+ const PAUtil_1 = require("./PAUtil");
21
+ const PHUtil_1 = require("./PHUtil");
22
+ const PropertyContextUtil_1 = require("./PropertyContextUtil");
23
+ const PropertyValueResolverV1_1 = require("./PropertyValueResolverV1");
24
+ const iconv_lite_1 = __importDefault(require("iconv-lite"));
25
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
26
+ class PSTFile {
27
+ /**
28
+ * Creates an instance of PSTFile. File is opened in constructor.
29
+ * @internal
30
+ * @param {string} fileName
31
+ * @memberof PSTFile
32
+ */
33
+ constructor(store, nodeMap, opts) {
34
+ PSTFile.nodeMap = nodeMap;
35
+ this._store = store;
36
+ this._resolver = new PropertyValueResolverV1_1.PropertyValueResolverV1((array) => __awaiter(this, void 0, void 0, function* () {
37
+ return iconv_lite_1.default.decode(Buffer.from(array), (opts && opts.ansiEncoding) || "latin1");
38
+ }));
39
+ }
40
+ /**
41
+ * Close the file.
42
+ * @memberof PSTFile
43
+ */
44
+ close() {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ yield this._store.close();
47
+ });
48
+ }
49
+ /**
50
+ * Get name to ID map item.
51
+ * @param {number} key
52
+ * @param {number} idx
53
+ * @returns {number}
54
+ * @memberof PSTFile
55
+ */
56
+ getNameToIdMapItem(key, idx) {
57
+ return PSTFile.nodeMap.getId(key, idx);
58
+ }
59
+ /**
60
+ * Get public string to id map item.
61
+ * @static
62
+ * @param {string} key
63
+ * @returns {number}
64
+ * @memberof PSTFile
65
+ */
66
+ static getPublicStringToIdMapItem(key) {
67
+ return PSTFile.nodeMap.getId(key);
68
+ }
69
+ /**
70
+ * Get property name from id.
71
+ * @static
72
+ * @param {number} propertyId
73
+ * @param {boolean} bNamed
74
+ * @returns {string}
75
+ * @memberof PSTFile
76
+ */
77
+ static getPropertyName(propertyId, bNamed) {
78
+ return PSTUtil_class_1.PSTUtil.propertyName.get(propertyId);
79
+ }
80
+ /**
81
+ * Get name to id map key.
82
+ * @static
83
+ * @param {number} propId
84
+ * @returns {long}
85
+ * @memberof PSTFile
86
+ */
87
+ static getNameToIdMapKey(propId) {
88
+ return PSTFile.nodeMap.getNumericName(propId);
89
+ }
90
+ /**
91
+ * Get the message store of the PST file. Note that this doesn't really
92
+ * have much information, better to look under the root folder.
93
+ * @returns {PSTMessageStore}
94
+ * @memberof PSTFile
95
+ */
96
+ getMessageStore() {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ const node = this._store.getOneNodeBy(PSTFile.MESSAGE_STORE_DESCRIPTOR_IDENTIFIER);
99
+ if (node === undefined) {
100
+ throw new Error("MESSAGE_STORE_DESCRIPTOR not found");
101
+ }
102
+ const heap = yield (0, PHUtil_1.getHeapFrom)(node.getSubNode());
103
+ const pc = yield (0, PropertyContextUtil_1.getPropertyContext)(heap, this._resolver);
104
+ const propertyFinder = (0, PAUtil_1.createPropertyFinder)(yield pc.list());
105
+ return new PSTMessageStore_class_1.PSTMessageStore(this.getRootProvider(), node, node.getSubNode(), propertyFinder);
106
+ });
107
+ }
108
+ getFolderOf(node) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ const heap = yield (0, PHUtil_1.getHeapFrom)(node.getSubNode());
111
+ const pc = yield (0, PropertyContextUtil_1.getPropertyContext)(heap, this._resolver);
112
+ const propertyFinder = (0, PAUtil_1.createPropertyFinder)(yield pc.list());
113
+ const output = new PSTFolder_class_1.PSTFolder(this.getRootProvider(), node, node.getSubNode(), propertyFinder);
114
+ return output;
115
+ });
116
+ }
117
+ getItemOf(node, subNode, propertyFinder) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ return yield PSTUtil_class_1.PSTUtil.createAppropriatePSTMessageObject(this.getRootProvider(), node, subNode, this._resolver, propertyFinder);
120
+ });
121
+ }
122
+ /**
123
+ * Get the root folder for the PST file
124
+ * @returns {PSTFolder}
125
+ * @memberof PSTFile
126
+ */
127
+ getRootFolder() {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ const node = this._store.getOneNodeBy(PSTFile.ROOT_FOLDER_DESCRIPTOR_IDENTIFIER);
130
+ if (node === undefined) {
131
+ throw new Error("ROOT_FOLDER_DESCRIPTOR not found");
132
+ }
133
+ return yield this.getFolderOf(node);
134
+ });
135
+ }
136
+ getRootProvider() {
137
+ return {
138
+ resolver: this._resolver,
139
+ getNameToIdMapItem: this.getNameToIdMapItem.bind(this),
140
+ getItemOf: this.getItemOf.bind(this),
141
+ getFolderOf: this.getFolderOf.bind(this),
142
+ };
143
+ }
144
+ /**
145
+ * JSON stringify the object properties.
146
+ * @returns {string}
147
+ * @memberof PSTFile
148
+ */
149
+ toJSON() {
150
+ return this;
151
+ }
152
+ }
153
+ exports.PSTFile = PSTFile;
154
+ /**
155
+ * @internal
156
+ */
157
+ PSTFile.ENCRYPTION_TYPE_NONE = 0;
158
+ /**
159
+ * @internal
160
+ */
161
+ PSTFile.ENCRYPTION_TYPE_COMPRESSIBLE = 1;
162
+ PSTFile.MESSAGE_STORE_DESCRIPTOR_IDENTIFIER = 33;
163
+ PSTFile.ROOT_FOLDER_DESCRIPTOR_IDENTIFIER = 290;
164
+ /**
165
+ * @internal
166
+ */
167
+ PSTFile.PST_TYPE_ANSI = 14;
168
+ /**
169
+ * @internal
170
+ */
171
+ PSTFile.PST_TYPE_ANSI_2 = 15;
172
+ /**
173
+ * @internal
174
+ */
175
+ PSTFile.PST_TYPE_UNICODE = 23;
176
+ /**
177
+ * @internal
178
+ */
179
+ PSTFile.PST_TYPE_2013_UNICODE = 36;
180
+ /**
181
+ * @internal
182
+ */
183
+ PSTFile.PS_PUBLIC_STRINGS = 0;
184
+ /**
185
+ * @internal
186
+ */
187
+ PSTFile.PS_INTERNET_HEADERS = 3;
188
+ /**
189
+ * @internal
190
+ */
191
+ PSTFile.PSETID_Messaging = 7;
192
+ /**
193
+ * @internal
194
+ */
195
+ PSTFile.PSETID_Note = 8;
196
+ /**
197
+ * @internal
198
+ */
199
+ PSTFile.PSETID_PostRss = 9;
200
+ /**
201
+ * @internal
202
+ */
203
+ PSTFile.PSETID_Task = 10;
204
+ /**
205
+ * @internal
206
+ */
207
+ PSTFile.PSETID_UnifiedMessaging = 11;
208
+ /**
209
+ * @internal
210
+ */
211
+ PSTFile.PS_MAPI = 12;
212
+ /**
213
+ * @internal
214
+ */
215
+ PSTFile.PSETID_AirSync = 13;
216
+ /**
217
+ * @internal
218
+ */
219
+ PSTFile.PSETID_Sharing = 14;
220
+ // node tree maps
221
+ PSTFile.nodeMap = new NodeMap_class_1.NodeMap();
@@ -0,0 +1,111 @@
1
+ import { PSTObject } from './PSTObject.class';
2
+ import { PLNode } from './PLNode';
3
+ import { PropertyFinder } from './PAUtil';
4
+ import { PSTMessage } from './PSTMessage.class';
5
+ import { PLSubNode } from './PLSubNode';
6
+ import { RootProvider } from './RootProvider';
7
+ /**
8
+ * Represents a folder in the PST File. Allows you to access child folders or items.
9
+ * Items are accessed through a sort of cursor arrangement. This allows for
10
+ * incremental reading of a folder which may have _lots_ of emails.
11
+ * @export
12
+ * @class PSTFolder
13
+ * @extends {PSTObject}
14
+ */
15
+ export declare class PSTFolder extends PSTObject {
16
+ private _subFoldersProvider;
17
+ private _emailsProvider;
18
+ /**
19
+ * Creates an instance of PSTFolder.
20
+ * Represents a folder in the PST File. Allows you to access child folders or items.
21
+ * Items are accessed through a sort of cursor arrangement. This allows for
22
+ * incremental reading of a folder which may have _lots_ of emails.
23
+ * @internal
24
+ * @param {PSTFile} rootProvider
25
+ * @param {DescriptorIndexNode} descriptorIndexNode
26
+ * @param {Map<number, PSTDescriptorItem>} [localDescriptorItems]
27
+ * @memberof PSTFolder
28
+ */
29
+ constructor(rootProvider: RootProvider, node: PLNode, subNode: PLSubNode, propertyFinder: PropertyFinder);
30
+ private getEmailsProvider;
31
+ private getSubFoldersProvider;
32
+ /**
33
+ * Get folders in one fell swoop, since there's not usually thousands of them.
34
+ * @returns {PSTFolder[]}
35
+ * @memberof PSTFolder
36
+ */
37
+ getSubFolders(): Promise<PSTFolder[]>;
38
+ getSubFolder(index: number): Promise<PSTFolder>;
39
+ /**
40
+ * The number of child folders in this folder
41
+ * @readonly
42
+ * @type {number}
43
+ * @memberof PSTFolder
44
+ */
45
+ getSubFolderCount(): Promise<number>;
46
+ /**
47
+ * Number of emails in this folder
48
+ * @readonly
49
+ * @type {number}
50
+ * @memberof PSTFolder
51
+ */
52
+ getEmailCount(): Promise<number>;
53
+ getEmail(index: number): Promise<PSTMessage>;
54
+ getEmails(): Promise<PSTMessage[]>;
55
+ /**
56
+ * Contains a constant that indicates the folder type.
57
+ * https://msdn.microsoft.com/en-us/library/office/cc815373.aspx
58
+ * @readonly
59
+ * @type {number}
60
+ * @memberof PSTFolder
61
+ */
62
+ get folderType(): number;
63
+ /**
64
+ * Contains the number of messages in a folder, as computed by the message store.
65
+ * For a number calculated by the library use getEmailCount
66
+ * @readonly
67
+ * @type {number}
68
+ * @memberof PSTFolder
69
+ */
70
+ get contentCount(): number;
71
+ /**
72
+ * Contains the number of unread messages in a folder, as computed by the message store.
73
+ * https://msdn.microsoft.com/en-us/library/office/cc841964.aspx
74
+ * @readonly
75
+ * @type {number}
76
+ * @memberof PSTFolder
77
+ */
78
+ get unreadCount(): number;
79
+ /**
80
+ * Contains TRUE if a folder contains subfolders.
81
+ * once again, read from the PST, use getSubFolderCount if you want to know
82
+ * @readonly
83
+ * @type {boolean}
84
+ * @memberof PSTFolder
85
+ */
86
+ get hasSubfolders(): boolean;
87
+ /**
88
+ * Contains a text string describing the type of a folder. Although this property is
89
+ * generally ignored, versions of Microsoft® Exchange Server prior to Exchange Server
90
+ * 2003 Mailbox Manager expect this property to be present.
91
+ * https://msdn.microsoft.com/en-us/library/office/cc839839.aspx
92
+ * @readonly
93
+ * @type {string}
94
+ * @memberof PSTFolder
95
+ */
96
+ get containerClass(): string;
97
+ /**
98
+ * Contains a bitmask of flags describing capabilities of an address book container.
99
+ * https://msdn.microsoft.com/en-us/library/office/cc839610.aspx
100
+ * @readonly
101
+ * @type {number}
102
+ * @memberof PSTFolder
103
+ */
104
+ get containerFlags(): number;
105
+ /**
106
+ * JSON stringify the object properties.
107
+ * @returns {string}
108
+ * @memberof PSTFolder
109
+ */
110
+ toJSON(): any;
111
+ }