node-ebics-client/packages/ebics-client/lib/orders/H004/serializers/generic.js

135 lines
2.2 KiB
JavaScript
Raw Normal View History

2018-06-15 06:33:41 +00:00
'use strict';
2018-06-20 09:20:03 +00:00
const constants = require('../../../consts');
2018-06-15 06:33:41 +00:00
const rootName = 'ebicsRequest';
const rootAttributes = {
'xmlns:ds': 'http://www.w3.org/2000/09/xmldsig#',
xmlns: 'urn:org:ebics:H004',
Version: 'H004',
Revision: '1',
};
const header = {};
const authSignature = ({
'ds:SignedInfo': {
'ds:CanonicalizationMethod': {
'@': {
Algorithm:
'http://www.w3.org/TR/2001/REC-xml-c14n-20010315',
},
},
'ds:SignatureMethod': {
'@': {
Algorithm:
'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
},
},
'ds:Reference': {
'@': { URI: "#xpointer(//*[@authenticate='true'])" },
'ds:Transforms': {
'ds:Transform': {
'@': {
Algorithm:
'http://www.w3.org/TR/2001/REC-xml-c14n-20010315',
},
},
},
'ds:DigestMethod': {
'@': {
Algorithm:
'http://www.w3.org/2001/04/xmlenc#sha256',
},
},
'ds:DigestValue': {},
},
},
'ds:SignatureValue': {},
});
const body = {};
const xmlOptions = {
declaration: {
include: true,
encoding: 'utf-8',
},
format: {
doubleQuotes: true,
indent: '',
newline: '',
pretty: true,
},
};
2018-06-20 09:20:03 +00:00
module.exports = (hostId, transactionId) => ({
// return {
productString: constants.productString,
rootName,
xmlOptions,
xmlSchema: {
'@': rootAttributes,
header,
AuthSignature: authSignature,
body,
},
2018-06-15 06:33:41 +00:00
2018-06-20 09:20:03 +00:00
receipt() {
this.xmlSchema = {
2018-06-15 06:33:41 +00:00
'@': rootAttributes,
2018-06-20 09:20:03 +00:00
header: {
'@': { authenticate: true },
static: {
HostID: hostId,
TransactionID: transactionId,
},
mutable: {
TransactionPhase: 'Receipt',
2018-06-15 06:33:41 +00:00
},
2018-06-20 09:20:03 +00:00
},
2018-06-15 06:33:41 +00:00
2018-06-20 09:20:03 +00:00
AuthSignature: authSignature,
2018-06-15 06:33:41 +00:00
2018-06-20 09:20:03 +00:00
body: {
TransferReceipt: {
'@': { authenticate: true },
ReceiptCode: 0,
2018-06-15 06:33:41 +00:00
},
2018-06-20 09:20:03 +00:00
},
};
2018-06-15 06:33:41 +00:00
2018-06-20 09:20:03 +00:00
return this;
},
2018-06-15 06:33:41 +00:00
2018-06-20 09:20:03 +00:00
transfer(encryptedOrderData) {
this.xmlSchema = {
'@': rootAttributes,
2018-06-15 06:33:41 +00:00
2018-06-20 09:20:03 +00:00
header: {
'@': { authenticate: true },
static: {
HostID: hostId,
TransactionID: transactionId,
},
mutable: {
TransactionPhase: 'Transfer',
SegmentNumber: {
'@': { lastSegment: true },
'#': 1,
2018-06-15 06:33:41 +00:00
},
},
2018-06-20 09:20:03 +00:00
},
2018-06-15 06:33:41 +00:00
2018-06-20 09:20:03 +00:00
AuthSignature: authSignature,
2018-06-15 06:33:41 +00:00
2018-06-20 09:20:03 +00:00
body: {
DataTransfer: {
OrderData: encryptedOrderData,
2018-06-15 06:33:41 +00:00
},
2018-06-20 09:20:03 +00:00
},
};
2018-06-15 06:33:41 +00:00
2018-06-20 09:20:03 +00:00
return this;
},
// };
});