UNPKG

pkcs-ts

Version:

PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More

60 lines 2.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_Attribute = exports._decode_Attribute = exports._extension_additions_list_spec_for_Attribute = exports._root_component_type_list_2_spec_for_Attribute = exports._root_component_type_list_1_spec_for_Attribute = exports.Attribute = void 0; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional")); class Attribute { constructor(type_, values) { this.type_ = type_; this.values = values; } static _from_object(_o) { return new Attribute(_o.type_, _o.values); } } exports.Attribute = Attribute; exports._root_component_type_list_1_spec_for_Attribute = [ new $.ComponentSpec("type", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("values", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined), ]; exports._root_component_type_list_2_spec_for_Attribute = []; exports._extension_additions_list_spec_for_Attribute = []; let _cached_decoder_for_Attribute = null; function _decode_Attribute(el) { if (!_cached_decoder_for_Attribute) { _cached_decoder_for_Attribute = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("Attribute contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "type"; sequence[1].name = "values"; let type_; let values; type_ = $._decodeObjectIdentifier(sequence[0]); values = $._decodeSetOf(() => $._decodeAny)(sequence[1]); return new Attribute(type_, values); }; } return _cached_decoder_for_Attribute(el); } exports._decode_Attribute = _decode_Attribute; let _cached_encoder_for_Attribute = null; function _encode_Attribute(value, elGetter) { if (!_cached_encoder_for_Attribute) { _cached_encoder_for_Attribute = function (value, elGetter) { return $._encodeSequence([] .concat([ $._encodeObjectIdentifier(value.type_, $.BER), $._encodeSetOf(() => $._encodeAny, $.BER)(value.values, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_Attribute(value, elGetter); } exports._encode_Attribute = _encode_Attribute; //# sourceMappingURL=Attribute.ta.js.map