@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
155 lines • 5.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_CertBag = exports._decode_CertBag = exports._extension_additions_list_spec_for_CertBag = exports._root_component_type_list_2_spec_for_CertBag = exports._root_component_type_list_1_spec_for_CertBag = exports.CertBag = exports.CertTypes = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
var CertTypes_osa_1 = require("../PKCS-12/CertTypes.osa");
Object.defineProperty(exports, "CertTypes", { enumerable: true, get: function () { return CertTypes_osa_1.CertTypes; } });
/* START_OF_SYMBOL_DEFINITION CertBag */
/**
* @summary CertBag
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* CertBag ::= SEQUENCE {
* certId BAG-TYPE.&id ({CertTypes}),
* certValue [0] EXPLICIT BAG-TYPE.&Type ({CertTypes}{@certId})
* }
* ```
*
* @class
*/
class CertBag {
constructor(
/**
* @summary `certId`.
* @public
* @readonly
*/
certId,
/**
* @summary `certValue`.
* @public
* @readonly
*/
certValue) {
this.certId = certId;
this.certValue = certValue;
}
/**
* @summary Restructures an object into a CertBag
* @description
*
* This takes an `object` and converts it to a `CertBag`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `CertBag`.
* @returns {CertBag}
*/
static _from_object(_o) {
return new CertBag(_o.certId, _o.certValue);
}
}
exports.CertBag = CertBag;
/* END_OF_SYMBOL_DEFINITION CertBag */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CertBag */
/**
* @summary The Leading Root Component Types of CertBag
* @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_CertBag = [
new $.ComponentSpec("certId", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined),
new $.ComponentSpec("certValue", false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CertBag */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CertBag */
/**
* @summary The Trailing Root Component Types of CertBag
* @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_CertBag = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CertBag */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CertBag */
/**
* @summary The Extension Addition Component Types of CertBag
* @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_CertBag = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CertBag */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_CertBag */
let _cached_decoder_for_CertBag = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_CertBag */
/* START_OF_SYMBOL_DEFINITION _decode_CertBag */
/**
* @summary Decodes an ASN.1 element into a(n) CertBag
* @function
* @param {_Element} el The element being decoded.
* @returns {CertBag} The decoded data structure.
*/
function _decode_CertBag(el) {
if (!_cached_decoder_for_CertBag) {
_cached_decoder_for_CertBag = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("CertBag contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "certId";
sequence[1].name = "certValue";
let certId;
let certValue;
certId = $._decodeObjectIdentifier(sequence[0]);
certValue = $._decode_explicit(() => $._decodeAny)(sequence[1]);
return new CertBag(certId, certValue);
};
}
return _cached_decoder_for_CertBag(el);
}
exports._decode_CertBag = _decode_CertBag;
/* END_OF_SYMBOL_DEFINITION _decode_CertBag */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_CertBag */
let _cached_encoder_for_CertBag = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_CertBag */
/* START_OF_SYMBOL_DEFINITION _encode_CertBag */
/**
* @summary Encodes a(n) CertBag 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 CertBag, encoded as an ASN.1 Element.
*/
function _encode_CertBag(value, elGetter) {
if (!_cached_encoder_for_CertBag) {
_cached_encoder_for_CertBag = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ $._encodeObjectIdentifier(value.certId, $.BER),
/* REQUIRED */ $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeAny, $.BER)(value.certValue, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_CertBag(value, elGetter);
}
exports._encode_CertBag = _encode_CertBag;
/* END_OF_SYMBOL_DEFINITION _encode_CertBag */
/* eslint-enable */
//# sourceMappingURL=CertBag.ta.js.map