@sswroom/sswr 1.6.4 → 1.6.5

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/certutil.d.ts CHANGED
@@ -48,7 +48,7 @@ export enum RuleCond
48
48
  RepeatIfTypeIs,
49
49
  LastOIDAndTypeIs,
50
50
  AllNotMatch
51
- };
51
+ }
52
52
 
53
53
  declare class PDULenInfo
54
54
  {
@@ -88,7 +88,7 @@ export class ASN1Util
88
88
  static pduDSizeEnd(reader: data.ByteReader, startOfst: number, endOfst: number): number | null;
89
89
  static pduGetItem(reader: data.ByteReader, startOfst: number, endOfst: number, path: string): PDUInfo;
90
90
  static pduGetItemType(reader: data.ByteReader, startOfst: number, endOfst: number, path: string): ASN1ItemType;
91
- static pduCountItem(reader: data.ByteReader, startOfst: number, endOfst: number, path?: string): number;
91
+ static pduCountItem(reader: data.ByteReader, startOfst: number, endOfst: number, path?: string | null): number;
92
92
  static pduIsValid(reader: data.ByteReader, startOfst: number, endOfst: number): boolean;
93
93
  // static void PDUAnalyse(NotNullPtr<IO::FileAnalyse::FrameDetail> frame, Data::ByteArrayR buff, UOSInt pduOfst, UOSInt pduEndOfst, Net::ASN1Names *names);
94
94
 
@@ -160,19 +160,19 @@ export class ASN1Names
160
160
  setPFX(): ASN1Names; //PKCS-12
161
161
  }
162
162
 
163
- class General
163
+ declare class General
164
164
  {
165
165
  static pbeParam(names: ASN1Names): void;
166
166
  static extendedValidationCertificates(names: ASN1Names): void;
167
167
  static attributeOutlookExpress(names: ASN1Names): void;
168
168
  }
169
169
 
170
- class InformationFramework
170
+ declare class InformationFramework
171
171
  {
172
172
  static attributeCont(names: ASN1Names): void;
173
173
  }
174
174
 
175
- class PKCS1
175
+ declare class PKCS1
176
176
  {
177
177
  static rsaPublicKey(names: ASN1Names): void;
178
178
  static rsaPublicKeyCont(names: ASN1Names): void;
@@ -183,7 +183,7 @@ class PKCS1
183
183
  static digestInfoCont(names: ASN1Names): void;
184
184
  }
185
185
 
186
- class PKCS7
186
+ declare class PKCS7
187
187
  {
188
188
  static addContentInfo(names: ASN1Names, name: string): void;
189
189
  static contentInfo(names: ASN1Names): void;
@@ -214,7 +214,7 @@ class PKCS7
214
214
  static authenticatedData(names: ASN1Names): void;
215
215
  }
216
216
 
217
- class PKCS8
217
+ declare class PKCS8
218
218
  {
219
219
  static privateKeyInfo(names: ASN1Names): void;
220
220
  static privateKeyInfoCont(names: ASN1Names): void;
@@ -222,7 +222,7 @@ class PKCS8
222
222
  static encryptedPrivateKeyInfoCont(names: ASN1Names): void;
223
223
  }
224
224
 
225
- class PKCS9
225
+ declare class PKCS9
226
226
  {
227
227
  static attributeContentType(names: ASN1Names): void;
228
228
  static attributeMessageDigest(names: ASN1Names): void;
@@ -234,7 +234,7 @@ class PKCS9
234
234
  static smimeCapabilityCont(names: ASN1Names): void;
235
235
  }
236
236
 
237
- class PKCS10
237
+ declare class PKCS10
238
238
  {
239
239
  static addCertificationRequestInfo(names: ASN1Names, name: string): void;
240
240
  static certificationRequestInfoCont(names: ASN1Names): void;
@@ -243,7 +243,7 @@ class PKCS10
243
243
  static certificationRequestCont(names: ASN1Names): void;
244
244
  }
