@mft/moneyhub-api-client 6.94.0 → 6.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/CHANGELOG.md +11 -1
  3. package/README.md +42 -0
  4. package/dist/discovery.d.ts +75 -0
  5. package/dist/discovery.d.ts.map +1 -0
  6. package/dist/discovery.js +169 -0
  7. package/dist/discovery.js.map +1 -0
  8. package/dist/index.d.ts +37 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +61 -24
  11. package/dist/index.js.map +1 -1
  12. package/dist/oidc-config.d.ts +17 -0
  13. package/dist/oidc-config.d.ts.map +1 -0
  14. package/dist/oidc-config.js +44 -0
  15. package/dist/oidc-config.js.map +1 -0
  16. package/dist/request.d.ts +11 -3
  17. package/dist/request.d.ts.map +1 -1
  18. package/dist/request.js +38 -7
  19. package/dist/request.js.map +1 -1
  20. package/dist/requests/caas/accounts.d.ts +5 -0
  21. package/dist/requests/caas/accounts.d.ts.map +1 -0
  22. package/dist/requests/caas/accounts.js +17 -0
  23. package/dist/requests/caas/accounts.js.map +1 -0
  24. package/dist/requests/caas/categories.d.ts +5 -0
  25. package/dist/requests/caas/categories.d.ts.map +1 -0
  26. package/dist/requests/caas/categories.js +26 -0
  27. package/dist/requests/caas/categories.js.map +1 -0
  28. package/dist/requests/caas/counterparties.d.ts +5 -0
  29. package/dist/requests/caas/counterparties.d.ts.map +1 -0
  30. package/dist/requests/caas/counterparties.js +18 -0
  31. package/dist/requests/caas/counterparties.js.map +1 -0
  32. package/dist/requests/caas/geotags.d.ts +5 -0
  33. package/dist/requests/caas/geotags.d.ts.map +1 -0
  34. package/dist/requests/caas/geotags.js +18 -0
  35. package/dist/requests/caas/geotags.js.map +1 -0
  36. package/dist/requests/caas/transactions.d.ts +5 -0
  37. package/dist/requests/caas/transactions.d.ts.map +1 -0
  38. package/dist/requests/caas/transactions.js +46 -0
  39. package/dist/requests/caas/transactions.js.map +1 -0
  40. package/dist/requests/caas/types/accounts.d.ts +7 -0
  41. package/dist/requests/caas/types/accounts.d.ts.map +1 -0
  42. package/dist/requests/{types/reseller.js → caas/types/accounts.js} +1 -1
  43. package/dist/requests/caas/types/accounts.js.map +1 -0
  44. package/dist/requests/caas/types/categories.d.ts +17 -0
  45. package/dist/requests/caas/types/categories.d.ts.map +1 -0
  46. package/dist/{schema/payment-link.js → requests/caas/types/categories.js} +1 -1
  47. package/dist/requests/caas/types/categories.js.map +1 -0
  48. package/dist/requests/caas/types/counterparties.d.ts +9 -0
  49. package/dist/requests/caas/types/counterparties.d.ts.map +1 -0
  50. package/dist/requests/caas/types/counterparties.js +3 -0
  51. package/dist/requests/caas/types/counterparties.js.map +1 -0
  52. package/dist/requests/caas/types/geotags.d.ts +8 -0
  53. package/dist/requests/caas/types/geotags.d.ts.map +1 -0
  54. package/dist/requests/{types/payment-links.js → caas/types/geotags.js} +1 -1
  55. package/dist/requests/caas/types/geotags.js.map +1 -0
  56. package/dist/requests/caas/types/transactions.d.ts +97 -0
  57. package/dist/requests/caas/types/transactions.d.ts.map +1 -0
  58. package/dist/requests/caas/types/transactions.js +3 -0
  59. package/dist/requests/caas/types/transactions.js.map +1 -0
  60. package/dist/requests/caas/types/users.d.ts +7 -0
  61. package/dist/requests/caas/types/users.d.ts.map +1 -0
  62. package/dist/requests/caas/types/users.js +3 -0
  63. package/dist/requests/caas/types/users.js.map +1 -0
  64. package/dist/requests/caas/users.d.ts +5 -0
  65. package/dist/requests/caas/users.d.ts.map +1 -0
  66. package/dist/requests/caas/users.js +17 -0
  67. package/dist/requests/caas/users.js.map +1 -0
  68. package/dist/requests/consent-history.d.ts +5 -0
  69. package/dist/requests/consent-history.d.ts.map +1 -0
  70. package/dist/requests/consent-history.js +17 -0
  71. package/dist/requests/consent-history.js.map +1 -0
  72. package/dist/requests/index.d.ts +37 -0
  73. package/dist/requests/index.d.ts.map +1 -1
  74. package/dist/requests/index.js +14 -0
  75. package/dist/requests/index.js.map +1 -1
  76. package/dist/requests/recurring-payments.d.ts.map +1 -1
  77. package/dist/requests/recurring-payments.js +8 -0
  78. package/dist/requests/recurring-payments.js.map +1 -1
  79. package/dist/requests/standard-financial-statements.d.ts +5 -0
  80. package/dist/requests/standard-financial-statements.d.ts.map +1 -0
  81. package/dist/requests/standard-financial-statements.js +23 -0
  82. package/dist/requests/standard-financial-statements.js.map +1 -0
  83. package/dist/requests/types/consent-history.d.ts +6 -0
  84. package/dist/requests/types/consent-history.d.ts.map +1 -0
  85. package/dist/requests/types/consent-history.js +3 -0
  86. package/dist/requests/types/consent-history.js.map +1 -0
  87. package/dist/requests/types/recurring-payments.d.ts +5 -1
  88. package/dist/requests/types/recurring-payments.d.ts.map +1 -1
  89. package/dist/requests/types/standard-financial-statements.d.ts +17 -0
  90. package/dist/requests/types/standard-financial-statements.d.ts.map +1 -0
  91. package/dist/requests/types/standard-financial-statements.js +3 -0
  92. package/dist/requests/types/standard-financial-statements.js.map +1 -0
  93. package/dist/requests/unauthenticated.d.ts.map +1 -1
  94. package/dist/requests/unauthenticated.js +2 -2
  95. package/dist/requests/unauthenticated.js.map +1 -1
  96. package/dist/requests/users-and-connections.d.ts.map +1 -1
  97. package/dist/requests/users-and-connections.js +2 -1
  98. package/dist/requests/users-and-connections.js.map +1 -1
  99. package/dist/schema/config.d.ts +13 -0
  100. package/dist/schema/config.d.ts.map +1 -1
  101. package/dist/schema/consent-history.d.ts +31 -0
  102. package/dist/schema/consent-history.d.ts.map +1 -0
  103. package/dist/schema/consent-history.js +3 -0
  104. package/dist/schema/consent-history.js.map +1 -0
  105. package/dist/schema/payment.d.ts +11 -0
  106. package/dist/schema/payment.d.ts.map +1 -1
  107. package/dist/schema/scim-user.d.ts +4 -0
  108. package/dist/schema/scim-user.d.ts.map +1 -1
  109. package/dist/schema/standard-financial-statement.d.ts +21 -0
  110. package/dist/schema/standard-financial-statement.d.ts.map +1 -0
  111. package/dist/schema/standard-financial-statement.js +3 -0
  112. package/dist/schema/standard-financial-statement.js.map +1 -0
  113. package/dist/schema/statement.d.ts.map +1 -1
  114. package/dist/schema/statement.js +1 -0
  115. package/dist/schema/statement.js.map +1 -1
  116. package/dist/tokens.js +1 -1
  117. package/dist/tokens.js.map +1 -1
  118. package/docs/readme.md +2430 -0
  119. package/package.json +5 -2
  120. package/readme.md +210 -9
  121. package/dist/get-payment-link.d.ts +0 -15
  122. package/dist/get-payment-link.d.ts.map +0 -1
  123. package/dist/get-payment-link.js +0 -61
  124. package/dist/get-payment-link.js.map +0 -1
  125. package/dist/requests/payment-links.d.ts +0 -5
  126. package/dist/requests/payment-links.d.ts.map +0 -1
  127. package/dist/requests/payment-links.js +0 -32
  128. package/dist/requests/payment-links.js.map +0 -1
  129. package/dist/requests/reseller.d.ts +0 -5
  130. package/dist/requests/reseller.d.ts.map +0 -1
  131. package/dist/requests/reseller.js +0 -21
  132. package/dist/requests/reseller.js.map +0 -1
  133. package/dist/requests/types/payment-links.d.ts +0 -23
  134. package/dist/requests/types/payment-links.d.ts.map +0 -1
  135. package/dist/requests/types/payment-links.js.map +0 -1
  136. package/dist/requests/types/reseller.d.ts +0 -10
  137. package/dist/requests/types/reseller.d.ts.map +0 -1
  138. package/dist/requests/types/reseller.js.map +0 -1
  139. package/dist/schema/payment-link.d.ts +0 -18
  140. package/dist/schema/payment-link.d.ts.map +0 -1
  141. package/dist/schema/payment-link.js.map +0 -1
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@mft/moneyhub-api-client",
3
- "version": "6.94.0",
3
+ "version": "6.95.0",
4
4
  "description": "Node.JS client for the Moneyhub API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "lint": "eslint src/ ",
