pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
82 lines • 5.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_EncryptedData = exports._decode_EncryptedData = exports._extension_additions_list_spec_for_EncryptedData = exports._root_component_type_list_2_spec_for_EncryptedData = exports._root_component_type_list_1_spec_for_EncryptedData = exports.EncryptedData = exports._encode_Version = exports._decode_Version = exports._encode_EncryptedContentInfo = exports._decode_EncryptedContentInfo = exports.EncryptedContentInfo = exports._encode_Attributes = exports._decode_Attributes = 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 Attributes_ta_1 = require("../PKCS7/Attributes.ta");
const EncryptedContentInfo_ta_1 = require("../PKCS7/EncryptedContentInfo.ta");
const Version_ta_1 = require("../PKCS7/Version.ta");
var Attributes_ta_2 = require("../PKCS7/Attributes.ta");
Object.defineProperty(exports, "_decode_Attributes", { enumerable: true, get: function () { return Attributes_ta_2._decode_Attributes; } });
Object.defineProperty(exports, "_encode_Attributes", { enumerable: true, get: function () { return Attributes_ta_2._encode_Attributes; } });
var EncryptedContentInfo_ta_2 = require("../PKCS7/EncryptedContentInfo.ta");
Object.defineProperty(exports, "EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2.EncryptedContentInfo; } });
Object.defineProperty(exports, "_decode_EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2._decode_EncryptedContentInfo; } });
Object.defineProperty(exports, "_encode_EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2._encode_EncryptedContentInfo; } });
var Version_ta_2 = require("../PKCS7/Version.ta");
Object.defineProperty(exports, "_decode_Version", { enumerable: true, get: function () { return Version_ta_2._decode_Version; } });
Object.defineProperty(exports, "_encode_Version", { enumerable: true, get: function () { return Version_ta_2._encode_Version; } });
class EncryptedData {
constructor(version, encryptedContentInfo, unprotectedAttributes) {
this.version = version;
this.encryptedContentInfo = encryptedContentInfo;
this.unprotectedAttributes = unprotectedAttributes;
}
static _from_object(_o) {
return new EncryptedData(_o.version, _o.encryptedContentInfo, _o.unprotectedAttributes);
}
}
exports.EncryptedData = EncryptedData;
exports._root_component_type_list_1_spec_for_EncryptedData = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("encryptedContentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("unprotectedAttributes", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_EncryptedData = [];
exports._extension_additions_list_spec_for_EncryptedData = [];
let _cached_decoder_for_EncryptedData = null;
function _decode_EncryptedData(el) {
if (!_cached_decoder_for_EncryptedData) {
_cached_decoder_for_EncryptedData = function (el) {
let version;
let encryptedContentInfo;
let unprotectedAttributes;
const callbacks = {
version: (_el) => {
version = Version_ta_1._decode_Version(_el);
},
encryptedContentInfo: (_el) => {
encryptedContentInfo = EncryptedContentInfo_ta_1._decode_EncryptedContentInfo(_el);
},
unprotectedAttributes: (_el) => {
unprotectedAttributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(_el);
},
};
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_EncryptedData, exports._extension_additions_list_spec_for_EncryptedData, exports._root_component_type_list_2_spec_for_EncryptedData, undefined);
return new EncryptedData(version, encryptedContentInfo, unprotectedAttributes);
};
}
return _cached_decoder_for_EncryptedData(el);
}
exports._decode_EncryptedData = _decode_EncryptedData;
let _cached_encoder_for_EncryptedData = null;
function _encode_EncryptedData(value, elGetter) {
if (!_cached_encoder_for_EncryptedData) {
_cached_encoder_for_EncryptedData = function (value, elGetter) {
return $._encodeSequence([]
.concat([
Version_ta_1._encode_Version(value.version, $.BER),
EncryptedContentInfo_ta_1._encode_EncryptedContentInfo(value.encryptedContentInfo, $.BER),
value.unprotectedAttributes ===
undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => Attributes_ta_1._encode_Attributes, $.BER)(value.unprotectedAttributes, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_EncryptedData(value, elGetter);
}
exports._encode_EncryptedData = _encode_EncryptedData;
//# sourceMappingURL=EncryptedData.ta.js.map