diff --git a/lib/Client.js b/lib/Client.js index 2868c90..098b804 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -78,7 +78,7 @@ module.exports = class Client { const returnedBusinessCode = res.businessCode(); return { - orderData: xml, + orderData: xml.length ? xml.toString() : xml, orderId: res.orderId(), technicalCode: returnedTechnicalCode, diff --git a/lib/orders/H004/response.js b/lib/orders/H004/response.js index 9708698..7fb7a51 100644 --- a/lib/orders/H004/response.js +++ b/lib/orders/H004/response.js @@ -47,7 +47,7 @@ module.exports = (xml, keys) => ({ const decipher = crypto.createDecipheriv('aes-128-cbc', this.transactionKey(), DEFAULT_IV).setAutoPadding(false); const data = Buffer.from(decipher.update(orderData, 'base64', 'binary') + decipher.final('binary'), 'binary'); - return zlib.inflateSync(data).toString(); + return zlib.inflateSync(data); }, transactionKey() { @@ -111,17 +111,8 @@ module.exports = (xml, keys) => ({ return errors.technical[code].meaning; }, - /* returnCode(where = 'header') { - const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' }); - const node = where === 'header' - ? select('//xmlns:header/xmlns:mutable/xmlns:ReturnCode', this.doc) - : select('//xmlns:body/xmlns:ReturnCode', this.doc); - - return node.length ? node[0].textContent : ''; - }, */ - bankKeys() { - const orderData = this.orderData(); + const orderData = this.orderData().toString(); if (!Object.keys(orderData).length) return {}; const doc = new DOMParser().parseFromString(orderData, 'text/xml');