@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.
- package/dist/BTHeap.d.ts +15 -0
- package/dist/BTHeap.js +76 -0
- package/dist/CollectionAsyncProvider.d.ts +15 -0
- package/dist/CollectionAsyncProvider.js +44 -0
- package/dist/KeyedDelay.d.ts +8 -0
- package/dist/KeyedDelay.js +37 -0
- package/dist/LZFu.class.d.ts +12 -0
- package/dist/LZFu.class.js +95 -0
- package/dist/NodeMap.class.d.ts +35 -0
- package/dist/NodeMap.class.js +86 -0
- package/dist/OutlookProperties.d.ts +278 -0
- package/dist/OutlookProperties.js +284 -0
- package/dist/PAUtil.d.ts +17 -0
- package/dist/PAUtil.js +145 -0
- package/dist/PHNodeHeap.d.ts +16 -0
- package/dist/PHNodeHeap.js +2 -0
- package/dist/PHNodeHeapReader.d.ts +6 -0
- package/dist/PHNodeHeapReader.js +5 -0
- package/dist/PHUtil.d.ts +6 -0
- package/dist/PHUtil.js +103 -0
- package/dist/PLMisc.d.ts +8 -0
- package/dist/PLMisc.js +16 -0
- package/dist/PLNode.d.ts +11 -0
- package/dist/PLNode.js +5 -0
- package/dist/PLStore.d.ts +9 -0
- package/dist/PLStore.js +5 -0
- package/dist/PLSubNode.d.ts +8 -0
- package/dist/PLSubNode.js +5 -0
- package/dist/PLUtil.d.ts +29 -0
- package/dist/PLUtil.js +683 -0
- package/dist/PSTActivity.class.d.ts +103 -0
- package/dist/PSTActivity.class.js +144 -0
- package/dist/PSTAppointment.class.d.ts +275 -0
- package/dist/PSTAppointment.class.js +381 -0
- package/dist/PSTAttachment.class.d.ts +168 -0
- package/dist/PSTAttachment.class.js +286 -0
- package/dist/PSTContact.class.d.ts +900 -0
- package/dist/PSTContact.class.js +1253 -0
- package/dist/PSTFile.class.d.ts +144 -0
- package/dist/PSTFile.class.js +221 -0
- package/dist/PSTFolder.class.d.ts +111 -0
- package/dist/PSTFolder.class.js +269 -0
- package/dist/PSTMessage.class.d.ts +773 -0
- package/dist/PSTMessage.class.js +1264 -0
- package/dist/PSTMessageStore.class.d.ts +16 -0
- package/dist/PSTMessageStore.class.js +18 -0
- package/dist/PSTObject.class.d.ts +107 -0
- package/dist/PSTObject.class.js +208 -0
- package/dist/PSTOpts.d.ts +24 -0
- package/dist/PSTOpts.js +2 -0
- package/dist/PSTRecipient.class.d.ts +68 -0
- package/dist/PSTRecipient.class.js +105 -0
- package/dist/PSTTask.class.d.ts +146 -0
- package/dist/PSTTask.class.js +206 -0
- package/dist/PSTUtil.class.d.ts +134 -0
- package/dist/PSTUtil.class.js +804 -0
- package/dist/Property.d.ts +38 -0
- package/dist/Property.js +2 -0
- package/dist/PropertyContext.d.ts +6 -0
- package/dist/PropertyContext.js +2 -0
- package/dist/PropertyContextUtil.d.ts +4 -0
- package/dist/PropertyContextUtil.js +77 -0
- package/dist/PropertyTypeObject.d.ts +12 -0
- package/dist/PropertyTypeObject.js +21 -0
- package/dist/PropertyValueResolver.d.ts +4 -0
- package/dist/PropertyValueResolver.js +2 -0
- package/dist/PropertyValueResolverV1.d.ts +7 -0
- package/dist/PropertyValueResolverV1.js +253 -0
- package/dist/RawProperty.d.ts +8 -0
- package/dist/RawProperty.js +2 -0
- package/dist/RecurrencePattern.class.d.ts +50 -0
- package/dist/RecurrencePattern.class.js +120 -0
- package/dist/RootProvider.d.ts +12 -0
- package/dist/RootProvider.js +2 -0
- package/dist/SingleAsyncProvider.d.ts +5 -0
- package/dist/SingleAsyncProvider.js +30 -0
- package/dist/TableContext.d.ts +4 -0
- package/dist/TableContext.js +2 -0
- package/dist/TableContextUtil.d.ts +4 -0
- package/dist/TableContextUtil.js +147 -0
- package/dist/TableRow.d.ts +6 -0
- package/dist/TableRow.js +2 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +28 -0
- package/dist/msftUuidStringify.d.ts +17 -0
- package/dist/msftUuidStringify.js +48 -0
- package/dist/openPstFile.d.ts +19 -0
- package/dist/openPstFile.js +67 -0
- package/package.json +105 -0
- package/readme.md +16 -0
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SingleAsyncProvider = void 0;
|
|
13
|
+
class SingleAsyncProvider {
|
|
14
|
+
constructor() {
|
|
15
|
+
this._ready = false;
|
|
16
|
+
}
|
|
17
|
+
getOrCreate(provider) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
if (!this._ready) {
|
|
20
|
+
this._value = yield provider();
|
|
21
|
+
this._ready = true;
|
|
22
|
+
}
|
|
23
|
+
if (this._value === undefined) {
|
|
24
|
+
throw new Error("provider must provide non-undefined value");
|
|
25
|
+
}
|
|
26
|
+
return this._value;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.SingleAsyncProvider = SingleAsyncProvider;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PHNodeHeap } from "./PHNodeHeap";
|
|
2
|
+
import { PropertyValueResolver } from "./PropertyValueResolver";
|
|
3
|
+
import { TableContext } from "./TableContext";
|
|
4
|
+
export declare function getTableContext(heap: PHNodeHeap, resolver: PropertyValueResolver): Promise<TableContext>;
|
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getTableContext = void 0;
|
|
13
|
+
const PLMisc_1 = require("./PLMisc");
|
|
14
|
+
const bTypeTC = 0x7c;
|
|
15
|
+
function copy(rows) {
|
|
16
|
+
return rows.map(it => Object.assign({}, it));
|
|
17
|
+
}
|
|
18
|
+
function getTableContext(heap, resolver) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (heap.bClientSig != bTypeTC) {
|
|
21
|
+
throw new Error("expected type bTypeTC");
|
|
22
|
+
}
|
|
23
|
+
const reader = heap.getReader();
|
|
24
|
+
const headerData = yield reader.getHeapBuffers(heap.userRootHnid);
|
|
25
|
+
if (headerData.length !== 1) {
|
|
26
|
+
throw new Error("table context header buffer must be single");
|
|
27
|
+
}
|
|
28
|
+
const headerView = new DataView(headerData[0]);
|
|
29
|
+
const tcSig = headerView.getUint8(0);
|
|
30
|
+
const numCols = headerView.getUint8(1);
|
|
31
|
+
const cebOffset = headerView.getUint16(6, true);
|
|
32
|
+
const numRowBytes = headerView.getUint16(8, true);
|
|
33
|
+
const hidRowIndex = headerView.getUint32(10, true);
|
|
34
|
+
const hnidRows = headerView.getUint32(14, true);
|
|
35
|
+
var tColDesc = headerData[0].slice(22);
|
|
36
|
+
const schema = Array.from((0, PLMisc_1.splitPer)(tColDesc, 8))
|
|
37
|
+
.map(it => {
|
|
38
|
+
const view = new DataView(it);
|
|
39
|
+
return {
|
|
40
|
+
type: view.getUint16(0, true),
|
|
41
|
+
key: view.getUint16(2, true),
|
|
42
|
+
ibData: view.getUint16(4, true),
|
|
43
|
+
cbData: view.getUint8(6),
|
|
44
|
+
iBit: view.getUint8(7),
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
if (numCols !== schema.length) {
|
|
48
|
+
throw new Error("schema length not matched");
|
|
49
|
+
}
|
|
50
|
+
if (tcSig !== 0x7c) {
|
|
51
|
+
throw new Error("tcSig is not 0x7c");
|
|
52
|
+
}
|
|
53
|
+
//const min_size = schema.reduce((accum, it) => accum + it.cbData, 0);
|
|
54
|
+
//const rowIndex = getBTHeapReaderFrom(reader, hidRowIndex);
|
|
55
|
+
const rows_pages = (hnidRows !== 0)
|
|
56
|
+
? yield reader.getHeapBuffers(hnidRows)
|
|
57
|
+
: [];
|
|
58
|
+
//const data2 = await reader.getHeapBuffers(offset2);
|
|
59
|
+
const rows_per_page = (rows_pages.length !== 0)
|
|
60
|
+
? Math.floor(rows_pages[0].byteLength / numRowBytes)
|
|
61
|
+
: 0;
|
|
62
|
+
function get_record(record_index) {
|
|
63
|
+
const page_index = (record_index / rows_per_page) | 0;
|
|
64
|
+
const heap_index = (record_index % rows_per_page) | 0;
|
|
65
|
+
const buffer = rows_pages[page_index].slice(numRowBytes * (heap_index + 0), numRowBytes * (heap_index + 1));
|
|
66
|
+
if (buffer.byteLength !== numRowBytes) {
|
|
67
|
+
throw new Error(`get_record(${record_index}) is reaching EOF while reading record. The heap is ${reader}`);
|
|
68
|
+
}
|
|
69
|
+
const ceb = [];
|
|
70
|
+
{
|
|
71
|
+
const rgCEB = new Uint8Array(buffer.slice(cebOffset));
|
|
72
|
+
for (let x = 0; x < numCols; x++) {
|
|
73
|
+
ceb.push((rgCEB[(x / 8) | 0] & (1 << (7 - (x % 8)))) != 0);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
buffer,
|
|
78
|
+
ceb,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const count = rows_pages.reduce((accum, it) => (accum + it.byteLength / numRowBytes) | 0, 0);
|
|
82
|
+
function listRaw(index) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const record = get_record(index);
|
|
85
|
+
const list = [];
|
|
86
|
+
for (let column of schema) {
|
|
87
|
+
list.push({
|
|
88
|
+
key: column.key,
|
|
89
|
+
type: column.type,
|
|
90
|
+
value: record.ceb[column.iBit]
|
|
91
|
+
? record.buffer.slice(column.ibData, column.ibData + column.cbData)
|
|
92
|
+
: new ArrayBuffer(0),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return list;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function list(record) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const rawProps = yield listRaw(record);
|
|
101
|
+
const list = [];
|
|
102
|
+
for (let rawProp of rawProps) {
|
|
103
|
+
try {
|
|
104
|
+
list.push({
|
|
105
|
+
key: rawProp.key,
|
|
106
|
+
type: rawProp.type,
|
|
107
|
+
value: (rawProp.value.byteLength !== 0)
|
|
108
|
+
? yield resolver.resolveValueOf(rawProp.key, rawProp.type, rawProp.value, reader)
|
|
109
|
+
: undefined
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
catch (ex) {
|
|
113
|
+
throw new Error(`getTableContext.list(rowIndex=${record}) resolving property`
|
|
114
|
+
+ ` key=0x${rawProp.key.toString(16).padStart(4, '0')}`
|
|
115
|
+
+ ` type=0x${rawProp.type.toString(16).padStart(4, '0')}`
|
|
116
|
+
+ ` of ${heap} failure`
|
|
117
|
+
+ ` --> ${ex}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return list;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const rows = [];
|
|
124
|
+
for (let x = 0; x < count; x++) {
|
|
125
|
+
rows.push({
|
|
126
|
+
listRaw() {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
return yield listRaw(x);
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
list() {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
return yield list(x);
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
rows() {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
return copy(rows);
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
exports.getTableContext = getTableContext;
|
package/dist/TableRow.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { PSTFile } from './PSTFile.class';
|
|
2
|
+
export { PSTTask } from './PSTTask.class';
|
|
3
|
+
export { PSTRecipient } from './PSTRecipient.class';
|
|
4
|
+
export { PSTAttachment } from './PSTAttachment.class';
|
|
5
|
+
export { PSTMessage } from './PSTMessage.class';
|
|
6
|
+
export { PSTFolder } from './PSTFolder.class';
|
|
7
|
+
export { openPstFile, openPst, } from './openPstFile';
|
|
8
|
+
export { PSTOpts } from './PSTOpts';
|
|
9
|
+
export { PSTContact } from './PSTContact.class';
|
|
10
|
+
export { PSTAppointment } from './PSTAppointment.class';
|
|
11
|
+
export { PSTMessageStore } from './PSTMessageStore.class';
|
|
12
|
+
export { PSTObject } from './PSTObject.class';
|
|
13
|
+
export { Property } from './Property';
|
|
14
|
+
export { PropertyTypeObject } from './PropertyTypeObject';
|
|
15
|
+
export { ReadFileApi, ReadFile, Close, } from './PLUtil';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropertyTypeObject = exports.PSTObject = exports.PSTMessageStore = exports.PSTAppointment = exports.PSTContact = exports.openPst = exports.openPstFile = exports.PSTFolder = exports.PSTMessage = exports.PSTAttachment = exports.PSTRecipient = exports.PSTTask = exports.PSTFile = void 0;
|
|
4
|
+
var PSTFile_class_1 = require("./PSTFile.class");
|
|
5
|
+
Object.defineProperty(exports, "PSTFile", { enumerable: true, get: function () { return PSTFile_class_1.PSTFile; } });
|
|
6
|
+
var PSTTask_class_1 = require("./PSTTask.class");
|
|
7
|
+
Object.defineProperty(exports, "PSTTask", { enumerable: true, get: function () { return PSTTask_class_1.PSTTask; } });
|
|
8
|
+
var PSTRecipient_class_1 = require("./PSTRecipient.class");
|
|
9
|
+
Object.defineProperty(exports, "PSTRecipient", { enumerable: true, get: function () { return PSTRecipient_class_1.PSTRecipient; } });
|
|
10
|
+
var PSTAttachment_class_1 = require("./PSTAttachment.class");
|
|
11
|
+
Object.defineProperty(exports, "PSTAttachment", { enumerable: true, get: function () { return PSTAttachment_class_1.PSTAttachment; } });
|
|
12
|
+
var PSTMessage_class_1 = require("./PSTMessage.class");
|
|
13
|
+
Object.defineProperty(exports, "PSTMessage", { enumerable: true, get: function () { return PSTMessage_class_1.PSTMessage; } });
|
|
14
|
+
var PSTFolder_class_1 = require("./PSTFolder.class");
|
|
15
|
+
Object.defineProperty(exports, "PSTFolder", { enumerable: true, get: function () { return PSTFolder_class_1.PSTFolder; } });
|
|
16
|
+
var openPstFile_1 = require("./openPstFile");
|
|
17
|
+
Object.defineProperty(exports, "openPstFile", { enumerable: true, get: function () { return openPstFile_1.openPstFile; } });
|
|
18
|
+
Object.defineProperty(exports, "openPst", { enumerable: true, get: function () { return openPstFile_1.openPst; } });
|
|
19
|
+
var PSTContact_class_1 = require("./PSTContact.class");
|
|
20
|
+
Object.defineProperty(exports, "PSTContact", { enumerable: true, get: function () { return PSTContact_class_1.PSTContact; } });
|
|
21
|
+
var PSTAppointment_class_1 = require("./PSTAppointment.class");
|
|
22
|
+
Object.defineProperty(exports, "PSTAppointment", { enumerable: true, get: function () { return PSTAppointment_class_1.PSTAppointment; } });
|
|
23
|
+
var PSTMessageStore_class_1 = require("./PSTMessageStore.class");
|
|
24
|
+
Object.defineProperty(exports, "PSTMessageStore", { enumerable: true, get: function () { return PSTMessageStore_class_1.PSTMessageStore; } });
|
|
25
|
+
var PSTObject_class_1 = require("./PSTObject.class");
|
|
26
|
+
Object.defineProperty(exports, "PSTObject", { enumerable: true, get: function () { return PSTObject_class_1.PSTObject; } });
|
|
27
|
+
var PropertyTypeObject_1 = require("./PropertyTypeObject");
|
|
28
|
+
Object.defineProperty(exports, "PropertyTypeObject", { enumerable: true, get: function () { return PropertyTypeObject_1.PropertyTypeObject; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* byte to lower case hex string
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare function toHex1(value: number): string;
|
|
7
|
+
/**
|
|
8
|
+
* Variant 2 UUIDs, historically used in Microsoft's COM/OLE libraries,
|
|
9
|
+
* use a mixed-endian format, whereby the first three components of the UUID are little-endian,
|
|
10
|
+
* and the last two are big-endian.
|
|
11
|
+
* For example, `00112233-4455-6677-8899-aabbccddeeff` is encoded as the bytes
|
|
12
|
+
* `33 22 11 00 55 44 77 66 88 99 aa bb cc dd ee ff`.
|
|
13
|
+
*
|
|
14
|
+
* @see https://en.wikipedia.org/wiki/Universally_unique_identifier
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function msftUuidStringify(array: ArrayLike<number>, offset: number): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.msftUuidStringify = exports.toHex1 = void 0;
|
|
4
|
+
const hex = "0123456789abcdef";
|
|
5
|
+
/**
|
|
6
|
+
* byte to lower case hex string
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
function toHex1(value) {
|
|
11
|
+
return hex[(value >> 4) & 15]
|
|
12
|
+
+ hex[(value) & 15];
|
|
13
|
+
}
|
|
14
|
+
exports.toHex1 = toHex1;
|
|
15
|
+
/**
|
|
16
|
+
* Variant 2 UUIDs, historically used in Microsoft's COM/OLE libraries,
|
|
17
|
+
* use a mixed-endian format, whereby the first three components of the UUID are little-endian,
|
|
18
|
+
* and the last two are big-endian.
|
|
19
|
+
* For example, `00112233-4455-6677-8899-aabbccddeeff` is encoded as the bytes
|
|
20
|
+
* `33 22 11 00 55 44 77 66 88 99 aa bb cc dd ee ff`.
|
|
21
|
+
*
|
|
22
|
+
* @see https://en.wikipedia.org/wiki/Universally_unique_identifier
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
function msftUuidStringify(array, offset) {
|
|
26
|
+
return ""
|
|
27
|
+
+ toHex1(array[offset + 3])
|
|
28
|
+
+ toHex1(array[offset + 2])
|
|
29
|
+
+ toHex1(array[offset + 1])
|
|
30
|
+
+ toHex1(array[offset + 0])
|
|
31
|
+
+ "-"
|
|
32
|
+
+ toHex1(array[offset + 5])
|
|
33
|
+
+ toHex1(array[offset + 4])
|
|
34
|
+
+ "-"
|
|
35
|
+
+ toHex1(array[offset + 7])
|
|
36
|
+
+ toHex1(array[offset + 6])
|
|
37
|
+
+ "-"
|
|
38
|
+
+ toHex1(array[offset + 8])
|
|
39
|
+
+ toHex1(array[offset + 9])
|
|
40
|
+
+ "-"
|
|
41
|
+
+ toHex1(array[offset + 10])
|
|
42
|
+
+ toHex1(array[offset + 11])
|
|
43
|
+
+ toHex1(array[offset + 12])
|
|
44
|
+
+ toHex1(array[offset + 13])
|
|
45
|
+
+ toHex1(array[offset + 14])
|
|
46
|
+
+ toHex1(array[offset + 15]);
|
|
47
|
+
}
|
|
48
|
+
exports.msftUuidStringify = msftUuidStringify;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PSTFile } from './PSTFile.class';
|
|
2
|
+
import { ReadFileApi } from './PLUtil';
|
|
3
|
+
import { PSTOpts } from './PSTOpts';
|
|
4
|
+
/**
|
|
5
|
+
* Open pst/ost file from os file path.
|
|
6
|
+
*
|
|
7
|
+
* @param path os file path.
|
|
8
|
+
* @param opts options
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function openPstFile(path: string, opts?: PSTOpts): Promise<PSTFile>;
|
|
12
|
+
/**
|
|
13
|
+
* Open pst/ost file using user defined callback.
|
|
14
|
+
*
|
|
15
|
+
* @param api reader callback
|
|
16
|
+
* @param opts options
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare function openPst(api: ReadFileApi, opts?: PSTOpts): Promise<PSTFile>;
|
|
@@ -0,0 +1,67 @@
|
|
|
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.openPst = exports.openPstFile = void 0;
|
|
16
|
+
const PSTFile_class_1 = require("./PSTFile.class");
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
18
|
+
const PLUtil_1 = require("./PLUtil");
|
|
19
|
+
const PropertyValueResolverV1_1 = require("./PropertyValueResolverV1");
|
|
20
|
+
const iconv_lite_1 = __importDefault(require("iconv-lite"));
|
|
21
|
+
const PAUtil_1 = require("./PAUtil");
|
|
22
|
+
/**
|
|
23
|
+
* Open pst/ost file from os file path.
|
|
24
|
+
*
|
|
25
|
+
* @param path os file path.
|
|
26
|
+
* @param opts options
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
function openPstFile(path, opts) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const file = yield fs_1.default.promises.open(path, "r");
|
|
32
|
+
function readFile(buffer, offset, length, position) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const view = new Uint8Array(buffer);
|
|
35
|
+
const { bytesRead } = yield file.read(view, offset, length, position);
|
|
36
|
+
return bytesRead;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return yield openPst({
|
|
40
|
+
readFile,
|
|
41
|
+
close: () => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
yield file.close();
|
|
43
|
+
}),
|
|
44
|
+
}, opts);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.openPstFile = openPstFile;
|
|
48
|
+
/**
|
|
49
|
+
* Open pst/ost file using user defined callback.
|
|
50
|
+
*
|
|
51
|
+
* @param api reader callback
|
|
52
|
+
* @param opts options
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
function openPst(api, opts) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const lowPst = yield (0, PLUtil_1.openLowPst)(api);
|
|
58
|
+
const convertAnsiString = (opts && opts.convertAnsiString)
|
|
59
|
+
|| ((array) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
return iconv_lite_1.default.decode(Buffer.from(array), (opts && opts.ansiEncoding) || "latin1");
|
|
61
|
+
}));
|
|
62
|
+
const resolver = new PropertyValueResolverV1_1.PropertyValueResolverV1(convertAnsiString);
|
|
63
|
+
const nodeMap = yield (0, PAUtil_1.processNameToIDMap)(yield lowPst.getOneNodeByOrError(97), resolver);
|
|
64
|
+
return new PSTFile_class_1.PSTFile(lowPst, nodeMap, opts);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
exports.openPst = openPst;
|
package/package.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hiraokahypertools/pst-extractor",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "Extract objects from MS Outlook/Exchange PST files",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=10"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prebuild": "rimraf dist",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "run-s test:unit test:build",
|
|
14
|
+
"test:build": "run-s build",
|
|
15
|
+
"test:unit": "cross-env CI=1 jest --coverage --reporters=default --reporters=jest-junit"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/HiraokaHyperTools/pst-extractor.git"
|
|
20
|
+
},
|
|
21
|
+
"author": "kenjiuno",
|
|
22
|
+
"contributors": [
|
|
23
|
+
{
|
|
24
|
+
"name": "Ed Pfromer",
|
|
25
|
+
"email": "epfromer@gmail.com"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@babel/core": "^7.17.8",
|
|
31
|
+
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
32
|
+
"@babel/preset-env": "^7.16.11",
|
|
33
|
+
"@babel/preset-typescript": "^7.16.7",
|
|
34
|
+
"@types/debug": "4.1.7",
|
|
35
|
+
"@types/jest": "^27.4.1",
|
|
36
|
+
"@types/long": "^4.0.1",
|
|
37
|
+
"@types/node": "^17.0.23",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^5.18.0",
|
|
39
|
+
"@typescript-eslint/parser": "^5.18.0",
|
|
40
|
+
"babel-eslint": "^10.1.0",
|
|
41
|
+
"babel-jest": "^27.5.1",
|
|
42
|
+
"cross-env": "^7.0.3",
|
|
43
|
+
"debug": "^4.3.4",
|
|
44
|
+
"eslint": "^8.12.0",
|
|
45
|
+
"eslint-config-prettier": "^8.5.0",
|
|
46
|
+
"eslint-config-standard": "^16.0.3",
|
|
47
|
+
"eslint-plugin-import": "^2.26.0",
|
|
48
|
+
"eslint-plugin-node": "^11.1.0",
|
|
49
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
50
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
51
|
+
"eslint-plugin-standard": "^5.0.0",
|
|
52
|
+
"jest": "^27.5.1",
|
|
53
|
+
"jest-junit": "^13.1.0",
|
|
54
|
+
"npm-run-all": "^4.1.5",
|
|
55
|
+
"prettier": "^2.6.2",
|
|
56
|
+
"rimraf": "^3.0.2",
|
|
57
|
+
"source-map-support": "^0.5.21",
|
|
58
|
+
"ts-node": "^10.7.0",
|
|
59
|
+
"typedoc": "^0.23.10",
|
|
60
|
+
"typescript": "^4.6.3"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"iconv-lite": "^0.6.3",
|
|
64
|
+
"long": "^5.2.0"
|
|
65
|
+
},
|
|
66
|
+
"eslintConfig": {
|
|
67
|
+
"extends": [
|
|
68
|
+
"plugin:@typescript-eslint/recommended",
|
|
69
|
+
"prettier/@typescript-eslint",
|
|
70
|
+
"plugin:prettier/recommended"
|
|
71
|
+
],
|
|
72
|
+
"parserOptions": {
|
|
73
|
+
"ecmaVersion": 2018,
|
|
74
|
+
"sourceType": "module"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"prettier": {
|
|
78
|
+
"semi": false,
|
|
79
|
+
"singleQuote": true,
|
|
80
|
+
"endOfLine": "auto"
|
|
81
|
+
},
|
|
82
|
+
"babel": {
|
|
83
|
+
"presets": [
|
|
84
|
+
"@babel/preset-env",
|
|
85
|
+
"@babel/preset-typescript"
|
|
86
|
+
],
|
|
87
|
+
"plugins": [
|
|
88
|
+
"@babel/plugin-proposal-class-properties"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
"jest": {
|
|
92
|
+
"testMatch": [
|
|
93
|
+
"<rootDir>/src/__tests__/**/*.spec.ts"
|
|
94
|
+
],
|
|
95
|
+
"collectCoverageFrom": [
|
|
96
|
+
"<rootDir>/src/**/*.ts",
|
|
97
|
+
"!<rootDir>/src/__tests__/**/*.*"
|
|
98
|
+
],
|
|
99
|
+
"coverageReporters": [
|
|
100
|
+
"text",
|
|
101
|
+
"cobertura"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"files": ["dist"]
|
|
105
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# pst-extractor
|
|
2
|
+
|
|
3
|
+
Extract objects from MS Outlook/Exchange PST files
|
|
4
|
+
|
|
5
|
+
This is a private fork of https://github.com/epfromer/pst-extractor repository.
|
|
6
|
+
|
|
7
|
+
Links: [typedoc](https://hiraokahypertools.github.io/pst-extractor/typedoc/)
|
|
8
|
+
|
|
9
|
+
## Authors
|
|
10
|
+
|
|
11
|
+
- kenjiuno
|
|
12
|
+
- Ed Pfromer (epfromer@gmail.com)
|
|
13
|
+
|
|
14
|
+
## License
|
|
15
|
+
|
|
16
|
+
MIT © [epfromer](https://github.com/epfromer), kenjiuno
|