UNPKG

@wildboar/pkcs

Version:
209 lines 7.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_DDO = exports._decode_DDO = exports._extension_additions_list_spec_for_DDO = exports._root_component_type_list_2_spec_for_DDO = exports._root_component_type_list_1_spec_for_DDO = exports.DDO = exports._encode_Path = exports._decode_Path = exports.Path = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Path_ta_1 = require("../PKCS-15/Path.ta"); var Path_ta_2 = require("../PKCS-15/Path.ta"); Object.defineProperty(exports, "Path", { enumerable: true, get: function () { return Path_ta_2.Path; } }); Object.defineProperty(exports, "_decode_Path", { enumerable: true, get: function () { return Path_ta_2._decode_Path; } }); Object.defineProperty(exports, "_encode_Path", { enumerable: true, get: function () { return Path_ta_2._encode_Path; } }); /* START_OF_SYMBOL_DEFINITION DDO */ /** * @summary DDO * @description * * ### ASN.1 Definition: * * ```asn1 * DDO ::= SEQUENCE { * oid OBJECT IDENTIFIER, * odfPath Path OPTIONAL, * tokenInfoPath [0] Path OPTIONAL, * unusedPath [1] Path OPTIONAL, * ... -- For future extensions * } * ``` * * @class */ class DDO { constructor( /** * @summary `oid`. * @public * @readonly */ oid, /** * @summary `odfPath`. * @public * @readonly */ odfPath, /** * @summary `tokenInfoPath`. * @public * @readonly */ tokenInfoPath, /** * @summary `unusedPath`. * @public * @readonly */ unusedPath, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.oid = oid; this.odfPath = odfPath; this.tokenInfoPath = tokenInfoPath; this.unusedPath = unusedPath; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a DDO * @description * * This takes an `object` and converts it to a `DDO`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `DDO`. * @returns {DDO} */ static _from_object(_o) { return new DDO(_o.oid, _o.odfPath, _o.tokenInfoPath, _o.unusedPath, _o._unrecognizedExtensionsList); } } exports.DDO = DDO; /* END_OF_SYMBOL_DEFINITION DDO */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_DDO */ /** * @summary The Leading Root Component Types of DDO * @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_DDO = [ new $.ComponentSpec("oid", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("odfPath", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("tokenInfoPath", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("unusedPath", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_DDO */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_DDO */ /** * @summary The Trailing Root Component Types of DDO * @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_DDO = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_DDO */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_DDO */ /** * @summary The Extension Addition Component Types of DDO * @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_DDO = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_DDO */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_DDO */ let _cached_decoder_for_DDO = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_DDO */ /* START_OF_SYMBOL_DEFINITION _decode_DDO */ /** * @summary Decodes an ASN.1 element into a(n) DDO * @function * @param {_Element} el The element being decoded. * @returns {DDO} The decoded data structure. */ function _decode_DDO(el) { if (!_cached_decoder_for_DDO) { _cached_decoder_for_DDO = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let oid; let odfPath; let tokenInfoPath; let unusedPath; let _unrecognizedExtensionsList = []; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { oid: (_el) => { oid = $._decodeObjectIdentifier(_el); }, odfPath: (_el) => { odfPath = Path_ta_1._decode_Path(_el); }, tokenInfoPath: (_el) => { tokenInfoPath = $._decode_implicit(() => Path_ta_1._decode_Path)(_el); }, unusedPath: (_el) => { unusedPath = $._decode_implicit(() => Path_ta_1._decode_Path)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_DDO, exports._extension_additions_list_spec_for_DDO, exports._root_component_type_list_2_spec_for_DDO, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new DDO( /* SEQUENCE_CONSTRUCTOR_CALL */ oid, odfPath, tokenInfoPath, unusedPath, _unrecognizedExtensionsList); }; } return _cached_decoder_for_DDO(el); } exports._decode_DDO = _decode_DDO; /* END_OF_SYMBOL_DEFINITION _decode_DDO */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_DDO */ let _cached_encoder_for_DDO = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_DDO */ /* START_OF_SYMBOL_DEFINITION _encode_DDO */ /** * @summary Encodes a(n) DDO 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 DDO, encoded as an ASN.1 Element. */ function _encode_DDO(value, elGetter) { if (!_cached_encoder_for_DDO) { _cached_encoder_for_DDO = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeObjectIdentifier(value.oid, $.BER), /* IF_ABSENT */ value.odfPath === undefined ? undefined : Path_ta_1._encode_Path(value.odfPath, $.BER), /* IF_ABSENT */ value.tokenInfoPath === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => Path_ta_1._encode_Path, $.BER)(value.tokenInfoPath, $.BER), /* IF_ABSENT */ value.unusedPath === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => Path_ta_1._encode_Path, $.BER)(value.unusedPath, $.BER), ], value._unrecognizedExtensionsList ? value._unrecognizedExtensionsList : []) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_DDO(value, elGetter); } exports._encode_DDO = _encode_DDO; /* END_OF_SYMBOL_DEFINITION _encode_DDO */ /* eslint-enable */ //# sourceMappingURL=DDO.ta.js.map