@wildboar/pki-stub
Version:
X.510 PKI-Stub ASN.1 data structures in TypeScript
144 lines (143 loc) • 5.43 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, } from "@wildboar/asn1";
import * as $ from "@wildboar/asn1/functional";
import { _decode_BuiltInDomainDefinedAttributes, _encode_BuiltInDomainDefinedAttributes, } from "../PkiPmiExternalDataTypes/BuiltInDomainDefinedAttributes.ta.mjs";
import { _decode_BuiltInStandardAttributes, _encode_BuiltInStandardAttributes, } from "../PkiPmiExternalDataTypes/BuiltInStandardAttributes.ta.mjs";
import { _decode_ExtensionAttributes, _encode_ExtensionAttributes, } from "../PkiPmiExternalDataTypes/ExtensionAttributes.ta.mjs";
/**
* @summary ORAddress
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* ORAddress ::= SEQUENCE {
* built-in-standard-attributes BuiltInStandardAttributes,
* built-in-domain-defined-attributes BuiltInDomainDefinedAttributes OPTIONAL,
* -- see also teletex-domain-defined-attributes
* extension-attributes ExtensionAttributes OPTIONAL }
* ```
*
*/
export class ORAddress {
built_in_standard_attributes;
built_in_domain_defined_attributes;
extension_attributes;
constructor(
/**
* @summary `built_in_standard_attributes`.
* @public
* @readonly
*/
built_in_standard_attributes,
/**
* @summary `built_in_domain_defined_attributes`.
* @public
* @readonly
*/
built_in_domain_defined_attributes,
/**
* @summary `extension_attributes`.
* @public
* @readonly
*/
extension_attributes) {
this.built_in_standard_attributes = built_in_standard_attributes;
this.built_in_domain_defined_attributes = built_in_domain_defined_attributes;
this.extension_attributes = extension_attributes;
}
/**
* @summary Restructures an object into a ORAddress
* @description
*
* This takes an `object` and converts it to a `ORAddress`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `ORAddress`.
* @returns {ORAddress}
*/
static _from_object(_o) {
return new ORAddress(_o.built_in_standard_attributes, _o.built_in_domain_defined_attributes, _o.extension_attributes);
}
}
/**
* @summary The Leading Root Component Types of ORAddress
* @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_ORAddress = [
new $.ComponentSpec("built-in-standard-attributes", false, $.hasTag(_TagClass.universal, 16)),
new $.ComponentSpec("built-in-domain-defined-attributes", true, $.hasTag(_TagClass.universal, 16)),
new $.ComponentSpec("extension-attributes", true, $.hasTag(_TagClass.universal, 17)),
];
/**
* @summary The Trailing Root Component Types of ORAddress
* @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_ORAddress = [];
/**
* @summary The Extension Addition Component Types of ORAddress
* @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_ORAddress = [];
/**
* @summary Decodes an ASN.1 element into a(n) ORAddress
* @function
* @param {_Element} el The element being decoded.
* @returns {ORAddress} The decoded data structure.
*/
export function _decode_ORAddress(el) {
let built_in_standard_attributes;
let built_in_domain_defined_attributes;
let extension_attributes;
const callbacks = {
"built-in-standard-attributes": (_el) => {
built_in_standard_attributes =
_decode_BuiltInStandardAttributes(_el);
},
"built-in-domain-defined-attributes": (_el) => {
built_in_domain_defined_attributes =
_decode_BuiltInDomainDefinedAttributes(_el);
},
"extension-attributes": (_el) => {
extension_attributes = _decode_ExtensionAttributes(_el);
},
};
$._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_ORAddress, _extension_additions_list_spec_for_ORAddress, _root_component_type_list_2_spec_for_ORAddress, undefined);
return new ORAddress(built_in_standard_attributes, built_in_domain_defined_attributes, extension_attributes);
}
/**
* @summary Encodes a(n) ORAddress 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 ORAddress, encoded as an ASN.1 Element.
*/
export function _encode_ORAddress(value, _elGetter) {
const components = [
/* REQUIRED */ _encode_BuiltInStandardAttributes(value.built_in_standard_attributes, $.BER),
];
if (value.built_in_domain_defined_attributes?.length) {
const c = _encode_BuiltInDomainDefinedAttributes(value.built_in_domain_defined_attributes, $.BER);
components.push(c);
}
if (value.extension_attributes?.length) {
const c = _encode_ExtensionAttributes(value.extension_attributes, $.BER);
components.push(c);
}
return $._encodeSequence(components, $.BER);
}
/* eslint-enable */