@coderoftime/fints 0.1.0 → 0.2.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 +142 -1
- package/README.md +127 -37
- package/dist/client.d.ts +48 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +199 -0
- package/dist/client.js.map +1 -0
- package/dist/core/account.d.ts +35 -7
- package/dist/core/account.d.ts.map +1 -1
- package/dist/core/account.js +84 -13
- package/dist/core/account.js.map +1 -1
- package/dist/core/amount.d.ts +2 -1
- package/dist/core/amount.d.ts.map +1 -1
- package/dist/core/amount.js +4 -1
- package/dist/core/amount.js.map +1 -1
- package/dist/core/balance.d.ts +1 -0
- package/dist/core/balance.d.ts.map +1 -1
- package/dist/core/balance.js +6 -5
- package/dist/core/balance.js.map +1 -1
- package/dist/core/bank-info.d.ts +1 -1
- package/dist/core/bank-info.js +1 -1
- package/dist/core/client.d.ts +50 -15
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/config.d.ts +28 -16
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +66 -26
- package/dist/core/config.js.map +1 -1
- package/dist/core/errors.d.ts +85 -23
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +112 -47
- package/dist/core/errors.js.map +1 -1
- package/dist/core/feedback.d.ts +4 -1
- package/dist/core/feedback.d.ts.map +1 -1
- package/dist/core/feedback.js +4 -1
- package/dist/core/feedback.js.map +1 -1
- package/dist/core/transaction.d.ts +6 -1
- package/dist/core/transaction.d.ts.map +1 -1
- package/dist/core/transaction.js +9 -4
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/transport.d.ts +33 -6
- package/dist/core/transport.d.ts.map +1 -1
- package/dist/core/transport.js +77 -20
- package/dist/core/transport.js.map +1 -1
- package/dist/formats/camt.d.ts +24 -4
- package/dist/formats/camt.d.ts.map +1 -1
- package/dist/formats/camt.js +124 -41
- package/dist/formats/camt.js.map +1 -1
- package/dist/formats/mt940.d.ts +15 -3
- package/dist/formats/mt940.d.ts.map +1 -1
- package/dist/formats/mt940.js +161 -82
- 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 +24 -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 +6 -0
- package/dist/formats/sepa-purpose.d.ts.map +1 -1
- package/dist/formats/sepa-purpose.js +23 -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 +7 -10
- package/dist/session/dialog-runner.d.ts.map +1 -1
- package/dist/session/dialog-runner.js +15 -16
- 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 +156 -84
- 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 +33 -25
- package/dist/session/session-setup.d.ts.map +1 -1
- package/dist/session/session-setup.js +87 -65
- package/dist/session/session-setup.js.map +1 -1
- package/dist/session/session-state.d.ts +9 -6
- package/dist/session/session-state.d.ts.map +1 -1
- package/dist/session/session-state.js +52 -17
- package/dist/session/session-state.js.map +1 -1
- package/dist/session/signed-dialog.d.ts +77 -0
- package/dist/session/signed-dialog.d.ts.map +1 -0
- package/dist/session/signed-dialog.js +170 -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 +8 -4
- package/dist/session/user-prompts.d.ts.map +1 -1
- package/dist/session/user-prompts.js +34 -14
- package/dist/session/user-prompts.js.map +1 -1
- package/dist/tan/challenge.d.ts +34 -13
- package/dist/tan/challenge.d.ts.map +1 -1
- package/dist/tan/challenge.js +25 -26
- package/dist/tan/challenge.js.map +1 -1
- package/dist/tan/flicker.d.ts +7 -1
- package/dist/tan/flicker.d.ts.map +1 -1
- package/dist/tan/flicker.js +40 -6
- package/dist/tan/flicker.js.map +1 -1
- package/dist/tan/tan-image.d.ts +3 -2
- package/dist/tan/tan-image.d.ts.map +1 -1
- package/dist/tan/tan-image.js +7 -5
- package/dist/tan/tan-image.js.map +1 -1
- package/dist/tan/tan-models.d.ts +5 -1
- package/dist/tan/tan-models.d.ts.map +1 -1
- package/dist/tan/tan-models.js +10 -5
- package/dist/tan/tan-models.js.map +1 -1
- package/dist/util/async.d.ts +0 -2
- package/dist/util/async.d.ts.map +1 -1
- package/dist/util/async.js +0 -4
- package/dist/util/async.js.map +1 -1
- package/dist/util/bytes.d.ts +2 -3
- package/dist/util/bytes.d.ts.map +1 -1
- package/dist/util/bytes.js +12 -20
- 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 +9 -16
- package/dist/util/dates.d.ts.map +1 -1
- package/dist/util/dates.js +39 -19
- package/dist/util/dates.js.map +1 -1
- package/dist/util/errors.d.ts +9 -1
- package/dist/util/errors.d.ts.map +1 -1
- package/dist/util/errors.js +12 -3
- package/dist/util/errors.js.map +1 -1
- 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 +21 -4
- package/dist/util/text.d.ts.map +1 -1
- package/dist/util/text.js +42 -13
- package/dist/util/text.js.map +1 -1
- package/dist/util/xml.d.ts +4 -3
- package/dist/util/xml.d.ts.map +1 -1
- package/dist/util/xml.js +37 -26
- 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 +34 -0
- package/dist/v3/bank-connection.d.ts.map +1 -0
- package/dist/v3/bank-connection.js +58 -0
- package/dist/v3/bank-connection.js.map +1 -0
- package/dist/v3/dialog.d.ts +80 -46
- package/dist/v3/dialog.d.ts.map +1 -1
- package/dist/v3/dialog.js +162 -59
- package/dist/v3/dialog.js.map +1 -1
- package/dist/v3/message.d.ts +17 -4
- package/dist/v3/message.d.ts.map +1 -1
- package/dist/v3/message.js +62 -18
- package/dist/v3/message.js.map +1 -1
- package/dist/v3/parameter-store.d.ts +75 -0
- package/dist/v3/parameter-store.d.ts.map +1 -0
- package/dist/v3/parameter-store.js +143 -0
- package/dist/v3/parameter-store.js.map +1 -0
- package/dist/v3/parameters.d.ts +38 -12
- package/dist/v3/parameters.d.ts.map +1 -1
- package/dist/v3/parameters.js +91 -37
- package/dist/v3/parameters.js.map +1 -1
- package/dist/v3/protocol.d.ts +43 -50
- package/dist/v3/protocol.d.ts.map +1 -1
- package/dist/v3/protocol.js +58 -208
- 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 +120 -0
- package/dist/v3/queries.js.map +1 -0
- package/dist/v3/segments.d.ts +29 -12
- package/dist/v3/segments.d.ts.map +1 -1
- package/dist/v3/segments.js +65 -23
- package/dist/v3/segments.js.map +1 -1
- package/dist/v3/syntax.d.ts +65 -14
- package/dist/v3/syntax.d.ts.map +1 -1
- package/dist/v3/syntax.js +167 -101
- package/dist/v3/syntax.js.map +1 -1
- package/package.json +10 -6
- package/src/client.ts +252 -0
- package/src/core/account.ts +86 -13
- package/src/core/amount.ts +3 -1
- package/src/core/balance.ts +6 -5
- package/src/core/bank-info.ts +1 -1
- package/src/core/client.ts +52 -15
- package/src/core/config.ts +69 -28
- package/src/core/errors.ts +122 -48
- package/src/core/feedback.ts +4 -1
- package/src/core/transaction.ts +9 -4
- package/src/core/transport.ts +98 -23
- package/src/formats/camt.ts +136 -39
- package/src/formats/mt940.ts +167 -81
- package/src/formats/readers.ts +24 -31
- package/src/formats/record-budget.ts +18 -0
- package/src/formats/sepa-purpose.ts +21 -2
- package/src/index.ts +4 -2
- package/src/session/app-approval.ts +51 -38
- package/src/session/dialog-runner.ts +31 -28
- package/src/session/login-guard.ts +174 -88
- package/src/session/sepa-accounts.ts +63 -45
- package/src/session/session-setup.ts +90 -71
- package/src/session/session-state.ts +56 -22
- package/src/session/signed-dialog.ts +192 -0
- package/src/session/tan-selection.ts +50 -39
- package/src/session/user-prompts.ts +35 -16
- package/src/tan/challenge.ts +40 -31
- package/src/tan/flicker.ts +44 -6
- package/src/tan/tan-image.ts +7 -5
- package/src/tan/tan-models.ts +10 -5
- package/src/util/async.ts +0 -5
- package/src/util/bytes.ts +13 -19
- package/src/util/call-context.ts +3 -2
- package/src/util/dates.ts +41 -24
- package/src/util/errors.ts +14 -3
- package/src/util/json.ts +16 -0
- package/src/util/text.ts +42 -12
- package/src/util/xml.ts +37 -26
- package/src/v3/account-extension.ts +7 -12
- package/src/v3/bank-connection.ts +67 -0
- package/src/v3/dialog.ts +175 -91
- package/src/v3/message.ts +69 -17
- package/src/v3/parameter-store.ts +160 -0
- package/src/v3/parameters.ts +110 -37
- package/src/v3/protocol.ts +70 -253
- package/src/v3/queries.ts +190 -0
- package/src/v3/segments.ts +65 -22
- package/src/v3/syntax.ts +153 -91
- 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
|
@@ -1,109 +1,181 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { clientClosedError, FinTsLoginDataChangedError, FinTsLoginRefusedError, FinTsPinError, loginRefusalFor, } from '../core/errors.js';
|
|
2
2
|
import { allowedTanMethodsIn, FeedbackCodes, hasCode } from '../core/feedback.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* PIN
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* then the error concerns the order.
|
|
12
|
-
*
|
|
13
|
-
* Errors in the answer to an order or an approval are no refusal, such as a wrong TAN at login: the bank checks the PIN
|
|
14
|
-
* before it asks for the approval. New login data (return code 3072) end the old ones for good (`refuse`).
|
|
4
|
+
* Logins in a row whose answer the client could not read, after which it sends the PIN no more: one may be a glitch of
|
|
5
|
+
* the connection, but with two the client would not learn of a wrong PIN before the bank locks the access.
|
|
6
|
+
*/
|
|
7
|
+
const maxUnreadLogins = 2;
|
|
8
|
+
/**
|
|
9
|
+
* Holds the PIN and hands it out only while no login is refused (`pin`), so that a retrying app cannot lock the user's
|
|
10
|
+
* access. `FinTsLoginRefusedError` tells which logins count as refused; `judge` decides it for each answer.
|
|
15
11
|
*
|
|
16
|
-
*
|
|
17
|
-
* session has taken care of a
|
|
18
|
-
*
|
|
12
|
+
* A refusal counts at once and fails closed: only `remedied` lifts it, within the call that met it (`runCall`), once
|
|
13
|
+
* the session has taken care of a reason it names, each reason once per call, so that a call sends at most three
|
|
14
|
+
* logins the bank refuses. A refusal that outlasts the call is final, and the guard forgets the PIN; only a PIN the
|
|
15
|
+
* user enters anew lifts it (`replacePin`), unless it brings new login data.
|
|
19
16
|
*/
|
|
20
17
|
export class LoginGuard {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
18
|
+
// ECMAScript private, so that neither `util.inspect` nor `JSON.stringify` of the client reaches it.
|
|
19
|
+
#pin;
|
|
20
|
+
refusalValue;
|
|
21
|
+
/** The TAN method of the login `refusalValue` refused, which a restored refusal does not tell. */
|
|
22
|
+
refusedMethod;
|
|
23
|
+
/** Logins sent since the bank last took the PIN whose answer the client has not read. */
|
|
24
|
+
unreadLogins = 0;
|
|
25
|
+
/** The refusal of `maxUnreadLogins` unread logins, kept so that `check` throws the same error each time. */
|
|
26
|
+
unreadLoginsRefusal;
|
|
27
|
+
/** The reasons `remedied` has lifted a refusal for in the running call. */
|
|
28
|
+
pardonedReasons = new Set();
|
|
29
|
+
constructor(pin) {
|
|
30
|
+
this.#pin = pin;
|
|
31
|
+
}
|
|
32
|
+
/** The PIN to sign a message with; throws the refusal instead (`check`), and `FinTsStateError` once closed. */
|
|
33
|
+
get pin() {
|
|
34
|
+
this.check();
|
|
35
|
+
if (this.#pin === undefined)
|
|
36
|
+
throw clientClosedError();
|
|
37
|
+
return this.#pin;
|
|
38
|
+
}
|
|
39
|
+
/** Throws the refusal, if there is one. */
|
|
25
40
|
check() {
|
|
26
|
-
|
|
27
|
-
|
|
41
|
+
const refusal = this.refusal;
|
|
42
|
+
if (refusal !== undefined)
|
|
43
|
+
throw refusal;
|
|
28
44
|
}
|
|
29
|
-
/**
|
|
30
|
-
get
|
|
31
|
-
|
|
45
|
+
/** The bank's refusal, else that of `maxUnreadLogins` unread logins; `undefined` while there is none. */
|
|
46
|
+
get refusal() {
|
|
47
|
+
if (this.refusalValue !== undefined || this.unreadLogins < maxUnreadLogins)
|
|
48
|
+
return this.refusalValue;
|
|
49
|
+
this.unreadLoginsRefusal ??= new FinTsLoginRefusedError([], `The answers to the last ${maxUnreadLogins} logins were lost or unreadable, and the bank may have counted them ` +
|
|
50
|
+
'as failed attempts');
|
|
51
|
+
return this.unreadLoginsRefusal;
|
|
32
52
|
}
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
53
|
+
/** Counts a login signed with the PIN as unread until `judge` reads its answer. */
|
|
54
|
+
loginSent() {
|
|
55
|
+
this.unreadLogins++;
|
|
36
56
|
}
|
|
37
57
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* `dialogOpen` tells whether the bank keeps the dialog open after its answer.
|
|
58
|
+
* Judges `error`, if the answer to a request of `kind` in a dialog signed with `method` has one: returns the refusal
|
|
59
|
+
* of the login it amounts to, and records it unless the guard holds one already. Any error refuses a login; after the
|
|
60
|
+
* login only one that refuses it itself, a rejected PIN or new login data, since the bank checked the PIN before.
|
|
42
61
|
*/
|
|
43
|
-
judge(error, kind,
|
|
44
|
-
const refused = error instanceof
|
|
45
|
-
if (
|
|
46
|
-
this.
|
|
47
|
-
|
|
62
|
+
judge(error, kind, method) {
|
|
63
|
+
const refused = error instanceof FinTsLoginRefusedError || (error !== undefined && kind === 'login');
|
|
64
|
+
if (kind === 'login')
|
|
65
|
+
this.unreadLogins = refused ? Math.max(0, this.unreadLogins - 1) : 0;
|
|
66
|
+
if (!refused)
|
|
67
|
+
return undefined;
|
|
68
|
+
const refusal = loginRefusalFor(error.feedback);
|
|
69
|
+
if (this.refusalValue === undefined) {
|
|
70
|
+
this.refusalValue = refusal;
|
|
71
|
+
this.refusedMethod = method;
|
|
48
72
|
}
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
/** Records `error` as the reason the client logs in no more, unless it holds a refusal already. */
|
|
52
|
-
refuse(error) {
|
|
53
|
-
this.refusal ??= error;
|
|
73
|
+
return refusal;
|
|
54
74
|
}
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
* that the caller carries on without it.
|
|
58
|
-
*
|
|
59
|
-
* A refused login is thrown, and so is a wrong TAN, which the user must hear of. An aborted dialog counts as a
|
|
60
|
-
* rejection: banks end the dialog along with many.
|
|
61
|
-
*/
|
|
62
|
-
async tryLookUp(lookup) {
|
|
75
|
+
/** Runs `call`, one call of the client; a refusal that outlasts it is final, and the next call remedies anew. */
|
|
76
|
+
async runCall(call) {
|
|
63
77
|
try {
|
|
64
|
-
return await
|
|
78
|
+
return await call();
|
|
65
79
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return undefined;
|
|
80
|
+
finally {
|
|
81
|
+
this.pardonedReasons.clear();
|
|
82
|
+
this.forgetPinIfRefused();
|
|
70
83
|
}
|
|
71
84
|
}
|
|
72
85
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* login data.
|
|
76
|
-
*
|
|
77
|
-
* Only the return codes of the refusal itself count: TAN methods listed earlier say nothing about this login.
|
|
86
|
+
* Runs `attempt`, which may log in, and runs it once more each time `remedy` takes care of a reason the refusal it
|
|
87
|
+
* failed with names; `remedy` gets the reason and the TAN method of the refused login, and returns whether it could.
|
|
78
88
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
async remedied(attempt, remedy) {
|
|
90
|
+
// A refusal of an earlier call stops the attempt before it sends the PIN; there is nothing to remedy.
|
|
91
|
+
if (this.refusal !== undefined)
|
|
92
|
+
return attempt();
|
|
93
|
+
for (;;) {
|
|
94
|
+
try {
|
|
95
|
+
return await attempt();
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
const refusal = this.refusalValue;
|
|
99
|
+
const rejected = this.refusedMethod;
|
|
100
|
+
// Only the bank's refusal the guard holds names reasons; any other error, a second refusal too, fails the call.
|
|
101
|
+
if (refusal === undefined || error !== refusal || rejected === undefined)
|
|
102
|
+
throw error;
|
|
103
|
+
const reason = remediableReasons(refusal, rejected).find((r) => !this.pardonedReasons.has(r));
|
|
104
|
+
if (reason === undefined || !(await remedy(reason, rejected)))
|
|
105
|
+
throw error;
|
|
106
|
+
this.pardonedReasons.add(reason);
|
|
107
|
+
// A closed client keeps the refusal.
|
|
108
|
+
if (this.#pin !== undefined)
|
|
109
|
+
this.liftRefusal();
|
|
110
|
+
}
|
|
93
111
|
}
|
|
94
|
-
if (hasCode(feedback, FeedbackCodes.newSystemIdRequired))
|
|
95
|
-
reasons.push('systemIdRejected');
|
|
96
|
-
return reasons;
|
|
97
112
|
}
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.
|
|
113
|
+
/**
|
|
114
|
+
* Signs with `pin` from now on, a PIN the user has entered anew and the protocol can send, and lifts the refusal.
|
|
115
|
+
* Throws the refusal instead where it brings new login data, which end the old ones for good.
|
|
116
|
+
*/
|
|
117
|
+
replacePin(pin) {
|
|
118
|
+
if (this.refusalValue instanceof FinTsLoginDataChangedError)
|
|
119
|
+
throw this.refusalValue;
|
|
120
|
+
this.#pin = pin;
|
|
121
|
+
this.liftRefusal();
|
|
122
|
+
this.unreadLogins = 0;
|
|
123
|
+
this.unreadLoginsRefusal = undefined;
|
|
124
|
+
}
|
|
125
|
+
/** Forgets the PIN; the client calls it once it is closed. */
|
|
126
|
+
close() {
|
|
127
|
+
this.#pin = undefined;
|
|
128
|
+
}
|
|
129
|
+
saveState() {
|
|
130
|
+
return { refusal: this.refusalValue?.feedback, unreadLogins: this.unreadLogins };
|
|
104
131
|
}
|
|
105
|
-
|
|
106
|
-
|
|
132
|
+
/** Restores what `saveState` returned; a restored refusal is final. */
|
|
133
|
+
restoreState(saved) {
|
|
134
|
+
if (saved.refusal !== undefined)
|
|
135
|
+
this.refusalValue = loginRefusalFor(saved.refusal);
|
|
136
|
+
this.unreadLogins = Math.max(0, saved.unreadLogins);
|
|
137
|
+
this.forgetPinIfRefused();
|
|
138
|
+
}
|
|
139
|
+
liftRefusal() {
|
|
140
|
+
this.refusalValue = undefined;
|
|
141
|
+
this.refusedMethod = undefined;
|
|
142
|
+
}
|
|
143
|
+
forgetPinIfRefused() {
|
|
144
|
+
if (this.refusal !== undefined)
|
|
145
|
+
this.#pin = undefined;
|
|
107
146
|
}
|
|
108
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* The reasons `refusal`, of a login signed with `method`, names that the session can take care of: a TAN method the
|
|
150
|
+
* refusal names as not allowed (`refusesMethod`), and 9391. None for a rejected PIN or new login data.
|
|
151
|
+
*/
|
|
152
|
+
function remediableReasons(refusal, method) {
|
|
153
|
+
if (refusal instanceof FinTsPinError || refusal instanceof FinTsLoginDataChangedError)
|
|
154
|
+
return [];
|
|
155
|
+
const reasons = [];
|
|
156
|
+
if (refusesMethod(refusal.feedback, method))
|
|
157
|
+
reasons.push('tanMethodNotAllowed');
|
|
158
|
+
if (hasCode(refusal.feedback, FeedbackCodes.newSystemIdRequired))
|
|
159
|
+
reasons.push('systemIdRejected');
|
|
160
|
+
return reasons;
|
|
161
|
+
}
|
|
162
|
+
/** Error codes that only say that the message failed, not why: 9050 (the message contains errors) and 9800. */
|
|
163
|
+
const unspecificErrors = new Set(['9050', FeedbackCodes.dialogAborted]);
|
|
164
|
+
/**
|
|
165
|
+
* Whether `feedback`, which refuses a login signed with `method`, names the method as the reason: a 3920 that lists the
|
|
166
|
+
* methods the user may use without it, or 9075 after the one-step method.
|
|
167
|
+
*
|
|
168
|
+
* Only the return codes of the refusal itself count: TAN methods listed earlier say nothing about this login. Banks
|
|
169
|
+
* list two-step methods only, so a 3920 always leaves the one-step method out, also where the login succeeds. After
|
|
170
|
+
* the one-step method a 3920 counts only where the bank names no other error than an unspecific one: any other, such
|
|
171
|
+
* as "Anmeldung fehlgeschlagen", may be about the PIN.
|
|
172
|
+
*/
|
|
173
|
+
function refusesMethod(feedback, method) {
|
|
174
|
+
if (method.isOneStep && hasCode(feedback, FeedbackCodes.scaRequired))
|
|
175
|
+
return true;
|
|
176
|
+
const allowed = allowedTanMethodsIn(feedback);
|
|
177
|
+
if (allowed.length === 0 || allowed.includes(method.securityFunction))
|
|
178
|
+
return false;
|
|
179
|
+
return !method.isOneStep || feedback.every((f) => !f.isError || unspecificErrors.has(f.code));
|
|
180
|
+
}
|
|
109
181
|
//# sourceMappingURL=login-guard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-guard.js","sourceRoot":"","sources":["../../src/session/login-guard.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"login-guard.js","sourceRoot":"","sources":["../../src/session/login-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EA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OAAO,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,gBAAgB,CAAC;QAAE,OAAO,KAAK,CAAC;IACpF,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAChG,CAAC"}
|
|
@@ -1,32 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Account } from '../core/account.js';
|
|
2
|
+
import type { ParameterStore } from '../v3/parameter-store.js';
|
|
2
3
|
import type { DialogRunner } from './dialog-runner.js';
|
|
3
|
-
import type { LoginGuard } from './login-guard.js';
|
|
4
|
-
import type { BankResponse, PinTanProtocol } from './protocol.js';
|
|
5
4
|
import type { SessionState } from './session-state.js';
|
|
6
5
|
/**
|
|
7
6
|
* IBAN and BIC of the user's accounts, from the bank's SEPA account list where the user parameter data lack them
|
|
8
|
-
* (Formals F.3.4).
|
|
7
|
+
* (Formals F.3.4), and the accounts the app passes completed from both.
|
|
9
8
|
*
|
|
10
9
|
* The list is read once per version of the user parameter data and kept in the saved state. Under version 0, which
|
|
11
|
-
* holds for one dialog only (Formals E.2), without user parameter data, or where the bank rejects the list,
|
|
12
|
-
*
|
|
10
|
+
* holds for one dialog only (Formals E.2), without user parameter data, or where the bank rejects the list, also by
|
|
11
|
+
* ending the dialog, or names no account in it, it is kept for this client only: an empty list completes nothing, and
|
|
12
|
+
* saved it would outlast a fault of a single answer until the bank changes its user parameter data.
|
|
13
13
|
*/
|
|
14
|
-
export declare class SepaAccounts
|
|
15
|
-
private readonly
|
|
14
|
+
export declare class SepaAccounts {
|
|
15
|
+
private readonly parameters;
|
|
16
16
|
private readonly state;
|
|
17
17
|
private readonly dialogs;
|
|
18
|
-
private readonly guard;
|
|
19
18
|
/**
|
|
20
19
|
* The list this client keeps unsaved, with the version of the user parameter data it was read under; empty where the
|
|
21
|
-
* bank rejected it.
|
|
20
|
+
* bank rejected it or named no account.
|
|
22
21
|
*/
|
|
23
22
|
private unsaved;
|
|
24
|
-
|
|
25
|
-
private abortSkipped;
|
|
26
|
-
constructor(protocol: PinTanProtocol<R, O>, state: SessionState, dialogs: DialogRunner<R, O>, guard: LoginGuard);
|
|
23
|
+
constructor(parameters: ParameterStore, state: SessionState, dialogs: DialogRunner);
|
|
27
24
|
/** The accounts of the user parameter data completed with IBAN and BIC, then the accounts only the list names. */
|
|
28
25
|
completedAccounts(): Promise<Account[]>;
|
|
29
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* `account` as the bank knows it: the one of `completedAccounts` it matches, with what the bank states of it first,
|
|
28
|
+
* so that an account the app has built itself, such as from an IBAN alone, goes out with the account number, the
|
|
29
|
+
* sub-account and the BIC the bank's orders take, and the currency of its statements. Where the bank names none it
|
|
30
|
+
* matches, only what identifies `account`, and its currency: the rest, such as the transactions it permits, only the
|
|
31
|
+
* bank can state.
|
|
32
|
+
*
|
|
33
|
+
* Throws `FinTsUnsupportedError` for such an account where the user parameter data list all permitted transactions:
|
|
34
|
+
* they permit nothing for an account they leave out, and the client cannot tell it from a mistyped one.
|
|
35
|
+
*/
|
|
30
36
|
complete(account: Account): Promise<Account>;
|
|
31
37
|
/** The list, read in the session's dialog, whose start delivers the user parameter data it is cached for. */
|
|
32
38
|
private list;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sepa-accounts.d.ts","sourceRoot":"","sources":["../../src/session/sepa-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sepa-accounts.d.ts","sourceRoot":"","sources":["../../src/session/sepa-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAgB,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;GAQG;AACH,qBAAa,YAAY;IAQrB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAT1B;;;OAGG;IACH,OAAO,CAAC,OAAO,CAA+E;gBAG3E,UAAU,EAAE,cAAc,EAC1B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,YAAY;IAGxC,kHAAkH;IAC5G,iBAAiB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAW7C;;;;;;;;;OASG;IACG,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IA2BlD,6GAA6G;YAC/F,IAAI;CA0BnB"}
|
|
@@ -1,49 +1,80 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Account, AccountIndex } from '../core/account.js';
|
|
2
|
+
import { FinTsUnsupportedError, tryLookUp } from '../core/errors.js';
|
|
3
|
+
import { sepaAccountsQuery } from '../v3/queries.js';
|
|
2
4
|
/**
|
|
3
5
|
* IBAN and BIC of the user's accounts, from the bank's SEPA account list where the user parameter data lack them
|
|
4
|
-
* (Formals F.3.4).
|
|
6
|
+
* (Formals F.3.4), and the accounts the app passes completed from both.
|
|
5
7
|
*
|
|
6
8
|
* The list is read once per version of the user parameter data and kept in the saved state. Under version 0, which
|
|
7
|
-
* holds for one dialog only (Formals E.2), without user parameter data, or where the bank rejects the list,
|
|
8
|
-
*
|
|
9
|
+
* holds for one dialog only (Formals E.2), without user parameter data, or where the bank rejects the list, also by
|
|
10
|
+
* ending the dialog, or names no account in it, it is kept for this client only: an empty list completes nothing, and
|
|
11
|
+
* saved it would outlast a fault of a single answer until the bank changes its user parameter data.
|
|
9
12
|
*/
|
|
10
13
|
export class SepaAccounts {
|
|
11
|
-
|
|
14
|
+
parameters;
|
|
12
15
|
state;
|
|
13
16
|
dialogs;
|
|
14
|
-
guard;
|
|
15
17
|
/**
|
|
16
18
|
* The list this client keeps unsaved, with the version of the user parameter data it was read under; empty where the
|
|
17
|
-
* bank rejected it.
|
|
19
|
+
* bank rejected it or named no account.
|
|
18
20
|
*/
|
|
19
21
|
unsaved;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
constructor(protocol, state, dialogs, guard) {
|
|
23
|
-
this.protocol = protocol;
|
|
22
|
+
constructor(parameters, state, dialogs) {
|
|
23
|
+
this.parameters = parameters;
|
|
24
24
|
this.state = state;
|
|
25
25
|
this.dialogs = dialogs;
|
|
26
|
-
this.guard = guard;
|
|
27
26
|
}
|
|
28
27
|
/** The accounts of the user parameter data completed with IBAN and BIC, then the accounts only the list names. */
|
|
29
28
|
async completedAccounts() {
|
|
30
29
|
const sepa = await this.list();
|
|
31
|
-
const accounts = this.
|
|
30
|
+
const accounts = this.parameters.userParameters?.accounts ?? [];
|
|
31
|
+
const listed = new AccountIndex(sepa);
|
|
32
|
+
const known = new AccountIndex(accounts);
|
|
32
33
|
return [
|
|
33
|
-
...accounts.map((account) => withSepaDetails(account,
|
|
34
|
-
...sepa.filter((s) =>
|
|
34
|
+
...accounts.map((account) => withSepaDetails(account, listed.find(account))),
|
|
35
|
+
...sepa.filter((s) => known.find(s) === undefined),
|
|
35
36
|
];
|
|
36
37
|
}
|
|
37
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* `account` as the bank knows it: the one of `completedAccounts` it matches, with what the bank states of it first,
|
|
40
|
+
* so that an account the app has built itself, such as from an IBAN alone, goes out with the account number, the
|
|
41
|
+
* sub-account and the BIC the bank's orders take, and the currency of its statements. Where the bank names none it
|
|
42
|
+
* matches, only what identifies `account`, and its currency: the rest, such as the transactions it permits, only the
|
|
43
|
+
* bank can state.
|
|
44
|
+
*
|
|
45
|
+
* Throws `FinTsUnsupportedError` for such an account where the user parameter data list all permitted transactions:
|
|
46
|
+
* they permit nothing for an account they leave out, and the client cannot tell it from a mistyped one.
|
|
47
|
+
*/
|
|
38
48
|
async complete(account) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
const known = (await this.completedAccounts()).find((a) => account.matches(a));
|
|
50
|
+
if (known !== undefined) {
|
|
51
|
+
// A sub-account belongs to the account number it comes with.
|
|
52
|
+
const national = known.accountNumber === undefined ? account : known;
|
|
53
|
+
return known.copyWith({
|
|
54
|
+
accountNumber: national.accountNumber,
|
|
55
|
+
subAccount: national.subAccount,
|
|
56
|
+
iban: known.iban ?? account.iban,
|
|
57
|
+
bic: known.bic ?? account.bic,
|
|
58
|
+
currency: known.currency ?? account.currency,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (this.parameters.userParameters?.listsAllTransactions === true) {
|
|
62
|
+
throw new FinTsUnsupportedError("The bank does not name this account among the user's, and so permits nothing");
|
|
63
|
+
}
|
|
64
|
+
return new Account({
|
|
65
|
+
accountNumber: account.accountNumber,
|
|
66
|
+
subAccount: account.subAccount,
|
|
67
|
+
bankCode: account.bankCode,
|
|
68
|
+
countryCode: account.countryCode,
|
|
69
|
+
iban: account.iban,
|
|
70
|
+
bic: account.bic,
|
|
71
|
+
currency: account.currency,
|
|
72
|
+
});
|
|
42
73
|
}
|
|
43
74
|
/** The list, read in the session's dialog, whose start delivers the user parameter data it is cached for. */
|
|
44
75
|
async list() {
|
|
45
76
|
await this.dialogs.open();
|
|
46
|
-
const upd = this.
|
|
77
|
+
const upd = this.parameters.userParameters;
|
|
47
78
|
if (upd !== undefined &&
|
|
48
79
|
upd.accounts.length > 0 &&
|
|
49
80
|
upd.accounts.every((a) => a.iban !== undefined && a.bic !== undefined)) {
|
|
@@ -55,29 +86,13 @@ export class SepaAccounts {
|
|
|
55
86
|
return saved;
|
|
56
87
|
if (this.unsaved !== undefined && this.unsaved.updVersion === updVersion)
|
|
57
88
|
return this.unsaved.accounts;
|
|
58
|
-
const query = this.
|
|
89
|
+
const query = sepaAccountsQuery(this.parameters);
|
|
59
90
|
if (query === undefined)
|
|
60
91
|
return [];
|
|
61
|
-
// Where the bank rejects the list, the accounts stay as the user parameter data state
|
|
62
|
-
|
|
63
|
-
const accounts = await this.
|
|
64
|
-
|
|
65
|
-
return await this.dialogs.query(() => query);
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
if (error instanceof FinTsDialogAbortedError)
|
|
69
|
-
outcome.aborted = true;
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
if (outcome.aborted && !this.abortSkipped) {
|
|
74
|
-
// The bank may have ended the dialog for a reason of its own, such as a timeout, so this call goes on without the
|
|
75
|
-
// list and the next one asks again in its new dialog. Only once: banks also end the dialog when they reject the
|
|
76
|
-
// list, and each time costs the next call a login.
|
|
77
|
-
this.abortSkipped = true;
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
80
|
-
if (accounts !== undefined && updVersion !== undefined && updVersion > 0) {
|
|
92
|
+
// Where the bank rejects the list, also by ending the dialog, the accounts stay as the user parameter data state
|
|
93
|
+
// them: asked again, a bank that ends the dialog in answer would cost each call a login.
|
|
94
|
+
const accounts = await tryLookUp(() => this.dialogs.query(() => query));
|
|
95
|
+
if (accounts !== undefined && accounts.length > 0 && updVersion !== undefined && updVersion > 0) {
|
|
81
96
|
this.state.cacheSepaAccounts(accounts, updVersion);
|
|
82
97
|
}
|
|
83
98
|
else {
|
|
@@ -86,11 +101,12 @@ export class SepaAccounts {
|
|
|
86
101
|
return accounts ?? [];
|
|
87
102
|
}
|
|
88
103
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
/**
|
|
105
|
+
* A copy of `account`, which shares no date with the user parameter data, with the IBAN and BIC of `match`, its entry
|
|
106
|
+
* in the SEPA account list, if any.
|
|
107
|
+
*/
|
|
108
|
+
function withSepaDetails(account, match) {
|
|
93
109
|
// A BIC of the list takes precedence over the one of the user parameter data (Formals E.3.1.1, "BIC").
|
|
94
|
-
return account.copyWith({ iban: account.iban ?? match
|
|
110
|
+
return account.copyWith({ iban: account.iban ?? match?.iban, bic: match?.bic ?? account.bic });
|
|
95
111
|
}
|
|
96
112
|
//# sourceMappingURL=sepa-accounts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sepa-accounts.js","sourceRoot":"","sources":["../../src/session/sepa-accounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sepa-accounts.js","sourceRoot":"","sources":["../../src/session/sepa-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrD;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;IAQJ;IACA;IACA;IATnB;;;OAGG;IACK,OAAO,CAA+E;IAE9F,YACmB,UAA0B,EAC1B,KAAmB,EACnB,OAAqB;QAFrB,eAAU,GAAV,UAAU,CAAgB;QAC1B,UAAK,GAAL,KAAK,CAAc;QACnB,YAAO,GAAP,OAAO,CAAc;IACrC,CAAC;IAEJ,kHAAkH;IAClH,KAAK,CAAC,iBAAiB;QACrB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,QAAQ,IAAI,EAAE,CAAC;QAChE,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;QACzC,OAAO;YACL,GAAG,QAAQ,CAAC,GAAG,CAAC,CA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AAC;QACxE,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;YAChG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACrD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,IAAI,EAAE,EAAE,CAAC;QAC1D,CAAC;QACD,OAAO,QAAQ,IAAI,EAAE,CAAC;IACxB,CAAC;CACF;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,OAAgB,EAAE,KAA0B;IACnE,uGAAuG;IACvG,OAAO,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AACjG,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { BankInfo } from '../core/bank-info.js';
|
|
2
|
-
import type { TanMethod } from '../tan/tan-models.js';
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
5
|
-
import type { ResponseHandler } from './response-handler.js';
|
|
2
|
+
import type { TanMedium, TanMethod } from '../tan/tan-models.js';
|
|
3
|
+
import type { FinTs3Protocol } from '../v3/protocol.js';
|
|
4
|
+
import { SignedDialog, type SessionParts } from './signed-dialog.js';
|
|
6
5
|
import type { TanSelection } from './tan-selection.js';
|
|
7
6
|
/**
|
|
8
7
|
* What has to be settled before a login: the bank parameter data, the synchronization, and through `TanSelection` the
|
|
@@ -10,14 +9,11 @@ import type { TanSelection } from './tan-selection.js';
|
|
|
10
9
|
*
|
|
11
10
|
* Where the bank refuses a login for a reason the session can take care of, `remedied` does so and logs in again.
|
|
12
11
|
*/
|
|
13
|
-
export declare class SessionSetup
|
|
12
|
+
export declare class SessionSetup {
|
|
13
|
+
private readonly session;
|
|
14
14
|
private readonly protocol;
|
|
15
|
-
private readonly responses;
|
|
16
15
|
private readonly tans;
|
|
17
|
-
|
|
18
|
-
/** Whether a synchronization dialog ran, so that a helpful one runs once only. */
|
|
19
|
-
private synchronizationTried;
|
|
20
|
-
constructor(protocol: PinTanProtocol<R, O>, responses: ResponseHandler<R>, tans: TanSelection<R, O>, guard: LoginGuard);
|
|
16
|
+
constructor(session: SessionParts, protocol: FinTs3Protocol, tans: TanSelection);
|
|
21
17
|
/**
|
|
22
18
|
* The bank's general information: from an anonymous dialog where the bank answers one, else from the synchronization.
|
|
23
19
|
* No TAN method or medium is chosen for it.
|
|
@@ -25,21 +21,19 @@ export declare class SessionSetup<R extends BankResponse, O> {
|
|
|
25
21
|
bankInfo(): Promise<BankInfo>;
|
|
26
22
|
/** The TAN methods the bank allows for this user, which the synchronization reports. */
|
|
27
23
|
methods(): Promise<TanMethod[]>;
|
|
28
|
-
/** Settles what is still open: the bank parameter data, the synchronization, the TAN method and medium. */
|
|
29
|
-
prepare(): Promise<void>;
|
|
30
|
-
/** A new dialog signed with the TAN method and medium in use, once `prepare` has settled them. */
|
|
31
|
-
newDialog(): Promise<ProtocolDialog<R, O>>;
|
|
32
24
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* | Refusal (`LoginGuard.remediableReasons`) | Remedy |
|
|
37
|
-
* | --- | --- |
|
|
38
|
-
* | 3920 without the method, or 9075 after the one-step method | another allowed method (`TanSelection.replace`) |
|
|
39
|
-
* | 9391 | a new synchronization, which issues a customer system ID |
|
|
25
|
+
* Settles what is still open: the bank parameter data, the synchronization, the TAN method and medium. Returns the TAN
|
|
26
|
+
* media it looked up to choose the medium; `undefined` where it looked up none, or the bank listed none.
|
|
40
27
|
*/
|
|
28
|
+
prepare(): Promise<TanMedium[] | undefined>;
|
|
29
|
+
/** A new dialog signed with the TAN method and medium in use, once `prepare` has settled them. */
|
|
30
|
+
newDialog(): Promise<SignedDialog>;
|
|
31
|
+
/** Runs `attempt`, which may log in, once more after each refused login `remedy` takes care of. */
|
|
41
32
|
remedied<T>(attempt: () => Promise<T>): Promise<T>;
|
|
42
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Takes care of `reason`, given for refusing a login signed with `rejected`, with another TAN method or a new
|
|
35
|
+
* synchronization; returns whether it could.
|
|
36
|
+
*/
|
|
43
37
|
private remedy;
|
|
44
38
|
/**
|
|
45
39
|
* Loads the bank parameter data if they are missing, then synchronizes if that is due.
|
|
@@ -52,11 +46,25 @@ export declare class SessionSetup<R extends BankResponse, O> {
|
|
|
52
46
|
*/
|
|
53
47
|
private loadParameters;
|
|
54
48
|
/**
|
|
55
|
-
* Asks for the bank parameter data without logging in
|
|
56
|
-
*
|
|
49
|
+
* Asks for the bank parameter data without logging in, keeps them where there are none from a dialog signed with the
|
|
50
|
+
* PIN (`ParameterStore.keepAnonymous`), and passes the bank's messages on: all an anonymous dialog tells, since the
|
|
51
|
+
* TAN methods it lists are not those of a user. A bank that does not answer anonymously is no error, but a failed
|
|
52
|
+
* connection is: the synchronization would only wait for the same server again.
|
|
57
53
|
*/
|
|
58
54
|
private fetchBankParametersAnonymously;
|
|
59
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Asks for the bank parameter data in an anonymous dialog that announces strong customer authentication; a bank that
|
|
57
|
+
* rejects the announcement, with a return code or by failing on it, is asked again without it.
|
|
58
|
+
*
|
|
59
|
+
* A timeout or a broken connection is not a reason to ask again: it would only double the wait.
|
|
60
|
+
*/
|
|
61
|
+
private requestBankParametersAnonymously;
|
|
62
|
+
private anonymousDialog;
|
|
63
|
+
/**
|
|
64
|
+
* Runs the synchronization, a login in a dialog of its own, while there is no customer system ID, without which no
|
|
65
|
+
* regular dialog starts. It runs before the TAN method and medium are settled (`TanSelection.synchronizationDialog`
|
|
66
|
+
* tells which method signs it).
|
|
67
|
+
*/
|
|
60
68
|
private synchronizeIfDue;
|
|
61
69
|
/**
|
|
62
70
|
* The TAN media of the method in use; `undefined` if the bank does not list them or rejects the list, after which the
|