node-ebics-client/lib/orders/INI.js

78 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-05-17 15:03:59 +00:00
'use strict';
const zlib = require('zlib');
const js2xmlparser = require('js2xmlparser');
const GenericOrder = require('./GenericOrder');
module.exports = class INI extends GenericOrder {
2018-06-01 13:16:43 +00:00
constructor(client) {
2018-05-17 15:03:59 +00:00
super(client);
this._schema = {
2018-06-01 13:16:43 +00:00
'@': {
'xmlns:ds': 'http://www.w3.org/2000/09/xmldsig#',
xmlns: 'urn:org:ebics:H004',
Version: 'H004',
Revision: '1',
2018-05-17 15:03:59 +00:00
},
header: {
2018-06-01 13:16:43 +00:00
'@': { authenticate: true },
2018-05-17 15:03:59 +00:00
static: {
HostID: this.hostId,
PartnerID: this.partnerId,
UserID: this.userId,
Product: {
2018-06-01 13:16:43 +00:00
'@': { Language: 'de' },
'#': this.productString,
2018-05-17 15:03:59 +00:00
},
OrderDetails: {
2018-06-01 13:16:43 +00:00
OrderType: 'INI',
OrderAttribute: 'DZNNN',
2018-05-17 15:03:59 +00:00
},
2018-06-01 13:16:43 +00:00
SecurityMedium: '0000',
2018-05-17 15:03:59 +00:00
},
2018-06-01 13:16:43 +00:00
mutable: {},
2018-05-17 15:03:59 +00:00
},
body: {
DataTransfer: {
2018-06-01 13:16:43 +00:00
OrderData: Buffer.from(zlib.deflateSync(this.keySignature())).toString('base64'),
},
},
2018-05-17 15:03:59 +00:00
};
}
2018-06-01 13:16:43 +00:00
root() { // eslint-disable-line class-methods-use-this
return 'ebicsUnsecuredRequest';
}
2018-05-17 15:03:59 +00:00
keySignature() {
const xmlOrderData = {
2018-06-01 13:16:43 +00:00
'@': {
'xmlns:ds': 'http://www.w3.org/2000/09/xmldsig#',
xmlns: 'http://www.ebics.org/S001',
2018-05-17 15:03:59 +00:00
},
SignaturePubKeyInfo: {
PubKeyValue: {
2018-06-01 13:16:43 +00:00
'ds:RSAKeyValue': {
'ds:Modulus': Buffer.from(this.client.a().n(), 'HEX').toString('base64'),
'ds:Exponent': 'AQAB',
2018-05-17 15:03:59 +00:00
},
2018-06-01 13:16:43 +00:00
TimeStamp: this.timestamp(),
2018-05-17 15:03:59 +00:00
},
2018-06-01 13:16:43 +00:00
SignatureVersion: 'A006',
2018-05-17 15:03:59 +00:00
},
PartnerID: this.partnerId,
2018-06-01 13:16:43 +00:00
UserID: this.userId,
2018-05-17 15:03:59 +00:00
};
2018-06-01 13:16:43 +00:00
return js2xmlparser.parse('SignaturePubKeyOrderData', xmlOrderData, this.xmlOptions);
}
2018-05-17 15:03:59 +00:00
toXML() {
return js2xmlparser.parse(this.root(), this._schema, this.xmlOptions);
}
};