pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
116 lines • 8.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_SignedData = exports._decode_SignedData = exports._extension_additions_list_spec_for_SignedData = exports._root_component_type_list_2_spec_for_SignedData = exports._root_component_type_list_1_spec_for_SignedData = exports.SignedData = exports._encode_Version = exports._decode_Version = exports._encode_SignerInfos = exports._decode_SignerInfos = exports._encode_DigestAlgorithmIdentifiers = exports._decode_DigestAlgorithmIdentifiers = exports._encode_ContentInfo = exports._decode_ContentInfo = exports.ContentInfo = exports._encode_CertificateSet = exports._decode_CertificateSet = exports._encode_CertificateRevocationLists = exports._decode_CertificateRevocationLists = 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 CertificateRevocationLists_ta_1 = require("../PKCS7/CertificateRevocationLists.ta");
const CertificateSet_ta_1 = require("../PKCS7/CertificateSet.ta");
const ContentInfo_ta_1 = require("../PKCS7/ContentInfo.ta");
const DigestAlgorithmIdentifiers_ta_1 = require("../PKCS7/DigestAlgorithmIdentifiers.ta");
const SignerInfos_ta_1 = require("../PKCS7/SignerInfos.ta");
const Version_ta_1 = require("../PKCS7/Version.ta");
var CertificateRevocationLists_ta_2 = require("../PKCS7/CertificateRevocationLists.ta");
Object.defineProperty(exports, "_decode_CertificateRevocationLists", { enumerable: true, get: function () { return CertificateRevocationLists_ta_2._decode_CertificateRevocationLists; } });
Object.defineProperty(exports, "_encode_CertificateRevocationLists", { enumerable: true, get: function () { return CertificateRevocationLists_ta_2._encode_CertificateRevocationLists; } });
var CertificateSet_ta_2 = require("../PKCS7/CertificateSet.ta");
Object.defineProperty(exports, "_decode_CertificateSet", { enumerable: true, get: function () { return CertificateSet_ta_2._decode_CertificateSet; } });
Object.defineProperty(exports, "_encode_CertificateSet", { enumerable: true, get: function () { return CertificateSet_ta_2._encode_CertificateSet; } });
var ContentInfo_ta_2 = require("../PKCS7/ContentInfo.ta");
Object.defineProperty(exports, "ContentInfo", { enumerable: true, get: function () { return ContentInfo_ta_2.ContentInfo; } });
Object.defineProperty(exports, "_decode_ContentInfo", { enumerable: true, get: function () { return ContentInfo_ta_2._decode_ContentInfo; } });
Object.defineProperty(exports, "_encode_ContentInfo", { enumerable: true, get: function () { return ContentInfo_ta_2._encode_ContentInfo; } });
var DigestAlgorithmIdentifiers_ta_2 = require("../PKCS7/DigestAlgorithmIdentifiers.ta");
Object.defineProperty(exports, "_decode_DigestAlgorithmIdentifiers", { enumerable: true, get: function () { return DigestAlgorithmIdentifiers_ta_2._decode_DigestAlgorithmIdentifiers; } });
Object.defineProperty(exports, "_encode_DigestAlgorithmIdentifiers", { enumerable: true, get: function () { return DigestAlgorithmIdentifiers_ta_2._encode_DigestAlgorithmIdentifiers; } });
var SignerInfos_ta_2 = require("../PKCS7/SignerInfos.ta");
Object.defineProperty(exports, "_decode_SignerInfos", { enumerable: true, get: function () { return SignerInfos_ta_2._decode_SignerInfos; } });
Object.defineProperty(exports, "_encode_SignerInfos", { enumerable: true, get: function () { return SignerInfos_ta_2._encode_SignerInfos; } });
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 SignedData {
constructor(version, digestAlgorithms, contentInfo, certificates, crls, signerInfos) {
this.version = version;
this.digestAlgorithms = digestAlgorithms;
this.contentInfo = contentInfo;
this.certificates = certificates;
this.crls = crls;
this.signerInfos = signerInfos;
}
static _from_object(_o) {
return new SignedData(_o.version, _o.digestAlgorithms, _o.contentInfo, _o.certificates, _o.crls, _o.signerInfos);
}
}
exports.SignedData = SignedData;
exports._root_component_type_list_1_spec_for_SignedData = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("digestAlgorithms", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined),
new $.ComponentSpec("contentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("certificates", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
new $.ComponentSpec("crls", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined),
new $.ComponentSpec("signerInfos", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_SignedData = [];
exports._extension_additions_list_spec_for_SignedData = [];
let _cached_decoder_for_SignedData = null;
function _decode_SignedData(el) {
if (!_cached_decoder_for_SignedData) {
_cached_decoder_for_SignedData = function (el) {
let version;
let digestAlgorithms;
let contentInfo;
let certificates;
let crls;
let signerInfos;
const callbacks = {
version: (_el) => {
version = Version_ta_1._decode_Version(_el);
},
digestAlgorithms: (_el) => {
digestAlgorithms = DigestAlgorithmIdentifiers_ta_1._decode_DigestAlgorithmIdentifiers(_el);
},
contentInfo: (_el) => {
contentInfo = ContentInfo_ta_1._decode_ContentInfo(_el);
},
certificates: (_el) => {
certificates = $._decode_implicit(() => CertificateSet_ta_1._decode_CertificateSet)(_el);
},
crls: (_el) => {
crls = $._decode_implicit(() => CertificateRevocationLists_ta_1._decode_CertificateRevocationLists)(_el);
},
signerInfos: (_el) => {
signerInfos = SignerInfos_ta_1._decode_SignerInfos(_el);
},
};
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_SignedData, exports._extension_additions_list_spec_for_SignedData, exports._root_component_type_list_2_spec_for_SignedData, undefined);
return new SignedData(version, digestAlgorithms, contentInfo, certificates, crls, signerInfos);
};
}
return _cached_decoder_for_SignedData(el);
}
exports._decode_SignedData = _decode_SignedData;
let _cached_encoder_for_SignedData = null;
function _encode_SignedData(value, elGetter) {
if (!_cached_encoder_for_SignedData) {
_cached_encoder_for_SignedData = function (value, elGetter) {
return $._encodeSequence([]
.concat([
Version_ta_1._encode_Version(value.version, $.BER),
DigestAlgorithmIdentifiers_ta_1._encode_DigestAlgorithmIdentifiers(value.digestAlgorithms, $.BER),
ContentInfo_ta_1._encode_ContentInfo(value.contentInfo, $.BER),
value.certificates === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => CertificateSet_ta_1._encode_CertificateSet, $.BER)(value.certificates, $.BER),
value.crls === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => CertificateRevocationLists_ta_1._encode_CertificateRevocationLists, $.BER)(value.crls, $.BER),
SignerInfos_ta_1._encode_SignerInfos(value.signerInfos, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_SignedData(value, elGetter);
}
exports._encode_SignedData = _encode_SignedData;
//# sourceMappingURL=SignedData.ta.js.map