UNPKG

@wildboar/pki-stub

Version:
207 lines 10.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_ObjectDigestInfo = exports._decode_ObjectDigestInfo = exports._extension_additions_list_spec_for_ObjectDigestInfo = exports._root_component_type_list_2_spec_for_ObjectDigestInfo = exports._root_component_type_list_1_spec_for_ObjectDigestInfo = exports.ObjectDigestInfo = exports._encode_ObjectDigestInfo_digestedObjectType = exports._decode_ObjectDigestInfo_digestedObjectType = exports.otherObjectTypes = exports.ObjectDigestInfo_digestedObjectType_otherObjectTypes = exports.publicKeyCert = exports.ObjectDigestInfo_digestedObjectType_publicKeyCert = exports.publicKey = exports.ObjectDigestInfo_digestedObjectType_publicKey = exports._enum_for_ObjectDigestInfo_digestedObjectType = exports.ObjectDigestInfo_digestedObjectType = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const ObjectDigestInfo_digestedObjectType_ta_1 = require("../PKI-Stub/ObjectDigestInfo-digestedObjectType.ta"); var ObjectDigestInfo_digestedObjectType_ta_2 = require("../PKI-Stub/ObjectDigestInfo-digestedObjectType.ta"); Object.defineProperty(exports, "ObjectDigestInfo_digestedObjectType", { enumerable: true, get: function () { return ObjectDigestInfo_digestedObjectType_ta_2.ObjectDigestInfo_digestedObjectType; } }); Object.defineProperty(exports, "_enum_for_ObjectDigestInfo_digestedObjectType", { enumerable: true, get: function () { return ObjectDigestInfo_digestedObjectType_ta_2._enum_for_ObjectDigestInfo_digestedObjectType; } }); Object.defineProperty(exports, "ObjectDigestInfo_digestedObjectType_publicKey", { enumerable: true, get: function () { return ObjectDigestInfo_digestedObjectType_ta_2.ObjectDigestInfo_digestedObjectType_publicKey; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "publicKey", { enumerable: true, get: function () { return ObjectDigestInfo_digestedObjectType_ta_2.publicKey; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "ObjectDigestInfo_digestedObjectType_publicKeyCert", { enumerable: true, get: function () { return ObjectDigestInfo_digestedObjectType_ta_2.ObjectDigestInfo_digestedObjectType_publicKeyCert; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "publicKeyCert", { enumerable: true, get: function () { return ObjectDigestInfo_digestedObjectType_ta_2.publicKeyCert; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "ObjectDigestInfo_digestedObjectType_otherObjectTypes", { enumerable: true, get: function () { return ObjectDigestInfo_digestedObjectType_ta_2.ObjectDigestInfo_digestedObjectType_otherObjectTypes; } }); /* IMPORTED_LONG_ENUMERATION_ITEM */ Object.defineProperty(exports, "otherObjectTypes", { enumerable: true, get: function () { return ObjectDigestInfo_digestedObjectType_ta_2.otherObjectTypes; } }); /* IMPORTED_SHORT_ENUMERATION_ITEM */ Object.defineProperty(exports, "_decode_ObjectDigestInfo_digestedObjectType", { enumerable: true, get: function () { return ObjectDigestInfo_digestedObjectType_ta_2._decode_ObjectDigestInfo_digestedObjectType; } }); Object.defineProperty(exports, "_encode_ObjectDigestInfo_digestedObjectType", { enumerable: true, get: function () { return ObjectDigestInfo_digestedObjectType_ta_2._encode_ObjectDigestInfo_digestedObjectType; } }); const AlgorithmIdentifier_ta_1 = require("../PKI-Stub/AlgorithmIdentifier.ta"); /* START_OF_SYMBOL_DEFINITION ObjectDigestInfo */ /** * @summary ObjectDigestInfo * @description * * ### ASN.1 Definition: * * ```asn1 * ObjectDigestInfo ::= SEQUENCE { * digestedObjectType ENUMERATED { * publicKey (0), * publicKeyCert (1), * otherObjectTypes (2)}, * otherObjectTypeID OBJECT IDENTIFIER OPTIONAL, * digestAlgorithm AlgorithmIdentifier{{SupportedAlgorithms}}, * objectDigest BIT STRING, * ... } * ``` * * @class */ class ObjectDigestInfo { constructor( /** * @summary `digestedObjectType`. * @public * @readonly */ digestedObjectType, /** * @summary `otherObjectTypeID`. * @public * @readonly */ otherObjectTypeID, /** * @summary `digestAlgorithm`. * @public * @readonly */ digestAlgorithm, /** * @summary `objectDigest`. * @public * @readonly */ objectDigest, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.digestedObjectType = digestedObjectType; this.otherObjectTypeID = otherObjectTypeID; this.digestAlgorithm = digestAlgorithm; this.objectDigest = objectDigest; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a ObjectDigestInfo * @description * * This takes an `object` and converts it to a `ObjectDigestInfo`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `ObjectDigestInfo`. * @returns {ObjectDigestInfo} */ static _from_object(_o) { return new ObjectDigestInfo(_o.digestedObjectType, _o.otherObjectTypeID, _o.digestAlgorithm, _o.objectDigest, _o._unrecognizedExtensionsList); } } exports.ObjectDigestInfo = ObjectDigestInfo; /** * @summary The enum used as the type of the component `digestedObjectType` * @public * @static */ ObjectDigestInfo._enum_for_digestedObjectType = ObjectDigestInfo_digestedObjectType_ta_1._enum_for_ObjectDigestInfo_digestedObjectType; /* END_OF_SYMBOL_DEFINITION ObjectDigestInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ObjectDigestInfo */ /** * @summary The Leading Root Component Types of ObjectDigestInfo * @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_ObjectDigestInfo = [ new $.ComponentSpec("digestedObjectType", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 10), undefined, undefined), new $.ComponentSpec("otherObjectTypeID", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("digestAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("objectDigest", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ObjectDigestInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ObjectDigestInfo */ /** * @summary The Trailing Root Component Types of ObjectDigestInfo * @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_ObjectDigestInfo = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ObjectDigestInfo */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ObjectDigestInfo */ /** * @summary The Extension Addition Component Types of ObjectDigestInfo * @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_ObjectDigestInfo = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ObjectDigestInfo */ /* START_OF_SYMBOL_DEFINITION _decode_ObjectDigestInfo */ /** * @summary Decodes an ASN.1 element into a(n) ObjectDigestInfo * @function * @param {_Element} el The element being decoded. * @returns {ObjectDigestInfo} The decoded data structure. */ function _decode_ObjectDigestInfo(el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let digestedObjectType; let otherObjectTypeID; let digestAlgorithm; let objectDigest; let _unrecognizedExtensionsList = []; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { digestedObjectType: (_el) => { digestedObjectType = ObjectDigestInfo_digestedObjectType_ta_1._decode_ObjectDigestInfo_digestedObjectType(_el); }, otherObjectTypeID: (_el) => { otherObjectTypeID = $._decodeObjectIdentifier(_el); }, digestAlgorithm: (_el) => { digestAlgorithm = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(_el); }, objectDigest: (_el) => { objectDigest = $._decodeBitString(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_ObjectDigestInfo, exports._extension_additions_list_spec_for_ObjectDigestInfo, exports._root_component_type_list_2_spec_for_ObjectDigestInfo, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new ObjectDigestInfo( /* SEQUENCE_CONSTRUCTOR_CALL */ digestedObjectType, otherObjectTypeID, digestAlgorithm, objectDigest, _unrecognizedExtensionsList); } exports._decode_ObjectDigestInfo = _decode_ObjectDigestInfo; /* END_OF_SYMBOL_DEFINITION _decode_ObjectDigestInfo */ /* START_OF_SYMBOL_DEFINITION _encode_ObjectDigestInfo */ /** * @summary Encodes a(n) ObjectDigestInfo 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 ObjectDigestInfo, encoded as an ASN.1 Element. */ function _encode_ObjectDigestInfo(value, elGetter) { var _a; const components = [ /* REQUIRED */ ObjectDigestInfo_digestedObjectType_ta_1._encode_ObjectDigestInfo_digestedObjectType(value.digestedObjectType, $.BER), ...(_a = value._unrecognizedExtensionsList) !== null && _a !== void 0 ? _a : [], ]; if (value.otherObjectTypeID) { const c = ObjectDigestInfo_digestedObjectType_ta_1._encode_ObjectDigestInfo_digestedObjectType(value.digestedObjectType, $.BER); components.push(c); } components.push(AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.digestAlgorithm, $.BER)); components.push($._encodeBitString(value.objectDigest, $.BER)); components.push(...value._unrecognizedExtensionsList); return $._encodeSequence(components, $.BER); } exports._encode_ObjectDigestInfo = _encode_ObjectDigestInfo; /* END_OF_SYMBOL_DEFINITION _encode_ObjectDigestInfo */ /* eslint-enable */ //# sourceMappingURL=ObjectDigestInfo.ta.js.map