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 HIA extends GenericOrder {
|
|
|
|
constructor(client) {
|
|
|
|
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: 'HIA',
|
|
|
|
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.orderData())).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
|
|
|
|
|
|
|
orderData() {
|
|
|
|
const xmlOrderData = {
|
2018-06-01 13:16:43 +00:00
|
|
|
'@': {
|
|
|
|
'xmlns:ds': 'http://www.w3.org/2000/09/xmldsig#',
|
|
|
|
xmlns: 'urn:org:ebics:H004',
|
2018-05-17 15:03:59 +00:00
|
|
|
},
|
|
|
|
AuthenticationPubKeyInfo: {
|
|
|
|
PubKeyValue: {
|
2018-06-01 13:16:43 +00:00
|
|
|
'ds:RSAKeyValue': {
|
|
|
|
'ds:Modulus': Buffer.from(this.client.x().n(), 'HEX').toString('base64'),
|
|
|
|
'ds:Exponent': 'AQAB',
|
2018-05-17 15:03:59 +00:00
|
|
|
},
|
|
|
|
},
|
2018-06-01 13:16:43 +00:00
|
|
|
AuthenticationVersion: 'X002',
|
2018-05-17 15:03:59 +00:00
|
|
|
},
|
|
|
|
EncryptionPubKeyInfo: {
|
|
|
|
PubKeyValue: {
|
2018-06-01 13:16:43 +00:00
|
|
|
'ds:RSAKeyValue': {
|
|
|
|
'ds:Modulus': Buffer.from(this.client.e().n(), 'HEX').toString('base64'),
|
|
|
|
'ds:Exponent': 'AQAB',
|
2018-05-17 15:03:59 +00:00
|
|
|
},
|
|
|
|
},
|
2018-06-01 13:16:43 +00:00
|
|
|
EncryptionVersion: 'E002',
|
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('HIARequestOrderData', xmlOrderData, this.xmlOptions);
|
|
|
|
}
|
2018-05-17 15:03:59 +00:00
|
|
|
|
|
|
|
toXML() {
|
|
|
|
return js2xmlparser.parse(this.root(), this._schema, this.xmlOptions);
|
2018-06-01 13:16:43 +00:00
|
|
|
}
|
2018-05-17 15:03:59 +00:00
|
|
|
};
|