@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.
Files changed (272) hide show
  1. package/CHANGELOG.md +142 -1
  2. package/README.md +127 -37
  3. package/dist/client.d.ts +48 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +199 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/core/account.d.ts +35 -7
  8. package/dist/core/account.d.ts.map +1 -1
  9. package/dist/core/account.js +84 -13
  10. package/dist/core/account.js.map +1 -1
  11. package/dist/core/amount.d.ts +2 -1
  12. package/dist/core/amount.d.ts.map +1 -1
  13. package/dist/core/amount.js +4 -1
  14. package/dist/core/amount.js.map +1 -1
  15. package/dist/core/balance.d.ts +1 -0
  16. package/dist/core/balance.d.ts.map +1 -1
  17. package/dist/core/balance.js +6 -5
  18. package/dist/core/balance.js.map +1 -1
  19. package/dist/core/bank-info.d.ts +1 -1
  20. package/dist/core/bank-info.js +1 -1
  21. package/dist/core/client.d.ts +50 -15
  22. package/dist/core/client.d.ts.map +1 -1
  23. package/dist/core/config.d.ts +28 -16
  24. package/dist/core/config.d.ts.map +1 -1
  25. package/dist/core/config.js +66 -26
  26. package/dist/core/config.js.map +1 -1
  27. package/dist/core/errors.d.ts +85 -23
  28. package/dist/core/errors.d.ts.map +1 -1
  29. package/dist/core/errors.js +112 -47
  30. package/dist/core/errors.js.map +1 -1
  31. package/dist/core/feedback.d.ts +4 -1
  32. package/dist/core/feedback.d.ts.map +1 -1
  33. package/dist/core/feedback.js +4 -1
  34. package/dist/core/feedback.js.map +1 -1
  35. package/dist/core/transaction.d.ts +6 -1
  36. package/dist/core/transaction.d.ts.map +1 -1
  37. package/dist/core/transaction.js +9 -4
  38. package/dist/core/transaction.js.map +1 -1
  39. package/dist/core/transport.d.ts +33 -6
  40. package/dist/core/transport.d.ts.map +1 -1
  41. package/dist/core/transport.js +77 -20
  42. package/dist/core/transport.js.map +1 -1
  43. package/dist/formats/camt.d.ts +24 -4
  44. package/dist/formats/camt.d.ts.map +1 -1
  45. package/dist/formats/camt.js +124 -41
  46. package/dist/formats/camt.js.map +1 -1
  47. package/dist/formats/mt940.d.ts +15 -3
  48. package/dist/formats/mt940.d.ts.map +1 -1
  49. package/dist/formats/mt940.js +161 -82
  50. package/dist/formats/mt940.js.map +1 -1
  51. package/dist/formats/readers.d.ts +6 -2
  52. package/dist/formats/readers.d.ts.map +1 -1
  53. package/dist/formats/readers.js +24 -29
  54. package/dist/formats/readers.js.map +1 -1
  55. package/dist/formats/record-budget.d.ts +7 -0
  56. package/dist/formats/record-budget.d.ts.map +1 -0
  57. package/dist/formats/record-budget.js +17 -0
  58. package/dist/formats/record-budget.js.map +1 -0
  59. package/dist/formats/sepa-purpose.d.ts +6 -0
  60. package/dist/formats/sepa-purpose.d.ts.map +1 -1
  61. package/dist/formats/sepa-purpose.js +23 -2
  62. package/dist/formats/sepa-purpose.js.map +1 -1
  63. package/dist/index.d.ts +3 -3
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +2 -2
  66. package/dist/index.js.map +1 -1
  67. package/dist/session/app-approval.d.ts +11 -5
  68. package/dist/session/app-approval.d.ts.map +1 -1
  69. package/dist/session/app-approval.js +23 -12
  70. package/dist/session/app-approval.js.map +1 -1
  71. package/dist/session/dialog-runner.d.ts +7 -10
  72. package/dist/session/dialog-runner.d.ts.map +1 -1
  73. package/dist/session/dialog-runner.js +15 -16
  74. package/dist/session/dialog-runner.js.map +1 -1
  75. package/dist/session/login-guard.d.ts +54 -49
  76. package/dist/session/login-guard.d.ts.map +1 -1
  77. package/dist/session/login-guard.js +156 -84
  78. package/dist/session/login-guard.js.map +1 -1
  79. package/dist/session/sepa-accounts.d.ts +20 -14
  80. package/dist/session/sepa-accounts.d.ts.map +1 -1
  81. package/dist/session/sepa-accounts.js +62 -46
  82. package/dist/session/sepa-accounts.js.map +1 -1
  83. package/dist/session/session-setup.d.ts +33 -25
  84. package/dist/session/session-setup.d.ts.map +1 -1
  85. package/dist/session/session-setup.js +87 -65
  86. package/dist/session/session-setup.js.map +1 -1
  87. package/dist/session/session-state.d.ts +9 -6
  88. package/dist/session/session-state.d.ts.map +1 -1
  89. package/dist/session/session-state.js +52 -17
  90. package/dist/session/session-state.js.map +1 -1
  91. package/dist/session/signed-dialog.d.ts +77 -0
  92. package/dist/session/signed-dialog.d.ts.map +1 -0
  93. package/dist/session/signed-dialog.js +170 -0
  94. package/dist/session/signed-dialog.js.map +1 -0
  95. package/dist/session/tan-selection.d.ts +26 -18
  96. package/dist/session/tan-selection.d.ts.map +1 -1
  97. package/dist/session/tan-selection.js +44 -33
  98. package/dist/session/tan-selection.js.map +1 -1
  99. package/dist/session/user-prompts.d.ts +8 -4
  100. package/dist/session/user-prompts.d.ts.map +1 -1
  101. package/dist/session/user-prompts.js +34 -14
  102. package/dist/session/user-prompts.js.map +1 -1
  103. package/dist/tan/challenge.d.ts +34 -13
  104. package/dist/tan/challenge.d.ts.map +1 -1
  105. package/dist/tan/challenge.js +25 -26
  106. package/dist/tan/challenge.js.map +1 -1
  107. package/dist/tan/flicker.d.ts +7 -1
  108. package/dist/tan/flicker.d.ts.map +1 -1
  109. package/dist/tan/flicker.js +40 -6
  110. package/dist/tan/flicker.js.map +1 -1
  111. package/dist/tan/tan-image.d.ts +3 -2
  112. package/dist/tan/tan-image.d.ts.map +1 -1
  113. package/dist/tan/tan-image.js +7 -5
  114. package/dist/tan/tan-image.js.map +1 -1
  115. package/dist/tan/tan-models.d.ts +5 -1
  116. package/dist/tan/tan-models.d.ts.map +1 -1
  117. package/dist/tan/tan-models.js +10 -5
  118. package/dist/tan/tan-models.js.map +1 -1
  119. package/dist/util/async.d.ts +0 -2
  120. package/dist/util/async.d.ts.map +1 -1
  121. package/dist/util/async.js +0 -4
  122. package/dist/util/async.js.map +1 -1
  123. package/dist/util/bytes.d.ts +2 -3
  124. package/dist/util/bytes.d.ts.map +1 -1
  125. package/dist/util/bytes.js +12 -20
  126. package/dist/util/bytes.js.map +1 -1
  127. package/dist/util/call-context.d.ts.map +1 -1
  128. package/dist/util/call-context.js +3 -2
  129. package/dist/util/call-context.js.map +1 -1
  130. package/dist/util/dates.d.ts +9 -16
  131. package/dist/util/dates.d.ts.map +1 -1
  132. package/dist/util/dates.js +39 -19
  133. package/dist/util/dates.js.map +1 -1
  134. package/dist/util/errors.d.ts +9 -1
  135. package/dist/util/errors.d.ts.map +1 -1
  136. package/dist/util/errors.js +12 -3
  137. package/dist/util/errors.js.map +1 -1
  138. package/dist/util/json.d.ts +4 -0
  139. package/dist/util/json.d.ts.map +1 -1
  140. package/dist/util/json.js +18 -0
  141. package/dist/util/json.js.map +1 -1
  142. package/dist/util/text.d.ts +21 -4
  143. package/dist/util/text.d.ts.map +1 -1
  144. package/dist/util/text.js +42 -13
  145. package/dist/util/text.js.map +1 -1
  146. package/dist/util/xml.d.ts +4 -3
  147. package/dist/util/xml.d.ts.map +1 -1
  148. package/dist/util/xml.js +37 -26
  149. package/dist/util/xml.js.map +1 -1
  150. package/dist/v3/account-extension.d.ts.map +1 -1
  151. package/dist/v3/account-extension.js +7 -10
  152. package/dist/v3/account-extension.js.map +1 -1
  153. package/dist/v3/bank-connection.d.ts +34 -0
  154. package/dist/v3/bank-connection.d.ts.map +1 -0
  155. package/dist/v3/bank-connection.js +58 -0
  156. package/dist/v3/bank-connection.js.map +1 -0
  157. package/dist/v3/dialog.d.ts +80 -46
  158. package/dist/v3/dialog.d.ts.map +1 -1
  159. package/dist/v3/dialog.js +162 -59
  160. package/dist/v3/dialog.js.map +1 -1
  161. package/dist/v3/message.d.ts +17 -4
  162. package/dist/v3/message.d.ts.map +1 -1
  163. package/dist/v3/message.js +62 -18
  164. package/dist/v3/message.js.map +1 -1
  165. package/dist/v3/parameter-store.d.ts +75 -0
  166. package/dist/v3/parameter-store.d.ts.map +1 -0
  167. package/dist/v3/parameter-store.js +143 -0
  168. package/dist/v3/parameter-store.js.map +1 -0
  169. package/dist/v3/parameters.d.ts +38 -12
  170. package/dist/v3/parameters.d.ts.map +1 -1
  171. package/dist/v3/parameters.js +91 -37
  172. package/dist/v3/parameters.js.map +1 -1
  173. package/dist/v3/protocol.d.ts +43 -50
  174. package/dist/v3/protocol.d.ts.map +1 -1
  175. package/dist/v3/protocol.js +58 -208
  176. package/dist/v3/protocol.js.map +1 -1
  177. package/dist/v3/queries.d.ts +51 -0
  178. package/dist/v3/queries.d.ts.map +1 -0
  179. package/dist/v3/queries.js +120 -0
  180. package/dist/v3/queries.js.map +1 -0
  181. package/dist/v3/segments.d.ts +29 -12
  182. package/dist/v3/segments.d.ts.map +1 -1
  183. package/dist/v3/segments.js +65 -23
  184. package/dist/v3/segments.js.map +1 -1
  185. package/dist/v3/syntax.d.ts +65 -14
  186. package/dist/v3/syntax.d.ts.map +1 -1
  187. package/dist/v3/syntax.js +167 -101
  188. package/dist/v3/syntax.js.map +1 -1
  189. package/package.json +10 -6
  190. package/src/client.ts +252 -0
  191. package/src/core/account.ts +86 -13
  192. package/src/core/amount.ts +3 -1
  193. package/src/core/balance.ts +6 -5
  194. package/src/core/bank-info.ts +1 -1
  195. package/src/core/client.ts +52 -15
  196. package/src/core/config.ts +69 -28
  197. package/src/core/errors.ts +122 -48
  198. package/src/core/feedback.ts +4 -1
  199. package/src/core/transaction.ts +9 -4
  200. package/src/core/transport.ts +98 -23
  201. package/src/formats/camt.ts +136 -39
  202. package/src/formats/mt940.ts +167 -81
  203. package/src/formats/readers.ts +24 -31
  204. package/src/formats/record-budget.ts +18 -0
  205. package/src/formats/sepa-purpose.ts +21 -2
  206. package/src/index.ts +4 -2
  207. package/src/session/app-approval.ts +51 -38
  208. package/src/session/dialog-runner.ts +31 -28
  209. package/src/session/login-guard.ts +174 -88
  210. package/src/session/sepa-accounts.ts +63 -45
  211. package/src/session/session-setup.ts +90 -71
  212. package/src/session/session-state.ts +56 -22
  213. package/src/session/signed-dialog.ts +192 -0
  214. package/src/session/tan-selection.ts +50 -39
  215. package/src/session/user-prompts.ts +35 -16
  216. package/src/tan/challenge.ts +40 -31
  217. package/src/tan/flicker.ts +44 -6
  218. package/src/tan/tan-image.ts +7 -5
  219. package/src/tan/tan-models.ts +10 -5
  220. package/src/util/async.ts +0 -5
  221. package/src/util/bytes.ts +13 -19
  222. package/src/util/call-context.ts +3 -2
  223. package/src/util/dates.ts +41 -24
  224. package/src/util/errors.ts +14 -3
  225. package/src/util/json.ts +16 -0
  226. package/src/util/text.ts +42 -12
  227. package/src/util/xml.ts +37 -26
  228. package/src/v3/account-extension.ts +7 -12
  229. package/src/v3/bank-connection.ts +67 -0
  230. package/src/v3/dialog.ts +175 -91
  231. package/src/v3/message.ts +69 -17
  232. package/src/v3/parameter-store.ts +160 -0
  233. package/src/v3/parameters.ts +110 -37
  234. package/src/v3/protocol.ts +70 -253
  235. package/src/v3/queries.ts +190 -0
  236. package/src/v3/segments.ts +65 -22
  237. package/src/v3/syntax.ts +153 -91
  238. package/dist/session/bank-connection.d.ts +0 -28
  239. package/dist/session/bank-connection.d.ts.map +0 -1
  240. package/dist/session/bank-connection.js +0 -48
  241. package/dist/session/bank-connection.js.map +0 -1
  242. package/dist/session/parameter-data.d.ts +0 -83
  243. package/dist/session/parameter-data.d.ts.map +0 -1
  244. package/dist/session/parameter-data.js +0 -68
  245. package/dist/session/parameter-data.js.map +0 -1
  246. package/dist/session/pin-tan-client.d.ts +0 -54
  247. package/dist/session/pin-tan-client.d.ts.map +0 -1
  248. package/dist/session/pin-tan-client.js +0 -153
  249. package/dist/session/pin-tan-client.js.map +0 -1
  250. package/dist/session/pin-tan-dialog.d.ts +0 -71
  251. package/dist/session/pin-tan-dialog.d.ts.map +0 -1
  252. package/dist/session/pin-tan-dialog.js +0 -124
  253. package/dist/session/pin-tan-dialog.js.map +0 -1
  254. package/dist/session/protocol.d.ts +0 -209
  255. package/dist/session/protocol.d.ts.map +0 -1
  256. package/dist/session/protocol.js +0 -75
  257. package/dist/session/protocol.js.map +0 -1
  258. package/dist/session/response-handler.d.ts +0 -48
  259. package/dist/session/response-handler.d.ts.map +0 -1
  260. package/dist/session/response-handler.js +0 -121
  261. package/dist/session/response-handler.js.map +0 -1
  262. package/dist/v3/client.d.ts +0 -24
  263. package/dist/v3/client.d.ts.map +0 -1
  264. package/dist/v3/client.js +0 -16
  265. package/dist/v3/client.js.map +0 -1
  266. package/src/session/bank-connection.ts +0 -51
  267. package/src/session/parameter-data.ts +0 -137
  268. package/src/session/pin-tan-client.ts +0 -186
  269. package/src/session/pin-tan-dialog.ts +0 -160
  270. package/src/session/protocol.ts +0 -311
  271. package/src/session/response-handler.ts +0 -130
  272. package/src/v3/client.ts +0 -29
