UNPKG

@wildboar/pkcs

Version:
279 lines 12.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_CommonCertificateAttributes = exports._decode_CommonCertificateAttributes = exports._extension_additions_list_spec_for_CommonCertificateAttributes = exports._root_component_type_list_2_spec_for_CommonCertificateAttributes = exports._root_component_type_list_1_spec_for_CommonCertificateAttributes = exports.CommonCertificateAttributes = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const CredentialIdentifier_ta_1 = require("../PKCS-15/CredentialIdentifier.ta"); const Identifier_ta_1 = require("../PKCS-15/Identifier.ta"); const Usage_ta_1 = require("../PKCS-15/Usage.ta"); const OOBCertHash_ta_1 = require("../PKIXCMP-2009/OOBCertHash.ta"); /* START_OF_SYMBOL_DEFINITION CommonCertificateAttributes */ /** * @summary CommonCertificateAttributes * @description * * ### ASN.1 Definition: * * ```asn1 * CommonCertificateAttributes ::= SEQUENCE { * iD Identifier, * authority BOOLEAN DEFAULT FALSE, * identifier CredentialIdentifier{{KeyIdentifiers}} OPTIONAL, * certHash [0] OOBCertHash OPTIONAL, * ..., * trustedUsage [1] Usage OPTIONAL, * identifiers [2] SEQUENCE OF CredentialIdentifier{{KeyIdentifiers}} OPTIONAL, * implicitTrust [3] BOOLEAN DEFAULT FALSE * } * ``` * * @class */ class CommonCertificateAttributes { constructor( /** * @summary `iD`. * @public * @readonly */ iD, /** * @summary `authority`. * @public * @readonly */ authority, /** * @summary `identifier`. * @public * @readonly */ identifier, /** * @summary `certHash`. * @public * @readonly */ certHash, /** * @summary `trustedUsage`. * @public * @readonly */ trustedUsage, /** * @summary `identifiers`. * @public * @readonly */ identifiers, /** * @summary `implicitTrust`. * @public * @readonly */ implicitTrust, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.iD = iD; this.authority = authority; this.identifier = identifier; this.certHash = certHash; this.trustedUsage = trustedUsage; this.identifiers = identifiers; this.implicitTrust = implicitTrust; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a CommonCertificateAttributes * @description * * This takes an `object` and converts it to a `CommonCertificateAttributes`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `CommonCertificateAttributes`. * @returns {CommonCertificateAttributes} */ static _from_object(_o) { return new CommonCertificateAttributes(_o.iD, _o.authority, _o.identifier, _o.certHash, _o.trustedUsage, _o.identifiers, _o.implicitTrust, _o._unrecognizedExtensionsList); } /** * @summary Getter that returns the default value for `authority`. * @public * @static * @method */ static get _default_value_for_authority() { return false; } /** * @summary Getter that returns the default value for `implicitTrust`. * @public * @static * @method */ static get _default_value_for_implicitTrust() { return false; } } exports.CommonCertificateAttributes = CommonCertificateAttributes; /* END_OF_SYMBOL_DEFINITION CommonCertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CommonCertificateAttributes */ /** * @summary The Leading Root Component Types of CommonCertificateAttributes * @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_CommonCertificateAttributes = [ new $.ComponentSpec("iD", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), new $.ComponentSpec("authority", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 1), undefined, undefined), new $.ComponentSpec("identifier", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("certHash", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CommonCertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CommonCertificateAttributes */ /** * @summary The Trailing Root Component Types of CommonCertificateAttributes * @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_CommonCertificateAttributes = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CommonCertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CommonCertificateAttributes */ /** * @summary The Extension Addition Component Types of CommonCertificateAttributes * @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_CommonCertificateAttributes = [ new $.ComponentSpec("trustedUsage", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), new $.ComponentSpec("identifiers", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 2), undefined, undefined), new $.ComponentSpec("implicitTrust", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 3), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CommonCertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_CommonCertificateAttributes */ let _cached_decoder_for_CommonCertificateAttributes = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_CommonCertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _decode_CommonCertificateAttributes */ /** * @summary Decodes an ASN.1 element into a(n) CommonCertificateAttributes * @function * @param {_Element} el The element being decoded. * @returns {CommonCertificateAttributes} The decoded data structure. */ function _decode_CommonCertificateAttributes(el) { if (!_cached_decoder_for_CommonCertificateAttributes) { _cached_decoder_for_CommonCertificateAttributes = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let iD; let authority = CommonCertificateAttributes._default_value_for_authority; let identifier; let certHash; let trustedUsage; let identifiers; let implicitTrust = CommonCertificateAttributes._default_value_for_implicitTrust; let _unrecognizedExtensionsList = []; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { iD: (_el) => { iD = Identifier_ta_1._decode_Identifier(_el); }, authority: (_el) => { authority = $._decodeBoolean(_el); }, identifier: (_el) => { identifier = CredentialIdentifier_ta_1._decode_CredentialIdentifier(_el); }, certHash: (_el) => { certHash = $._decode_implicit(() => OOBCertHash_ta_1._decode_OOBCertHash)(_el); }, trustedUsage: (_el) => { trustedUsage = $._decode_implicit(() => Usage_ta_1._decode_Usage)(_el); }, identifiers: (_el) => { identifiers = $._decode_implicit(() => $._decodeSequenceOf(() => CredentialIdentifier_ta_1._decode_CredentialIdentifier))(_el); }, implicitTrust: (_el) => { implicitTrust = $._decode_implicit(() => $._decodeBoolean)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_CommonCertificateAttributes, exports._extension_additions_list_spec_for_CommonCertificateAttributes, exports._root_component_type_list_2_spec_for_CommonCertificateAttributes, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new CommonCertificateAttributes( /* SEQUENCE_CONSTRUCTOR_CALL */ iD, authority, identifier, certHash, trustedUsage, identifiers, implicitTrust, _unrecognizedExtensionsList); }; } return _cached_decoder_for_CommonCertificateAttributes(el); } exports._decode_CommonCertificateAttributes = _decode_CommonCertificateAttributes; /* END_OF_SYMBOL_DEFINITION _decode_CommonCertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_CommonCertificateAttributes */ let _cached_encoder_for_CommonCertificateAttributes = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_CommonCertificateAttributes */ /* START_OF_SYMBOL_DEFINITION _encode_CommonCertificateAttributes */ /** * @summary Encodes a(n) CommonCertificateAttributes 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 CommonCertificateAttributes, encoded as an ASN.1 Element. */ function _encode_CommonCertificateAttributes(value, elGetter) { if (!_cached_encoder_for_CommonCertificateAttributes) { _cached_encoder_for_CommonCertificateAttributes = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ Identifier_ta_1._encode_Identifier(value.iD, $.BER), /* IF_DEFAULT */ value.authority === undefined || $.deepEq(value.authority, CommonCertificateAttributes._default_value_for_authority) ? undefined : $._encodeBoolean(value.authority, $.BER), /* IF_ABSENT */ value.identifier === undefined ? undefined : CredentialIdentifier_ta_1._encode_CredentialIdentifier(value.identifier, $.BER), /* IF_ABSENT */ value.certHash === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => OOBCertHash_ta_1._encode_OOBCertHash, $.BER)(value.certHash, $.BER), ], [ /* IF_ABSENT */ value.trustedUsage === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => Usage_ta_1._encode_Usage, $.BER)(value.trustedUsage, $.BER), /* IF_ABSENT */ value.identifiers === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 2, () => $._encodeSequenceOf(() => CredentialIdentifier_ta_1._encode_CredentialIdentifier, $.BER), $.BER)(value.identifiers, $.BER), /* IF_DEFAULT */ value.implicitTrust === undefined || $.deepEq(value.implicitTrust, CommonCertificateAttributes._default_value_for_implicitTrust) ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 3, () => $._encodeBoolean, $.BER)(value.implicitTrust, $.BER), ], value._unrecognizedExtensionsList ? value._unrecognizedExtensionsList : []) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_CommonCertificateAttributes(value, elGetter); } exports._encode_CommonCertificateAttributes = _encode_CommonCertificateAttributes; /* END_OF_SYMBOL_DEFINITION _encode_CommonCertificateAttributes */ /* eslint-enable */ //# sourceMappingURL=CommonCertificateAttributes.ta.js.map