UNPKG

@wildboar/copp

Version:

Connection-oriented presentation protocol (COPP) data structures and business logic in TypeScript

227 lines 12.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_CP_type = exports._decode_CP_type = exports._extension_additions_list_spec_for_CP_type = exports._root_component_type_list_2_spec_for_CP_type = exports._root_component_type_list_1_spec_for_CP_type = exports.CP_type = exports._encode_CP_type_normal_mode_parameters = exports._decode_CP_type_normal_mode_parameters = exports.CP_type_normal_mode_parameters = exports._encode_CP_type_x410_mode_parameters = exports._decode_CP_type_x410_mode_parameters = exports.CP_type_x410_mode_parameters = exports._encode_Mode_selector = exports._decode_Mode_selector = exports.Mode_selector = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Mode_selector_ta_1 = require("../ISO8823-PRESENTATION/Mode-selector.ta"); var Mode_selector_ta_2 = require("../ISO8823-PRESENTATION/Mode-selector.ta"); Object.defineProperty(exports, "Mode_selector", { enumerable: true, get: function () { return Mode_selector_ta_2.Mode_selector; } }); Object.defineProperty(exports, "_decode_Mode_selector", { enumerable: true, get: function () { return Mode_selector_ta_2._decode_Mode_selector; } }); Object.defineProperty(exports, "_encode_Mode_selector", { enumerable: true, get: function () { return Mode_selector_ta_2._encode_Mode_selector; } }); const CP_type_x410_mode_parameters_ta_1 = require("../ISO8823-PRESENTATION/CP-type-x410-mode-parameters.ta"); var CP_type_x410_mode_parameters_ta_2 = require("../ISO8823-PRESENTATION/CP-type-x410-mode-parameters.ta"); Object.defineProperty(exports, "CP_type_x410_mode_parameters", { enumerable: true, get: function () { return CP_type_x410_mode_parameters_ta_2.CP_type_x410_mode_parameters; } }); Object.defineProperty(exports, "_decode_CP_type_x410_mode_parameters", { enumerable: true, get: function () { return CP_type_x410_mode_parameters_ta_2._decode_CP_type_x410_mode_parameters; } }); Object.defineProperty(exports, "_encode_CP_type_x410_mode_parameters", { enumerable: true, get: function () { return CP_type_x410_mode_parameters_ta_2._encode_CP_type_x410_mode_parameters; } }); const CP_type_normal_mode_parameters_ta_1 = require("../ISO8823-PRESENTATION/CP-type-normal-mode-parameters.ta"); var CP_type_normal_mode_parameters_ta_2 = require("../ISO8823-PRESENTATION/CP-type-normal-mode-parameters.ta"); Object.defineProperty(exports, "CP_type_normal_mode_parameters", { enumerable: true, get: function () { return CP_type_normal_mode_parameters_ta_2.CP_type_normal_mode_parameters; } }); Object.defineProperty(exports, "_decode_CP_type_normal_mode_parameters", { enumerable: true, get: function () { return CP_type_normal_mode_parameters_ta_2._decode_CP_type_normal_mode_parameters; } }); Object.defineProperty(exports, "_encode_CP_type_normal_mode_parameters", { enumerable: true, get: function () { return CP_type_normal_mode_parameters_ta_2._encode_CP_type_normal_mode_parameters; } }); /* START_OF_SYMBOL_DEFINITION CP_type */ /** * @summary CP_type * @description * * ### ASN.1 Definition: * * ```asn1 * CP-type ::= SET { * mode-selector [0] IMPLICIT Mode-selector, * x410-mode-parameters * [1] IMPLICIT SET {COMPONENTS OF Reliable-Transfer-APDU.RTORQapdu} OPTIONAL-- This OPTIONAL element shall be absent for a * -- nested presentation connection. * -- Shall be used for X.410 mode only. Shall be bitwise * -- compatible with CCITT Recommendation X.410-1984. * -- This shall be the User data parameter of the CP PPDU1) --, * normal-mode-parameters * [2] IMPLICIT SEQUENCE {protocol-version * [0] IMPLICIT Protocol-version DEFAULT {version-1}, * calling-presentation-selector * [1] IMPLICIT Calling-presentation-selector * OPTIONAL, * called-presentation-selector * [2] IMPLICIT Called-presentation-selector OPTIONAL, * presentation-context-definition-list * [4] IMPLICIT Presentation-context-definition-list * OPTIONAL, * default-context-name * [6] IMPLICIT Default-context-name OPTIONAL, * presentation-requirements * [8] IMPLICIT Presentation-requirements OPTIONAL, * user-session-requirements * [9] IMPLICIT User-session-requirements OPTIONAL-- shall not be present if equal to the Revised session * -- requirements parameter --, * protocol-options * [11] Protocol-options DEFAULT {}, * -- shall be absent if no options are offered * initiators-nominated-context * [12] Presentation-context-identifier OPTIONAL, * -- shall only be present if nominated-context is * -- offered in protocol-options * extensions * [14] SEQUENCE {...} OPTIONAL, * -- to allow for future extensions * user-data * User-data OPTIONAL} OPTIONAL * -- Shall be used for normal mode only. * -- Shall be the parameters of the CP PPDU. * } * ``` * * @class */ class CP_type { constructor( /** * @summary `mode_selector`. * @public * @readonly */ mode_selector, /** * @summary `x410_mode_parameters`. * @public * @readonly */ x410_mode_parameters, /** * @summary `normal_mode_parameters`. * @public * @readonly */ normal_mode_parameters) { this.mode_selector = mode_selector; this.x410_mode_parameters = x410_mode_parameters; this.normal_mode_parameters = normal_mode_parameters; } /** * @summary Restructures an object into a CP_type * @description * * This takes an `object` and converts it to a `CP_type`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `CP_type`. * @returns {CP_type} */ static _from_object(_o) { return new CP_type(_o.mode_selector, _o.x410_mode_parameters, _o.normal_mode_parameters); } } exports.CP_type = CP_type; /* END_OF_SYMBOL_DEFINITION CP_type */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CP_type */ /** * @summary The Leading Root Component Types of CP_type * @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_CP_type = [ new $.ComponentSpec('mode-selector', false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec('x410-mode-parameters', true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), new $.ComponentSpec('normal-mode-parameters', true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 2), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CP_type */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CP_type */ /** * @summary The Trailing Root Component Types of CP_type * @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_CP_type = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CP_type */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CP_type */ /** * @summary The Extension Addition Component Types of CP_type * @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_CP_type = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CP_type */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_CP_type */ let _cached_decoder_for_CP_type = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_CP_type */ /* START_OF_SYMBOL_DEFINITION _decode_CP_type */ /** * @summary Decodes an ASN.1 element into a(n) CP_type * @function * @param {_Element} el The element being decoded. * @returns {CP_type} The decoded data structure. */ function _decode_CP_type(el) { if (!_cached_decoder_for_CP_type) { _cached_decoder_for_CP_type = function (el) { /* START_OF_SET_COMPONENT_DECLARATIONS */ let mode_selector; let x410_mode_parameters; let normal_mode_parameters; /* END_OF_SET_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { 'mode-selector': (_el) => { mode_selector = $._decode_implicit(() => Mode_selector_ta_1._decode_Mode_selector)(_el); }, 'x410-mode-parameters': (_el) => { x410_mode_parameters = $._decode_implicit(() => CP_type_x410_mode_parameters_ta_1._decode_CP_type_x410_mode_parameters)(_el); }, 'normal-mode-parameters': (_el) => { normal_mode_parameters = $._decode_implicit(() => CP_type_normal_mode_parameters_ta_1._decode_CP_type_normal_mode_parameters)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_set(el, callbacks, exports._root_component_type_list_1_spec_for_CP_type, exports._extension_additions_list_spec_for_CP_type, exports._root_component_type_list_2_spec_for_CP_type, undefined); return new CP_type /* SET_CONSTRUCTOR_CALL */(mode_selector, x410_mode_parameters, normal_mode_parameters); }; } return _cached_decoder_for_CP_type(el); } exports._decode_CP_type = _decode_CP_type; /* END_OF_SYMBOL_DEFINITION _decode_CP_type */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_CP_type */ let _cached_encoder_for_CP_type = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_CP_type */ /* START_OF_SYMBOL_DEFINITION _encode_CP_type */ /** * @summary Encodes a(n) CP_type 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 CP_type, encoded as an ASN.1 Element. */ function _encode_CP_type(value, elGetter) { if (!_cached_encoder_for_CP_type) { _cached_encoder_for_CP_type = function (value, elGetter) { return $._encodeSet([] .concat([ /* REQUIRED */ $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => Mode_selector_ta_1._encode_Mode_selector, $.BER)(value.mode_selector, $.BER), /* IF_ABSENT */ value.x410_mode_parameters === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => CP_type_x410_mode_parameters_ta_1._encode_CP_type_x410_mode_parameters, $.BER)(value.x410_mode_parameters, $.BER), /* IF_ABSENT */ value.normal_mode_parameters === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 2, () => CP_type_normal_mode_parameters_ta_1._encode_CP_type_normal_mode_parameters, $.BER)(value.normal_mode_parameters, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_CP_type(value, elGetter); } exports._encode_CP_type = _encode_CP_type; /* END_OF_SYMBOL_DEFINITION _encode_CP_type */ /* eslint-enable */ //# sourceMappingURL=CP-type.ta.js.map