@wildboar/pki-stub
Version:
X.510 PKI-Stub ASN.1 data structures in TypeScript
150 lines (149 loc) • 5.22 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, } from "@wildboar/asn1";
import * as $ from "@wildboar/asn1/functional";
import { _decode_TBSCertAVL_entries_Item_idType, _encode_TBSCertAVL_entries_Item_idType, } from "../PKI-Stub/TBSCertAVL-entries-Item-idType.ta.mjs";
import { _decode_Extensions, _encode_Extensions, } from "../PKI-Stub/Extensions.ta.mjs";
import { _decode_ScopeRestrictions, _encode_ScopeRestrictions, } from "../AuthenticationFramework/ScopeRestrictions.ta.mjs";
/**
* @summary TBSCertAVL_entries_Item
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* TBSCertAVL-entries-Item ::= SEQUENCE { -- REMOVED_FROM_UNNESTING -- }
* ```
*
*/
export class TBSCertAVL_entries_Item {
idType;
scope;
entryExtensions;
_unrecognizedExtensionsList;
constructor(
/**
* @summary `idType`.
* @public
* @readonly
*/
idType,
/**
* @summary `scope`.
* @public
* @readonly
*/
scope,
/**
* @summary `entryExtensions`.
* @public
* @readonly
*/
entryExtensions,
/**
* @summary Extensions that are not recognized.
* @public
* @readonly
*/
_unrecognizedExtensionsList = []) {
this.idType = idType;
this.scope = scope;
this.entryExtensions = entryExtensions;
this._unrecognizedExtensionsList = _unrecognizedExtensionsList;
}
/**
* @summary Restructures an object into a TBSCertAVL_entries_Item
* @description
*
* This takes an `object` and converts it to a `TBSCertAVL_entries_Item`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `TBSCertAVL_entries_Item`.
* @returns {TBSCertAVL_entries_Item}
*/
static _from_object(_o) {
return new TBSCertAVL_entries_Item(_o.idType, _o.scope, _o.entryExtensions, _o._unrecognizedExtensionsList);
}
}
/**
* @summary The Leading Root Component Types of TBSCertAVL_entries_Item
* @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_TBSCertAVL_entries_Item = [
new $.ComponentSpec("idType", false, $.hasAnyTag),
new $.ComponentSpec("scope", true, $.hasTag(_TagClass.context, 0)),
new $.ComponentSpec("entryExtensions", true, $.hasTag(_TagClass.context, 1)),
];
/**
* @summary The Trailing Root Component Types of TBSCertAVL_entries_Item
* @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_TBSCertAVL_entries_Item = [];
/**
* @summary The Extension Addition Component Types of TBSCertAVL_entries_Item
* @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_TBSCertAVL_entries_Item = [];
/**
* @summary Decodes an ASN.1 element into a(n) TBSCertAVL_entries_Item
* @function
* @param {_Element} el The element being decoded.
* @returns {TBSCertAVL_entries_Item} The decoded data structure.
*/
export function _decode_TBSCertAVL_entries_Item(el) {
let idType;
let scope;
let entryExtensions;
let _unrecognizedExtensionsList = [];
const callbacks = {
idType: (_el) => {
idType = _decode_TBSCertAVL_entries_Item_idType(_el);
},
scope: (_el) => {
scope = $._decode_implicit(() => _decode_ScopeRestrictions)(_el);
},
entryExtensions: (_el) => {
entryExtensions = $._decode_implicit(() => _decode_Extensions)(_el);
},
};
$._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_TBSCertAVL_entries_Item, _extension_additions_list_spec_for_TBSCertAVL_entries_Item, _root_component_type_list_2_spec_for_TBSCertAVL_entries_Item, (ext) => {
_unrecognizedExtensionsList.push(ext);
});
return new TBSCertAVL_entries_Item(idType, scope, entryExtensions, _unrecognizedExtensionsList);
}
/**
* @summary Encodes a(n) TBSCertAVL_entries_Item 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 TBSCertAVL_entries_Item, encoded as an ASN.1 Element.
*/
export function _encode_TBSCertAVL_entries_Item(value) {
const components = [
_encode_TBSCertAVL_entries_Item_idType(value.idType, $.BER),
];
if (value.scope) {
const c = $._encode_implicit(_TagClass.context, 0, () => _encode_ScopeRestrictions, $.BER)(value.scope, $.BER);
components.push(c);
}
if (value.entryExtensions?.length) {
const c = $._encode_implicit(_TagClass.context, 1, () => _encode_Extensions, $.BER)(value.entryExtensions, $.BER);
components.push(c);
}
components.push(...value._unrecognizedExtensionsList ?? []);
return $._encodeSequence(components, $.BER);
}
/* eslint-enable */