@wildboar/ocsp
Version:
Online Certificate Status Protocol PDUs in TypeScript
133 lines (132 loc) • 4.31 kB
JavaScript
/* eslint-disable */
import { ASN1ConstructionError as _ConstructionError, ASN1TagClass as _TagClass, } from "@wildboar/asn1";
import * as $ from "@wildboar/asn1/functional";
/**
* @summary ResponseBytes
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* ResponseBytes ::= SEQUENCE {
* responseType RESPONSE.
* &id ({ResponseSet}),
* response OCTET STRING (CONTAINING RESPONSE.
* &Type({ResponseSet}{@responseType}))}
* ```
*
*/
export class ResponseBytes {
responseType;
response;
constructor(
/**
* @summary `responseType`.
* @public
* @readonly
*/
responseType,
/**
* @summary `response`.
* @public
* @readonly
*/
response) {
this.responseType = responseType;
this.response = response;
}
/**
* @summary Restructures an object into a ResponseBytes
* @description
*
* This takes an `object` and converts it to a `ResponseBytes`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `ResponseBytes`.
* @returns {ResponseBytes}
*/
static _from_object(_o) {
return new ResponseBytes(_o.responseType, _o.response);
}
}
/**
* @summary The Leading Root Component Types of ResponseBytes
* @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_ResponseBytes = [
new $.ComponentSpec("responseType", false, $.hasTag(_TagClass.universal, 6)),
new $.ComponentSpec("response", false, $.hasTag(_TagClass.universal, 4)),
];
/**
* @summary The Trailing Root Component Types of ResponseBytes
* @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_ResponseBytes = [];
/**
* @summary The Extension Addition Component Types of ResponseBytes
* @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_ResponseBytes = [];
let _cached_decoder_for_ResponseBytes = null;
/**
* @summary Decodes an ASN.1 element into a(n) ResponseBytes
* @function
* @param {_Element} el The element being decoded.
* @returns {ResponseBytes} The decoded data structure.
*/
export function _decode_ResponseBytes(el) {
if (!_cached_decoder_for_ResponseBytes) {
_cached_decoder_for_ResponseBytes = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new _ConstructionError("ResponseBytes contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "responseType";
sequence[1].name = "response";
let responseType;
let response;
responseType = $._decodeObjectIdentifier(sequence[0]);
response = $._decodeOctetString(sequence[1]);
return new ResponseBytes(responseType, response);
};
}
return _cached_decoder_for_ResponseBytes(el);
}
let _cached_encoder_for_ResponseBytes = null;
/**
* @summary Encodes a(n) ResponseBytes 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 ResponseBytes, encoded as an ASN.1 Element.
*/
export function _encode_ResponseBytes(value, elGetter) {
if (!_cached_encoder_for_ResponseBytes) {
_cached_encoder_for_ResponseBytes = function (value) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ $._encodeObjectIdentifier(value.responseType, $.DER),
/* REQUIRED */ $._encodeOctetString(value.response, $.DER),
])
.filter((c) => !!c), $.DER);
};
}
return _cached_encoder_for_ResponseBytes(value, elGetter);
}
/* eslint-enable */