2018-05-17 15:03:59 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-06-11 12:25:07 +00:00
|
|
|
const H004Signer = require('../versions/H004/Signer');
|
2018-05-17 15:03:59 +00:00
|
|
|
|
2018-06-11 12:25:07 +00:00
|
|
|
const H004Serializer = require('../versions/H004/OrderSerializer');
|
2018-05-17 15:03:59 +00:00
|
|
|
|
2018-06-11 12:25:07 +00:00
|
|
|
module.exports = class XMLSign {
|
|
|
|
static sign(order) {
|
|
|
|
const { keys } = order;
|
2018-05-17 15:03:59 +00:00
|
|
|
|
2018-06-11 12:25:07 +00:00
|
|
|
if (order.version.toUpperCase() === 'H004') return new H004Signer(H004Serializer.serialize(order).toXML(), keys).digest().sign().toXML();
|
2018-05-17 15:03:59 +00:00
|
|
|
|
2018-06-11 12:25:07 +00:00
|
|
|
throw Error('Error from XMLSign class: Invalid version number');
|
2018-05-17 15:03:59 +00:00
|
|
|
}
|
|
|
|
};
|