@coderoftime/fints 0.1.0 → 0.3.0
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/CHANGELOG.md +519 -1
- package/README.md +138 -40
- package/dist/client.d.ts +49 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +242 -0
- package/dist/client.js.map +1 -0
- package/dist/core/account.d.ts +46 -7
- package/dist/core/account.d.ts.map +1 -1
- package/dist/core/account.js +143 -24
- package/dist/core/account.js.map +1 -1
- package/dist/core/amount.d.ts +15 -4
- package/dist/core/amount.d.ts.map +1 -1
- package/dist/core/amount.js +46 -9
- package/dist/core/amount.js.map +1 -1
- package/dist/core/balance.d.ts +4 -0
- package/dist/core/balance.d.ts.map +1 -1
- package/dist/core/balance.js +11 -5
- package/dist/core/balance.js.map +1 -1
- package/dist/core/bank-info.d.ts +21 -4
- package/dist/core/bank-info.d.ts.map +1 -1
- package/dist/core/bank-info.js +26 -5
- package/dist/core/bank-info.js.map +1 -1
- package/dist/core/client.d.ts +81 -19
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/config.d.ts +40 -20
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +85 -30
- package/dist/core/config.js.map +1 -1
- package/dist/core/errors.d.ts +100 -26
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +136 -53
- package/dist/core/errors.js.map +1 -1
- package/dist/core/feedback.d.ts +11 -1
- package/dist/core/feedback.d.ts.map +1 -1
- package/dist/core/feedback.js +14 -2
- package/dist/core/feedback.js.map +1 -1
- package/dist/core/transaction.d.ts +11 -1
- package/dist/core/transaction.d.ts.map +1 -1
- package/dist/core/transaction.js +21 -4
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/transport.d.ts +48 -6
- package/dist/core/transport.d.ts.map +1 -1
- package/dist/core/transport.js +126 -29
- package/dist/core/transport.js.map +1 -1
- package/dist/formats/camt.d.ts +28 -5
- package/dist/formats/camt.d.ts.map +1 -1
- package/dist/formats/camt.js +132 -50
- package/dist/formats/camt.js.map +1 -1
- package/dist/formats/mt940.d.ts +29 -5
- package/dist/formats/mt940.d.ts.map +1 -1
- package/dist/formats/mt940.js +209 -113
- package/dist/formats/mt940.js.map +1 -1
- package/dist/formats/readers.d.ts +6 -2
- package/dist/formats/readers.d.ts.map +1 -1
- package/dist/formats/readers.js +28 -29
- package/dist/formats/readers.js.map +1 -1
- package/dist/formats/record-budget.d.ts +7 -0
- package/dist/formats/record-budget.d.ts.map +1 -0
- package/dist/formats/record-budget.js +17 -0
- package/dist/formats/record-budget.js.map +1 -0
- package/dist/formats/sepa-purpose.d.ts +9 -0
- package/dist/formats/sepa-purpose.d.ts.map +1 -1
- package/dist/formats/sepa-purpose.js +32 -2
- package/dist/formats/sepa-purpose.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/session/app-approval.d.ts +11 -5
- package/dist/session/app-approval.d.ts.map +1 -1
- package/dist/session/app-approval.js +23 -12
- package/dist/session/app-approval.js.map +1 -1
- package/dist/session/dialog-runner.d.ts +11 -11
- package/dist/session/dialog-runner.d.ts.map +1 -1
- package/dist/session/dialog-runner.js +34 -19
- package/dist/session/dialog-runner.js.map +1 -1
- package/dist/session/login-guard.d.ts +54 -49
- package/dist/session/login-guard.d.ts.map +1 -1
- package/dist/session/login-guard.js +170 -83
- package/dist/session/login-guard.js.map +1 -1
- package/dist/session/sepa-accounts.d.ts +20 -14
- package/dist/session/sepa-accounts.d.ts.map +1 -1
- package/dist/session/sepa-accounts.js +62 -46
- package/dist/session/sepa-accounts.js.map +1 -1
- package/dist/session/session-setup.d.ts +41 -24
- package/dist/session/session-setup.d.ts.map +1 -1
- package/dist/session/session-setup.js +106 -63
- package/dist/session/session-setup.js.map +1 -1
- package/dist/session/session-state.d.ts +10 -6
- package/dist/session/session-state.d.ts.map +1 -1
- package/dist/session/session-state.js +72 -18
- package/dist/session/session-state.js.map +1 -1
- package/dist/session/signed-dialog.d.ts +83 -0
- package/dist/session/signed-dialog.d.ts.map +1 -0
- package/dist/session/signed-dialog.js +185 -0
- package/dist/session/signed-dialog.js.map +1 -0
- package/dist/session/tan-selection.d.ts +26 -18
- package/dist/session/tan-selection.d.ts.map +1 -1
- package/dist/session/tan-selection.js +44 -33
- package/dist/session/tan-selection.js.map +1 -1
- package/dist/session/user-prompts.d.ts +14 -5
- package/dist/session/user-prompts.d.ts.map +1 -1
- package/dist/session/user-prompts.js +53 -18
- package/dist/session/user-prompts.js.map +1 -1
- package/dist/tan/challenge.d.ts +47 -24
- package/dist/tan/challenge.d.ts.map +1 -1
- package/dist/tan/challenge.js +56 -51
- package/dist/tan/challenge.js.map +1 -1
- package/dist/tan/flicker.d.ts +11 -1
- package/dist/tan/flicker.d.ts.map +1 -1
- package/dist/tan/flicker.js +70 -24
- package/dist/tan/flicker.js.map +1 -1
- package/dist/tan/tan-image.d.ts +6 -2
- package/dist/tan/tan-image.d.ts.map +1 -1
- package/dist/tan/tan-image.js +14 -6
- package/dist/tan/tan-image.js.map +1 -1
- package/dist/tan/tan-models.d.ts +14 -2
- package/dist/tan/tan-models.d.ts.map +1 -1
- package/dist/tan/tan-models.js +24 -7
- package/dist/tan/tan-models.js.map +1 -1
- package/dist/util/arguments.d.ts +13 -0
- package/dist/util/arguments.d.ts.map +1 -0
- package/dist/util/arguments.js +40 -0
- package/dist/util/arguments.js.map +1 -0
- package/dist/util/async.d.ts +4 -3
- package/dist/util/async.d.ts.map +1 -1
- package/dist/util/async.js +6 -7
- package/dist/util/async.js.map +1 -1
- package/dist/util/bytes.d.ts +3 -4
- package/dist/util/bytes.d.ts.map +1 -1
- package/dist/util/bytes.js +13 -21
- package/dist/util/bytes.js.map +1 -1
- package/dist/util/call-context.d.ts.map +1 -1
- package/dist/util/call-context.js +3 -2
- package/dist/util/call-context.js.map +1 -1
- package/dist/util/dates.d.ts +6 -20
- package/dist/util/dates.d.ts.map +1 -1
- package/dist/util/dates.js +58 -28
- package/dist/util/dates.js.map +1 -1
- package/dist/util/errors.d.ts +13 -3
- package/dist/util/errors.d.ts.map +1 -1
- package/dist/util/errors.js +19 -6
- package/dist/util/errors.js.map +1 -1
- package/dist/util/immutable-map.d.ts +5 -2
- package/dist/util/immutable-map.d.ts.map +1 -1
- package/dist/util/immutable-map.js +15 -12
- package/dist/util/immutable-map.js.map +1 -1
- package/dist/util/inspect.d.ts +11 -0
- package/dist/util/inspect.d.ts.map +1 -0
- package/dist/util/inspect.js +14 -0
- package/dist/util/inspect.js.map +1 -0
- package/dist/util/json.d.ts +4 -0
- package/dist/util/json.d.ts.map +1 -1
- package/dist/util/json.js +18 -0
- package/dist/util/json.js.map +1 -1
- package/dist/util/text.d.ts +38 -5
- package/dist/util/text.d.ts.map +1 -1
- package/dist/util/text.js +90 -16
- package/dist/util/text.js.map +1 -1
- package/dist/util/xml.d.ts +9 -6
- package/dist/util/xml.d.ts.map +1 -1
- package/dist/util/xml.js +129 -56
- package/dist/util/xml.js.map +1 -1
- package/dist/v3/account-extension.d.ts.map +1 -1
- package/dist/v3/account-extension.js +7 -10
- package/dist/v3/account-extension.js.map +1 -1
- package/dist/v3/bank-connection.d.ts +54 -0
- package/dist/v3/bank-connection.d.ts.map +1 -0
- package/dist/v3/bank-connection.js +118 -0
- package/dist/v3/bank-connection.js.map +1 -0
- package/dist/v3/dialog.d.ts +84 -46
- package/dist/v3/dialog.d.ts.map +1 -1
- package/dist/v3/dialog.js +174 -60
- package/dist/v3/dialog.js.map +1 -1
- package/dist/v3/message.d.ts +32 -11
- package/dist/v3/message.d.ts.map +1 -1
- package/dist/v3/message.js +144 -83
- package/dist/v3/message.js.map +1 -1
- package/dist/v3/parameter-store.d.ts +111 -0
- package/dist/v3/parameter-store.d.ts.map +1 -0
- package/dist/v3/parameter-store.js +197 -0
- package/dist/v3/parameter-store.js.map +1 -0
- package/dist/v3/parameters.d.ts +44 -17
- package/dist/v3/parameters.d.ts.map +1 -1
- package/dist/v3/parameters.js +136 -60
- package/dist/v3/parameters.js.map +1 -1
- package/dist/v3/protocol.d.ts +50 -50
- package/dist/v3/protocol.d.ts.map +1 -1
- package/dist/v3/protocol.js +91 -210
- package/dist/v3/protocol.js.map +1 -1
- package/dist/v3/queries.d.ts +51 -0
- package/dist/v3/queries.d.ts.map +1 -0
- package/dist/v3/queries.js +128 -0
- package/dist/v3/queries.js.map +1 -0
- package/dist/v3/segments.d.ts +43 -19
- package/dist/v3/segments.d.ts.map +1 -1
- package/dist/v3/segments.js +84 -33
- package/dist/v3/segments.js.map +1 -1
- package/dist/v3/syntax.d.ts +68 -13
- package/dist/v3/syntax.d.ts.map +1 -1
- package/dist/v3/syntax.js +183 -102
- package/dist/v3/syntax.js.map +1 -1
- package/package.json +10 -6
- package/src/client.ts +293 -0
- package/src/core/account.ts +153 -24
- package/src/core/amount.ts +45 -10
- package/src/core/balance.ts +12 -5
- package/src/core/bank-info.ts +29 -5
- package/src/core/client.ts +83 -19
- package/src/core/config.ts +95 -35
- package/src/core/errors.ts +148 -54
- package/src/core/feedback.ts +16 -2
- package/src/core/transaction.ts +22 -4
- package/src/core/transport.ts +153 -32
- package/src/formats/camt.ts +153 -45
- package/src/formats/mt940.ts +244 -122
- package/src/formats/readers.ts +28 -31
- package/src/formats/record-budget.ts +18 -0
- package/src/formats/sepa-purpose.ts +29 -2
- package/src/index.ts +4 -2
- package/src/session/app-approval.ts +51 -38
- package/src/session/dialog-runner.ts +61 -31
- package/src/session/login-guard.ts +189 -87
- package/src/session/sepa-accounts.ts +63 -45
- package/src/session/session-setup.ts +105 -68
- package/src/session/session-state.ts +74 -23
- package/src/session/signed-dialog.ts +222 -0
- package/src/session/tan-selection.ts +50 -39
- package/src/session/user-prompts.ts +62 -18
- package/src/tan/challenge.ts +87 -64
- package/src/tan/flicker.ts +72 -23
- package/src/tan/tan-image.ts +15 -6
- package/src/tan/tan-models.ts +26 -7
- package/src/util/arguments.ts +40 -0
- package/src/util/async.ts +10 -9
- package/src/util/bytes.ts +14 -20
- package/src/util/call-context.ts +3 -2
- package/src/util/dates.ts +64 -33
- package/src/util/errors.ts +22 -6
- package/src/util/immutable-map.ts +15 -12
- package/src/util/inspect.ts +14 -0
- package/src/util/json.ts +16 -0
- package/src/util/text.ts +87 -15
- package/src/util/xml.ts +130 -52
- package/src/v3/account-extension.ts +7 -12
- package/src/v3/bank-connection.ts +126 -0
- package/src/v3/dialog.ts +186 -92
- package/src/v3/message.ts +140 -79
- package/src/v3/parameter-store.ts +226 -0
- package/src/v3/parameters.ts +166 -66
- package/src/v3/protocol.ts +103 -253
- package/src/v3/queries.ts +198 -0
- package/src/v3/segments.ts +86 -31
- package/src/v3/syntax.ts +172 -93
- package/dist/session/bank-connection.d.ts +0 -28
- package/dist/session/bank-connection.d.ts.map +0 -1
- package/dist/session/bank-connection.js +0 -48
- package/dist/session/bank-connection.js.map +0 -1
- package/dist/session/parameter-data.d.ts +0 -83
- package/dist/session/parameter-data.d.ts.map +0 -1
- package/dist/session/parameter-data.js +0 -68
- package/dist/session/parameter-data.js.map +0 -1
- package/dist/session/pin-tan-client.d.ts +0 -54
- package/dist/session/pin-tan-client.d.ts.map +0 -1
- package/dist/session/pin-tan-client.js +0 -153
- package/dist/session/pin-tan-client.js.map +0 -1
- package/dist/session/pin-tan-dialog.d.ts +0 -71
- package/dist/session/pin-tan-dialog.d.ts.map +0 -1
- package/dist/session/pin-tan-dialog.js +0 -124
- package/dist/session/pin-tan-dialog.js.map +0 -1
- package/dist/session/protocol.d.ts +0 -209
- package/dist/session/protocol.d.ts.map +0 -1
- package/dist/session/protocol.js +0 -75
- package/dist/session/protocol.js.map +0 -1
- package/dist/session/response-handler.d.ts +0 -48
- package/dist/session/response-handler.d.ts.map +0 -1
- package/dist/session/response-handler.js +0 -121
- package/dist/session/response-handler.js.map +0 -1
- package/dist/v3/client.d.ts +0 -24
- package/dist/v3/client.d.ts.map +0 -1
- package/dist/v3/client.js +0 -16
- package/dist/v3/client.js.map +0 -1
- package/src/session/bank-connection.ts +0 -51
- package/src/session/parameter-data.ts +0 -137
- package/src/session/pin-tan-client.ts +0 -186
- package/src/session/pin-tan-dialog.ts +0 -160
- package/src/session/protocol.ts +0 -311
- package/src/session/response-handler.ts +0 -130
- package/src/v3/client.ts +0 -29
package/dist/v3/protocol.js
CHANGED
|
@@ -1,83 +1,50 @@
|
|
|
1
1
|
// Internal to the package, and named after the FinTS specification. Documentation is where the meaning is not evident.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { hasErrors } from '../core/feedback.js';
|
|
5
|
-
import { camtTransactions, mt940Transactions } from '../formats/readers.js';
|
|
6
|
-
import { BankConnection, checkMessageSize } from '../session/bank-connection.js';
|
|
7
|
-
import { LoginGuard } from '../session/login-guard.js';
|
|
8
|
-
import { offeredVersion, requireBankParameters } from '../session/parameter-data.js';
|
|
9
|
-
import { balanceQuery, checkBeforeSigning, chooseTransactions, } from '../session/protocol.js';
|
|
10
|
-
import { invalidArgument } from '../util/errors.js';
|
|
11
|
-
import { readOptionalString } from '../util/json.js';
|
|
2
|
+
import { requirePinLength } from '../core/config.js';
|
|
3
|
+
import { clientClosedError } from '../core/errors.js';
|
|
12
4
|
import { decodeBankText } from '../util/text.js';
|
|
13
|
-
import {
|
|
14
|
-
import { buildMessage, decodeTransport, encodeTransport
|
|
15
|
-
import {
|
|
16
|
-
import { balanceAccount, parseBalance, parseSepaAccounts, parseTanMedia, Segments } from './segments.js';
|
|
17
|
-
import { isLatin1 } from './syntax.js';
|
|
5
|
+
import { BankConnection, checkMessageSize } from './bank-connection.js';
|
|
6
|
+
import { buildMessage, decodeTransport, encodeTransport } from './message.js';
|
|
7
|
+
import { Segments } from './segments.js';
|
|
18
8
|
/** Customer ID the specification reserves for anonymous dialogs. */
|
|
19
9
|
const anonymousCustomerId = '9999999999';
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
/**
|
|
11
|
+
* How long the request on its way when the client is closed may take, and then its dialog ends, where the transport
|
|
12
|
+
* takes the abort (`beginClose`).
|
|
13
|
+
*/
|
|
14
|
+
const closingGraceMs = 5000;
|
|
15
|
+
/**
|
|
16
|
+
* Throws if `limits` rule out a message of `size` bytes, or the length of `loginPin`, the PIN of a login: `TypeError`
|
|
17
|
+
* for the PIN, which the bank would count as a failed attempt, and `FinTsProtocolError` for the size.
|
|
18
|
+
*/
|
|
19
|
+
function checkLimits(limits, size, loginPin) {
|
|
20
|
+
if (loginPin !== undefined)
|
|
21
|
+
requirePinLength(loginPin, limits.pinLength?.min, limits.pinLength?.max);
|
|
22
|
+
checkMessageSize(size, limits.maxMessageSize);
|
|
28
23
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
/** Whether `segments` are those of a dialog end, the one message a closing client still sends. */
|
|
25
|
+
function isDialogEnd(segments) {
|
|
26
|
+
return segments.length === 1 && segments[0].type === 'HKEND';
|
|
32
27
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// Cut short, the product would be one the bank does not know.
|
|
39
|
-
requireMaxLength(config.productId, maxProductIdLength, 'productId');
|
|
40
|
-
requireMaxLength(config.productVersion, maxProductVersionLength, 'productVersion');
|
|
41
|
-
return config;
|
|
42
|
-
}
|
|
43
|
-
/** The segments of `type` in all `pages`. */
|
|
44
|
-
function all(pages, type) {
|
|
45
|
-
return pages.flatMap((p) => p.findAll(type));
|
|
46
|
-
}
|
|
47
|
-
/** FinTS 3.0 messages and business transactions (HBCI segment syntax, PIN/TAN security). */
|
|
28
|
+
/**
|
|
29
|
+
* Builds, signs and posts FinTS 3.0 messages (HBCI segment syntax, PIN/TAN security) for the user `parameters.config`
|
|
30
|
+
* names, with the parameter data and IDs `parameters` keeps. Every message signed with the PIN takes it from the
|
|
31
|
+
* `PinGuard` (`post`), which keeps it from going out after a refused login.
|
|
32
|
+
*/
|
|
48
33
|
export class FinTs3Protocol {
|
|
34
|
+
parameters;
|
|
35
|
+
guard;
|
|
49
36
|
config;
|
|
50
|
-
pin;
|
|
51
37
|
connection;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.config = requireSendable(config);
|
|
63
|
-
this.pin = requireLatin1(requirePin(pin), 'pin');
|
|
64
|
-
this.connection = new BankConnection(config.url, transport, logger);
|
|
65
|
-
}
|
|
66
|
-
get bankParameters() {
|
|
67
|
-
return this.bpd;
|
|
68
|
-
}
|
|
69
|
-
get userParameters() {
|
|
70
|
-
return this.upd;
|
|
71
|
-
}
|
|
72
|
-
/** Dialogs cannot start without the customer system ID. */
|
|
73
|
-
get synchronization() {
|
|
74
|
-
return this.systemId === undefined ? 'required' : 'none';
|
|
75
|
-
}
|
|
76
|
-
forgetSystemId() {
|
|
77
|
-
const had = this.systemId !== undefined;
|
|
78
|
-
this.systemId = undefined;
|
|
79
|
-
return had;
|
|
80
|
-
}
|
|
38
|
+
closing = false;
|
|
39
|
+
/** The error with which the limits last stopped a login (`stoppedLogin`). */
|
|
40
|
+
stoppedLoginError;
|
|
41
|
+
constructor(parameters, guard, transport, logger) {
|
|
42
|
+
this.parameters = parameters;
|
|
43
|
+
this.guard = guard;
|
|
44
|
+
this.config = parameters.config;
|
|
45
|
+
this.connection = new BankConnection(this.config.url, transport, logger);
|
|
46
|
+
}
|
|
47
|
+
/** Identification (HKIDN) and processing preparation (HKVVB), which open every dialog. */
|
|
81
48
|
initSegments(systemId, anonymous = false) {
|
|
82
49
|
return [
|
|
83
50
|
Segments.identification({
|
|
@@ -88,173 +55,87 @@ export class FinTs3Protocol {
|
|
|
88
55
|
systemIdRequired: !anonymous,
|
|
89
56
|
}),
|
|
90
57
|
Segments.processingPreparation({
|
|
91
|
-
bpdVersion: this.
|
|
92
|
-
updVersion: anonymous ? 0 :
|
|
93
|
-
language: this.
|
|
58
|
+
bpdVersion: this.parameters.reportedBpdVersion,
|
|
59
|
+
updVersion: anonymous ? 0 : this.parameters.reportedUpdVersion,
|
|
60
|
+
language: this.parameters.bankParameters?.dialogLanguage ?? 0,
|
|
94
61
|
productId: this.config.productId,
|
|
95
62
|
productVersion: this.config.productVersion,
|
|
96
63
|
}),
|
|
97
64
|
];
|
|
98
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Sends `segments` as message `number` of the dialog `dialogId` and returns the bank's answer, not yet parsed.
|
|
68
|
+
*
|
|
69
|
+
* With `signing` the message is signed with the PIN, which `PinGuard.pin` hands out, and the `tan`; without, it
|
|
70
|
+
* goes out unsigned, as in an anonymous dialog.
|
|
71
|
+
*/
|
|
99
72
|
async post(message) {
|
|
73
|
+
if (this.closing && !isDialogEnd(message.segments))
|
|
74
|
+
throw clientClosedError();
|
|
100
75
|
const signing = message.signing;
|
|
101
|
-
|
|
102
|
-
|
|
76
|
+
const security = signing === undefined
|
|
77
|
+
? undefined
|
|
78
|
+
: {
|
|
79
|
+
countryCode: this.config.countryCode,
|
|
80
|
+
bankCode: this.config.bankCode,
|
|
81
|
+
userId: this.config.userId,
|
|
82
|
+
systemId: signing.systemId,
|
|
83
|
+
pin: this.guard.pin,
|
|
84
|
+
securityFunction: signing.securityFunction,
|
|
85
|
+
};
|
|
86
|
+
// The first message of a signed dialog logs in: from here on the bank may count the PIN.
|
|
87
|
+
const login = security !== undefined && message.number === 1;
|
|
103
88
|
const outgoing = buildMessage({
|
|
104
89
|
dialogId: message.dialogId,
|
|
105
90
|
messageNumber: message.number,
|
|
106
91
|
segments: message.segments,
|
|
107
|
-
security
|
|
108
|
-
? undefined
|
|
109
|
-
: {
|
|
110
|
-
countryCode: this.config.countryCode,
|
|
111
|
-
bankCode: this.config.bankCode,
|
|
112
|
-
userId: this.config.userId,
|
|
113
|
-
systemId: signing.systemId,
|
|
114
|
-
pin: this.pin,
|
|
115
|
-
securityFunction: signing.securityFunction,
|
|
116
|
-
},
|
|
92
|
+
security,
|
|
117
93
|
tan: message.tan,
|
|
118
94
|
});
|
|
119
|
-
|
|
95
|
+
this.checkOutgoing(outgoing.bytes.length, login ? security.pin : undefined);
|
|
96
|
+
this.connection.checkSendable();
|
|
120
97
|
this.connection.log('outgoing', () => outgoing.masked);
|
|
98
|
+
if (login)
|
|
99
|
+
this.guard.loginSent();
|
|
121
100
|
const bytes = decodeTransport(await this.connection.post(encodeTransport(outgoing.bytes), 'text/plain'));
|
|
122
101
|
this.connection.log('incoming', () => decodeBankText(bytes));
|
|
123
102
|
return bytes;
|
|
124
103
|
}
|
|
125
|
-
keepParameterData(response) {
|
|
126
|
-
this.keepBankParameters(response);
|
|
127
|
-
this.upd = Upd3.fromSegments(response.segments, this.config.bankCode, this.config.countryCode) ?? this.upd;
|
|
128
|
-
this.systemId = response.find('HISYN')?.text(1) ?? this.systemId;
|
|
129
|
-
}
|
|
130
|
-
keepBankParameters(response) {
|
|
131
|
-
this.bpd = Bpd3.fromSegments(response.segments, this.config.bankCode) ?? this.bpd;
|
|
132
|
-
}
|
|
133
|
-
/** Keeps the bank parameter data of an anonymous dialog, and nothing that belongs to a user. */
|
|
134
|
-
async fetchBankParametersAnonymously() {
|
|
135
|
-
const response = await this.requestBankParametersAnonymously();
|
|
136
|
-
this.keepBankParameters(response);
|
|
137
|
-
return response;
|
|
138
|
-
}
|
|
139
104
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
105
|
+
* Throws if the limits of the parameter data rule out a message of `size` bytes, or the length of `loginPin`, the PIN
|
|
106
|
+
* of a login (`checkLimits`). The later messages of a dialog, its end included, take the PIN the bank has accepted,
|
|
107
|
+
* whatever the parameter data it delivered since say.
|
|
142
108
|
*
|
|
143
|
-
*
|
|
109
|
+
* Remembers the error that stops a login (`stoppedLogin`): the parameter data may be outdated, as saved ones are,
|
|
110
|
+
* and new ones would come only in answer to the login they rule out.
|
|
144
111
|
*/
|
|
145
|
-
|
|
146
|
-
let announced;
|
|
112
|
+
checkOutgoing(size, loginPin) {
|
|
147
113
|
try {
|
|
148
|
-
|
|
114
|
+
checkLimits(this.parameters.limits, size, loginPin);
|
|
149
115
|
}
|
|
150
116
|
catch (error) {
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
throw error;
|
|
155
|
-
return this.anonymousDialog(false);
|
|
117
|
+
if (loginPin !== undefined)
|
|
118
|
+
this.stoppedLoginError = error;
|
|
119
|
+
throw error;
|
|
156
120
|
}
|
|
157
|
-
if (!hasErrors(announced.feedback) || announced.find('HIBPA') !== undefined)
|
|
158
|
-
return announced;
|
|
159
|
-
return this.anonymousDialog(false);
|
|
160
121
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return await dialog.requestBankParameters(announceSca);
|
|
165
|
-
}
|
|
166
|
-
finally {
|
|
167
|
-
await dialog.end();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
newDialog(method, tanMedium) {
|
|
171
|
-
return FinTs3Dialog.signed(this, method, tanMedium);
|
|
172
|
-
}
|
|
173
|
-
combine(first, second) {
|
|
174
|
-
return IncomingMessage3.combine(first, second);
|
|
175
|
-
}
|
|
176
|
-
// --- Business transactions ---
|
|
177
|
-
version(transaction, implemented, options = {}) {
|
|
178
|
-
return offeredVersion(this.bpd, this.upd, transaction, new Set(implemented), options);
|
|
179
|
-
}
|
|
180
|
-
tanMedia() {
|
|
181
|
-
const version = this.version('HKTAB', [4, 5]);
|
|
182
|
-
if (version === undefined)
|
|
183
|
-
return undefined;
|
|
184
|
-
return {
|
|
185
|
-
order: () => Segments.tanMedia(version),
|
|
186
|
-
read: (pages) => all(pages, 'HITAB').flatMap(parseTanMedia),
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
sepaAccounts() {
|
|
190
|
-
const version = this.version('HKSPA', [1, 2, 3], { requiresEntry: true });
|
|
191
|
-
if (version === undefined)
|
|
192
|
-
return undefined;
|
|
193
|
-
return {
|
|
194
|
-
order: (continuation) => Segments.sepaAccounts(version, continuation),
|
|
195
|
-
read: (pages) => all(pages, 'HISPA').flatMap((s) => parseSepaAccounts(s, this.config.countryCode, this.config.bankCode)),
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
balance(account) {
|
|
199
|
-
const version = this.version('HKSAL', [6, 7, 8], { account });
|
|
200
|
-
if (version === undefined) {
|
|
201
|
-
throw new FinTsUnsupportedError('The bank reports no balance (HKSAL) for this account');
|
|
202
|
-
}
|
|
203
|
-
return balanceQuery(account, {
|
|
204
|
-
order: (continuation) => Segments.balance(version, account, continuation),
|
|
205
|
-
records: (pages) => all(pages, 'HISAL'),
|
|
206
|
-
accountOf: balanceAccount,
|
|
207
|
-
read: parseBalance,
|
|
208
|
-
});
|
|
122
|
+
/** Whether `error` is the one with which the limits of the parameter data last stopped a login. */
|
|
123
|
+
stoppedLogin(error) {
|
|
124
|
+
return this.stoppedLoginError !== undefined && this.stoppedLoginError === error;
|
|
209
125
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
camtFormats: requireBankParameters(this.bpd).camtFormats,
|
|
214
|
-
mt940: { name: 'HKKAZ', version: this.version('HKKAZ', [6, 7], { account }) },
|
|
215
|
-
});
|
|
216
|
-
const version = request.version;
|
|
217
|
-
if (request.camt) {
|
|
218
|
-
return {
|
|
219
|
-
order: (continuation) => Segments.transactionsCamt(version, account, request.camtFormats, { from, to, continuation }),
|
|
220
|
-
// The third element group holds the booked documents, the fourth element the pending one.
|
|
221
|
-
read: (pages) => camtTransactions(all(pages, 'HICAZ').flatMap((s) => s
|
|
222
|
-
.group(3)
|
|
223
|
-
.filter((d) => !d.isEmpty)
|
|
224
|
-
.map((d) => d.bytes)), all(pages, 'HICAZ')
|
|
225
|
-
.map((s) => s.binary(4))
|
|
226
|
-
.filter((d) => d !== undefined)),
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
return {
|
|
230
|
-
order: (continuation) => Segments.transactionsMt940(version, account, { from, to, continuation }),
|
|
231
|
-
// The first element holds the booked transactions, the second the pending ones.
|
|
232
|
-
read: (pages) => mt940Transactions(all(pages, 'HIKAZ')
|
|
233
|
-
.map((s) => s.binary(1))
|
|
234
|
-
.filter((d) => d !== undefined), all(pages, 'HIKAZ')
|
|
235
|
-
.map((s) => s.binary(2))
|
|
236
|
-
.filter((d) => d !== undefined), request.currency),
|
|
237
|
-
};
|
|
126
|
+
/** Whether the client is closing, so that only dialog ends go out (`beginClose`). */
|
|
127
|
+
get isClosing() {
|
|
128
|
+
return this.closing;
|
|
238
129
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const bpd = readOptionalString(saved, 'bpd');
|
|
249
|
-
const upd = readOptionalString(saved, 'upd');
|
|
250
|
-
const restoredSystemId = readOptionalString(saved, 'systemId');
|
|
251
|
-
const restoredBpd = bpd === undefined ? undefined : Bpd3.fromSegments(decodeSegments(bpd), this.config.bankCode);
|
|
252
|
-
const restoredUpd = upd === undefined
|
|
253
|
-
? undefined
|
|
254
|
-
: Upd3.fromSegments(decodeSegments(upd), this.config.bankCode, this.config.countryCode);
|
|
255
|
-
this.systemId = restoredSystemId;
|
|
256
|
-
this.bpd = restoredBpd;
|
|
257
|
-
this.upd = restoredUpd;
|
|
130
|
+
/**
|
|
131
|
+
* Sends nothing but dialog ends from now on: any other message fails with `FinTsStateError` before it goes out, so
|
|
132
|
+
* that a call under way stops at its next one. The request on its way has `closingGraceMs` to bring its answer, which
|
|
133
|
+
* counts as any other, and is aborted then; the dialog ends have as long again once it is over, and none goes out
|
|
134
|
+
* later. The client calls it as soon as it is closed, and `close` once it has ended its dialog.
|
|
135
|
+
*/
|
|
136
|
+
beginClose() {
|
|
137
|
+
this.closing = true;
|
|
138
|
+
this.connection.abortRequestsAfter(closingGraceMs);
|
|
258
139
|
}
|
|
259
140
|
close() {
|
|
260
141
|
this.connection.close();
|
package/dist/v3/protocol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/v3/protocol.ts"],"names":[],"mappings":"AAAA,uHAAuH;AAKvH,OAAO,EAAE,UAAU,EAAoB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,GAInB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAmB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAwC,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,QAAQ,EAAkC,M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AAK,CAAC,SAAS,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;QACzG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;OAOG;IACK,aAAa,CAAC,IAAY,EAAE,QAA4B;QAC9D,IAAI,CAAC;YACH,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,QAAQ,KAAK,SAAS;gBAAE,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;YAC3D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,mGAAmG;IACnG,YAAY,CAAC,KAAc;QACzB,OAAO,IAAI,CAAC,iBAAiB,KAAK,SAAS,IAAI,IAAI,CAAC,iBAAiB,KAAK,KAAK,CAAC;IAClF,CAAC;IAED,qFAAqF;IACrF,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,UAAU;QACR,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACrD,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Account } from '../core/account.js';
|
|
2
|
+
import type { Balance } from '../core/balance.js';
|
|
3
|
+
import type { FinTsFeedback } from '../core/feedback.js';
|
|
4
|
+
import type { Transaction, TransactionFormat } from '../core/transaction.js';
|
|
5
|
+
import type { TanMedium } from '../tan/tan-models.js';
|
|
6
|
+
import type { IncomingMessage3 } from './message.js';
|
|
7
|
+
import type { ParameterStore } from './parameter-store.js';
|
|
8
|
+
import type { Segment, SegmentSpec } from './syntax.js';
|
|
9
|
+
/**
|
|
10
|
+
* A business transaction: the order to send for each page, and how to read all pages the bank sent.
|
|
11
|
+
*
|
|
12
|
+
* Where the bank does not offer the transaction, the builders of the lookups the session makes for itself, of the TAN
|
|
13
|
+
* media and the SEPA accounts, return `undefined`, and those of the app's queries, of a balance and of transactions,
|
|
14
|
+
* throw `FinTsUnsupportedError`.
|
|
15
|
+
*/
|
|
16
|
+
export interface Query<T> {
|
|
17
|
+
/** The order for the page at `continuation`; `undefined` for the first page. */
|
|
18
|
+
readonly order: (continuation: string | undefined) => SegmentSpec;
|
|
19
|
+
/** Reads the result; throws `FormatError` for malformed data. */
|
|
20
|
+
readonly read: (pages: readonly IncomingMessage3[]) => T;
|
|
21
|
+
}
|
|
22
|
+
/** Lists the TAN media, and keeps the names as the bank sent them in `parameters`; `undefined` if the bank does not. */
|
|
23
|
+
export declare function tanMediaQuery(parameters: ParameterStore): Query<TanMedium[]> | undefined;
|
|
24
|
+
/** Lists IBAN and BIC of the accounts; `undefined` if the bank does not offer it. */
|
|
25
|
+
export declare function sepaAccountsQuery(parameters: ParameterStore): Query<Account[]> | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The balance (HISAL) of `account` in `records`: the one whose account matches. A single record must match as well,
|
|
28
|
+
* though the query asked for this one account only: it names the account it is for.
|
|
29
|
+
*
|
|
30
|
+
* Throws `FinTsBankError` with the bank's `feedback` if there is none, and `FinTsProtocolError` if none matches.
|
|
31
|
+
*
|
|
32
|
+
* @internal Exported for the tests.
|
|
33
|
+
*/
|
|
34
|
+
export declare function balanceRecord(records: readonly Segment[], account: Account, feedback: readonly FinTsFeedback[]): Segment;
|
|
35
|
+
/**
|
|
36
|
+
* The balance of `account`, which the session has taken as the bank knows it, with the transactions the bank permits
|
|
37
|
+
* for it (`SepaAccounts.complete`); throws `FinTsUnsupportedError` if the bank does not report balances.
|
|
38
|
+
*/
|
|
39
|
+
export declare function balanceQuery(parameters: ParameterStore, account: Account): Query<Balance>;
|
|
40
|
+
/**
|
|
41
|
+
* The transactions of `account` in `format`, from the day of `from` to that of `to`. The session has taken `account` as
|
|
42
|
+
* the bank knows it, with the transactions the bank permits for it and its currency (`SepaAccounts.complete`).
|
|
43
|
+
*
|
|
44
|
+
* The client reads camt.052 only, so camt counts as offered only where the bank offers a camt.052 format. With `auto`
|
|
45
|
+
* the client takes camt where the bank offers it, unless MT940 can be requested for the account and the user parameter
|
|
46
|
+
* data list only MT940 transactions for it.
|
|
47
|
+
*
|
|
48
|
+
* Throws `FinTsUnsupportedError` if the bank does not offer the chosen format for the account.
|
|
49
|
+
*/
|
|
50
|
+
export declare function transactionsQuery(parameters: ParameterStore, account: Account, format: TransactionFormat, from: Date | undefined, to: Date | undefined): Query<Transaction[]>;
|
|
51
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/v3/queries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC;IACtB,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,KAAK,WAAW,CAAC;IAElE,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,KAAK,CAAC,CAAC;CAC1D;AAsBD,wHAAwH;AACxH,wBAAgB,aAAa,CAAC,UAAU,EAAE,cAAc,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC,GAAG,SAAS,CAYxF;AAED,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,CAQ1F;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,OAAO,EAAE,EAC3B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,SAAS,aAAa,EAAE,GACjC,OAAO,CAOT;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAkBzF;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE,IAAI,GAAG,SAAS,EACtB,EAAE,EAAE,IAAI,GAAG,SAAS,GACnB,KAAK,CAAC,WAAW,EAAE,CAAC,CA4DtB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Internal to the package, and named after the FinTS specification. Documentation is where the meaning is not evident.
|
|
2
|
+
import { FinTsBankError, FinTsProtocolError, FinTsUnsupportedError } from '../core/errors.js';
|
|
3
|
+
import { camtTransactions, mt940Transactions } from '../formats/readers.js';
|
|
4
|
+
import { lists, offeredVersion, requireBankParameters } from './parameters.js';
|
|
5
|
+
import { balanceAccount, camtAccount, parseBalance, parseSepaAccounts, parseTanMedia, Segments } from './segments.js';
|
|
6
|
+
/** The segments of `type` in all `pages`. */
|
|
7
|
+
function all(pages, type) {
|
|
8
|
+
return pages.flatMap((p) => p.findAll(type));
|
|
9
|
+
}
|
|
10
|
+
function version(parameters, transaction, implemented, options = {}) {
|
|
11
|
+
return offeredVersion(parameters.bankParameters, parameters.userParameters, transaction, new Set(implemented), options);
|
|
12
|
+
}
|
|
13
|
+
/** Lists the TAN media, and keeps the names as the bank sent them in `parameters`; `undefined` if the bank does not. */
|
|
14
|
+
export function tanMediaQuery(parameters) {
|
|
15
|
+
const offered = version(parameters, 'HKTAB', [4, 5]);
|
|
16
|
+
if (offered === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
return {
|
|
19
|
+
order: () => Segments.tanMedia(offered),
|
|
20
|
+
read: (pages) => {
|
|
21
|
+
const names = new Map();
|
|
22
|
+
const media = all(pages, 'HITAB').flatMap((s) => parseTanMedia(s, names));
|
|
23
|
+
parameters.keepTanMediumNames(names);
|
|
24
|
+
return media;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Lists IBAN and BIC of the accounts; `undefined` if the bank does not offer it. */
|
|
29
|
+
export function sepaAccountsQuery(parameters) {
|
|
30
|
+
const offered = version(parameters, 'HKSPA', [1, 2, 3], { requiresEntry: true });
|
|
31
|
+
if (offered === undefined)
|
|
32
|
+
return undefined;
|
|
33
|
+
const { countryCode, bankCode } = parameters.config;
|
|
34
|
+
return {
|
|
35
|
+
order: (continuation) => Segments.sepaAccounts(offered, continuation),
|
|
36
|
+
read: (pages) => all(pages, 'HISPA').flatMap((s) => parseSepaAccounts(s, countryCode, bankCode)),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The balance (HISAL) of `account` in `records`: the one whose account matches. A single record must match as well,
|
|
41
|
+
* though the query asked for this one account only: it names the account it is for.
|
|
42
|
+
*
|
|
43
|
+
* Throws `FinTsBankError` with the bank's `feedback` if there is none, and `FinTsProtocolError` if none matches.
|
|
44
|
+
*
|
|
45
|
+
* @internal Exported for the tests.
|
|
46
|
+
*/
|
|
47
|
+
export function balanceRecord(records, account, feedback) {
|
|
48
|
+
if (records.length === 0)
|
|
49
|
+
throw new FinTsBankError(feedback, 'No balance returned');
|
|
50
|
+
const match = records.find((record) => balanceAccount(record).matches(account));
|
|
51
|
+
if (match === undefined) {
|
|
52
|
+
throw new FinTsProtocolError('The bank returned balances, but none for the requested account');
|
|
53
|
+
}
|
|
54
|
+
return match;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The balance of `account`, which the session has taken as the bank knows it, with the transactions the bank permits
|
|
58
|
+
* for it (`SepaAccounts.complete`); throws `FinTsUnsupportedError` if the bank does not report balances.
|
|
59
|
+
*/
|
|
60
|
+
export function balanceQuery(parameters, account) {
|
|
61
|
+
const offered = version(parameters, 'HKSAL', [6, 7, 8], { account });
|
|
62
|
+
if (offered === undefined) {
|
|
63
|
+
throw new FinTsUnsupportedError('The bank reports no balance (HKSAL) for this account');
|
|
64
|
+
}
|
|
65
|
+
const nationalAllowed = requireBankParameters(parameters.bankParameters).nationalAccountAllowed;
|
|
66
|
+
return {
|
|
67
|
+
order: (continuation) => Segments.balance(offered, account, nationalAllowed, continuation),
|
|
68
|
+
read: (pages) => parseBalance(balanceRecord(all(pages, 'HISAL'), account, pages.flatMap((p) => p.feedback)), account),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The transactions of `account` in `format`, from the day of `from` to that of `to`. The session has taken `account` as
|
|
73
|
+
* the bank knows it, with the transactions the bank permits for it and its currency (`SepaAccounts.complete`).
|
|
74
|
+
*
|
|
75
|
+
* The client reads camt.052 only, so camt counts as offered only where the bank offers a camt.052 format. With `auto`
|
|
76
|
+
* the client takes camt where the bank offers it, unless MT940 can be requested for the account and the user parameter
|
|
77
|
+
* data list only MT940 transactions for it.
|
|
78
|
+
*
|
|
79
|
+
* Throws `FinTsUnsupportedError` if the bank does not offer the chosen format for the account.
|
|
80
|
+
*/
|
|
81
|
+
export function transactionsQuery(parameters, account, format, from, to) {
|
|
82
|
+
const bpd = requireBankParameters(parameters.bankParameters);
|
|
83
|
+
const camtVersion = bpd.camtFormats.length === 0 ? undefined : version(parameters, 'HKCAZ', [1], { account });
|
|
84
|
+
const mt940Version = version(parameters, 'HKKAZ', [6, 7], { account });
|
|
85
|
+
const camt = format === 'camt' ||
|
|
86
|
+
(format === 'auto' &&
|
|
87
|
+
camtVersion !== undefined &&
|
|
88
|
+
(mt940Version === undefined || lists(account, 'HKCAZ') || !lists(account, 'HKKAZ')));
|
|
89
|
+
const offered = camt ? camtVersion : mt940Version;
|
|
90
|
+
if (offered === undefined) {
|
|
91
|
+
throw new FinTsUnsupportedError(`The bank offers no ${camt ? 'camt ' : ''}transactions (${camt ? 'HKCAZ' : 'HKKAZ'}) for this account`);
|
|
92
|
+
}
|
|
93
|
+
if (camt) {
|
|
94
|
+
return {
|
|
95
|
+
order: (continuation) => Segments.transactionsCamt(offered, account, bpd.nationalAccountAllowed, bpd.camtFormats, {
|
|
96
|
+
from,
|
|
97
|
+
to,
|
|
98
|
+
continuation,
|
|
99
|
+
}),
|
|
100
|
+
// The first element names the account, the third element group holds the booked documents, the fourth
|
|
101
|
+
// element the pending one: binary data, which a bank may send as text instead.
|
|
102
|
+
read: (pages) => {
|
|
103
|
+
const segments = all(pages, 'HICAZ');
|
|
104
|
+
if (!segments.every((s) => camtAccount(s).matches(account))) {
|
|
105
|
+
throw new FinTsProtocolError('The bank returned the transactions of another account than the one asked for');
|
|
106
|
+
}
|
|
107
|
+
return camtTransactions(segments.flatMap((s) => s
|
|
108
|
+
.group(3)
|
|
109
|
+
.filter((d) => !d.isEmpty)
|
|
110
|
+
.map((d) => d.bytes)), segments.map((s) => s.bytes(4)).filter((d) => d !== undefined));
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
order: (continuation) => Segments.transactionsMt940(offered, account, bpd.nationalAccountAllowed, { from, to, continuation }),
|
|
116
|
+
// The first element holds the booked transactions, the second the pending ones: binary data, which a bank may send
|
|
117
|
+
// as text instead. Unlike HICAZ, HIKAZ names no account, and banks write the account line of a statement (`:25:`)
|
|
118
|
+
// in many ways, so it is not compared with `account`: a strict comparison would fail every query of such a bank.
|
|
119
|
+
read: (pages) => mt940Transactions(all(pages, 'HIKAZ')
|
|
120
|
+
.map((s) => s.bytes(1))
|
|
121
|
+
.filter((d) => d !== undefined), all(pages, 'HIKAZ')
|
|
122
|
+
.map((s) => s.bytes(2))
|
|
123
|
+
.filter((d) => d !== undefined),
|
|
124
|
+
// The currency of statements that state none.
|
|
125
|
+
account.currency),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/v3/queries.ts"],"names":[],"mappings":"AAAA,uHAAuH;AAIvH,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG9F,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAkBtH,6CAA6C;AAC7C,SAAS,GAAG,CAAC,KAAkC,EAAE,IAAY;IAC3D,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;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