isLastSegment() { const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' }); const node = select("//xmlns:header/xmlns:mutable/*[@lastSegment='true']", this.doc); return !!node.length; }
const sign = (doc, key) => { const nodeSignatureValue = doc.getElementsByTagName('ds:SignatureValue')[0]; if (nodeSignatureValue) { const select = xpath.useNamespaces({ ds: 'http://www.w3.org/2000/09/xmldsig#' }); const contentToSign = (new C14n().process(select('//ds:SignedInfo', doc)[0])).replace('xmlns:ds="http://www.w3.org/2000/09/xmldsig#"', 'xmlns="urn:org:ebics:H004" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"'); nodeSignatureValue.textContent = Crypto.privateSign(key, contentToSign); // this.keys.x().key.sign(contentToSign, 'base64'); } return doc; }
bankKeys() { const orderData = this.orderData().toString(); if (!Object.keys(orderData).length) return {}; const doc = new DOMParser().parseFromString(orderData, 'text/xml'); const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' }); const keyNodes = select('//xmlns:PubKeyValue', doc); const bankKeys = {}; if (!keyNodes.length) return {}; for (let i = 0; i < keyNodes.length; i++) { const type = lastChild(keyNodes[i].parentNode).textContent; const modulus = xpath.select(".//*[local-name(.)='Modulus']", keyNodes[i])[0].textContent; const exponent = xpath.select(".//*[local-name(.)='Exponent']", keyNodes[i])[0].textContent; const mod = Buffer.from(modulus, 'base64'); const exp = Buffer.from(exponent, 'base64'); bankKeys[`bank${type}`] = { mod, exp, }; } return bankKeys; }
orderId() { const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' }); const node = select('.//xmlns:header/xmlns:mutable/xmlns:OrderID', this.doc); return node.length ? node[0].textContent : ''; }
businessCode() { const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' }); const node = select('//xmlns:body/xmlns:ReturnCode', this.doc); return node.length ? node[0].textContent : ''; }
technicalSymbol() { const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' }); const node = select('//xmlns:header/xmlns:mutable/xmlns:ReportText', this.doc); return node.length ? node[0].textContent : ''; }
transactionId() { const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' }); const node = select('//xmlns:header/xmlns:static/xmlns:TransactionID', this.doc); return node.length ? node[0].textContent : ''; }
technicalCode() { const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' }); const node = select('//xmlns:header/xmlns:mutable/xmlns:ReturnCode', this.doc); return node.length ? node[0].textContent : ''; }
isSegmented() { const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' }); const node = select('//xmlns:header/xmlns:mutable/xmlns:SegmentNumber', this.doc); return !!node.length; }