@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,38 @@
|
|
|
1
|
+
export interface Property {
|
|
2
|
+
/**
|
|
3
|
+
* Key of property.
|
|
4
|
+
*
|
|
5
|
+
* e.g. `0x3001` is `PR_DISPLAY_NAME`
|
|
6
|
+
*/
|
|
7
|
+
key: number;
|
|
8
|
+
/**
|
|
9
|
+
* Type of property.
|
|
10
|
+
*
|
|
11
|
+
* e.g. `0x001f` is `PT_UNICODE`
|
|
12
|
+
*/
|
|
13
|
+
type: number;
|
|
14
|
+
/**
|
|
15
|
+
* Value of property.
|
|
16
|
+
*
|
|
17
|
+
* The value conversion depends on implementation.
|
|
18
|
+
* Check the source code of {@link PropertyValueResolverV1} for detail.
|
|
19
|
+
*
|
|
20
|
+
* - `PT_SHORT` will be casted to `number`
|
|
21
|
+
* - `PT_FLOAT` will be casted to `number`
|
|
22
|
+
* - `PT_LONG` will be casted to `number`
|
|
23
|
+
* - `PT_OBJECT` will be casted to {@link PropertyTypeObject}
|
|
24
|
+
* - `PT_LONGLONG` will be casted to `Long`
|
|
25
|
+
* - `PT_DOUBLE` will be casted to `number`
|
|
26
|
+
* - `PT_BOOLEAN` will be casted to `boolean`
|
|
27
|
+
* - `PT_STRING8` will be casted to `string`
|
|
28
|
+
* - `PT_UNICODE` will be casted to `string`
|
|
29
|
+
* - `PT_SYSTIME` will be casted to `Date`
|
|
30
|
+
* - `PT_CLSID` will be casted to `ArrayBuffer`
|
|
31
|
+
* - `0x0102` will be casted to `ArrayBuffer`
|
|
32
|
+
* - `PT_MV_UNICODE` will be casted to `string[]`
|
|
33
|
+
* - `PT_MV_BINARY` will be casted to `ArrayBuffer[]`
|
|
34
|
+
* - `PT_MV_LONG` will be casted to `number[]`
|
|
35
|
+
* - `PT_MV_CLSID` will be casted to `ArrayBuffer[]`
|
|
36
|
+
*/
|
|
37
|
+
value: any;
|
|
38
|
+
}
|
package/dist/Property.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PHNodeHeap } from "./PHNodeHeap";
|
|
2
|
+
import { PropertyContext } from "./PropertyContext";
|
|
3
|
+
import { PropertyValueResolver } from "./PropertyValueResolver";
|
|
4
|
+
export declare function getPropertyContext(heap: PHNodeHeap, resolver: PropertyValueResolver): Promise<PropertyContext>;
|
|
@@ -0,0 +1,77 @@
|
|
|
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.getPropertyContext = void 0;
|
|
13
|
+
const BTHeap_1 = require("./BTHeap");
|
|
14
|
+
const bTypePC = 0xBC;
|
|
15
|
+
function copy(array) {
|
|
16
|
+
return array
|
|
17
|
+
.map(it => Object.assign({}, it));
|
|
18
|
+
}
|
|
19
|
+
function getPropertyContext(heap, resolver) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
if (heap.bClientSig !== bTypePC) {
|
|
22
|
+
throw new Error("bClientSig must be bTypePC");
|
|
23
|
+
}
|
|
24
|
+
const reader = heap.getReader();
|
|
25
|
+
function getRecords() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
try {
|
|
28
|
+
const index_data = yield (0, BTHeap_1.getBTHeapReaderFrom)(reader, heap.userRootHnid);
|
|
29
|
+
return yield index_data.list();
|
|
30
|
+
}
|
|
31
|
+
catch (ex) {
|
|
32
|
+
throw new Error(`getRecords failure of hnid ${heap.userRootHnid} of ${heap} --> ${ex}`);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const rawProperties = (yield getRecords())
|
|
37
|
+
.map(record => {
|
|
38
|
+
const keyView = new DataView(record.key);
|
|
39
|
+
const dataView = new DataView(record.data);
|
|
40
|
+
return {
|
|
41
|
+
key: keyView.getUint16(0, true),
|
|
42
|
+
type: dataView.getUint16(0, true),
|
|
43
|
+
value: record.data.slice(2),
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
listRaw() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
return copy(rawProperties);
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
list() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const props = [];
|
|
55
|
+
for (let it of rawProperties) {
|
|
56
|
+
try {
|
|
57
|
+
props.push({
|
|
58
|
+
key: it.key,
|
|
59
|
+
type: it.type,
|
|
60
|
+
value: yield resolver.resolveValueOf(it.key, it.type, it.value, reader),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (ex) {
|
|
64
|
+
throw new Error(`getPropertyContext.list() resolving property`
|
|
65
|
+
+ ` key=0x${it.key.toString(16).padStart(4, '0')}`
|
|
66
|
+
+ ` type=0x${it.type.toString(16).padStart(4, '0')}`
|
|
67
|
+
+ ` of ${heap} failure`
|
|
68
|
+
+ ` --> ${ex}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return props;
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.getPropertyContext = getPropertyContext;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value representation of `PT_OBJECT` type
|
|
3
|
+
*
|
|
4
|
+
* @see [[MS-PST]: PtypObject Properties | Microsoft Docs](https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-pst/49457d57-820e-453d-bbc0-1d192a999814)
|
|
5
|
+
*/
|
|
6
|
+
export declare class PropertyTypeObject {
|
|
7
|
+
private _subNodeId;
|
|
8
|
+
private _size;
|
|
9
|
+
constructor(subNodeId: number, size: number);
|
|
10
|
+
get subNodeId(): number;
|
|
11
|
+
get size(): number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropertyTypeObject = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The value representation of `PT_OBJECT` type
|
|
6
|
+
*
|
|
7
|
+
* @see [[MS-PST]: PtypObject Properties | Microsoft Docs](https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-pst/49457d57-820e-453d-bbc0-1d192a999814)
|
|
8
|
+
*/
|
|
9
|
+
class PropertyTypeObject {
|
|
10
|
+
constructor(subNodeId, size) {
|
|
11
|
+
this._subNodeId = subNodeId;
|
|
12
|
+
this._size = size;
|
|
13
|
+
}
|
|
14
|
+
get subNodeId() {
|
|
15
|
+
return this._subNodeId;
|
|
16
|
+
}
|
|
17
|
+
get size() {
|
|
18
|
+
return this._size;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.PropertyTypeObject = PropertyTypeObject;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PHNodeHeapReader } from "./PHNodeHeapReader";
|
|
2
|
+
import { PropertyValueResolver } from "./PropertyValueResolver";
|
|
3
|
+
export declare class PropertyValueResolverV1 implements PropertyValueResolver {
|
|
4
|
+
private convertAnsiString;
|
|
5
|
+
constructor(convertAnsiString: (array: ArrayBuffer) => Promise<string>);
|
|
6
|
+
resolveValueOf(key: number, type: number, value: ArrayBuffer, heap: PHNodeHeapReader): Promise<any>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
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.PropertyValueResolverV1 = void 0;
|
|
16
|
+
const long_1 = __importDefault(require("long"));
|
|
17
|
+
const PLUtil_1 = require("./PLUtil");
|
|
18
|
+
const PropertyTypeObject_1 = require("./PropertyTypeObject");
|
|
19
|
+
const PSTUtil_class_1 = require("./PSTUtil.class");
|
|
20
|
+
const typeConverters = {};
|
|
21
|
+
const PT_BOOLEAN = 0xB;
|
|
22
|
+
const PT_DOUBLE = 0x5;
|
|
23
|
+
const PT_LONG = 0x3;
|
|
24
|
+
const PT_OBJECT = 0xD;
|
|
25
|
+
const PT_LONGLONG = 0x14;
|
|
26
|
+
const PT_STRING8 = 0x1E;
|
|
27
|
+
const PT_UNICODE = 0x1F;
|
|
28
|
+
const PT_SYSTIME = 0x40;
|
|
29
|
+
const PT_CLSID = 0x48;
|
|
30
|
+
const PT_SHORT = 0x2;
|
|
31
|
+
const PT_FLOAT = 0x4;
|
|
32
|
+
const PT_MV_UNICODE = 0x101F;
|
|
33
|
+
const PT_MV_STRING8 = 0x101E;
|
|
34
|
+
const PT_MV_BINARY = 0x1102;
|
|
35
|
+
const PT_MV_LONG = 0x1003;
|
|
36
|
+
const PT_MV_CLSID = 0x1048;
|
|
37
|
+
typeConverters[PT_SHORT] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
return arg.view.getInt16(0, true);
|
|
39
|
+
});
|
|
40
|
+
typeConverters[PT_FLOAT] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
return arg.view.getFloat32(0, true);
|
|
42
|
+
});
|
|
43
|
+
typeConverters[PT_LONG] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
return arg.view.getInt32(0, true);
|
|
45
|
+
});
|
|
46
|
+
typeConverters[PT_OBJECT] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
const heap = arg.view.getUint32(0, true);
|
|
48
|
+
const bytes = yield arg.resolveHeap(heap);
|
|
49
|
+
if (bytes !== undefined) {
|
|
50
|
+
const view = new DataView(bytes);
|
|
51
|
+
return new PropertyTypeObject_1.PropertyTypeObject(view.getUint32(0, true), view.getUint32(4, true));
|
|
52
|
+
}
|
|
53
|
+
return bytes;
|
|
54
|
+
});
|
|
55
|
+
typeConverters[PT_LONGLONG] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
const bytes = yield arg.getBytes(8);
|
|
57
|
+
if (bytes !== undefined) {
|
|
58
|
+
const view = new DataView(bytes);
|
|
59
|
+
return (0, PLUtil_1.readLong)(view, 0);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
typeConverters[PT_DOUBLE] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
const bytes = yield arg.getBytes(8);
|
|
67
|
+
return (bytes !== undefined)
|
|
68
|
+
? new DataView(bytes).getFloat64(0, true)
|
|
69
|
+
: undefined;
|
|
70
|
+
});
|
|
71
|
+
typeConverters[PT_BOOLEAN] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
+
return arg.view.getUint8(0) !== 0;
|
|
73
|
+
});
|
|
74
|
+
typeConverters[PT_STRING8] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
const heap = arg.view.getUint32(0, true);
|
|
76
|
+
const bytes = yield arg.resolveHeap(heap);
|
|
77
|
+
return (bytes !== undefined)
|
|
78
|
+
? yield arg.convertAnsiString(bytes)
|
|
79
|
+
: undefined;
|
|
80
|
+
});
|
|
81
|
+
typeConverters[PT_UNICODE] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
+
const heap = arg.view.getUint32(0, true);
|
|
83
|
+
const bytes = yield arg.resolveHeap(heap);
|
|
84
|
+
return (bytes !== undefined)
|
|
85
|
+
? Buffer.from(bytes).toString('utf16le').replace(/\0/g, '')
|
|
86
|
+
: undefined;
|
|
87
|
+
// `.replace(/\0/g, '')` is needed to eliminate a trailing null char.
|
|
88
|
+
});
|
|
89
|
+
typeConverters[PT_SYSTIME] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
const bytes = yield arg.getBytes(8);
|
|
91
|
+
if (bytes !== undefined) {
|
|
92
|
+
const view = new DataView(bytes);
|
|
93
|
+
return PSTUtil_class_1.PSTUtil.filetimeToDate(new long_1.default(view.getUint32(4, true)), new long_1.default(view.getUint32(0, true)));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
typeConverters[PT_CLSID] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
const heap = arg.view.getUint32(0, true);
|
|
101
|
+
const bytes = yield arg.resolveHeap(heap);
|
|
102
|
+
return bytes;
|
|
103
|
+
});
|
|
104
|
+
typeConverters[0x0102] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
const heap = arg.view.getUint32(0, true);
|
|
106
|
+
const bytes = yield arg.resolveHeap(heap);
|
|
107
|
+
return bytes;
|
|
108
|
+
});
|
|
109
|
+
typeConverters[PT_MV_UNICODE] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
const heap = arg.view.getUint32(0, true);
|
|
111
|
+
const list = [];
|
|
112
|
+
if (heap !== 0) {
|
|
113
|
+
const bytes = yield arg.resolveHeap(heap);
|
|
114
|
+
if (bytes !== undefined) {
|
|
115
|
+
const view = new DataView(bytes);
|
|
116
|
+
const count = view.getUint32(0, true);
|
|
117
|
+
for (let x = 0; x < count - 1; x++) {
|
|
118
|
+
const from = view.getUint32(4 + 4 * (x), true);
|
|
119
|
+
const to = view.getUint32(4 + 4 * (x + 1), true);
|
|
120
|
+
const elementBytes = bytes.slice(from, to);
|
|
121
|
+
list.push(Buffer.from(elementBytes).toString('utf16le').replace(/\0/g, ''));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return list;
|
|
126
|
+
});
|
|
127
|
+
typeConverters[PT_MV_BINARY] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
const heap = arg.view.getUint32(0, true);
|
|
129
|
+
const list = [];
|
|
130
|
+
if (heap !== 0) {
|
|
131
|
+
const bytes = yield arg.resolveHeap(heap);
|
|
132
|
+
if (bytes !== undefined) {
|
|
133
|
+
const view = new DataView(bytes);
|
|
134
|
+
const count = view.getUint32(0, true);
|
|
135
|
+
for (let x = 0; x < count - 1; x++) {
|
|
136
|
+
const from = view.getUint32(4 + 4 * (x), true);
|
|
137
|
+
const to = view.getUint32(4 + 4 * (x + 1), true);
|
|
138
|
+
const elementBytes = bytes.slice(from, to);
|
|
139
|
+
list.push(elementBytes);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return list;
|
|
144
|
+
});
|
|
145
|
+
typeConverters[PT_MV_LONG] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
146
|
+
const heap = arg.view.getUint32(0, true);
|
|
147
|
+
const list = [];
|
|
148
|
+
if (heap !== 0) {
|
|
149
|
+
const bytes = yield arg.resolveHeap(heap);
|
|
150
|
+
if (bytes !== undefined) {
|
|
151
|
+
const view = new DataView(bytes);
|
|
152
|
+
const count = bytes.byteLength / 4;
|
|
153
|
+
for (let x = 0; x < count; x++) {
|
|
154
|
+
list.push(view.getInt32(4 * x, true));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return list;
|
|
159
|
+
});
|
|
160
|
+
typeConverters[PT_MV_CLSID] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
+
const heap = arg.view.getUint32(0, true);
|
|
162
|
+
const list = [];
|
|
163
|
+
if (heap !== 0) {
|
|
164
|
+
const bytes = yield arg.resolveHeap(heap);
|
|
165
|
+
if (bytes !== undefined) {
|
|
166
|
+
const count = bytes.byteLength / 16;
|
|
167
|
+
for (let x = 0; x < count; x++) {
|
|
168
|
+
const from = 16 * (x);
|
|
169
|
+
const to = 16 * (x + 1);
|
|
170
|
+
const elementBytes = bytes.slice(from, to);
|
|
171
|
+
list.push(elementBytes);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return list;
|
|
176
|
+
});
|
|
177
|
+
typeConverters[PT_MV_STRING8] = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
178
|
+
const heap = arg.view.getUint32(0, true);
|
|
179
|
+
const list = [];
|
|
180
|
+
if (heap !== 0) {
|
|
181
|
+
const bytes = yield arg.resolveHeap(heap);
|
|
182
|
+
if (bytes !== undefined) {
|
|
183
|
+
const view = new DataView(bytes);
|
|
184
|
+
const count = view.getUint32(0, true);
|
|
185
|
+
for (let x = 0; x < count - 1; x++) {
|
|
186
|
+
const from = view.getUint32(4 + 4 * (x), true);
|
|
187
|
+
const to = view.getUint32(4 + 4 * (x + 1), true);
|
|
188
|
+
const elementBytes = bytes.slice(from, to);
|
|
189
|
+
list.push(yield arg.convertAnsiString(elementBytes));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return list;
|
|
194
|
+
});
|
|
195
|
+
function mixIntoOne(array) {
|
|
196
|
+
if (array.length === 0) {
|
|
197
|
+
return new ArrayBuffer(0);
|
|
198
|
+
}
|
|
199
|
+
else if (array.length === 1) {
|
|
200
|
+
return array[0];
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const numBytes = array.reduce((prev, it) => prev + it.byteLength, 0);
|
|
204
|
+
const one = new ArrayBuffer(numBytes);
|
|
205
|
+
const dest = new Uint8Array(one);
|
|
206
|
+
array.reduce((nextPos, source) => {
|
|
207
|
+
dest.set(new Uint8Array(source), nextPos);
|
|
208
|
+
return nextPos + source.byteLength;
|
|
209
|
+
}, 0);
|
|
210
|
+
return one;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
class PropertyValueResolverV1 {
|
|
214
|
+
constructor(convertAnsiString) {
|
|
215
|
+
this.convertAnsiString = convertAnsiString;
|
|
216
|
+
}
|
|
217
|
+
resolveValueOf(key, type, value, heap) {
|
|
218
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
219
|
+
const view = new DataView(value);
|
|
220
|
+
function resolveHeap(hnid) {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
return mixIntoOne(yield heap.getHeapBuffers(hnid));
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
const converter = typeConverters[type];
|
|
226
|
+
if (converter === undefined) {
|
|
227
|
+
throw new Error(`property type 0x${type.toString(16)} is unknown. please define a typeConverter in PropertyValueResolverV1.ts`);
|
|
228
|
+
}
|
|
229
|
+
return yield converter({
|
|
230
|
+
view: view,
|
|
231
|
+
heap: heap,
|
|
232
|
+
getBytes(numBytes) {
|
|
233
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
+
const { byteLength } = value;
|
|
235
|
+
if (byteLength === 4 && byteLength < numBytes) {
|
|
236
|
+
const hnid = view.getUint32(0, true);
|
|
237
|
+
return yield resolveHeap(hnid);
|
|
238
|
+
}
|
|
239
|
+
else if (byteLength !== 4 && numBytes <= byteLength) {
|
|
240
|
+
return value.slice(0, numBytes);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
throw new Error("dont know how to provide buffer");
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
resolveHeap: resolveHeap,
|
|
248
|
+
convertAnsiString: this.convertAnsiString,
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.PropertyValueResolverV1 = PropertyValueResolverV1;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare enum RecurFrequency {
|
|
3
|
+
Daily = 8202,
|
|
4
|
+
Weekly = 8203,
|
|
5
|
+
Monthly = 8204,
|
|
6
|
+
Yearly = 8205
|
|
7
|
+
}
|
|
8
|
+
export declare enum PatternType {
|
|
9
|
+
Day = 0,
|
|
10
|
+
Week = 1,
|
|
11
|
+
Month = 2,
|
|
12
|
+
MonthEnd = 4,
|
|
13
|
+
MonthNth = 3
|
|
14
|
+
}
|
|
15
|
+
export declare enum EndType {
|
|
16
|
+
AfterDate = 8225,
|
|
17
|
+
AfterNOccurrences = 8226,
|
|
18
|
+
NeverEnd = 8227
|
|
19
|
+
}
|
|
20
|
+
export declare enum NthOccurrence {
|
|
21
|
+
First = 1,
|
|
22
|
+
Second = 2,
|
|
23
|
+
Third = 3,
|
|
24
|
+
Fourth = 4,
|
|
25
|
+
Last = 5
|
|
26
|
+
}
|
|
27
|
+
export declare type WeekSpecific = boolean[] & {
|
|
28
|
+
length: 7;
|
|
29
|
+
};
|
|
30
|
+
export declare type MonthNthSpecific = {
|
|
31
|
+
weekdays: WeekSpecific;
|
|
32
|
+
nth: NthOccurrence;
|
|
33
|
+
};
|
|
34
|
+
export declare class RecurrencePattern {
|
|
35
|
+
private buffer;
|
|
36
|
+
recurFrequency: RecurFrequency;
|
|
37
|
+
patternType: PatternType;
|
|
38
|
+
firstDateTime: Date;
|
|
39
|
+
period: number;
|
|
40
|
+
patternTypeSpecific: number | WeekSpecific | MonthNthSpecific | null;
|
|
41
|
+
endType: EndType;
|
|
42
|
+
occurrenceCount: number;
|
|
43
|
+
firstDOW: number;
|
|
44
|
+
startDate: Date;
|
|
45
|
+
endDate: Date;
|
|
46
|
+
constructor(buffer: Buffer);
|
|
47
|
+
toJSON(): any;
|
|
48
|
+
private readInt;
|
|
49
|
+
private readPatternTypeSpecific;
|
|
50
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecurrencePattern = exports.NthOccurrence = exports.EndType = exports.PatternType = exports.RecurFrequency = void 0;
|
|
4
|
+
const OFFSETS = {
|
|
5
|
+
RecurFrequency: 4,
|
|
6
|
+
PatternType: 6,
|
|
7
|
+
FirstDateTime: 10,
|
|
8
|
+
Period: 14,
|
|
9
|
+
PatternTypeSpecific: 22,
|
|
10
|
+
EndType: 22,
|
|
11
|
+
OccurrenceCount: 26,
|
|
12
|
+
FirstDOW: 30,
|
|
13
|
+
StartDate: -8,
|
|
14
|
+
EndDate: -4,
|
|
15
|
+
};
|
|
16
|
+
var RecurFrequency;
|
|
17
|
+
(function (RecurFrequency) {
|
|
18
|
+
RecurFrequency[RecurFrequency["Daily"] = 8202] = "Daily";
|
|
19
|
+
RecurFrequency[RecurFrequency["Weekly"] = 8203] = "Weekly";
|
|
20
|
+
RecurFrequency[RecurFrequency["Monthly"] = 8204] = "Monthly";
|
|
21
|
+
RecurFrequency[RecurFrequency["Yearly"] = 8205] = "Yearly";
|
|
22
|
+
})(RecurFrequency = exports.RecurFrequency || (exports.RecurFrequency = {}));
|
|
23
|
+
var PatternType;
|
|
24
|
+
(function (PatternType) {
|
|
25
|
+
PatternType[PatternType["Day"] = 0] = "Day";
|
|
26
|
+
PatternType[PatternType["Week"] = 1] = "Week";
|
|
27
|
+
PatternType[PatternType["Month"] = 2] = "Month";
|
|
28
|
+
PatternType[PatternType["MonthEnd"] = 4] = "MonthEnd";
|
|
29
|
+
PatternType[PatternType["MonthNth"] = 3] = "MonthNth";
|
|
30
|
+
})(PatternType = exports.PatternType || (exports.PatternType = {}));
|
|
31
|
+
var EndType;
|
|
32
|
+
(function (EndType) {
|
|
33
|
+
EndType[EndType["AfterDate"] = 8225] = "AfterDate";
|
|
34
|
+
EndType[EndType["AfterNOccurrences"] = 8226] = "AfterNOccurrences";
|
|
35
|
+
EndType[EndType["NeverEnd"] = 8227] = "NeverEnd";
|
|
36
|
+
})(EndType = exports.EndType || (exports.EndType = {}));
|
|
37
|
+
var NthOccurrence;
|
|
38
|
+
(function (NthOccurrence) {
|
|
39
|
+
NthOccurrence[NthOccurrence["First"] = 1] = "First";
|
|
40
|
+
NthOccurrence[NthOccurrence["Second"] = 2] = "Second";
|
|
41
|
+
NthOccurrence[NthOccurrence["Third"] = 3] = "Third";
|
|
42
|
+
NthOccurrence[NthOccurrence["Fourth"] = 4] = "Fourth";
|
|
43
|
+
NthOccurrence[NthOccurrence["Last"] = 5] = "Last";
|
|
44
|
+
})(NthOccurrence = exports.NthOccurrence || (exports.NthOccurrence = {}));
|
|
45
|
+
class RecurrencePattern {
|
|
46
|
+
constructor(buffer) {
|
|
47
|
+
this.buffer = buffer;
|
|
48
|
+
const bufferEnd = buffer.length;
|
|
49
|
+
let patternTypeOffset = 0;
|
|
50
|
+
this.recurFrequency = this.readInt(OFFSETS.RecurFrequency, 1);
|
|
51
|
+
this.patternType = this.readInt(OFFSETS.PatternType, 1);
|
|
52
|
+
this.firstDateTime = winToJsDate(this.readInt(OFFSETS.FirstDateTime, 2));
|
|
53
|
+
this.period = this.readInt(OFFSETS.Period, 2);
|
|
54
|
+
this.patternTypeSpecific = this.readPatternTypeSpecific(this.patternType);
|
|
55
|
+
switch (this.patternType) {
|
|
56
|
+
case PatternType.Week:
|
|
57
|
+
case PatternType.Month:
|
|
58
|
+
case PatternType.MonthEnd:
|
|
59
|
+
patternTypeOffset = 4;
|
|
60
|
+
break;
|
|
61
|
+
case PatternType.MonthNth:
|
|
62
|
+
patternTypeOffset = 8;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
this.endType = this.readInt(OFFSETS.EndType + patternTypeOffset, 2);
|
|
66
|
+
this.occurrenceCount = this.readInt(OFFSETS.OccurrenceCount + patternTypeOffset, 2);
|
|
67
|
+
this.firstDOW = this.readInt(OFFSETS.FirstDOW + patternTypeOffset, 2);
|
|
68
|
+
this.startDate = winToJsDate(this.readInt(bufferEnd + OFFSETS.StartDate, 2));
|
|
69
|
+
this.endDate = winToJsDate(this.readInt(bufferEnd + OFFSETS.EndDate, 2));
|
|
70
|
+
}
|
|
71
|
+
toJSON() {
|
|
72
|
+
return {
|
|
73
|
+
recurFrequency: RecurFrequency[this.recurFrequency],
|
|
74
|
+
patternType: PatternType[this.patternType],
|
|
75
|
+
firstDateTime: this.firstDateTime,
|
|
76
|
+
period: this.period,
|
|
77
|
+
patternTypeSpecific: this.patternTypeSpecific,
|
|
78
|
+
endType: EndType[this.endType],
|
|
79
|
+
occurrenceCount: this.occurrenceCount,
|
|
80
|
+
firstDOW: this.firstDOW,
|
|
81
|
+
startDate: this.startDate,
|
|
82
|
+
endDate: this.endDate,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
readInt(offset, size) {
|
|
86
|
+
switch (size) {
|
|
87
|
+
case 1:
|
|
88
|
+
return this.buffer.readInt16LE(offset);
|
|
89
|
+
case 2:
|
|
90
|
+
return this.buffer.readInt32LE(offset);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
readPatternTypeSpecific(type) {
|
|
94
|
+
switch (type) {
|
|
95
|
+
case PatternType.Day:
|
|
96
|
+
return null;
|
|
97
|
+
case PatternType.Week:
|
|
98
|
+
return readWeekByte(this.buffer.readInt8(OFFSETS.PatternTypeSpecific));
|
|
99
|
+
case PatternType.Month:
|
|
100
|
+
case PatternType.MonthEnd:
|
|
101
|
+
return this.readInt(OFFSETS.PatternTypeSpecific, 2);
|
|
102
|
+
case PatternType.MonthNth:
|
|
103
|
+
return {
|
|
104
|
+
weekdays: readWeekByte(this.buffer.readInt8(OFFSETS.PatternTypeSpecific)),
|
|
105
|
+
nth: this.readInt(OFFSETS.PatternTypeSpecific + 4, 2),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.RecurrencePattern = RecurrencePattern;
|
|
111
|
+
function winToJsDate(dateInt) {
|
|
112
|
+
return new Date(dateInt * 60 * 1000 - 1.16444736e13); // subtract milliseconds between 1601-01-01 and 1970-01-01
|
|
113
|
+
}
|
|
114
|
+
function readWeekByte(byte) {
|
|
115
|
+
const weekArr = [];
|
|
116
|
+
for (let i = 0; i < 7; ++i) {
|
|
117
|
+
weekArr.push(Boolean(byte & (1 << i)));
|
|
118
|
+
}
|
|
119
|
+
return weekArr;
|
|
120
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PropertyFinder } from "./PAUtil";
|
|
2
|
+
import { PLNode } from "./PLNode";
|
|
3
|
+
import { PLSubNode } from "./PLSubNode";
|
|
4
|
+
import { PropertyValueResolver } from "./PropertyValueResolver";
|
|
5
|
+
import { PSTFolder } from "./PSTFolder.class";
|
|
6
|
+
import { PSTMessage } from "./PSTMessage.class";
|
|
7
|
+
export interface RootProvider {
|
|
8
|
+
resolver: PropertyValueResolver;
|
|
9
|
+
getNameToIdMapItem(key: number, idx: number): number;
|
|
10
|
+
getItemOf(node: PLNode, subNode: PLSubNode, propertyFinder: PropertyFinder | undefined): Promise<PSTMessage>;
|
|
11
|
+
getFolderOf(node: PLNode): Promise<PSTFolder>;
|
|
12
|
+
}
|