asn1-ts 9.0.3 → 10.0.0
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/README.md +2 -0
- package/dist/classes/ABSTRACT-SYNTAX.d.mts +1 -1
- package/dist/classes/TYPE-IDENTIFIER.d.mts +1 -1
- package/dist/classes/index.d.mts +2 -2
- package/dist/codecs/ber/decoders/decodeBitString.d.mts +1 -1
- package/dist/codecs/ber/decoders/decodeBoolean.d.mts +1 -1
- package/dist/codecs/ber/decoders/decodeDuration.d.mts +1 -1
- package/dist/codecs/ber/decoders/decodeDuration.mjs +2 -2
- package/dist/codecs/ber/decoders/decodeGeneralizedTime.d.mts +1 -1
- package/dist/codecs/ber/decoders/decodeGeneralizedTime.mjs +10 -4
- package/dist/codecs/ber/decoders/decodeReal.d.mts +1 -1
- package/dist/codecs/ber/decoders/decodeSequence.d.mts +1 -1
- package/dist/codecs/ber/decoders/decodeUTCTime.d.mts +1 -1
- package/dist/codecs/ber/encoders/encodeGeneralString.d.mts +1 -1
- package/dist/codecs/ber/encoders/encodeGraphicString.d.mts +1 -1
- package/dist/codecs/ber/encoders/encodeNumericString.d.mts +1 -1
- package/dist/codecs/ber/encoders/encodeObjectDescriptor.d.mts +1 -1
- package/dist/codecs/ber/encoders/encodePrintableString.d.mts +1 -1
- package/dist/codecs/ber/encoders/encodeVisibleString.d.mts +1 -1
- package/dist/codecs/ber.d.mts +1 -1
- package/dist/codecs/ber.mjs +2 -1
- package/dist/codecs/cer/decoders/decodeSequence.d.mts +1 -1
- package/dist/codecs/cer.d.mts +1 -1
- package/dist/codecs/cer.mjs +2 -1
- package/dist/codecs/coer/decoders/decodeBoolean.d.mts +1 -1
- package/dist/codecs/der/decoders/decodeBitString.d.mts +1 -1
- package/dist/codecs/der/decoders/decodeBoolean.d.mts +1 -1
- package/dist/codecs/der/decoders/decodeDuration.d.mts +1 -1
- package/dist/codecs/der/decoders/decodeDuration.mjs +2 -2
- package/dist/codecs/der/decoders/decodeGeneralizedTime.d.mts +1 -1
- package/dist/codecs/der/decoders/decodeReal.d.mts +1 -1
- package/dist/codecs/der/decoders/decodeSequence.d.mts +1 -1
- package/dist/codecs/der/decoders/decodeUTCTime.d.mts +1 -1
- package/dist/codecs/der.d.mts +1 -1
- package/dist/codecs/der.mjs +1 -0
- package/dist/codecs/x690/decoders/decodeDate.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeDateTime.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeEmbeddedPDV.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeExternal.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeExternal.mjs +1 -0
- package/dist/codecs/x690/decoders/decodeGeneralString.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeGraphicString.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeInteger.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeNumericString.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeOIDIRI.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeObjectDescriptor.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeObjectIdentifier.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodePrintableString.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeRelativeOIDIRI.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeRelativeObjectIdentifier.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeTime.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeTimeOfDay.d.mts +1 -1
- package/dist/codecs/x690/decoders/decodeVisibleString.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeBitString.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeBoolean.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeCharacterString.mjs +1 -0
- package/dist/codecs/x690/encoders/encodeDate.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeDateTime.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeDuration.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeEmbeddedPDV.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeExternal.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeGeneralizedTime.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeInteger.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeOIDIRI.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeObjectIdentifier.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeReal.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeRelativeOIDIRI.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeRelativeObjectIdentifier.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeSequence.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeSequence.mjs +1 -0
- package/dist/codecs/x690/encoders/encodeTime.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeTimeOfDay.d.mts +1 -1
- package/dist/codecs/x690/encoders/encodeUTCTime.d.mts +1 -1
- package/dist/functional.d.mts +40 -42
- package/dist/functional.mjs +118 -118
- package/dist/index.d.mts +0 -2
- package/dist/index.mjs +0 -1
- package/dist/interfaces/index.d.mts +12 -12
- package/dist/types/External.d.mts +1 -1
- package/dist/types/TypeIdentifier.mjs +1 -0
- package/dist/types/time/DATE-ENCODING.d.mts +1 -1
- package/dist/types/time/DURATION-EQUIVALENT.d.mts +1 -1
- package/dist/types/time/DURATION-INTERVAL-ENCODING.d.mts +1 -1
- package/dist/types/time/HOURS-DIFF-ENCODING.d.mts +1 -1
- package/dist/types/time/HOURS-ENCODING.d.mts +1 -1
- package/dist/types/time/HOURS-MINUTES-DIFF-ENCODING.d.mts +1 -1
- package/dist/types/time/HOURS-MINUTES-ENCODING.d.mts +1 -1
- package/dist/types/time/TIME-OF-DAY-DIFF-ENCODING.d.mts +1 -1
- package/dist/types/time/TIME-OF-DAY-ENCODING.d.mts +1 -1
- package/dist/types/time/TIME-OF-DAY-FRACTION-DIFF-ENCODING.d.mts +1 -1
- package/dist/types/time/TIME-OF-DAY-FRACTION-ENCODING.d.mts +1 -1
- package/dist/types/time/YEAR-ENCODING.d.mts +1 -1
- package/dist/types/time/YEAR-MONTH-ENCODING.d.mts +1 -1
- package/dist/utils/isInCanonicalOrder.mjs +1 -1
- package/dist/utils/packBits.d.mts +1 -1
- package/dist/utils/unpackBits.d.mts +1 -1
- package/dist/validators/datetimeComponentValidator.d.mts +1 -1
- package/dist/values.d.mts +1 -0
- package/dist/values.mjs +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# ASN.1 TypeScript Library
|
|
2
2
|
|
|
3
|
+
[](https://jsr.io/@wildboar/asn1)
|
|
4
|
+
|
|
3
5
|
Feature-complete, specification-compliant TypeScript library for encoding and
|
|
4
6
|
decoding ASN.1 data structures using the Basic Encoding Rules (BER),
|
|
5
7
|
Canonical Encoding Rules (CER), and Distinguished Encoding Rules (DER).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ASN1Decoder, ASN1Encoder } from "../functional.mjs";
|
|
1
|
+
import type { ASN1Decoder, ASN1Encoder } from "../functional.mjs";
|
|
2
2
|
import type { OBJECT_IDENTIFIER, BIT_STRING } from "../macros.mjs";
|
|
3
3
|
export default interface ABSTRACT_SYNTAX<Type = any> {
|
|
4
4
|
class: string;
|
package/dist/classes/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as ABSTRACT_SYNTAX } from "./ABSTRACT-SYNTAX.mjs";
|
|
2
|
-
export { default as TYPE_IDENTIFIER } from "./TYPE-IDENTIFIER.mjs";
|
|
1
|
+
export type { default as ABSTRACT_SYNTAX } from "./ABSTRACT-SYNTAX.mjs";
|
|
2
|
+
export type { default as TYPE_IDENTIFIER } from "./TYPE-IDENTIFIER.mjs";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BIT_STRING } from "../../../macros.mjs";
|
|
1
|
+
import type { BIT_STRING } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeBitString(value: Uint8Array): BIT_STRING;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BOOLEAN } from "../../../macros.mjs";
|
|
1
|
+
import type { BOOLEAN } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeBoolean(value: Uint8Array): BOOLEAN;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DURATION } from "../../../macros.mjs";
|
|
1
|
+
import type { DURATION } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeDuration(bytes: Uint8Array): DURATION;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import convertBytesToText from "../../../utils/convertBytesToText.mjs";
|
|
2
2
|
import * as errors from "../../../errors.mjs";
|
|
3
3
|
import { DURATION_EQUIVALENT } from "../../../types/index.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { durationRegex } from "../../../values.mjs";
|
|
5
5
|
export default function decodeDuration(bytes) {
|
|
6
6
|
const str = convertBytesToText(bytes).replace(/,/g, ".");
|
|
7
7
|
if (str.indexOf("W") === (str.length - 1)) {
|
|
@@ -27,7 +27,7 @@ export default function decodeDuration(bytes) {
|
|
|
27
27
|
}
|
|
28
28
|
return new DURATION_EQUIVALENT(undefined, undefined, weeks, undefined, undefined, undefined, undefined, fractional_part);
|
|
29
29
|
}
|
|
30
|
-
const match =
|
|
30
|
+
const match = durationRegex.exec(str);
|
|
31
31
|
if (!match) {
|
|
32
32
|
throw new errors.ASN1Error(`Malformed DURATION ${str}.`);
|
|
33
33
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GeneralizedTime } from "../../../macros.mjs";
|
|
1
|
+
import type { GeneralizedTime } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeGeneralizedTime(value: Uint8Array): GeneralizedTime;
|
|
@@ -7,6 +7,12 @@ const COMMA = ",".charCodeAt(0);
|
|
|
7
7
|
const Z = "Z".charCodeAt(0);
|
|
8
8
|
const PLUS = "+".charCodeAt(0);
|
|
9
9
|
const MINUS = "-".charCodeAt(0);
|
|
10
|
+
var FractionalUnits;
|
|
11
|
+
(function (FractionalUnits) {
|
|
12
|
+
FractionalUnits[FractionalUnits["Hours"] = 0] = "Hours";
|
|
13
|
+
FractionalUnits[FractionalUnits["Minutes"] = 1] = "Minutes";
|
|
14
|
+
FractionalUnits[FractionalUnits["Seconds"] = 2] = "Seconds";
|
|
15
|
+
})(FractionalUnits || (FractionalUnits = {}));
|
|
10
16
|
;
|
|
11
17
|
function isStop(s, i) {
|
|
12
18
|
const char = s.charCodeAt(i);
|
|
@@ -34,7 +40,7 @@ export default function decodeGeneralizedTime(value) {
|
|
|
34
40
|
let minutes = 0;
|
|
35
41
|
let seconds = 0;
|
|
36
42
|
let milliseconds = 0;
|
|
37
|
-
let fractionUnits =
|
|
43
|
+
let fractionUnits = FractionalUnits.Hours;
|
|
38
44
|
if (i == 14) {
|
|
39
45
|
minutes = Number.parseInt(dateString.slice(10, 12), 10);
|
|
40
46
|
seconds = Number.parseInt(dateString.slice(12, 14), 10);
|
|
@@ -59,14 +65,14 @@ export default function decodeGeneralizedTime(value) {
|
|
|
59
65
|
const fractionString = `0.${dateString.slice(i, j)}`;
|
|
60
66
|
i = j;
|
|
61
67
|
const fraction = Number.parseFloat(fractionString);
|
|
62
|
-
if (fractionUnits ===
|
|
68
|
+
if (fractionUnits === FractionalUnits.Hours) {
|
|
63
69
|
minutes = Math.floor(60 * fraction);
|
|
64
70
|
seconds = Math.floor((60 * 60 * fraction) % 60);
|
|
65
71
|
}
|
|
66
|
-
else if (fractionUnits ===
|
|
72
|
+
else if (fractionUnits === FractionalUnits.Minutes) {
|
|
67
73
|
seconds = Math.floor(60 * fraction);
|
|
68
74
|
}
|
|
69
|
-
else if (fractionUnits ===
|
|
75
|
+
else if (fractionUnits === FractionalUnits.Seconds) {
|
|
70
76
|
milliseconds = Math.floor(1000 * fraction);
|
|
71
77
|
}
|
|
72
78
|
else {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { REAL } from "../../../macros.mjs";
|
|
1
|
+
import type { REAL } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeReal(value: Uint8Array): REAL;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UTCTime } from "../../../macros.mjs";
|
|
1
|
+
import type { UTCTime } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeUTCTime(value: Uint8Array): UTCTime;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GeneralString } from "../../../macros.mjs";
|
|
1
|
+
import type { GeneralString } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeGeneralString(value: GeneralString): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GraphicString } from "../../../macros.mjs";
|
|
1
|
+
import type { GraphicString } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeGraphicString(value: GraphicString): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NumericString } from "../../../macros.mjs";
|
|
1
|
+
import type { NumericString } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeNumericString(value: NumericString): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ObjectDescriptor } from "../../../macros.mjs";
|
|
1
|
+
import type { ObjectDescriptor } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeObjectDescriptor(value: ObjectDescriptor): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PrintableString } from "../../../macros.mjs";
|
|
1
|
+
import type { PrintableString } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeNumericString(value: PrintableString): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { VisibleString } from "../../../macros.mjs";
|
|
1
|
+
import type { VisibleString } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeVisibleString(value: VisibleString): Uint8Array;
|
package/dist/codecs/ber.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import ASN1Element from "../asn1.mjs";
|
|
|
2
2
|
import { ASN1Construction, ASN1TagClass, LengthEncodingPreference } from "../values.mjs";
|
|
3
3
|
import X690Element from "../x690.mjs";
|
|
4
4
|
import CharacterString from "../types/CharacterString.mjs";
|
|
5
|
-
import { BOOLEAN, BIT_STRING, OCTET_STRING, ObjectDescriptor, EXTERNAL, REAL, EMBEDDED_PDV, UTF8String, SEQUENCE, SET, GraphicString, NumericString, VisibleString, PrintableString, TeletexString, GeneralString, UniversalString, VideotexString, BMPString, IA5String, UTCTime, GeneralizedTime, DURATION } from "../macros.mjs";
|
|
5
|
+
import type { BOOLEAN, BIT_STRING, OCTET_STRING, ObjectDescriptor, EXTERNAL, REAL, EMBEDDED_PDV, UTF8String, SEQUENCE, SET, GraphicString, NumericString, VisibleString, PrintableString, TeletexString, GeneralString, UniversalString, VideotexString, BMPString, IA5String, UTCTime, GeneralizedTime, DURATION } from "../macros.mjs";
|
|
6
6
|
export default class BERElement extends X690Element {
|
|
7
7
|
static lengthEncodingPreference: LengthEncodingPreference;
|
|
8
8
|
private _value;
|
package/dist/codecs/ber.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import ASN1Element from "../asn1.mjs";
|
|
|
2
2
|
import * as errors from "../errors.mjs";
|
|
3
3
|
import { ASN1Construction, ASN1TagClass, ASN1UniversalType, LengthEncodingPreference, } from "../values.mjs";
|
|
4
4
|
import X690Element from "../x690.mjs";
|
|
5
|
+
import CharacterString from "../types/CharacterString.mjs";
|
|
5
6
|
import convertBytesToText from "../utils/convertBytesToText.mjs";
|
|
6
7
|
import convertTextToBytes from "../utils/convertTextToBytes.mjs";
|
|
7
8
|
import ObjectIdentifier from "../types/ObjectIdentifier.mjs";
|
|
@@ -37,7 +38,7 @@ import decodeVisibleString from "../codecs/x690/decoders/decodeVisibleString.mjs
|
|
|
37
38
|
import decodeGeneralString from "../codecs/x690/decoders/decodeGeneralString.mjs";
|
|
38
39
|
import encodeDuration from "../codecs/x690/encoders/encodeDuration.mjs";
|
|
39
40
|
import decodeDuration from "../codecs/ber/decoders/decodeDuration.mjs";
|
|
40
|
-
import { FALSE_BIT
|
|
41
|
+
import { FALSE_BIT } from "../macros.mjs";
|
|
41
42
|
import { isUniquelyTagged } from "../utils/index.mjs";
|
|
42
43
|
import { Buffer } from "node:buffer";
|
|
43
44
|
class BERElement extends X690Element {
|
package/dist/codecs/cer.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import ASN1Element from "../asn1.mjs";
|
|
|
2
2
|
import { ASN1Construction, ASN1TagClass } from "../values.mjs";
|
|
3
3
|
import X690Element from "../x690.mjs";
|
|
4
4
|
import CharacterString from "../types/CharacterString.mjs";
|
|
5
|
-
import { BOOLEAN, BIT_STRING, OCTET_STRING, ObjectDescriptor, EXTERNAL, REAL, EMBEDDED_PDV, UTF8String, SEQUENCE, SET, GraphicString, NumericString, VisibleString, PrintableString, TeletexString, GeneralString, UniversalString, VideotexString, BMPString, IA5String, UTCTime, GeneralizedTime, DURATION } from "../macros.mjs";
|
|
5
|
+
import type { BOOLEAN, BIT_STRING, OCTET_STRING, ObjectDescriptor, EXTERNAL, REAL, EMBEDDED_PDV, UTF8String, SEQUENCE, SET, GraphicString, NumericString, VisibleString, PrintableString, TeletexString, GeneralString, UniversalString, VideotexString, BMPString, IA5String, UTCTime, GeneralizedTime, DURATION } from "../macros.mjs";
|
|
6
6
|
export default class CERElement extends X690Element {
|
|
7
7
|
private _value;
|
|
8
8
|
private _currentValueLength;
|
package/dist/codecs/cer.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import ASN1Element from "../asn1.mjs";
|
|
|
2
2
|
import * as errors from "../errors.mjs";
|
|
3
3
|
import { ASN1Construction, ASN1TagClass, ASN1UniversalType, } from "../values.mjs";
|
|
4
4
|
import X690Element from "../x690.mjs";
|
|
5
|
+
import CharacterString from "../types/CharacterString.mjs";
|
|
5
6
|
import convertBytesToText from "../utils/convertBytesToText.mjs";
|
|
6
7
|
import convertTextToBytes from "../utils/convertTextToBytes.mjs";
|
|
7
8
|
import sortCanonically from "../utils/sortCanonically.mjs";
|
|
@@ -39,7 +40,7 @@ import decodeVisibleString from "../codecs/x690/decoders/decodeVisibleString.mjs
|
|
|
39
40
|
import decodeGeneralString from "../codecs/x690/decoders/decodeGeneralString.mjs";
|
|
40
41
|
import encodeDuration from "../codecs/x690/encoders/encodeDuration.mjs";
|
|
41
42
|
import decodeDuration from "../codecs/der/decoders/decodeDuration.mjs";
|
|
42
|
-
import { FALSE_BIT
|
|
43
|
+
import { FALSE_BIT } from "../macros.mjs";
|
|
43
44
|
import { isUniquelyTagged } from "../utils/index.mjs";
|
|
44
45
|
import { Buffer } from "node:buffer";
|
|
45
46
|
export default class CERElement extends X690Element {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BOOLEAN } from "../../../macros.mjs";
|
|
1
|
+
import type { BOOLEAN } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeBoolean(value: Uint8Array): BOOLEAN;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BIT_STRING } from "../../../macros.mjs";
|
|
1
|
+
import type { BIT_STRING } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeBitString(value: Uint8Array): BIT_STRING;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BOOLEAN } from "../../../macros.mjs";
|
|
1
|
+
import type { BOOLEAN } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeBoolean(value: Uint8Array): BOOLEAN;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DURATION } from "../../../macros.mjs";
|
|
1
|
+
import type { DURATION } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeDuration(bytes: Uint8Array): DURATION;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import convertBytesToText from "../../../utils/convertBytesToText.mjs";
|
|
2
2
|
import * as errors from "../../../errors.mjs";
|
|
3
3
|
import { DURATION_EQUIVALENT } from "../../../types/index.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { durationRegex } from "../../../values.mjs";
|
|
5
5
|
export default function decodeDuration(bytes) {
|
|
6
6
|
const str = convertBytesToText(bytes);
|
|
7
7
|
if (str.indexOf(",") !== -1) {
|
|
@@ -30,7 +30,7 @@ export default function decodeDuration(bytes) {
|
|
|
30
30
|
}
|
|
31
31
|
return new DURATION_EQUIVALENT(undefined, undefined, weeks, undefined, undefined, undefined, undefined, fractional_part);
|
|
32
32
|
}
|
|
33
|
-
const match =
|
|
33
|
+
const match = durationRegex.exec(str);
|
|
34
34
|
if (!match) {
|
|
35
35
|
throw new errors.ASN1Error(`Malformed DURATION ${str}.`);
|
|
36
36
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GeneralizedTime } from "../../../macros.mjs";
|
|
1
|
+
import type { GeneralizedTime } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeGeneralizedTime(value: Uint8Array): GeneralizedTime;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { REAL } from "../../../macros.mjs";
|
|
1
|
+
import type { REAL } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeReal(value: Uint8Array): REAL;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UTCTime } from "../../../macros.mjs";
|
|
1
|
+
import type { UTCTime } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeUTCTime(value: Uint8Array): UTCTime;
|
package/dist/codecs/der.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import ASN1Element from "../asn1.mjs";
|
|
|
2
2
|
import { ASN1Construction, ASN1TagClass } from "../values.mjs";
|
|
3
3
|
import CharacterString from "../types/CharacterString.mjs";
|
|
4
4
|
import X690Element from "../x690.mjs";
|
|
5
|
-
import { BOOLEAN, BIT_STRING, OCTET_STRING, ObjectDescriptor, EXTERNAL, REAL, EMBEDDED_PDV, UTF8String, SEQUENCE, SET, GraphicString, NumericString, VisibleString, PrintableString, TeletexString, GeneralString, UniversalString, VideotexString, BMPString, IA5String, UTCTime, GeneralizedTime, DURATION } from "../macros.mjs";
|
|
5
|
+
import type { BOOLEAN, BIT_STRING, OCTET_STRING, ObjectDescriptor, EXTERNAL, REAL, EMBEDDED_PDV, UTF8String, SEQUENCE, SET, GraphicString, NumericString, VisibleString, PrintableString, TeletexString, GeneralString, UniversalString, VideotexString, BMPString, IA5String, UTCTime, GeneralizedTime, DURATION } from "../macros.mjs";
|
|
6
6
|
export default class DERElement extends X690Element {
|
|
7
7
|
private _value;
|
|
8
8
|
private _currentValueLength;
|
package/dist/codecs/der.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ASN1Element from "../asn1.mjs";
|
|
2
2
|
import * as errors from "../errors.mjs";
|
|
3
3
|
import { ASN1Construction, ASN1TagClass, ASN1UniversalType, } from "../values.mjs";
|
|
4
|
+
import CharacterString from "../types/CharacterString.mjs";
|
|
4
5
|
import convertBytesToText from "../utils/convertBytesToText.mjs";
|
|
5
6
|
import convertTextToBytes from "../utils/convertTextToBytes.mjs";
|
|
6
7
|
import sortCanonically from "../utils/sortCanonically.mjs";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DATE } from "../../../macros.mjs";
|
|
1
|
+
import type { DATE } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeDate(bytes: Uint8Array): DATE;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DATE_TIME } from "../../../macros.mjs";
|
|
1
|
+
import type { DATE_TIME } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeDateTime(bytes: Uint8Array): DATE_TIME;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EMBEDDED_PDV } from "../../../macros.mjs";
|
|
1
|
+
import type { EMBEDDED_PDV } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeEmbeddedPDV(value: Uint8Array): EMBEDDED_PDV;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EXTERNAL } from "../../../macros.mjs";
|
|
1
|
+
import type { EXTERNAL } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeExternal(value: Uint8Array): EXTERNAL;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import External from "../../../types/External.mjs";
|
|
2
2
|
import { ASN1TagClass, ASN1UniversalType } from "../../../values.mjs";
|
|
3
|
+
import ASN1Element from "../../../asn1.mjs";
|
|
3
4
|
import * as errors from "../../../errors.mjs";
|
|
4
5
|
import decodeSequence from "../../der/decoders/decodeSequence.mjs";
|
|
5
6
|
export default function decodeExternal(value) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GeneralString } from "../../../macros.mjs";
|
|
1
|
+
import type { GeneralString } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeGeneralString(value: Uint8Array): GeneralString;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GraphicString } from "../../../macros.mjs";
|
|
1
|
+
import type { GraphicString } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeGraphicString(value: Uint8Array): GraphicString;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { INTEGER } from "../../../macros.mjs";
|
|
1
|
+
import type { INTEGER } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeInteger(value: Uint8Array): INTEGER;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NumericString } from "../../../macros.mjs";
|
|
1
|
+
import type { NumericString } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeNumericString(value: Uint8Array): NumericString;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { OID_IRI } from "../../../macros.mjs";
|
|
1
|
+
import type { OID_IRI } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeOIDIRI(bytes: Uint8Array): OID_IRI;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ObjectDescriptor } from "../../../macros.mjs";
|
|
1
|
+
import type { ObjectDescriptor } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeObjectDescriptor(value: Uint8Array): ObjectDescriptor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { OBJECT_IDENTIFIER } from "../../../macros.mjs";
|
|
1
|
+
import type { OBJECT_IDENTIFIER } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeObjectIdentifier(value: Uint8Array): OBJECT_IDENTIFIER;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PrintableString } from "../../../macros.mjs";
|
|
1
|
+
import type { PrintableString } from "../../../macros.mjs";
|
|
2
2
|
export default function decodePrintableString(value: Uint8Array): PrintableString;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RELATIVE_OID_IRI } from "../../../macros.mjs";
|
|
1
|
+
import type { RELATIVE_OID_IRI } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeRelativeOIDIRI(bytes: Uint8Array): RELATIVE_OID_IRI;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RELATIVE_OID } from "../../../macros.mjs";
|
|
1
|
+
import type { RELATIVE_OID } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeRelativeObjectIdentifier(value: Uint8Array): RELATIVE_OID;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TIME } from "../../../macros.mjs";
|
|
1
|
+
import type { TIME } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeTime(bytes: Uint8Array): TIME;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TIME_OF_DAY } from "../../../macros.mjs";
|
|
1
|
+
import type { TIME_OF_DAY } from "../../../macros.mjs";
|
|
2
2
|
export default function decodeTimeOfDay(bytes: Uint8Array): TIME_OF_DAY;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PrintableString } from "../../../macros.mjs";
|
|
1
|
+
import type { PrintableString } from "../../../macros.mjs";
|
|
2
2
|
export default function decodePrintableString(value: Uint8Array): PrintableString;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BIT_STRING } from "../../../macros.mjs";
|
|
1
|
+
import type { BIT_STRING } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeBitString(value: BIT_STRING): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BOOLEAN } from "../../../macros.mjs";
|
|
1
|
+
import type { BOOLEAN } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeBoolean(value: BOOLEAN): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DATE } from "../../../macros.mjs";
|
|
1
|
+
import type { DATE } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeDate(date: DATE): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DATE_TIME } from "../../../macros.mjs";
|
|
1
|
+
import type { DATE_TIME } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeDateTime(value: DATE_TIME): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DURATION } from "../../../macros.mjs";
|
|
1
|
+
import type { DURATION } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeDuration(value: DURATION): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EMBEDDED_PDV } from "../../../macros.mjs";
|
|
1
|
+
import type { EMBEDDED_PDV } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeEmbeddedPDV(value: EMBEDDED_PDV): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EXTERNAL } from "../../../macros.mjs";
|
|
1
|
+
import type { EXTERNAL } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeExternal(value: EXTERNAL): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GeneralizedTime } from "../../../macros.mjs";
|
|
1
|
+
import type { GeneralizedTime } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeGeneralizedTime(value: GeneralizedTime): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { INTEGER } from "../../../macros.mjs";
|
|
1
|
+
import type { INTEGER } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeInteger(value: INTEGER): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { OID_IRI } from "../../../macros.mjs";
|
|
1
|
+
import type { OID_IRI } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeOIDIRI(value: OID_IRI): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { REAL } from "../../../macros.mjs";
|
|
1
|
+
import type { REAL } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeReal(value: REAL): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RELATIVE_OID_IRI } from "../../../macros.mjs";
|
|
1
|
+
import type { RELATIVE_OID_IRI } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeRelativeOIDIRI(value: RELATIVE_OID_IRI): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RELATIVE_OID } from "../../../macros.mjs";
|
|
1
|
+
import type { RELATIVE_OID } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeRelativeObjectIdentifier(value: RELATIVE_OID): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TIME } from "../../../macros.mjs";
|
|
1
|
+
import type { TIME } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeTime(value: TIME): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TIME_OF_DAY } from "../../../macros.mjs";
|
|
1
|
+
import type { TIME_OF_DAY } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeTimeOfDay(time: TIME_OF_DAY): Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UTCTime } from "../../../macros.mjs";
|
|
1
|
+
import type { UTCTime } from "../../../macros.mjs";
|
|
2
2
|
export default function encodeUTCTime(value: UTCTime): Uint8Array;
|