UNPKG

@wildboar/ocsp

Version:
151 lines (150 loc) 4.83 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; /** * @summary CrlID * @description * * ### ASN.1 Definition: * * ```asn1 * CrlID ::= SEQUENCE { * crlUrl [0] EXPLICIT IA5String OPTIONAL, * crlNum [1] EXPLICIT INTEGER OPTIONAL, * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL } * ``` * */ export class CrlID { crlUrl; crlNum; crlTime; constructor( /** * @summary `crlUrl`. * @public * @readonly */ crlUrl, /** * @summary `crlNum`. * @public * @readonly */ crlNum, /** * @summary `crlTime`. * @public * @readonly */ crlTime) { this.crlUrl = crlUrl; this.crlNum = crlNum; this.crlTime = crlTime; } /** * @summary Restructures an object into a CrlID * @description * * This takes an `object` and converts it to a `CrlID`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `CrlID`. * @returns {CrlID} */ static _from_object(_o) { return new CrlID(_o.crlUrl, _o.crlNum, _o.crlTime); } } /** * @summary The Leading Root Component Types of CrlID * @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 */ export const _root_component_type_list_1_spec_for_CrlID = [ new $.ComponentSpec("crlUrl", true, $.hasTag(_TagClass.context, 0)), new $.ComponentSpec("crlNum", true, $.hasTag(_TagClass.context, 1)), new $.ComponentSpec("crlTime", true, $.hasTag(_TagClass.context, 2)), ]; /** * @summary The Trailing Root Component Types of CrlID * @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 */ export const _root_component_type_list_2_spec_for_CrlID = []; /** * @summary The Extension Addition Component Types of CrlID * @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 */ export const _extension_additions_list_spec_for_CrlID = []; let _cached_decoder_for_CrlID = null; /** * @summary Decodes an ASN.1 element into a(n) CrlID * @function * @param {_Element} el The element being decoded. * @returns {CrlID} The decoded data structure. */ export function _decode_CrlID(el) { if (!_cached_decoder_for_CrlID) { _cached_decoder_for_CrlID = function (el) { let crlUrl; let crlNum; let crlTime; const callbacks = { crlUrl: (_el) => { crlUrl = $._decode_explicit(() => $._decodeIA5String)(_el); }, crlNum: (_el) => { crlNum = $._decode_explicit(() => $._decodeInteger)(_el); }, crlTime: (_el) => { crlTime = $._decode_explicit(() => $._decodeGeneralizedTime)(_el); }, }; $._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_CrlID, _extension_additions_list_spec_for_CrlID, _root_component_type_list_2_spec_for_CrlID, undefined); return new CrlID(crlUrl, crlNum, crlTime); }; } return _cached_decoder_for_CrlID(el); } let _cached_encoder_for_CrlID = null; /** * @summary Encodes a(n) CrlID into an ASN.1 Element. * @function * @param value The element being encoded. * @param elGetter A function that can be used to get new ASN.1 elements. * @returns {_Element} The CrlID, encoded as an ASN.1 Element. */ export function _encode_CrlID(value, elGetter) { if (!_cached_encoder_for_CrlID) { _cached_encoder_for_CrlID = function (value) { return $._encodeSequence([] .concat([ /* IF_ABSENT */ value.crlUrl === undefined ? undefined : $._encode_explicit(_TagClass.context, 0, () => $._encodeIA5String, $.DER)(value.crlUrl, $.DER), /* IF_ABSENT */ value.crlNum === undefined ? undefined : $._encode_explicit(_TagClass.context, 1, () => $._encodeInteger, $.DER)(value.crlNum, $.DER), /* IF_ABSENT */ value.crlTime === undefined ? undefined : $._encode_explicit(_TagClass.context, 2, () => $._encodeGeneralizedTime, $.DER)(value.crlTime, $.DER), ]) .filter((c) => !!c), $.DER); }; } return _cached_encoder_for_CrlID(value, elGetter); } /* eslint-enable */