pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
62 lines • 2.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_CertBag = exports._decode_CertBag = exports._extension_additions_list_spec_for_CertBag = exports._root_component_type_list_2_spec_for_CertBag = exports._root_component_type_list_1_spec_for_CertBag = exports.CertBag = exports.CertTypes = void 0;
const tslib_1 = require("tslib");
const asn1_ts_1 = require("asn1-ts");
const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional"));
var CertTypes_osa_1 = require("../PKCS-12/CertTypes.osa");
Object.defineProperty(exports, "CertTypes", { enumerable: true, get: function () { return CertTypes_osa_1.CertTypes; } });
class CertBag {
constructor(certId, certValue) {
this.certId = certId;
this.certValue = certValue;
}
static _from_object(_o) {
return new CertBag(_o.certId, _o.certValue);
}
}
exports.CertBag = CertBag;
exports._root_component_type_list_1_spec_for_CertBag = [
new $.ComponentSpec("certId", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined),
new $.ComponentSpec("certValue", false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_CertBag = [];
exports._extension_additions_list_spec_for_CertBag = [];
let _cached_decoder_for_CertBag = null;
function _decode_CertBag(el) {
if (!_cached_decoder_for_CertBag) {
_cached_decoder_for_CertBag = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("CertBag contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "certId";
sequence[1].name = "certValue";
let certId;
let certValue;
certId = $._decodeObjectIdentifier(sequence[0]);
certValue = $._decode_explicit(() => $._decodeAny)(sequence[1]);
return new CertBag(certId, certValue);
};
}
return _cached_decoder_for_CertBag(el);
}
exports._decode_CertBag = _decode_CertBag;
let _cached_encoder_for_CertBag = null;
function _encode_CertBag(value, elGetter) {
if (!_cached_encoder_for_CertBag) {
_cached_encoder_for_CertBag = function (value, elGetter) {
return $._encodeSequence([]
.concat([
$._encodeObjectIdentifier(value.certId, $.BER),
$._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeAny, $.BER)(value.certValue, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_CertBag(value, elGetter);
}
exports._encode_CertBag = _encode_CertBag;
//# sourceMappingURL=CertBag.ta.js.map