@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/core/errors.js
CHANGED
|
@@ -1,78 +1,116 @@
|
|
|
1
1
|
import { FormatError } from '../util/errors.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { nonBlank } from '../util/text.js';
|
|
3
|
+
import { endsDialog, FeedbackCodes, hasCode } from './feedback.js';
|
|
4
|
+
/**
|
|
5
|
+
* Base class of all errors the client raises about the bank and its data.
|
|
6
|
+
*
|
|
7
|
+
* Each error class states its `name`: a minifier renames classes, and `constructor.name` would show a meaningless one.
|
|
8
|
+
*/
|
|
4
9
|
export class FinTsError extends Error {
|
|
5
|
-
constructor(name, message, cause) {
|
|
6
|
-
super(message, cause === undefined ? undefined : { cause });
|
|
7
|
-
// Set explicitly: a minifier renames classes, and `constructor.name` would show a meaningless name.
|
|
8
|
-
this.name = name;
|
|
9
|
-
}
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* The connection to the bank failed or returned an HTTP error.
|
|
13
|
+
*
|
|
14
|
+
* It carries no `cause`: the transport's own error may hold the message it was sending, PIN and TAN included.
|
|
15
|
+
*/
|
|
12
16
|
export class FinTsTransportError extends FinTsError {
|
|
13
|
-
|
|
17
|
+
name = 'FinTsTransportError';
|
|
18
|
+
/**
|
|
19
|
+
* The HTTP status code of the bank's answer, `undefined` where none came, for example after a timeout; the client
|
|
20
|
+
* acts on it (`FinTsTransport.post`).
|
|
21
|
+
*/
|
|
14
22
|
statusCode;
|
|
15
23
|
constructor(message, options) {
|
|
16
|
-
super(
|
|
24
|
+
super(message);
|
|
17
25
|
this.statusCode = options?.statusCode;
|
|
18
26
|
}
|
|
19
27
|
}
|
|
20
28
|
/** The bank's response could not be understood. */
|
|
21
29
|
export class FinTsProtocolError extends FinTsError {
|
|
22
|
-
|
|
23
|
-
super('FinTsProtocolError', message);
|
|
24
|
-
}
|
|
30
|
+
name = 'FinTsProtocolError';
|
|
25
31
|
}
|
|
26
32
|
/** The bank does not offer the requested business transaction. */
|
|
27
33
|
export class FinTsUnsupportedError extends FinTsError {
|
|
28
|
-
|
|
29
|
-
super('FinTsUnsupportedError', message);
|
|
30
|
-
}
|
|
34
|
+
name = 'FinTsUnsupportedError';
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
33
|
-
* The
|
|
37
|
+
* The client has no TAN method or medium to log in with: the method in use needs a TAN medium the client could not
|
|
38
|
+
* learn, or the bank offers the user only TAN methods the client cannot run. Pass a medium to
|
|
39
|
+
* `FinTsClient.selectTanMethod`, or choose another method.
|
|
34
40
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
41
|
+
* The client does not send a login the bank would refuse for it, but the steps before, such as the synchronization or
|
|
42
|
+
* the lookup of the TAN media, may have gone out.
|
|
43
|
+
*/
|
|
44
|
+
export class FinTsTanSetupError extends FinTsError {
|
|
45
|
+
name = 'FinTsTanSetupError';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The bank rejected the request; `feedback` holds all return codes. A refused login is a `FinTsLoginRefusedError`.
|
|
49
|
+
*
|
|
50
|
+
* The message is not safe to log: by default it holds the code, text and parameters of each error the bank names, such
|
|
51
|
+
* as an IBAN or a login name, and so does `stack`. Log `codes` instead. `feedback` is a getter, not a field, so that
|
|
52
|
+
* `JSON.stringify` and Node.js's report of an uncaught error, which show an error's fields as they are, leave out at
|
|
53
|
+
* least the warnings and successes, such as the new login data of return code 3072.
|
|
37
54
|
*/
|
|
38
55
|
export class FinTsBankError extends FinTsError {
|
|
39
|
-
|
|
40
|
-
feedback;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
name = 'FinTsBankError';
|
|
57
|
+
#feedback;
|
|
58
|
+
/**
|
|
59
|
+
* A rejection with the return codes in `feedback`; `message` defaults to the errors among them, with the bank's texts
|
|
60
|
+
* and parameters, such as `9010: Konto gesperrt [DE89370400440532013000]`, so it is not safe to log.
|
|
61
|
+
*/
|
|
62
|
+
constructor(feedback, message) {
|
|
63
|
+
super(message ??
|
|
44
64
|
feedback
|
|
45
65
|
.filter((f) => f.isError)
|
|
46
|
-
.map(
|
|
66
|
+
.map(withText)
|
|
47
67
|
.join('; '));
|
|
48
|
-
this
|
|
68
|
+
this.#feedback = Object.freeze([...feedback]);
|
|
69
|
+
}
|
|
70
|
+
/** All return codes of the response, warnings and successes included. */
|
|
71
|
+
get feedback() {
|
|
72
|
+
return this.#feedback;
|
|
49
73
|
}
|
|
50
74
|
/** The return codes of `feedback`. */
|
|
51
75
|
get codes() {
|
|
52
76
|
return this.feedback.map((f) => f.code);
|
|
53
77
|
}
|
|
54
78
|
}
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
79
|
+
/**
|
|
80
|
+
* The bank refused the login, so the client sends the PIN no more: every later call that would send it fails with this
|
|
81
|
+
* error without contacting the bank, also in a client restored from the saved state, until
|
|
82
|
+
* `FinTsClient.clearLoginRefusal` takes a PIN the user has entered anew; for good where the bank has changed the login
|
|
83
|
+
* data (`FinTsLoginDataChangedError`).
|
|
84
|
+
*
|
|
85
|
+
* Banks lock the access after a few failed logins, and a return code does not always tell whether the PIN was the
|
|
86
|
+
* reason, so any error in the answer to a login refuses it, also one that ends the dialog, and so does a wrong PIN
|
|
87
|
+
* wherever the bank reports it. Only where the bank names a reason the client can take care of, another TAN method or a
|
|
88
|
+
* new customer system ID, does the same call log in once more, for each reason once. The client refuses the login
|
|
89
|
+
* itself where it could not read the answers to two logins in a row, which the bank may have counted as failed
|
|
90
|
+
* attempts; `feedback` is empty then.
|
|
91
|
+
*/
|
|
92
|
+
export class FinTsLoginRefusedError extends FinTsBankError {
|
|
93
|
+
name = 'FinTsLoginRefusedError';
|
|
94
|
+
}
|
|
95
|
+
/** Wrong or blocked PIN. */
|
|
96
|
+
export class FinTsPinError extends FinTsLoginRefusedError {
|
|
97
|
+
name = 'FinTsPinError';
|
|
60
98
|
}
|
|
61
99
|
/** Invalid, expired or rejected TAN, as the bank reports it in answer to a TAN or to an approval status request. */
|
|
62
100
|
export class FinTsTanError extends FinTsBankError {
|
|
63
|
-
|
|
64
|
-
super(feedback, undefined, 'FinTsTanError');
|
|
65
|
-
}
|
|
101
|
+
name = 'FinTsTanError';
|
|
66
102
|
}
|
|
67
103
|
/**
|
|
68
|
-
* The bank has changed the user's login data and expects the new ones from now on (return code 3072)
|
|
104
|
+
* The bank has changed the user's login data and expects the new ones from now on (return code 3072), also where it
|
|
105
|
+
* names an error next to them, but for a rejected PIN, which is a `FinTsPinError`.
|
|
69
106
|
*
|
|
70
|
-
* The client has ended the dialog,
|
|
71
|
-
* `loginName` replaces user ID and customer ID: pass it as `userId`, without a customer ID.
|
|
107
|
+
* The client has ended the dialog, where the bank opened one, and logs in with the old data no more. Create a new
|
|
108
|
+
* client with the new data; a `loginName` replaces user ID and customer ID: pass it as `userId`, without a customer ID.
|
|
72
109
|
*/
|
|
73
|
-
export class FinTsLoginDataChangedError extends
|
|
110
|
+
export class FinTsLoginDataChangedError extends FinTsLoginRefusedError {
|
|
111
|
+
name = 'FinTsLoginDataChangedError';
|
|
74
112
|
constructor(feedback) {
|
|
75
|
-
super(feedback, 'The bank has changed the login data'
|
|
113
|
+
super(feedback, 'The bank has changed the login data');
|
|
76
114
|
}
|
|
77
115
|
/** The new user ID (Benutzerkennung); `undefined` where the bank names none. */
|
|
78
116
|
get userId() {
|
|
@@ -88,26 +126,31 @@ export class FinTsLoginDataChangedError extends FinTsBankError {
|
|
|
88
126
|
}
|
|
89
127
|
parameter(index) {
|
|
90
128
|
const change = this.feedback.find((f) => f.code === FeedbackCodes.newLoginData);
|
|
91
|
-
|
|
92
|
-
return value === undefined || value === '' ? undefined : value;
|
|
129
|
+
return nonBlank(change?.parameters[index]);
|
|
93
130
|
}
|
|
94
131
|
}
|
|
95
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* The bank ended the dialog, for example after a timeout; the next call logs in anew. Where the bank ends the dialog
|
|
134
|
+
* in answer to a login, the call fails with `FinTsLoginRefusedError` instead.
|
|
135
|
+
*/
|
|
96
136
|
export class FinTsDialogAbortedError extends FinTsBankError {
|
|
97
|
-
|
|
98
|
-
super(feedback, undefined, 'FinTsDialogAbortedError');
|
|
99
|
-
}
|
|
137
|
+
name = 'FinTsDialogAbortedError';
|
|
100
138
|
}
|
|
101
139
|
/** The user cancelled the TAN entry or the approval in the banking app. */
|
|
102
140
|
export class FinTsTanCancelledError extends FinTsError {
|
|
141
|
+
name = 'FinTsTanCancelledError';
|
|
103
142
|
constructor() {
|
|
104
|
-
super('
|
|
143
|
+
super('TAN entry cancelled');
|
|
105
144
|
}
|
|
106
145
|
}
|
|
107
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* The user did not approve in the banking app in time: within the status requests the bank allows, 60 where it states
|
|
148
|
+
* none, and 10 minutes of polling at most.
|
|
149
|
+
*/
|
|
108
150
|
export class FinTsDecoupledTimeoutError extends FinTsError {
|
|
151
|
+
name = 'FinTsDecoupledTimeoutError';
|
|
109
152
|
constructor() {
|
|
110
|
-
super('
|
|
153
|
+
super('Approval on the separate device was not completed in time');
|
|
111
154
|
}
|
|
112
155
|
}
|
|
113
156
|
/**
|
|
@@ -116,10 +159,11 @@ export class FinTsDecoupledTimeoutError extends FinTsError {
|
|
|
116
159
|
* It does not extend `FinTsError`: it tells about the app's use of the client, not about the bank.
|
|
117
160
|
*/
|
|
118
161
|
export class FinTsStateError extends Error {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
162
|
+
name = 'FinTsStateError';
|
|
163
|
+
}
|
|
164
|
+
/** The error of whatever a closed client is asked to do. */
|
|
165
|
+
export function clientClosedError() {
|
|
166
|
+
return new FinTsStateError('The FinTS client is closed');
|
|
123
167
|
}
|
|
124
168
|
/**
|
|
125
169
|
* Return codes for a wrong or blocked PIN, from the FinTS return code list (Rückmeldungscodes): 9340 signature (PIN)
|
|
@@ -151,6 +195,10 @@ function isPinError(f) {
|
|
|
151
195
|
return true;
|
|
152
196
|
}
|
|
153
197
|
}
|
|
198
|
+
/** `f` with the bank's text and parameters, which `FinTsFeedback.toString` leaves out. */
|
|
199
|
+
function withText(f) {
|
|
200
|
+
return `${f.code}: ${f.text}${f.parameters.length === 0 ? '' : ` [${f.parameters.join(', ')}]`}`;
|
|
201
|
+
}
|
|
154
202
|
/**
|
|
155
203
|
* The most specific error for the errors in `feedback`, the answer to a message that `completesApproval` or not.
|
|
156
204
|
*
|
|
@@ -168,7 +216,24 @@ export function bankErrorFor(feedback, completesApproval = false) {
|
|
|
168
216
|
return new FinTsDialogAbortedError(feedback);
|
|
169
217
|
return new FinTsBankError(feedback);
|
|
170
218
|
}
|
|
171
|
-
/**
|
|
219
|
+
/**
|
|
220
|
+
* The refusal of a login whose answer carried `feedback`: `FinTsPinError` for a rejected PIN, else
|
|
221
|
+
* `FinTsLoginDataChangedError` for new login data, also next to other errors, and `FinTsLoginRefusedError` for anything
|
|
222
|
+
* else. The same for a refusal restored from the saved state, which keeps only `feedback`.
|
|
223
|
+
*
|
|
224
|
+
* New login data end the old ones for good, so the session takes care of no other reason the answer names.
|
|
225
|
+
*/
|
|
226
|
+
export function loginRefusalFor(feedback) {
|
|
227
|
+
if (feedback.some(isPinError))
|
|
228
|
+
return new FinTsPinError(feedback);
|
|
229
|
+
if (hasCode(feedback, FeedbackCodes.newLoginData))
|
|
230
|
+
return new FinTsLoginDataChangedError(feedback);
|
|
231
|
+
return new FinTsLoginRefusedError(feedback);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Runs `parse` on data from the bank and reports malformed data as `FinTsProtocolError`, whose message leaves the data
|
|
235
|
+
* out (`FormatError`).
|
|
236
|
+
*/
|
|
172
237
|
export function parseBankData(parse) {
|
|
173
238
|
try {
|
|
174
239
|
return parse();
|
|
@@ -179,4 +244,22 @@ export function parseBankData(parse) {
|
|
|
179
244
|
throw error;
|
|
180
245
|
}
|
|
181
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Runs `lookup`, which only completes data, such as the SEPA account list; `undefined` where the bank rejects it, so
|
|
249
|
+
* that the caller carries on without it. An aborted dialog counts as a rejection: banks end the dialog along with many.
|
|
250
|
+
* A refused login and a rejected TAN fail the call: the user must hear of them.
|
|
251
|
+
*/
|
|
252
|
+
export async function tryLookUp(lookup) {
|
|
253
|
+
try {
|
|
254
|
+
return await lookup();
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
if (!(error instanceof FinTsBankError) ||
|
|
258
|
+
error instanceof FinTsLoginRefusedError ||
|
|
259
|
+
error instanceof FinTsTanError) {
|
|
260
|
+
throw error;
|
|
261
|
+
}
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
182
265
|
//# sourceMappingURL=errors.js.map
|
package/dist/core/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAsB,MAAM,eAAe,CAAC;AAEvF;;;;GAIG;AACH,MAAM,OAAgB,UAAW,SAAQ,KAAK;CAE7C;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IACxC,IAAI,GAAG,qBAAqB,CAAC;I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,CAAC;QACxG,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,MAAwB;IACzD,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IACE,CAAC,CAAC,KAAK,YAAY,cAAc,CAAC;YAClC,KAAK,YAAY,sBAAsB;YACvC,KAAK,YAAY,aAAa,EAC9B,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/core/feedback.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { inspectCustom } from '../util/inspect.js';
|
|
1
2
|
/** A return code with text from the bank, for example `0020: Auftrag ausgeführt`. */
|
|
2
3
|
export declare class FinTsFeedback {
|
|
3
4
|
/** The four-digit return code; `0…` reports success, `3…` a warning and `9…` an error. */
|
|
@@ -6,7 +7,10 @@ export declare class FinTsFeedback {
|
|
|
6
7
|
readonly reference: string | undefined;
|
|
7
8
|
/** The bank's explanation of the code. */
|
|
8
9
|
readonly text: string;
|
|
9
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Values the bank adds to the code, such as the position to continue at: one character per byte the bank sent (ISO
|
|
12
|
+
* 8859-1, the FinTS character set), since the client and the app send them back as they came.
|
|
13
|
+
*/
|
|
10
14
|
readonly parameters: readonly string[];
|
|
11
15
|
constructor(init: {
|
|
12
16
|
code: string;
|
|
@@ -20,7 +24,13 @@ export declare class FinTsFeedback {
|
|
|
20
24
|
get isWarning(): boolean;
|
|
21
25
|
/** Whether the code is an error. */
|
|
22
26
|
get isError(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The code only, not the text and parameters, which may name the account or hold login data, such as those of return
|
|
29
|
+
* code 3072, so that logs and crash reports do not collect them; show `text` to the user.
|
|
30
|
+
*/
|
|
23
31
|
toString(): string;
|
|
32
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
33
|
+
[inspectCustom](): string;
|
|
24
34
|
}
|
|
25
35
|
/** Return codes the client reacts to, as named in the FinTS return code list (Rückmeldungscodes). */
|
|
26
36
|
export declare const FeedbackCodes: Readonly<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../../src/core/feedback.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,qBAAa,aAAa;IACxB,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB
|
|
1
|
+
{"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../../src/core/feedback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qFAAqF;AACrF,qBAAa,aAAa;IACxB,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;gBAE3B,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE;IAOhH,wCAAwC;IACxC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,qCAAqC;IACrC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,oCAAoC;IACpC,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB,wFAAwF;IACxF,CAAC,aAAa,CAAC,IAAI,MAAM;CAG1B;AAED,qGAAqG;AACrG,eAAO,MAAM,aAAa;IACxB,6GAA6G;;IAE7G,kHAAkH;;IAElH;;;OAGG;;IAEH,qEAAqE;;IAErE,mHAAmH;;IAEnH,4FAA4F;;IAE5F,6DAA6D;;IAE7D,sDAAsD;;IAEtD;;;OAGG;;IAEH,0HAA0H;;EAE1H,CAAC;AA0BH,4DAA4D;AAC5D,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjF;AAED,2CAA2C;AAC3C,wBAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAErE;AAED,sGAAsG;AACtG,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAO7E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,EAAE,CAOhF;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAEtE;AAED,mEAAmE;AACnE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,EAAE,CAEhF"}
|
package/dist/core/feedback.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { inspectCustom } from '../util/inspect.js';
|
|
1
2
|
/** A return code with text from the bank, for example `0020: Auftrag ausgeführt`. */
|
|
2
3
|
export class FinTsFeedback {
|
|
3
4
|
/** The four-digit return code; `0…` reports success, `3…` a warning and `9…` an error. */
|
|
@@ -6,7 +7,10 @@ export class FinTsFeedback {
|
|
|
6
7
|
reference;
|
|
7
8
|
/** The bank's explanation of the code. */
|
|
8
9
|
text;
|
|
9
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Values the bank adds to the code, such as the position to continue at: one character per byte the bank sent (ISO
|
|
12
|
+
* 8859-1, the FinTS character set), since the client and the app send them back as they came.
|
|
13
|
+
*/
|
|
10
14
|
parameters;
|
|
11
15
|
constructor(init) {
|
|
12
16
|
this.code = init.code;
|
|
@@ -26,8 +30,16 @@ export class FinTsFeedback {
|
|
|
26
30
|
get isError() {
|
|
27
31
|
return this.code.startsWith('9');
|
|
28
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* The code only, not the text and parameters, which may name the account or hold login data, such as those of return
|
|
35
|
+
* code 3072, so that logs and crash reports do not collect them; show `text` to the user.
|
|
36
|
+
*/
|
|
29
37
|
toString() {
|
|
30
|
-
return
|
|
38
|
+
return `FinTsFeedback(${this.code})`;
|
|
39
|
+
}
|
|
40
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
41
|
+
[inspectCustom]() {
|
|
42
|
+
return this.toString();
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
/** Return codes the client reacts to, as named in the FinTS return code list (Rückmeldungscodes). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedback.js","sourceRoot":"","sources":["../../src/core/feedback.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,MAAM,OAAO,aAAa;IACxB,0FAA0F;IACjF,IAAI,CAAS;IAEtB,4EAA4E;IACnE,SAAS,CAAqB;IAEvC,0CAA0C;IACjC,IAAI,CAAS;IAEtB
|
|
1
|
+
{"version":3,"file":"feedback.js","sourceRoot":"","sources":["../../src/core/feedback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qFAAqF;AACrF,MAAM,OAAO,aAAa;IACxB,0FAA0F;IACjF,IAAI,CAAS;IAEtB,4EAA4E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Q,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,EAAE;YAAE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9G,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAkC;IACpE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,iBAAiB;YAAE,SAAS;QACzD,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,UAAU;YAAE,IAAI,IAAI,KAAK,EAAE;gBAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,QAAkC;IAC3D,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,YAAY,CAAC,QAAkC;IAC7D,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { inspectCustom } from '../util/inspect.js';
|
|
1
2
|
import type { Amount } from './amount.js';
|
|
2
3
|
/** Whether a transaction is booked or still pending. */
|
|
3
4
|
export type TransactionStatus = 'booked' | 'pending';
|
|
5
|
+
/** `status`; throws `TypeError` unless it is a `TransactionStatus`. */
|
|
6
|
+
export declare function requireStatus(status: unknown): TransactionStatus;
|
|
4
7
|
/** Transaction format to request; `auto` prefers camt.052 when the bank supports it. */
|
|
5
8
|
export type TransactionFormat =
|
|
6
9
|
/** camt.052 where the bank offers it, otherwise MT940. */
|
|
@@ -84,8 +87,13 @@ export declare class Transaction {
|
|
|
84
87
|
readonly ultimateCreditor: string | undefined;
|
|
85
88
|
/** The party the payer acts for, where that is not the payer itself. */
|
|
86
89
|
readonly ultimateDebtor: string | undefined;
|
|
87
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* The SEPA keywords of the purpose, keyed by keyword (EREF, KREF, MREF, CRED, SVWZ, …): those `SepaPurpose` reads. In
|
|
92
|
+
* camt, EREF, MREF and CRED are those of `endToEndId`, `mandateId` and `creditorId`, which the bank states apart,
|
|
93
|
+
* never keywords of the remittance text the payer or the payee writes.
|
|
94
|
+
*/
|
|
88
95
|
readonly purposeCodes: ReadonlyMap<string, string>;
|
|
96
|
+
/** Takes copies of the dates and purpose codes of `init`: each transaction has its own, which no other one shares. */
|
|
89
97
|
constructor(init: TransactionInit);
|
|
90
98
|
/** Whether the transaction is still pending. */
|
|
91
99
|
get isPending(): boolean;
|
|
@@ -94,5 +102,7 @@ export declare class Transaction {
|
|
|
94
102
|
* account data.
|
|
95
103
|
*/
|
|
96
104
|
toString(): string;
|
|
105
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
106
|
+
[inspectCustom](): string;
|
|
97
107
|
}
|
|
98
108
|
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/core/transaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/core/transaction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,wDAAw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AExC,6CAA6C;IAC7C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/C,2CAA2C;IAC3C,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAE3C,oEAAoE;IACpE,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7C,kDAAkD;IAClD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/C,wCAAwC;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC,wEAAwE;IACxE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9C,wEAAwE;IACxE,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEnD,sHAAsH;gBAC1G,IAAI,EAAE,eAAe;IA0BjC,gDAAgD;IAChD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB,wFAAwF;IACxF,CAAC,aAAa,CAAC,IAAI,MAAM;CAG1B"}
|
package/dist/core/transaction.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { formatIsoDate } from '../util/dates.js';
|
|
1
|
+
import { copyDate, formatIsoDate } from '../util/dates.js';
|
|
2
|
+
import { invalidArgument } from '../util/errors.js';
|
|
2
3
|
import { ImmutableMap } from '../util/immutable-map.js';
|
|
4
|
+
import { inspectCustom } from '../util/inspect.js';
|
|
5
|
+
/** `status`; throws `TypeError` unless it is a `TransactionStatus`. */
|
|
6
|
+
export function requireStatus(status) {
|
|
7
|
+
if (status === 'booked' || status === 'pending')
|
|
8
|
+
return status;
|
|
9
|
+
throw invalidArgument("Must be 'booked' or 'pending'", 'status');
|
|
10
|
+
}
|
|
3
11
|
/** A single account transaction, parsed from camt.052 or MT940/MT942. */
|
|
4
12
|
export class Transaction {
|
|
5
13
|
/** Whether the transaction is booked or pending. */
|
|
@@ -49,12 +57,17 @@ export class Transaction {
|
|
|
49
57
|
ultimateCreditor;
|
|
50
58
|
/** The party the payer acts for, where that is not the payer itself. */
|
|
51
59
|
ultimateDebtor;
|
|
52
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* The SEPA keywords of the purpose, keyed by keyword (EREF, KREF, MREF, CRED, SVWZ, …): those `SepaPurpose` reads. In
|
|
62
|
+
* camt, EREF, MREF and CRED are those of `endToEndId`, `mandateId` and `creditorId`, which the bank states apart,
|
|
63
|
+
* never keywords of the remittance text the payer or the payee writes.
|
|
64
|
+
*/
|
|
53
65
|
purposeCodes;
|
|
66
|
+
/** Takes copies of the dates and purpose codes of `init`: each transaction has its own, which no other one shares. */
|
|
54
67
|
constructor(init) {
|
|
55
68
|
this.status = init.status ?? 'booked';
|
|
56
|
-
this.bookingDate = init.bookingDate;
|
|
57
|
-
this.valueDate = init.valueDate;
|
|
69
|
+
this.bookingDate = copyDate(init.bookingDate);
|
|
70
|
+
this.valueDate = copyDate(init.valueDate);
|
|
58
71
|
this.amount = init.amount;
|
|
59
72
|
this.isReversal = init.isReversal ?? false;
|
|
60
73
|
this.bookingText = init.bookingText;
|
|
@@ -87,5 +100,9 @@ export class Transaction {
|
|
|
87
100
|
toString() {
|
|
88
101
|
return `Transaction(${formatIsoDate(this.bookingDate ?? this.valueDate)}, ${this.status}${this.isReversal ? ', reversal' : ''})`;
|
|
89
102
|
}
|
|
103
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
104
|
+
[inspectCustom]() {
|
|
105
|
+
return this.toString();
|
|
106
|
+
}
|
|
90
107
|
}
|
|
91
108
|
//# sourceMappingURL=transaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/core/transaction.ts"],"names":[],"m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C;QACxC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,gDAAgD;IAChD,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,QAAQ;QACN,OAAO,eAAe,aAAa,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;IACnI,CAAC;IAED,wFAAwF;IACxF,CAAC,aAAa,CAAC;QACb,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF"}
|
package/dist/core/transport.d.ts
CHANGED
|
@@ -3,24 +3,55 @@ export interface FinTsTransport {
|
|
|
3
3
|
/**
|
|
4
4
|
* Posts `body` to `url` and returns the response body.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Once the client is closed, it aborts `signal` five seconds later, and that of the dialog ends it then sends five
|
|
7
|
+
* seconds after the request on its way, if any, is over: the client no longer waits for the answer then, and the
|
|
8
|
+
* transport should stop the request, since the dialog end may go out while it still runs.
|
|
9
|
+
*
|
|
10
|
+
* The client bounds neither the time of the exchange nor the size of the answer: do so in the transport, as
|
|
11
|
+
* `HttpTransport` does, so that a server that stops answering cannot hold up a call and one that sends without end
|
|
12
|
+
* cannot exhaust the memory.
|
|
13
|
+
*
|
|
14
|
+
* Implementations report failures as `FinTsTransportError`, with the HTTP status as `statusCode` where the bank
|
|
15
|
+
* answered with an HTTP error: an anonymous request for the bank parameter data that fails so goes out once more,
|
|
16
|
+
* without the announcement of strong authentication, which some banks fail on. Of any other error, another
|
|
17
|
+
* `FinTsError` included, the client keeps only its message and the reason its cause gives (its message, or else the
|
|
18
|
+
* messages of its errors or its code), as a `FinTsTransportError` without `statusCode`. `body` holds PIN and TAN in
|
|
19
|
+
* plain text: keep it out of error messages and logs.
|
|
7
20
|
*/
|
|
8
|
-
post(url: URL, body: Uint8Array, contentType: string): Promise<Uint8Array>;
|
|
21
|
+
post(url: URL, body: Uint8Array, contentType: string, signal: AbortSignal): Promise<Uint8Array>;
|
|
9
22
|
/** Releases the connection; the client calls it when it is closed. */
|
|
10
23
|
close(): void;
|
|
11
24
|
}
|
|
12
25
|
/** What `HttpTransport` takes; all optional. */
|
|
13
26
|
export interface HttpTransportOptions {
|
|
14
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* The `fetch` to send with, for example one with a proxy agent; the global `fetch` by default, as it is at each
|
|
29
|
+
* request.
|
|
30
|
+
*
|
|
31
|
+
* It must post to the URL it is given: an answer from another URL counts as a redirect, which fails the request. Of
|
|
32
|
+
* an answer whose `body` is no `ReadableStream`, as with node-fetch, the size can only be checked once it is read
|
|
33
|
+
* whole.
|
|
34
|
+
*/
|
|
15
35
|
fetch?: typeof fetch;
|
|
16
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Time for the whole exchange in milliseconds, from sending the request to the last byte of the response; 90 s. At
|
|
38
|
+
* most 2147483647 (about 24 days), the longest `setTimeout` waits.
|
|
39
|
+
*/
|
|
17
40
|
timeoutMs?: number;
|
|
18
|
-
/** Largest response accepted, so that a faulty server cannot exhaust the memory; 16 MiB. */
|
|
41
|
+
/** Largest response accepted in bytes, so that a faulty server cannot exhaust the memory; 16 MiB. */
|
|
19
42
|
maxResponseBytes?: number;
|
|
20
43
|
}
|
|
21
44
|
/**
|
|
22
45
|
* Default `FinTsTransport`: HTTP POST with `fetch`.
|
|
23
46
|
*
|
|
47
|
+
* Without the `fetch` option it sends with the global `fetch` as it is at each request, and cannot bypass what that
|
|
48
|
+
* does, for plain http to a local server (`FinTsConfig.allowInsecureUrl`) as for https: whatever replaces that `fetch`
|
|
49
|
+
* or handles its requests, such as a test's stub of `globalThis.fetch` or on Node.js a global dispatcher (undici's
|
|
50
|
+
* `setGlobalDispatcher`), gets every message, PIN and TAN included, and a proxy that the runtime takes from the
|
|
51
|
+
* environment, as Node.js does with `NODE_USE_ENV_PROXY=1`, and Deno and Bun do from `HTTP_PROXY`, sees the PIN of
|
|
52
|
+
* plain http unencrypted. Exempt the host with `NO_PROXY`, such as `localhost,127.0.0.1,::1`, or pass a `fetch` that
|
|
53
|
+
* connects directly.
|
|
54
|
+
*
|
|
24
55
|
* In a browser it only reaches servers that allow the page's origin (CORS), which bank servers do not: a web app needs
|
|
25
56
|
* a server of its own between browser and bank, reached with a `FinTsTransport` of its own.
|
|
26
57
|
*/
|
|
@@ -28,10 +59,21 @@ export declare class HttpTransport implements FinTsTransport {
|
|
|
28
59
|
readonly timeoutMs: number;
|
|
29
60
|
readonly maxResponseBytes: number;
|
|
30
61
|
private readonly fetchFn;
|
|
62
|
+
/**
|
|
63
|
+
* Throws `TypeError` if `timeoutMs` is not a positive number of at most 2147483647, or `maxResponseBytes` is not a
|
|
64
|
+
* positive number.
|
|
65
|
+
*/
|
|
31
66
|
constructor(options?: HttpTransportOptions);
|
|
32
|
-
|
|
67
|
+
/** Fails with `FinTsTransportError` at the timeout or once `signal` is aborted; sends nothing if it is already. */
|
|
68
|
+
post(url: URL, body: Uint8Array, contentType: string, signal?: AbortSignal): Promise<Uint8Array>;
|
|
33
69
|
private exchange;
|
|
34
70
|
private readBody;
|
|
71
|
+
private tooLarge;
|
|
35
72
|
close(): void;
|
|
36
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* The message of a failed request, with the reason its cause gives: Node.js reports `fetch failed` and the reason in the
|
|
76
|
+
* cause. Only messages and codes, since the error may hold the request, PIN and TAN included.
|
|
77
|
+
*/
|
|
78
|
+
export declare function failureMessage(error: unknown): string;
|
|
37
79
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/core/transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/core/transport.ts"],"names":[],"mappings":"AAIA,+GAA+G;AAC/G,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEhG,sEAAsE;IACtE,KAAK,IAAI,IAAI,CAAC;CACf;AAED,gDAAgD;AAChD,MAAM,WAAW,oBAAoB;IACnC;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qGAAqG;IACrG,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAKD;;;;;;;;;;;;;GAaG;AACH,qBAAa,aAAc,YAAW,cAAc;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IAEvC;;;OAGG;gBACS,OAAO,GAAE,oBAAyB;IAY9C,mHAAmH;IAC7G,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;YA2BxF,QAAQ;YAmCR,QAAQ;IAgCtB,OAAO,CAAC,QAAQ;IAIhB,KAAK,IAAI,IAAI;CAGd;AAsBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIrD"}
|