ess-ts
Version:
Enhanced Security Services (ESS) in TypeScript
86 lines • 5.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_Receipt = exports._decode_Receipt = exports._extension_additions_list_spec_for_Receipt = exports._root_component_type_list_2_spec_for_Receipt = exports._root_component_type_list_1_spec_for_Receipt = exports.Receipt = exports._encode_ESSVersion = exports._decode_ESSVersion = exports.v1 = exports.ESSVersion_v1 = exports._encode_ContentIdentifier = exports._decode_ContentIdentifier = exports._encode_ContentType = exports._decode_ContentType = 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 ContentType_ta_1 = require("../CryptographicMessageSyntax2004/ContentType.ta");
const ContentIdentifier_ta_1 = require("../ExtendedSecurityServices-2006/ContentIdentifier.ta");
const ESSVersion_ta_1 = require("../ExtendedSecurityServices-2006/ESSVersion.ta");
var ContentType_ta_2 = require("../CryptographicMessageSyntax2004/ContentType.ta");
Object.defineProperty(exports, "_decode_ContentType", { enumerable: true, get: function () { return ContentType_ta_2._decode_ContentType; } });
Object.defineProperty(exports, "_encode_ContentType", { enumerable: true, get: function () { return ContentType_ta_2._encode_ContentType; } });
var ContentIdentifier_ta_2 = require("../ExtendedSecurityServices-2006/ContentIdentifier.ta");
Object.defineProperty(exports, "_decode_ContentIdentifier", { enumerable: true, get: function () { return ContentIdentifier_ta_2._decode_ContentIdentifier; } });
Object.defineProperty(exports, "_encode_ContentIdentifier", { enumerable: true, get: function () { return ContentIdentifier_ta_2._encode_ContentIdentifier; } });
var ESSVersion_ta_2 = require("../ExtendedSecurityServices-2006/ESSVersion.ta");
Object.defineProperty(exports, "ESSVersion_v1", { enumerable: true, get: function () { return ESSVersion_ta_2.ESSVersion_v1; } });
Object.defineProperty(exports, "v1", { enumerable: true, get: function () { return ESSVersion_ta_2.v1; } });
Object.defineProperty(exports, "_decode_ESSVersion", { enumerable: true, get: function () { return ESSVersion_ta_2._decode_ESSVersion; } });
Object.defineProperty(exports, "_encode_ESSVersion", { enumerable: true, get: function () { return ESSVersion_ta_2._encode_ESSVersion; } });
class Receipt {
constructor(version, contentType, signedContentIdentifier, originatorSignatureValue) {
this.version = version;
this.contentType = contentType;
this.signedContentIdentifier = signedContentIdentifier;
this.originatorSignatureValue = originatorSignatureValue;
}
static _from_object(_o) {
return new Receipt(_o.version, _o.contentType, _o.signedContentIdentifier, _o.originatorSignatureValue);
}
}
exports.Receipt = Receipt;
exports._root_component_type_list_1_spec_for_Receipt = [
new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("contentType", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined),
new $.ComponentSpec("signedContentIdentifier", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined),
new $.ComponentSpec("originatorSignatureValue", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_Receipt = [];
exports._extension_additions_list_spec_for_Receipt = [];
let _cached_decoder_for_Receipt = null;
function _decode_Receipt(el) {
if (!_cached_decoder_for_Receipt) {
_cached_decoder_for_Receipt = function (el) {
const sequence = el.sequence;
if (sequence.length < 4) {
throw new asn1_ts_1.ASN1ConstructionError("Receipt contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "version";
sequence[1].name = "contentType";
sequence[2].name = "signedContentIdentifier";
sequence[3].name = "originatorSignatureValue";
let version;
let contentType;
let signedContentIdentifier;
let originatorSignatureValue;
version = ESSVersion_ta_1._decode_ESSVersion(sequence[0]);
contentType = ContentType_ta_1._decode_ContentType(sequence[1]);
signedContentIdentifier = ContentIdentifier_ta_1._decode_ContentIdentifier(sequence[2]);
originatorSignatureValue = $._decodeOctetString(sequence[3]);
return new Receipt(version, contentType, signedContentIdentifier, originatorSignatureValue);
};
}
return _cached_decoder_for_Receipt(el);
}
exports._decode_Receipt = _decode_Receipt;
let _cached_encoder_for_Receipt = null;
function _encode_Receipt(value, elGetter) {
if (!_cached_encoder_for_Receipt) {
_cached_encoder_for_Receipt = function (value, elGetter) {
return $._encodeSequence([]
.concat([
ESSVersion_ta_1._encode_ESSVersion(value.version, $.BER),
ContentType_ta_1._encode_ContentType(value.contentType, $.BER),
ContentIdentifier_ta_1._encode_ContentIdentifier(value.signedContentIdentifier, $.BER),
$._encodeOctetString(value.originatorSignatureValue, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_Receipt(value, elGetter);
}
exports._encode_Receipt = _encode_Receipt;
//# sourceMappingURL=Receipt.ta.js.map