245
245
 
246
- class PKCS12
246
+ declare class PKCS12
247
247
  {
248
248
  static pfx(names: ASN1Names): void;
249
249
  static pfxCont(names: ASN1Names): void;
@@ -272,7 +272,7 @@ class PKCS12
272
272
  static pkcs12Attributes(names: ASN1Names): void;
273
273
  }
274
274
 
275
- class PKIX1Explicit88
275
+ declare class PKIX1Explicit88
276
276
  {
277
277
  static addAttributeTypeAndValue(names: ASN1Names, name: string): void;
278
278
  static attributeTypeAndValueCont(names: ASN1Names): void;
package/certutil.js CHANGED
@@ -489,7 +489,7 @@ export class ASN1Util
489
489
  case 0x1E:
490
490
  sb = ["\t".repeat(level)];
491
491
  if (name) sb.push(name+" ")
492
- if (len & 1)
492
+ if (len.pduLen & 1)
493
493
  {
494
494
  sb.push("BMPString (");
495
495
  sb.push(text.u8Arr2Hex(new Uint8Array(reader.getArrayBuffer(len.nextOfst, len.pduLen)), ' ', null));
@@ -1032,6 +1032,10 @@ export class ASN1Util
1032
1032
  return sb.join(".");
1033
1033
  }
1034
1034
 
1035
+ /**
1036
+ * @param {string} oidText
1037
+ * @returns {number[] | null}
1038
+ */
1035
1039
  static oidText2PDU(oidText)
1036
1040
  {
1037
1041
  let sarr = oidText.split(".");
@@ -1226,6 +1230,10 @@ class RuleContainer
1226
1230
  constructor()
1227
1231
  {
1228
1232
  this.rules = [];
1233
+ /**
1234
+ * @type {RuleContainer | null}
1235
+ */
1236
+ this.parent = null;
1229
1237
  }
1230
1238
  }
1231
1239
 
@@ -2103,11 +2111,6 @@ class PKIX1Explicit88
2103
2111
  names.typeIs(ASN1ItemType.SEQUENCE).container(name, PKIX1Explicit88.rdnSequenceCont);
2104
2112
  }
2105
2113
 
2106
- static name(names)
2107
- {
2108
- names.typeIs(ASN1ItemType.SEQUENCE).container("Name", PKIX1Explicit88.rdnSequenceCont);
2109
- }
2110
-
2111
2114
  static rdnSequenceCont(names)
2112
2115
  {
2113
2116
  names.repeatIfTypeIs(ASN1ItemType.SET).container("rdnSequence", PKIX1Explicit88.relativeDistinguishedNameCont);
@@ -2562,6 +2565,8 @@ export class ASN1PDUBuilder
2562
2565
  appendOIDString(oidStr)
2563
2566
  {
2564
2567
  let buff = ASN1Util.oidText2PDU(oidStr);
2568
+ if (buff == null)
2569
+ throw new Error("\""+oidStr+"\" is not valid oid string");
2565
2570
  this.appendOID(new Uint8Array(buff).buffer);
2566
2571
  }
2567
2572
 
package/data.d.ts CHANGED
@@ -24,7 +24,7 @@ export function arrayBuffer2Base64(buff: ArrayBuffer): string;
24
24
  export function arrayBufferEquals(buff1: ArrayBuffer, buff2: ArrayBuffer): boolean;
25
25
  export function compare(a: any, b: any): number;
26
26
  export function sort(arr: object[], compareFunc?: (val1: object, val2: object) => number, firstIndex?: number, lastIndex?: number): void;
27
- export function mergeOptions(options: object | null, defOptions: object): object;
27
+ export function mergeOptions<OptionType>(options: object | null, defOptions: OptionType): OptionType;
28
28
  export function readUInt16(arr: Uint8Array, index: number): number;
29
29
  export function readMUInt16(arr: Uint8Array, index: number): number;
30
30
  export function readUInt24(arr: Uint8Array, index: number): number;
@@ -75,9 +75,11 @@ export class DateTimeUtil
75
75
  static ticks2Weekday(ticks: number, tzQhr: number): Weekday;
76
76
  static toString(tval: TimeValue, pattern: string): string;
77
77
  static string2TimeValue(dateStr: string, tzQhr?: number): TimeValue;
78
+ static timeValueFromYMDHMS(ymdhms: number | bigint): TimeValue | null;
78
79
  static isYearLeap(year: number): boolean;
79
80
  static parseYearStr(year: string): number;
80
81
  static parseMonthStr(month: string): number;
82
+ static dayInMonth(year: number, month: number): number;
81
83
  static getLocalTzQhr(): number;
82
84
  }
