pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
79 lines • 5.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_RecipientKeyIdentifier = exports._decode_RecipientKeyIdentifier = exports._extension_additions_list_spec_for_RecipientKeyIdentifier = exports._root_component_type_list_2_spec_for_RecipientKeyIdentifier = exports._root_component_type_list_1_spec_for_RecipientKeyIdentifier = exports.RecipientKeyIdentifier = exports._encode_SubjectKeyIdentifier = exports._decode_SubjectKeyIdentifier = exports._encode_OtherKeyAttribute = exports._decode_OtherKeyAttribute = exports.OtherKeyAttribute = 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 OtherKeyAttribute_ta_1 = require("../PKCS7/OtherKeyAttribute.ta");
const SubjectKeyIdentifier_ta_1 = require("../PKCS7/SubjectKeyIdentifier.ta");
var OtherKeyAttribute_ta_2 = require("../PKCS7/OtherKeyAttribute.ta");
Object.defineProperty(exports, "OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2.OtherKeyAttribute; } });
Object.defineProperty(exports, "_decode_OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2._decode_OtherKeyAttribute; } });
Object.defineProperty(exports, "_encode_OtherKeyAttribute", { enumerable: true, get: function () { return OtherKeyAttribute_ta_2._encode_OtherKeyAttribute; } });
var SubjectKeyIdentifier_ta_2 = require("../PKCS7/SubjectKeyIdentifier.ta");
Object.defineProperty(exports, "_decode_SubjectKeyIdentifier", { enumerable: true, get: function () { return SubjectKeyIdentifier_ta_2._decode_SubjectKeyIdentifier; } });
Object.defineProperty(exports, "_encode_SubjectKeyIdentifier", { enumerable: true, get: function () { return SubjectKeyIdentifier_ta_2._encode_SubjectKeyIdentifier; } });
class RecipientKeyIdentifier {
constructor(subjectKeyIdentifier, date, otherKeyAttribute) {
this.subjectKeyIdentifier = subjectKeyIdentifier;
this.date = date;
this.otherKeyAttribute = otherKeyAttribute;
}
static _from_object(_o) {
return new RecipientKeyIdentifier(_o.subjectKeyIdentifier, _o.date, _o.otherKeyAttribute);
}
}
exports.RecipientKeyIdentifier = RecipientKeyIdentifier;
exports._root_component_type_list_1_spec_for_RecipientKeyIdentifier = [
new $.ComponentSpec("subjectKeyIdentifier", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined),
new $.ComponentSpec("date", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 24), undefined, undefined),
new $.ComponentSpec("otherKeyAttribute", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_RecipientKeyIdentifier = [];
exports._extension_additions_list_spec_for_RecipientKeyIdentifier = [];
let _cached_decoder_for_RecipientKeyIdentifier = null;
function _decode_RecipientKeyIdentifier(el) {
if (!_cached_decoder_for_RecipientKeyIdentifier) {
_cached_decoder_for_RecipientKeyIdentifier = function (el) {
let subjectKeyIdentifier;
let date;
let otherKeyAttribute;
const callbacks = {
subjectKeyIdentifier: (_el) => {
subjectKeyIdentifier = SubjectKeyIdentifier_ta_1._decode_SubjectKeyIdentifier(_el);
},
date: (_el) => {
date = $._decodeGeneralizedTime(_el);
},
otherKeyAttribute: (_el) => {
otherKeyAttribute = OtherKeyAttribute_ta_1._decode_OtherKeyAttribute(_el);
},
};
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_RecipientKeyIdentifier, exports._extension_additions_list_spec_for_RecipientKeyIdentifier, exports._root_component_type_list_2_spec_for_RecipientKeyIdentifier, undefined);
return new RecipientKeyIdentifier(subjectKeyIdentifier, date, otherKeyAttribute);
};
}
return _cached_decoder_for_RecipientKeyIdentifier(el);
}
exports._decode_RecipientKeyIdentifier = _decode_RecipientKeyIdentifier;
let _cached_encoder_for_RecipientKeyIdentifier = null;
function _encode_RecipientKeyIdentifier(value, elGetter) {
if (!_cached_encoder_for_RecipientKeyIdentifier) {
_cached_encoder_for_RecipientKeyIdentifier = function (value, elGetter) {
return $._encodeSequence([]
.concat([
SubjectKeyIdentifier_ta_1._encode_SubjectKeyIdentifier(value.subjectKeyIdentifier, $.BER),
value.date === undefined
? undefined
: $._encodeGeneralizedTime(value.date, $.BER),
value.otherKeyAttribute === undefined
? undefined
: OtherKeyAttribute_ta_1._encode_OtherKeyAttribute(value.otherKeyAttribute, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_RecipientKeyIdentifier(value, elGetter);
}
exports._encode_RecipientKeyIdentifier = _encode_RecipientKeyIdentifier;
//# sourceMappingURL=RecipientKeyIdentifier.ta.js.map