UNPKG

pkcs-ts

Version:

PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More

75 lines 4.23 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; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(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; } }); class SafeBag { constructor(bagId, bagValue, bagAttributes) { this.bagId = bagId; this.bagValue = bagValue; this.bagAttributes = bagAttributes; } static _from_object(_o) { return new SafeBag(_o.bagId, _o.bagValue, _o.bagAttributes); } } exports.SafeBag = SafeBag; 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), ]; exports._root_component_type_list_2_spec_for_SafeBag = []; exports._extension_additions_list_spec_for_SafeBag = []; let _cached_decoder_for_SafeBag = null; function _decode_SafeBag(el) { if (!_cached_decoder_for_SafeBag) { _cached_decoder_for_SafeBag = function (el) { let bagId; let bagValue; let bagAttributes; const callbacks = { bagId: (_el) => { bagId = $._decodeObjectIdentifier(_el); }, bagValue: (_el) => { bagValue = $._decode_explicit(() => $._decodeAny)(_el); }, bagAttributes: (_el) => { bagAttributes = $._decodeSetOf(() => PKCS12Attribute_ta_1._decode_PKCS12Attribute)(_el); }, }; $._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(bagId, bagValue, bagAttributes); }; } return _cached_decoder_for_SafeBag(el); } exports._decode_SafeBag = _decode_SafeBag; let _cached_encoder_for_SafeBag = null; function _encode_SafeBag(value, elGetter) { if (!_cached_encoder_for_SafeBag) { _cached_encoder_for_SafeBag = function (value, elGetter) { return $._encodeSequence([] .concat([ $._encodeObjectIdentifier(value.bagId, $.BER), $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeAny, $.BER)(value.bagValue, $.BER), 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; //# sourceMappingURL=SafeBag.ta.js.map