UNPKG

pkcs-ts

Version:

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

76 lines 4.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_CertificationRequestInfo = exports._decode_CertificationRequestInfo = exports._extension_additions_list_spec_for_CertificationRequestInfo = exports._root_component_type_list_2_spec_for_CertificationRequestInfo = exports._root_component_type_list_1_spec_for_CertificationRequestInfo = exports.CertificationRequestInfo = void 0; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional")); const Name_ta_1 = require("x500-ts/dist/node/modules/InformationFramework/Name.ta"); const Attributes_ta_1 = require("../PKCS-10/Attributes.ta"); const CertificationRequestInfo_version_ta_1 = require("../PKCS-10/CertificationRequestInfo-version.ta"); const SubjectPublicKeyInfo_ta_1 = require("../PKCS-10/SubjectPublicKeyInfo.ta"); class CertificationRequestInfo { constructor(version, subject, subjectPKInfo, attributes) { this.version = version; this.subject = subject; this.subjectPKInfo = subjectPKInfo; this.attributes = attributes; } static _from_object(_o) { return new CertificationRequestInfo(_o.version, _o.subject, _o.subjectPKInfo, _o.attributes); } } exports.CertificationRequestInfo = CertificationRequestInfo; exports._root_component_type_list_1_spec_for_CertificationRequestInfo = [ new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("subject", false, $.hasAnyTag, undefined, undefined), new $.ComponentSpec("subjectPKInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("attributes", false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), ]; exports._root_component_type_list_2_spec_for_CertificationRequestInfo = []; exports._extension_additions_list_spec_for_CertificationRequestInfo = []; let _cached_decoder_for_CertificationRequestInfo = null; function _decode_CertificationRequestInfo(el) { if (!_cached_decoder_for_CertificationRequestInfo) { _cached_decoder_for_CertificationRequestInfo = function (el) { const sequence = el.sequence; if (sequence.length < 4) { throw new asn1_ts_1.ASN1ConstructionError("CertificationRequestInfo contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "version"; sequence[1].name = "subject"; sequence[2].name = "subjectPKInfo"; sequence[3].name = "attributes"; let version; let subject; let subjectPKInfo; let attributes; version = CertificationRequestInfo_version_ta_1._decode_CertificationRequestInfo_version(sequence[0]); subject = Name_ta_1._decode_Name(sequence[1]); subjectPKInfo = SubjectPublicKeyInfo_ta_1._decode_SubjectPublicKeyInfo(sequence[2]); attributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(sequence[3]); return new CertificationRequestInfo(version, subject, subjectPKInfo, attributes); }; } return _cached_decoder_for_CertificationRequestInfo(el); } exports._decode_CertificationRequestInfo = _decode_CertificationRequestInfo; let _cached_encoder_for_CertificationRequestInfo = null; function _encode_CertificationRequestInfo(value, elGetter) { if (!_cached_encoder_for_CertificationRequestInfo) { _cached_encoder_for_CertificationRequestInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ CertificationRequestInfo_version_ta_1._encode_CertificationRequestInfo_version(value.version, $.BER), Name_ta_1._encode_Name(value.subject, $.BER), SubjectPublicKeyInfo_ta_1._encode_SubjectPublicKeyInfo(value.subjectPKInfo, $.BER), $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => Attributes_ta_1._encode_Attributes, $.BER)(value.attributes, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_CertificationRequestInfo(value, elGetter); } exports._encode_CertificationRequestInfo = _encode_CertificationRequestInfo; //# sourceMappingURL=CertificationRequestInfo.ta.js.map