9
+ "lint-fix": "eslint src/ --fix",
9
10
  "test": "mocha --require ts-node/register --config test/opts/integration.json",
10
11
  "test-ci": "mocha --require ts-node/register --config test/opts/integration-ci.json || true",
11
12
  "prepare": "husky install",
12
13
  "prepublishOnly": "npm run build",
13
14
  "build": "tsc",
15
+ "create-jwks": "node examples/jwks/create-jwks.js",
14
16
  "ts-node": "ts-node",
15
17
  "snyk-ci": "snyk test --fail-on=all --severity-threshold=high",
16
18
  "snyk": "snyk test"
@@ -30,6 +32,7 @@
30
32
  "node": ">= 12.0.0"
31
33
  },
32
34
  "dependencies": {
35
+ "@isaacs/ttlcache": "^2.1.4",
33
36
  "form-data": "^3.0.4",
34
37
  "got": "^11.8.5",
35
38
  "jose": "^5.2.3",
@@ -48,7 +51,7 @@
48
51
  "chai": "^4.3.6",
49
52
  "command-line-args": "^5.2.1",
50
53
  "command-line-usage": "^6.1.1",
51
- "config": "^3.3.7",
54
+ "config": "^4.2.0",
52
55
  "eslint": "^8.20.0",
53
56
  "expect-type": "^0.13.0",
54
57
  "express": "^4.17.3",
package/readme.md CHANGED
@@ -26,6 +26,7 @@ This is an Node.JS client for the [Moneyhub API](https://docs.moneyhubenterprise
26
26
  - Get a tax return for a subset of transactions
27
27
  - Get the regular transactions on an account
28
28
  - Get beneficiaries
29
+ - CAAS (Categorisation as a Service) API for advanced transaction enrichment and categorisation
29
30
 
30
31
  Currently this library supports `client_secret_basic`, `client_secret_jwt` and `private_key_jwt` authentication.
31
32
 
@@ -35,7 +36,7 @@ The breaking changes when upgrading are outlined below:
35
36
 
36
37
  - Normalisation of all methods to use object destructuring to pass parameters. Please refer to the docs of each method when migrating to this version
37
38
 
38
- - Delete methods only return the status code when succesful
39
+ - Delete methods only return the status code when successful
39
40
 
40
41
  - All methods to retrieve data return the body response as json, on previous versions some methods were returning the full response from the got library.
41
42
 
@@ -73,6 +74,23 @@ To use this API client you will need:
73
74
 
74
75
  `npm install @mft/moneyhub-api-client`
75
76
 
77
+ ## Creating JWKS
78
+
79
+ If you need to generate JWKS (JSON Web Key Set) for authentication with `private_key_jwt`, you can use the provided script:
80
+
81
+ ```bash
82
+ npm run create-jwks -- --key-alg RS256 --key-size 2048 --key-use sig --alg RS256
83
+ ```
84
+
85
+ ### Options
86
+
87
+ - `--key-alg`: The key algorithm (default: uses the value from `--alg`)
88
+ - `--key-size`: The key size in bits (default: 2048)
89
+ - `--key-use`: The key usage, typically `sig` for signing (default: sig)
90
+ - `--alg`: The signing algorithm, e.g., `RS256`, `RS384`, `RS512` (default: RS256)
91
+
92
+ This will generate both public and private JWKS. The public keys should be added to your API client configuration in the Moneyhub Admin portal, and the private keys should be used as the `keys` value when configuring the Moneyhub API client.
93
+
76
94
  ## Usage
77
95
 
78
96
  This module exposes a single factory function that accepts the following configuration:
@@ -158,6 +176,63 @@ At least one of the following parameters needs to be passed in to any api call t
158
176
  - **token**: The token will be added as bearer authorization header
159
177
  - **Authorization header**: The full authorisation header can be passed in
160
178
 
179
+ ## Using the client behind a gateway
180
+
181
+ The client keeps the original resource URLs in config (`resourceServerUrl`, `identityServiceUrl`, `caasResourceServerUrl`, `osipResourceServerUrl`, `accountConnectUrl`). You can optionally set a **gateway URL** for each resource (`gatewayResourceServerUrl`, `gatewayIdentityServiceUrl`, `gatewayCaasResourceServerUrl`, `gatewayOsipResourceServerUrl`, `gatewayAccountConnectUrl`). **Only when a gateway URL is set** for a resource does the client use that URL for requests to that resource and rewrite responses to it. If you only route one resource through a gateway, set only that resource’s gateway URL; the others stay on the original URLs and no rewriting occurs for them. Example:
182
+
183
+ ```javascript
184
+ const moneyhub = await Moneyhub({
185
+ resourceServerUrl: "https://api.moneyhub.co.uk/v3",
186
+ identityServiceUrl: "https://identity.moneyhub.co.uk",
187
+ gatewayResourceServerUrl: "https://my-gateway.example.com/moneyhub/v3",
188
+ gatewayIdentityServiceUrl: "https://my-gateway.example.com/moneyhub/identity",
189
+ options: {
190
+ openIdConfigCacheTtlMs: 3600000, // optional; default 1 hour
191
+ },
192
+ client: { /* ... */ },
193
+ })
194
+ ```
195
+
196
+ Behaviour:
197
+
198
+ - **Identity**: When `gatewayIdentityServiceUrl` is set, the client fetches the OpenID discovery document from that URL and rewrites endpoint URLs in the document to use it, so that authorization, token exchange, and JWKS requests go through the gateway. When it is not set, discovery is fetched from `identityServiceUrl` and no rewriting is applied.
199
+ - **Resource server**: When `gatewayResourceServerUrl` (or `gatewayCaasResourceServerUrl` or `gatewayOsipResourceServerUrl`) is set, the client uses that URL for requests to that API and rewrites link URLs in responses (e.g. `links.self`, `links.next`, `links.prev`) to that base. When no gateway URL is set for that resource, the client uses the original URL and does not rewrite response links.
200
+
201
+ **Verifying behaviour**: Run the unit tests for the rewrite logic with `npx mocha --require ts-node/register "src/__tests__/discovery.ts"`; run the integration tests for gateway rewriting with `npm run test -- -g "Gateway URL rewriting"` (or run the full test suite as described in [Running Tests](#running-tests)); in production, check your gateway access logs to confirm identity and API requests hit the gateway, or inspect `getOpenIdConfig()` and any `response.links` to see gateway URLs.
202
+
203
+ ### Security considerations
204
+
205
+ The following points are intended for security review (e.g. by banks or regulated entities).
206
+
207
+ - **Rewrite target is always a configured gateway URL**
208
+ URLs are rewritten only to the gateway base URLs you supply (`gatewayIdentityServiceUrl`, `gatewayResourceServerUrl`, etc.). The client never uses a URL from a response or discovery document as the *target* of the rewrite. An attacker who could influence response content cannot cause the client to send traffic to an arbitrary or malicious host.
209
+
210
+ - **TLS and certificates**
211
+ The client validates TLS only to the configured base (the gateway). The gateway is responsible for TLS to the upstream identity and API services. No new certificate or trust store requirements are introduced by the library.
212
+
213
+ - **OIDC issuer claim and discovery `issuer`**
214
+ ID tokens from the identity provider carry an `iss` (issuer) claim. Many OIDC clients validate that the token’s `iss` matches the Issuer’s `issuer` from discovery. When using a gateway, the implementation may leave the discovery `issuer` field unchanged so that token validation continues to expect the IdP’s canonical `iss`; or the identity service behind the gateway may be configured to issue tokens with `iss` equal to the gateway URL. See the release notes or implementation docs for the chosen behaviour so you can align with your IdP and validation policies.
215
+
216
+ - **Response body integrity**
217
+ The client modifies response bodies (e.g. `links`) for resource server responses. If you sign or checksum the *full* response body elsewhere, rewriting URL fields would invalidate that. Treat the client as the consumer of the API for integrity purposes, or apply signing after the client (e.g. at the gateway) so the signed payload is the rewritten one.
218
+
219
+ - **Secrets**
220
+ Client credentials, keys, and tokens are used as in the standard flow. No new storage, logging, or transmission of secrets is introduced by the gateway rewrite logic.
221
+
222
+ ### Governance considerations
223
+
224
+ - **Change control and risk**
225
+ The gateway feature alters outbound request behaviour (discovery used for the Issuer) and response bodies (resource server links). Release notes and CHANGELOG describe the change. Summary: enables gateway-only routing; no new external dependency; rewrite targets are config-only; considerations include issuer claim alignment and response body integrity as above.
226
+
227
+ - **Audit and assurance**
228
+ To demonstrate that traffic to Moneyhub goes through your approved gateway, set the relevant gateway URLs and use the verification steps above (tests, gateway logs, inspection of `getOpenIdConfig()` and `response.links`). Internal or external audit can rely on config plus these verification steps.
229
+
230
+ - **Third-party and supply chain**
231
+ The client uses `@isaacs/ttlcache` for OIDC discovery caching. Rewrite targets are never taken from responses or discovery documents.
232
+
233
+ - **Regulatory and outsourcing**
234
+ Use of a gateway is your architectural choice; this feature makes it possible for the client to honour that choice. Regulatory implications (e.g. outsourcing, record-keeping) remain with your use of the gateway and the Moneyhub service, not with the library change itself.
235
+
161
236
  ## API
162
237
  Once the api client has been initialised it provides a simple promise based interface with the following methods:
163
238
 
@@ -364,10 +439,10 @@ const defaultClaims = {
364
439
  #### `exchangeCodeForTokensLegacy`
365
440
 
366
441
  This is a legacy method to get tokens for a user.
367
- After a user has succesfully authorised they will be redirected to your redirect_uri with an authorization code. You can use this to retrieve access, refresh and id tokens for the user.
442
+ After a user has successfully authorised they will be redirected to your redirect_uri with an authorization code. You can use this to retrieve access, refresh and id tokens for the user.
368
443
 
369
444
  ```javascript
370
- const tokens = await moneyhub.exchangeCodeForTokens({
445
+ const tokens = await moneyhub.exchangeCodeForTokensLegacy({
371
446
  code: "the authorization code",
372
447
  nonce: "your nonce value", // optional
373
448
  state: "your state value", // optional
@@ -377,7 +452,7 @@ const tokens = await moneyhub.exchangeCodeForTokens({
377
452
 
378
453
  #### `exchangeCodeForTokens`
379
454
 
380
- After a user has succesfully authorised they will be redirected to your redirect_uri with an authorization code. You can use this method to retrieve access, refresh and id tokens for the user.
455
+ After a user has successfully authorised they will be redirected to your redirect_uri with an authorization code. You can use this method to retrieve access, refresh and id tokens for the user.
381
456
 
382
457
  The signature for this method changed in v3.
383
458
  The previous function is available at 'exchangeCodeForTokensLegacy'
@@ -531,7 +606,7 @@ const tokens = await moneyhub.createAuthRequest({
531
606
 
532
607
  #### `completeAuthRequest`
533
608
 
534
- Completes an auth request succesfully
609
+ Completes an auth request successfully
535
610
 
536
611
  ```javascript
537
612
  const tokens = await moneyhub.completeAuthRequest({
@@ -2138,6 +2213,129 @@ const resellerCheck = await moneyhub.createResellerCheckRequest({
2138
2213
  }, options);
2139
2214
  ```
2140
2215
 
2216
+ ### CAAS API
2217
+
2218
+ The CAAS (Categorisation as a Service) API provides advanced transaction enrichment, categorisation, and management capabilities. All CAAS endpoints use dedicated scopes prefixed with `caas:`.
2219
+
2220
+ #### `caasEnrichTransactions`
2221
+
2222
+ Enrich transactions with detailed categorisation, counterparty information, and geolocation data. This function uses the scope `caas:transactions:write`.
2223
+
2224
+ ```javascript
2225
+ const transactions = [
2226
+ {
2227
+ userId: "0a1327eb-26b9-4abc-b932-ff61cb27b227",
2228
+ accountId: "10ed62b0-05f7-4a24-8ed1-0c503fc58924",
2229
+ transactionId: "a8b7c6d5-e4f3-2a1b-3c4d-5e6f7a8b9c01",
2230
+ accountType: "cash",
2231
+ txCode: "",
2232
+ date: "2025-12-01T00:00:00.000Z",
2233
+ status: "posted",
2234
+ description: "Tesco Milton Keynes",
2235
+ amount: -125.67,
2236
+ currency: "GBP",
2237
+ merchantCategoryCode: "5411",
2238
+ cardPresent: true,
2239
+ },
2240
+ ];
2241
+
2242
+ const result = await moneyhub.caasEnrichTransactions({
2243
+ transactions: transactions,
2244
+ }, options);
2245
+ ```
2246
+
2247
+ #### `caasGetTransactions`
2248
+
2249
+ Get transactions from the CAAS API with optional filtering by user and limit. This function uses the scope `caas:transactions:read`.
2250
+
2251
+ ```javascript
2252
+ const result = await moneyhub.caasGetTransactions({
2253
+ accountId: "accountId",
2254
+ userId: "userId", // optional
2255
+ limit: 50, // optional
2256
+ }, options);
2257
+ ```
2258
+
2259
+ #### `caasPatchTransaction`
2260
+
2261
+ Update a transaction category via the CAAS endpoint. This function uses the scope `caas:transactions:write` and returns the updated transaction data under `data`.
2262
+
2263
+ ```javascript
2264
+ const result = await moneyhub.caasPatchTransaction({
2265
+ accountId: "accountId",
2266
+ transactionId: "transactionId",
2267
+ l2CategoryId: "21",
2268
+ }, options);
2269
+ ```
2270
+
2271
+ #### `caasDeleteTransaction`
2272
+
2273
+ Delete a transaction via the CAAS endpoint. This function uses the scope `caas:transactions:delete`.
2274
+
2275
+ ```javascript
2276
+ await moneyhub.caasDeleteTransaction({
2277
+ accountId: "accountId",
2278
+ transactionId: "transactionId",
2279
+ }, options);
2280
+ ```
2281
+
2282
+ #### `caasGetCategories`
2283
+
2284
+ Get all available CAAS categories. This function uses the scope `caas:categories:read`.
2285
+
2286
+ ```javascript
2287
+ const result = await moneyhub.caasGetCategories(options);
2288
+ ```
2289
+
2290
+ #### `caasGetCategoryGroups`
2291
+
2292
+ Get all available CAAS category groups. This function uses the scope `caas:categories:read`.
2293
+
2294
+ ```javascript
2295
+ const result = await moneyhub.caasGetCategoryGroups(options);
2296
+ ```
2297
+
2298
+ #### `caasGetCounterparties`
2299
+
2300
+ Get counterparties with optional pagination. This function uses the scope `caas:transactions:read`.
2301
+
2302
+ ```javascript
2303
+ const result = await moneyhub.caasGetCounterparties({
2304
+ limit: 50, // optional
2305
+ offset: 0, // optional
2306
+ }, options);
2307
+ ```
2308
+
2309
+ #### `caasGetGeotags`
2310
+
2311
+ Get geotag information for specific geotag IDs. This function uses the scope `caas:transactions:read`.
2312
+
2313
+ ```javascript
2314
+ const result = await moneyhub.caasGetGeotags({
2315
+ geotagIds: ["geotag-id-1", "geotag-id-2"],
2316
+ }, options);
2317
+ ```
2318
+
2319
+ #### `caasDeleteAccount`
2320
+
2321
+ Delete an account via the CAAS endpoint. This function uses the scope `caas:users:delete`.
2322
+
2323
+ ```javascript
2324
+ await moneyhub.caasDeleteAccount({
2325
+ accountId: "accountId",
2326
+ }, options);
2327
+ ```
2328
+
2329
+ #### `caasDeleteUser`
2330
+
2331
+ Delete a user via the CAAS endpoint. This function uses the scope `caas:users:delete`.
2332
+
2333
+ ```javascript
2334
+ await moneyhub.caasDeleteUser({
2335
+ userId: "userId",
2336
+ }, options);
2337
+ ```
2338
+
2141
2339
  ### Financial Connections
2142
2340
 
2143
2341
  #### `listConnections`
@@ -2184,10 +2382,13 @@ const availableConnections = await moneyhub.listPaymentsConnections();
2184
2382
 
2185
2383
  #### `getOpenIdConfig`
2186
2384
 
2187
- This method will resolve with our open id configuration.
2385
+ Returns the OpenID Connect discovery document (e.g. `issuer`, `authorization_endpoint`, `token_endpoint`, `jwks_uri`).
2386
+
2387
+ > [!IMPORTANT]
2388
+ > When `gatewayIdentityServiceUrl` is set, endpoint URLs in the discovery document are rewritten to that base; the result is cached for `openIdConfigCacheTtlMs` (default 1 hour). See [Using the client behind a gateway](#using-the-client-behind-a-gateway).
2188
2389
 
2189
2390
  ```javascript
2190
- const availableConnections = await moneyhub.getOpenIdConfig();
2391
+ const openIdConfig = await moneyhub.getOpenIdConfig();
2191
2392
  ```
2192
2393
 
2193
2394
  ### Examples
@@ -2210,7 +2411,7 @@ The tests use root level Mocha hooks to set up and teardown test data. When addi
2210
2411
 
2211
2412
  ### Troubleshooting tests
2212
2413
 
2213
- - If any errors occurr during test setup or teardown, this should appear as happening in the "before all" or "after all" hook in `"{root}"` with the error.
2414
+ - If any errors occur during test setup or teardown, this should appear as happening in the "before all" or "after all" hook in `"{root}"` with the error.
2214
2415
  - Errors in the `before all` hook can cause errors in the `after all` hook as it won't be able to find data to clear up.
2215
2416
 
2216
2417
  ## TypeScript
@@ -2226,4 +2427,4 @@ const getAccounts = ({userId}) => {
2226
2427
  }
2227
2428
  ```
2228
2429
 
2229
- The default export is of the Moneyhub constructor that takes in an argument of the config. You can use `ApiClientConfig` to type that config. The client object that is returned from the constructor can then be used to make API calls. The methods are available with arguments and returns typed.
2430
+ The named export `Moneyhub` is the factory function that creates the client; it takes your config (typed with `ApiClientConfig`) and returns a promise of the client instance. The client object can then be used to make API calls, with methods, arguments and return types all typed.
@@ -1,15 +0,0 @@
1
- import { Client } from "openid-client";
2
- import { ApiClientConfig } from "./schema/config";
3
- declare const _default: ({ config }: {
4
- client: Client;
5
- config: ApiClientConfig;
6
- }) => {
7
- createPaymentLinkUrl: ({ expirationTime, params, url, }: {
8
- url?: string | undefined;
9
- expirationTime: string | number;
10
- params: Record<string, any>;
11
- type: "widget";
12
- }) => Promise<string>;
13
- };
14
- export default _default;
15
- //# sourceMappingURL=get-payment-link.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-payment-link.d.ts","sourceRoot":"","sources":["../src/get-payment-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAA;AAGpC,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAA;;YAEZ,MAAM;YAAU,eAAe;;;;wBAyD9C,MAAM,GAAG,MAAM;gBACvB,OAAO,MAAM,EAAE,GAAG,CAAC;cACrB,QAAQ;;;AA3DlB,wBAoEC"}
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const jose = __importStar(require("jose"));
27
- const crypto = __importStar(require("crypto"));
28
- exports.default = ({ config }) => {
29
- const { identityServiceUrl, client: { client_id, keys, request_object_signing_alg }, } = config;
30
- const formatLinkUrl = ({ url, jwt, params, }) => {
31
- if (url) {
32
- return `${url}#linkParams=${jwt}`;
33
- }
34
- return `${identityServiceUrl}/widget-pages/${params === null || params === void 0 ? void 0 : params.widgetId}#linkParams=${jwt}`;
35
- };
36
- const formatJWTPayload = async ({ expirationTime, params, }) => {
37
- const privateJWK = keys.find(({ alg }) => alg === request_object_signing_alg);
38
- if (!privateJWK)
39
- throw new Error(`Private key with alg ${request_object_signing_alg} missing`);
40
- const privateKey = await jose.importJWK(privateJWK);
41
- return new jose.SignJWT(params)
42
- .setProtectedHeader({
43
- alg: request_object_signing_alg,
44
- kid: privateJWK.kid,
45
- })
46
- .setAudience(identityServiceUrl)
47
- .setIssuer(client_id)
48
- .setJti(jose.base64url.encode(crypto.randomBytes(32)))
49
- .setIssuedAt()
50
- .setExpirationTime(expirationTime)
51
- .sign(privateKey);
52
- };
53
- const createPaymentLinkUrl = async ({ expirationTime, params, url, }) => {
54
- const jwt = await formatJWTPayload({ expirationTime, params });
55
- return formatLinkUrl({ url, jwt, params });
56
- };
57
- return {
58
- createPaymentLinkUrl,
59
- };
60
- };
61
- //# sourceMappingURL=get-payment-link.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-payment-link.js","sourceRoot":"","sources":["../src/get-payment-link.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA4B;AAC5B,+CAAgC;AAGhC,kBAAe,CAAC,EAAC,MAAM,EAA4C,EAAE,EAAE;IACrE,MAAM,EACJ,kBAAkB,EAClB,MAAM,EAAE,EAAC,SAAS,EAAE,IAAI,EAAE,0BAA0B,EAAC,GACtD,GAAG,MAAM,CAAA;IAEV,MAAM,aAAa,GAAG,CAAC,EACrB,GAAG,EACH,GAAG,EACH,MAAM,GAKP,EAAE,EAAE;QACH,IAAI,GAAG,EAAE;YACP,OAAO,GAAG,GAAG,eAAe,GAAG,EAAE,CAAA;SAClC;QACD,OAAO,GAAG,kBAAkB,iBAAiB,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,eAAe,GAAG,EAAE,CAAA;IACnF,CAAC,CAAA;IAED,MAAM,gBAAgB,GAAG,KAAK,EAAE,EAC9B,cAAc,EACd,MAAM,GAIP,EAAE,EAAE;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAC1B,CAAC,EAAC,GAAG,EAAC,EAAE,EAAE,CAAC,GAAG,KAAK,0BAA0B,CAClC,CAAA;QACb,IAAI,CAAC,UAAU;YACb,MAAM,IAAI,KAAK,CACb,wBAAwB,0BAA0B,UAAU,CAC7D,CAAA;QAEH,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAEnD,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;aAC5B,kBAAkB,CAAC;YAClB,GAAG,EAAE,0BAA0B;YAC/B,GAAG,EAAE,UAAU,CAAC,GAAG;SACpB,CAAC;aACD,WAAW,CAAC,kBAAkB,CAAC;aAC/B,SAAS,CAAC,SAAS,CAAC;aACpB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;aACrD,WAAW,EAAE;aACb,iBAAiB,CAAC,cAAc,CAAC;aACjC,IAAI,CAAC,UAAU,CAAC,CAAA;IACrB,CAAC,CAAA;IAED,MAAM,oBAAoB,GAAG,KAAK,EAAE,EAClC,cAAc,EACd,MAAM,EACN,GAAG,GAMJ,EAAE,EAAE;QACH,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,EAAC,cAAc,EAAE,MAAM,EAAC,CAAC,CAAA;QAC5D,OAAO,aAAa,CAAC,EAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAC,CAAC,CAAA;IAC1C,CAAC,CAAA;IAED,OAAO;QACL,oBAAoB;KACrB,CAAA;AACH,CAAC,CAAA"}
@@ -1,5 +0,0 @@
1
- import { RequestsParams } from "../request";
2
- import { PaymentLinksRequests } from "./types/payment-links";
3
- declare const _default: ({ config, request }: RequestsParams) => PaymentLinksRequests;
4
- export default _default;
5
- //# sourceMappingURL=payment-links.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment-links.d.ts","sourceRoot":"","sources":["../../src/requests/payment-links.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAC,MAAM,YAAY,CAAA;AACpE,OAAO,EACL,oBAAoB,EAIrB,MAAM,uBAAuB,CAAA;8CAGK,cAAc,KAAG,oBAAoB;AAAxE,wBA2CC"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = ({ config, request }) => {
4
- const { identityServiceUrl } = config;
5
- const addPaymentLink = (body, options) => request(`${identityServiceUrl}/payment-links`, {
6
- method: "POST",
7
- body,
8
- cc: {
9
- scope: "payment_link:create",
10
- },
11
- options,
12
- });
13
- const getPaymentLink = ({ id }, options) => request(`${identityServiceUrl}/payment-links/${id}`, {
14
- cc: {
15
- scope: "payment_link:read",
16
- },
17
- options,
18
- });
19
- const getPaymentLinks = (params = {}, options) => request(`${identityServiceUrl}/payment-links`, {
20
- searchParams: params,
21
- cc: {
22
- scope: "payment_link:read",
23
- },
24
- options,
25
- });
26
- return {
27
- addPaymentLink,
28
- getPaymentLink,
29
- getPaymentLinks,
30
- };
31
- };
32
- //# sourceMappingURL=payment-links.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment-links.js","sourceRoot":"","sources":["../../src/requests/payment-links.ts"],"names":[],"mappings":";;AASA,kBAAe,CAAC,EAAC,MAAM,EAAE,OAAO,EAAiB,EAAwB,EAAE;IACzE,MAAM,EAAC,kBAAkB,EAAC,GAAG,MAAM,CAAA;IAEnC,MAAM,cAAc,GAAmB,CACrC,IAAI,EACJ,OAAsB,EACa,EAAE,CACrC,OAAO,CAAC,GAAG,kBAAkB,gBAAgB,EAAE;QAC7C,MAAM,EAAE,MAAM;QACd,IAAI;QACJ,EAAE,EAAE;YACF,KAAK,EAAE,qBAAqB;SAC7B;QACD,OAAO;KACR,CAAC,CAAA;IACJ,MAAM,cAAc,GAAmB,CACrC,EAAC,EAAE,EAAC,EACJ,OAAsB,EACa,EAAE,CACrC,OAAO,CAAC,GAAG,kBAAkB,kBAAkB,EAAE,EAAE,EAAE;QACnD,EAAE,EAAE;YACF,KAAK,EAAE,mBAAmB;SAC3B;QACD,OAAO;KACR,CAAC,CAAA;IAEJ,MAAM,eAAe,GAAoB,CACvC,MAAM,GAAG,EAAE,EACX,OAAO,EAC8B,EAAE,CACvC,OAAO,CAAC,GAAG,kBAAkB,gBAAgB,EAAE;QAC7C,YAAY,EAAE,MAAM;QACpB,EAAE,EAAE;YACF,KAAK,EAAE,mBAAmB;SAC3B;QACD,OAAO;KACR,CAAC,CAAA;IAEJ,OAAO;QACL,cAAc;QACd,cAAc;QACd,eAAe;KAChB,CAAA;AACH,CAAC,CAAA"}
@@ -1,5 +0,0 @@
1
- import { RequestsParams } from "../request";
2
- import { ResellerRequests } from "./types/reseller";
3
- declare const _default: ({ config, request }: RequestsParams) => ResellerRequests;
4
- export default _default;
5
- //# sourceMappingURL=reseller.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reseller.d.ts","sourceRoot":"","sources":["../../src/requests/reseller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,EAAwB,gBAAgB,EAAC,MAAM,kBAAkB,CAAA;8CAErC,cAAc,KAAG,gBAAgB;AAApE,wBAwBC"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = ({ config, request }) => {
4
- const { identityServiceUrl } = config;
5
- const createResellerRequest = ({ companyRegistrationNumber, email, telephone, }, options) => request(`${identityServiceUrl}/reseller-check`, {
6
- method: "POST",
7
- cc: {
8
- scope: "reseller:create",
9
- },
10
- body: {
11
- companyRegistrationNumber,
12
- email,
13
- telephone,
14
- },
15
- options,
16
- });
17
- return {
18
- createResellerRequest,
19
- };
20
- };
21
- //# sourceMappingURL=reseller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reseller.js","sourceRoot":"","sources":["../../src/requests/reseller.ts"],"names":[],"mappings":";;AAGA,kBAAe,CAAC,EAAC,MAAM,EAAE,OAAO,EAAiB,EAAoB,EAAE;IACrE,MAAM,EAAC,kBAAkB,EAAC,GAAG,MAAM,CAAA;IAEnC,MAAM,qBAAqB,GAA0B,CAAC,EACpD,yBAAyB,EACzB,KAAK,EACL,SAAS,GACV,EAAE,OAAO,EAAE,EAAE,CACZ,OAAO,CAAC,GAAG,kBAAkB,iBAAiB,EAAE;QAC9C,MAAM,EAAE,MAAM;QACd,EAAE,EAAE;YACF,KAAK,EAAE,iBAAiB;SACzB;QACD,IAAI,EAAE;YACJ,yBAAyB;YACzB,KAAK;YACL,SAAS;SACV;QACD,OAAO;KACR,CAAC,CAAA;IAEJ,OAAO;QACL,qBAAqB;KACtB,CAAA;AACH,CAAC,CAAA"}
@@ -1,23 +0,0 @@
1
- import { ApiResponse, ExtraOptions } from "../../request";
2
- import { RequestPayee } from "../../schema/payee";
3
- import { PaymentLink, PaymentLinkSearchParams } from "../../schema/payment-link";
4
- export type AddPaymentLink = (body: {
5
- widgetId?: string;
6
- payeeId?: string;
7
- amount?: number;
8
- payee?: RequestPayee;
9
- reference: string;
10
- expiry?: string;
11
- endToEndId?: string;
12
- userId?: string;
13
- }, options?: ExtraOptions) => Promise<ApiResponse<PaymentLink>>;
14
- export type GetPaymentLink = ({ id }: {
15
- id: string;
16
- }, options?: ExtraOptions) => Promise<ApiResponse<PaymentLink>>;
17
- export type GetPaymentLinks = (params?: PaymentLinkSearchParams, options?: ExtraOptions) => Promise<ApiResponse<PaymentLink[]>>;
18
- export interface PaymentLinksRequests {
19
- addPaymentLink: AddPaymentLink;
20
- getPaymentLink: GetPaymentLink;
21
- getPaymentLinks: GetPaymentLinks;
22
- }
23
- //# sourceMappingURL=payment-links.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment-links.d.ts","sourceRoot":"","sources":["../../../src/requests/types/payment-links.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,YAAY,EAAC,MAAM,eAAe,CAAA;AACvD,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,WAAW,EAAE,uBAAuB,EAAC,MAAM,2BAA2B,CAAA;AAG9E,MAAM,MAAM,cAAc,GAAG,CAC3B,IAAI,EAAE;IACJ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,EACD,OAAO,CAAC,EAAE,YAAY,KACnB,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;AAEtC,MAAM,MAAM,cAAc,GAAG,CAC3B,EAAC,EAAE,EAAC,EAAE;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,EAClB,OAAO,CAAC,EAAE,YAAY,KACnB,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;AAEtC,MAAM,MAAM,eAAe,GAAG,CAC5B,MAAM,CAAC,EAAE,uBAAuB,EAChC,OAAO,CAAC,EAAE,YAAY,KACnB,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;AAExC,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,cAAc,CAAA;IAC9B,cAAc,EAAE,cAAc,CAAA;IAC9B,eAAe,EAAE,eAAe,CAAA;CACjC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment-links.js","sourceRoot":"","sources":["../../../src/requests/types/payment-links.ts"],"names":[],"mappings":""}
@@ -1,10 +0,0 @@
1
- import { ApiResponse, ExtraOptions } from "../../request";
2
- export declare type CreateResellerRequest = ({ companyRegistrationNumber, email, telephone, }: {
3
- companyRegistrationNumber: string;
4
- email: string;
5
- telephone?: string;
6
- }, options?: ExtraOptions) => Promise<ApiResponse<null>>;
7
- export interface ResellerRequests {
8
- createResellerRequest: CreateResellerRequest;
9
- }
10
- //# sourceMappingURL=reseller.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reseller.d.ts","sourceRoot":"","sources":["../../../src/requests/types/reseller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,YAAY,EAAC,MAAM,eAAe,CAAA;AAEvD,oBAAY,qBAAqB,GAAG,CAClC,EACE,yBAAyB,EACzB,KAAK,EACL,SAAS,GACV,EAAE;IACD,yBAAyB,EAAE,MAAM,CAAA;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,EACD,OAAO,CAAC,EAAE,YAAY,KACnB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;AAE/B,MAAM,WAAW,gBAAgB;IAC/B,qBAAqB,EAAE,qBAAqB,CAAA;CAC7C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reseller.js","sourceRoot":"","sources":["../../../src/requests/types/reseller.ts"],"names":[],"mappings":""}
@@ -1,18 +0,0 @@
1
- import { SearchParams } from "../request";
2
- export interface PaymentLinkSearchParams extends SearchParams {
3
- widgetId?: string;
4
- payeeId?: string;
5
- }
6
- export interface PaymentLink {
7
- id: string;
8
- clientId: string;
9
- payeeId: string;
10
- reference: string;
11
- widgetId?: string;
12
- amount?: number;
13
- expiry?: string;
14
- endToEndId?: string;
15
- createdAt: string;
16
- updatedAt: string;
17
- }
18
- //# sourceMappingURL=payment-link.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment-link.d.ts","sourceRoot":"","sources":["../../src/schema/payment-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAEvC,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment-link.js","sourceRoot":"","sources":["../../src/schema/payment-link.ts"],"names":[],"mappings":""}