@open-banking-io/client 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -1
- package/dist/index.cjs +77 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +77 -4
- package/dist/index.js.map +1 -1
- package/package.json +11 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 open-banking.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -18,7 +18,9 @@ const client = OpenBankingClient.fromCredentials("credentials.json");
|
|
|
18
18
|
|
|
19
19
|
for (const account of await client.getAccounts()) {
|
|
20
20
|
const booked = account.balances.find((b) => b.type === "ITBD");
|
|
21
|
-
console.log(
|
|
21
|
+
console.log(
|
|
22
|
+
`${account.displayName ?? account.ownerName} ${account.iban}: ${booked?.amount} ${account.currency}`,
|
|
23
|
+
);
|
|
22
24
|
|
|
23
25
|
const page = await client.getTransactions(account.id, { limit: 50 });
|
|
24
26
|
for (const t of page.items) {
|
|
@@ -36,6 +38,9 @@ Or construct it explicitly:
|
|
|
36
38
|
const client = new OpenBankingClient({ apiBaseUrl, apiKey, privateKeyPkcs8 });
|
|
37
39
|
```
|
|
38
40
|
|
|
41
|
+
Every request carries a `User-Agent: open-banking-io/node/<version>` header and a default 30s timeout
|
|
42
|
+
(override via the `timeoutMs` option) so a hung connection can't block forever.
|
|
43
|
+
|
|
39
44
|
## Money
|
|
40
45
|
|
|
41
46
|
Amounts (`balance.amount`, `transaction.amount`, `transaction.balanceAfterTransaction`) are exposed
|
package/dist/index.cjs
CHANGED
|
@@ -94,18 +94,83 @@ function base64ToBytes(b64) {
|
|
|
94
94
|
return new Uint8Array(Buffer.from(b64, "base64"));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
// package.json
|
|
98
|
+
var package_default = {
|
|
99
|
+
name: "@open-banking-io/client",
|
|
100
|
+
version: "0.2.0",
|
|
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
|
+
type: "module",
|
|
103
|
+
license: "MIT",
|
|
104
|
+
author: "open-banking.io",
|
|
105
|
+
keywords: [
|
|
106
|
+
"open-banking",
|
|
107
|
+
"psd2",
|
|
108
|
+
"zero-knowledge",
|
|
109
|
+
"encryption",
|
|
110
|
+
"fintech"
|
|
111
|
+
],
|
|
112
|
+
repository: {
|
|
113
|
+
type: "git",
|
|
114
|
+
url: "https://github.com/open-banking-io/clients"
|
|
115
|
+
},
|
|
116
|
+
engines: {
|
|
117
|
+
node: ">=20"
|
|
118
|
+
},
|
|
119
|
+
files: [
|
|
120
|
+
"dist",
|
|
121
|
+
"README.md"
|
|
122
|
+
],
|
|
123
|
+
main: "./dist/index.cjs",
|
|
124
|
+
module: "./dist/index.js",
|
|
125
|
+
types: "./dist/index.d.ts",
|
|
126
|
+
exports: {
|
|
127
|
+
".": {
|
|
128
|
+
types: "./dist/index.d.ts",
|
|
129
|
+
import: "./dist/index.js",
|
|
130
|
+
require: "./dist/index.cjs"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
scripts: {
|
|
134
|
+
build: "tsup",
|
|
135
|
+
test: "vitest run",
|
|
136
|
+
coverage: "vitest run --coverage",
|
|
137
|
+
typecheck: "tsc --noEmit",
|
|
138
|
+
lint: "eslint .",
|
|
139
|
+
"format:check": "prettier --check ."
|
|
140
|
+
},
|
|
141
|
+
devDependencies: {
|
|
142
|
+
"@eslint/js": "^9.39.4",
|
|
143
|
+
"@types/node": "^25.9.2",
|
|
144
|
+
"@vitest/coverage-v8": "^3.2.6",
|
|
145
|
+
eslint: "^9.39.4",
|
|
146
|
+
prettier: "^3.8.4",
|
|
147
|
+
tsup: "^8.3.5",
|
|
148
|
+
typescript: "^5.7.2",
|
|
149
|
+
"typescript-eslint": "^8.61.0",
|
|
150
|
+
vitest: "^3.2.6"
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/version.ts
|
|
155
|
+
var VERSION2 = package_default.version;
|
|
156
|
+
var USER_AGENT = `open-banking-io/node/${VERSION2}`;
|
|
157
|
+
|
|
97
158
|
// src/client.ts
|
|
98
159
|
var OpenBankingClient = class _OpenBankingClient {
|
|
160
|
+
/** Default per-request timeout (30s) when {@link OpenBankingClientOptions.timeoutMs} is unset. */
|
|
161
|
+
static DEFAULT_TIMEOUT_MS = 3e4;
|
|
99
162
|
baseUrl;
|
|
100
163
|
apiKey;
|
|
164
|
+
timeoutMs;
|
|
101
165
|
privateKey;
|
|
102
166
|
constructor(options) {
|
|
103
|
-
const { apiBaseUrl, apiKey, privateKeyPkcs8 } = options;
|
|
167
|
+
const { apiBaseUrl, apiKey, privateKeyPkcs8, timeoutMs } = options;
|
|
104
168
|
if (!apiBaseUrl?.trim()) throw new Error("apiBaseUrl is required");
|
|
105
169
|
if (!apiKey?.trim()) throw new Error("apiKey is required");
|
|
106
170
|
if (!privateKeyPkcs8?.trim()) throw new Error("privateKeyPkcs8 is required");
|
|
107
171
|
this.baseUrl = apiBaseUrl.replace(/\/+$/, "");
|
|
108
172
|
this.apiKey = apiKey;
|
|
173
|
+
this.timeoutMs = timeoutMs ?? _OpenBankingClient.DEFAULT_TIMEOUT_MS;
|
|
109
174
|
this.privateKey = importPrivateKey(privateKeyPkcs8);
|
|
110
175
|
}
|
|
111
176
|
/** Builds a client from a credentials-bundle JSON string or a path to a bundle file. */
|
|
@@ -257,7 +322,10 @@ var OpenBankingClient = class _OpenBankingClient {
|
|
|
257
322
|
};
|
|
258
323
|
}
|
|
259
324
|
async getJson(path) {
|
|
260
|
-
const res = await fetch(this.baseUrl + path, {
|
|
325
|
+
const res = await fetch(this.baseUrl + path, {
|
|
326
|
+
headers: { "X-Api-Key": this.apiKey, "User-Agent": USER_AGENT },
|
|
327
|
+
signal: AbortSignal.timeout(this.timeoutMs)
|
|
328
|
+
});
|
|
261
329
|
if (!res.ok) {
|
|
262
330
|
throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);
|
|
263
331
|
}
|
|
@@ -266,8 +334,13 @@ var OpenBankingClient = class _OpenBankingClient {
|
|
|
266
334
|
async postJson(path, body) {
|
|
267
335
|
const res = await fetch(this.baseUrl + path, {
|
|
268
336
|
method: "POST",
|
|
269
|
-
headers: {
|
|
270
|
-
|
|
337
|
+
headers: {
|
|
338
|
+
"X-Api-Key": this.apiKey,
|
|
339
|
+
"Content-Type": "application/json",
|
|
340
|
+
"User-Agent": USER_AGENT
|
|
341
|
+
},
|
|
342
|
+
body: JSON.stringify(body),
|
|
343
|
+
signal: AbortSignal.timeout(this.timeoutMs)
|
|
271
344
|
});
|
|
272
345
|
if (!res.ok) {
|
|
273
346
|
throw new Error(`POST ${path} failed: ${res.status} ${res.statusText}`);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/envelope.ts"],"sourcesContent":["export { OpenBankingClient } from \"./client.js\";\nexport {\n decryptEnvelope,\n decryptTo,\n importPrivateKey,\n} 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 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 private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly privateKey: Promise<CryptoKey>;\n\n constructor(options: OpenBankingClientOptions) {\n const { apiBaseUrl, apiKey, privateKeyPkcs8 } = 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.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, { headers: { \"X-Api-Key\": this.apiKey } });\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: { \"X-Api-Key\": this.apiKey, \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\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 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 {\n return new Uint8Array(Buffer.from(b64, \"base64\"));\n}\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,Q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,MAAM,IAAI,KAAK;AAAA,EACzB;AACF;","names":[]}
|
|
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,qBA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AAY,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
|
@@ -106,6 +106,11 @@ interface OpenBankingClientOptions {
|
|
|
106
106
|
apiKey: string;
|
|
107
107
|
/** The base64 PKCS#8 encryption private key from your bundle. */
|
|
108
108
|
privateKeyPkcs8: string;
|
|
109
|
+
/**
|
|
110
|
+
* Per-request timeout in milliseconds, so a hung connection can't block forever.
|
|
111
|
+
* Defaults to {@link DEFAULT_TIMEOUT_MS} (30s).
|
|
112
|
+
*/
|
|
113
|
+
timeoutMs?: number;
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
/**
|
|
@@ -114,8 +119,11 @@ interface OpenBankingClientOptions {
|
|
|
114
119
|
* only ever returns ciphertext it cannot read.
|
|
115
120
|
*/
|
|
116
121
|
declare class OpenBankingClient {
|
|
122
|
+
/** Default per-request timeout (30s) when {@link OpenBankingClientOptions.timeoutMs} is unset. */
|
|
123
|
+
static readonly DEFAULT_TIMEOUT_MS = 30000;
|
|
117
124
|
private readonly baseUrl;
|
|
118
125
|
private readonly apiKey;
|
|
126
|
+
private readonly timeoutMs;
|
|
119
127
|
private readonly privateKey;
|
|
120
128
|
constructor(options: OpenBankingClientOptions);
|
|
121
129
|
/** Builds a client from a credentials-bundle JSON string or a path to a bundle file. */
|
package/dist/index.d.ts
CHANGED
|
@@ -106,6 +106,11 @@ interface OpenBankingClientOptions {
|
|
|
106
106
|
apiKey: string;
|
|
107
107
|
/** The base64 PKCS#8 encryption private key from your bundle. */
|
|
108
108
|
privateKeyPkcs8: string;
|
|
109
|
+
/**
|
|
110
|
+
* Per-request timeout in milliseconds, so a hung connection can't block forever.
|
|
111
|
+
* Defaults to {@link DEFAULT_TIMEOUT_MS} (30s).
|
|
112
|
+
*/
|
|
113
|
+
timeoutMs?: number;
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
/**
|
|
@@ -114,8 +119,11 @@ interface OpenBankingClientOptions {
|
|
|
114
119
|
* only ever returns ciphertext it cannot read.
|
|
115
120
|
*/
|
|
116
121
|
declare class OpenBankingClient {
|
|
122
|
+
/** Default per-request timeout (30s) when {@link OpenBankingClientOptions.timeoutMs} is unset. */
|
|
123
|
+
static readonly DEFAULT_TIMEOUT_MS = 30000;
|
|
117
124
|
private readonly baseUrl;
|
|
118
125
|
private readonly apiKey;
|
|
126
|
+
private readonly timeoutMs;
|
|
119
127
|
private readonly privateKey;
|
|
120
128
|
constructor(options: OpenBankingClientOptions);
|
|
121
129
|
/** Builds a client from a credentials-bundle JSON string or a path to a bundle file. */
|
package/dist/index.js
CHANGED
|
@@ -65,18 +65,83 @@ function base64ToBytes(b64) {
|
|
|
65
65
|
return new Uint8Array(Buffer.from(b64, "base64"));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// package.json
|
|
69
|
+
var package_default = {
|
|
70
|
+
name: "@open-banking-io/client",
|
|
71
|
+
version: "0.2.0",
|
|
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
|
+
type: "module",
|
|
74
|
+
license: "MIT",
|
|
75
|
+
author: "open-banking.io",
|
|
76
|
+
keywords: [
|
|
77
|
+
"open-banking",
|
|
78
|
+
"psd2",
|
|
79
|
+
"zero-knowledge",
|
|
80
|
+
"encryption",
|
|
81
|
+
"fintech"
|
|
82
|
+
],
|
|
83
|
+
repository: {
|
|
84
|
+
type: "git",
|
|
85
|
+
url: "https://github.com/open-banking-io/clients"
|
|
86
|
+
},
|
|
87
|
+
engines: {
|
|
88
|
+
node: ">=20"
|
|
89
|
+
},
|
|
90
|
+
files: [
|
|
91
|
+
"dist",
|
|
92
|
+
"README.md"
|
|
93
|
+
],
|
|
94
|
+
main: "./dist/index.cjs",
|
|
95
|
+
module: "./dist/index.js",
|
|
96
|
+
types: "./dist/index.d.ts",
|
|
97
|
+
exports: {
|
|
98
|
+
".": {
|
|
99
|
+
types: "./dist/index.d.ts",
|
|
100
|
+
import: "./dist/index.js",
|
|
101
|
+
require: "./dist/index.cjs"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
scripts: {
|
|
105
|
+
build: "tsup",
|
|
106
|
+
test: "vitest run",
|
|
107
|
+
coverage: "vitest run --coverage",
|
|
108
|
+
typecheck: "tsc --noEmit",
|
|
109
|
+
lint: "eslint .",
|
|
110
|
+
"format:check": "prettier --check ."
|
|
111
|
+
},
|
|
112
|
+
devDependencies: {
|
|
113
|
+
"@eslint/js": "^9.39.4",
|
|
114
|
+
"@types/node": "^25.9.2",
|
|
115
|
+
"@vitest/coverage-v8": "^3.2.6",
|
|
116
|
+
eslint: "^9.39.4",
|
|
117
|
+
prettier: "^3.8.4",
|
|
118
|
+
tsup: "^8.3.5",
|
|
119
|
+
typescript: "^5.7.2",
|
|
120
|
+
"typescript-eslint": "^8.61.0",
|
|
121
|
+
vitest: "^3.2.6"
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// src/version.ts
|
|
126
|
+
var VERSION2 = package_default.version;
|
|
127
|
+
var USER_AGENT = `open-banking-io/node/${VERSION2}`;
|
|
128
|
+
|
|
68
129
|
// src/client.ts
|
|
69
130
|
var OpenBankingClient = class _OpenBankingClient {
|
|
131
|
+
/** Default per-request timeout (30s) when {@link OpenBankingClientOptions.timeoutMs} is unset. */
|
|
132
|
+
static DEFAULT_TIMEOUT_MS = 3e4;
|
|
70
133
|
baseUrl;
|
|
71
134
|
apiKey;
|
|
135
|
+
timeoutMs;
|
|
72
136
|
privateKey;
|
|
73
137
|
constructor(options) {
|
|
74
|
-
const { apiBaseUrl, apiKey, privateKeyPkcs8 } = options;
|
|
138
|
+
const { apiBaseUrl, apiKey, privateKeyPkcs8, timeoutMs } = options;
|
|
75
139
|
if (!apiBaseUrl?.trim()) throw new Error("apiBaseUrl is required");
|
|
76
140
|
if (!apiKey?.trim()) throw new Error("apiKey is required");
|
|
77
141
|
if (!privateKeyPkcs8?.trim()) throw new Error("privateKeyPkcs8 is required");
|
|
78
142
|
this.baseUrl = apiBaseUrl.replace(/\/+$/, "");
|
|
79
143
|
this.apiKey = apiKey;
|
|
144
|
+
this.timeoutMs = timeoutMs ?? _OpenBankingClient.DEFAULT_TIMEOUT_MS;
|
|
80
145
|
this.privateKey = importPrivateKey(privateKeyPkcs8);
|
|
81
146
|
}
|
|
82
147
|
/** Builds a client from a credentials-bundle JSON string or a path to a bundle file. */
|
|
@@ -228,7 +293,10 @@ var OpenBankingClient = class _OpenBankingClient {
|
|
|
228
293
|
};
|
|
229
294
|
}
|
|
230
295
|
async getJson(path) {
|
|
231
|
-
const res = await fetch(this.baseUrl + path, {
|
|
296
|
+
const res = await fetch(this.baseUrl + path, {
|
|
297
|
+
headers: { "X-Api-Key": this.apiKey, "User-Agent": USER_AGENT },
|
|
298
|
+
signal: AbortSignal.timeout(this.timeoutMs)
|
|
299
|
+
});
|
|
232
300
|
if (!res.ok) {
|
|
233
301
|
throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);
|
|
234
302
|
}
|
|
@@ -237,8 +305,13 @@ var OpenBankingClient = class _OpenBankingClient {
|
|
|
237
305
|
async postJson(path, body) {
|
|
238
306
|
const res = await fetch(this.baseUrl + path, {
|
|
239
307
|
method: "POST",
|
|
240
|
-
headers: {
|
|
241
|
-
|
|
308
|
+
headers: {
|
|
309
|
+
"X-Api-Key": this.apiKey,
|
|
310
|
+
"Content-Type": "application/json",
|
|
311
|
+
"User-Agent": USER_AGENT
|
|
312
|
+
},
|
|
313
|
+
body: JSON.stringify(body),
|
|
314
|
+
signal: AbortSignal.timeout(this.timeoutMs)
|
|
242
315
|
});
|
|
243
316
|
if (!res.ok) {
|
|
244
317
|
throw new Error(`POST ${path} failed: ${res.status} ${res.statusText}`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/envelope.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { decryptTo, importPrivateKey, type CryptoKey } from \"./envelope.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 private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly privateKey: Promise<CryptoKey>;\n\n constructor(options: OpenBankingClientOptions) {\n const { apiBaseUrl, apiKey, privateKeyPkcs8 } = 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.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, { headers: { \"X-Api-Key\": this.apiKey } });\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: { \"X-Api-Key\": this.apiKey, \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\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 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 {\n return new Uint8Array(Buffer.from(b64, \"base64\"));\n}\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,IAAI,SAAS;AAC9C,QAAM,QAAQ,MAAM,SAAS,IAAI,WAAW,IAAI,YAAY,SAAS;AACrE,QAAM,MAAM,MAAM,SAAS,IAAI,YAAY,WAAW,IAAI,YAAY,YAAY,OAAO;AACzF,QAAM,aAAa,MAAM,SAAS,IAAI,YAAY,YAAY,OAAO;AAErE,QAAM,SAAS,MAAM,OAA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BAAiB,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,EAAE,SAAS,EAAE,aAAa,KAAK,OAAO,EAAE,CAAC;AACtF,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,EAAE,aAAa,KAAK,QAAQ,gBAAgB,mBAAmB;AAAA,MACxE,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,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":[]}
|
|
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,IAAI,SAAS;AAC9C,QAAM,QAAQ,MAAM,SAAS,IAAI,WAAW,IAAI,YAAY,SAAS;AACrE,QAAM,MAAM,MAAM,SAAS,IAAI,YAAY,WAAW,IAAI,YAAY,YAAY,OAAO;AACzF,QAAM,aAAa,MAAM,SAAS,IAAI,YAAY,YAAY,OAAO;AAKrE,QAAM,SAAS,MAAM,OAAO;AAAA,IAC1B;AAAA,IACA;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AM;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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-banking-io/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|
|
@@ -36,13 +36,20 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsup",
|
|
38
38
|
"test": "vitest run",
|
|
39
|
+
"coverage": "vitest run --coverage",
|
|
39
40
|
"typecheck": "tsc --noEmit",
|
|
40
|
-
"lint": "
|
|
41
|
+
"lint": "eslint .",
|
|
42
|
+
"format:check": "prettier --check ."
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
|
-
"@
|
|
45
|
+
"@eslint/js": "^9.39.4",
|
|
46
|
+
"@types/node": "^25.9.2",
|
|
47
|
+
"@vitest/coverage-v8": "^3.2.6",
|
|
48
|
+
"eslint": "^9.39.4",
|
|
49
|
+
"prettier": "^3.8.4",
|
|
44
50
|
"tsup": "^8.3.5",
|
|
45
51
|
"typescript": "^5.7.2",
|
|
46
|
-
"
|
|
52
|
+
"typescript-eslint": "^8.61.0",
|
|
53
|
+
"vitest": "^3.2.6"
|
|
47
54
|
}
|
|
48
55
|
}
|