UNPKG

@wildboar/pkcs

Version:
153 lines 6.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_CredentialIdentifier = exports._decode_CredentialIdentifier = exports._extension_additions_list_spec_for_CredentialIdentifier = exports._root_component_type_list_2_spec_for_CredentialIdentifier = exports._root_component_type_list_1_spec_for_CredentialIdentifier = exports.CredentialIdentifier = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); /* START_OF_SYMBOL_DEFINITION CredentialIdentifier */ /** * @summary CredentialIdentifier * @description * * ### ASN.1 Definition: * * ```asn1 * CredentialIdentifier {KEY-IDENTIFIER : IdentifierSet} ::= SEQUENCE { * idType KEY-IDENTIFIER.&id ({IdentifierSet}), * idValue KEY-IDENTIFIER.&Value ({IdentifierSet}{@idType}) * } * ``` * * @class */ class CredentialIdentifier { constructor( /** * @summary `idType`. * @public * @readonly */ idType, /** * @summary `idValue`. * @public * @readonly */ idValue) { this.idType = idType; this.idValue = idValue; } /** * @summary Restructures an object into a CredentialIdentifier * @description * * This takes an `object` and converts it to a `CredentialIdentifier`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `CredentialIdentifier`. * @returns {CredentialIdentifier} */ static _from_object(_o) { return new CredentialIdentifier(_o.idType, _o.idValue); } } exports.CredentialIdentifier = CredentialIdentifier; /* END_OF_SYMBOL_DEFINITION CredentialIdentifier */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CredentialIdentifier */ /** * @summary The Leading Root Component Types of CredentialIdentifier * @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_CredentialIdentifier = [ new $.ComponentSpec("idType", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("idValue", false, $.hasAnyTag, undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CredentialIdentifier */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CredentialIdentifier */ /** * @summary The Trailing Root Component Types of CredentialIdentifier * @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_CredentialIdentifier = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CredentialIdentifier */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CredentialIdentifier */ /** * @summary The Extension Addition Component Types of CredentialIdentifier * @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_CredentialIdentifier = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CredentialIdentifier */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_CredentialIdentifier */ let _cached_decoder_for_CredentialIdentifier = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_CredentialIdentifier */ /* START_OF_SYMBOL_DEFINITION _decode_CredentialIdentifier */ /** * @summary Decodes an ASN.1 element into a(n) CredentialIdentifier * @function * @param {_Element} el The element being decoded. * @returns {CredentialIdentifier} The decoded data structure. */ function _decode_CredentialIdentifier(el) { if (!_cached_decoder_for_CredentialIdentifier) { _cached_decoder_for_CredentialIdentifier = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("CredentialIdentifier contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "idType"; sequence[1].name = "idValue"; let idType; let idValue; idType = $._decodeInteger(sequence[0]); idValue = $._decodeAny(sequence[1]); return new CredentialIdentifier(idType, idValue); }; } return _cached_decoder_for_CredentialIdentifier(el); } exports._decode_CredentialIdentifier = _decode_CredentialIdentifier; /* END_OF_SYMBOL_DEFINITION _decode_CredentialIdentifier */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_CredentialIdentifier */ let _cached_encoder_for_CredentialIdentifier = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_CredentialIdentifier */ /* START_OF_SYMBOL_DEFINITION _encode_CredentialIdentifier */ /** * @summary Encodes a(n) CredentialIdentifier 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 CredentialIdentifier, encoded as an ASN.1 Element. */ function _encode_CredentialIdentifier(value, elGetter) { if (!_cached_encoder_for_CredentialIdentifier) { _cached_encoder_for_CredentialIdentifier = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeInteger(value.idType, $.BER), /* REQUIRED */ $._encodeAny(value.idValue, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_CredentialIdentifier(value, elGetter); } exports._encode_CredentialIdentifier = _encode_CredentialIdentifier; /* END_OF_SYMBOL_DEFINITION _encode_CredentialIdentifier */ /* eslint-enable */ //# sourceMappingURL=CredentialIdentifier.ta.js.map