Comparing version 7.0.5 to 7.0.6
@@ -51,2 +51,6 @@ import { ASN1Construction, ASN1TagClass } from "./values"; | ||
abstract get set(): SET<ASN1Element>; | ||
abstract set sequenceOf(value: SEQUENCE<ASN1Element>); | ||
abstract get sequenceOf(): SEQUENCE<ASN1Element>; | ||
abstract set setOf(value: SET<ASN1Element>); | ||
abstract get setOf(): SET<ASN1Element>; | ||
abstract set numericString(value: NumericString); | ||
@@ -53,0 +57,0 @@ abstract get numericString(): NumericString; |
@@ -73,3 +73,3 @@ "use strict"; | ||
sizeConstrainedSequenceOf(min, max) { | ||
const ret = this.sequence; | ||
const ret = this.sequenceOf; | ||
this.validateSize(this.name || "SEQUENCE OF", "elements", ret.length, min, max); | ||
@@ -79,3 +79,3 @@ return ret; | ||
sizeConstrainedSetOf(min, max) { | ||
const ret = this.set; | ||
const ret = this.setOf; | ||
this.validateSize(this.name || "SET OF", "elements", ret.length, min, max); | ||
@@ -82,0 +82,0 @@ return ret; |
@@ -28,2 +28,6 @@ import ASN1Element from "../asn1"; | ||
get set(): SET<ASN1Element>; | ||
set sequenceOf(value: SEQUENCE<ASN1Element>); | ||
get sequenceOf(): SEQUENCE<ASN1Element>; | ||
set setOf(value: SET<ASN1Element>); | ||
get setOf(): SET<ASN1Element>; | ||
set numericString(value: NumericString); | ||
@@ -58,4 +62,5 @@ get numericString(): NumericString; | ||
encode(value: any): void; | ||
static fromSequence(sequence: (BERElement | null | undefined)[]): BERElement; | ||
static fromSequence(sequence: (ASN1Element | null | undefined)[]): BERElement; | ||
static fromSet(set: (BERElement | null | undefined)[]): BERElement; | ||
static fromSetOf(set: (BERElement | null | undefined)[]): BERElement; | ||
get inner(): BERElement; | ||
@@ -62,0 +67,0 @@ set inner(value: BERElement); |
@@ -44,2 +44,3 @@ "use strict"; | ||
const macros_1 = require("../macros"); | ||
const utils_1 = require("../utils"); | ||
class BERElement extends x690_1.default { | ||
@@ -147,2 +148,22 @@ constructor(tagClass = values_1.ASN1TagClass.universal, construction = values_1.ASN1Construction.primitive, tagNumber = values_1.ASN1UniversalType.endOfContent, value = undefined) { | ||
get set() { | ||
const ret = this.sequence; | ||
if (!(0, utils_1.isUniquelyTagged)(ret)) { | ||
throw new errors.ASN1ConstructionError("Duplicate tag in SET.", this); | ||
} | ||
return ret; | ||
} | ||
set sequenceOf(value) { | ||
this.value = (0, encodeSequence_1.default)(value); | ||
this.construction = values_1.ASN1Construction.constructed; | ||
} | ||
get sequenceOf() { | ||
if (this.construction !== values_1.ASN1Construction.constructed) { | ||
throw new errors.ASN1ConstructionError("SET or SEQUENCE cannot be primitively constructed.", this); | ||
} | ||
return (0, decodeSequence_1.default)(this.value); | ||
} | ||
set setOf(value) { | ||
this.sequence = value; | ||
} | ||
get setOf() { | ||
return this.sequence; | ||
@@ -370,2 +391,7 @@ } | ||
} | ||
static fromSetOf(set) { | ||
const ret = new BERElement(values_1.ASN1TagClass.universal, values_1.ASN1Construction.constructed, values_1.ASN1UniversalType.set); | ||
ret.setOf = set.filter((element) => Boolean(element)); | ||
return ret; | ||
} | ||
get inner() { | ||
@@ -372,0 +398,0 @@ if (this.construction !== values_1.ASN1Construction.constructed) { |
@@ -6,5 +6,2 @@ "use strict"; | ||
function decodeSequence(value) { | ||
if (value.length === 0) { | ||
return []; | ||
} | ||
const encodedElements = []; | ||
@@ -11,0 +8,0 @@ let i = 0; |
@@ -29,2 +29,6 @@ import ASN1Element from "../asn1"; | ||
get set(): SET<ASN1Element>; | ||
set sequenceOf(value: SEQUENCE<ASN1Element>); | ||
get sequenceOf(): SEQUENCE<ASN1Element>; | ||
set setOf(value: SET<ASN1Element>); | ||
get setOf(): SET<ASN1Element>; | ||
set numericString(value: NumericString); | ||
@@ -59,4 +63,5 @@ get numericString(): NumericString; | ||
encode(value: any): void; | ||
static fromSequence(sequence: (CERElement | null | undefined)[]): CERElement; | ||
static fromSequence(sequence: (ASN1Element | null | undefined)[]): CERElement; | ||
static fromSet(set: (CERElement | null | undefined)[]): CERElement; | ||
static fromSetOf(set: (CERElement | null | undefined)[]): CERElement; | ||
get inner(): CERElement; | ||
@@ -63,0 +68,0 @@ set inner(value: CERElement); |
@@ -46,2 +46,3 @@ "use strict"; | ||
const macros_1 = require("../macros"); | ||
const utils_1 = require("../utils"); | ||
class CERElement extends x690_1.default { | ||
@@ -157,2 +158,22 @@ get unfragmentedValue() { | ||
get set() { | ||
const ret = this.sequence; | ||
if (!(0, utils_1.isUniquelyTagged)(ret)) { | ||
throw new errors.ASN1ConstructionError("Duplicate tag in SET.", this); | ||
} | ||
return ret; | ||
} | ||
set sequenceOf(value) { | ||
this.value = (0, encodeSequence_1.default)(value); | ||
this.construction = values_1.ASN1Construction.constructed; | ||
} | ||
get sequenceOf() { | ||
if (this.construction !== values_1.ASN1Construction.constructed) { | ||
throw new errors.ASN1ConstructionError("SET or SEQUENCE cannot be primitively constructed.", this); | ||
} | ||
return (0, decodeSequence_1.default)(this.value); | ||
} | ||
set setOf(value) { | ||
this.sequence = value; | ||
} | ||
get setOf() { | ||
return this.sequence; | ||
@@ -376,2 +397,7 @@ } | ||
} | ||
static fromSetOf(set) { | ||
const ret = new CERElement(values_1.ASN1TagClass.universal, values_1.ASN1Construction.constructed, values_1.ASN1UniversalType.set); | ||
ret.setOf = set.filter((element) => Boolean(element)); | ||
return ret; | ||
} | ||
get inner() { | ||
@@ -378,0 +404,0 @@ if (this.construction !== values_1.ASN1Construction.constructed) { |
@@ -27,2 +27,6 @@ import ASN1Element from "../asn1"; | ||
get set(): SET<ASN1Element>; | ||
set sequenceOf(value: SEQUENCE<ASN1Element>); | ||
get sequenceOf(): SEQUENCE<ASN1Element>; | ||
set setOf(value: SET<ASN1Element>); | ||
get setOf(): SET<ASN1Element>; | ||
set numericString(value: NumericString); | ||
@@ -59,2 +63,3 @@ get numericString(): NumericString; | ||
static fromSet(set: (ASN1Element | null | undefined)[]): DERElement; | ||
static fromSetOf(set: (DERElement | null | undefined)[]): DERElement; | ||
get inner(): DERElement; | ||
@@ -61,0 +66,0 @@ set inner(value: DERElement); |
@@ -44,2 +44,3 @@ "use strict"; | ||
const x690_1 = tslib_1.__importDefault(require("../x690")); | ||
const utils_1 = require("../utils"); | ||
class DERElement extends x690_1.default { | ||
@@ -132,2 +133,22 @@ set boolean(value) { | ||
get set() { | ||
const ret = this.sequence; | ||
if (!(0, utils_1.isUniquelyTagged)(ret)) { | ||
throw new errors.ASN1ConstructionError("Duplicate tag in SET.", this); | ||
} | ||
return ret; | ||
} | ||
set sequenceOf(value) { | ||
this.value = (0, encodeSequence_1.default)(value); | ||
this.construction = values_1.ASN1Construction.constructed; | ||
} | ||
get sequenceOf() { | ||
if (this.construction !== values_1.ASN1Construction.constructed) { | ||
throw new errors.ASN1ConstructionError("SET or SEQUENCE cannot be primitively constructed.", this); | ||
} | ||
return (0, decodeSequence_1.default)(this.value); | ||
} | ||
set setOf(value) { | ||
this.sequence = value; | ||
} | ||
get setOf() { | ||
return this.sequence; | ||
@@ -380,2 +401,7 @@ } | ||
} | ||
static fromSetOf(set) { | ||
const ret = new DERElement(values_1.ASN1TagClass.universal, values_1.ASN1Construction.constructed, values_1.ASN1UniversalType.set); | ||
ret.setOf = set.filter((element) => Boolean(element)); | ||
return ret; | ||
} | ||
get inner() { | ||
@@ -551,3 +577,3 @@ if (this.construction !== values_1.ASN1Construction.constructed) { | ||
deconstruct() { | ||
return this.value.subarray(0); | ||
return new Uint8Array(this.value); | ||
} | ||
@@ -554,0 +580,0 @@ get components() { |
@@ -857,3 +857,3 @@ "use strict"; | ||
return function (el) { | ||
return el.set.map(decoderGetter()); | ||
return el.setOf.map(decoderGetter()); | ||
}; | ||
@@ -866,3 +866,3 @@ } | ||
const encoder = encoderGetter(); | ||
el.set = value.map((v) => encoder(v, outerElGetter)); | ||
el.setOf = value.map((v) => encoder(v, outerElGetter)); | ||
el.tagClass = index_1.ASN1TagClass.universal; | ||
@@ -869,0 +869,0 @@ el.tagNumber = index_1.ASN1UniversalType.set; |
@@ -6,3 +6,4 @@ "use strict"; | ||
for (let i = 0; i < elements.length; i++) { | ||
const key = `${elements[i].tagClass}.${elements[i].tagNumber}`; | ||
const key = ((elements[i].tagClass << 30) | ||
+ elements[i].tagNumber); | ||
if (finds.has(key)) { | ||
@@ -9,0 +10,0 @@ return false; |
@@ -7,6 +7,10 @@ "use strict"; | ||
const ret = new Uint8Array(bytesNeeded); | ||
let byte = -1; | ||
for (let bit = 0; bit < bits.length; bit++) { | ||
const bitMod8 = bit % 8; | ||
if (bitMod8 === 0) { | ||
byte++; | ||
} | ||
if (bits[bit] !== macros_1.FALSE_BIT) { | ||
const byte = Math.floor(bit / 8); | ||
ret[byte] |= (0x01 << (7 - (bit % 8))); | ||
ret[byte] |= (0x01 << (7 - bitMod8)); | ||
} | ||
@@ -13,0 +17,0 @@ } |
@@ -64,3 +64,3 @@ { | ||
"types": "./dist/node/index.d.ts", | ||
"version": "7.0.5" | ||
"version": "7.0.6" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
694800
7720