lib-fints 1.4.0 → 1.4.2
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/dist/camtParser.js +18 -9
- package/dist/client.js +51 -35
- 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 +3 -3
- package/dist/tests/client.test.js +636 -22
- 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 +5 -5
- 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/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));
|
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 };
|