83
85
 
@@ -152,6 +154,7 @@ export class TimeInstant
152
154
  toEpochSec(): bigint;
153
155
  toEpochMS(): bigint;
154
156
  toEpochNS(): bigint;
157
+ static fromDotNetTicks(ticks: bigint | number): TimeInstant;
155
158
  }
156
159
 
157
160
  export class Timestamp {
package/data.js CHANGED
@@ -549,7 +549,7 @@ export class DateTimeUtil
549
549
 
550
550
  static timeValue2Ticks(t)
551
551
  {
552
- return DateTimeUtil.timeValue2Secs(t) * 1000n + Math.floor(t.nanosec / 1000000);
552
+ return DateTimeUtil.timeValue2Secs(t) * 1000n + BigInt(Math.floor(t.nanosec / 1000000));
553
553
  }
554
554
 
555
555
  static ticks2TimeValue(ticks, tzQhr)
@@ -813,7 +813,7 @@ export class DateTimeUtil
813
813
  secs -= totalDays * 86400n;
814
814
  while (secs < 0)
815
815
  {
816
- totalDays -= 1;
816
+ totalDays -= 1n;
817
817
  secs += 86400n;
818
818
  }
819
819
  minutes = Number(secs % 86400n);
@@ -1088,12 +1088,12 @@ export class DateTimeUtil
1088
1088
  }
1089
1089
  else if (pattern[3] != 'M')
1090
1090
  {
1091
- output.push(data.DateTimeUtil.monString[tval.month - 1]);
1091
+ output.push(DateTimeUtil.monString[tval.month - 1]);
1092
1092
  i += 3;
1093
1093
  }
1094
1094
  else
1095
1095
  {
1096
- output.push(data.DateTimeUtil.monthString[tval.month - 1]);
1096
+ output.push(DateTimeUtil.monthString[tval.month - 1]);
1097
1097
  i += 4;
1098
1098
  while (i < pattern.length && pattern.charAt(i) == 'M')
1099
1099
  i++;
@@ -1278,7 +1278,7 @@ export class DateTimeUtil
1278
1278
  tval.tzQhr = min / 15;
1279
1279
  }
1280
1280
  }
