UNPKG

@wildboar/pkcs

Version:
180 lines 7.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_SafeBag = exports._decode_SafeBag = exports._extension_additions_list_spec_for_SafeBag = exports._root_component_type_list_2_spec_for_SafeBag = exports._root_component_type_list_1_spec_for_SafeBag = exports.SafeBag = exports.PKCS12BagSet = exports._encode_PKCS12Attribute = exports._decode_PKCS12Attribute = exports.PKCS12Attribute = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const PKCS12Attribute_ta_1 = require("../PKCS-12/PKCS12Attribute.ta"); var PKCS12Attribute_ta_2 = require("../PKCS-12/PKCS12Attribute.ta"); Object.defineProperty(exports, "PKCS12Attribute", { enumerable: true, get: function () { return PKCS12Attribute_ta_2.PKCS12Attribute; } }); Object.defineProperty(exports, "_decode_PKCS12Attribute", { enumerable: true, get: function () { return PKCS12Attribute_ta_2._decode_PKCS12Attribute; } }); Object.defineProperty(exports, "_encode_PKCS12Attribute", { enumerable: true, get: function () { return PKCS12Attribute_ta_2._encode_PKCS12Attribute; } }); var PKCS12BagSet_osa_1 = require("../PKCS-12/PKCS12BagSet.osa"); Object.defineProperty(exports, "PKCS12BagSet", { enumerable: true, get: function () { return PKCS12BagSet_osa_1.PKCS12BagSet; } }); /* START_OF_SYMBOL_DEFINITION SafeBag */ /** * @summary SafeBag * @description * * ### ASN.1 Definition: * * ```asn1 * SafeBag ::= SEQUENCE { * bagId BAG-TYPE.&id ({PKCS12BagSet}), * bagValue [0] EXPLICIT BAG-TYPE.&Type({PKCS12BagSet}{@bagId}), * bagAttributes SET OF PKCS12Attribute OPTIONAL * } * ``` * * @class */ class SafeBag { constructor( /** * @summary `bagId`. * @public * @readonly */ bagId, /** * @summary `bagValue`. * @public * @readonly */ bagValue, /** * @summary `bagAttributes`. * @public * @readonly */ bagAttributes) { this.bagId = bagId; this.bagValue = bagValue; this.bagAttributes = bagAttributes; } /** * @summary Restructures an object into a SafeBag * @description * * This takes an `object` and converts it to a `SafeBag`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `SafeBag`. * @returns {SafeBag} */ static _from_object(_o) { return new SafeBag(_o.bagId, _o.bagValue, _o.bagAttributes); } } exports.SafeBag = SafeBag; /* END_OF_SYMBOL_DEFINITION SafeBag */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SafeBag */ /** * @summary The Leading Root Component Types of SafeBag * @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_SafeBag = [ new $.ComponentSpec("bagId", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("bagValue", false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("bagAttributes", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SafeBag */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SafeBag */ /** * @summary The Trailing Root Component Types of SafeBag * @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_SafeBag = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SafeBag */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SafeBag */ /** * @summary The Extension Addition Component Types of SafeBag * @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_SafeBag = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SafeBag */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_SafeBag */ let _cached_decoder_for_SafeBag = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_SafeBag */ /* START_OF_SYMBOL_DEFINITION _decode_SafeBag */ /** * @summary Decodes an ASN.1 element into a(n) SafeBag * @function * @param {_Element} el The element being decoded. * @returns {SafeBag} The decoded data structure. */ function _decode_SafeBag(el) { if (!_cached_decoder_for_SafeBag) { _cached_decoder_for_SafeBag = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let bagId; let bagValue; let bagAttributes; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { bagId: (_el) => { bagId = $._decodeObjectIdentifier(_el); }, bagValue: (_el) => { bagValue = $._decode_explicit(() => $._decodeAny)(_el); }, bagAttributes: (_el) => { bagAttributes = $._decodeSetOf(() => PKCS12Attribute_ta_1._decode_PKCS12Attribute)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_SafeBag, exports._extension_additions_list_spec_for_SafeBag, exports._root_component_type_list_2_spec_for_SafeBag, undefined); return new SafeBag( /* SEQUENCE_CONSTRUCTOR_CALL */ bagId, bagValue, bagAttributes); }; } return _cached_decoder_for_SafeBag(el); } exports._decode_SafeBag = _decode_SafeBag; /* END_OF_SYMBOL_DEFINITION _decode_SafeBag */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_SafeBag */ let _cached_encoder_for_SafeBag = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_SafeBag */ /* START_OF_SYMBOL_DEFINITION _encode_SafeBag */ /** * @summary Encodes a(n) SafeBag 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 SafeBag, encoded as an ASN.1 Element. */ function _encode_SafeBag(value, elGetter) { if (!_cached_encoder_for_SafeBag) { _cached_encoder_for_SafeBag = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeObjectIdentifier(value.bagId, $.BER), /* REQUIRED */ $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeAny, $.BER)(value.bagValue, $.BER), /* IF_ABSENT */ value.bagAttributes === undefined ? undefined : $._encodeSetOf(() => PKCS12Attribute_ta_1._encode_PKCS12Attribute, $.BER)(value.bagAttributes, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_SafeBag(value, elGetter); } exports._encode_SafeBag = _encode_SafeBag; /* END_OF_SYMBOL_DEFINITION _encode_SafeBag */ /* eslint-enable */ //# sourceMappingURL=SafeBag.ta.js.map