@wildboar/pki-stub
Version:
X.510 PKI-Stub ASN.1 data structures in TypeScript
264 lines (263 loc) • 11 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, } from "@wildboar/asn1";
import * as $ from "@wildboar/asn1/functional";
import { _decode_AdministrationDomainName, _encode_AdministrationDomainName, } from "../PkiPmiExternalDataTypes/AdministrationDomainName.ta.mjs";
import { _decode_CountryName, _encode_CountryName, } from "../PkiPmiExternalDataTypes/CountryName.ta.mjs";
import { _decode_NetworkAddress, _encode_NetworkAddress, } from "../PkiPmiExternalDataTypes/NetworkAddress.ta.mjs";
import { _decode_NumericUserIdentifier, _encode_NumericUserIdentifier, } from "../PkiPmiExternalDataTypes/NumericUserIdentifier.ta.mjs";
import { _decode_OrganizationalUnitNames, _encode_OrganizationalUnitNames, } from "../PkiPmiExternalDataTypes/OrganizationalUnitNames.ta.mjs";
import { _decode_OrganizationName, _encode_OrganizationName, } from "../PkiPmiExternalDataTypes/OrganizationName.ta.mjs";
import { _decode_PersonalName, _encode_PersonalName, } from "../PkiPmiExternalDataTypes/PersonalName.ta.mjs";
import { _decode_PrivateDomainName, _encode_PrivateDomainName, } from "../PkiPmiExternalDataTypes/PrivateDomainName.ta.mjs";
import { _decode_TerminalIdentifier, _encode_TerminalIdentifier, } from "../PkiPmiExternalDataTypes/TerminalIdentifier.ta.mjs";
/**
* @summary BuiltInStandardAttributes
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* BuiltInStandardAttributes ::= SEQUENCE {
* country-name CountryName OPTIONAL,
* administration-domain-name AdministrationDomainName OPTIONAL,
* network-address [0] NetworkAddress OPTIONAL,
* -- see also extended-network-address
* terminal-identifier [1] TerminalIdentifier OPTIONAL,
* private-domain-name [2] PrivateDomainName OPTIONAL,
* organization-name [3] OrganizationName OPTIONAL,
* -- see also teletex-organization-name
* numeric-user-identifier [4] NumericUserIdentifier OPTIONAL,
* personal-name [5] PersonalName OPTIONAL,
* -- see also teletex-personal-name
* organizational-unit-names [6] OrganizationalUnitNames OPTIONAL
* -- see also teletex-organizational-unit-names --}
* ```
*
*/
export class BuiltInStandardAttributes {
country_name;
administration_domain_name;
network_address;
terminal_identifier;
private_domain_name;
organization_name;
numeric_user_identifier;
personal_name;
organizational_unit_names;
constructor(
/**
* @summary `country_name`.
* @public
* @readonly
*/
country_name,
/**
* @summary `administration_domain_name`.
* @public
* @readonly
*/
administration_domain_name,
/**
* @summary `network_address`.
* @public
* @readonly
*/
network_address,
/**
* @summary `terminal_identifier`.
* @public
* @readonly
*/
terminal_identifier,
/**
* @summary `private_domain_name`.
* @public
* @readonly
*/
private_domain_name,
/**
* @summary `organization_name`.
* @public
* @readonly
*/
organization_name,
/**
* @summary `numeric_user_identifier`.
* @public
* @readonly
*/
numeric_user_identifier,
/**
* @summary `personal_name`.
* @public
* @readonly
*/
personal_name,
/**
* @summary `organizational_unit_names`.
* @public
* @readonly
*/
organizational_unit_names) {
this.country_name = country_name;
this.administration_domain_name = administration_domain_name;
this.network_address = network_address;
this.terminal_identifier = terminal_identifier;
this.private_domain_name = private_domain_name;
this.organization_name = organization_name;
this.numeric_user_identifier = numeric_user_identifier;
this.personal_name = personal_name;
this.organizational_unit_names = organizational_unit_names;
}
/**
* @summary Restructures an object into a BuiltInStandardAttributes
* @description
*
* This takes an `object` and converts it to a `BuiltInStandardAttributes`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `BuiltInStandardAttributes`.
* @returns {BuiltInStandardAttributes}
*/
static _from_object(_o) {
return new BuiltInStandardAttributes(_o.country_name, _o.administration_domain_name, _o.network_address, _o.terminal_identifier, _o.private_domain_name, _o.organization_name, _o.numeric_user_identifier, _o.personal_name, _o.organizational_unit_names);
}
}
/**
* @summary The Leading Root Component Types of BuiltInStandardAttributes
* @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_BuiltInStandardAttributes = [
new $.ComponentSpec("country-name", true, $.hasTag(_TagClass.application, 1)),
new $.ComponentSpec("administration-domain-name", true, $.hasTag(_TagClass.application, 2)),
new $.ComponentSpec("network-address", true, $.hasTag(_TagClass.context, 0)),
new $.ComponentSpec("terminal-identifier", true, $.hasTag(_TagClass.context, 1)),
new $.ComponentSpec("private-domain-name", true, $.hasTag(_TagClass.context, 2)),
new $.ComponentSpec("organization-name", true, $.hasTag(_TagClass.context, 3)),
new $.ComponentSpec("numeric-user-identifier", true, $.hasTag(_TagClass.context, 4)),
new $.ComponentSpec("personal-name", true, $.hasTag(_TagClass.context, 5)),
new $.ComponentSpec("organizational-unit-names", true, $.hasTag(_TagClass.context, 6)),
];
/**
* @summary The Trailing Root Component Types of BuiltInStandardAttributes
* @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_BuiltInStandardAttributes = [];
/**
* @summary The Extension Addition Component Types of BuiltInStandardAttributes
* @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_BuiltInStandardAttributes = [];
/**
* @summary Decodes an ASN.1 element into a(n) BuiltInStandardAttributes
* @function
* @param {_Element} el The element being decoded.
* @returns {BuiltInStandardAttributes} The decoded data structure.
*/
export function _decode_BuiltInStandardAttributes(el) {
let country_name;
let administration_domain_name;
let network_address;
let terminal_identifier;
let private_domain_name;
let organization_name;
let numeric_user_identifier;
let personal_name;
let organizational_unit_names;
const callbacks = {
"country-name": (_el) => {
country_name = _decode_CountryName(_el);
},
"administration-domain-name": (_el) => {
administration_domain_name =
_decode_AdministrationDomainName(_el);
},
"network-address": (_el) => {
network_address = $._decode_explicit(() => _decode_NetworkAddress)(_el);
},
"terminal-identifier": (_el) => {
terminal_identifier =
$._decode_explicit(() => _decode_TerminalIdentifier)(_el);
},
"private-domain-name": (_el) => {
private_domain_name = $._decode_explicit(() => _decode_PrivateDomainName)(_el);
},
"organization-name": (_el) => {
organization_name = $._decode_explicit(() => _decode_OrganizationName)(_el);
},
"numeric-user-identifier": (_el) => {
numeric_user_identifier =
$._decode_explicit(() => _decode_NumericUserIdentifier)(_el);
},
"personal-name": (_el) => {
personal_name = $._decode_explicit(() => _decode_PersonalName)(_el);
},
"organizational-unit-names": (_el) => {
organizational_unit_names =
$._decode_explicit(() => _decode_OrganizationalUnitNames)(_el);
},
};
$._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_BuiltInStandardAttributes, _extension_additions_list_spec_for_BuiltInStandardAttributes, _root_component_type_list_2_spec_for_BuiltInStandardAttributes, undefined);
return new BuiltInStandardAttributes(country_name, administration_domain_name, network_address, terminal_identifier, private_domain_name, organization_name, numeric_user_identifier, personal_name, organizational_unit_names);
}
/**
* @summary Encodes a(n) BuiltInStandardAttributes 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 BuiltInStandardAttributes, encoded as an ASN.1 Element.
*/
export function _encode_BuiltInStandardAttributes(value, _elGetter) {
const components = [];
if (value.country_name) {
components.push(_encode_CountryName(value.country_name, $.BER));
}
if (value.administration_domain_name) {
const c = _encode_AdministrationDomainName(value.administration_domain_name, $.BER);
components.push(c);
}
if (value.network_address) {
const c = $._encode_explicit(_TagClass.context, 0, () => _encode_NetworkAddress, $.BER)(value.network_address, $.BER);
components.push(c);
}
if (value.terminal_identifier) {
const c = $._encode_explicit(_TagClass.context, 1, () => _encode_TerminalIdentifier, $.BER)(value.terminal_identifier, $.BER);
components.push(c);
}
if (value.private_domain_name) {
const c = $._encode_explicit(_TagClass.context, 2, () => _encode_PrivateDomainName, $.BER)(value.private_domain_name, $.BER);
components.push(c);
}
if (value.organization_name) {
const c = $._encode_explicit(_TagClass.context, 3, () => _encode_OrganizationName, $.BER)(value.organization_name, $.BER);
components.push(c);
}
if (value.numeric_user_identifier) {
const c = $._encode_explicit(_TagClass.context, 4, () => _encode_NumericUserIdentifier, $.BER)(value.numeric_user_identifier, $.BER);
components.push(c);
}
if (value.personal_name) {
const c = $._encode_explicit(_TagClass.context, 5, () => _encode_PersonalName, $.BER)(value.personal_name, $.BER);
components.push(c);
}
if (value.organizational_unit_names?.length) {
const c = $._encode_explicit(_TagClass.context, 6, () => _encode_OrganizationalUnitNames, $.BER)(value.organizational_unit_names, $.BER);
components.push(c);
}
return $._encodeSequence(components, $.BER);
}
/* eslint-enable */