@wildboar/pki-stub
Version:
X.510 PKI-Stub ASN.1 data structures in TypeScript
146 lines • 4.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_Validity = exports._decode_Validity = exports._extension_additions_list_spec_for_Validity = exports._root_component_type_list_2_spec_for_Validity = exports._root_component_type_list_1_spec_for_Validity = exports.Validity = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const Time_ta_1 = require("../PKI-Stub/Time.ta");
/* START_OF_SYMBOL_DEFINITION Validity */
/**
* @summary Validity
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* Validity ::= SEQUENCE {
* notBefore Time,
* notAfter Time,
* ... }
* ```
*
* @class
*/
class Validity {
constructor(
/**
* @summary `notBefore`.
* @public
* @readonly
*/
notBefore,
/**
* @summary `notAfter`.
* @public
* @readonly
*/
notAfter,
/**
* @summary Extensions that are not recognized.
* @public
* @readonly
*/
_unrecognizedExtensionsList = []) {
this.notBefore = notBefore;
this.notAfter = notAfter;
this._unrecognizedExtensionsList = _unrecognizedExtensionsList;
}
/**
* @summary Restructures an object into a Validity
* @description
*
* This takes an `object` and converts it to a `Validity`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `Validity`.
* @returns {Validity}
*/
static _from_object(_o) {
return new Validity(_o.notBefore, _o.notAfter, _o._unrecognizedExtensionsList);
}
}
exports.Validity = Validity;
/* END_OF_SYMBOL_DEFINITION Validity */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_Validity */
/**
* @summary The Leading Root Component Types of Validity
* @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_Validity = [
new $.ComponentSpec("notBefore", false, $.hasAnyTag, undefined, undefined),
new $.ComponentSpec("notAfter", false, $.hasAnyTag, undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_Validity */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_Validity */
/**
* @summary The Trailing Root Component Types of Validity
* @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_Validity = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_Validity */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_Validity */
/**
* @summary The Extension Addition Component Types of Validity
* @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_Validity = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_Validity */
/* START_OF_SYMBOL_DEFINITION _decode_Validity */
/**
* @summary Decodes an ASN.1 element into a(n) Validity
* @function
* @param {_Element} el The element being decoded.
* @returns {Validity} The decoded data structure.
*/
function _decode_Validity(el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("Validity contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "notBefore";
sequence[1].name = "notAfter";
let notBefore;
let notAfter;
notBefore = Time_ta_1._decode_Time(sequence[0]);
notAfter = Time_ta_1._decode_Time(sequence[1]);
return new Validity(notBefore, notAfter, sequence.slice(2));
}
exports._decode_Validity = _decode_Validity;
/* END_OF_SYMBOL_DEFINITION _decode_Validity */
/* START_OF_SYMBOL_DEFINITION _encode_Validity */
/**
* @summary Encodes a(n) Validity 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 Validity, encoded as an ASN.1 Element.
*/
function _encode_Validity(value, elGetter) {
var _a;
const components = [
/* REQUIRED */ Time_ta_1._encode_Time(value.notBefore, $.BER),
/* REQUIRED */ Time_ta_1._encode_Time(value.notAfter, $.BER),
...(_a = value._unrecognizedExtensionsList) !== null && _a !== void 0 ? _a : [],
];
return $._encodeSequence(components, $.BER);
}
exports._encode_Validity = _encode_Validity;
/* END_OF_SYMBOL_DEFINITION _encode_Validity */
/* eslint-enable */
//# sourceMappingURL=Validity.ta.js.map