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/dist/format.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function finTsEncode(value) {
|
|
2
|
-
return value.replace(/([
|
|
2
|
+
return value.replace(/([?:+'@])/g, '?$1');
|
|
3
3
|
}
|
|
4
4
|
export function finTsDecode(value) {
|
|
5
|
-
return value.replace(/\?([
|
|
5
|
+
return value.replace(/\?([?:+'@])/g, '$1');
|
|
6
6
|
}
|
package/dist/httpClient.js
CHANGED
|
@@ -30,14 +30,16 @@ export class HttpClient {
|
|
|
30
30
|
const responseText = responseBuffer.toString('latin1');
|
|
31
31
|
try {
|
|
32
32
|
const customerOrderMessage = message;
|
|
33
|
-
const responseMessage = Message.decode(responseText, customerOrderMessage.supportsPartedResponseSegments
|
|
33
|
+
const responseMessage = Message.decode(responseText, customerOrderMessage.supportsPartedResponseSegments
|
|
34
|
+
? customerOrderMessage.orderResponseSegId
|
|
35
|
+
: undefined);
|
|
34
36
|
if (this.debug) {
|
|
35
37
|
console.log('Response Message:\n');
|
|
36
38
|
if (this.debugRaw) {
|
|
37
39
|
console.log(responseText.split("'").join('\n'));
|
|
38
40
|
}
|
|
39
41
|
else {
|
|
40
|
-
console.log(
|
|
42
|
+
console.log(`Response Message:\n${responseMessage.toString(true)}\n`);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
return responseMessage;
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { registerSegments } from './segments/registry.js';
|
|
2
2
|
registerSegments();
|
|
3
|
+
export * from './accountBalance.js';
|
|
4
|
+
export * from './bankAccount.js';
|
|
5
|
+
export * from './bankAnswer.js';
|
|
6
|
+
export * from './bankingInformation.js';
|
|
7
|
+
export * from './bpd.js';
|
|
3
8
|
export * from './client.js';
|
|
4
9
|
export * from './config.js';
|
|
5
|
-
export * from './segment.js';
|
|
6
|
-
export * from './message.js';
|
|
7
10
|
export * from './dialog.js';
|
|
8
11
|
export * from './httpClient.js';
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './bankAccount.js';
|
|
11
|
-
export * from './bankingInformation.js';
|
|
12
|
-
export * from './accountBalance.js';
|
|
13
|
-
export * from './bpd.js';
|
|
14
|
-
export * from './upd.js';
|
|
15
|
-
export * from './statement.js';
|
|
16
|
-
export * from './mt940parser.js';
|
|
12
|
+
export * from './message.js';
|
|
17
13
|
export * from './mt535parser.js';
|
|
14
|
+
export * from './mt940parser.js';
|
|
15
|
+
export * from './segment.js';
|
|
16
|
+
export * from './statement.js';
|
|
17
|
+
export * from './upd.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
2
1
|
import { CreditDebit } from '../codes.js';
|
|
3
2
|
import { HISAL } from '../segments/HISAL.js';
|
|
4
3
|
import { HKSAL } from '../segments/HKSAL.js';
|
|
4
|
+
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
5
5
|
export class BalanceInteraction extends CustomerOrderInteraction {
|
|
6
6
|
accountNumber;
|
|
7
7
|
constructor(accountNumber) {
|
|
@@ -32,7 +32,7 @@ export class BalanceInteraction extends CustomerOrderInteraction {
|
|
|
32
32
|
date: hisal.balance.date,
|
|
33
33
|
currency: hisal.currency,
|
|
34
34
|
balance: balanceToValue(hisal.balance),
|
|
35
|
-
notedBalance: balanceToValue(hisal.notedBalance),
|
|
35
|
+
notedBalance: hisal.notedBalance ? balanceToValue(hisal.notedBalance) : undefined,
|
|
36
36
|
creditLimit: hisal.creditLimit?.value,
|
|
37
37
|
availableAmount: hisal.availableAmount?.value,
|
|
38
38
|
};
|
|
@@ -40,8 +40,5 @@ export class BalanceInteraction extends CustomerOrderInteraction {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function balanceToValue(balance) {
|
|
43
|
-
if (!balance) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
43
|
return balance.creditDebit === CreditDebit.Credit ? balance.amount.value : -balance.amount.value;
|
|
47
44
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
2
|
-
import { DKKKU } from '../segments/DKKKU.js';
|
|
3
1
|
import { DIKKU } from '../segments/DIKKU.js';
|
|
2
|
+
import { DKKKU } from '../segments/DKKKU.js';
|
|
3
|
+
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
4
4
|
export class CreditCardStatementInteraction extends CustomerOrderInteraction {
|
|
5
5
|
accountNumber;
|
|
6
6
|
from;
|
|
@@ -60,25 +60,25 @@ export class CreditCardStatementInteraction extends CustomerOrderInteraction {
|
|
|
60
60
|
const currency = parts[9];
|
|
61
61
|
const depositMarker = parts[10];
|
|
62
62
|
const amount = parseGermanFloat(parts[8]) * (depositMarker === 'D' ? -1 : 1);
|
|
63
|
-
const tYear = parseInt(transactionDateStr.substring(0, 4));
|
|
64
|
-
const tMonth = parseInt(transactionDateStr.substring(4, 6));
|
|
65
|
-
const tDay = parseInt(transactionDateStr.substring(6, 8));
|
|
66
|
-
const vYear = parseInt(valueDateStr.substring(0, 4));
|
|
67
|
-
const vMonth = parseInt(valueDateStr.substring(4, 6));
|
|
68
|
-
const vDay = parseInt(valueDateStr.substring(6, 8));
|
|
63
|
+
const tYear = parseInt(transactionDateStr.substring(0, 4), 10);
|
|
64
|
+
const tMonth = parseInt(transactionDateStr.substring(4, 6), 10);
|
|
65
|
+
const tDay = parseInt(transactionDateStr.substring(6, 8), 10);
|
|
66
|
+
const vYear = parseInt(valueDateStr.substring(0, 4), 10);
|
|
67
|
+
const vMonth = parseInt(valueDateStr.substring(4, 6), 10);
|
|
68
|
+
const vDay = parseInt(valueDateStr.substring(6, 8), 10);
|
|
69
69
|
let purpose = '';
|
|
70
70
|
let pIdx = 11;
|
|
71
71
|
do {
|
|
72
|
-
|
|
72
|
+
const partPurpose = parts[pIdx].trim();
|
|
73
73
|
if (partPurpose === 'J') {
|
|
74
74
|
break;
|
|
75
75
|
}
|
|
76
76
|
purpose = purpose + partPurpose;
|
|
77
77
|
if (purpose.endsWith('Betrag?')) {
|
|
78
|
-
purpose = purpose.slice(0, purpose.length - 7)
|
|
78
|
+
purpose = `${purpose.slice(0, purpose.length - 7)} Betrag `;
|
|
79
79
|
}
|
|
80
80
|
else if (purpose[purpose.length - 1] === '?') {
|
|
81
|
-
purpose = purpose.slice(0, purpose.length - 1)
|
|
81
|
+
purpose = `${purpose.slice(0, purpose.length - 1)} `;
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
84
|
break;
|
|
@@ -28,7 +28,7 @@ export class CustomerInteraction {
|
|
|
28
28
|
}
|
|
29
29
|
const countAsString = Array.from(bytes.slice(offset, 2), (b) => String(b)).join('');
|
|
30
30
|
offset += 2;
|
|
31
|
-
const count = parseInt(countAsString);
|
|
31
|
+
const count = parseInt(countAsString, 10);
|
|
32
32
|
const mimeTypeArray = bytes.slice(offset, offset + count);
|
|
33
33
|
const mimeType = new TextDecoder('iso-8859-1').decode(mimeTypeArray);
|
|
34
34
|
offset += count;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { CustomerInteraction } from './customerInteraction.js';
|
|
2
1
|
import { HKEND } from '../segments/HKEND.js';
|
|
2
|
+
import { CustomerInteraction } from './customerInteraction.js';
|
|
3
3
|
export class EndDialogInteraction extends CustomerInteraction {
|
|
4
4
|
constructor() {
|
|
5
5
|
super(HKEND.Id);
|
|
6
6
|
}
|
|
7
|
-
createSegments(
|
|
7
|
+
createSegments(_config) {
|
|
8
8
|
const hkend = {
|
|
9
9
|
header: { segId: HKEND.Id, segNr: 0, version: HKEND.Version },
|
|
10
|
-
dialogId: this.dialog
|
|
10
|
+
dialogId: this.dialog?.dialogId ?? '0',
|
|
11
11
|
};
|
|
12
12
|
return [hkend];
|
|
13
13
|
}
|
|
14
|
-
handleResponse(
|
|
14
|
+
handleResponse(_response, _clientResponse) {
|
|
15
15
|
// no special response handling needed
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HKIDN } from '../segments/HKIDN.js';
|
|
3
|
-
import { HKVVB } from '../segments/HKVVB.js';
|
|
1
|
+
import { finTsAccountTypeToEnum } from '../bankAccount.js';
|
|
4
2
|
import { Language, SyncMode, TanMediaRequirement } from '../codes.js';
|
|
5
|
-
import { HKSYN } from '../segments/HKSYN.js';
|
|
6
|
-
import { HISYN } from '../segments/HISYN.js';
|
|
7
3
|
import { HIBPA } from '../segments/HIBPA.js';
|
|
8
|
-
import {
|
|
4
|
+
import { HIKIM } from '../segments/HIKIM.js';
|
|
9
5
|
import { HIKOM } from '../segments/HIKOM.js';
|
|
10
6
|
import { HIPINS } from '../segments/HIPINS.js';
|
|
7
|
+
import { HISYN } from '../segments/HISYN.js';
|
|
8
|
+
import { HITANS } from '../segments/HITANS.js';
|
|
11
9
|
import { HIUPA } from '../segments/HIUPA.js';
|
|
12
|
-
import { finTsAccountTypeToEnum } from '../bankAccount.js';
|
|
13
|
-
import { HIKIM } from '../segments/HIKIM.js';
|
|
14
10
|
import { HIUPD } from '../segments/HIUPD.js';
|
|
15
|
-
import {
|
|
16
|
-
import { TanMediaInteraction } from './tanMediaInteraction.js';
|
|
11
|
+
import { HKIDN } from '../segments/HKIDN.js';
|
|
17
12
|
import { HKSPA } from '../segments/HKSPA.js';
|
|
13
|
+
import { HKSYN } from '../segments/HKSYN.js';
|
|
14
|
+
import { HKTAB } from '../segments/HKTAB.js';
|
|
15
|
+
import { HKVVB } from '../segments/HKVVB.js';
|
|
16
|
+
import { CustomerInteraction } from './customerInteraction.js';
|
|
18
17
|
import { SepaAccountInteraction } from './sepaAccountInteraction.js';
|
|
18
|
+
import { TanMediaInteraction } from './tanMediaInteraction.js';
|
|
19
19
|
export class InitDialogInteraction extends CustomerInteraction {
|
|
20
20
|
config;
|
|
21
21
|
syncSystemId;
|
|
@@ -54,7 +54,7 @@ export class InitDialogInteraction extends CustomerInteraction {
|
|
|
54
54
|
}
|
|
55
55
|
handleResponse(response, clientResponse) {
|
|
56
56
|
const hisyn = response.findSegment(HISYN.Id);
|
|
57
|
-
if (hisyn
|
|
57
|
+
if (hisyn?.systemId) {
|
|
58
58
|
this.config.bankingInformation.systemId = hisyn.systemId;
|
|
59
59
|
}
|
|
60
60
|
const bankAnswers = clientResponse.bankAnswers;
|
|
@@ -75,9 +75,9 @@ export class InitDialogInteraction extends CustomerInteraction {
|
|
|
75
75
|
tanMediaRequirement: method.tanMediaRequired,
|
|
76
76
|
decoupled: isDecoupledTanMethod(method)
|
|
77
77
|
? {
|
|
78
|
-
maxStatusRequests: method.decoupledMaxStatusRequests,
|
|
79
|
-
waitingSecondsBeforeFirstStatusRequest: method.decoupledWaitBeforeFirstStatusRequest,
|
|
80
|
-
waitingSecondsBetweenStatusRequests: method.decoupledWaitBetweenStatusRequests,
|
|
78
|
+
maxStatusRequests: method.decoupledMaxStatusRequests ?? 0,
|
|
79
|
+
waitingSecondsBeforeFirstStatusRequest: method.decoupledWaitBeforeFirstStatusRequest ?? 0,
|
|
80
|
+
waitingSecondsBetweenStatusRequests: method.decoupledWaitBetweenStatusRequests ?? 0,
|
|
81
81
|
manualConfirmationAllowed: method.decoupledManualConfirmationAllowed ?? false,
|
|
82
82
|
autoConfirmationAllowed: method.decoupledAutoConfirmationAllowed ?? false,
|
|
83
83
|
}
|
|
@@ -90,7 +90,7 @@ export class InitDialogInteraction extends CustomerInteraction {
|
|
|
90
90
|
if (hikom) {
|
|
91
91
|
bankingUrl = hikom?.comParams.address;
|
|
92
92
|
if (!bankingUrl.toLowerCase().startsWith('https://')) {
|
|
93
|
-
bankingUrl =
|
|
93
|
+
bankingUrl = `https://${bankingUrl}`;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
const hipins = response.findSegment(HIPINS.Id);
|
|
@@ -102,7 +102,7 @@ export class InitDialogInteraction extends CustomerInteraction {
|
|
|
102
102
|
});
|
|
103
103
|
bankTransactions.forEach((transaction) => {
|
|
104
104
|
if (transaction.transId.startsWith('HK') || transaction.transId.startsWith('DK')) {
|
|
105
|
-
const paramSegId =
|
|
105
|
+
const paramSegId = `HI${transaction.transId.slice(2)}S`;
|
|
106
106
|
const paramSegments = [
|
|
107
107
|
...response.findAllSegments(paramSegId),
|
|
108
108
|
...response.findAllUnknownSegments(paramSegId),
|
|
@@ -132,7 +132,7 @@ export class InitDialogInteraction extends CustomerInteraction {
|
|
|
132
132
|
const tanMethodMessaqe = bankAnswers.find((answer) => answer.code === 3920);
|
|
133
133
|
if (tanMethodMessaqe && this.config.bankingInformation.bpd) {
|
|
134
134
|
this.config.bankingInformation.bpd.availableTanMethodIds =
|
|
135
|
-
tanMethodMessaqe.params?.map((p) => Number.parseInt(p)) ?? [];
|
|
135
|
+
tanMethodMessaqe.params?.map((p) => Number.parseInt(p, 10)) ?? [];
|
|
136
136
|
}
|
|
137
137
|
const hiupa = response.findSegment(HIUPA.Id);
|
|
138
138
|
if (hiupa) {
|
|
@@ -161,19 +161,22 @@ export class InitDialogInteraction extends CustomerInteraction {
|
|
|
161
161
|
this.config.bankingInformation.upd = upd;
|
|
162
162
|
}
|
|
163
163
|
const hikimSegments = response.findAllSegments(HIKIM.Id);
|
|
164
|
-
const bankMessages = hikimSegments.map((s) => ({
|
|
164
|
+
const bankMessages = hikimSegments.map((s) => ({
|
|
165
|
+
subject: s.subject,
|
|
166
|
+
text: s.text,
|
|
167
|
+
}));
|
|
165
168
|
this.config.bankingInformation.bankMessages = bankMessages;
|
|
166
169
|
clientResponse.bankingInformation = this.config.bankingInformation;
|
|
167
170
|
if (this.config.selectedTanMethod &&
|
|
168
171
|
this.config.selectedTanMethod.tanMediaRequirement > TanMediaRequirement.NotAllowed &&
|
|
169
172
|
this.config.isTransactionSupported(HKTAB.Id)) {
|
|
170
|
-
this.dialog
|
|
173
|
+
this.dialog?.addCustomerInteraction(new TanMediaInteraction(), true);
|
|
171
174
|
}
|
|
172
175
|
const bankAccounts = this.config.bankingInformation?.upd?.bankAccounts;
|
|
173
176
|
if (bankAccounts) {
|
|
174
177
|
if (bankAccounts.some((account) => account.isSepaAccount === undefined) &&
|
|
175
178
|
this.config.isTransactionSupported(HKSPA.Id)) {
|
|
176
|
-
this.dialog
|
|
179
|
+
this.dialog?.addCustomerInteraction(new SepaAccountInteraction(), true);
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CustomerOrderInteraction, } from './customerInteraction.js';
|
|
2
|
-
import { HKWPD } from '../segments/HKWPD.js';
|
|
3
|
-
import { HIWPD } from '../segments/HIWPD.js';
|
|
4
1
|
import { Mt535Parser } from '../mt535parser.js';
|
|
2
|
+
import { HIWPD } from '../segments/HIWPD.js';
|
|
3
|
+
import { HKWPD } from '../segments/HKWPD.js';
|
|
4
|
+
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
5
5
|
/**
|
|
6
6
|
* Interaction for requesting and parsing stock portfolio information (HKWPD/HIWPD)
|
|
7
7
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
2
1
|
import { HISPA } from '../segments/HISPA.js';
|
|
3
2
|
import { HKSPA } from '../segments/HKSPA.js';
|
|
3
|
+
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
4
4
|
export class SepaAccountInteraction extends CustomerOrderInteraction {
|
|
5
5
|
accounts;
|
|
6
6
|
maxEntries;
|
|
@@ -32,11 +32,11 @@ export class SepaAccountInteraction extends CustomerOrderInteraction {
|
|
|
32
32
|
const hispa = response.findSegment(HISPA.Id);
|
|
33
33
|
if (hispa) {
|
|
34
34
|
clientResponse.sepaAccounts = hispa.sepaAccounts || [];
|
|
35
|
-
this.dialog
|
|
35
|
+
this.dialog?.config.bankingInformation.upd?.bankAccounts.forEach((bankAccount) => {
|
|
36
36
|
bankAccount.isSepaAccount = false;
|
|
37
37
|
});
|
|
38
38
|
clientResponse.sepaAccounts.forEach((sepaAccount) => {
|
|
39
|
-
const bankAccount = this.dialog
|
|
39
|
+
const bankAccount = this.dialog?.config.getBankAccount(sepaAccount.accountNumber);
|
|
40
40
|
if (bankAccount) {
|
|
41
41
|
bankAccount.isSepaAccount = sepaAccount.isSepaAccount;
|
|
42
42
|
bankAccount.iban = sepaAccount.iban;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
2
|
-
import { HKCAZ } from '../segments/HKCAZ.js';
|
|
3
|
-
import { HICAZ } from '../segments/HICAZ.js';
|
|
4
1
|
import { CamtParser } from '../camtParser.js';
|
|
2
|
+
import { HICAZ } from '../segments/HICAZ.js';
|
|
3
|
+
import { HKCAZ } from '../segments/HKCAZ.js';
|
|
4
|
+
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
5
5
|
export class StatementInteractionCAMT extends CustomerOrderInteraction {
|
|
6
6
|
accountNumber;
|
|
7
7
|
from;
|
|
@@ -31,7 +31,7 @@ export class StatementInteractionCAMT extends CustomerOrderInteraction {
|
|
|
31
31
|
}
|
|
32
32
|
handleResponse(response, clientResponse) {
|
|
33
33
|
const hicaz = response.findSegment(HICAZ.Id);
|
|
34
|
-
if (hicaz
|
|
34
|
+
if (hicaz?.bookedTransactions && hicaz.bookedTransactions.length > 0) {
|
|
35
35
|
try {
|
|
36
36
|
// Parse all CAMT messages (one per booking day) and combine statements
|
|
37
37
|
const allStatements = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
2
|
-
import { HKKAZ } from '../segments/HKKAZ.js';
|
|
3
|
-
import { HIKAZ } from '../segments/HIKAZ.js';
|
|
4
1
|
import { Mt940Parser } from '../mt940parser.js';
|
|
2
|
+
import { HIKAZ } from '../segments/HIKAZ.js';
|
|
3
|
+
import { HKKAZ } from '../segments/HKKAZ.js';
|
|
4
|
+
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
5
5
|
export class StatementInteractionMT940 extends CustomerOrderInteraction {
|
|
6
6
|
accountNumber;
|
|
7
7
|
from;
|
|
@@ -30,7 +30,7 @@ export class StatementInteractionMT940 extends CustomerOrderInteraction {
|
|
|
30
30
|
}
|
|
31
31
|
handleResponse(response, clientResponse) {
|
|
32
32
|
const hikaz = response.findSegment(HIKAZ.Id);
|
|
33
|
-
if (hikaz
|
|
33
|
+
if (hikaz?.bookedTransactions) {
|
|
34
34
|
try {
|
|
35
35
|
const parser = new Mt940Parser(hikaz.bookedTransactions);
|
|
36
36
|
clientResponse.statements = parser.parse();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
2
|
-
import { HKTAB } from '../segments/HKTAB.js';
|
|
3
|
-
import { HITAB } from '../segments/HITAB.js';
|
|
4
1
|
import { TanMediaClass, TanMediaType } from '../codes.js';
|
|
2
|
+
import { HITAB } from '../segments/HITAB.js';
|
|
3
|
+
import { HKTAB } from '../segments/HKTAB.js';
|
|
4
|
+
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
5
5
|
export class TanMediaInteraction extends CustomerOrderInteraction {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(HKTAB.Id, HITAB.Id);
|
|
@@ -24,7 +24,7 @@ export class TanMediaInteraction extends CustomerOrderInteraction {
|
|
|
24
24
|
clientResponse.tanMediaList = (hitab.mediaList ?? [])
|
|
25
25
|
.map((media) => media.name)
|
|
26
26
|
.filter((name) => name);
|
|
27
|
-
|
|
27
|
+
const tanMethod = this.dialog?.config.selectedTanMethod;
|
|
28
28
|
if (tanMethod) {
|
|
29
29
|
tanMethod.activeTanMedia = clientResponse.tanMediaList;
|
|
30
30
|
}
|
package/dist/message.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { HashAlgorithm } from './codes.js';
|
|
2
2
|
import { splitBySeparator } from './parser.js';
|
|
3
|
-
import {
|
|
3
|
+
import { PARTED } from './partedSegment.js';
|
|
4
|
+
import { decode, encode, segmentToString } from './segment.js';
|
|
5
|
+
import { SegmentDefinition } from './segmentDefinition.js';
|
|
6
|
+
import { HIRMG } from './segments/HIRMG.js';
|
|
7
|
+
import { HIRMS } from './segments/HIRMS.js';
|
|
4
8
|
import { HNHBK } from './segments/HNHBK.js';
|
|
5
|
-
import {
|
|
9
|
+
import { HNHBS } from './segments/HNHBS.js';
|
|
10
|
+
import { HNSHA } from './segments/HNSHA.js';
|
|
6
11
|
import { HNSHK } from './segments/HNSHK.js';
|
|
7
12
|
import { HNVSD } from './segments/HNVSD.js';
|
|
8
|
-
import {
|
|
9
|
-
import { HIRMS } from './segments/HIRMS.js';
|
|
10
|
-
import { HIRMG } from './segments/HIRMG.js';
|
|
11
|
-
import { UnkownId } from './unknownSegment.js';
|
|
12
|
-
import { decode, encode, segmentToString } from './segment.js';
|
|
13
|
-
import { SegmentDefinition } from './segmentDefinition.js';
|
|
14
|
-
import { PARTED } from './partedSegment.js';
|
|
13
|
+
import { HNVSK } from './segments/HNVSK.js';
|
|
15
14
|
import { getSegmentDefinition } from './segments/registry.js';
|
|
15
|
+
import { UnkownId } from './unknownSegment.js';
|
|
16
16
|
export class Message {
|
|
17
17
|
segments;
|
|
18
18
|
constructor(segments) {
|
|
@@ -32,27 +32,41 @@ export class Message {
|
|
|
32
32
|
hasReturnCode(code) {
|
|
33
33
|
const hirmg = this.findSegment(HIRMG.Id);
|
|
34
34
|
const hirmsList = this.findAllSegments(HIRMS.Id);
|
|
35
|
-
return (
|
|
35
|
+
return (hirmg?.answers.some((answer) => answer.code === code) ||
|
|
36
36
|
hirmsList.some((hirms) => hirms.answers.some((answer) => answer.code === code)));
|
|
37
37
|
}
|
|
38
38
|
getHighestReturnCode() {
|
|
39
39
|
const hirmg = this.findSegment(HIRMG.Id);
|
|
40
40
|
const hirmsList = this.findAllSegments(HIRMS.Id);
|
|
41
41
|
const allAnswers = hirmg ? [...hirmg.answers] : [];
|
|
42
|
-
hirmsList.forEach((hirms) =>
|
|
42
|
+
hirmsList.forEach((hirms) => {
|
|
43
|
+
allAnswers.push(...hirms.answers);
|
|
44
|
+
});
|
|
43
45
|
return allAnswers.reduce((max, answer) => (answer.code > max ? answer.code : max), 0);
|
|
44
46
|
}
|
|
45
47
|
getBankAnswers() {
|
|
46
|
-
|
|
48
|
+
const bankAnswers = [];
|
|
47
49
|
const hirmgSegments = this.findAllSegments(HIRMG.Id);
|
|
48
|
-
hirmgSegments.forEach((hirmg) =>
|
|
50
|
+
hirmgSegments.forEach((hirmg) => {
|
|
51
|
+
bankAnswers.push(...hirmg.answers.map((message) => ({
|
|
52
|
+
code: message.code,
|
|
53
|
+
text: message.text,
|
|
54
|
+
params: message.params,
|
|
55
|
+
})));
|
|
56
|
+
});
|
|
49
57
|
const hirmsSegments = this.findAllSegments(HIRMS.Id);
|
|
50
|
-
hirmsSegments.forEach((hirms) =>
|
|
58
|
+
hirmsSegments.forEach((hirms) => {
|
|
59
|
+
bankAnswers.push(...hirms.answers.map((message) => ({
|
|
60
|
+
code: message.code,
|
|
61
|
+
text: message.text,
|
|
62
|
+
params: message.params,
|
|
63
|
+
})));
|
|
64
|
+
});
|
|
51
65
|
return bankAnswers;
|
|
52
66
|
}
|
|
53
67
|
static decode(text, partedResponseSegId) {
|
|
54
68
|
const segmentTexts = splitBySeparator(text, "'").filter((text) => !!text);
|
|
55
|
-
|
|
69
|
+
const segments = segmentTexts.map((text) => Message.decodeSegment(text, partedResponseSegId));
|
|
56
70
|
const hnvskIndex = segments.findIndex((segment) => segment.header.segId === HNVSK.Id);
|
|
57
71
|
const hnvsdIndex = segments.findIndex((segment) => segment.header.segId === HNVSD.Id);
|
|
58
72
|
const isEncrypted = hnvskIndex !== -1 && hnvsdIndex !== -1 && hnvsdIndex - hnvskIndex === 1;
|
|
@@ -68,7 +82,10 @@ export class Message {
|
|
|
68
82
|
static decodeSegment(text, partedResponseSegId) {
|
|
69
83
|
if (partedResponseSegId && text.startsWith(partedResponseSegId)) {
|
|
70
84
|
const partedSegment = {
|
|
71
|
-
header: {
|
|
85
|
+
header: {
|
|
86
|
+
...SegmentDefinition.header.decode(text, 1),
|
|
87
|
+
segId: PARTED.Id,
|
|
88
|
+
},
|
|
72
89
|
originalId: partedResponseSegId,
|
|
73
90
|
rawData: text,
|
|
74
91
|
};
|
|
@@ -118,6 +135,9 @@ export class CustomerMessage extends Message {
|
|
|
118
135
|
let segments = this.segments;
|
|
119
136
|
if (this.lastSignatureNumber > 0) {
|
|
120
137
|
const firstSignature = this.findSegment(HNSHK.Id);
|
|
138
|
+
if (!firstSignature) {
|
|
139
|
+
throw new Error('no signature segment found in message');
|
|
140
|
+
}
|
|
121
141
|
const now = new Date();
|
|
122
142
|
const hnvsk = {
|
|
123
143
|
header: { segId: HNVSK.Id, segNr: 998, version: HNVSK.Version },
|
|
@@ -126,7 +146,14 @@ export class CustomerMessage extends Message {
|
|
|
126
146
|
secRole: 1,
|
|
127
147
|
secId: { partyType: 1, partyId: firstSignature.secId.partyId },
|
|
128
148
|
dateTime: { type: 1, date: now, time: now },
|
|
129
|
-
encryption: {
|
|
149
|
+
encryption: {
|
|
150
|
+
use: 2,
|
|
151
|
+
mode: 2,
|
|
152
|
+
algorithm: 13,
|
|
153
|
+
keyParamValue: '00000000',
|
|
154
|
+
keyParamName: 5,
|
|
155
|
+
initParamName: 1,
|
|
156
|
+
},
|
|
130
157
|
key: {
|
|
131
158
|
bank: firstSignature.key.bank,
|
|
132
159
|
userId: firstSignature.key.userId,
|
|
@@ -164,7 +191,13 @@ export class CustomerMessage extends Message {
|
|
|
164
191
|
dateTime: { type: 1, date: now, time: now },
|
|
165
192
|
hash: { use: 1, algorithm: HashAlgorithm.SHA256, paramName: 1 },
|
|
166
193
|
signature: { use: 6, algorithm: 10, mode: 16 },
|
|
167
|
-
key: {
|
|
194
|
+
key: {
|
|
195
|
+
bank: { country: countryCode, bankId: bankId },
|
|
196
|
+
userId: userId,
|
|
197
|
+
keyType: 'S',
|
|
198
|
+
keyNr: 0,
|
|
199
|
+
keyVersion: 0,
|
|
200
|
+
},
|
|
168
201
|
};
|
|
169
202
|
this.segments.splice(1, 0, hnshk);
|
|
170
203
|
const pinTan = { pin: pin, tan: tan };
|
package/dist/mt535parser.js
CHANGED
|
@@ -24,16 +24,14 @@ const tokens535 = {
|
|
|
24
24
|
[TokenType535.TimeString]: /^.{14}(\d{2})(\d{2})(\d{2})/ms,
|
|
25
25
|
};
|
|
26
26
|
export class Mt535Parser {
|
|
27
|
-
rawData;
|
|
28
27
|
cleanedRawData;
|
|
29
28
|
constructor(rawData) {
|
|
30
|
-
this.rawData = rawData;
|
|
31
29
|
// The divider can be either \r\n or @@
|
|
32
30
|
const crlfCount = (rawData.match(/\r\n-/g) || []).length;
|
|
33
31
|
const atAtCount = (rawData.match(/@@-/g) || []).length;
|
|
34
32
|
const divider = crlfCount > atAtCount ? '\r\n' : '@@';
|
|
35
33
|
// Remove dividers that are not followed by a colon (tag indicator)
|
|
36
|
-
const regex = new RegExp(divider
|
|
34
|
+
const regex = new RegExp(`${divider}([^:])`, 'gms');
|
|
37
35
|
this.cleanedRawData = rawData.replace(regex, '$1');
|
|
38
36
|
}
|
|
39
37
|
parse() {
|
|
@@ -170,7 +168,7 @@ export class Mt535Parser {
|
|
|
170
168
|
// :98C: has a time component HHMMSS starting at character 14
|
|
171
169
|
const timeMatch = content.match(tokens535[TokenType535.TimeString]);
|
|
172
170
|
if (timeMatch) {
|
|
173
|
-
parsedDate.setHours(parseInt(timeMatch[1]), parseInt(timeMatch[2]), parseInt(timeMatch[3]));
|
|
171
|
+
parsedDate.setHours(parseInt(timeMatch[1], 10), parseInt(timeMatch[2], 10), parseInt(timeMatch[3], 10));
|
|
174
172
|
}
|
|
175
173
|
}
|
|
176
174
|
else {
|
|
@@ -187,7 +185,7 @@ export class Mt535Parser {
|
|
|
187
185
|
throw new Error(`Invalid date format: ${dateString}`);
|
|
188
186
|
}
|
|
189
187
|
try {
|
|
190
|
-
return new Date(parseInt(match[1]), parseInt(match[2]) - 1, parseInt(match[3]));
|
|
188
|
+
return new Date(parseInt(match[1], 10), parseInt(match[2], 10) - 1, parseInt(match[3], 10));
|
|
191
189
|
}
|
|
192
190
|
catch (error) {
|
|
193
191
|
throw new Error(`Invalid date: ${dateString}`, { cause: error });
|