@sswroom/sswr 1.6.12 → 1.6.14
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/Changelog +10 -0
- package/certutil.d.ts +1 -1
- package/certutil.js +645 -23
- package/crypto.d.ts +27 -0
- package/crypto.js +149 -0
- package/data.d.ts +29 -1
- package/data.js +673 -72
- package/exporter/XLSXExporter.d.ts +40 -0
- package/exporter/XLSXExporter.js +1960 -0
- package/hash.d.ts +25 -0
- package/hash.js +257 -2
- package/osm.js +41 -2
- package/package.json +4 -1
- package/parser.js +46 -0
- package/spreadsheet.d.ts +574 -0
- package/spreadsheet.js +2227 -0
- package/text.d.ts +19 -0
- package/text.js +25 -0
- package/zip.d.ts +57 -0
- package/zip.js +474 -0
package/crypto.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export abstract class ICrypto
|
|
2
|
+
{
|
|
3
|
+
abstract encrypt(inBuff: ArrayBuffer): Promise<ArrayBuffer | null>;
|
|
4
|
+
abstract decrypt(inBuff: ArrayBuffer): Promise<ArrayBuffer | null>;
|
|
5
|
+
|
|
6
|
+
abstract getEncBlockSize(): number;
|
|
7
|
+
abstract getDecBlockSize(): number;
|
|
8
|
+
|
|
9
|
+
static keyToBuffer(key: string, nBytes: number): ArrayBuffer;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class AES256GCM extends ICrypto
|
|
13
|
+
{
|
|
14
|
+
constructor(key: ArrayBuffer, iv: ArrayBuffer);
|
|
15
|
+
|
|
16
|
+
encrypt(inBuff: ArrayBuffer): Promise<ArrayBuffer | null>;
|
|
17
|
+
decrypt(inBuff: ArrayBuffer): Promise<ArrayBuffer | null>;
|
|
18
|
+
|
|
19
|
+
getEncBlockSize(): number;
|
|
20
|
+
getDecBlockSize(): number;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 12 byte length
|
|
24
|
+
* @param iv Initial Vector
|
|
25
|
+
*/
|
|
26
|
+
setIV(iv: ArrayBuffer): void;
|
|
27
|
+
}
|
package/crypto.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
export class ICrypto
|
|
2
|
+
{
|
|
3
|
+
/**
|
|
4
|
+
* @param {ArrayBuffer} inBuff
|
|
5
|
+
* @returns {Promise<ArrayBuffer|null>}
|
|
6
|
+
*/
|
|
7
|
+
async encrypt(inBuff)
|
|
8
|
+
{
|
|
9
|
+
throw new Error("ICrypto.encrypt must be inherited");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {ArrayBuffer} inBuff
|
|
14
|
+
* @returns {Promise<ArrayBuffer|null>}
|
|
15
|
+
*/
|
|
16
|
+
async decrypt(inBuff)
|
|
17
|
+
{
|
|
18
|
+
throw new Error("ICrypto.decrypt must be inherited");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @returns {number}
|
|
23
|
+
*/
|
|
24
|
+
getEncBlockSize() /**
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
throw new Error("ICrypto.getEncBlockSize must be inherited");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @returns {number}
|
|
34
|
+
*/
|
|
35
|
+
getDecBlockSize()
|
|
36
|
+
{
|
|
37
|
+
throw new Error("ICrypto.getDecBlockSize must be inherited");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} key
|
|
43
|
+
* @param {number} nBytes
|
|
44
|
+
* @returns {Uint8Array}
|
|
45
|
+
*/
|
|
46
|
+
static keyToBuffer(key, nBytes)
|
|
47
|
+
{
|
|
48
|
+
let enc = new TextEncoder();
|
|
49
|
+
let arr = enc.encode(key);
|
|
50
|
+
if (arr.length >= nBytes)
|
|
51
|
+
{
|
|
52
|
+
return arr.subarray(0, nBytes);
|
|
53
|
+
}
|
|
54
|
+
else
|
|
55
|
+
{
|
|
56
|
+
let ret = new Uint8Array(nBytes);
|
|
57
|
+
let i = 0;
|
|
58
|
+
let j = arr.length;
|
|
59
|
+
let k = 0;
|
|
60
|
+
while (i < nBytes)
|
|
61
|
+
{
|
|
62
|
+
if (k >= j)
|
|
63
|
+
{
|
|
64
|
+
ret[i] = 0x7f;
|
|
65
|
+
k = 0;
|
|
66
|
+
}
|
|
67
|
+
else
|
|
68
|
+
{
|
|
69
|
+
ret[i] = arr[k];
|
|
70
|
+
k++;
|
|
71
|
+
}
|
|
72
|
+
i++;
|
|
73
|
+
}
|
|
74
|
+
return ret;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class AES256GCM extends ICrypto
|
|
80
|
+
{
|
|
81
|
+
/**
|
|
82
|
+
* @param {ArrayBuffer} key
|
|
83
|
+
* @param {ArrayBuffer} iv
|
|
84
|
+
*/
|
|
85
|
+
constructor(key, iv)
|
|
86
|
+
{
|
|
87
|
+
super();
|
|
88
|
+
if (key.byteLength != 32)
|
|
89
|
+
{
|
|
90
|
+
throw new Error("key must be 32 bytes long");
|
|
91
|
+
}
|
|
92
|
+
this.key = key;
|
|
93
|
+
this.setIV(iv);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {ArrayBuffer} inBuff
|
|
98
|
+
*/
|
|
99
|
+
async encrypt(inBuff)
|
|
100
|
+
{
|
|
101
|
+
if (window.crypto.subtle == null)
|
|
102
|
+
{
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
let key = await window.crypto.subtle.importKey("raw", this.key, {name: "AES-GCM"}, false, ["encrypt", "decrypt"]);
|
|
106
|
+
return await window.crypto.subtle.encrypt( {
|
|
107
|
+
name: "AES-GCM",
|
|
108
|
+
iv: this.iv
|
|
109
|
+
}, key, inBuff);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param {ArrayBuffer} inBuff
|
|
114
|
+
*/
|
|
115
|
+
async decrypt(inBuff)
|
|
116
|
+
{
|
|
117
|
+
if (window.crypto.subtle == null)
|
|
118
|
+
{
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
let key = await window.crypto.subtle.importKey("raw", this.key, {name: "AES-GCM"}, false, ["encrypt", "decrypt"]);
|
|
122
|
+
return await window.crypto.subtle.decrypt( {
|
|
123
|
+
name: "AES-GCM",
|
|
124
|
+
iv: this.iv
|
|
125
|
+
}, key, inBuff);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
getEncBlockSize()
|
|
129
|
+
{
|
|
130
|
+
return 16;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getDecBlockSize()
|
|
134
|
+
{
|
|
135
|
+
return 16;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @param {ArrayBuffer} iv
|
|
140
|
+
*/
|
|
141
|
+
setIV(iv)
|
|
142
|
+
{
|
|
143
|
+
if (iv.byteLength != 12)
|
|
144
|
+
{
|
|
145
|
+
throw new Error("iv must be 12 bytes long");
|
|
146
|
+
}
|
|
147
|
+
this.iv = iv;
|
|
148
|
+
}
|
|
149
|
+
}
|
package/data.d.ts
CHANGED
|
@@ -83,6 +83,7 @@ export class DateTimeUtil
|
|
|
83
83
|
static parseMonthStr(month: string): number;
|
|
84
84
|
static dayInMonth(year: number, month: number): number;
|
|
85
85
|
static getLocalTzQhr(): number;
|
|
86
|
+
static secs2FILETIME(secs: bigint, nanosec: number): bigint;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
export class Duration
|
|
@@ -156,6 +157,7 @@ export class TimeInstant
|
|
|
156
157
|
toEpochSec(): bigint;
|
|
157
158
|
toEpochMS(): bigint;
|
|
158
159
|
toEpochNS(): bigint;
|
|
160
|
+
toFILETIME(): bigint;
|
|
159
161
|
static fromDotNetTicks(ticks: bigint | number): TimeInstant;
|
|
160
162
|
}
|
|
161
163
|
|
|
@@ -164,7 +166,7 @@ export class Timestamp {
|
|
|
164
166
|
tzQhr: number;
|
|
165
167
|
|
|
166
168
|
constructor(inst: TimeInstant, tzQhr?: number);
|
|
167
|
-
static fromTicks(ticks: number |
|
|
169
|
+
static fromTicks(ticks: number | bigint, tzQhr?: number): Timestamp;
|
|
168
170
|
static fromStr(str: string, defTzQhr?: number): Timestamp | null;
|
|
169
171
|
static now(): Timestamp;
|
|
170
172
|
static utcNow(): Timestamp;
|
|
@@ -203,6 +205,9 @@ export class Timestamp {
|
|
|
203
205
|
toEpochSec(): bigint;
|
|
204
206
|
toEpochMS(): bigint;
|
|
205
207
|
toEpochNS(): bigint;
|
|
208
|
+
toMSDOSDate(): number;
|
|
209
|
+
toMSDOSTime(): number;
|
|
210
|
+
toFILETIME(): bigint;
|
|
206
211
|
toString(pattern?: string): string;
|
|
207
212
|
toStringISO8601(): string;
|
|
208
213
|
toStringNoZone(): string;
|
|
@@ -251,6 +256,29 @@ export class ByteReader
|
|
|
251
256
|
isASCIIText(ofst: number, len: number): boolean;
|
|
252
257
|
}
|
|
253
258
|
|
|
259
|
+
export class ByteBuilder
|
|
260
|
+
{
|
|
261
|
+
tmpBuff: Uint8Array;
|
|
262
|
+
view: DataView;
|
|
263
|
+
buff: number[];
|
|
264
|
+
|
|
265
|
+
constructor();
|
|
266
|
+
writeInt8(ofst: number, value: number): void;
|
|
267
|
+
writeInt16(ofst: number, value: number, lsb: boolean): void;
|
|
268
|
+
writeInt24(ofst: number, value: number, lsb: boolean): void;
|
|
269
|
+
writeInt32(ofst: number, value: number, lsb: boolean): void;
|
|
270
|
+
writeInt64(ofst: number, value: bigint, lsb: boolean): void;
|
|
271
|
+
writeFloat64(ofst: number, value: number, lsb: boolean): void;
|
|
272
|
+
/** @returns number of bytes written */
|
|
273
|
+
writeUTF8(ofst: number, value: string): number;
|
|
274
|
+
/** @returns number of bytes written */
|
|
275
|
+
writeUTF16(ofst: number, value: string, lsb: boolean): number;
|
|
276
|
+
writeUInt8Array(ofst: number, buff: Uint8Array): void;
|
|
277
|
+
build(): Uint8Array;
|
|
278
|
+
|
|
279
|
+
allocBuff(ofst: number, len: number): void;
|
|
280
|
+
}
|
|
281
|
+
|
|
254
282
|
export abstract class ParsedObject
|
|
255
283
|
{
|
|
256
284
|
sourceName: string;
|