@@ -0,0 +1,170 @@
1
+ import { requireLatin1 } from '../core/config.js';
2
+ import { bankErrorFor, FinTsLoginDataChangedError, FinTsProtocolError, FinTsTanCancelledError, } from '../core/errors.js';
3
+ import { allowedTanMethodsIn, FeedbackCodes, hasCode, hasErrors, userWarnings } from '../core/feedback.js';
4
+ import { invalidArgument } from '../util/errors.js';
5
+ import { IncomingMessage3 } from '../v3/message.js';
6
+ import { appApprovalWait } from './app-approval.js';
7
+ /**
8
+ * A dialog signed with the PIN, which settles each answer before it hands it out: it keeps the parameter data of the
9
+ * dialog's opening, passes the notices on, has the `LoginGuard` judge the answer and throws its errors, and completes
10
+ * the approval the bank asks for. The session sends every message signed with the PIN through it, so that the guard
11
+ * judges every answer, that to the dialog's end included.
12
+ */
13
+ export class SignedDialog {
14
+ dialog;
15
+ session;
16
+ constructor(dialog, session) {
17
+ this.dialog = dialog;
18
+ this.session = session;
19
+ }
20
+ /** Whether the bank knows this dialog and it has not ended. */
21
+ get isActive() {
22
+ return this.dialog.isActive;
23
+ }
24
+ /** Logs in, which opens the dialog; with `synchronize` the bank also assigns a customer system ID. */
25
+ async login(synchronize = false) {
26
+ return this.settle(await this.dialog.start(synchronize), 'login');
27
+ }
28
+ /**
29
+ * Logs in, asking strong authentication for `order`, then sends `order` in a message of its own, as for listing the
30
+ * TAN media while no medium is chosen yet (`FinTs3Dialog.startWith`); returns both answers.
31
+ */
32
+ async loginWith(order) {
33
+ const start = this.dialog.startWith(order);
34
+ const login = await this.settle(await start.login(), 'login');
35
+ return [login, await this.settle(await start.order(), 'order')];
36
+ }
37
+ /** Sends `order`, the first page of a query, and completes the approval the bank asks for. */
38
+ async send(order) {
39
+ return this.settle(await this.dialog.send(order), 'order');
40
+ }
41
+ /**
42
+ * Sends `order` for a further page of a query (Formals B.6.3), whose answer must not ask for an approval: the client
43
+ * completes that of the first page only, so that a bank that asks anew for every page cannot prompt the user once per
44
+ * page. Throws `FinTsProtocolError` if it asks for one.
45
+ */
46
+ async sendFurtherPage(order) {
47
+ const response = await this.dialog.send(order);
48
+ this.receive(response, 'order', false);
49
+ if (this.dialog.approvalAskedIn(response) !== undefined) {
50
+ throw new FinTsProtocolError('The bank asks for an approval of a further page of the same query');
51
+ }
52
+ return response;
53
+ }
54
+ /**
55
+ * Ends the dialog at the bank; does nothing if it is not active. Of the answer only a rejected PIN counts, which the
56
+ * guard judges: the dialog is over either way.
57
+ */
58
+ async end() {
59
+ const response = await this.dialog.end();
60
+ if (response !== undefined && hasErrors(response.feedback)) {
61
+ this.session.guard.judge(bankErrorFor(response.feedback), 'order', this.dialog.method);
62
+ }
63
+ }
64
+ /**
65
+ * Receives `response`, the answer to a request of `kind`: keeps its parameter data where it answers the `opening` of
66
+ * the dialog, the login or its approval, even alongside errors, since the remedy for a refused login may need them;
67
+ * passes its notices on; and has the guard judge it, then throws its errors, as the refusal of the login where they
68
+ * amount to one.
69
+ */
70
+ receive(response, kind, opening) {
71
+ if (opening)
72
+ this.session.parameters.keep(response);
73
+ this.readNotices(response);
74
+ const error = hasErrors(response.feedback) ? bankErrorFor(response.feedback, kind === 'approval') : undefined;
75
+ const refusal = this.session.guard.judge(error, kind, this.dialog.method);
76
+ // Every further message of a refused login's dialog would carry the refused PIN.
77
+ if (refusal !== undefined)
78
+ this.dialog.discard();
79
+ if (error !== undefined)
80
+ throw refusal ?? error;
81
+ }
82
+ /**
83
+ * Where `response` answers a login, a request of `kind` other than `order`, or its approval with new login data: ends
84
+ * the dialog, stops the client from logging in with the old ones, and fails the call with
85
+ * `FinTsLoginDataChangedError` (Rückmeldungscodes C.6). It runs before any approval, which would cost the user a TAN
86
+ * for a session that ends anyway. New login data next to an error are the login's refusal already
87
+ * (`loginRefusalFor`).
88
+ */
89
+ async retireOldLoginData(response, kind) {
90
+ if (kind === 'order' || !hasCode(response.feedback, FeedbackCodes.newLoginData))
91
+ return;
92
+ await this.end();
93
+ const error = new FinTsLoginDataChangedError(response.feedback);
94
+ throw this.session.guard.judge(error, kind, this.dialog.method) ?? error;
95
+ }
96
+ /**
97
+ * Receives `response`, the answer to a request of `kind`, then completes the approval it asks for; returns it joined
98
+ * with the response that completes the approval.
99
+ *
100
+ * Throws `FinTsProtocolError` if that response asks for an approval once more: the bank has not executed the message
101
+ * then either, and read as done it would report an empty result.
102
+ */
103
+ async settle(response, kind) {
104
+ const opening = kind !== 'order';
105
+ this.receive(response, kind, opening);
106
+ await this.retireOldLoginData(response, kind);
107
+ const approval = this.dialog.approvalAskedIn(response);
108
+ if (approval === undefined)
109
+ return response;
110
+ const approved = approval.challenge.isDecoupled
111
+ ? await this.awaitAppApproval(approval, opening)
112
+ : await this.enterTan(approval, opening);
113
+ await this.retireOldLoginData(approved, kind);
114
+ if (this.dialog.approvalAskedIn(approved) !== undefined) {
115
+ throw new FinTsProtocolError('The bank asks for another approval in answer to the approval');
116
+ }
117
+ return IncomingMessage3.combine(response, approved);
118
+ }
119
+ /** Passes on the notices in `response`: the TAN methods the user may use (3920), the bank's messages and warnings. */
120
+ readNotices(response) {
121
+ const allowed = allowedTanMethodsIn(response.feedback);
122
+ if (allowed.length > 0)
123
+ this.session.state.rememberAllowedMethods(allowed);
124
+ for (const message of response.bankMessages)
125
+ this.session.prompts.showBankMessage(message);
126
+ for (const warning of userWarnings(response.feedback))
127
+ this.session.prompts.showWarning(warning);
128
+ }
129
+ /** Asks the user for the TAN `approval` takes and sends it; `opening` tells whether it approves the login. */
130
+ async enterTan(approval, opening) {
131
+ const answer = await this.session.prompts.askTan(approval.challenge);
132
+ if (answer.kind === 'approved') {
133
+ throw invalidArgument('Answered a TAN challenge with an approval in the banking app', 'tanCallback');
134
+ }
135
+ // NFKC, so that digits of another width, such as those of a Japanese input method, go out as the digits they are.
136
+ const tan = answer.kind === 'tan' ? answer.tan.normalize('NFKC').trim() : '';
137
+ if (tan === '')
138
+ throw new FinTsTanCancelledError();
139
+ const response = await approval.submitTan(requireTanOf(approval.challenge.method, tan));
140
+ this.receive(response, 'approval', opening);
141
+ return response;
142
+ }
143
+ /** Waits for the user to approve in the banking app; `opening` tells whether the approval is that of the login. */
144
+ awaitAppApproval(approval, opening) {
145
+ const prompts = this.session.prompts;
146
+ return appApprovalWait(approval, {
147
+ ask: (challenge) => prompts.askTan(challenge),
148
+ pause: (delayMs, interrupt) => prompts.pause(delayMs, interrupt),
149
+ receive: (response) => {
150
+ this.receive(response, 'approval', opening);
151
+ },
152
+ }).run();
153
+ }
154
+ }
155
+ /**
156
+ * Throws `TypeError` for a TAN that `method` rules out, which the bank would count as a failed attempt: one longer than
157
+ * `TanMethod.maxTanLength`, or with other characters than digits for a `TanMethod.numericTan` method; and for one that
158
+ * FinTS 3.0 cannot send. The message leaves out the TAN.
159
+ */
160
+ function requireTanOf(method, tan) {
161
+ const max = method.maxTanLength;
162
+ if (max !== undefined && max > 0 && tan.length > max) {
163
+ throw invalidArgument(`The TAN method ${method.name} takes TANs of at most ${max} characters`, 'tan');
164
+ }
165
+ if (method.numericTan && !/^[0-9]+$/.test(tan)) {
166
+ throw invalidArgument(`The TAN method ${method.name} takes digits only`, 'tan');
167
+ }
168
+ return requireLatin1(tan, 'tan');
169
+ }
170
+ //# sourceMappingURL=signed-dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signed-dialog.js","sourceRoot":"","sources":["../../src/session/signed-dialog.ts"],"names":[],"mappings":"AAA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,CAAC;IAChC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QACrD,MAAM,eAAe,CAAC,kBAAkB,MAAM,CAAC,IAAI,0BAA0B,GAAG,aAAa,EAAE,KAAK,CAAC,CAAC;IACxG,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,eAAe,CAAC,kBAAkB,MAAM,CAAC,IAAI,oBAAoB,EAAE,KAAK,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC"}
@@ -1,40 +1,47 @@
1
1
  import { TanMethod, type TanMedium } from '../tan/tan-models.js';
