@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
169 lines • 7.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_ExtendedCertificateInfo = exports._decode_ExtendedCertificateInfo = exports._extension_additions_list_spec_for_ExtendedCertificateInfo = exports._root_component_type_list_2_spec_for_ExtendedCertificateInfo = exports._root_component_type_list_1_spec_for_ExtendedCertificateInfo = exports.ExtendedCertificateInfo = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const Certificate_ta_1 = require("@wildboar/x500/src/lib/modules/AuthenticationFramework/Certificate.ta");
const Attributes_ta_1 = require("../PKCS7/Attributes.ta");
const Version_ta_1 = require("../PKCS7/Version.ta");
/* START_OF_SYMBOL_DEFINITION ExtendedCertificateInfo */
/**
* @summary ExtendedCertificateInfo
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* ExtendedCertificateInfo ::= SEQUENCE {
* version Version,
* certificate Certificate,
* attributes Attributes
* }
* ```
*
* @class
*/
class ExtendedCertificateInfo {
constructor(
/**
* @summary `version`.
* @public
* @readonly
*/
version,
/**
* @summary `certificate`.
* @public
* @readonly
*/
certificate,
/**
* @summary `attributes`.
* @public
* @readonly
*/
attributes) {
this.version = version;
this.certificate = certificate;
this.attributes = attributes;
}
/**
* @summary Restructures an object into a ExtendedCertificateInfo
* @description
*
* This takes an `object` and converts it to a `ExtendedCertificateInfo`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `ExtendedCertificateInfo`.
* @returns {ExtendedCertificateInfo}
*/
static _from_object(_o) {
return new ExtendedCertificateInfo(_o.version, _o.certificate, _o.attributes);
}
}
exports.ExtendedCertificateInfo = ExtendedCertificateInfo;
/* END_OF_SYMBOL_DEFINITION ExtendedCertificateInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ExtendedCertificateInfo */
/**
* @summary The Leading Root Component Types of ExtendedCertificateInfo
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._root_component_type_list_1_spec_for_ExtendedCertificateInfo = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("certificate", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("attributes", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ExtendedCertificateInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ExtendedCertificateInfo */
/**
* @summary The Trailing Root Component Types of ExtendedCertificateInfo
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._root_component_type_list_2_spec_for_ExtendedCertificateInfo = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ExtendedCertificateInfo */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ExtendedCertificateInfo */
/**
* @summary The Extension Addition Component Types of ExtendedCertificateInfo
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._extension_additions_list_spec_for_ExtendedCertificateInfo = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ExtendedCertificateInfo */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_ExtendedCertificateInfo */
let _cached_decoder_for_ExtendedCertificateInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_ExtendedCertificateInfo */
/* START_OF_SYMBOL_DEFINITION _decode_ExtendedCertificateInfo */
/**
* @summary Decodes an ASN.1 element into a(n) ExtendedCertificateInfo
* @function
* @param {_Element} el The element being decoded.
* @returns {ExtendedCertificateInfo} The decoded data structure.
*/
function _decode_ExtendedCertificateInfo(el) {
if (!_cached_decoder_for_ExtendedCertificateInfo) {
_cached_decoder_for_ExtendedCertificateInfo = function (el) {
const sequence = el.sequence;
if (sequence.length < 3) {
throw new asn1_ts_1.ASN1ConstructionError("ExtendedCertificateInfo contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "version";
sequence[1].name = "certificate";
sequence[2].name = "attributes";
let version;
let certificate;
let attributes;
version = Version_ta_1._decode_Version(sequence[0]);
certificate = Certificate_ta_1._decode_Certificate(sequence[1]);
attributes = Attributes_ta_1._decode_Attributes(sequence[2]);
return new ExtendedCertificateInfo(version, certificate, attributes);
};
}
return _cached_decoder_for_ExtendedCertificateInfo(el);
}
exports._decode_ExtendedCertificateInfo = _decode_ExtendedCertificateInfo;
/* END_OF_SYMBOL_DEFINITION _decode_ExtendedCertificateInfo */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_ExtendedCertificateInfo */
let _cached_encoder_for_ExtendedCertificateInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_ExtendedCertificateInfo */
/* START_OF_SYMBOL_DEFINITION _encode_ExtendedCertificateInfo */
/**
* @summary Encodes a(n) ExtendedCertificateInfo into an ASN.1 Element.
* @function
* @param {value} el The element being decoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The ExtendedCertificateInfo, encoded as an ASN.1 Element.
*/
function _encode_ExtendedCertificateInfo(value, elGetter) {
if (!_cached_encoder_for_ExtendedCertificateInfo) {
_cached_encoder_for_ExtendedCertificateInfo = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ Version_ta_1._encode_Version(value.version, $.BER),
/* REQUIRED */ Certificate_ta_1._encode_Certificate(value.certificate, $.BER),
/* REQUIRED */ Attributes_ta_1._encode_Attributes(value.attributes, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_ExtendedCertificateInfo(value, elGetter);
}
exports._encode_ExtendedCertificateInfo = _encode_ExtendedCertificateInfo;
/* END_OF_SYMBOL_DEFINITION _encode_ExtendedCertificateInfo */
/* eslint-enable */
//# sourceMappingURL=ExtendedCertificateInfo.ta.js.map