@open-banking-io/client 0.2.0 → 0.3.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 +11 -4
- package/dist/index.cjs +34 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +34 -18
- package/dist/index.js.map +1 -1
- package/package.json +14 -10
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://open-banking.io">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/open-banking-io/clients/main/.github/logo.png" alt="open-banking.io" height="56">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
1
7
|
# @open-banking-io/client (Node / TypeScript)
|
|
2
8
|
|
|
3
9
|
Server-to-server client for [open-banking.io](https://open-banking.io). It authenticates with your
|
|
@@ -49,9 +55,10 @@ library to avoid precision loss.
|
|
|
49
55
|
|
|
50
56
|
## Encryption
|
|
51
57
|
|
|
52
|
-
Envelopes use **ECDH P-256 → HKDF-SHA256 → AES-256-GCM
|
|
53
|
-
your credentials bundle and happens entirely
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
Envelopes use **ECDH P-256 → HKDF-SHA256 → AES-256-GCM**, implemented with the built-in `node:crypto`
|
|
59
|
+
WebCrypto. Decryption requires the private key from your credentials bundle and happens entirely
|
|
60
|
+
in-process. Full wire format and the other language clients:
|
|
61
|
+
[repo README](https://github.com/open-banking-io/clients) ·
|
|
62
|
+
[`THREAT_MODEL.md`](https://github.com/open-banking-io/clients/blob/main/THREAT_MODEL.md).
|
|
56
63
|
|
|
57
64
|
MIT licensed.
|
package/dist/index.cjs
CHANGED
|
@@ -97,7 +97,7 @@ function base64ToBytes(b64) {
|
|
|
97
97
|
// package.json
|
|
98
98
|
var package_default = {
|
|
99
99
|
name: "@open-banking-io/client",
|
|
100
|
-
version: "0.
|
|
100
|
+
version: "0.3.1",
|
|
101
101
|
description: "Server-to-server client for open-banking.io: API-key auth + client-side decryption of the zero-knowledge data envelopes with your exported private key.",
|
|
102
102
|
type: "module",
|
|
103
103
|
license: "MIT",
|
|
@@ -138,17 +138,21 @@ var package_default = {
|
|
|
138
138
|
lint: "eslint .",
|
|
139
139
|
"format:check": "prettier --check ."
|
|
140
140
|
},
|
|
141
|
+
overrides: {
|
|
142
|
+
esbuild: "^0.28.1"
|
|
143
|
+
},
|
|
141
144
|
devDependencies: {
|
|
142
|
-
"@eslint/js": "^
|
|
143
|
-
"@types/node": "^25.9.
|
|
144
|
-
"@vitest/coverage-v8": "^
|
|
145
|
-
eslint: "^
|
|
145
|
+
"@eslint/js": "^10.0.1",
|
|
146
|
+
"@types/node": "^25.9.3",
|
|
147
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
148
|
+
eslint: "^10.5.0",
|
|
146
149
|
prettier: "^3.8.4",
|
|
147
|
-
tsup: "^8.
|
|
148
|
-
typescript: "^
|
|
149
|
-
"typescript-eslint": "^8.61.
|
|
150
|
-
vitest: "^
|
|
151
|
-
}
|
|
150
|
+
tsup: "^8.5.1",
|
|
151
|
+
typescript: "^6.0.3",
|
|
152
|
+
"typescript-eslint": "^8.61.1",
|
|
153
|
+
vitest: "^4.1.9"
|
|
154
|
+
},
|
|
155
|
+
homepage: "https://open-banking.io"
|
|
152
156
|
};
|
|
153
157
|
|
|
154
158
|
// src/version.ts
|
|
@@ -162,32 +166,44 @@ var OpenBankingClient = class _OpenBankingClient {
|
|
|
162
166
|
baseUrl;
|
|
163
167
|
apiKey;
|
|
164
168
|
timeoutMs;
|
|
169
|
+
fetchImpl;
|
|
165
170
|
privateKey;
|
|
166
171
|
constructor(options) {
|
|
167
172
|
const { apiBaseUrl, apiKey, privateKeyPkcs8, timeoutMs } = options;
|
|
168
173
|
if (!apiBaseUrl?.trim()) throw new Error("apiBaseUrl is required");
|
|
169
174
|
if (!apiKey?.trim()) throw new Error("apiKey is required");
|
|
170
175
|
if (!privateKeyPkcs8?.trim()) throw new Error("privateKeyPkcs8 is required");
|
|
171
|
-
|
|
176
|
+
let end = apiBaseUrl.length;
|
|
177
|
+
while (end > 0 && apiBaseUrl.charCodeAt(end - 1) === 47) end--;
|
|
178
|
+
this.baseUrl = apiBaseUrl.slice(0, end);
|
|
172
179
|
this.apiKey = apiKey;
|
|
173
180
|
this.timeoutMs = timeoutMs ?? _OpenBankingClient.DEFAULT_TIMEOUT_MS;
|
|
181
|
+
this.fetchImpl = options.fetch ?? fetch;
|
|
174
182
|
this.privateKey = importPrivateKey(privateKeyPkcs8);
|
|
175
183
|
}
|
|
176
|
-
/**
|
|
177
|
-
|
|
184
|
+
/**
|
|
185
|
+
* Builds a client from a credentials-bundle JSON string or a path to a bundle file.
|
|
186
|
+
*
|
|
187
|
+
* `overrides` (optional) lets the bundle path set the same transport knobs as the
|
|
188
|
+
* constructor — e.g. a custom {@link OpenBankingClientOptions.fetch} or
|
|
189
|
+
* {@link OpenBankingClientOptions.timeoutMs}.
|
|
190
|
+
*/
|
|
191
|
+
static fromCredentials(jsonOrPath, overrides = {}) {
|
|
178
192
|
let json = jsonOrPath;
|
|
179
193
|
if (!jsonOrPath.trimStart().startsWith("{")) {
|
|
180
194
|
json = (0, import_node_fs.readFileSync)(jsonOrPath, "utf8");
|
|
181
195
|
}
|
|
182
196
|
const bundle = JSON.parse(json);
|
|
183
|
-
return _OpenBankingClient.fromBundle(bundle);
|
|
197
|
+
return _OpenBankingClient.fromBundle(bundle, overrides);
|
|
184
198
|
}
|
|
185
|
-
static fromBundle(bundle) {
|
|
199
|
+
static fromBundle(bundle, overrides = {}) {
|
|
186
200
|
if (!bundle.apiKey?.trim()) throw new Error("The credentials bundle has no apiKey");
|
|
187
201
|
return new _OpenBankingClient({
|
|
188
202
|
apiBaseUrl: bundle.apiBaseUrl,
|
|
189
203
|
apiKey: bundle.apiKey,
|
|
190
|
-
privateKeyPkcs8: bundle.encryptionKey.privateKey
|
|
204
|
+
privateKeyPkcs8: bundle.encryptionKey.privateKey,
|
|
205
|
+
timeoutMs: overrides.timeoutMs,
|
|
206
|
+
fetch: overrides.fetch
|
|
191
207
|
});
|
|
192
208
|
}
|
|
193
209
|
/** Lists the user's accounts with all sensitive fields decrypted. */
|
|
@@ -322,7 +338,7 @@ var OpenBankingClient = class _OpenBankingClient {
|
|
|
322
338
|
};
|
|
323
339
|
}
|
|
324
340
|
async getJson(path) {
|
|
325
|
-
const res = await
|
|
341
|
+
const res = await this.fetchImpl(this.baseUrl + path, {
|
|
326
342
|
headers: { "X-Api-Key": this.apiKey, "User-Agent": USER_AGENT },
|
|
327
343
|
signal: AbortSignal.timeout(this.timeoutMs)
|
|
328
344
|
});
|
|
@@ -332,7 +348,7 @@ var OpenBankingClient = class _OpenBankingClient {
|
|
|
332
348
|
return await res.json();
|
|
333
349
|
}
|
|
334
350
|
async postJson(path, body) {
|
|
335
|
-
const res = await
|
|
351
|
+
const res = await this.fetchImpl(this.baseUrl + path, {
|
|
336
352
|
method: "POST",
|
|
337
353
|
headers: {
|
|
338
354
|
"X-Api-Key": this.apiKey,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/envelope.ts","../package.json","../src/version.ts"],"sourcesContent":["export { OpenBankingClient } from \"./client.js\";\nexport { decryptEnvelope, decryptTo, importPrivateKey } from \"./envelope.js\";\nexport type {\n Account,\n Balance,\n Transaction,\n TransactionPage,\n TransactionQuery,\n Connection,\n SyncResult,\n SyncAllResult,\n CredentialsBundle,\n EncryptionKey,\n OpenBankingClientOptions,\n} from \"./models.js\";\n","import { readFileSync } from \"node:fs\";\nimport { decryptTo, importPrivateKey, type CryptoKey } from \"./envelope.js\";\nimport { USER_AGENT } from \"./version.js\";\nimport type {\n Account,\n AccountEnc,\n AccountWire,\n BalanceEnc,\n Connection,\n ConnectionWire,\n CredentialsBundle,\n DisplayNameEnc,\n OpenBankingClientOptions,\n SyncAllResult,\n SyncAllResultWire,\n SyncResult,\n SyncResultWire,\n Transaction,\n TransactionEnc,\n TransactionPage,\n TransactionPageWire,\n TransactionQuery,\n TransactionWire,\n UidEnc,\n} from \"./models.js\";\n\n/**\n * Server-to-server client for open-banking.io. Authenticates with an API key (`X-Api-Key`) and\n * decrypts the zero-knowledge data envelopes locally with the exported private key — the service\n * only ever returns ciphertext it cannot read.\n */\nexport class OpenBankingClient {\n /** Default per-request timeout (30s) when {@link OpenBankingClientOptions.timeoutMs} is unset. */\n static readonly DEFAULT_TIMEOUT_MS = 30_000;\n\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeoutMs: number;\n private readonly privateKey: Promise<CryptoKey>;\n\n constructor(options: OpenBankingClientOptions) {\n const { apiBaseUrl, apiKey, privateKeyPkcs8, timeoutMs } = options;\n if (!apiBaseUrl?.trim()) throw new Error(\"apiBaseUrl is required\");\n if (!apiKey?.trim()) throw new Error(\"apiKey is required\");\n if (!privateKeyPkcs8?.trim()) throw new Error(\"privateKeyPkcs8 is required\");\n\n this.baseUrl = apiBaseUrl.replace(/\\/+$/, \"\");\n this.apiKey = apiKey;\n this.timeoutMs = timeoutMs ?? OpenBankingClient.DEFAULT_TIMEOUT_MS;\n this.privateKey = importPrivateKey(privateKeyPkcs8);\n }\n\n /** Builds a client from a credentials-bundle JSON string or a path to a bundle file. */\n static fromCredentials(jsonOrPath: string): OpenBankingClient {\n let json = jsonOrPath;\n if (!jsonOrPath.trimStart().startsWith(\"{\")) {\n json = readFileSync(jsonOrPath, \"utf8\");\n }\n const bundle = JSON.parse(json) as CredentialsBundle;\n return OpenBankingClient.fromBundle(bundle);\n }\n\n static fromBundle(bundle: CredentialsBundle): OpenBankingClient {\n if (!bundle.apiKey?.trim()) throw new Error(\"The credentials bundle has no apiKey\");\n return new OpenBankingClient({\n apiBaseUrl: bundle.apiBaseUrl,\n apiKey: bundle.apiKey,\n privateKeyPkcs8: bundle.encryptionKey.privateKey,\n });\n }\n\n /** Lists the user's accounts with all sensitive fields decrypted. */\n async getAccounts(): Promise<Account[]> {\n const wires = await this.getAccountWires();\n return Promise.all(wires.map((w) => this.mapAccount(w)));\n }\n\n /** Returns a page of an account's statement, newest first, with decrypted fields. */\n async getTransactions(accountId: string, query: TransactionQuery = {}): Promise<TransactionPage> {\n const qs = new URLSearchParams();\n if (query.from != null) qs.set(\"from\", query.from);\n if (query.to != null) qs.set(\"to\", query.to);\n if (query.limit != null) qs.set(\"limit\", String(query.limit));\n if (query.offset != null) qs.set(\"offset\", String(query.offset));\n const suffix = qs.toString() ? `?${qs.toString()}` : \"\";\n\n const page = await this.getJson<TransactionPageWire>(\n `/api/accounts/${encodeURIComponent(accountId)}/transactions${suffix}`,\n );\n\n const items = await Promise.all((page.items ?? []).map((t) => this.mapTransaction(t)));\n return { items, total: page.total };\n }\n\n /** Lists the user's bank connections. */\n async getConnections(): Promise<Connection[]> {\n const wires = await this.getJson<ConnectionWire[]>(\"/api/connections\");\n return wires.map((c) => ({\n sessionId: c.sessionId,\n aspspName: c.aspspName,\n aspspCountry: c.aspspCountry,\n validUntil: c.validUntil,\n status: c.status,\n accountCount: c.accountCount,\n lastSyncedAt: c.lastSyncedAt ?? null,\n psuType: c.psuType ?? null,\n }));\n }\n\n /**\n * Triggers an online sync of one account: decrypts that account's Enable Banking uid and posts\n * it, so the service can fetch fresh data without ever holding the uid in plaintext.\n */\n async sync(accountId: string): Promise<SyncResult> {\n const wires = await this.getAccountWires();\n const account = wires.find((a) => a.id === accountId);\n if (!account) throw new Error(`Account ${accountId} not found`);\n\n const uid = await this.decryptUid(account);\n if (uid == null) {\n throw new Error(\"Account has no active session (reconnect required) — cannot sync\");\n }\n\n const result = await this.postJson<SyncResultWire>(\n `/api/accounts/${encodeURIComponent(accountId)}/sync`,\n { uid },\n );\n return { newTransactions: result.newTransactions, totalFetched: result.totalFetched };\n }\n\n /** Triggers an online sync of every account that has an active session. */\n async syncAll(): Promise<SyncAllResult> {\n const wires = await this.getAccountWires();\n const decrypted = await Promise.all(\n wires.map(async (a) => ({ accountId: a.id, uid: await this.decryptUid(a) })),\n );\n const items = decrypted\n .filter((x): x is { accountId: string; uid: string } => x.uid != null)\n .map((x) => ({ accountId: x.accountId, uid: x.uid }));\n\n const result = await this.postJson<SyncAllResultWire>(\"/api/sync\", { items });\n return { accounts: result.accounts, newTransactions: result.newTransactions };\n }\n\n // ---- internals ---------------------------------------------------------------------------------\n\n private getAccountWires(): Promise<AccountWire[]> {\n return this.getJson<AccountWire[]>(\"/api/accounts\");\n }\n\n private async decryptUid(a: AccountWire): Promise<string | null> {\n const dec = await decryptTo<UidEnc>(await this.privateKey, a.uidEnc);\n return dec?.uid ?? null;\n }\n\n private async mapAccount(a: AccountWire): Promise<Account> {\n const priv = await this.privateKey;\n const acc = await decryptTo<AccountEnc>(priv, a.enc);\n const name = await decryptTo<DisplayNameEnc>(priv, a.displayNameEnc);\n const balances = await Promise.all(\n (a.balances ?? []).map(async (b) => {\n const dec = await decryptTo<BalanceEnc>(priv, b.enc);\n return {\n type: b.type,\n name: dec?.name ?? null,\n amount: dec?.amount ?? \"0\",\n currency: b.currency,\n referenceDate: b.referenceDate ?? null,\n };\n }),\n );\n\n return {\n id: a.id,\n aspspName: a.aspspName,\n aspspCountry: a.aspspCountry,\n currency: a.currency,\n accountType: a.accountType ?? null,\n bic: a.bic ?? null,\n needsReconnect: a.needsReconnect,\n iban: acc?.iban ?? null,\n bban: acc?.bban ?? null,\n ownerName: acc?.ownerName ?? null,\n accountName: acc?.accountName ?? null,\n product: acc?.product ?? null,\n displayName: name?.displayName ?? null,\n balances,\n };\n }\n\n private async mapTransaction(t: TransactionWire): Promise<Transaction> {\n const d = await decryptTo<TransactionEnc>(await this.privateKey, t.enc);\n return {\n id: t.id,\n currency: t.currency,\n creditDebitIndicator: t.creditDebitIndicator,\n status: t.status ?? null,\n bookingDate: t.bookingDate ?? null,\n valueDate: t.valueDate ?? null,\n transactionDate: t.transactionDate ?? null,\n bankTransactionCode: t.bankTransactionCode ?? null,\n amount: d?.amount ?? \"0\",\n creditorName: d?.creditorName ?? null,\n creditorIban: d?.creditorIban ?? null,\n creditorBban: d?.creditorBban ?? null,\n creditorAgentBic: d?.creditorAgentBic ?? null,\n debtorName: d?.debtorName ?? null,\n debtorIban: d?.debtorIban ?? null,\n debtorBban: d?.debtorBban ?? null,\n debtorAgentBic: d?.debtorAgentBic ?? null,\n remittanceInformation: d?.remittanceInformation ?? null,\n note: d?.note ?? null,\n referenceNumber: d?.referenceNumber ?? null,\n exchangeRate: d?.exchangeRate ?? null,\n merchantCategoryCode: d?.merchantCategoryCode ?? null,\n balanceAfterTransaction: d?.balanceAfter ?? null,\n balanceAfterCurrency: d?.balanceAfterCurrency ?? null,\n };\n }\n\n private async getJson<T>(path: string): Promise<T> {\n const res = await fetch(this.baseUrl + path, {\n headers: { \"X-Api-Key\": this.apiKey, \"User-Agent\": USER_AGENT },\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n if (!res.ok) {\n throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as T;\n }\n\n private async postJson<T>(path: string, body: unknown): Promise<T> {\n const res = await fetch(this.baseUrl + path, {\n method: \"POST\",\n headers: {\n \"X-Api-Key\": this.apiKey,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": USER_AGENT,\n },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n if (!res.ok) {\n throw new Error(`POST ${path} failed: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as T;\n }\n}\n","import { webcrypto } from \"node:crypto\";\n\nconst { subtle } = webcrypto;\n\n/** Re-export the WebCrypto key type so callers don't depend on the DOM lib. */\nexport type CryptoKey = webcrypto.CryptoKey;\n\nconst VERSION = 0x01;\nconst POINT_LEN = 65;\nconst NONCE_LEN = 12;\nconst TAG_LEN = 16;\n\nconst HKDF_INFO = new TextEncoder().encode(\"bank.core.ci/zk/v1\");\nconst HKDF_SALT = new Uint8Array(32); // 32 zero bytes (must be exactly this).\n\n/**\n * Decrypts open-banking.io's zero-knowledge data envelopes.\n * Scheme: ephemeral ECDH on NIST P-256 -> HKDF-SHA256 -> AES-256-GCM.\n * Wire: `version(1)=0x01 | ephemeralPublicKeyRaw(65) | nonce(12) | tag(16) | ciphertext`.\n * Only the user's private key can decrypt — the service stores ciphertext it cannot read.\n */\nexport async function decryptEnvelope(\n privateKey: CryptoKey,\n envelopeBase64: string,\n): Promise<Uint8Array> {\n const bytes = base64ToBytes(envelopeBase64);\n if (bytes.length < 1 + POINT_LEN + NONCE_LEN + TAG_LEN || bytes[0] !== VERSION) {\n throw new Error(\"Invalid or unsupported envelope\");\n }\n\n const ephPub = bytes.subarray(1, 1 + POINT_LEN);\n const nonce = bytes.subarray(1 + POINT_LEN, 1 + POINT_LEN + NONCE_LEN);\n const tag = bytes.subarray(1 + POINT_LEN + NONCE_LEN, 1 + POINT_LEN + NONCE_LEN + TAG_LEN);\n const ciphertext = bytes.subarray(1 + POINT_LEN + NONCE_LEN + TAG_LEN);\n\n // Guard against invalid-curve attacks: WebCrypto's P-256 `importKey` validates that the raw point\n // lies on the curve and is not the point at infinity, so a forged/off-curve ephemeral public key\n // throws here rather than yielding a derivable (and exploitable) shared secret below.\n const ephKey = await subtle.importKey(\n \"raw\",\n ephPub,\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [],\n );\n\n const shared = new Uint8Array(\n await subtle.deriveBits({ name: \"ECDH\", public: ephKey }, privateKey, 256),\n );\n\n const hkdf = await subtle.importKey(\"raw\", shared, \"HKDF\", false, [\"deriveKey\"]);\n\n const aesKey = await subtle.deriveKey(\n { name: \"HKDF\", hash: \"SHA-256\", salt: HKDF_SALT, info: HKDF_INFO },\n hkdf,\n { name: \"AES-GCM\", length: 256 },\n false,\n [\"decrypt\"],\n );\n\n // Web Crypto AES-GCM expects ciphertext||tag.\n const ctWithTag = new Uint8Array(ciphertext.length + tag.length);\n ctWithTag.set(ciphertext, 0);\n ctWithTag.set(tag, ciphertext.length);\n\n const plaintext = await subtle.decrypt(\n { name: \"AES-GCM\", iv: nonce, tagLength: 128 },\n aesKey,\n ctWithTag,\n );\n\n return new Uint8Array(plaintext);\n}\n\n/** Decrypts a base64 envelope and JSON-parses its payload. `null`/`undefined` in -> `null`. */\nexport async function decryptTo<T>(\n privateKey: CryptoKey,\n envelopeBase64: string | null | undefined,\n): Promise<T | null> {\n if (envelopeBase64 == null) return null;\n const plaintext = await decryptEnvelope(privateKey, envelopeBase64);\n return JSON.parse(new TextDecoder().decode(plaintext)) as T;\n}\n\n/** Imports a base64 PKCS#8 P-256 ECDH private key for use with {@link decryptEnvelope}. */\nexport async function importPrivateKey(pkcs8Base64: string): Promise<CryptoKey> {\n return subtle.importKey(\n \"pkcs8\",\n base64ToBytes(pkcs8Base64),\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [\"deriveBits\"],\n );\n}\n\nfunction base64ToBytes(b64: string): Uint8Array<ArrayBuffer> {\n return new Uint8Array(Buffer.from(b64, \"base64\"));\n}\n","{\n \"name\": \"@open-banking-io/client\",\n \"version\": \"0.2.0\",\n \"description\": \"Server-to-server client for open-banking.io: API-key auth + client-side decryption of the zero-knowledge data envelopes with your exported private key.\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"author\": \"open-banking.io\",\n \"keywords\": [\n \"open-banking\",\n \"psd2\",\n \"zero-knowledge\",\n \"encryption\",\n \"fintech\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/open-banking-io/clients\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest run\",\n \"coverage\": \"vitest run --coverage\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format:check\": \"prettier --check .\"\n },\n \"devDependencies\": {\n \"@eslint/js\": \"^9.39.4\",\n \"@types/node\": \"^25.9.2\",\n \"@vitest/coverage-v8\": \"^3.2.6\",\n \"eslint\": \"^9.39.4\",\n \"prettier\": \"^3.8.4\",\n \"tsup\": \"^8.3.5\",\n \"typescript\": \"^5.7.2\",\n \"typescript-eslint\": \"^8.61.0\",\n \"vitest\": \"^3.2.6\"\n }\n}\n","// The package version, sourced from package.json so it can never drift. tsup inlines the JSON at\n// build time (tree-shaken to the single string), and vitest/tsx resolve the import directly — so\n// this stays ESM/CJS-safe without a runtime file read.\nimport pkg from \"../package.json\" with { type: \"json\" };\n\nexport const VERSION: string = pkg.version;\n\n/** The `User-Agent` sent on every request: `open-banking-io/node/<version>`. */\nexport const USER_AGENT = `open-banking-io/node/${VERSION}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA6B;;;ACA7B,yBAA0B;AAE1B,IAAM,EAAE,OAAO,IAAI;AAKnB,IAAM,UAAU;AAChB,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,UAAU;AAEhB,IAAM,YAAY,IAAI,YAAY,EAAE,OAAO,oBAAoB;AAC/D,IAAM,YAAY,IAAI,WAAW,EAAE;AAQnC,eAAsB,gBACpB,YACA,gBACqB;AACrB,QAAM,QAAQ,cAAc,cAAc;AAC1C,MAAI,MAAM,SAAS,IAAI,YAAY,YAAY,WAAW,MAAM,CAAC,MAAM,SAAS;AAC9E,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,QAAM,SAAS,MAAM,SAAS,GAAG,IAAI,SAAS;AAC9C,QAAM,QAAQ,MAAM,SAAS,IAAI,WAAW,IAAI,YAAY,SAAS;AACrE,QAAM,MAAM,MAAM,SAAS,IA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B,GAAG,gBAAgB;AAAA,MAC5C,sBAAsB,GAAG,wBAAwB;AAAA,IACnD;AAAA,EACF;AAAA,EAEA,MAAc,QAAW,MAA0B;AACjD,UAAM,MAAM,MAAM,MAAM,KAAK,UAAU,MAAM;AAAA,MAC3C,SAAS,EAAE,aAAa,KAAK,QAAQ,cAAc,WAAW;AAAA,MAC9D,QAAQ,YAAY,QAAQ,KAAK,SAAS;AAAA,IAC5C,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,IAAI,MAAM,OAAO,IAAI,YAAY,IAAI,MAAM,IAAI,IAAI,UAAU,EAAE;AAAA,IACvE;AACA,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB;AAAA,EAEA,MAAc,SAAY,MAAc,MAA2B;AACjE,UAAM,MAAM,MAAM,MAAM,KAAK,UAAU,MAAM;AAAA,MAC3C,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,aAAa,KAAK;AAAA,QAClB,gBAAgB;AAAA,QAChB,cAAc;AAAA,MAChB;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,MACzB,QAAQ,YAAY,QAAQ,KAAK,SAAS;AAAA,IAC5C,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,IAAI,MAAM,QAAQ,IAAI,YAAY,IAAI,MAAM,IAAI,IAAI,UAAU,EAAE;AAAA,IACxE;AACA,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB;AACF;","names":["VERSION"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/envelope.ts","../package.json","../src/version.ts"],"sourcesContent":["export { OpenBankingClient } from \"./client.js\";\nexport { decryptEnvelope, decryptTo, importPrivateKey } from \"./envelope.js\";\nexport type {\n Account,\n Balance,\n Transaction,\n TransactionPage,\n TransactionQuery,\n Connection,\n SyncResult,\n SyncAllResult,\n CredentialsBundle,\n EncryptionKey,\n OpenBankingClientOptions,\n} from \"./models.js\";\n","import { readFileSync } from \"node:fs\";\nimport { decryptTo, importPrivateKey, type CryptoKey } from \"./envelope.js\";\nimport { USER_AGENT } from \"./version.js\";\nimport type {\n Account,\n AccountEnc,\n AccountWire,\n BalanceEnc,\n Connection,\n ConnectionWire,\n CredentialsBundle,\n DisplayNameEnc,\n OpenBankingClientOptions,\n SyncAllResult,\n SyncAllResultWire,\n SyncResult,\n SyncResultWire,\n Transaction,\n TransactionEnc,\n TransactionPage,\n TransactionPageWire,\n TransactionQuery,\n TransactionWire,\n UidEnc,\n} from \"./models.js\";\n\n/**\n * Server-to-server client for open-banking.io. Authenticates with an API key (`X-Api-Key`) and\n * decrypts the zero-knowledge data envelopes locally with the exported private key — the service\n * only ever returns ciphertext it cannot read.\n */\nexport class OpenBankingClient {\n /** Default per-request timeout (30s) when {@link OpenBankingClientOptions.timeoutMs} is unset. */\n static readonly DEFAULT_TIMEOUT_MS = 30_000;\n\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeoutMs: number;\n private readonly fetchImpl: typeof globalThis.fetch;\n private readonly privateKey: Promise<CryptoKey>;\n\n constructor(options: OpenBankingClientOptions) {\n const { apiBaseUrl, apiKey, privateKeyPkcs8, timeoutMs } = options;\n if (!apiBaseUrl?.trim()) throw new Error(\"apiBaseUrl is required\");\n if (!apiKey?.trim()) throw new Error(\"apiKey is required\");\n if (!privateKeyPkcs8?.trim()) throw new Error(\"privateKeyPkcs8 is required\");\n\n // Strip all trailing \"/\" without a backtracking regex (avoids ReDoS on long inputs).\n let end = apiBaseUrl.length;\n while (end > 0 && apiBaseUrl.charCodeAt(end - 1) === 47 /* \"/\" */) end--;\n this.baseUrl = apiBaseUrl.slice(0, end);\n this.apiKey = apiKey;\n this.timeoutMs = timeoutMs ?? OpenBankingClient.DEFAULT_TIMEOUT_MS;\n this.fetchImpl = options.fetch ?? fetch;\n this.privateKey = importPrivateKey(privateKeyPkcs8);\n }\n\n /**\n * Builds a client from a credentials-bundle JSON string or a path to a bundle file.\n *\n * `overrides` (optional) lets the bundle path set the same transport knobs as the\n * constructor — e.g. a custom {@link OpenBankingClientOptions.fetch} or\n * {@link OpenBankingClientOptions.timeoutMs}.\n */\n static fromCredentials(\n jsonOrPath: string,\n overrides: Partial<Pick<OpenBankingClientOptions, \"fetch\" | \"timeoutMs\">> = {},\n ): OpenBankingClient {\n let json = jsonOrPath;\n if (!jsonOrPath.trimStart().startsWith(\"{\")) {\n json = readFileSync(jsonOrPath, \"utf8\");\n }\n const bundle = JSON.parse(json) as CredentialsBundle;\n return OpenBankingClient.fromBundle(bundle, overrides);\n }\n\n static fromBundle(\n bundle: CredentialsBundle,\n overrides: Partial<Pick<OpenBankingClientOptions, \"fetch\" | \"timeoutMs\">> = {},\n ): OpenBankingClient {\n if (!bundle.apiKey?.trim()) throw new Error(\"The credentials bundle has no apiKey\");\n return new OpenBankingClient({\n apiBaseUrl: bundle.apiBaseUrl,\n apiKey: bundle.apiKey,\n privateKeyPkcs8: bundle.encryptionKey.privateKey,\n timeoutMs: overrides.timeoutMs,\n fetch: overrides.fetch,\n });\n }\n\n /** Lists the user's accounts with all sensitive fields decrypted. */\n async getAccounts(): Promise<Account[]> {\n const wires = await this.getAccountWires();\n return Promise.all(wires.map((w) => this.mapAccount(w)));\n }\n\n /** Returns a page of an account's statement, newest first, with decrypted fields. */\n async getTransactions(accountId: string, query: TransactionQuery = {}): Promise<TransactionPage> {\n const qs = new URLSearchParams();\n if (query.from != null) qs.set(\"from\", query.from);\n if (query.to != null) qs.set(\"to\", query.to);\n if (query.limit != null) qs.set(\"limit\", String(query.limit));\n if (query.offset != null) qs.set(\"offset\", String(query.offset));\n const suffix = qs.toString() ? `?${qs.toString()}` : \"\";\n\n const page = await this.getJson<TransactionPageWire>(\n `/api/accounts/${encodeURIComponent(accountId)}/transactions${suffix}`,\n );\n\n const items = await Promise.all((page.items ?? []).map((t) => this.mapTransaction(t)));\n return { items, total: page.total };\n }\n\n /** Lists the user's bank connections. */\n async getConnections(): Promise<Connection[]> {\n const wires = await this.getJson<ConnectionWire[]>(\"/api/connections\");\n return wires.map((c) => ({\n sessionId: c.sessionId,\n aspspName: c.aspspName,\n aspspCountry: c.aspspCountry,\n validUntil: c.validUntil,\n status: c.status,\n accountCount: c.accountCount,\n lastSyncedAt: c.lastSyncedAt ?? null,\n psuType: c.psuType ?? null,\n }));\n }\n\n /**\n * Triggers an online sync of one account: decrypts that account's Enable Banking uid and posts\n * it, so the service can fetch fresh data without ever holding the uid in plaintext.\n */\n async sync(accountId: string): Promise<SyncResult> {\n const wires = await this.getAccountWires();\n const account = wires.find((a) => a.id === accountId);\n if (!account) throw new Error(`Account ${accountId} not found`);\n\n const uid = await this.decryptUid(account);\n if (uid == null) {\n throw new Error(\"Account has no active session (reconnect required) — cannot sync\");\n }\n\n const result = await this.postJson<SyncResultWire>(\n `/api/accounts/${encodeURIComponent(accountId)}/sync`,\n { uid },\n );\n return { newTransactions: result.newTransactions, totalFetched: result.totalFetched };\n }\n\n /** Triggers an online sync of every account that has an active session. */\n async syncAll(): Promise<SyncAllResult> {\n const wires = await this.getAccountWires();\n const decrypted = await Promise.all(\n wires.map(async (a) => ({ accountId: a.id, uid: await this.decryptUid(a) })),\n );\n const items = decrypted\n .filter((x): x is { accountId: string; uid: string } => x.uid != null)\n .map((x) => ({ accountId: x.accountId, uid: x.uid }));\n\n const result = await this.postJson<SyncAllResultWire>(\"/api/sync\", { items });\n return { accounts: result.accounts, newTransactions: result.newTransactions };\n }\n\n // ---- internals ---------------------------------------------------------------------------------\n\n private getAccountWires(): Promise<AccountWire[]> {\n return this.getJson<AccountWire[]>(\"/api/accounts\");\n }\n\n private async decryptUid(a: AccountWire): Promise<string | null> {\n const dec = await decryptTo<UidEnc>(await this.privateKey, a.uidEnc);\n return dec?.uid ?? null;\n }\n\n private async mapAccount(a: AccountWire): Promise<Account> {\n const priv = await this.privateKey;\n const acc = await decryptTo<AccountEnc>(priv, a.enc);\n const name = await decryptTo<DisplayNameEnc>(priv, a.displayNameEnc);\n const balances = await Promise.all(\n (a.balances ?? []).map(async (b) => {\n const dec = await decryptTo<BalanceEnc>(priv, b.enc);\n return {\n type: b.type,\n name: dec?.name ?? null,\n amount: dec?.amount ?? \"0\",\n currency: b.currency,\n referenceDate: b.referenceDate ?? null,\n };\n }),\n );\n\n return {\n id: a.id,\n aspspName: a.aspspName,\n aspspCountry: a.aspspCountry,\n currency: a.currency,\n accountType: a.accountType ?? null,\n bic: a.bic ?? null,\n needsReconnect: a.needsReconnect,\n iban: acc?.iban ?? null,\n bban: acc?.bban ?? null,\n ownerName: acc?.ownerName ?? null,\n accountName: acc?.accountName ?? null,\n product: acc?.product ?? null,\n displayName: name?.displayName ?? null,\n balances,\n };\n }\n\n private async mapTransaction(t: TransactionWire): Promise<Transaction> {\n const d = await decryptTo<TransactionEnc>(await this.privateKey, t.enc);\n return {\n id: t.id,\n currency: t.currency,\n creditDebitIndicator: t.creditDebitIndicator,\n status: t.status ?? null,\n bookingDate: t.bookingDate ?? null,\n valueDate: t.valueDate ?? null,\n transactionDate: t.transactionDate ?? null,\n bankTransactionCode: t.bankTransactionCode ?? null,\n amount: d?.amount ?? \"0\",\n creditorName: d?.creditorName ?? null,\n creditorIban: d?.creditorIban ?? null,\n creditorBban: d?.creditorBban ?? null,\n creditorAgentBic: d?.creditorAgentBic ?? null,\n debtorName: d?.debtorName ?? null,\n debtorIban: d?.debtorIban ?? null,\n debtorBban: d?.debtorBban ?? null,\n debtorAgentBic: d?.debtorAgentBic ?? null,\n remittanceInformation: d?.remittanceInformation ?? null,\n note: d?.note ?? null,\n referenceNumber: d?.referenceNumber ?? null,\n exchangeRate: d?.exchangeRate ?? null,\n merchantCategoryCode: d?.merchantCategoryCode ?? null,\n balanceAfterTransaction: d?.balanceAfter ?? null,\n balanceAfterCurrency: d?.balanceAfterCurrency ?? null,\n };\n }\n\n private async getJson<T>(path: string): Promise<T> {\n const res = await this.fetchImpl(this.baseUrl + path, {\n headers: { \"X-Api-Key\": this.apiKey, \"User-Agent\": USER_AGENT },\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n if (!res.ok) {\n throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as T;\n }\n\n private async postJson<T>(path: string, body: unknown): Promise<T> {\n const res = await this.fetchImpl(this.baseUrl + path, {\n method: \"POST\",\n headers: {\n \"X-Api-Key\": this.apiKey,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": USER_AGENT,\n },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n if (!res.ok) {\n throw new Error(`POST ${path} failed: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as T;\n }\n}\n","import { webcrypto } from \"node:crypto\";\n\nconst { subtle } = webcrypto;\n\n/** Re-export the WebCrypto key type so callers don't depend on the DOM lib. */\nexport type CryptoKey = webcrypto.CryptoKey;\n\nconst VERSION = 0x01;\nconst POINT_LEN = 65;\nconst NONCE_LEN = 12;\nconst TAG_LEN = 16;\n\nconst HKDF_INFO = new TextEncoder().encode(\"bank.core.ci/zk/v1\");\nconst HKDF_SALT = new Uint8Array(32); // 32 zero bytes (must be exactly this).\n\n/**\n * Decrypts open-banking.io's zero-knowledge data envelopes.\n * Scheme: ephemeral ECDH on NIST P-256 -> HKDF-SHA256 -> AES-256-GCM.\n * Wire: `version(1)=0x01 | ephemeralPublicKeyRaw(65) | nonce(12) | tag(16) | ciphertext`.\n * Only the user's private key can decrypt — the service stores ciphertext it cannot read.\n */\nexport async function decryptEnvelope(\n privateKey: CryptoKey,\n envelopeBase64: string,\n): Promise<Uint8Array> {\n const bytes = base64ToBytes(envelopeBase64);\n if (bytes.length < 1 + POINT_LEN + NONCE_LEN + TAG_LEN || bytes[0] !== VERSION) {\n throw new Error(\"Invalid or unsupported envelope\");\n }\n\n const ephPub = bytes.subarray(1, 1 + POINT_LEN);\n const nonce = bytes.subarray(1 + POINT_LEN, 1 + POINT_LEN + NONCE_LEN);\n const tag = bytes.subarray(1 + POINT_LEN + NONCE_LEN, 1 + POINT_LEN + NONCE_LEN + TAG_LEN);\n const ciphertext = bytes.subarray(1 + POINT_LEN + NONCE_LEN + TAG_LEN);\n\n // Guard against invalid-curve attacks: WebCrypto's P-256 `importKey` validates that the raw point\n // lies on the curve and is not the point at infinity, so a forged/off-curve ephemeral public key\n // throws here rather than yielding a derivable (and exploitable) shared secret below.\n const ephKey = await subtle.importKey(\n \"raw\",\n ephPub,\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [],\n );\n\n const shared = new Uint8Array(\n await subtle.deriveBits({ name: \"ECDH\", public: ephKey }, privateKey, 256),\n );\n\n const hkdf = await subtle.importKey(\"raw\", shared, \"HKDF\", false, [\"deriveKey\"]);\n\n const aesKey = await subtle.deriveKey(\n { name: \"HKDF\", hash: \"SHA-256\", salt: HKDF_SALT, info: HKDF_INFO },\n hkdf,\n { name: \"AES-GCM\", length: 256 },\n false,\n [\"decrypt\"],\n );\n\n // Web Crypto AES-GCM expects ciphertext||tag.\n const ctWithTag = new Uint8Array(ciphertext.length + tag.length);\n ctWithTag.set(ciphertext, 0);\n ctWithTag.set(tag, ciphertext.length);\n\n const plaintext = await subtle.decrypt(\n { name: \"AES-GCM\", iv: nonce, tagLength: 128 },\n aesKey,\n ctWithTag,\n );\n\n return new Uint8Array(plaintext);\n}\n\n/** Decrypts a base64 envelope and JSON-parses its payload. `null`/`undefined` in -> `null`. */\nexport async function decryptTo<T>(\n privateKey: CryptoKey,\n envelopeBase64: string | null | undefined,\n): Promise<T | null> {\n if (envelopeBase64 == null) return null;\n const plaintext = await decryptEnvelope(privateKey, envelopeBase64);\n return JSON.parse(new TextDecoder().decode(plaintext)) as T;\n}\n\n/** Imports a base64 PKCS#8 P-256 ECDH private key for use with {@link decryptEnvelope}. */\nexport async function importPrivateKey(pkcs8Base64: string): Promise<CryptoKey> {\n return subtle.importKey(\n \"pkcs8\",\n base64ToBytes(pkcs8Base64),\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [\"deriveBits\"],\n );\n}\n\nfunction base64ToBytes(b64: string): Uint8Array<ArrayBuffer> {\n return new Uint8Array(Buffer.from(b64, \"base64\"));\n}\n","{\n \"name\": \"@open-banking-io/client\",\n \"version\": \"0.3.1\",\n \"description\": \"Server-to-server client for open-banking.io: API-key auth + client-side decryption of the zero-knowledge data envelopes with your exported private key.\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"author\": \"open-banking.io\",\n \"keywords\": [\n \"open-banking\",\n \"psd2\",\n \"zero-knowledge\",\n \"encryption\",\n \"fintech\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/open-banking-io/clients\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest run\",\n \"coverage\": \"vitest run --coverage\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format:check\": \"prettier --check .\"\n },\n \"overrides\": {\n \"esbuild\": \"^0.28.1\"\n },\n \"devDependencies\": {\n \"@eslint/js\": \"^10.0.1\",\n \"@types/node\": \"^25.9.3\",\n \"@vitest/coverage-v8\": \"^4.1.9\",\n \"eslint\": \"^10.5.0\",\n \"prettier\": \"^3.8.4\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^6.0.3\",\n \"typescript-eslint\": \"^8.61.1\",\n \"vitest\": \"^4.1.9\"\n },\n \"homepage\": \"https://open-banking.io\"\n}\n","// The package version, sourced from package.json so it can never drift. tsup inlines the JSON at\n// build time (tree-shaken to the single string), and vitest/tsx resolve the import directly — so\n// this stays ESM/CJS-safe without a runtime file read.\nimport pkg from \"../package.json\" with { type: \"json\" };\n\nexport const VERSION: string = pkg.version;\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WAAW;AAAA,MAC9D,QAAQ,YAAY,QAAQ,KAAK,SAAS;AAAA,IAC5C,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,IAAI,MAAM,OAAO,IAAI,YAAY,IAAI,MAAM,IAAI,IAAI,UAAU,EAAE;AAAA,IACvE;AACA,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB;AAAA,EAEA,MAAc,SAAY,MAAc,MAA2B;AACjE,UAAM,MAAM,MAAM,KAAK,UAAU,KAAK,UAAU,MAAM;AAAA,MACpD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,aAAa,KAAK;AAAA,QAClB,gBAAgB;AAAA,QAChB,cAAc;AAAA,MAChB;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,MACzB,QAAQ,YAAY,QAAQ,KAAK,SAAS;AAAA,IAC5C,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,IAAI,MAAM,QAAQ,IAAI,YAAY,IAAI,MAAM,IAAI,IAAI,UAAU,EAAE;AAAA,IACxE;AACA,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB;AACF;","names":["VERSION"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -111,6 +111,25 @@ interface OpenBankingClientOptions {
|
|
|
111
111
|
* Defaults to {@link DEFAULT_TIMEOUT_MS} (30s).
|
|
112
112
|
*/
|
|
113
113
|
timeoutMs?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Custom `fetch` implementation, used in place of the global `fetch` for every request.
|
|
116
|
+
* Typed to the WHATWG `fetch` signature only, so the SDK keeps zero runtime dependencies.
|
|
117
|
+
*
|
|
118
|
+
* A custom HTTP transport (proxy, custom CA/mTLS, keep-alive, connection pooling) is
|
|
119
|
+
* expressed by passing a `fetch` bound to an undici `Dispatcher`, e.g.:
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* import { Agent, fetch as undiciFetch } from "undici";
|
|
123
|
+
* const dispatcher = new Agent({ keepAliveTimeout: 60_000 });
|
|
124
|
+
* const client = new OpenBankingClient({
|
|
125
|
+
* apiBaseUrl, apiKey, privateKeyPkcs8,
|
|
126
|
+
* fetch: (input, init) => undiciFetch(input, { ...init, dispatcher }),
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* Defaults to the global `fetch`.
|
|
131
|
+
*/
|
|
132
|
+
fetch?: typeof globalThis.fetch;
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
/**
|
|
@@ -124,11 +143,18 @@ declare class OpenBankingClient {
|
|
|
124
143
|
private readonly baseUrl;
|
|
125
144
|
private readonly apiKey;
|
|
126
145
|
private readonly timeoutMs;
|
|
146
|
+
private readonly fetchImpl;
|
|
127
147
|
private readonly privateKey;
|
|
128
148
|
constructor(options: OpenBankingClientOptions);
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Builds a client from a credentials-bundle JSON string or a path to a bundle file.
|
|
151
|
+
*
|
|
152
|
+
* `overrides` (optional) lets the bundle path set the same transport knobs as the
|
|
153
|
+
* constructor — e.g. a custom {@link OpenBankingClientOptions.fetch} or
|
|
154
|
+
* {@link OpenBankingClientOptions.timeoutMs}.
|
|
155
|
+
*/
|
|
156
|
+
static fromCredentials(jsonOrPath: string, overrides?: Partial<Pick<OpenBankingClientOptions, "fetch" | "timeoutMs">>): OpenBankingClient;
|
|
157
|
+
static fromBundle(bundle: CredentialsBundle, overrides?: Partial<Pick<OpenBankingClientOptions, "fetch" | "timeoutMs">>): OpenBankingClient;
|
|
132
158
|
/** Lists the user's accounts with all sensitive fields decrypted. */
|
|
133
159
|
getAccounts(): Promise<Account[]>;
|
|
134
160
|
/** Returns a page of an account's statement, newest first, with decrypted fields. */
|
package/dist/index.d.ts
CHANGED
|
@@ -111,6 +111,25 @@ interface OpenBankingClientOptions {
|
|
|
111
111
|
* Defaults to {@link DEFAULT_TIMEOUT_MS} (30s).
|
|
112
112
|
*/
|
|
113
113
|
timeoutMs?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Custom `fetch` implementation, used in place of the global `fetch` for every request.
|
|
116
|
+
* Typed to the WHATWG `fetch` signature only, so the SDK keeps zero runtime dependencies.
|
|
117
|
+
*
|
|
118
|
+
* A custom HTTP transport (proxy, custom CA/mTLS, keep-alive, connection pooling) is
|
|
119
|
+
* expressed by passing a `fetch` bound to an undici `Dispatcher`, e.g.:
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* import { Agent, fetch as undiciFetch } from "undici";
|
|
123
|
+
* const dispatcher = new Agent({ keepAliveTimeout: 60_000 });
|
|
124
|
+
* const client = new OpenBankingClient({
|
|
125
|
+
* apiBaseUrl, apiKey, privateKeyPkcs8,
|
|
126
|
+
* fetch: (input, init) => undiciFetch(input, { ...init, dispatcher }),
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* Defaults to the global `fetch`.
|
|
131
|
+
*/
|
|
132
|
+
fetch?: typeof globalThis.fetch;
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
/**
|
|
@@ -124,11 +143,18 @@ declare class OpenBankingClient {
|
|
|
124
143
|
private readonly baseUrl;
|
|
125
144
|
private readonly apiKey;
|
|
126
145
|
private readonly timeoutMs;
|
|
146
|
+
private readonly fetchImpl;
|
|
127
147
|
private readonly privateKey;
|
|
128
148
|
constructor(options: OpenBankingClientOptions);
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Builds a client from a credentials-bundle JSON string or a path to a bundle file.
|
|
151
|
+
*
|
|
152
|
+
* `overrides` (optional) lets the bundle path set the same transport knobs as the
|
|
153
|
+
* constructor — e.g. a custom {@link OpenBankingClientOptions.fetch} or
|
|
154
|
+
* {@link OpenBankingClientOptions.timeoutMs}.
|
|
155
|
+
*/
|
|
156
|
+
static fromCredentials(jsonOrPath: string, overrides?: Partial<Pick<OpenBankingClientOptions, "fetch" | "timeoutMs">>): OpenBankingClient;
|
|
157
|
+
static fromBundle(bundle: CredentialsBundle, overrides?: Partial<Pick<OpenBankingClientOptions, "fetch" | "timeoutMs">>): OpenBankingClient;
|
|
132
158
|
/** Lists the user's accounts with all sensitive fields decrypted. */
|
|
133
159
|
getAccounts(): Promise<Account[]>;
|
|
134
160
|
/** Returns a page of an account's statement, newest first, with decrypted fields. */
|
package/dist/index.js
CHANGED
|
@@ -68,7 +68,7 @@ function base64ToBytes(b64) {
|
|
|
68
68
|
// package.json
|
|
69
69
|
var package_default = {
|
|
70
70
|
name: "@open-banking-io/client",
|
|
71
|
-
version: "0.
|
|
71
|
+
version: "0.3.1",
|
|
72
72
|
description: "Server-to-server client for open-banking.io: API-key auth + client-side decryption of the zero-knowledge data envelopes with your exported private key.",
|
|
73
73
|
type: "module",
|
|
74
74
|
license: "MIT",
|
|
@@ -109,17 +109,21 @@ var package_default = {
|
|
|
109
109
|
lint: "eslint .",
|
|
110
110
|
"format:check": "prettier --check ."
|
|
111
111
|
},
|
|
112
|
+
overrides: {
|
|
113
|
+
esbuild: "^0.28.1"
|
|
114
|
+
},
|
|
112
115
|
devDependencies: {
|
|
113
|
-
"@eslint/js": "^
|
|
114
|
-
"@types/node": "^25.9.
|
|
115
|
-
"@vitest/coverage-v8": "^
|
|
116
|
-
eslint: "^
|
|
116
|
+
"@eslint/js": "^10.0.1",
|
|
117
|
+
"@types/node": "^25.9.3",
|
|
118
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
119
|
+
eslint: "^10.5.0",
|
|
117
120
|
prettier: "^3.8.4",
|
|
118
|
-
tsup: "^8.
|
|
119
|
-
typescript: "^
|
|
120
|
-
"typescript-eslint": "^8.61.
|
|
121
|
-
vitest: "^
|
|
122
|
-
}
|
|
121
|
+
tsup: "^8.5.1",
|
|
122
|
+
typescript: "^6.0.3",
|
|
123
|
+
"typescript-eslint": "^8.61.1",
|
|
124
|
+
vitest: "^4.1.9"
|
|
125
|
+
},
|
|
126
|
+
homepage: "https://open-banking.io"
|
|
123
127
|
};
|
|
124
128
|
|
|
125
129
|
// src/version.ts
|
|
@@ -133,32 +137,44 @@ var OpenBankingClient = class _OpenBankingClient {
|
|
|
133
137
|
baseUrl;
|
|
134
138
|
apiKey;
|
|
135
139
|
timeoutMs;
|
|
140
|
+
fetchImpl;
|
|
136
141
|
privateKey;
|
|
137
142
|
constructor(options) {
|
|
138
143
|
const { apiBaseUrl, apiKey, privateKeyPkcs8, timeoutMs } = options;
|
|
139
144
|
if (!apiBaseUrl?.trim()) throw new Error("apiBaseUrl is required");
|
|
140
145
|
if (!apiKey?.trim()) throw new Error("apiKey is required");
|
|
141
146
|
if (!privateKeyPkcs8?.trim()) throw new Error("privateKeyPkcs8 is required");
|
|
142
|
-
|
|
147
|
+
let end = apiBaseUrl.length;
|
|
148
|
+
while (end > 0 && apiBaseUrl.charCodeAt(end - 1) === 47) end--;
|
|
149
|
+
this.baseUrl = apiBaseUrl.slice(0, end);
|
|
143
150
|
this.apiKey = apiKey;
|
|
144
151
|
this.timeoutMs = timeoutMs ?? _OpenBankingClient.DEFAULT_TIMEOUT_MS;
|
|
152
|
+
this.fetchImpl = options.fetch ?? fetch;
|
|
145
153
|
this.privateKey = importPrivateKey(privateKeyPkcs8);
|
|
146
154
|
}
|
|
147
|
-
/**
|
|
148
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Builds a client from a credentials-bundle JSON string or a path to a bundle file.
|
|
157
|
+
*
|
|
158
|
+
* `overrides` (optional) lets the bundle path set the same transport knobs as the
|
|
159
|
+
* constructor — e.g. a custom {@link OpenBankingClientOptions.fetch} or
|
|
160
|
+
* {@link OpenBankingClientOptions.timeoutMs}.
|
|
161
|
+
*/
|
|
162
|
+
static fromCredentials(jsonOrPath, overrides = {}) {
|
|
149
163
|
let json = jsonOrPath;
|
|
150
164
|
if (!jsonOrPath.trimStart().startsWith("{")) {
|
|
151
165
|
json = readFileSync(jsonOrPath, "utf8");
|
|
152
166
|
}
|
|
153
167
|
const bundle = JSON.parse(json);
|
|
154
|
-
return _OpenBankingClient.fromBundle(bundle);
|
|
168
|
+
return _OpenBankingClient.fromBundle(bundle, overrides);
|
|
155
169
|
}
|
|
156
|
-
static fromBundle(bundle) {
|
|
170
|
+
static fromBundle(bundle, overrides = {}) {
|
|
157
171
|
if (!bundle.apiKey?.trim()) throw new Error("The credentials bundle has no apiKey");
|
|
158
172
|
return new _OpenBankingClient({
|
|
159
173
|
apiBaseUrl: bundle.apiBaseUrl,
|
|
160
174
|
apiKey: bundle.apiKey,
|
|
161
|
-
privateKeyPkcs8: bundle.encryptionKey.privateKey
|
|
175
|
+
privateKeyPkcs8: bundle.encryptionKey.privateKey,
|
|
176
|
+
timeoutMs: overrides.timeoutMs,
|
|
177
|
+
fetch: overrides.fetch
|
|
162
178
|
});
|
|
163
179
|
}
|
|
164
180
|
/** Lists the user's accounts with all sensitive fields decrypted. */
|
|
@@ -293,7 +309,7 @@ var OpenBankingClient = class _OpenBankingClient {
|
|
|
293
309
|
};
|
|
294
310
|
}
|
|
295
311
|
async getJson(path) {
|
|
296
|
-
const res = await
|
|
312
|
+
const res = await this.fetchImpl(this.baseUrl + path, {
|
|
297
313
|
headers: { "X-Api-Key": this.apiKey, "User-Agent": USER_AGENT },
|
|
298
314
|
signal: AbortSignal.timeout(this.timeoutMs)
|
|
299
315
|
});
|
|
@@ -303,7 +319,7 @@ var OpenBankingClient = class _OpenBankingClient {
|
|
|
303
319
|
return await res.json();
|
|
304
320
|
}
|
|
305
321
|
async postJson(path, body) {
|
|
306
|
-
const res = await
|
|
322
|
+
const res = await this.fetchImpl(this.baseUrl + path, {
|
|
307
323
|
method: "POST",
|
|
308
324
|
headers: {
|
|
309
325
|
"X-Api-Key": this.apiKey,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/envelope.ts","../package.json","../src/version.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { decryptTo, importPrivateKey, type CryptoKey } from \"./envelope.js\";\nimport { USER_AGENT } from \"./version.js\";\nimport type {\n Account,\n AccountEnc,\n AccountWire,\n BalanceEnc,\n Connection,\n ConnectionWire,\n CredentialsBundle,\n DisplayNameEnc,\n OpenBankingClientOptions,\n SyncAllResult,\n SyncAllResultWire,\n SyncResult,\n SyncResultWire,\n Transaction,\n TransactionEnc,\n TransactionPage,\n TransactionPageWire,\n TransactionQuery,\n TransactionWire,\n UidEnc,\n} from \"./models.js\";\n\n/**\n * Server-to-server client for open-banking.io. Authenticates with an API key (`X-Api-Key`) and\n * decrypts the zero-knowledge data envelopes locally with the exported private key — the service\n * only ever returns ciphertext it cannot read.\n */\nexport class OpenBankingClient {\n /** Default per-request timeout (30s) when {@link OpenBankingClientOptions.timeoutMs} is unset. */\n static readonly DEFAULT_TIMEOUT_MS = 30_000;\n\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeoutMs: number;\n private readonly privateKey: Promise<CryptoKey>;\n\n constructor(options: OpenBankingClientOptions) {\n const { apiBaseUrl, apiKey, privateKeyPkcs8, timeoutMs } = options;\n if (!apiBaseUrl?.trim()) throw new Error(\"apiBaseUrl is required\");\n if (!apiKey?.trim()) throw new Error(\"apiKey is required\");\n if (!privateKeyPkcs8?.trim()) throw new Error(\"privateKeyPkcs8 is required\");\n\n this.baseUrl = apiBaseUrl.replace(/\\/+$/, \"\");\n this.apiKey = apiKey;\n this.timeoutMs = timeoutMs ?? OpenBankingClient.DEFAULT_TIMEOUT_MS;\n this.privateKey = importPrivateKey(privateKeyPkcs8);\n }\n\n /** Builds a client from a credentials-bundle JSON string or a path to a bundle file. */\n static fromCredentials(jsonOrPath: string): OpenBankingClient {\n let json = jsonOrPath;\n if (!jsonOrPath.trimStart().startsWith(\"{\")) {\n json = readFileSync(jsonOrPath, \"utf8\");\n }\n const bundle = JSON.parse(json) as CredentialsBundle;\n return OpenBankingClient.fromBundle(bundle);\n }\n\n static fromBundle(bundle: CredentialsBundle): OpenBankingClient {\n if (!bundle.apiKey?.trim()) throw new Error(\"The credentials bundle has no apiKey\");\n return new OpenBankingClient({\n apiBaseUrl: bundle.apiBaseUrl,\n apiKey: bundle.apiKey,\n privateKeyPkcs8: bundle.encryptionKey.privateKey,\n });\n }\n\n /** Lists the user's accounts with all sensitive fields decrypted. */\n async getAccounts(): Promise<Account[]> {\n const wires = await this.getAccountWires();\n return Promise.all(wires.map((w) => this.mapAccount(w)));\n }\n\n /** Returns a page of an account's statement, newest first, with decrypted fields. */\n async getTransactions(accountId: string, query: TransactionQuery = {}): Promise<TransactionPage> {\n const qs = new URLSearchParams();\n if (query.from != null) qs.set(\"from\", query.from);\n if (query.to != null) qs.set(\"to\", query.to);\n if (query.limit != null) qs.set(\"limit\", String(query.limit));\n if (query.offset != null) qs.set(\"offset\", String(query.offset));\n const suffix = qs.toString() ? `?${qs.toString()}` : \"\";\n\n const page = await this.getJson<TransactionPageWire>(\n `/api/accounts/${encodeURIComponent(accountId)}/transactions${suffix}`,\n );\n\n const items = await Promise.all((page.items ?? []).map((t) => this.mapTransaction(t)));\n return { items, total: page.total };\n }\n\n /** Lists the user's bank connections. */\n async getConnections(): Promise<Connection[]> {\n const wires = await this.getJson<ConnectionWire[]>(\"/api/connections\");\n return wires.map((c) => ({\n sessionId: c.sessionId,\n aspspName: c.aspspName,\n aspspCountry: c.aspspCountry,\n validUntil: c.validUntil,\n status: c.status,\n accountCount: c.accountCount,\n lastSyncedAt: c.lastSyncedAt ?? null,\n psuType: c.psuType ?? null,\n }));\n }\n\n /**\n * Triggers an online sync of one account: decrypts that account's Enable Banking uid and posts\n * it, so the service can fetch fresh data without ever holding the uid in plaintext.\n */\n async sync(accountId: string): Promise<SyncResult> {\n const wires = await this.getAccountWires();\n const account = wires.find((a) => a.id === accountId);\n if (!account) throw new Error(`Account ${accountId} not found`);\n\n const uid = await this.decryptUid(account);\n if (uid == null) {\n throw new Error(\"Account has no active session (reconnect required) — cannot sync\");\n }\n\n const result = await this.postJson<SyncResultWire>(\n `/api/accounts/${encodeURIComponent(accountId)}/sync`,\n { uid },\n );\n return { newTransactions: result.newTransactions, totalFetched: result.totalFetched };\n }\n\n /** Triggers an online sync of every account that has an active session. */\n async syncAll(): Promise<SyncAllResult> {\n const wires = await this.getAccountWires();\n const decrypted = await Promise.all(\n wires.map(async (a) => ({ accountId: a.id, uid: await this.decryptUid(a) })),\n );\n const items = decrypted\n .filter((x): x is { accountId: string; uid: string } => x.uid != null)\n .map((x) => ({ accountId: x.accountId, uid: x.uid }));\n\n const result = await this.postJson<SyncAllResultWire>(\"/api/sync\", { items });\n return { accounts: result.accounts, newTransactions: result.newTransactions };\n }\n\n // ---- internals ---------------------------------------------------------------------------------\n\n private getAccountWires(): Promise<AccountWire[]> {\n return this.getJson<AccountWire[]>(\"/api/accounts\");\n }\n\n private async decryptUid(a: AccountWire): Promise<string | null> {\n const dec = await decryptTo<UidEnc>(await this.privateKey, a.uidEnc);\n return dec?.uid ?? null;\n }\n\n private async mapAccount(a: AccountWire): Promise<Account> {\n const priv = await this.privateKey;\n const acc = await decryptTo<AccountEnc>(priv, a.enc);\n const name = await decryptTo<DisplayNameEnc>(priv, a.displayNameEnc);\n const balances = await Promise.all(\n (a.balances ?? []).map(async (b) => {\n const dec = await decryptTo<BalanceEnc>(priv, b.enc);\n return {\n type: b.type,\n name: dec?.name ?? null,\n amount: dec?.amount ?? \"0\",\n currency: b.currency,\n referenceDate: b.referenceDate ?? null,\n };\n }),\n );\n\n return {\n id: a.id,\n aspspName: a.aspspName,\n aspspCountry: a.aspspCountry,\n currency: a.currency,\n accountType: a.accountType ?? null,\n bic: a.bic ?? null,\n needsReconnect: a.needsReconnect,\n iban: acc?.iban ?? null,\n bban: acc?.bban ?? null,\n ownerName: acc?.ownerName ?? null,\n accountName: acc?.accountName ?? null,\n product: acc?.product ?? null,\n displayName: name?.displayName ?? null,\n balances,\n };\n }\n\n private async mapTransaction(t: TransactionWire): Promise<Transaction> {\n const d = await decryptTo<TransactionEnc>(await this.privateKey, t.enc);\n return {\n id: t.id,\n currency: t.currency,\n creditDebitIndicator: t.creditDebitIndicator,\n status: t.status ?? null,\n bookingDate: t.bookingDate ?? null,\n valueDate: t.valueDate ?? null,\n transactionDate: t.transactionDate ?? null,\n bankTransactionCode: t.bankTransactionCode ?? null,\n amount: d?.amount ?? \"0\",\n creditorName: d?.creditorName ?? null,\n creditorIban: d?.creditorIban ?? null,\n creditorBban: d?.creditorBban ?? null,\n creditorAgentBic: d?.creditorAgentBic ?? null,\n debtorName: d?.debtorName ?? null,\n debtorIban: d?.debtorIban ?? null,\n debtorBban: d?.debtorBban ?? null,\n debtorAgentBic: d?.debtorAgentBic ?? null,\n remittanceInformation: d?.remittanceInformation ?? null,\n note: d?.note ?? null,\n referenceNumber: d?.referenceNumber ?? null,\n exchangeRate: d?.exchangeRate ?? null,\n merchantCategoryCode: d?.merchantCategoryCode ?? null,\n balanceAfterTransaction: d?.balanceAfter ?? null,\n balanceAfterCurrency: d?.balanceAfterCurrency ?? null,\n };\n }\n\n private async getJson<T>(path: string): Promise<T> {\n const res = await fetch(this.baseUrl + path, {\n headers: { \"X-Api-Key\": this.apiKey, \"User-Agent\": USER_AGENT },\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n if (!res.ok) {\n throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as T;\n }\n\n private async postJson<T>(path: string, body: unknown): Promise<T> {\n const res = await fetch(this.baseUrl + path, {\n method: \"POST\",\n headers: {\n \"X-Api-Key\": this.apiKey,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": USER_AGENT,\n },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n if (!res.ok) {\n throw new Error(`POST ${path} failed: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as T;\n }\n}\n","import { webcrypto } from \"node:crypto\";\n\nconst { subtle } = webcrypto;\n\n/** Re-export the WebCrypto key type so callers don't depend on the DOM lib. */\nexport type CryptoKey = webcrypto.CryptoKey;\n\nconst VERSION = 0x01;\nconst POINT_LEN = 65;\nconst NONCE_LEN = 12;\nconst TAG_LEN = 16;\n\nconst HKDF_INFO = new TextEncoder().encode(\"bank.core.ci/zk/v1\");\nconst HKDF_SALT = new Uint8Array(32); // 32 zero bytes (must be exactly this).\n\n/**\n * Decrypts open-banking.io's zero-knowledge data envelopes.\n * Scheme: ephemeral ECDH on NIST P-256 -> HKDF-SHA256 -> AES-256-GCM.\n * Wire: `version(1)=0x01 | ephemeralPublicKeyRaw(65) | nonce(12) | tag(16) | ciphertext`.\n * Only the user's private key can decrypt — the service stores ciphertext it cannot read.\n */\nexport async function decryptEnvelope(\n privateKey: CryptoKey,\n envelopeBase64: string,\n): Promise<Uint8Array> {\n const bytes = base64ToBytes(envelopeBase64);\n if (bytes.length < 1 + POINT_LEN + NONCE_LEN + TAG_LEN || bytes[0] !== VERSION) {\n throw new Error(\"Invalid or unsupported envelope\");\n }\n\n const ephPub = bytes.subarray(1, 1 + POINT_LEN);\n const nonce = bytes.subarray(1 + POINT_LEN, 1 + POINT_LEN + NONCE_LEN);\n const tag = bytes.subarray(1 + POINT_LEN + NONCE_LEN, 1 + POINT_LEN + NONCE_LEN + TAG_LEN);\n const ciphertext = bytes.subarray(1 + POINT_LEN + NONCE_LEN + TAG_LEN);\n\n // Guard against invalid-curve attacks: WebCrypto's P-256 `importKey` validates that the raw point\n // lies on the curve and is not the point at infinity, so a forged/off-curve ephemeral public key\n // throws here rather than yielding a derivable (and exploitable) shared secret below.\n const ephKey = await subtle.importKey(\n \"raw\",\n ephPub,\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [],\n );\n\n const shared = new Uint8Array(\n await subtle.deriveBits({ name: \"ECDH\", public: ephKey }, privateKey, 256),\n );\n\n const hkdf = await subtle.importKey(\"raw\", shared, \"HKDF\", false, [\"deriveKey\"]);\n\n const aesKey = await subtle.deriveKey(\n { name: \"HKDF\", hash: \"SHA-256\", salt: HKDF_SALT, info: HKDF_INFO },\n hkdf,\n { name: \"AES-GCM\", length: 256 },\n false,\n [\"decrypt\"],\n );\n\n // Web Crypto AES-GCM expects ciphertext||tag.\n const ctWithTag = new Uint8Array(ciphertext.length + tag.length);\n ctWithTag.set(ciphertext, 0);\n ctWithTag.set(tag, ciphertext.length);\n\n const plaintext = await subtle.decrypt(\n { name: \"AES-GCM\", iv: nonce, tagLength: 128 },\n aesKey,\n ctWithTag,\n );\n\n return new Uint8Array(plaintext);\n}\n\n/** Decrypts a base64 envelope and JSON-parses its payload. `null`/`undefined` in -> `null`. */\nexport async function decryptTo<T>(\n privateKey: CryptoKey,\n envelopeBase64: string | null | undefined,\n): Promise<T | null> {\n if (envelopeBase64 == null) return null;\n const plaintext = await decryptEnvelope(privateKey, envelopeBase64);\n return JSON.parse(new TextDecoder().decode(plaintext)) as T;\n}\n\n/** Imports a base64 PKCS#8 P-256 ECDH private key for use with {@link decryptEnvelope}. */\nexport async function importPrivateKey(pkcs8Base64: string): Promise<CryptoKey> {\n return subtle.importKey(\n \"pkcs8\",\n base64ToBytes(pkcs8Base64),\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [\"deriveBits\"],\n );\n}\n\nfunction base64ToBytes(b64: string): Uint8Array<ArrayBuffer> {\n return new Uint8Array(Buffer.from(b64, \"base64\"));\n}\n","{\n \"name\": \"@open-banking-io/client\",\n \"version\": \"0.2.0\",\n \"description\": \"Server-to-server client for open-banking.io: API-key auth + client-side decryption of the zero-knowledge data envelopes with your exported private key.\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"author\": \"open-banking.io\",\n \"keywords\": [\n \"open-banking\",\n \"psd2\",\n \"zero-knowledge\",\n \"encryption\",\n \"fintech\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/open-banking-io/clients\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest run\",\n \"coverage\": \"vitest run --coverage\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format:check\": \"prettier --check .\"\n },\n \"devDependencies\": {\n \"@eslint/js\": \"^9.39.4\",\n \"@types/node\": \"^25.9.2\",\n \"@vitest/coverage-v8\": \"^3.2.6\",\n \"eslint\": \"^9.39.4\",\n \"prettier\": \"^3.8.4\",\n \"tsup\": \"^8.3.5\",\n \"typescript\": \"^5.7.2\",\n \"typescript-eslint\": \"^8.61.0\",\n \"vitest\": \"^3.2.6\"\n }\n}\n","// The package version, sourced from package.json so it can never drift. tsup inlines the JSON at\n// build time (tree-shaken to the single string), and vitest/tsx resolve the import directly — so\n// this stays ESM/CJS-safe without a runtime file read.\nimport pkg from \"../package.json\" with { type: \"json\" };\n\nexport const VERSION: string = pkg.version;\n\n/** The `User-Agent` sent on every request: `open-banking-io/node/<version>`. */\nexport const USER_AGENT = `open-banking-io/node/${VERSION}`;\n"],"mappings":";AAAA,SAAS,oBAAoB;;;ACA7B,SAAS,iBAAiB;AAE1B,IAAM,EAAE,OAAO,IAAI;AAKnB,IAAM,UAAU;AAChB,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,UAAU;AAEhB,IAAM,YAAY,IAAI,YAAY,EAAE,OAAO,oBAAoB;AAC/D,IAAM,YAAY,IAAI,WAAW,EAAE;AAQnC,eAAsB,gBACpB,YACA,gBACqB;AACrB,QAAM,QAAQ,cAAc,cAAc;AAC1C,MAAI,MAAM,SAAS,IAAI,YAAY,YAAY,WAAW,MAAM,CAAC,MAAM,SAAS;AAC9E,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,QAAM,SAAS,MAAM,SAAS,GAAG,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AiB,GAAG,mBAAmB;AAAA,MACvC,cAAc,GAAG,gBAAgB;AAAA,MACjC,sBAAsB,GAAG,wBAAwB;AAAA,MACjD,yBAAyB,GAAG,gBAAgB;AAAA,MAC5C,sBAAsB,GAAG,wBAAwB;AAAA,IACnD;AAAA,EACF;AAAA,EAEA,MAAc,QAAW,MAA0B;AACjD,UAAM,MAAM,MAAM,MAAM,KAAK,UAAU,MAAM;AAAA,MAC3C,SAAS,EAAE,aAAa,KAAK,QAAQ,cAAc,WAAW;AAAA,MAC9D,QAAQ,YAAY,QAAQ,KAAK,SAAS;AAAA,IAC5C,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,IAAI,MAAM,OAAO,IAAI,YAAY,IAAI,MAAM,IAAI,IAAI,UAAU,EAAE;AAAA,IACvE;AACA,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB;AAAA,EAEA,MAAc,SAAY,MAAc,MAA2B;AACjE,UAAM,MAAM,MAAM,MAAM,KAAK,UAAU,MAAM;AAAA,MAC3C,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,aAAa,KAAK;AAAA,QAClB,gBAAgB;AAAA,QAChB,cAAc;AAAA,MAChB;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,MACzB,QAAQ,YAAY,QAAQ,KAAK,SAAS;AAAA,IAC5C,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,IAAI,MAAM,QAAQ,IAAI,YAAY,IAAI,MAAM,IAAI,IAAI,UAAU,EAAE;AAAA,IACxE;AACA,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB;AACF;","names":["VERSION"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/envelope.ts","../package.json","../src/version.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { decryptTo, importPrivateKey, type CryptoKey } from \"./envelope.js\";\nimport { USER_AGENT } from \"./version.js\";\nimport type {\n Account,\n AccountEnc,\n AccountWire,\n BalanceEnc,\n Connection,\n ConnectionWire,\n CredentialsBundle,\n DisplayNameEnc,\n OpenBankingClientOptions,\n SyncAllResult,\n SyncAllResultWire,\n SyncResult,\n SyncResultWire,\n Transaction,\n TransactionEnc,\n TransactionPage,\n TransactionPageWire,\n TransactionQuery,\n TransactionWire,\n UidEnc,\n} from \"./models.js\";\n\n/**\n * Server-to-server client for open-banking.io. Authenticates with an API key (`X-Api-Key`) and\n * decrypts the zero-knowledge data envelopes locally with the exported private key — the service\n * only ever returns ciphertext it cannot read.\n */\nexport class OpenBankingClient {\n /** Default per-request timeout (30s) when {@link OpenBankingClientOptions.timeoutMs} is unset. */\n static readonly DEFAULT_TIMEOUT_MS = 30_000;\n\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeoutMs: number;\n private readonly fetchImpl: typeof globalThis.fetch;\n private readonly privateKey: Promise<CryptoKey>;\n\n constructor(options: OpenBankingClientOptions) {\n const { apiBaseUrl, apiKey, privateKeyPkcs8, timeoutMs } = options;\n if (!apiBaseUrl?.trim()) throw new Error(\"apiBaseUrl is required\");\n if (!apiKey?.trim()) throw new Error(\"apiKey is required\");\n if (!privateKeyPkcs8?.trim()) throw new Error(\"privateKeyPkcs8 is required\");\n\n // Strip all trailing \"/\" without a backtracking regex (avoids ReDoS on long inputs).\n let end = apiBaseUrl.length;\n while (end > 0 && apiBaseUrl.charCodeAt(end - 1) === 47 /* \"/\" */) end--;\n this.baseUrl = apiBaseUrl.slice(0, end);\n this.apiKey = apiKey;\n this.timeoutMs = timeoutMs ?? OpenBankingClient.DEFAULT_TIMEOUT_MS;\n this.fetchImpl = options.fetch ?? fetch;\n this.privateKey = importPrivateKey(privateKeyPkcs8);\n }\n\n /**\n * Builds a client from a credentials-bundle JSON string or a path to a bundle file.\n *\n * `overrides` (optional) lets the bundle path set the same transport knobs as the\n * constructor — e.g. a custom {@link OpenBankingClientOptions.fetch} or\n * {@link OpenBankingClientOptions.timeoutMs}.\n */\n static fromCredentials(\n jsonOrPath: string,\n overrides: Partial<Pick<OpenBankingClientOptions, \"fetch\" | \"timeoutMs\">> = {},\n ): OpenBankingClient {\n let json = jsonOrPath;\n if (!jsonOrPath.trimStart().startsWith(\"{\")) {\n json = readFileSync(jsonOrPath, \"utf8\");\n }\n const bundle = JSON.parse(json) as CredentialsBundle;\n return OpenBankingClient.fromBundle(bundle, overrides);\n }\n\n static fromBundle(\n bundle: CredentialsBundle,\n overrides: Partial<Pick<OpenBankingClientOptions, \"fetch\" | \"timeoutMs\">> = {},\n ): OpenBankingClient {\n if (!bundle.apiKey?.trim()) throw new Error(\"The credentials bundle has no apiKey\");\n return new OpenBankingClient({\n apiBaseUrl: bundle.apiBaseUrl,\n apiKey: bundle.apiKey,\n privateKeyPkcs8: bundle.encryptionKey.privateKey,\n timeoutMs: overrides.timeoutMs,\n fetch: overrides.fetch,\n });\n }\n\n /** Lists the user's accounts with all sensitive fields decrypted. */\n async getAccounts(): Promise<Account[]> {\n const wires = await this.getAccountWires();\n return Promise.all(wires.map((w) => this.mapAccount(w)));\n }\n\n /** Returns a page of an account's statement, newest first, with decrypted fields. */\n async getTransactions(accountId: string, query: TransactionQuery = {}): Promise<TransactionPage> {\n const qs = new URLSearchParams();\n if (query.from != null) qs.set(\"from\", query.from);\n if (query.to != null) qs.set(\"to\", query.to);\n if (query.limit != null) qs.set(\"limit\", String(query.limit));\n if (query.offset != null) qs.set(\"offset\", String(query.offset));\n const suffix = qs.toString() ? `?${qs.toString()}` : \"\";\n\n const page = await this.getJson<TransactionPageWire>(\n `/api/accounts/${encodeURIComponent(accountId)}/transactions${suffix}`,\n );\n\n const items = await Promise.all((page.items ?? []).map((t) => this.mapTransaction(t)));\n return { items, total: page.total };\n }\n\n /** Lists the user's bank connections. */\n async getConnections(): Promise<Connection[]> {\n const wires = await this.getJson<ConnectionWire[]>(\"/api/connections\");\n return wires.map((c) => ({\n sessionId: c.sessionId,\n aspspName: c.aspspName,\n aspspCountry: c.aspspCountry,\n validUntil: c.validUntil,\n status: c.status,\n accountCount: c.accountCount,\n lastSyncedAt: c.lastSyncedAt ?? null,\n psuType: c.psuType ?? null,\n }));\n }\n\n /**\n * Triggers an online sync of one account: decrypts that account's Enable Banking uid and posts\n * it, so the service can fetch fresh data without ever holding the uid in plaintext.\n */\n async sync(accountId: string): Promise<SyncResult> {\n const wires = await this.getAccountWires();\n const account = wires.find((a) => a.id === accountId);\n if (!account) throw new Error(`Account ${accountId} not found`);\n\n const uid = await this.decryptUid(account);\n if (uid == null) {\n throw new Error(\"Account has no active session (reconnect required) — cannot sync\");\n }\n\n const result = await this.postJson<SyncResultWire>(\n `/api/accounts/${encodeURIComponent(accountId)}/sync`,\n { uid },\n );\n return { newTransactions: result.newTransactions, totalFetched: result.totalFetched };\n }\n\n /** Triggers an online sync of every account that has an active session. */\n async syncAll(): Promise<SyncAllResult> {\n const wires = await this.getAccountWires();\n const decrypted = await Promise.all(\n wires.map(async (a) => ({ accountId: a.id, uid: await this.decryptUid(a) })),\n );\n const items = decrypted\n .filter((x): x is { accountId: string; uid: string } => x.uid != null)\n .map((x) => ({ accountId: x.accountId, uid: x.uid }));\n\n const result = await this.postJson<SyncAllResultWire>(\"/api/sync\", { items });\n return { accounts: result.accounts, newTransactions: result.newTransactions };\n }\n\n // ---- internals ---------------------------------------------------------------------------------\n\n private getAccountWires(): Promise<AccountWire[]> {\n return this.getJson<AccountWire[]>(\"/api/accounts\");\n }\n\n private async decryptUid(a: AccountWire): Promise<string | null> {\n const dec = await decryptTo<UidEnc>(await this.privateKey, a.uidEnc);\n return dec?.uid ?? null;\n }\n\n private async mapAccount(a: AccountWire): Promise<Account> {\n const priv = await this.privateKey;\n const acc = await decryptTo<AccountEnc>(priv, a.enc);\n const name = await decryptTo<DisplayNameEnc>(priv, a.displayNameEnc);\n const balances = await Promise.all(\n (a.balances ?? []).map(async (b) => {\n const dec = await decryptTo<BalanceEnc>(priv, b.enc);\n return {\n type: b.type,\n name: dec?.name ?? null,\n amount: dec?.amount ?? \"0\",\n currency: b.currency,\n referenceDate: b.referenceDate ?? null,\n };\n }),\n );\n\n return {\n id: a.id,\n aspspName: a.aspspName,\n aspspCountry: a.aspspCountry,\n currency: a.currency,\n accountType: a.accountType ?? null,\n bic: a.bic ?? null,\n needsReconnect: a.needsReconnect,\n iban: acc?.iban ?? null,\n bban: acc?.bban ?? null,\n ownerName: acc?.ownerName ?? null,\n accountName: acc?.accountName ?? null,\n product: acc?.product ?? null,\n displayName: name?.displayName ?? null,\n balances,\n };\n }\n\n private async mapTransaction(t: TransactionWire): Promise<Transaction> {\n const d = await decryptTo<TransactionEnc>(await this.privateKey, t.enc);\n return {\n id: t.id,\n currency: t.currency,\n creditDebitIndicator: t.creditDebitIndicator,\n status: t.status ?? null,\n bookingDate: t.bookingDate ?? null,\n valueDate: t.valueDate ?? null,\n transactionDate: t.transactionDate ?? null,\n bankTransactionCode: t.bankTransactionCode ?? null,\n amount: d?.amount ?? \"0\",\n creditorName: d?.creditorName ?? null,\n creditorIban: d?.creditorIban ?? null,\n creditorBban: d?.creditorBban ?? null,\n creditorAgentBic: d?.creditorAgentBic ?? null,\n debtorName: d?.debtorName ?? null,\n debtorIban: d?.debtorIban ?? null,\n debtorBban: d?.debtorBban ?? null,\n debtorAgentBic: d?.debtorAgentBic ?? null,\n remittanceInformation: d?.remittanceInformation ?? null,\n note: d?.note ?? null,\n referenceNumber: d?.referenceNumber ?? null,\n exchangeRate: d?.exchangeRate ?? null,\n merchantCategoryCode: d?.merchantCategoryCode ?? null,\n balanceAfterTransaction: d?.balanceAfter ?? null,\n balanceAfterCurrency: d?.balanceAfterCurrency ?? null,\n };\n }\n\n private async getJson<T>(path: string): Promise<T> {\n const res = await this.fetchImpl(this.baseUrl + path, {\n headers: { \"X-Api-Key\": this.apiKey, \"User-Agent\": USER_AGENT },\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n if (!res.ok) {\n throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as T;\n }\n\n private async postJson<T>(path: string, body: unknown): Promise<T> {\n const res = await this.fetchImpl(this.baseUrl + path, {\n method: \"POST\",\n headers: {\n \"X-Api-Key\": this.apiKey,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": USER_AGENT,\n },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n if (!res.ok) {\n throw new Error(`POST ${path} failed: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as T;\n }\n}\n","import { webcrypto } from \"node:crypto\";\n\nconst { subtle } = webcrypto;\n\n/** Re-export the WebCrypto key type so callers don't depend on the DOM lib. */\nexport type CryptoKey = webcrypto.CryptoKey;\n\nconst VERSION = 0x01;\nconst POINT_LEN = 65;\nconst NONCE_LEN = 12;\nconst TAG_LEN = 16;\n\nconst HKDF_INFO = new TextEncoder().encode(\"bank.core.ci/zk/v1\");\nconst HKDF_SALT = new Uint8Array(32); // 32 zero bytes (must be exactly this).\n\n/**\n * Decrypts open-banking.io's zero-knowledge data envelopes.\n * Scheme: ephemeral ECDH on NIST P-256 -> HKDF-SHA256 -> AES-256-GCM.\n * Wire: `version(1)=0x01 | ephemeralPublicKeyRaw(65) | nonce(12) | tag(16) | ciphertext`.\n * Only the user's private key can decrypt — the service stores ciphertext it cannot read.\n */\nexport async function decryptEnvelope(\n privateKey: CryptoKey,\n envelopeBase64: string,\n): Promise<Uint8Array> {\n const bytes = base64ToBytes(envelopeBase64);\n if (bytes.length < 1 + POINT_LEN + NONCE_LEN + TAG_LEN || bytes[0] !== VERSION) {\n throw new Error(\"Invalid or unsupported envelope\");\n }\n\n const ephPub = bytes.subarray(1, 1 + POINT_LEN);\n const nonce = bytes.subarray(1 + POINT_LEN, 1 + POINT_LEN + NONCE_LEN);\n const tag = bytes.subarray(1 + POINT_LEN + NONCE_LEN, 1 + POINT_LEN + NONCE_LEN + TAG_LEN);\n const ciphertext = bytes.subarray(1 + POINT_LEN + NONCE_LEN + TAG_LEN);\n\n // Guard against invalid-curve attacks: WebCrypto's P-256 `importKey` validates that the raw point\n // lies on the curve and is not the point at infinity, so a forged/off-curve ephemeral public key\n // throws here rather than yielding a derivable (and exploitable) shared secret below.\n const ephKey = await subtle.importKey(\n \"raw\",\n ephPub,\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [],\n );\n\n const shared = new Uint8Array(\n await subtle.deriveBits({ name: \"ECDH\", public: ephKey }, privateKey, 256),\n );\n\n const hkdf = await subtle.importKey(\"raw\", shared, \"HKDF\", false, [\"deriveKey\"]);\n\n const aesKey = await subtle.deriveKey(\n { name: \"HKDF\", hash: \"SHA-256\", salt: HKDF_SALT, info: HKDF_INFO },\n hkdf,\n { name: \"AES-GCM\", length: 256 },\n false,\n [\"decrypt\"],\n );\n\n // Web Crypto AES-GCM expects ciphertext||tag.\n const ctWithTag = new Uint8Array(ciphertext.length + tag.length);\n ctWithTag.set(ciphertext, 0);\n ctWithTag.set(tag, ciphertext.length);\n\n const plaintext = await subtle.decrypt(\n { name: \"AES-GCM\", iv: nonce, tagLength: 128 },\n aesKey,\n ctWithTag,\n );\n\n return new Uint8Array(plaintext);\n}\n\n/** Decrypts a base64 envelope and JSON-parses its payload. `null`/`undefined` in -> `null`. */\nexport async function decryptTo<T>(\n privateKey: CryptoKey,\n envelopeBase64: string | null | undefined,\n): Promise<T | null> {\n if (envelopeBase64 == null) return null;\n const plaintext = await decryptEnvelope(privateKey, envelopeBase64);\n return JSON.parse(new TextDecoder().decode(plaintext)) as T;\n}\n\n/** Imports a base64 PKCS#8 P-256 ECDH private key for use with {@link decryptEnvelope}. */\nexport async function importPrivateKey(pkcs8Base64: string): Promise<CryptoKey> {\n return subtle.importKey(\n \"pkcs8\",\n base64ToBytes(pkcs8Base64),\n { name: \"ECDH\", namedCurve: \"P-256\" },\n false,\n [\"deriveBits\"],\n );\n}\n\nfunction base64ToBytes(b64: string): Uint8Array<ArrayBuffer> {\n return new Uint8Array(Buffer.from(b64, \"base64\"));\n}\n","{\n \"name\": \"@open-banking-io/client\",\n \"version\": \"0.3.1\",\n \"description\": \"Server-to-server client for open-banking.io: API-key auth + client-side decryption of the zero-knowledge data envelopes with your exported private key.\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"author\": \"open-banking.io\",\n \"keywords\": [\n \"open-banking\",\n \"psd2\",\n \"zero-knowledge\",\n \"encryption\",\n \"fintech\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/open-banking-io/clients\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest run\",\n \"coverage\": \"vitest run --coverage\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format:check\": \"prettier --check .\"\n },\n \"overrides\": {\n \"esbuild\": \"^0.28.1\"\n },\n \"devDependencies\": {\n \"@eslint/js\": \"^10.0.1\",\n \"@types/node\": \"^25.9.3\",\n \"@vitest/coverage-v8\": \"^4.1.9\",\n \"eslint\": \"^10.5.0\",\n \"prettier\": \"^3.8.4\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^6.0.3\",\n \"typescript-eslint\": \"^8.61.1\",\n \"vitest\": \"^4.1.9\"\n },\n \"homepage\": \"https://open-banking.io\"\n}\n","// The package version, sourced from package.json so it can never drift. tsup inlines the JSON at\n// build time (tree-shaken to the single string), and vitest/tsx resolve the import directly — so\n// this stays ESM/CJS-safe without a runtime file read.\nimport pkg from \"../package.json\" with { type: \"json\" };\n\nexport const VERSION: string = pkg.version;\n\n/** The `User-Agent` sent on every request: `open-banking-io/node/<version>`. */\nexport const USER_AGENT = `open-banking-io/node/${VERSION}`;\n"],"mappings":";AAAA,SAAS,oBAAoB;;;AC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A,IACvE;AACA,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB;AAAA,EAEA,MAAc,SAAY,MAAc,MAA2B;AACjE,UAAM,MAAM,MAAM,KAAK,UAAU,KAAK,UAAU,MAAM;AAAA,MACpD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,aAAa,KAAK;AAAA,QAClB,gBAAgB;AAAA,QAChB,cAAc;AAAA,MAChB;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,MACzB,QAAQ,YAAY,QAAQ,KAAK,SAAS;AAAA,IAC5C,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,IAAI,MAAM,QAAQ,IAAI,YAAY,IAAI,MAAM,IAAI,IAAI,UAAU,EAAE;AAAA,IACxE;AACA,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB;AACF;","names":["VERSION"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-banking-io/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Server-to-server client for open-banking.io: API-key auth + client-side decryption of the zero-knowledge data envelopes with your exported private key.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,15 +41,19 @@
|
|
|
41
41
|
"lint": "eslint .",
|
|
42
42
|
"format:check": "prettier --check ."
|
|
43
43
|
},
|
|
44
|
+
"overrides": {
|
|
45
|
+
"esbuild": "^0.28.1"
|
|
46
|
+
},
|
|
44
47
|
"devDependencies": {
|
|
45
|
-
"@eslint/js": "^
|
|
46
|
-
"@types/node": "^25.9.
|
|
47
|
-
"@vitest/coverage-v8": "^
|
|
48
|
-
"eslint": "^
|
|
48
|
+
"@eslint/js": "^10.0.1",
|
|
49
|
+
"@types/node": "^25.9.3",
|
|
50
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
51
|
+
"eslint": "^10.5.0",
|
|
49
52
|
"prettier": "^3.8.4",
|
|
50
|
-
"tsup": "^8.
|
|
51
|
-
"typescript": "^
|
|
52
|
-
"typescript-eslint": "^8.61.
|
|
53
|
-
"vitest": "^
|
|
54
|
-
}
|
|
53
|
+
"tsup": "^8.5.1",
|
|
54
|
+
"typescript": "^6.0.3",
|
|
55
|
+
"typescript-eslint": "^8.61.1",
|
|
56
|
+
"vitest": "^4.1.9"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://open-banking.io"
|
|
55
59
|
}
|