UNPKG

@wildboar/pki-stub

Version:
118 lines (117 loc) 3.84 kB
/* eslint-disable */ import { ASN1ConstructionError as _ConstructionError, ASN1TagClass as _TagClass, } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; /** * @summary BuiltInDomainDefinedAttribute * @description * * ### ASN.1 Definition: * * ```asn1 * BuiltInDomainDefinedAttribute ::= SEQUENCE { * type PrintableString(SIZE (1..ub-domain-defined-attribute-type-length)), * value PrintableString(SIZE (1..ub-domain-defined-attribute-value-length)) } * ``` * */ export class BuiltInDomainDefinedAttribute { type_; value; constructor( /** * @summary `type_`. * @public * @readonly */ type_, /** * @summary `value`. * @public * @readonly */ value) { this.type_ = type_; this.value = value; } /** * @summary Restructures an object into a BuiltInDomainDefinedAttribute * @description * * This takes an `object` and converts it to a `BuiltInDomainDefinedAttribute`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `BuiltInDomainDefinedAttribute`. * @returns {BuiltInDomainDefinedAttribute} */ static _from_object(_o) { return new BuiltInDomainDefinedAttribute(_o.type_, _o.value); } } /** * @summary The Leading Root Component Types of BuiltInDomainDefinedAttribute * @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_BuiltInDomainDefinedAttribute = [ new $.ComponentSpec("type", false, $.hasTag(_TagClass.universal, 19)), new $.ComponentSpec("value", false, $.hasTag(_TagClass.universal, 19)), ]; /** * @summary The Trailing Root Component Types of BuiltInDomainDefinedAttribute * @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_BuiltInDomainDefinedAttribute = []; /** * @summary The Extension Addition Component Types of BuiltInDomainDefinedAttribute * @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_BuiltInDomainDefinedAttribute = []; /** * @summary Decodes an ASN.1 element into a(n) BuiltInDomainDefinedAttribute * @function * @param {_Element} el The element being decoded. * @returns {BuiltInDomainDefinedAttribute} The decoded data structure. */ export function _decode_BuiltInDomainDefinedAttribute(el) { const sequence = el.sequence; if (sequence.length < 2) { throw new _ConstructionError("BuiltInDomainDefinedAttribute contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "type"; sequence[1].name = "value"; let type_; let value; type_ = $._decodePrintableString(sequence[0]); value = $._decodePrintableString(sequence[1]); return new BuiltInDomainDefinedAttribute(type_, value); } /** * @summary Encodes a(n) BuiltInDomainDefinedAttribute 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 BuiltInDomainDefinedAttribute, encoded as an ASN.1 Element. */ export function _encode_BuiltInDomainDefinedAttribute(value) { const components = [ $._encodePrintableString(value.type_, $.BER), $._encodePrintableString(value.value, $.BER), ]; return $._encodeSequence(components, $.BER); } /* eslint-enable */