lib-fints 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/camtParser.js +21 -9
- package/dist/client.js +31 -20
- package/dist/config.js +10 -6
- package/dist/dataElements/AlphaNumeric.js +1 -1
- package/dist/dataElements/DataElement.js +2 -1
- package/dist/dataElements/Digits.js +1 -1
- package/dist/dataElements/Float.js +1 -1
- package/dist/dataElements/Numeric.js +2 -2
- package/dist/dataElements/Text.js +1 -1
- package/dist/dataGroups/Account.js +1 -1
- package/dist/dataGroups/Balance.js +2 -2
- package/dist/dataGroups/BankIdentification.js +1 -1
- package/dist/dataGroups/DataGroup.js +13 -6
- package/dist/dataGroups/InternationalAccount.js +1 -1
- package/dist/dataGroups/Money.js +1 -1
- package/dist/dataGroups/RefMessage.js +1 -1
- package/dist/dataGroups/SepaAccount.js +2 -2
- package/dist/dataGroups/SepaAccountParameters.js +2 -2
- package/dist/dataGroups/TimeStamp.js +1 -1
- package/dist/decoder.js +12 -6
- package/dist/dialog.js +33 -19
- package/dist/encoder.js +16 -4
- package/dist/format.js +2 -2
- package/dist/httpClient.js +4 -2
- package/dist/index.js +10 -10
- package/dist/interactions/balanceInteraction.js +2 -5
- package/dist/interactions/creditcardStatementInteraction.js +11 -11
- package/dist/interactions/customerInteraction.js +1 -1
- package/dist/interactions/endDialogInteraction.js +4 -4
- package/dist/interactions/initDialogInteraction.js +23 -20
- package/dist/interactions/portfolioInteraction.js +3 -3
- package/dist/interactions/sepaAccountInteraction.js +3 -3
- package/dist/interactions/statementInteractionCAMT.js +4 -4
- package/dist/interactions/statementInteractionMT940.js +4 -4
- package/dist/interactions/tanMediaInteraction.js +4 -4
- package/dist/message.js +51 -18
- package/dist/mt535parser.js +3 -5
- package/dist/mt940parser.js +18 -17
- package/dist/parser.js +1 -1
- package/dist/segment.js +12 -7
- package/dist/segmentDefinition.js +5 -2
- package/dist/segmentHeader.js +1 -1
- package/dist/segments/DIKKU.js +3 -3
- package/dist/segments/DKKKU.js +2 -2
- package/dist/segments/HIBPA.js +2 -2
- package/dist/segments/HICAZ.js +1 -1
- package/dist/segments/HICAZS.js +3 -3
- package/dist/segments/HIKAZS.js +7 -3
- package/dist/segments/HIKIM.js +1 -1
- package/dist/segments/HIKOM.js +1 -1
- package/dist/segments/HIPINS.js +3 -3
- package/dist/segments/HIRMG.js +1 -1
- package/dist/segments/HIRMS.js +1 -1
- package/dist/segments/HISAL.js +3 -3
- package/dist/segments/HISPAS.js +3 -4
- package/dist/segments/HISYN.js +1 -1
- package/dist/segments/HITAB.js +3 -3
- package/dist/segments/HITAN.js +3 -3
- package/dist/segments/HITANS.js +3 -3
- package/dist/segments/HIUPA.js +2 -2
- package/dist/segments/HIUPD.js +8 -4
- package/dist/segments/HKCAZ.js +3 -3
- package/dist/segments/HKIDN.js +1 -1
- package/dist/segments/HKKAZ.js +3 -3
- package/dist/segments/HKSAL.js +3 -3
- package/dist/segments/HKSPA.js +1 -1
- package/dist/segments/HKTAB.js +1 -1
- package/dist/segments/HKTAN.js +3 -3
- package/dist/segments/HKVVB.js +1 -1
- package/dist/segments/HKWPD.js +1 -1
- package/dist/segments/HNHBK.js +1 -1
- package/dist/segments/HNSHA.js +1 -1
- package/dist/segments/HNSHK.js +14 -6
- package/dist/segments/HNVSK.js +10 -6
- package/dist/segments/registry.js +31 -31
- package/dist/tests/HIBPA.test.js +3 -3
- package/dist/tests/HICAZS.test.js +2 -2
- package/dist/tests/HIPINS.test.js +2 -2
- package/dist/tests/HIRMG.test.js +2 -2
- package/dist/tests/HITAB.test.js +5 -5
- package/dist/tests/HITANS.test.js +2 -2
- package/dist/tests/HIUPA.test.js +2 -2
- package/dist/tests/HIUPD.test.js +2 -2
- package/dist/tests/HIWPD.test.js +2 -2
- package/dist/tests/HKCAZ.test.js +3 -3
- package/dist/tests/HKIDN.test.js +2 -2
- package/dist/tests/HKSAL.test.js +3 -3
- package/dist/tests/HKTAN.test.js +4 -4
- package/dist/tests/HKWPD.test.js +2 -2
- package/dist/tests/HNSHK.test.js +2 -2
- package/dist/tests/HNVSK.test.js +2 -2
- package/dist/tests/camtParser.test.js +188 -3
- package/dist/tests/client.test.js +15 -15
- package/dist/tests/datatypes.test.js +1 -1
- package/dist/tests/dialog.test.js +21 -14
- package/dist/tests/message.test.js +4 -4
- package/dist/tests/mt535parser.test.js +1 -3
- package/dist/types/accountBalance.d.ts.map +1 -1
- package/dist/types/bankAccount.d.ts +2 -2
- package/dist/types/bankAccount.d.ts.map +1 -1
- package/dist/types/bankAnswer.d.ts.map +1 -1
- package/dist/types/bankTransaction.d.ts.map +1 -1
- package/dist/types/bankingInformation.d.ts +2 -2
- package/dist/types/bankingInformation.d.ts.map +1 -1
- package/dist/types/bpd.d.ts +3 -3
- package/dist/types/bpd.d.ts.map +1 -1
- package/dist/types/camtParser.d.ts +1 -1
- package/dist/types/camtParser.d.ts.map +1 -1
- package/dist/types/client.d.ts +11 -11
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/config.d.ts +4 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/creditCardStatement.d.ts.map +1 -1
- package/dist/types/dataElements/AlphaNumeric.d.ts.map +1 -1
- package/dist/types/dataElements/Amount.d.ts.map +1 -1
- package/dist/types/dataElements/Binary.d.ts.map +1 -1
- package/dist/types/dataElements/Country.d.ts.map +1 -1
- package/dist/types/dataElements/Currency.d.ts.map +1 -1
- package/dist/types/dataElements/Dat.d.ts.map +1 -1
- package/dist/types/dataElements/DataElement.d.ts +3 -3
- package/dist/types/dataElements/DataElement.d.ts.map +1 -1
- package/dist/types/dataElements/Digits.d.ts.map +1 -1
- package/dist/types/dataElements/Float.d.ts.map +1 -1
- package/dist/types/dataElements/Identification.d.ts.map +1 -1
- package/dist/types/dataElements/Numeric.d.ts.map +1 -1
- package/dist/types/dataElements/Text.d.ts.map +1 -1
- package/dist/types/dataElements/Time.d.ts.map +1 -1
- package/dist/types/dataElements/YesNo.d.ts.map +1 -1
- package/dist/types/dataGroups/Account.d.ts.map +1 -1
- package/dist/types/dataGroups/Balance.d.ts +1 -1
- package/dist/types/dataGroups/Balance.d.ts.map +1 -1
- package/dist/types/dataGroups/BankIdentification.d.ts.map +1 -1
- package/dist/types/dataGroups/DataGroup.d.ts +3 -3
- package/dist/types/dataGroups/DataGroup.d.ts.map +1 -1
- package/dist/types/dataGroups/InternationalAccount.d.ts +1 -1
- package/dist/types/dataGroups/InternationalAccount.d.ts.map +1 -1
- package/dist/types/dataGroups/Money.d.ts.map +1 -1
- package/dist/types/dataGroups/RefMessage.d.ts.map +1 -1
- package/dist/types/dataGroups/SepaAccount.d.ts +1 -1
- package/dist/types/dataGroups/SepaAccount.d.ts.map +1 -1
- package/dist/types/dataGroups/TimeStamp.d.ts.map +1 -1
- package/dist/types/decoder.d.ts +2 -2
- package/dist/types/decoder.d.ts.map +1 -1
- package/dist/types/dialog.d.ts +2 -2
- package/dist/types/dialog.d.ts.map +1 -1
- package/dist/types/encoder.d.ts +2 -2
- package/dist/types/encoder.d.ts.map +1 -1
- package/dist/types/httpClient.d.ts +1 -1
- package/dist/types/httpClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +12 -13
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interactions/balanceInteraction.d.ts +5 -5
- package/dist/types/interactions/balanceInteraction.d.ts.map +1 -1
- package/dist/types/interactions/creditcardStatementInteraction.d.ts +6 -6
- package/dist/types/interactions/creditcardStatementInteraction.d.ts.map +1 -1
- package/dist/types/interactions/customerInteraction.d.ts +6 -6
- package/dist/types/interactions/customerInteraction.d.ts.map +1 -1
- package/dist/types/interactions/endDialogInteraction.d.ts +6 -6
- package/dist/types/interactions/endDialogInteraction.d.ts.map +1 -1
- package/dist/types/interactions/initDialogInteraction.d.ts +5 -5
- package/dist/types/interactions/initDialogInteraction.d.ts.map +1 -1
- package/dist/types/interactions/portfolioInteraction.d.ts +5 -5
- package/dist/types/interactions/portfolioInteraction.d.ts.map +1 -1
- package/dist/types/interactions/sepaAccountInteraction.d.ts +5 -5
- package/dist/types/interactions/sepaAccountInteraction.d.ts.map +1 -1
- package/dist/types/interactions/statementInteractionCAMT.d.ts +4 -4
- package/dist/types/interactions/statementInteractionCAMT.d.ts.map +1 -1
- package/dist/types/interactions/statementInteractionMT940.d.ts +4 -4
- package/dist/types/interactions/statementInteractionMT940.d.ts.map +1 -1
- package/dist/types/interactions/tanMediaInteraction.d.ts +4 -4
- package/dist/types/interactions/tanMediaInteraction.d.ts.map +1 -1
- package/dist/types/message.d.ts +3 -3
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/mt535parser.d.ts +0 -1
- package/dist/types/mt535parser.d.ts.map +1 -1
- package/dist/types/mt940parser.d.ts +1 -2
- package/dist/types/mt940parser.d.ts.map +1 -1
- package/dist/types/partedSegment.d.ts +1 -1
- package/dist/types/partedSegment.d.ts.map +1 -1
- package/dist/types/segment.d.ts +1 -1
- package/dist/types/segment.d.ts.map +1 -1
- package/dist/types/segmentDefinition.d.ts +2 -2
- package/dist/types/segmentDefinition.d.ts.map +1 -1
- package/dist/types/segmentHeader.d.ts.map +1 -1
- package/dist/types/segments/DIKKU.d.ts +4 -4
- package/dist/types/segments/DIKKU.d.ts.map +1 -1
- package/dist/types/segments/DKKKU.d.ts +3 -3
- package/dist/types/segments/DKKKU.d.ts.map +1 -1
- package/dist/types/segments/HIBPA.d.ts +5 -5
- package/dist/types/segments/HIBPA.d.ts.map +1 -1
- package/dist/types/segments/HICAZ.d.ts +2 -2
- package/dist/types/segments/HICAZ.d.ts.map +1 -1
- package/dist/types/segments/HICAZS.d.ts +1 -1
- package/dist/types/segments/HICAZS.d.ts.map +1 -1
- package/dist/types/segments/HIKAZ.d.ts +1 -1
- package/dist/types/segments/HIKAZ.d.ts.map +1 -1
- package/dist/types/segments/HIKAZS.d.ts +1 -1
- package/dist/types/segments/HIKAZS.d.ts.map +1 -1
- package/dist/types/segments/HIKIM.d.ts +2 -2
- package/dist/types/segments/HIKIM.d.ts.map +1 -1
- package/dist/types/segments/HIKOM.d.ts +3 -3
- package/dist/types/segments/HIKOM.d.ts.map +1 -1
- package/dist/types/segments/HIPINS.d.ts +1 -1
- package/dist/types/segments/HIPINS.d.ts.map +1 -1
- package/dist/types/segments/HIRMG.d.ts +1 -1
- package/dist/types/segments/HIRMG.d.ts.map +1 -1
- package/dist/types/segments/HIRMS.d.ts +2 -2
- package/dist/types/segments/HIRMS.d.ts.map +1 -1
- package/dist/types/segments/HISAL.d.ts +7 -7
- package/dist/types/segments/HISAL.d.ts.map +1 -1
- package/dist/types/segments/HISPA.d.ts +2 -2
- package/dist/types/segments/HISPA.d.ts.map +1 -1
- package/dist/types/segments/HISPAS.d.ts +2 -2
- package/dist/types/segments/HISPAS.d.ts.map +1 -1
- package/dist/types/segments/HISYN.d.ts +2 -2
- package/dist/types/segments/HISYN.d.ts.map +1 -1
- package/dist/types/segments/HITAB.d.ts +4 -4
- package/dist/types/segments/HITAB.d.ts.map +1 -1
- package/dist/types/segments/HITAN.d.ts +5 -5
- package/dist/types/segments/HITAN.d.ts.map +1 -1
- package/dist/types/segments/HITANS.d.ts +2 -2
- package/dist/types/segments/HITANS.d.ts.map +1 -1
- package/dist/types/segments/HIUPA.d.ts +3 -3
- package/dist/types/segments/HIUPA.d.ts.map +1 -1
- package/dist/types/segments/HIUPD.d.ts +6 -6
- package/dist/types/segments/HIUPD.d.ts.map +1 -1
- package/dist/types/segments/HIWPD.d.ts +1 -1
- package/dist/types/segments/HIWPD.d.ts.map +1 -1
- package/dist/types/segments/HKCAZ.d.ts +5 -5
- package/dist/types/segments/HKCAZ.d.ts.map +1 -1
- package/dist/types/segments/HKEND.d.ts +1 -1
- package/dist/types/segments/HKEND.d.ts.map +1 -1
- package/dist/types/segments/HKIDN.d.ts +3 -3
- package/dist/types/segments/HKIDN.d.ts.map +1 -1
- package/dist/types/segments/HKKAZ.d.ts +5 -5
- package/dist/types/segments/HKKAZ.d.ts.map +1 -1
- package/dist/types/segments/HKSAL.d.ts +6 -6
- package/dist/types/segments/HKSAL.d.ts.map +1 -1
- package/dist/types/segments/HKSPA.d.ts +3 -3
- package/dist/types/segments/HKSPA.d.ts.map +1 -1
- package/dist/types/segments/HKSYN.d.ts +2 -2
- package/dist/types/segments/HKSYN.d.ts.map +1 -1
- package/dist/types/segments/HKTAB.d.ts +3 -3
- package/dist/types/segments/HKTAB.d.ts.map +1 -1
- package/dist/types/segments/HKTAN.d.ts +6 -6
- package/dist/types/segments/HKTAN.d.ts.map +1 -1
- package/dist/types/segments/HKVVB.d.ts +3 -3
- package/dist/types/segments/HKVVB.d.ts.map +1 -1
- package/dist/types/segments/HKWPD.d.ts +2 -2
- package/dist/types/segments/HKWPD.d.ts.map +1 -1
- package/dist/types/segments/HNHBK.d.ts +3 -3
- package/dist/types/segments/HNHBK.d.ts.map +1 -1
- package/dist/types/segments/HNHBS.d.ts +1 -1
- package/dist/types/segments/HNHBS.d.ts.map +1 -1
- package/dist/types/segments/HNSHA.d.ts +3 -3
- package/dist/types/segments/HNSHA.d.ts.map +1 -1
- package/dist/types/segments/HNSHK.d.ts +4 -4
- package/dist/types/segments/HNSHK.d.ts.map +1 -1
- package/dist/types/segments/HNVSD.d.ts +2 -2
- package/dist/types/segments/HNVSD.d.ts.map +1 -1
- package/dist/types/segments/HNVSK.d.ts +4 -4
- package/dist/types/segments/HNVSK.d.ts.map +1 -1
- package/dist/types/segments/businessTransactionParameter.d.ts +2 -2
- package/dist/types/segments/businessTransactionParameter.d.ts.map +1 -1
- package/dist/types/segments/registry.d.ts +1 -1
- package/dist/types/segments/registry.d.ts.map +1 -1
- package/dist/types/tanMethod.d.ts +1 -1
- package/dist/types/tanMethod.d.ts.map +1 -1
- package/dist/types/unknownSegment.d.ts +1 -1
- package/dist/types/unknownSegment.d.ts.map +1 -1
- package/dist/types/upd.d.ts +2 -2
- package/dist/types/upd.d.ts.map +1 -1
- package/package.json +48 -47
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://github.com/robocode13/lib-fints/actions/workflows/ci.yml)
|
|
2
2
|
|
|
3
3
|
# Lib-FinTS
|
|
4
4
|
|
package/dist/camtParser.js
CHANGED
|
@@ -75,7 +75,9 @@ export class CamtParser {
|
|
|
75
75
|
}
|
|
76
76
|
// Look for any object with BkToCstmrAcctRpt property
|
|
77
77
|
for (const key in document) {
|
|
78
|
-
if (document[key] &&
|
|
78
|
+
if (document[key] &&
|
|
79
|
+
typeof document[key] === 'object' &&
|
|
80
|
+
document[key]?.BkToCstmrAcctRpt) {
|
|
79
81
|
return document[key];
|
|
80
82
|
}
|
|
81
83
|
}
|
|
@@ -130,12 +132,16 @@ export class CamtParser {
|
|
|
130
132
|
}
|
|
131
133
|
// Parse transactions
|
|
132
134
|
const transactions = this.parseTransactions(report, reportNumber);
|
|
135
|
+
// At this point we should have both balances, otherwise throw an error
|
|
136
|
+
if (!openingBalance || !closingBalance) {
|
|
137
|
+
throw new CamtParsingError(`Unable to determine required balances for CAMT report ${reportNumber}`);
|
|
138
|
+
}
|
|
133
139
|
return {
|
|
134
140
|
account,
|
|
135
141
|
number,
|
|
136
142
|
transactionReference,
|
|
137
|
-
openingBalance
|
|
138
|
-
closingBalance
|
|
143
|
+
openingBalance,
|
|
144
|
+
closingBalance,
|
|
139
145
|
availableBalance: balances.availableBalance,
|
|
140
146
|
transactions,
|
|
141
147
|
};
|
|
@@ -151,7 +157,7 @@ export class CamtParser {
|
|
|
151
157
|
const pathParts = path.split('.');
|
|
152
158
|
let current = obj;
|
|
153
159
|
for (const part of pathParts) {
|
|
154
|
-
if (current && typeof current === 'object' && current
|
|
160
|
+
if (current && typeof current === 'object' && current !== null && part in current) {
|
|
155
161
|
current = current[part];
|
|
156
162
|
}
|
|
157
163
|
else {
|
|
@@ -161,7 +167,10 @@ export class CamtParser {
|
|
|
161
167
|
if (typeof current === 'string' || typeof current === 'number') {
|
|
162
168
|
return String(current);
|
|
163
169
|
}
|
|
164
|
-
if (current
|
|
170
|
+
if (Array.isArray(current)) {
|
|
171
|
+
return String(current.join(''));
|
|
172
|
+
}
|
|
173
|
+
if (current && typeof current === 'object' && current !== null && '#text' in current) {
|
|
165
174
|
return String(current['#text']);
|
|
166
175
|
}
|
|
167
176
|
return undefined;
|
|
@@ -180,7 +189,10 @@ export class CamtParser {
|
|
|
180
189
|
for (const balanceObj of balanceArray) {
|
|
181
190
|
const typeCode = this.getValueFromPath(balanceObj, 'Tp.CdOrPrtry.Cd');
|
|
182
191
|
// Extract amount and currency
|
|
183
|
-
|
|
192
|
+
let currency = 'EUR';
|
|
193
|
+
if (balanceObj.Amt && typeof balanceObj.Amt === 'object' && '@Ccy' in balanceObj.Amt) {
|
|
194
|
+
currency = balanceObj.Amt['@Ccy'] || 'EUR';
|
|
195
|
+
}
|
|
184
196
|
const value = parseFloat(this.getValueFromPath(balanceObj, 'Amt') || '0');
|
|
185
197
|
const creditDebitInd = this.getValueFromPath(balanceObj, 'CdtDbtInd');
|
|
186
198
|
const finalValue = creditDebitInd === 'DBIT' ? -value : value;
|
|
@@ -237,7 +249,7 @@ export class CamtParser {
|
|
|
237
249
|
const entryArray = Array.isArray(entries) ? entries : [entries];
|
|
238
250
|
for (let i = 0; i < entryArray.length; i++) {
|
|
239
251
|
try {
|
|
240
|
-
const transaction = this.parseTransaction(entryArray[i]
|
|
252
|
+
const transaction = this.parseTransaction(entryArray[i]);
|
|
241
253
|
if (transaction) {
|
|
242
254
|
transactions.push(transaction);
|
|
243
255
|
}
|
|
@@ -248,7 +260,7 @@ export class CamtParser {
|
|
|
248
260
|
}
|
|
249
261
|
return transactions;
|
|
250
262
|
}
|
|
251
|
-
parseTransaction(entry
|
|
263
|
+
parseTransaction(entry) {
|
|
252
264
|
try {
|
|
253
265
|
// Extract amount and credit/debit indicator
|
|
254
266
|
const amountValue = parseFloat(this.getValueFromPath(entry, 'Amt') || '0');
|
|
@@ -381,7 +393,7 @@ export class CamtParser {
|
|
|
381
393
|
parseDate(dateStr) {
|
|
382
394
|
// Parse ISO date format (YYYY-MM-DD)
|
|
383
395
|
if (dateStr.length === 10 && dateStr.includes('-')) {
|
|
384
|
-
return new Date(dateStr
|
|
396
|
+
return new Date(`${dateStr}T12:00:00`); // Set time to noon to avoid timezone issues
|
|
385
397
|
}
|
|
386
398
|
// Parse CAMT date format (YYYYMMDD)
|
|
387
399
|
if (dateStr.length === 8) {
|
package/dist/client.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { FinTSConfig } from './config.js';
|
|
1
2
|
import { Dialog } from './dialog.js';
|
|
2
|
-
import {
|
|
3
|
+
import { BalanceInteraction, } from './interactions/balanceInteraction.js';
|
|
4
|
+
import { CreditCardStatementInteraction } from './interactions/creditcardStatementInteraction.js';
|
|
5
|
+
import { PortfolioInteraction, } from './interactions/portfolioInteraction.js';
|
|
3
6
|
import { StatementInteractionCAMT } from './interactions/statementInteractionCAMT.js';
|
|
4
|
-
import {
|
|
5
|
-
import { PortfolioInteraction } from './interactions/portfolioInteraction.js';
|
|
6
|
-
import { FinTSConfig } from './config.js';
|
|
7
|
-
import { HKSAL } from './segments/HKSAL.js';
|
|
8
|
-
import { HKKAZ } from './segments/HKKAZ.js';
|
|
9
|
-
import { HKCAZ } from './segments/HKCAZ.js';
|
|
10
|
-
import { HKWPD } from './segments/HKWPD.js';
|
|
7
|
+
import { StatementInteractionMT940 } from './interactions/statementInteractionMT940.js';
|
|
11
8
|
import { DKKKU } from './segments/DKKKU.js';
|
|
12
|
-
import {
|
|
9
|
+
import { HKCAZ } from './segments/HKCAZ.js';
|
|
13
10
|
import { HKIDN } from './segments/HKIDN.js';
|
|
11
|
+
import { HKKAZ } from './segments/HKKAZ.js';
|
|
12
|
+
import { HKSAL } from './segments/HKSAL.js';
|
|
13
|
+
import { HKWPD } from './segments/HKWPD.js';
|
|
14
14
|
/**
|
|
15
15
|
* A client to communicate with a bank over the FinTS protocol
|
|
16
16
|
*/
|
|
@@ -36,8 +36,7 @@ export class FinTSClient {
|
|
|
36
36
|
* @returns the selected TAN method
|
|
37
37
|
*/
|
|
38
38
|
selectTanMethod(tanMethodId) {
|
|
39
|
-
this.config.selectTanMethod(tanMethodId);
|
|
40
|
-
return this.config.selectedTanMethod;
|
|
39
|
+
return this.config.selectTanMethod(tanMethodId);
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
43
42
|
* Selects a TAN media by its name
|
|
@@ -105,7 +104,7 @@ export class FinTSClient {
|
|
|
105
104
|
}
|
|
106
105
|
else {
|
|
107
106
|
// Check if either CAMT or MT940 is supported by the bank
|
|
108
|
-
return this.config.isTransactionSupported(HKCAZ.Id) || this.config.isTransactionSupported(HKKAZ.Id);
|
|
107
|
+
return (this.config.isTransactionSupported(HKCAZ.Id) || this.config.isTransactionSupported(HKKAZ.Id));
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
/**
|
|
@@ -163,12 +162,12 @@ export class FinTSClient {
|
|
|
163
162
|
return (await this.startCustomerOrderInteraction(new PortfolioInteraction(accountNumber, currency, priceQuality, maxEntries)));
|
|
164
163
|
}
|
|
165
164
|
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
* Continues the portfolio fetching when a TAN is required
|
|
166
|
+
* @param tanReference The TAN reference provided in the first call's response
|
|
167
|
+
|
|
168
|
+
* @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
|
|
169
|
+
* @returns a portfolio response containing holdings and total value
|
|
170
|
+
*/
|
|
172
171
|
async getPortfolioWithTan(tanReference, tan) {
|
|
173
172
|
return (await this.continueCustomerInteractionWithTan([HKWPD.Id], tanReference, tan));
|
|
174
173
|
}
|
|
@@ -211,7 +210,13 @@ export class FinTSClient {
|
|
|
211
210
|
return response;
|
|
212
211
|
}
|
|
213
212
|
else {
|
|
214
|
-
|
|
213
|
+
const lastResponse = [...responses.values()].at(-1);
|
|
214
|
+
if (lastResponse) {
|
|
215
|
+
return lastResponse;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
throw new Error(`No response received for customer interaction with segment ID '${interaction.segId}'`);
|
|
219
|
+
}
|
|
215
220
|
}
|
|
216
221
|
}
|
|
217
222
|
async continueCustomerInteractionWithTan(segIds, tanReference, tan) {
|
|
@@ -225,6 +230,12 @@ export class FinTSClient {
|
|
|
225
230
|
return response;
|
|
226
231
|
}
|
|
227
232
|
}
|
|
228
|
-
|
|
233
|
+
const lastResponse = [...responses.values()].at(-1);
|
|
234
|
+
if (lastResponse) {
|
|
235
|
+
return lastResponse;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
throw new Error(`No response received for customer interaction with segment IDs '${segIds.join(', ')}'`);
|
|
239
|
+
}
|
|
229
240
|
}
|
|
230
241
|
}
|
package/dist/config.js
CHANGED
|
@@ -89,19 +89,19 @@ export class FinTSConfig {
|
|
|
89
89
|
* The FinTS URL of the bank
|
|
90
90
|
*/
|
|
91
91
|
get bankingUrl() {
|
|
92
|
-
return this.bankingInformation.bpd?.url ?? this.url;
|
|
92
|
+
return this.bankingInformation.bpd?.url ?? this.url ?? '';
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* The country code of the bank
|
|
96
96
|
*/
|
|
97
97
|
get countryCode() {
|
|
98
|
-
return this.bankingInformation.bpd?.countryCode ?? this.country;
|
|
98
|
+
return this.bankingInformation.bpd?.countryCode ?? this.country ?? 280;
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* The bank ID (BLZ)
|
|
102
102
|
*/
|
|
103
103
|
get bankId() {
|
|
104
|
-
return this.bankingInformation.bpd?.bankId ?? this.bankIdentification;
|
|
104
|
+
return this.bankingInformation.bpd?.bankId ?? this.bankIdentification ?? '';
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
107
|
* A list of all available TAN methods for the user
|
|
@@ -114,10 +114,12 @@ export class FinTSConfig {
|
|
|
114
114
|
* @param tanMethodId The ID of the TAN method to select, corresponding to an ID in availableTanMethods
|
|
115
115
|
*/
|
|
116
116
|
selectTanMethod(tanMethodId) {
|
|
117
|
-
|
|
117
|
+
const tanMethod = this.availableTanMethods.find((method) => method.id === tanMethodId);
|
|
118
|
+
if (!tanMethod) {
|
|
118
119
|
throw new Error(`TAN Method '${tanMethodId}' is not supported`);
|
|
119
120
|
}
|
|
120
121
|
this.tanMethodId = tanMethodId;
|
|
122
|
+
return tanMethod;
|
|
121
123
|
}
|
|
122
124
|
/**
|
|
123
125
|
* Selects a TAN media by its name for the user
|
|
@@ -143,7 +145,8 @@ export class FinTSConfig {
|
|
|
143
145
|
* @param transId The transaction ID
|
|
144
146
|
*/
|
|
145
147
|
isTransactionSupported(transId) {
|
|
146
|
-
return this.bankingInformation.bpd?.allowedTransactions.find((t) => t.transId === transId) !==
|
|
148
|
+
return (this.bankingInformation.bpd?.allowedTransactions.find((t) => t.transId === transId) !==
|
|
149
|
+
undefined);
|
|
147
150
|
}
|
|
148
151
|
/**
|
|
149
152
|
* Checks if a transaction is supported for a specific account
|
|
@@ -163,7 +166,8 @@ export class FinTSConfig {
|
|
|
163
166
|
if (!definition) {
|
|
164
167
|
throw new Error(`segment definition for ${transId} not registered`);
|
|
165
168
|
}
|
|
166
|
-
const allowedVersions = this.bankingInformation.bpd?.allowedTransactions.find((t) => t.transId === transId)
|
|
169
|
+
const allowedVersions = this.bankingInformation.bpd?.allowedTransactions.find((t) => t.transId === transId)
|
|
170
|
+
?.versions ?? [];
|
|
167
171
|
const maxSupportedversion = allowedVersions.sort().findLast((version) => version <= definition.version) ?? undefined;
|
|
168
172
|
return maxSupportedversion;
|
|
169
173
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataElement } from './DataElement.js';
|
|
2
1
|
import { finTsDecode, finTsEncode } from '../format.js';
|
|
2
|
+
import { DataElement } from './DataElement.js';
|
|
3
3
|
export class AlphaNumeric extends DataElement {
|
|
4
4
|
maxLength;
|
|
5
5
|
constructor(name, minCount = 0, maxCount = 1, maxLength, minVersion, maxVersion) {
|
|
@@ -21,7 +21,8 @@ export class DataElement {
|
|
|
21
21
|
return this.isInVersion(version) ? 1 : 0;
|
|
22
22
|
}
|
|
23
23
|
isInVersion(version) {
|
|
24
|
-
return (!this.minVersion || version >= this.minVersion) &&
|
|
24
|
+
return ((!this.minVersion || version >= this.minVersion) &&
|
|
25
|
+
(!this.maxVersion || version <= this.maxVersion));
|
|
25
26
|
}
|
|
26
27
|
toString(value) {
|
|
27
28
|
if (value !== undefined && value !== null && value !== '') {
|
|
@@ -13,7 +13,7 @@ export class Float extends DataElement {
|
|
|
13
13
|
throw Error(`the Float value '${this.name}' must not exceed its maximum length`);
|
|
14
14
|
}
|
|
15
15
|
const text = value.toString().replace('.', ',');
|
|
16
|
-
return text.indexOf(',') >= 0 ? text : text
|
|
16
|
+
return text.indexOf(',') >= 0 ? text : `${text},`;
|
|
17
17
|
}
|
|
18
18
|
decode(text) {
|
|
19
19
|
return Number.parseFloat(text.replace(',', '.'));
|
|
@@ -18,9 +18,9 @@ export class Numeric extends DataElement {
|
|
|
18
18
|
return value.toString();
|
|
19
19
|
}
|
|
20
20
|
decode(text) {
|
|
21
|
-
return Number.parseInt(text);
|
|
21
|
+
return Number.parseInt(text, 10);
|
|
22
22
|
}
|
|
23
23
|
static decode(text) {
|
|
24
|
-
return Number.parseInt(text);
|
|
24
|
+
return Number.parseInt(text, 10);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataElement } from './DataElement.js';
|
|
2
1
|
import { finTsDecode, finTsEncode } from '../format.js';
|
|
2
|
+
import { DataElement } from './DataElement.js';
|
|
3
3
|
export class Text extends DataElement {
|
|
4
4
|
maxLength;
|
|
5
5
|
constructor(name, minCount = 0, maxCount = 1, maxLength, minVersion, maxVersion) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DataGroup } from './DataGroup.js';
|
|
2
1
|
import { Identification } from '../dataElements/Identification.js';
|
|
3
2
|
import { BankIdentification } from './BankIdentification.js';
|
|
3
|
+
import { DataGroup } from './DataGroup.js';
|
|
4
4
|
export class AccountGroup extends DataGroup {
|
|
5
5
|
constructor(name, minCount = 0, maxCount = 1, minVersion, maxVersion) {
|
|
6
6
|
super(name, [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Time } from '../dataElements/Time.js';
|
|
2
|
-
import { Dat } from '../dataElements/Dat.js';
|
|
3
1
|
import { AlphaNumeric } from '../dataElements/AlphaNumeric.js';
|
|
2
|
+
import { Dat } from '../dataElements/Dat.js';
|
|
3
|
+
import { Time } from '../dataElements/Time.js';
|
|
4
4
|
import { DataGroup } from './DataGroup.js';
|
|
5
5
|
import { MoneyGroup } from './Money.js';
|
|
6
6
|
export class BalanceGroup extends DataGroup {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AlphaNumeric } from '../dataElements/AlphaNumeric.js';
|
|
2
|
-
import { DataGroup } from './DataGroup.js';
|
|
3
2
|
import { Country } from '../dataElements/Country.js';
|
|
3
|
+
import { DataGroup } from './DataGroup.js';
|
|
4
4
|
export class BankIdentification extends DataGroup {
|
|
5
5
|
constructor(name, minCount = 0, maxCount = 1, minVersion, maxVersion) {
|
|
6
6
|
super(name, [new Country('country', 1, 1), new AlphaNumeric('bankId', 1, 1, 30)], minCount, maxCount, minVersion, maxVersion);
|
|
@@ -21,7 +21,10 @@ export class DataGroup extends DataElement {
|
|
|
21
21
|
throw new Error('version is required for encoding an element group');
|
|
22
22
|
}
|
|
23
23
|
const isSingleArray = this.elements.length === 1 && this.elements[0].maxCount > 1;
|
|
24
|
-
return encodeElements(isSingleArray ? [values] : values, this.elements, ':', version, [
|
|
24
|
+
return encodeElements(isSingleArray ? [values] : values, this.elements, ':', version, [
|
|
25
|
+
...context,
|
|
26
|
+
this.name,
|
|
27
|
+
]);
|
|
25
28
|
}
|
|
26
29
|
decode(text, version) {
|
|
27
30
|
if (!text.replaceAll(':', '')) {
|
|
@@ -36,18 +39,22 @@ export class DataGroup extends DataElement {
|
|
|
36
39
|
if (!values) {
|
|
37
40
|
return '';
|
|
38
41
|
}
|
|
39
|
-
|
|
42
|
+
const texts = this.elements.map((element) => {
|
|
40
43
|
if (element.maxCount > 1) {
|
|
41
|
-
if (this.elements.length === 1) {
|
|
44
|
+
if (this.elements.length === 1 && Array.isArray(values)) {
|
|
42
45
|
return values.map((value) => element.toString(value)).join('; ');
|
|
43
46
|
}
|
|
44
|
-
else {
|
|
45
|
-
|
|
47
|
+
else if (!Array.isArray(values)) {
|
|
48
|
+
const currentValue = values[element.name];
|
|
49
|
+
return Array.isArray(currentValue)
|
|
50
|
+
? currentValue.map((value) => element.toString(value)).join('; ')
|
|
51
|
+
: element.toString(currentValue);
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
|
-
else {
|
|
54
|
+
else if (!Array.isArray(values)) {
|
|
49
55
|
return element.toString(values[element.name]);
|
|
50
56
|
}
|
|
57
|
+
return element.toString(undefined);
|
|
51
58
|
});
|
|
52
59
|
return `[${texts.filter((text) => !!text).join(', ')}]`;
|
|
53
60
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AlphaNumeric } from '../dataElements/AlphaNumeric.js';
|
|
2
|
-
import { DataGroup } from './DataGroup.js';
|
|
3
2
|
import { Identification } from '../dataElements/Identification.js';
|
|
4
3
|
import { BankIdentification } from './BankIdentification.js';
|
|
4
|
+
import { DataGroup } from './DataGroup.js';
|
|
5
5
|
export class InternationalAccountGroup extends DataGroup {
|
|
6
6
|
constructor(name, minCount = 0, maxCount = 1, minVersion, maxVersion) {
|
|
7
7
|
super(name, [
|
package/dist/dataGroups/Money.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DataGroup } from './DataGroup.js';
|
|
2
1
|
import { Amount } from '../dataElements/Amount.js';
|
|
3
2
|
import { Currency } from '../dataElements/Currency.js';
|
|
3
|
+
import { DataGroup } from './DataGroup.js';
|
|
4
4
|
export class MoneyGroup extends DataGroup {
|
|
5
5
|
constructor(name, minCount = 0, maxCount = 1, minVersion, maxVersion) {
|
|
6
6
|
super(name, [new Amount('value', 1, 1), new Currency('currency', 1, 1)], minCount, maxCount, minVersion, maxVersion);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Identification } from '../dataElements/Identification.js';
|
|
1
2
|
import { Numeric } from '../dataElements/Numeric.js';
|
|
2
3
|
import { DataGroup } from './DataGroup.js';
|
|
3
|
-
import { Identification } from '../dataElements/Identification.js';
|
|
4
4
|
export class RefMessageGroup extends DataGroup {
|
|
5
5
|
constructor(name, minCount = 0, maxCount = 1, minVersion, maxVersion) {
|
|
6
6
|
super(name, [new Identification('dialogId', 1, 1), new Numeric('msgNr', 1, 1, 4)], minCount, maxCount, minVersion, maxVersion);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AlphaNumeric } from '../dataElements/AlphaNumeric.js';
|
|
2
|
-
import { DataGroup } from './DataGroup.js';
|
|
3
2
|
import { Identification } from '../dataElements/Identification.js';
|
|
4
|
-
import { BankIdentification } from './BankIdentification.js';
|
|
5
3
|
import { YesNo } from '../dataElements/YesNo.js';
|
|
4
|
+
import { BankIdentification } from './BankIdentification.js';
|
|
5
|
+
import { DataGroup } from './DataGroup.js';
|
|
6
6
|
export class SepaAccountGroup extends DataGroup {
|
|
7
7
|
constructor(name, minCount = 0, maxCount = 1, minVersion, maxVersion) {
|
|
8
8
|
super(name, [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { YesNo } from '../dataElements/YesNo.js';
|
|
2
|
-
import { Numeric } from '../dataElements/Numeric.js';
|
|
3
1
|
import { AlphaNumeric } from '../dataElements/AlphaNumeric.js';
|
|
2
|
+
import { Numeric } from '../dataElements/Numeric.js';
|
|
3
|
+
import { YesNo } from '../dataElements/YesNo.js';
|
|
4
4
|
import { DataGroup } from './DataGroup.js';
|
|
5
5
|
export class SepaAccountParametersGroup extends DataGroup {
|
|
6
6
|
constructor(name, minCount = 1, maxCount = 1, minVersion, maxVersion) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Time } from '../dataElements/Time.js';
|
|
2
1
|
import { Dat } from '../dataElements/Dat.js';
|
|
2
|
+
import { Time } from '../dataElements/Time.js';
|
|
3
3
|
import { DataGroup } from './DataGroup.js';
|
|
4
4
|
export class TimeStampGroup extends DataGroup {
|
|
5
5
|
constructor(name, minCount = 0, maxCount = 1, minVersion, maxVersion) {
|
package/dist/decoder.js
CHANGED
|
@@ -10,7 +10,9 @@ export function decodeElements(text, elements, separator, version, context) {
|
|
|
10
10
|
if (element.isInVersion(version)) {
|
|
11
11
|
let textValue;
|
|
12
12
|
if (separator === ':') {
|
|
13
|
-
textValue = textValues
|
|
13
|
+
textValue = textValues
|
|
14
|
+
.slice(valueIndex, valueIndex + element.maxValueCount(version))
|
|
15
|
+
.join(':');
|
|
14
16
|
valueIndex += element.maxValueCount(version);
|
|
15
17
|
}
|
|
16
18
|
else {
|
|
@@ -27,13 +29,14 @@ export function decodeElements(text, elements, separator, version, context) {
|
|
|
27
29
|
else {
|
|
28
30
|
value = element.decode(textValue, version);
|
|
29
31
|
}
|
|
30
|
-
if (
|
|
32
|
+
if (Array.isArray(result)) {
|
|
31
33
|
if (element.maxCount > 1) {
|
|
32
34
|
if (elements.length === 1) {
|
|
33
35
|
result = [...result, value];
|
|
34
36
|
}
|
|
35
37
|
else {
|
|
36
|
-
|
|
38
|
+
const currentValue = result[elementIndex];
|
|
39
|
+
result[elementIndex] = Array.isArray(currentValue) ? [...currentValue, value] : [value];
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
else {
|
|
@@ -42,7 +45,8 @@ export function decodeElements(text, elements, separator, version, context) {
|
|
|
42
45
|
}
|
|
43
46
|
else {
|
|
44
47
|
if (element.maxCount > 1) {
|
|
45
|
-
|
|
48
|
+
const currentValue = result[element.name];
|
|
49
|
+
result[element.name] = Array.isArray(currentValue) ? [...currentValue, value] : [value];
|
|
46
50
|
}
|
|
47
51
|
else {
|
|
48
52
|
result[element.name] = value;
|
|
@@ -51,7 +55,9 @@ export function decodeElements(text, elements, separator, version, context) {
|
|
|
51
55
|
}
|
|
52
56
|
elementCount++;
|
|
53
57
|
if (valueIndex >= textValues.length) {
|
|
54
|
-
if (elements
|
|
58
|
+
if (elements
|
|
59
|
+
.slice(elementIndex + 1)
|
|
60
|
+
.some((element) => element.isInVersion(version) && element.minCount > 0)) {
|
|
55
61
|
throw new Error(`Not all mandatory values are present in '${context}', expected a value for element '${elements[elementIndex + 1].name}'`);
|
|
56
62
|
}
|
|
57
63
|
else {
|
|
@@ -72,7 +78,7 @@ export function splitBySeparator(text, separator) {
|
|
|
72
78
|
const char = text[index];
|
|
73
79
|
if (char === '@' && !isEscaped(text, index)) {
|
|
74
80
|
const next = text.indexOf('@', index + 1);
|
|
75
|
-
const size = Number.parseInt(text.slice(index + 1, next));
|
|
81
|
+
const size = Number.parseInt(text.slice(index + 1, next), 10);
|
|
76
82
|
if (size) {
|
|
77
83
|
index = next + size;
|
|
78
84
|
}
|
package/dist/dialog.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { TanMediaRequirement, TanProcess } from './codes.js';
|
|
2
2
|
import { HttpClient } from './httpClient.js';
|
|
3
|
+
import { CustomerOrderInteraction, } from './interactions/customerInteraction.js';
|
|
4
|
+
import { EndDialogInteraction } from './interactions/endDialogInteraction.js';
|
|
5
|
+
import { InitDialogInteraction } from './interactions/initDialogInteraction.js';
|
|
3
6
|
import { CustomerMessage, CustomerOrderMessage } from './message.js';
|
|
4
|
-
import {
|
|
7
|
+
import { PARTED } from './partedSegment.js';
|
|
8
|
+
import { decode } from './segment.js';
|
|
9
|
+
import { HKEND } from './segments/HKEND.js';
|
|
5
10
|
import { HKTAN } from './segments/HKTAN.js';
|
|
6
11
|
import { HNHBK } from './segments/HNHBK.js';
|
|
7
|
-
import { decode } from './segment.js';
|
|
8
|
-
import { PARTED } from './partedSegment.js';
|
|
9
|
-
import { CustomerOrderInteraction } from './interactions/customerInteraction.js';
|
|
10
|
-
import { InitDialogInteraction } from './interactions/initDialogInteraction.js';
|
|
11
|
-
import { EndDialogInteraction } from './interactions/endDialogInteraction.js';
|
|
12
12
|
export class Dialog {
|
|
13
13
|
config;
|
|
14
14
|
dialogId = '0';
|
|
@@ -125,22 +125,24 @@ export class Dialog {
|
|
|
125
125
|
? new CustomerOrderMessage(this.currentInteraction.segId, this.currentInteraction.responseSegId, this.dialogId, this.lastMessageNumber)
|
|
126
126
|
: new CustomerMessage(this.dialogId, this.lastMessageNumber);
|
|
127
127
|
const tanMethod = this.config.selectedTanMethod;
|
|
128
|
-
|
|
129
|
-
let isTanMethodNeeded = isScaSupported;
|
|
128
|
+
const isScaSupported = tanMethod && tanMethod.version >= 6;
|
|
129
|
+
let isTanMethodNeeded = isScaSupported && this.currentInteraction.segId !== HKEND.Id;
|
|
130
130
|
if (isCustomerOrder) {
|
|
131
131
|
const bankTransaction = this.config.bankingInformation.bpd?.allowedTransactions.find((t) => t.transId === this.currentInteraction.segId);
|
|
132
|
-
isTanMethodNeeded =
|
|
132
|
+
isTanMethodNeeded = isTanMethodNeeded && bankTransaction?.tanRequired;
|
|
133
133
|
}
|
|
134
134
|
if (this.config.userId && this.config.pin) {
|
|
135
135
|
message.sign(this.config.countryCode, this.config.bankId, this.config.userId, this.config.pin, this.config.bankingInformation.systemId, isScaSupported ? this.config.tanMethodId : undefined);
|
|
136
136
|
}
|
|
137
137
|
const segments = this.currentInteraction.getSegments(this.config);
|
|
138
|
-
segments.forEach((segment) =>
|
|
138
|
+
segments.forEach((segment) => {
|
|
139
|
+
message.addSegment(segment);
|
|
140
|
+
});
|
|
139
141
|
if (this.config.userId && this.config.pin && isTanMethodNeeded) {
|
|
140
142
|
const hktan = {
|
|
141
|
-
header: { segId: HKTAN.Id, segNr: 0, version: tanMethod
|
|
143
|
+
header: { segId: HKTAN.Id, segNr: 0, version: tanMethod?.version ?? 0 },
|
|
142
144
|
tanProcess: TanProcess.Process4,
|
|
143
|
-
segId:
|
|
145
|
+
segId: this.currentInteraction.segId,
|
|
144
146
|
};
|
|
145
147
|
message.addSegment(hktan);
|
|
146
148
|
}
|
|
@@ -150,16 +152,19 @@ export class Dialog {
|
|
|
150
152
|
this.lastMessageNumber++;
|
|
151
153
|
const message = new CustomerMessage(this.dialogId, this.lastMessageNumber);
|
|
152
154
|
if (this.config.userId && this.config.pin) {
|
|
153
|
-
message.sign(this.config.countryCode, this.config.bankId, this.config.userId, this.config.pin, this.config.bankingInformation
|
|
155
|
+
message.sign(this.config.countryCode, this.config.bankId, this.config.userId, this.config.pin, this.config.bankingInformation?.systemId, this.config.tanMethodId, tan);
|
|
154
156
|
}
|
|
155
157
|
if (this.config.userId && this.config.pin && this.config.tanMethodId) {
|
|
156
158
|
const hktan = {
|
|
157
|
-
header: { segId: HKTAN.Id, segNr: 0, version: this.config.selectedTanMethod
|
|
158
|
-
tanProcess: this.config.selectedTanMethod?.isDecoupled
|
|
159
|
+
header: { segId: HKTAN.Id, segNr: 0, version: this.config.selectedTanMethod?.version ?? 0 },
|
|
160
|
+
tanProcess: this.config.selectedTanMethod?.isDecoupled
|
|
161
|
+
? TanProcess.Status
|
|
162
|
+
: TanProcess.Process2,
|
|
159
163
|
segId: this.currentInteraction.segId,
|
|
160
164
|
orderRef: tanOrderReference,
|
|
161
165
|
nextTan: false,
|
|
162
|
-
tanMedia: this.config.selectedTanMethod
|
|
166
|
+
tanMedia: (this.config.selectedTanMethod?.tanMediaRequirement ??
|
|
167
|
+
TanMediaRequirement.NotAllowed >= TanMediaRequirement.Optional)
|
|
163
168
|
? this.config.tanMediaName
|
|
164
169
|
: undefined,
|
|
165
170
|
};
|
|
@@ -176,13 +181,22 @@ export class Dialog {
|
|
|
176
181
|
if (!segmentWithContinuation) {
|
|
177
182
|
throw new Error(`Response contains segment with further information, but corresponding segment could not be found or is not specified`);
|
|
178
183
|
}
|
|
179
|
-
|
|
180
|
-
|
|
184
|
+
const answer = answers.find((a) => a.code === 3040);
|
|
185
|
+
if (!answer || !answer.params || answer.params.length === 0) {
|
|
186
|
+
throw new Error('Expected bank answer to contain continuation mark parameters (code 3040)');
|
|
187
|
+
}
|
|
188
|
+
segmentWithContinuation.continuationMark = answer.params[0];
|
|
189
|
+
const hnhbkSegment = message.findSegment(HNHBK.Id);
|
|
190
|
+
if (!hnhbkSegment) {
|
|
191
|
+
throw new Error('HNHBK segment not found in message');
|
|
192
|
+
}
|
|
193
|
+
hnhbkSegment.msgNr = ++this.lastMessageNumber;
|
|
181
194
|
const nextResponseMessage = await this.httpClient.sendMessage(message);
|
|
182
195
|
const nextPartedSegment = nextResponseMessage.findSegment(PARTED.Id);
|
|
183
196
|
if (nextPartedSegment) {
|
|
184
197
|
nextPartedSegment.rawData =
|
|
185
|
-
partedSegment.rawData +
|
|
198
|
+
partedSegment.rawData +
|
|
199
|
+
nextPartedSegment.rawData.slice(nextPartedSegment.rawData.indexOf('+') + 1);
|
|
186
200
|
partedSegment = nextPartedSegment;
|
|
187
201
|
}
|
|
188
202
|
responseMessage = nextResponseMessage;
|
package/dist/encoder.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export function encodeElements(values, elements, separator, version, context) {
|
|
2
2
|
const isArray = Array.isArray(values);
|
|
3
|
-
if (!values ||
|
|
3
|
+
if (!values ||
|
|
4
|
+
(isArray && values.length === 0) ||
|
|
5
|
+
(!isArray && Object.keys(values).length === 0)) {
|
|
4
6
|
if (context.length >= 3) {
|
|
5
7
|
return separator.repeat(elements.reduce((sum, element) => sum + element.maxValueCount(version), 0) - 1);
|
|
6
8
|
}
|
|
@@ -9,7 +11,7 @@ export function encodeElements(values, elements, separator, version, context) {
|
|
|
9
11
|
if (isArray && values.length !== elements.length) {
|
|
10
12
|
throw new Error(`Values to encode don't match number of elements (${values.length} <> ${elements.length}) when encoding '${context.join('->')}'`);
|
|
11
13
|
}
|
|
12
|
-
|
|
14
|
+
const textValues = [];
|
|
13
15
|
let elementIndex = 0;
|
|
14
16
|
while (elementIndex < elements.length) {
|
|
15
17
|
const element = elements[elementIndex];
|
|
@@ -24,7 +26,12 @@ export function encodeElements(values, elements, separator, version, context) {
|
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
if (element.maxCount > 1) {
|
|
27
|
-
|
|
29
|
+
const elementValue = values[elementIndex];
|
|
30
|
+
textValues.push(Array.isArray(elementValue)
|
|
31
|
+
? elementValue
|
|
32
|
+
.map((value) => element.encode(value, context, version))
|
|
33
|
+
.join(separator)
|
|
34
|
+
: undefined);
|
|
28
35
|
}
|
|
29
36
|
else {
|
|
30
37
|
textValues.push(element.encode(values[elementIndex], context, version));
|
|
@@ -32,7 +39,12 @@ export function encodeElements(values, elements, separator, version, context) {
|
|
|
32
39
|
}
|
|
33
40
|
else {
|
|
34
41
|
if (element.maxCount > 1) {
|
|
35
|
-
|
|
42
|
+
const elementValue = values[element.name];
|
|
43
|
+
textValues.push(Array.isArray(elementValue)
|
|
44
|
+
? elementValue
|
|
45
|
+
.map((value) => element.encode(value, context, version))
|
|
46
|
+
.join(separator)
|
|
47
|
+
: undefined);
|
|
36
48
|
}
|
|
37
49
|
else {
|
|
38
50
|
textValues.push(element.encode(values[element.name], context, version));
|