@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
208 lines • 9.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_X509AttributeCertificateAttributes = exports._decode_X509AttributeCertificateAttributes = exports._extension_additions_list_spec_for_X509AttributeCertificateAttributes = exports._root_component_type_list_2_spec_for_X509AttributeCertificateAttributes = exports._root_component_type_list_1_spec_for_X509AttributeCertificateAttributes = exports.X509AttributeCertificateAttributes = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const AttributeCertificate_ta_1 = require("@wildboar/x500/src/lib/modules/AttributeCertificateDefinitions/AttributeCertificate.ta");
const CertificateSerialNumber_ta_1 = require("@wildboar/x500/src/lib/modules/AuthenticationFramework/CertificateSerialNumber.ta");
const GeneralNames_ta_1 = require("@wildboar/x500/src/lib/modules/CertificateExtensions/GeneralNames.ta");
const ObjectValue_ta_1 = require("../PKCS-15/ObjectValue.ta");
/* START_OF_SYMBOL_DEFINITION X509AttributeCertificateAttributes */
/**
* @summary X509AttributeCertificateAttributes
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* X509AttributeCertificateAttributes ::= SEQUENCE {
* value ObjectValue { AttributeCertificate },
* issuer GeneralNames OPTIONAL,
* serialNumber CertificateSerialNumber OPTIONAL,
* attrTypes [0] SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
* ... -- For future extensions
* }
* ```
*
* @class
*/
class X509AttributeCertificateAttributes {
constructor(
/**
* @summary `value`.
* @public
* @readonly
*/
value,
/**
* @summary `issuer`.
* @public
* @readonly
*/
issuer,
/**
* @summary `serialNumber`.
* @public
* @readonly
*/
serialNumber,
/**
* @summary `attrTypes`.
* @public
* @readonly
*/
attrTypes,
/**
* @summary Extensions that are not recognized.
* @public
* @readonly
*/
_unrecognizedExtensionsList = []) {
this.value = value;
this.issuer = issuer;
this.serialNumber = serialNumber;
this.attrTypes = attrTypes;
this._unrecognizedExtensionsList = _unrecognizedExtensionsList;
}
/**
* @summary Restructures an object into a X509AttributeCertificateAttributes
* @description
*
* This takes an `object` and converts it to a `X509AttributeCertificateAttributes`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `X509AttributeCertificateAttributes`.
* @returns {X509AttributeCertificateAttributes}
*/
static _from_object(_o) {
return new X509AttributeCertificateAttributes(_o.value, _o.issuer, _o.serialNumber, _o.attrTypes, _o._unrecognizedExtensionsList);
}
}
exports.X509AttributeCertificateAttributes = X509AttributeCertificateAttributes;
/* END_OF_SYMBOL_DEFINITION X509AttributeCertificateAttributes */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_X509AttributeCertificateAttributes */
/**
* @summary The Leading Root Component Types of X509AttributeCertificateAttributes
* @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_X509AttributeCertificateAttributes = [
new $.ComponentSpec("value", false, $.hasAnyTag, undefined, undefined),
new $.ComponentSpec("issuer", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("serialNumber", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("attrTypes", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_X509AttributeCertificateAttributes */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_X509AttributeCertificateAttributes */
/**
* @summary The Trailing Root Component Types of X509AttributeCertificateAttributes
* @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_X509AttributeCertificateAttributes = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_X509AttributeCertificateAttributes */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_X509AttributeCertificateAttributes */
/**
* @summary The Extension Addition Component Types of X509AttributeCertificateAttributes
* @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_X509AttributeCertificateAttributes = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_X509AttributeCertificateAttributes */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_X509AttributeCertificateAttributes */
let _cached_decoder_for_X509AttributeCertificateAttributes = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_X509AttributeCertificateAttributes */
/* START_OF_SYMBOL_DEFINITION _decode_X509AttributeCertificateAttributes */
/**
* @summary Decodes an ASN.1 element into a(n) X509AttributeCertificateAttributes
* @function
* @param {_Element} el The element being decoded.
* @returns {X509AttributeCertificateAttributes} The decoded data structure.
*/
function _decode_X509AttributeCertificateAttributes(el) {
if (!_cached_decoder_for_X509AttributeCertificateAttributes) {
_cached_decoder_for_X509AttributeCertificateAttributes = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let value;
let issuer;
let serialNumber;
let attrTypes;
let _unrecognizedExtensionsList = [];
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
value: (_el) => {
value = ObjectValue_ta_1._get_decoder_for_ObjectValue(AttributeCertificate_ta_1._decode_AttributeCertificate)(_el);
},
issuer: (_el) => {
issuer = GeneralNames_ta_1._decode_GeneralNames(_el);
},
serialNumber: (_el) => {
serialNumber = CertificateSerialNumber_ta_1._decode_CertificateSerialNumber(_el);
},
attrTypes: (_el) => {
attrTypes = $._decode_implicit(() => $._decodeSequenceOf(() => $._decodeObjectIdentifier))(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_X509AttributeCertificateAttributes, exports._extension_additions_list_spec_for_X509AttributeCertificateAttributes, exports._root_component_type_list_2_spec_for_X509AttributeCertificateAttributes, (ext) => {
_unrecognizedExtensionsList.push(ext);
});
return new X509AttributeCertificateAttributes(
/* SEQUENCE_CONSTRUCTOR_CALL */ value, issuer, serialNumber, attrTypes, _unrecognizedExtensionsList);
};
}
return _cached_decoder_for_X509AttributeCertificateAttributes(el);
}
exports._decode_X509AttributeCertificateAttributes = _decode_X509AttributeCertificateAttributes;
/* END_OF_SYMBOL_DEFINITION _decode_X509AttributeCertificateAttributes */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_X509AttributeCertificateAttributes */
let _cached_encoder_for_X509AttributeCertificateAttributes = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_X509AttributeCertificateAttributes */
/* START_OF_SYMBOL_DEFINITION _encode_X509AttributeCertificateAttributes */
/**
* @summary Encodes a(n) X509AttributeCertificateAttributes 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 X509AttributeCertificateAttributes, encoded as an ASN.1 Element.
*/
function _encode_X509AttributeCertificateAttributes(value, elGetter) {
if (!_cached_encoder_for_X509AttributeCertificateAttributes) {
_cached_encoder_for_X509AttributeCertificateAttributes = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ ObjectValue_ta_1._get_encoder_for_ObjectValue(AttributeCertificate_ta_1._encode_AttributeCertificate)(value.value, $.BER),
/* IF_ABSENT */ value.issuer === undefined
? undefined
: GeneralNames_ta_1._encode_GeneralNames(value.issuer, $.BER),
/* IF_ABSENT */ value.serialNumber === undefined
? undefined
: CertificateSerialNumber_ta_1._encode_CertificateSerialNumber(value.serialNumber, $.BER),
/* IF_ABSENT */ value.attrTypes === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeSequenceOf(() => $._encodeObjectIdentifier, $.BER), $.BER)(value.attrTypes, $.BER),
], value._unrecognizedExtensionsList
? value._unrecognizedExtensionsList
: [])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_X509AttributeCertificateAttributes(value, elGetter);
}
exports._encode_X509AttributeCertificateAttributes = _encode_X509AttributeCertificateAttributes;
/* END_OF_SYMBOL_DEFINITION _encode_X509AttributeCertificateAttributes */
/* eslint-enable */
//# sourceMappingURL=X509AttributeCertificateAttributes.ta.js.map