asn1-ts 11.0.1 → 11.0.2

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.
@@ -372,7 +372,8 @@ class BERElement extends X690Element {
372
372
  }
373
373
  });
374
374
  }
375
- else if ((value instanceof ObjectIdentifier) || (value.constructor?.name === "ObjectIdentifier")) {
375
+ else if ((value instanceof ObjectIdentifier)
376
+ || ((typeof value["fromParts"] === "function") && (typeof value["toBytes"] === "function"))) {
376
377
  this.tagNumber = ASN1UniversalType.objectIdentifier;
377
378
  this.objectIdentifier = value;
378
379
  }
@@ -385,7 +385,8 @@ export default class CERElement extends X690Element {
385
385
  }
386
386
  });
387
387
  }
388
- else if ((value instanceof ObjectIdentifier) || (value.constructor?.name === "ObjectIdentifier")) {
388
+ else if ((value instanceof ObjectIdentifier)
389
+ || ((typeof value["fromParts"] === "function") && (typeof value["toBytes"] === "function"))) {
389
390
  this.tagNumber = ASN1UniversalType.objectIdentifier;
390
391
  this.objectIdentifier = value;
391
392
  }
@@ -386,7 +386,8 @@ export default class DERElement extends X690Element {
386
386
  }
387
387
  });
388
388
  }
389
- else if ((value instanceof ObjectIdentifier) || (value.constructor?.name === "ObjectIdentifier")) {
389
+ else if ((value instanceof ObjectIdentifier)
390
+ || ((typeof value["fromParts"] === "function") && (typeof value["toBytes"] === "function"))) {
390
391
  this.tagNumber = ASN1UniversalType.objectIdentifier;
391
392
  this.objectIdentifier = value;
392
393
  }
@@ -3,8 +3,10 @@ import DERElement from "../../../codecs/der.mjs";
3
3
  import { ASN1TagClass, ASN1UniversalType, ASN1Construction } from "../../../values.mjs";
4
4
  import encodeSequence from "./encodeSequence.mjs";
5
5
  export default function encodeCharacterString(value) {
6
+ const encoding = new DERElement(ASN1TagClass.universal, ASN1Construction.primitive, ASN1UniversalType.octetString);
7
+ encoding.octetString = value.stringValue;
6
8
  return encodeSequence([
7
9
  value.identification,
8
- new DERElement(ASN1TagClass.universal, ASN1Construction.primitive, ASN1UniversalType.octetString, value.stringValue),
10
+ encoding,
9
11
  ]);
10
12
  }
@@ -2,8 +2,10 @@ import DERElement from "../../../codecs/der.mjs";
2
2
  import { ASN1TagClass, ASN1UniversalType, ASN1Construction } from "../../../values.mjs";
3
3
  import encodeSequence from "./encodeSequence.mjs";
4
4
  export default function encodeEmbeddedPDV(value) {
5
+ const encoding = new DERElement(ASN1TagClass.universal, ASN1Construction.primitive, ASN1UniversalType.octetString);
6
+ encoding.octetString = value.dataValue;
5
7
  return encodeSequence([
6
8
  value.identification,
7
- new DERElement(ASN1TagClass.universal, ASN1Construction.primitive, ASN1UniversalType.octetString, value.dataValue),
9
+ encoding,
8
10
  ]);
9
11
  }
@@ -4,11 +4,13 @@ import ASN1Element from "../../../asn1.mjs";
4
4
  export default function encodeExternal(value) {
5
5
  let directReferenceElement = undefined;
6
6
  if (value.directReference) {
7
- directReferenceElement = new DERElement(ASN1TagClass.universal, ASN1Construction.primitive, ASN1UniversalType.objectIdentifier, value.directReference);
7
+ directReferenceElement = new DERElement(ASN1TagClass.universal, ASN1Construction.primitive, ASN1UniversalType.objectIdentifier);
8
+ directReferenceElement.objectIdentifier = value.directReference;
8
9
  }
9
10
  let indirectReferenceElement = undefined;
10
11
  if (value.indirectReference) {
11
- indirectReferenceElement = new DERElement(ASN1TagClass.universal, ASN1Construction.primitive, ASN1UniversalType.integer, value.indirectReference);
12
+ indirectReferenceElement = new DERElement(ASN1TagClass.universal, ASN1Construction.primitive, ASN1UniversalType.integer);
13
+ indirectReferenceElement.integer = value.indirectReference;
12
14
  }
13
15
  let dataValueDescriptorElement = undefined;
14
16
  if (value.dataValueDescriptor) {
@@ -17,10 +19,12 @@ export default function encodeExternal(value) {
17
19
  }
18
20
  let encodingElement = undefined;
19
21
  if (value.encoding instanceof ASN1Element) {
20
- encodingElement = new DERElement(ASN1TagClass.context, ASN1Construction.constructed, 0, value.encoding);
22
+ encodingElement = new DERElement(ASN1TagClass.context, ASN1Construction.constructed, 0);
23
+ encodingElement.inner = value.encoding;
21
24
  }
22
25
  else if (value.encoding instanceof Uint8Array) {
23
- encodingElement = new DERElement(ASN1TagClass.context, ASN1Construction.primitive, 1, value.encoding);
26
+ encodingElement = new DERElement(ASN1TagClass.context, ASN1Construction.primitive, 1);
27
+ encodingElement.octetString = value.encoding;
24
28
  }
25
29
  else {
26
30
  encodingElement = new DERElement(ASN1TagClass.context, ASN1Construction.primitive, 2);
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "description": "ASN.1 encoding and decoding, including BER, CER, and DER.",
14
14
  "devDependencies": {
15
15
  "@types/node": "^22.10.5",
16
- "typescript": "^5.7.2"
16
+ "typescript": "^5.9"
17
17
  },
18
18
  "directories": {
19
19
  "doc": "documentation",
@@ -48,7 +48,7 @@
48
48
  "test": "node --test"
49
49
  },
50
50
  "types": "./dist/index.d.mts",
51
- "version": "11.0.1",
51
+ "version": "11.0.2",
52
52
  "exports": {
53
53
  "./functional": "./dist/functional.mjs"
54
54
  }