thunder-bridge 1.4.2 → 2.1.1
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/README.md +145 -133
- package/dist/bank-CEIuNhV_.d.cts +896 -0
- package/dist/bank-M8flcMks.d.ts +896 -0
- package/dist/bank.cjs +338 -0
- package/dist/bank.d.cts +46 -0
- package/dist/bank.d.ts +46 -0
- package/dist/bank.js +310 -0
- package/dist/errors-DriqW-lp.d.cts +126 -0
- package/dist/errors-ZEUT-MhO.d.ts +126 -0
- package/dist/index.cjs +2108 -1235
- package/dist/index.d.cts +13 -505
- package/dist/index.d.ts +13 -505
- package/dist/index.js +2088 -1193
- package/dist/{server.cjs → nwc.cjs} +376 -720
- package/dist/nwc.d.cts +122 -0
- package/dist/nwc.d.ts +122 -0
- package/dist/{server.js → nwc.js} +368 -695
- package/dist/price.cjs +240 -0
- package/dist/price.d.cts +17 -0
- package/dist/price.d.ts +17 -0
- package/dist/price.js +205 -0
- package/dist/qr-CF-YeXU1.d.cts +55 -0
- package/dist/qr-CF-YeXU1.d.ts +55 -0
- package/dist/qr.cjs +259 -0
- package/dist/qr.d.cts +1 -0
- package/dist/qr.d.ts +1 -0
- package/dist/qr.js +224 -0
- package/dist/types-DYZ9EkmJ.d.cts +261 -0
- package/dist/types-DYZ9EkmJ.d.ts +261 -0
- package/openapi.yaml +29 -39
- package/package.json +48 -9
- package/dist/rail-CqUfuYXJ.d.cts +0 -615
- package/dist/rail-CqUfuYXJ.d.ts +0 -615
- package/dist/server.d.cts +0 -145
- package/dist/server.d.ts +0 -145
package/dist/bank.cjs
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/entry/bank.ts
|
|
21
|
+
var bank_exports = {};
|
|
22
|
+
__export(bank_exports, {
|
|
23
|
+
bankAgent: () => bankAgent,
|
|
24
|
+
fioStatement: () => fioStatement
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(bank_exports);
|
|
27
|
+
|
|
28
|
+
// ../core/bytes.ts
|
|
29
|
+
function bytesToHex(bytes) {
|
|
30
|
+
let hex = "";
|
|
31
|
+
for (const byte of bytes) {
|
|
32
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
33
|
+
}
|
|
34
|
+
return hex;
|
|
35
|
+
}
|
|
36
|
+
function hexToBytes(hex) {
|
|
37
|
+
const bytes = new Uint8Array(hex.length >> 1);
|
|
38
|
+
for (let at = 0; at < bytes.length; at++) {
|
|
39
|
+
bytes[at] = parseInt(hex.slice(at * 2, at * 2 + 2), 16);
|
|
40
|
+
}
|
|
41
|
+
return bytes;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ../core/ed25519.ts
|
|
45
|
+
var PKCS8_HEADER = hexToBytes("302e020100300506032b657004220420");
|
|
46
|
+
var SMALL_ORDER = [
|
|
47
|
+
"00".repeat(32),
|
|
48
|
+
`01${"00".repeat(31)}`,
|
|
49
|
+
"26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05",
|
|
50
|
+
"c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a",
|
|
51
|
+
`ec${"ff".repeat(30)}7f`,
|
|
52
|
+
`ed${"ff".repeat(30)}7f`,
|
|
53
|
+
`ee${"ff".repeat(30)}7f`
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
// ../core/hmac.ts
|
|
57
|
+
async function hmacHex(secret, payload) {
|
|
58
|
+
const raw = typeof secret === "string" ? new TextEncoder().encode(secret) : secret;
|
|
59
|
+
const key = await crypto.subtle.importKey(
|
|
60
|
+
"raw",
|
|
61
|
+
asBuffer(raw),
|
|
62
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
63
|
+
false,
|
|
64
|
+
["sign"]
|
|
65
|
+
);
|
|
66
|
+
const message = typeof payload === "string" ? new TextEncoder().encode(payload) : payload;
|
|
67
|
+
return bytesToHex(new Uint8Array(await crypto.subtle.sign("HMAC", key, asBuffer(message))));
|
|
68
|
+
}
|
|
69
|
+
function asBuffer(bytes) {
|
|
70
|
+
return bytes instanceof Uint8Array && bytes.buffer instanceof ArrayBuffer ? bytes : new Uint8Array(bytes);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ../core/sha256.ts
|
|
74
|
+
var ROUND_CONSTANTS = new Uint32Array([
|
|
75
|
+
1116352408,
|
|
76
|
+
1899447441,
|
|
77
|
+
3049323471,
|
|
78
|
+
3921009573,
|
|
79
|
+
961987163,
|
|
80
|
+
1508970993,
|
|
81
|
+
2453635748,
|
|
82
|
+
2870763221,
|
|
83
|
+
3624381080,
|
|
84
|
+
310598401,
|
|
85
|
+
607225278,
|
|
86
|
+
1426881987,
|
|
87
|
+
1925078388,
|
|
88
|
+
2162078206,
|
|
89
|
+
2614888103,
|
|
90
|
+
3248222580,
|
|
91
|
+
3835390401,
|
|
92
|
+
4022224774,
|
|
93
|
+
264347078,
|
|
94
|
+
604807628,
|
|
95
|
+
770255983,
|
|
96
|
+
1249150122,
|
|
97
|
+
1555081692,
|
|
98
|
+
1996064986,
|
|
99
|
+
2554220882,
|
|
100
|
+
2821834349,
|
|
101
|
+
2952996808,
|
|
102
|
+
3210313671,
|
|
103
|
+
3336571891,
|
|
104
|
+
3584528711,
|
|
105
|
+
113926993,
|
|
106
|
+
338241895,
|
|
107
|
+
666307205,
|
|
108
|
+
773529912,
|
|
109
|
+
1294757372,
|
|
110
|
+
1396182291,
|
|
111
|
+
1695183700,
|
|
112
|
+
1986661051,
|
|
113
|
+
2177026350,
|
|
114
|
+
2456956037,
|
|
115
|
+
2730485921,
|
|
116
|
+
2820302411,
|
|
117
|
+
3259730800,
|
|
118
|
+
3345764771,
|
|
119
|
+
3516065817,
|
|
120
|
+
3600352804,
|
|
121
|
+
4094571909,
|
|
122
|
+
275423344,
|
|
123
|
+
430227734,
|
|
124
|
+
506948616,
|
|
125
|
+
659060556,
|
|
126
|
+
883997877,
|
|
127
|
+
958139571,
|
|
128
|
+
1322822218,
|
|
129
|
+
1537002063,
|
|
130
|
+
1747873779,
|
|
131
|
+
1955562222,
|
|
132
|
+
2024104815,
|
|
133
|
+
2227730452,
|
|
134
|
+
2361852424,
|
|
135
|
+
2428436474,
|
|
136
|
+
2756734187,
|
|
137
|
+
3204031479,
|
|
138
|
+
3329325298
|
|
139
|
+
]);
|
|
140
|
+
var INITIAL_STATE = new Uint32Array([
|
|
141
|
+
1779033703,
|
|
142
|
+
3144134277,
|
|
143
|
+
1013904242,
|
|
144
|
+
2773480762,
|
|
145
|
+
1359893119,
|
|
146
|
+
2600822924,
|
|
147
|
+
528734635,
|
|
148
|
+
1541459225
|
|
149
|
+
]);
|
|
150
|
+
|
|
151
|
+
// ../core/sealed.ts
|
|
152
|
+
var MIN_SECRET_CHARS = 32;
|
|
153
|
+
var INFO = new TextEncoder().encode("thunder-bridge/sealed");
|
|
154
|
+
function refuseAWeakSecret(secret) {
|
|
155
|
+
if (secret.length < MIN_SECRET_CHARS) {
|
|
156
|
+
throw new Error(`the sealing secret needs ${MIN_SECRET_CHARS} characters of randomness`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/bank.ts
|
|
161
|
+
var DEFAULT_CURRENCY = "CZK";
|
|
162
|
+
var DEFAULT_LOOK_BACK_SECS = 7 * 24 * 60 * 60;
|
|
163
|
+
function bankAgent(config) {
|
|
164
|
+
refuseAWeakSecret(config.secret);
|
|
165
|
+
return config.gateway.attend({
|
|
166
|
+
onError: config.onError,
|
|
167
|
+
answer: async (paymentHash) => {
|
|
168
|
+
const order = await config.orders(paymentHash);
|
|
169
|
+
if (order === null) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
const currency = order.currency ?? DEFAULT_CURRENCY;
|
|
173
|
+
return await creditedPreimage({
|
|
174
|
+
secret: config.secret,
|
|
175
|
+
asked: {
|
|
176
|
+
iban: accountOf(order.iban),
|
|
177
|
+
reference: order.reference,
|
|
178
|
+
amountMinor: order.amountMinor,
|
|
179
|
+
currency,
|
|
180
|
+
expiresAt: order.expiresAt
|
|
181
|
+
},
|
|
182
|
+
statement: order.statement,
|
|
183
|
+
lookBackSecs: config.lookBackSecs
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
async function creditedPreimage(params) {
|
|
189
|
+
const since = unixNow() - (params.lookBackSecs ?? DEFAULT_LOOK_BACK_SECS);
|
|
190
|
+
const landed = (await params.statement(since)).some((credit) => pays(credit, params.asked));
|
|
191
|
+
if (!landed) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
return await hmacHex(params.secret, `preimage|${subjectOf(params.asked)}`);
|
|
195
|
+
}
|
|
196
|
+
function pays(credit, asked) {
|
|
197
|
+
return credit.amountMinor === asked.amountMinor && credit.currency.toUpperCase() === asked.currency.toUpperCase() && namesOnly(credit.reference, asked.reference);
|
|
198
|
+
}
|
|
199
|
+
function namesOnly(written, reference) {
|
|
200
|
+
const wanted = reference.toUpperCase();
|
|
201
|
+
const alike = [...written.toUpperCase().matchAll(wordsShapedLike(wanted))].map(([word]) => word);
|
|
202
|
+
return alike.includes(wanted) && (!/\d/.test(wanted) || alike.every((word) => word === wanted));
|
|
203
|
+
}
|
|
204
|
+
function wordsShapedLike(reference) {
|
|
205
|
+
const shape = [...reference].map((char) => {
|
|
206
|
+
if (/\d/.test(char)) {
|
|
207
|
+
return "\\d";
|
|
208
|
+
}
|
|
209
|
+
return /\p{L}/u.test(char) ? "\\p{L}" : char.replace(/[\^$\\.*+?()[\]{}|/]/g, "\\$&");
|
|
210
|
+
}).join("");
|
|
211
|
+
return new RegExp(`(?<![\\p{L}\\p{N}])${shape}(?![\\p{L}\\p{N}])`, "gu");
|
|
212
|
+
}
|
|
213
|
+
function subjectOf({ iban, amountMinor, currency, expiresAt, reference }) {
|
|
214
|
+
return `${iban}|${amountMinor}|${currency.toUpperCase()}|${expiresAt}|${reference}`;
|
|
215
|
+
}
|
|
216
|
+
function accountOf(iban) {
|
|
217
|
+
return iban.replace(/\s+/g, "").toUpperCase();
|
|
218
|
+
}
|
|
219
|
+
function unixNow() {
|
|
220
|
+
return Math.floor(Date.now() / 1e3);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/fio.ts
|
|
224
|
+
var BASE_URL = "https://fioapi.fio.cz/v1/rest";
|
|
225
|
+
var MINOR_UNITS = 100;
|
|
226
|
+
var MILLIS = 1e3;
|
|
227
|
+
var DATE_CHARS = "2026-08-04".length;
|
|
228
|
+
var DEFAULT_MIN_INTERVAL_SECS = 30;
|
|
229
|
+
var TOO_SOON = 409;
|
|
230
|
+
var BOOKED_AT = "column0";
|
|
231
|
+
var AMOUNT = "column1";
|
|
232
|
+
var CURRENCY = "column14";
|
|
233
|
+
var VARIABLE_SYMBOL = "column5";
|
|
234
|
+
var USER_IDENTIFICATION = "column7";
|
|
235
|
+
var MESSAGE_FOR_RECIPIENT = "column16";
|
|
236
|
+
var PAYER_REFERENCE = "column27";
|
|
237
|
+
var WHERE_A_PAYER_WRITES = [
|
|
238
|
+
MESSAGE_FOR_RECIPIENT,
|
|
239
|
+
VARIABLE_SYMBOL,
|
|
240
|
+
USER_IDENTIFICATION,
|
|
241
|
+
PAYER_REFERENCE
|
|
242
|
+
];
|
|
243
|
+
var UTC_OFFSET = /^[+-]\d{4}$/;
|
|
244
|
+
function fioStatement(config) {
|
|
245
|
+
const named = typeof config.token === "string" ? [config.token] : config.token;
|
|
246
|
+
if (named.length === 0) {
|
|
247
|
+
throw new Error("fioStatement needs at least one token to read with");
|
|
248
|
+
}
|
|
249
|
+
const usedAt = new Map(named.map((token) => [token, Number.NEGATIVE_INFINITY]));
|
|
250
|
+
const tokenWindowMs = (config.minIntervalSecs ?? DEFAULT_MIN_INTERVAL_SECS) * MILLIS;
|
|
251
|
+
const paceMs = tokenWindowMs / usedAt.size;
|
|
252
|
+
let lastRead = Number.NEGATIVE_INFINITY;
|
|
253
|
+
let credits = [];
|
|
254
|
+
return async (sinceUnix) => {
|
|
255
|
+
const now = Date.now();
|
|
256
|
+
if (now - lastRead < paceMs) {
|
|
257
|
+
return credits;
|
|
258
|
+
}
|
|
259
|
+
const idlest = longestUnused(usedAt);
|
|
260
|
+
if (now - idlest.usedAt < tokenWindowMs) {
|
|
261
|
+
return credits;
|
|
262
|
+
}
|
|
263
|
+
usedAt.set(idlest.token, now);
|
|
264
|
+
lastRead = now;
|
|
265
|
+
const url = [
|
|
266
|
+
config.baseUrl ?? BASE_URL,
|
|
267
|
+
"periods",
|
|
268
|
+
idlest.token,
|
|
269
|
+
asDate(sinceUnix),
|
|
270
|
+
asDate(Math.floor(now / MILLIS)),
|
|
271
|
+
"transactions.json"
|
|
272
|
+
].join("/");
|
|
273
|
+
const answer = await fetch(url, { headers: { accept: "application/json" } });
|
|
274
|
+
if (answer.status === TOO_SOON) {
|
|
275
|
+
throw new Error("fio refuses a second read of this token inside its 30 second window");
|
|
276
|
+
}
|
|
277
|
+
if (!answer.ok) {
|
|
278
|
+
throw new Error(`fio answered ${answer.status} reading the statement`);
|
|
279
|
+
}
|
|
280
|
+
const read = await answer.json();
|
|
281
|
+
credits = (read.accountStatement?.transactionList?.transaction ?? []).filter(isCredit).map(asCredit);
|
|
282
|
+
return credits;
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function longestUnused(usedAt) {
|
|
286
|
+
let token = "";
|
|
287
|
+
let idleSince = Number.POSITIVE_INFINITY;
|
|
288
|
+
for (const [candidate, at] of usedAt) {
|
|
289
|
+
if (at < idleSince) {
|
|
290
|
+
token = candidate;
|
|
291
|
+
idleSince = at;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return { token, usedAt: idleSince };
|
|
295
|
+
}
|
|
296
|
+
function isCredit(transaction) {
|
|
297
|
+
return numberIn(transaction[AMOUNT]) > 0;
|
|
298
|
+
}
|
|
299
|
+
function asCredit(transaction) {
|
|
300
|
+
return {
|
|
301
|
+
amountMinor: Math.round(numberIn(transaction[AMOUNT]) * MINOR_UNITS),
|
|
302
|
+
currency: textIn(transaction[CURRENCY]),
|
|
303
|
+
reference: WHERE_A_PAYER_WRITES.map((column) => textIn(transaction[column])).filter((written) => written.length > 0).join(" "),
|
|
304
|
+
bookedAt: bookedAtIn(transaction[BOOKED_AT])
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function bookedAtIn(cell) {
|
|
308
|
+
const value = cell?.value;
|
|
309
|
+
if (typeof value === "number") {
|
|
310
|
+
return Math.floor(value / MILLIS);
|
|
311
|
+
}
|
|
312
|
+
const at = Date.parse(asIso8601(textIn(cell)));
|
|
313
|
+
return Number.isFinite(at) ? Math.floor(at / MILLIS) : 0;
|
|
314
|
+
}
|
|
315
|
+
function asIso8601(booked) {
|
|
316
|
+
const day = booked.slice(0, DATE_CHARS);
|
|
317
|
+
const zone = booked.slice(DATE_CHARS);
|
|
318
|
+
if (!UTC_OFFSET.test(zone)) {
|
|
319
|
+
return `${day}T00:00:00Z`;
|
|
320
|
+
}
|
|
321
|
+
return `${day}T00:00:00${zone.slice(0, 3)}:${zone.slice(3)}`;
|
|
322
|
+
}
|
|
323
|
+
function numberIn(cell) {
|
|
324
|
+
const value = Number(cell?.value ?? Number.NaN);
|
|
325
|
+
return Number.isFinite(value) ? value : 0;
|
|
326
|
+
}
|
|
327
|
+
function textIn(cell) {
|
|
328
|
+
const value = cell?.value;
|
|
329
|
+
return value === null || value === void 0 ? "" : String(value).trim();
|
|
330
|
+
}
|
|
331
|
+
function asDate(unix) {
|
|
332
|
+
return new Date(unix * MILLIS).toISOString().slice(0, DATE_CHARS);
|
|
333
|
+
}
|
|
334
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
335
|
+
0 && (module.exports = {
|
|
336
|
+
bankAgent,
|
|
337
|
+
fioStatement
|
|
338
|
+
});
|
package/dist/bank.d.cts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { S as Statement } from './bank-CEIuNhV_.cjs';
|
|
2
|
+
export { B as BankAgentConfig, a as BankOrder, b as BankTransfer, c as BankTransferParams, d as BankVerifyConfig, C as Credit, e as bankAgent } from './bank-CEIuNhV_.cjs';
|
|
3
|
+
import './qr-CF-YeXU1.cjs';
|
|
4
|
+
import './types-DYZ9EkmJ.cjs';
|
|
5
|
+
|
|
6
|
+
/** A Fio account to read credits from, as its own API describes one */
|
|
7
|
+
interface FioConfig {
|
|
8
|
+
/**
|
|
9
|
+
* A token with "Sledování účtu" rights, which is read only and cannot move
|
|
10
|
+
* money. One token is one account, which is why this takes no account number.
|
|
11
|
+
*
|
|
12
|
+
* Give it several and they are used in turn. Fio's window is per token rather
|
|
13
|
+
* than per account, so five tokens on one account is a read every six seconds,
|
|
14
|
+
* and generating another token for the same account is what Fio's own
|
|
15
|
+
* documentation suggests when one is not enough
|
|
16
|
+
*/
|
|
17
|
+
token: string | string[];
|
|
18
|
+
/**
|
|
19
|
+
* Fio's window for one token, 30 seconds. No token is ever asked twice inside
|
|
20
|
+
* it, and the gap between reads is this divided by however many tokens were
|
|
21
|
+
* given, so the answers stay evenly spaced rather than arriving in bursts.
|
|
22
|
+
* Inside that gap the last answer is handed back. Only helps a process that
|
|
23
|
+
* stays up
|
|
24
|
+
*/
|
|
25
|
+
minIntervalSecs?: number;
|
|
26
|
+
/** Override to point at a mock */
|
|
27
|
+
baseUrl?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Read one Fio account as a `Statement`, so a bank transfer proves itself the
|
|
31
|
+
* way a Lightning payment does.
|
|
32
|
+
*
|
|
33
|
+
* The token is the read only kind, generated in internetbanking under Nastavení
|
|
34
|
+
* and API, and it is the whole configuration: a token belongs to one account, so
|
|
35
|
+
* there is no account number to get wrong. It cannot pay anyone, and the worst a
|
|
36
|
+
* leaked one costs you is that someone else can read the statement.
|
|
37
|
+
*
|
|
38
|
+
* Every field on a Fio transaction is optional and arrives as `null` when it is
|
|
39
|
+
* absent, the amount carries its direction in its sign rather than in a flag,
|
|
40
|
+
* and the date is a day and a UTC offset, `2026-07-15+0200`. This reads all
|
|
41
|
+
* three the way the bank answers them and treats a missing field as absent
|
|
42
|
+
* rather than guessing.
|
|
43
|
+
*/
|
|
44
|
+
declare function fioStatement(config: FioConfig): Statement;
|
|
45
|
+
|
|
46
|
+
export { type FioConfig, Statement, fioStatement };
|
package/dist/bank.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { S as Statement } from './bank-M8flcMks.js';
|
|
2
|
+
export { B as BankAgentConfig, a as BankOrder, b as BankTransfer, c as BankTransferParams, d as BankVerifyConfig, C as Credit, e as bankAgent } from './bank-M8flcMks.js';
|
|
3
|
+
import './qr-CF-YeXU1.js';
|
|
4
|
+
import './types-DYZ9EkmJ.js';
|
|
5
|
+
|
|
6
|
+
/** A Fio account to read credits from, as its own API describes one */
|
|
7
|
+
interface FioConfig {
|
|
8
|
+
/**
|
|
9
|
+
* A token with "Sledování účtu" rights, which is read only and cannot move
|
|
10
|
+
* money. One token is one account, which is why this takes no account number.
|
|
11
|
+
*
|
|
12
|
+
* Give it several and they are used in turn. Fio's window is per token rather
|
|
13
|
+
* than per account, so five tokens on one account is a read every six seconds,
|
|
14
|
+
* and generating another token for the same account is what Fio's own
|
|
15
|
+
* documentation suggests when one is not enough
|
|
16
|
+
*/
|
|
17
|
+
token: string | string[];
|
|
18
|
+
/**
|
|
19
|
+
* Fio's window for one token, 30 seconds. No token is ever asked twice inside
|
|
20
|
+
* it, and the gap between reads is this divided by however many tokens were
|
|
21
|
+
* given, so the answers stay evenly spaced rather than arriving in bursts.
|
|
22
|
+
* Inside that gap the last answer is handed back. Only helps a process that
|
|
23
|
+
* stays up
|
|
24
|
+
*/
|
|
25
|
+
minIntervalSecs?: number;
|
|
26
|
+
/** Override to point at a mock */
|
|
27
|
+
baseUrl?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Read one Fio account as a `Statement`, so a bank transfer proves itself the
|
|
31
|
+
* way a Lightning payment does.
|
|
32
|
+
*
|
|
33
|
+
* The token is the read only kind, generated in internetbanking under Nastavení
|
|
34
|
+
* and API, and it is the whole configuration: a token belongs to one account, so
|
|
35
|
+
* there is no account number to get wrong. It cannot pay anyone, and the worst a
|
|
36
|
+
* leaked one costs you is that someone else can read the statement.
|
|
37
|
+
*
|
|
38
|
+
* Every field on a Fio transaction is optional and arrives as `null` when it is
|
|
39
|
+
* absent, the amount carries its direction in its sign rather than in a flag,
|
|
40
|
+
* and the date is a day and a UTC offset, `2026-07-15+0200`. This reads all
|
|
41
|
+
* three the way the bank answers them and treats a missing field as absent
|
|
42
|
+
* rather than guessing.
|
|
43
|
+
*/
|
|
44
|
+
declare function fioStatement(config: FioConfig): Statement;
|
|
45
|
+
|
|
46
|
+
export { type FioConfig, Statement, fioStatement };
|