1281
- else if (tzlen == 2)
1281
+ else if (tz.length == 2)
1282
1282
  {
1283
1283
  if (c == '-')
1284
1284
  {
@@ -1499,6 +1499,40 @@ export class DateTimeUtil
1499
1499
  return tval;
1500
1500
  }
1501
1501
 
1502
+ static timeValueFromYMDHMS(prmymdhms)
1503
+ {
1504
+ let ymdhms = BigInt(prmymdhms);
1505
+ if (ymdhms < 0n)
1506
+ return null;
1507
+ let tval = new TimeValue();
1508
+ tval.second = Number(ymdhms % 100n);
1509
+ ymdhms = ymdhms / 100n;
1510
+ if (tval.second >= 60)
1511
+ return null;
1512
+ tval.minute = Number(ymdhms % 100n);
1513
+ ymdhms = ymdhms / 100n;
1514
+ if (tval.minute >= 60)
1515
+ return null;
1516
+ tval.hour = Number(ymdhms % 100n);
1517
+ ymdhms = ymdhms / 100n;
1518
+ if (tval.hour >= 24)
1519
+ return null;
1520
+ tval.day = Number(ymdhms % 100n);
1521
+ ymdhms = ymdhms / 100n;
1522
+ if (tval.day == 0 || tval.day > 31)
1523
+ return null;
1524
+ tval.month = Number(ymdhms % 100n);
1525
+ ymdhms = ymdhms / 100n;
1526
+ if (tval.month == 0 || tval.month > 12)
1527
+ return null;
1528
+ if (ymdhms <= 0n || ymdhms > 65535n)
1529
+ return null;
1530
+ tval.year = Number(ymdhms);
1531
+ if (tval.day > DateTimeUtil.dayInMonth(tval.year, tval.month))
1532
+ return null;
1533
+ return tval;
1534
+ }
1535
+
1502
1536
  static isYearLeap(year)
1503
1537
  {
1504
1538
  return ((year & 3) == 0) && ((year % 100) != 0 || (year % 400) == 0);
@@ -1568,6 +1602,52 @@ export class DateTimeUtil
1568
1602
  return 0;
1569
1603
  }
1570
1604
 
1605
+ static dayInMonth(year, month)
1606
+ {
1607
+ while (month < 1)
1608
+ {
1609
+ month = (month + 12);
1610
+ year--;
1611
+ }
1612
+ while (month > 12)
1613
+ {
1614
+ month = (month - 12);
1615
+ year++;
1616
+ }
1617
+ switch (month)
1618
+ {
1619
+ case 12:
1620
+ return 31;
1621
+ case 11:
1622
+ return 30;
1623
+ case 10:
1624
+ return 31;
1625
+ case 9:
1626
+ return 30;
1627
+ case 8:
1628
+ return 31;
1629
+ case 7:
1630
+ return 31;
1631
+ case 6:
1632
+ return 30;
1633
+ case 5:
1634
+ return 31;
1635
+ case 4:
1636
+ return 30;
1637
+ case 3:
1638
+ return 31;
1639
+ case 2:
1640
+ if (((year % 4) == 0 && (year % 100) != 0) || (year % 400) == 0)
1641
+ return 29;
1642
+ else
1643
+ return 28;
1644
+ case 1:
1645
+ return 31;
1646
+ default:
1647
+ return 0;
1648
+ }
1649
+ }
1650
+
1571
1651
  static getLocalTzQhr()
1572
1652
  {
1573
1653
  return new Date().getTimezoneOffset() / -15;
@@ -1625,27 +1705,27 @@ export class Duration
1625
1705
 
1626
1706
  getNS()
1627
1707
  {
1628
- return this.ns;
1708
+ return this.nanosec;
1629
1709
  }
1630
1710
 
1631
1711
  getTotalMS()
1632
1712
  {
1633
- return Number(this.seconds) * 1000 + this.ns / 1000000n;
1713
+ return Number(this.seconds) * 1000 + this.nanosec / 1000000;
1634
1714
  }
1635
1715
 
1636
1716
  getTotalSec()
1637
1717
  {
1638
- return Number(this.seconds) + (this.ns * 0.000000001);
1718
+ return Number(this.seconds) + (this.nanosec * 0.000000001);
1639
1719
  }
1640
1720
 
1641
1721
  notZero()
1642
1722
  {
1643
- return this.seconds != 0 || this.ns != 0;
1723
+ return this.seconds != 0n || this.nanosec != 0;
1644
1724
  }
1645
1725
 
1646
1726
  isZero()
1647
1727
  {
1648
- return this.seconds == 0 && this.ns == 0;
1728
+ return this.seconds == 0n && this.nanosec == 0;
1649
1729
  }
1650
1730
 
1651
1731
  toString()
@@ -1728,7 +1808,7 @@ export class LocalDate
1728
1808
  this.dateVal = year;
1729
1809
  }
1730
1810
  }
