UNPKG

@wildboar/ocsp

Version:
133 lines (132 loc) 4.49 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; import { _decode_CRLReason, _encode_CRLReason, } from "@wildboar/pki-stub"; /** * @summary RevokedInfo * @description * * ### ASN.1 Definition: * * ```asn1 * RevokedInfo ::= SEQUENCE { * revocationTime GeneralizedTime, * revocationReason [0] EXPLICIT CRLReason OPTIONAL } * ``` * */ export class RevokedInfo { revocationTime; revocationReason; constructor( /** * @summary `revocationTime`. * @public * @readonly */ revocationTime, /** * @summary `revocationReason`. * @public * @readonly */ revocationReason) { this.revocationTime = revocationTime; this.revocationReason = revocationReason; } /** * @summary Restructures an object into a RevokedInfo * @description * * This takes an `object` and converts it to a `RevokedInfo`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `RevokedInfo`. * @returns {RevokedInfo} */ static _from_object(_o) { return new RevokedInfo(_o.revocationTime, _o.revocationReason); } } /** * @summary The Leading Root Component Types of RevokedInfo * @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_RevokedInfo = [ new $.ComponentSpec("revocationTime", false, $.hasTag(_TagClass.universal, 24)), new $.ComponentSpec("revocationReason", true, $.hasTag(_TagClass.context, 0)), ]; /** * @summary The Trailing Root Component Types of RevokedInfo * @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_RevokedInfo = []; /** * @summary The Extension Addition Component Types of RevokedInfo * @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_RevokedInfo = []; let _cached_decoder_for_RevokedInfo = null; /** * @summary Decodes an ASN.1 element into a(n) RevokedInfo * @function * @param {_Element} el The element being decoded. * @returns {RevokedInfo} The decoded data structure. */ export function _decode_RevokedInfo(el) { if (!_cached_decoder_for_RevokedInfo) { _cached_decoder_for_RevokedInfo = function (el) { let revocationTime; let revocationReason; const callbacks = { revocationTime: (_el) => { revocationTime = $._decodeGeneralizedTime(_el); }, revocationReason: (_el) => { revocationReason = $._decode_explicit(() => _decode_CRLReason)(_el); }, }; $._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_RevokedInfo, _extension_additions_list_spec_for_RevokedInfo, _root_component_type_list_2_spec_for_RevokedInfo, undefined); return new RevokedInfo(revocationTime, revocationReason); }; } return _cached_decoder_for_RevokedInfo(el); } let _cached_encoder_for_RevokedInfo = null; /** * @summary Encodes a(n) RevokedInfo 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 RevokedInfo, encoded as an ASN.1 Element. */ export function _encode_RevokedInfo(value, elGetter) { if (!_cached_encoder_for_RevokedInfo) { _cached_encoder_for_RevokedInfo = function (value) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeGeneralizedTime(value.revocationTime, $.DER), /* IF_ABSENT */ value.revocationReason === undefined ? undefined : $._encode_explicit(_TagClass.context, 0, () => _encode_CRLReason, $.DER)(value.revocationReason, $.DER), ]) .filter((c) => !!c), $.DER); }; } return _cached_encoder_for_RevokedInfo(value, elGetter); } /* eslint-enable */