2
- import { type BankResponse, type PinTanProtocol, type ProtocolDialog } from './protocol.js';
2
+ import { FinTs3Dialog } from '../v3/dialog.js';
3
+ import type { FinTs3Protocol } from '../v3/protocol.js';
3
4
  import type { SessionState } from './session-state.js';
4
5
  import type { UserPrompts } from './user-prompts.js';
5
6
  /**
6
7
  * The TAN method and medium the session's messages are signed with, chosen by the user among what the bank offers and
7
8
  * the user may use, and kept in the session state.
8
9
  */
9
- export declare class TanSelection<R extends BankResponse, O> {
10
+ export declare class TanSelection {
10
11
  private readonly protocol;
11
12
  private readonly state;
12
13
  private readonly prompts;
13
- /** TAN methods whose media were looked up in this session. A lookup is not repeated, even where it gave no medium. */
14
- private readonly mediaLookedUp;
15
- /** The list the last lookup gave, until `takeLookedUpMedia` hands it out. */
16
- private lookedUpMedia;
14
+ /**
15
+ * The lookups of this session that found no medium to choose, by TAN method, with the list each gave; `undefined`
16
+ * where the bank gave none. Such a lookup is not repeated for its method until `select` or `forgetMedium` drops it.
17
+ */
18
+ private readonly lookupsWithoutMedium;
17
19
  /** Whether the bank refused a login signed with the one-step method in this session. */
18
20
  private oneStepRefused;
19
- constructor(protocol: PinTanProtocol<R, O>, state: SessionState, prompts: UserPrompts);
21
+ constructor(protocol: FinTs3Protocol, state: SessionState, prompts: UserPrompts);
20
22
  /** The TAN method in use; the one-step method until one is chosen. */
21
23
  get method(): TanMethod;
22
24
  /** Switches to `securityFunction` and `tanMedium` for the dialogs to come. */
23
25
  select(securityFunction: string, tanMedium: string | undefined): void;
26
+ /**
27
+ * Forgets the medium in use and the lookups of this session, so that the next login looks the media up anew where the
28
+ * method needs one: the bank may have refused the medium, such as that of a phone the user has replaced.
29
+ */
30
+ forgetMedium(): void;
24
31
  /**
25
32
  * A dialog signed with the TAN method in use and its medium.
26
33
  *
27
- * Throws `FinTsUnsupportedError` if the method needs a medium the user has not chosen: the bank would refuse the
34
+ * Throws `FinTsTanSetupError` if the method needs a medium the user has not chosen: the bank would refuse the
28
35
  * login, and the client would not send the PIN again.
29
36
  */
30
- newDialog(): ProtocolDialog<R, O>;
37
+ newDialog(): FinTs3Dialog;
31
38
  /**
32
39
  * The dialog that looks up the TAN media, signed with the TAN method in use.
33
40
  *
34
41
  * It runs before the medium is known, so it names a placeholder where the method needs one; the bank ignores the
35
42
  * medium in this dialog (PIN/TAN B.4.3.1.3).
36
43
  */
37
- lookupDialog(): ProtocolDialog<R, O>;
44
+ lookupDialog(): FinTs3Dialog;
38
45
  /**
39
46
  * The synchronization dialog. It runs before the TAN media are looked up, so its method must do without a medium the
40
47
  * user has not chosen: the placeholder for one is meant for the lookup only (PIN/TAN B.4.3.1.3). The first method
@@ -44,16 +51,16 @@ export declare class TanSelection<R extends BankResponse, O> {
44
51
  * a one-step login;
45
52
  * 3. another two-step method the user may use.
46
53
  *
47
- * Throws `FinTsUnsupportedError` if none does, before the bank could refuse the login.
54
+ * Throws `FinTsTanSetupError` if none does, before the bank could refuse the login.
48
55
  */
49
- synchronizationDialog(): ProtocolDialog<R, O>;
56
+ synchronizationDialog(): FinTs3Dialog;
50
57
  /** Whether `method` needs a medium the user has not chosen. */
51
58
  private lacksMedium;
52
59
  /**
53
60
  * The two-step TAN methods the bank offers, the user may use and this client can run; the one-step method if there
54
61
  * are none.
55
62
  *
56
- * Throws `FinTsUnsupportedError` if the bank offers the user nothing but methods the client cannot run.
63
+ * Throws `FinTsTanSetupError` if the bank offers the user nothing but methods the client cannot run.
57
64
  */
58
65
  available(): TanMethod[];
59
66
  /**
@@ -67,7 +74,7 @@ export declare class TanSelection<R extends BankResponse, O> {
67
74
  ensureMethodChosen(): Promise<void>;
68
75
  /**
69
76
  * Whether the media of the method in use have to be looked up: it needs a medium the user has not chosen, and they
70
- * were not looked up for it in this session.
77
+ * were not looked up in vain for it in this session.
71
78
  */
72
79
  get mediumToLookUp(): boolean;
73
80
  /**
@@ -76,12 +83,13 @@ export declare class TanSelection<R extends BankResponse, O> {
76
83
  */
77
84
  chooseMedium(media: TanMedium[] | undefined): Promise<void>;
78
85
  /**
79
- * The list of the last lookup, once; `undefined` if there was none since the last time.
86
+ * The list of the lookup that found no medium for the method in use; `undefined` where there was none, or the bank
87
+ * gave no list.
80
88
  *
81
- * `getTanMedia` takes it, so that the list is not asked for twice in a row. It also outlasts a call that failed for
82
- * want of an active medium, so that the app can show the user the list that tells why; later calls ask anew.
89
+ * It outlasts the call that failed for want of the medium, so that `getTanMedia` can show the user the list that tells
90
+ * why: the client neither looks the media up again for the method nor can list them in a dialog without a medium.
83
91
  */
84
- takeLookedUpMedia(): TanMedium[] | undefined;
92
+ get lookedUpMedia(): TanMedium[] | undefined;
85
93
  /** The name of the medium the user chooses among the active ones in `media`; `undefined` if none is active. */
86
94
  private chooseMediumOf;
87
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tan-selection.d.ts","sourceRoot":"","sources":["../../src/session/tan-selection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAe,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;A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C,WAAW;IAInB;;;;;OAKG;IACH,SAAS,IAAI,SAAS,EAAE;IAgBxB;;;;;OAKG;IACG,OAAO,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IASpD,4FAA4F;IACtF,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAQzC;;;OAGG;IACH,IAAI,cAAc,IAAI,OAAO,CAG5B;IAED;;;OAGG;IACG,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjE;;;;;;OAMG;IACH,IAAI,aAAa,IAAI,SAAS,EAAE,GAAG,SAAS,CAE3C;IAED,+GAA+G;YACjG,cAAc;CAQ7B"}
@@ -1,6 +1,7 @@
1
- import { FinTsUnsupportedError } from '../core/errors.js';
1
+ import { FinTsTanSetupError } from '../core/errors.js';
2
2
  import { TanMethod } from '../tan/tan-models.js';
3
- import { noReference } from './protocol.js';
3
+ import { FinTs3Dialog } from '../v3/dialog.js';
4
+ import { noReference } from '../v3/segments.js';
4
5
  /**
5
6
  * The TAN method and medium the session's messages are signed with, chosen by the user among what the bank offers and
6
7
  * the user may use, and kept in the session state.
@@ -9,10 +10,11 @@ export class TanSelection {
9
10
  protocol;
10
11
  state;
11
12
  prompts;
12
- /** TAN methods whose media were looked up in this session. A lookup is not repeated, even where it gave no medium. */
13
- mediaLookedUp = new Set();
14
- /** The list the last lookup gave, until `takeLookedUpMedia` hands it out. */
15
- lookedUpMedia;
13
+ /**
14
+ * The lookups of this session that found no medium to choose, by TAN method, with the list each gave; `undefined`
15
+ * where the bank gave none. Such a lookup is not repeated for its method until `select` or `forgetMedium` drops it.
16
+ */
17
+ lookupsWithoutMedium = new Map();
16
18
  /** Whether the bank refused a login signed with the one-step method in this session. */
17
19
  oneStepRefused = false;
18
20
  constructor(protocol, state, prompts) {
@@ -25,27 +27,36 @@ export class TanSelection {
25
27
  const code = this.state.tanMethod;
26
28
  if (code === undefined || code === TanMethod.oneStep.securityFunction)
27
29
  return TanMethod.oneStep;
28
- return this.protocol.bankParameters?.tanMethods.find((m) => m.securityFunction === code) ?? TanMethod.oneStep;
30
+ const methods = this.protocol.parameters.bankParameters?.tanMethods ?? [];
31
+ return methods.find((m) => m.securityFunction === code) ?? TanMethod.oneStep;
29
32
  }
30
33
  /** Switches to `securityFunction` and `tanMedium` for the dialogs to come. */
31
34
  select(securityFunction, tanMedium) {
32
35
  this.state.useTanMethod(securityFunction, tanMedium);
33
- this.mediaLookedUp.delete(securityFunction);
36
+ this.lookupsWithoutMedium.delete(securityFunction);
37
+ }
38
+ /**
39
+ * Forgets the medium in use and the lookups of this session, so that the next login looks the media up anew where the
40
+ * method needs one: the bank may have refused the medium, such as that of a phone the user has replaced.
41
+ */
42
+ forgetMedium() {
43
+ this.state.useTanMedium(undefined);
44
+ this.lookupsWithoutMedium.clear();
34
45
  }
35
46
  /**
36
47
  * A dialog signed with the TAN method in use and its medium.
37
48
  *
38
- * Throws `FinTsUnsupportedError` if the method needs a medium the user has not chosen: the bank would refuse the
49
+ * Throws `FinTsTanSetupError` if the method needs a medium the user has not chosen: the bank would refuse the
39
50
  * login, and the client would not send the PIN again.
40
51
  */
41
52
  newDialog() {
42
53
  const method = this.method;
43
54
  if (this.lacksMedium(method)) {
44
- throw new FinTsUnsupportedError(`The TAN method ${method.name} needs a TAN medium, and the client could not learn one: the bank lists no ` +
55
+ throw new FinTsTanSetupError(`The TAN method ${method.name} needs a TAN medium, and the client could not learn one: the bank lists no ` +
45
56
  'active medium for it, or does not offer or permit the list of TAN media, or rejected it. Pass a medium to ' +
46
57
  'selectTanMethod, or choose another method');
47
58
  }
48
- return this.protocol.newDialog(method, this.state.tanMedium);
59
+ return FinTs3Dialog.signed(this.protocol, method, this.state.tanMedium);
49
60
  }
50
61
  /**
51
62
  * The dialog that looks up the TAN media, signed with the TAN method in use.
@@ -55,7 +66,7 @@ export class TanSelection {
55
66
  */
56
67
  lookupDialog() {
57
68
  const method = this.method;
58
- return this.protocol.newDialog(method, this.lacksMedium(method) ? noReference : this.state.tanMedium);
69
+ return FinTs3Dialog.signed(this.protocol, method, this.lacksMedium(method) ? noReference : this.state.tanMedium);
59
70
  }
60
71
  /**
61
72
  * The synchronization dialog. It runs before the TAN media are looked up, so its method must do without a medium the
@@ -66,18 +77,18 @@ export class TanSelection {
66
77
  * a one-step login;
67
78
  * 3. another two-step method the user may use.
68
79
  *
69
- * Throws `FinTsUnsupportedError` if none does, before the bank could refuse the login.
80
+ * Throws `FinTsTanSetupError` if none does, before the bank could refuse the login.
70
81
  */
71
82
  synchronizationDialog() {
72
83
  const method = this.method;
73
84
  if (!this.lacksMedium(method))
74
- return this.protocol.newDialog(method, this.state.tanMedium);
85
+ return FinTs3Dialog.signed(this.protocol, method, this.state.tanMedium);
75
86
  if (!this.oneStepRefused)
76
- return this.protocol.newDialog(TanMethod.oneStep);
87
+ return FinTs3Dialog.signed(this.protocol, TanMethod.oneStep);
77
88
  const other = this.available().find((m) => !m.isOneStep && !this.lacksMedium(m));
78
89
  if (other !== undefined)
79
- return this.protocol.newDialog(other);
80
- throw new FinTsUnsupportedError(`The bank refuses the one-step method, and the TAN method ${method.name} needs a TAN medium, which the client ` +
90
+ return FinTs3Dialog.signed(this.protocol, other);
91
+ throw new FinTsTanSetupError(`The bank refuses the one-step method, and the TAN method ${method.name} needs a TAN medium, which the client ` +
81
92
  'can look up only after the synchronization. Pass the medium to selectTanMethod, or choose another method');
82
93
  }
83
94
  /** Whether `method` needs a medium the user has not chosen. */
@@ -88,17 +99,17 @@ export class TanSelection {
88
99
  * The two-step TAN methods the bank offers, the user may use and this client can run; the one-step method if there
89
100
  * are none.
90
101
  *
91
- * Throws `FinTsUnsupportedError` if the bank offers the user nothing but methods the client cannot run.
102
+ * Throws `FinTsTanSetupError` if the bank offers the user nothing but methods the client cannot run.
92
103
  */
93
104
  available() {
94
- const bpd = this.protocol.bankParameters;
105
+ const bpd = this.protocol.parameters.bankParameters;
95
106
  if (bpd === undefined)
96
107
  return [TanMethod.oneStep];
97
- const allowed = this.state.allowedMethods ?? this.protocol.userParameters?.allowedTanMethods;
108
+ const allowed = this.state.allowedMethods;
98
109
  const isAllowed = (securityFunction) => allowed === undefined || allowed.length === 0 || allowed.includes(securityFunction);
99
110
  const runnable = bpd.tanMethods.filter((m) => isAllowed(m.securityFunction));
100
111
  if (runnable.length === 0 && bpd.unsupportedTanMethods.some(isAllowed)) {
101
- throw new FinTsUnsupportedError('The bank offers only TAN methods this client cannot run: process variant 1, or methods that need an SMS ' +
112
+ throw new FinTsTanSetupError('The bank offers only TAN methods this client cannot run: process variant 1, or methods that need an SMS ' +
102
113
  'charge account or an HHD_UC answer');
103
114
  }
104
115
  return runnable.length === 0 ? [TanMethod.oneStep] : runnable;
@@ -130,11 +141,11 @@ export class TanSelection {
130
141
  }
131
142
  /**
132
143
  * Whether the media of the method in use have to be looked up: it needs a medium the user has not chosen, and they
133
- * were not looked up for it in this session.
144
+ * were not looked up in vain for it in this session.
134
145
  */
135
146
  get mediumToLookUp() {
136
147
  const method = this.method;
137
- return this.lacksMedium(method) && !this.mediaLookedUp.has(method.securityFunction);
148
+ return this.lacksMedium(method) && !this.lookupsWithoutMedium.has(method.securityFunction);
138
149
  }
139
150
  /**
140
151
  * Lets the user choose the medium of the method in use among the active ones in `media`, the result of a lookup;
@@ -142,20 +153,20 @@ export class TanSelection {
142
153
  */
143
154
  async chooseMedium(media) {
144
155
  const method = this.method;
145
- this.lookedUpMedia = media;
146
- this.state.useTanMedium(media === undefined ? undefined : await this.chooseMediumOf(method, media));
147
- this.mediaLookedUp.add(method.securityFunction);
156
+ const medium = media === undefined ? undefined : await this.chooseMediumOf(method, media);
157
+ this.state.useTanMedium(medium);
158
+ if (medium === undefined)
159
+ this.lookupsWithoutMedium.set(method.securityFunction, media);
148
160
  }
149
161
  /**
150
- * The list of the last lookup, once; `undefined` if there was none since the last time.
162
+ * The list of the lookup that found no medium for the method in use; `undefined` where there was none, or the bank
163
+ * gave no list.
151
164
  *
152
- * `getTanMedia` takes it, so that the list is not asked for twice in a row. It also outlasts a call that failed for
153
- * want of an active medium, so that the app can show the user the list that tells why; later calls ask anew.
165
+ * It outlasts the call that failed for want of the medium, so that `getTanMedia` can show the user the list that tells
166
+ * why: the client neither looks the media up again for the method nor can list them in a dialog without a medium.
154
167
  */
155
- takeLookedUpMedia() {
156
- const media = this.lookedUpMedia;
157
- this.lookedUpMedia = undefined;
158
- return media;
168
+ get lookedUpMedia() {
169
+ return this.lookupsWithoutMedium.get(this.method.securityFunction);
159
170
  }
160
171
  /** The name of the medium the user chooses among the active ones in `media`; `undefined` if none is active. */
161
172
  async chooseMediumOf(method, media) {
@@ -1 +1 @@
1
- {"version":3,"file":"tan-selection.js","sourceRoot":"","sources":["../../src/session/tan-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAkB,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,WAAW,EAA+D,MAAM,eAAe,CAAC;AAIzG;;;GAGG;AACH,MAAM,OAAO,YAAY;IAWJ;IACA;IACA;IAZnB,sHAAsH;IACrG,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnD,6EAA6E;IACrE,aAAa,CAA0B;IAE/C,wFAAwF;IAChF,cAAc,GAAG,KAAK,CAAC;IAE/B,YACmB,QAA8B,EAC9B,KAAmB,EACnB,OAAoB;QAFpB,aAAQ,GAAR,QAAQ,CAAsB;QAC9B,UAAK,GAAL,KAAK,CAAc;QACnB,YAAO,GAAP,OAAO,CAAa;IACpC,CAAC;IAEJ,sEAAsE;IACtE,IAAI,MAAM;QACR,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QAClC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,CAAC,OAAO,CAAC,gBAAgB;YAAE,OAAO,SAAS,CAAC,OAAO,CAAC;QAChG,O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AAC,CAAC;QAChC,IAAI,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;IAC1F,CAAC;IAED;;;;;;OAMG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACrE,CAAC;IAED,+GAA+G;IACvG,KAAK,CAAC,cAAc,CAAC,MAAiB,EAAE,KAA2B;QACzE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QACvE,oGAAoG;QACpG,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,KAAK,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACtF,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC7D,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAC9C,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5D,CAAC;CACF;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,MAAiB;IAC1C,OAAO,MAAM,CAAC,eAAe,IAAI,CAAC,MAAM,CAAC,gBAAgB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACtE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { BankMessage } from '../core/bank-info.js';
2
2
  import type { FinTsClientOptions, MessageLogger } from '../core/client.js';
3
3
  import type { FinTsFeedback } from '../core/feedback.js';
4
- import type { TanAnswer, TanChallenge } from '../tan/challenge.js';
4
+ import { TanAnswer, type TanChallenge } from '../tan/challenge.js';
5
5
  import type { TanMedium, TanMethod } from '../tan/tan-models.js';
6
6
  /**
7
7
  * Everything a session tells the app, asks of it or waits for: the bank's messages, warnings and log, the TAN callback,
@@ -15,7 +15,7 @@ export declare class UserPrompts {
15
15
  private closed;
16
16
  /** The first error an informing callback threw during the running call. */
17
17
  private callbackError;
18
- /** Aborts the waits under way; each wait removes its abort when it is over. */
18
+ /** Aborts the waits under way; each wait removes its abort when it is over, or when nothing waits for it any more. */
19
19
  private readonly aborts;
20
20
  constructor(options: FinTsClientOptions);
21
21
  /** Ends every wait; the client calls it once. */
@@ -34,7 +34,10 @@ export declare class UserPrompts {
34
34
  /** Passes the bank's `warning` to the app, unless the client is closed. */
35
35
  showWarning(warning: FinTsFeedback): void;
36
36
  private inform;
37
- /** Shows `challenge` through the TAN callback and returns its answer. */
37
+ /**
38
+ * Shows `challenge` through the TAN callback and returns its answer; rejects with `TypeError` for anything but a
39
+ * `TanAnswer`. Once `TanChallenge.resolved` settles, nothing waits for the answer any more.
40
+ */
38
41
  askTan(challenge: TanChallenge): Promise<TanAnswer>;
39
42
  /** Waits for `delayMs` milliseconds, or until `interrupt` settles. */
40
43
  pause(delayMs: number, interrupt?: Promise<unknown>): Promise<void>;
@@ -51,7 +54,8 @@ export declare class UserPrompts {
51
54
  */
52
55
  chooseMedium(media: readonly TanMedium[]): Promise<TanMedium>;
53
56
  /**
54
- * Starts `wait` and ends it with `FinTsStateError` if `close` is called before it is over.
57
+ * Starts `wait` and ends it with `FinTsStateError` if `close` is called before it is over. Once `unwanted` settles,
58
+ * nothing waits for it any more: it is forgotten then, rather than kept until a callback that never answers does.
55
59
  *
56
60
  * Once the client is closed, the returned promise rejects rather than this function throwing: a caller that starts
57
61
  * several waits at once would otherwise leave the failure of those started first unheard.
@@ -1 +1 @@
1
- {"version":3,"file":"user-prompts.d.ts","sourceRoot":"","sources":["../../src/session/user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