1731
- else if (t == "DateValue" || t == "TimeValue")
1811
+ else if (year instanceof DateValue)
1732
1812
  {
1733
1813
  this.dateVal = DateTimeUtil.dateValue2TotalDays(year);
1734
1814
  }
@@ -1874,7 +1954,7 @@ export class TimeInstant
1874
1954
  let days = Math.floor(variTime);
1875
1955
  let ds = (variTime - days);
1876
1956
  let s = Math.floor(ds * 86400);
1877
- return new TimeInstant((days - 25569n) * 86400000n + Math.floor(ds * 86400000n), ((ds * 86400n - s) * 1000000000n));
1957
+ return new TimeInstant(BigInt(days - 25569) * 86400000n + BigInt(Math.floor(ds * 86400000)), ((ds * 86400 - s) * 1000000000));
1878
1958
  }
1879
1959
 
1880
1960
  static fromTicks(ticks)
@@ -1912,7 +1992,7 @@ export class TimeInstant
1912
1992
 
1913
1993
  addMS(val)
1914
1994
  {
1915
- let newSec = this.sec + Math.floor(val / 1000);
1995
+ let newSec = this.sec + BigInt(Math.floor(val / 1000));
1916
1996
  val = (val % 1000) * 1000000 + this.nanosec;
1917
1997
  while (val > 1000000000)
1918
1998
  {
@@ -1924,7 +2004,7 @@ export class TimeInstant
1924
2004
 
1925
2005
  addNS(val)
1926
2006
  {
1927
- let newSec = this.sec + Math.floor(val / 1000000000);
2007
+ let newSec = this.sec + BigInt(Math.floor(val / 1000000000));
1928
2008
  val = val % 1000000000 + this.nanosec;
1929
2009
  while (val > 1000000000)
1930
2010
  {
@@ -1941,14 +2021,14 @@ export class TimeInstant
1941
2021
 
1942
2022
  clearTime()
1943
2023
  {
1944
- return new TimeInstant(this.sec - this.sec % 86400, 0);
2024
+ return new TimeInstant(this.sec - this.sec % 86400n, 0);
1945
2025
  }
1946
2026
 
1947
2027
  roundToS()
1948
2028
  {
1949
2029
  if (this.nanosec >= 500000000)
1950
2030
  {
1951
- return new TimeInstant(this.sec + 1, 0);
2031
+ return new TimeInstant(this.sec + 1n, 0);
1952
2032
  }
1953
2033
  else
1954
2034
  {
@@ -1958,7 +2038,7 @@ export class TimeInstant
1958
2038
 
1959
2039
  getMSPassedDate()
1960
2040
  {
1961
- return Number(this.sec % 86400) * 1000 + Math.floor(this.nanosec / 1000000);
2041
+ return Number(this.sec % 86400n) * 1000 + Math.floor(this.nanosec / 1000000);
1962
2042
  }
1963
2043
 
1964
2044
  diffMS(ts)
@@ -2009,12 +2089,27 @@ export class TimeInstant
2009
2089
 
2010
2090
  toEpochMS()
2011
2091
  {
2012
- return this.sec * 1000 + BigInt(Math.floor(this.nanosec / 1000000));
2092
+ return this.sec * 1000n + BigInt(Math.floor(this.nanosec / 1000000));
2013
2093
  }
2014
2094
 
2015
2095
  toEpochNS()
2016
2096
  {
2017
- return this.sec * 1000000000 + BigInt(this.nanosec);
2097
+ return this.sec * 1000000000n + BigInt(this.nanosec);
2098
+ }
2099
+
2100
+ static fromDotNetTicks(ticks)
2101
+ {
2102
+ ticks = BigInt(ticks) - 621355968000000000n;
2103
+ let ns = Number(ticks % 10000000n);
2104
+ if (ns < 0)
2105
+ {
2106
+ return new TimeInstant(ticks / 10000000n - 1n, (ns + 10000000) * 100);
2107
+ }
2108
+ else
2109
+ {
2110
+ return new TimeInstant(ticks / 10000000n, ns * 100);
2111
+ }
2112
+
2018
2113
  }
2019
2114
  }
2020
2115
 
@@ -2085,11 +2180,11 @@ export class Timestamp
2085
2180
  {
2086
2181
  if (epochUS < 0)
2087
2182
  {
2088
- return new Timestamp(new TimeInstant(epochUS / 1000000n - 1, Number(epochUS % 1000000 + 1000000) * 1000), tzQhr);
2183
+ return new Timestamp(new TimeInstant(epochUS / 1000000n - 1n, Number(epochUS % 1000000n + 1000000n) * 1000), tzQhr);
2089
2184
  }
2090
2185
  else
2091
2186
  {
2092
- return new Timestamp(new TimeInstant(epochUS / 1000000n, Number(epochUS % 1000000) * 1000), tzQhr);
2187
+ return new Timestamp(new TimeInstant(epochUS / 1000000n, Number(epochUS % 1000000n) * 1000), tzQhr);
2093
2188
  }
2094
2189
  }
2095
2190
 
@@ -2097,11 +2192,11 @@ export class Timestamp
2097
2192
  {
2098
2193
  if (epochNS < 0)
2099
2194
  {
2100
- return new Timestamp(new TimeInstant(epochNS / 1000000000n - 1, Number(epochNS % 1000000000 + 1000000000)), tzQhr);
2195
+ return new Timestamp(new TimeInstant(epochNS / 1000000000n - 1n, Number(epochNS % 1000000000n + 1000000000n)), tzQhr);
2101
2196
  }
2102
2197
  else
2103
2198
  {
2104
- return new Timestamp(new TimeInstant(epochNS / 1000000000n, Number(epochNS % 1000000000)), tzQhr);
2199
+ return new Timestamp(new TimeInstant(epochNS / 1000000000n, Number(epochNS % 1000000000n)), tzQhr);
2105
2200
  }
2106
2201
  }
2107
2202
 
@@ -2332,7 +2427,7 @@ export class Timestamp
2332
2427
  {
2333
2428
  if (this.inst.nanosec == 0)
2334
2429
  {
2335
- if (((this.inst.sec + BigInt(this.tzQhr * 900)) % 86400n) == 0)
2430
+ if (((this.inst.sec + BigInt(this.tzQhr * 900)) % 86400n) == 0n)
2336
2431
  {
2337
2432
  return this.toString("yyyy-MM-dd");
2338
2433
  }
package/geometry.d.ts CHANGED
@@ -35,10 +35,11 @@ export enum VectorType
35
35
  PieArea
36
36
  }
37
37
 
38
- export class Vector2D {
38
+ export abstract class Vector2D {
39
39
  srid: number;
40
40
  type: VectorType;
41
41
  constructor(srid: number);
42
+ abstract calBoundaryPoint(coord: math.Coord2D): BoundaryPointResult;
42
43
  insideOrTouch(coord: math.Coord2D): boolean;
43
44
  getBounds(): math.RectArea;
44
45
  }
@@ -47,6 +48,7 @@ export class Point extends Vector2D
47
48
  {
48
49
  coordinates: number[];
49
50
  constructor(srid: number, coordinates: number[] | math.Coord2D | math.Vector3);
51
+ calBoundaryPoint(coord: math.Coord2D): BoundaryPointResult;
50
52
  insideOrTouch(coord: math.Coord2D): boolean;
51
53
  getBounds(): math.RectArea;
52
54
  }
@@ -84,7 +86,7 @@ export class MultiGeometry<VecType> extends Vector2D
84
86
 
85
87
  export class Polygon extends MultiGeometry<LinearRing>
86
88
  {
87
- constructor(srid: number, coordinates: number[][][]);
89
+ constructor(srid: number, coordinates?: number[][][]);
88
90
  insideOrTouch(coord: math.Coord2D): boolean;
89
91
  }
90
92