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