UNPKG

pkcs-ts

Version:

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

60 lines 2.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_PKCS12Attribute = exports._decode_PKCS12Attribute = exports._extension_additions_list_spec_for_PKCS12Attribute = exports._root_component_type_list_2_spec_for_PKCS12Attribute = exports._root_component_type_list_1_spec_for_PKCS12Attribute = exports.PKCS12Attribute = 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 PKCS12Attribute { constructor(attrId, attrValues) { this.attrId = attrId; this.attrValues = attrValues; } static _from_object(_o) { return new PKCS12Attribute(_o.attrId, _o.attrValues); } } exports.PKCS12Attribute = PKCS12Attribute; exports._root_component_type_list_1_spec_for_PKCS12Attribute = [ new $.ComponentSpec("attrId", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("attrValues", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined), ]; exports._root_component_type_list_2_spec_for_PKCS12Attribute = []; exports._extension_additions_list_spec_for_PKCS12Attribute = []; let _cached_decoder_for_PKCS12Attribute = null; function _decode_PKCS12Attribute(el) { if (!_cached_decoder_for_PKCS12Attribute) { _cached_decoder_for_PKCS12Attribute = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("PKCS12Attribute contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "attrId"; sequence[1].name = "attrValues"; let attrId; let attrValues; attrId = $._decodeObjectIdentifier(sequence[0]); attrValues = $._decodeSetOf(() => $._decodeAny)(sequence[1]); return new PKCS12Attribute(attrId, attrValues); }; } return _cached_decoder_for_PKCS12Attribute(el); } exports._decode_PKCS12Attribute = _decode_PKCS12Attribute; let _cached_encoder_for_PKCS12Attribute = null; function _encode_PKCS12Attribute(value, elGetter) { if (!_cached_encoder_for_PKCS12Attribute) { _cached_encoder_for_PKCS12Attribute = function (value, elGetter) { return $._encodeSequence([] .concat([ $._encodeObjectIdentifier(value.attrId, $.BER), $._encodeSetOf(() => $._encodeAny, $.BER)(value.attrValues, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_PKCS12Attribute(value, elGetter); } exports._encode_PKCS12Attribute = _encode_PKCS12Attribute; //# sourceMappingURL=PKCS12Attribute.ta.js.map