@mft/moneyhub-api-client 6.99.0 → 6.101.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 (64) hide show
  1. package/CHANGELOG.md +237 -3
  2. package/dist/exchange-code-for-token.d.ts +12 -4
  3. package/dist/exchange-code-for-token.d.ts.map +1 -1
  4. package/dist/exchange-code-for-token.js +77 -58
  5. package/dist/exchange-code-for-token.js.map +1 -1
  6. package/dist/get-auth-urls.d.ts +20 -14
  7. package/dist/get-auth-urls.d.ts.map +1 -1
  8. package/dist/get-auth-urls.js +33 -5
  9. package/dist/get-auth-urls.js.map +1 -1
  10. package/dist/index.d.ts +19 -18
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/pkce.d.ts +31 -0
  14. package/dist/pkce.d.ts.map +1 -0
  15. package/dist/pkce.js +3 -0
  16. package/dist/pkce.js.map +1 -0
  17. package/dist/requests/caas/types/regular-transactions.d.ts +5 -6
  18. package/dist/requests/caas/types/regular-transactions.d.ts.map +1 -1
  19. package/dist/requests/caas/types/response-meta.d.ts +8 -0
  20. package/dist/requests/caas/types/response-meta.d.ts.map +1 -0
  21. package/dist/requests/caas/types/response-meta.js +3 -0
  22. package/dist/requests/caas/types/response-meta.js.map +1 -0
  23. package/dist/requests/caas/types/transactions.d.ts +3 -5
  24. package/dist/requests/caas/types/transactions.d.ts.map +1 -1
  25. package/dist/requests/index.d.ts +11 -0
  26. package/dist/requests/index.d.ts.map +1 -1
  27. package/dist/requests/index.js +2 -0
  28. package/dist/requests/index.js.map +1 -1
  29. package/dist/requests/standard-financial-statements.d.ts +5 -0
  30. package/dist/requests/standard-financial-statements.d.ts.map +1 -0
  31. package/dist/requests/standard-financial-statements.js +23 -0
  32. package/dist/requests/standard-financial-statements.js.map +1 -0
  33. package/dist/requests/types/standard-financial-statements.d.ts +19 -0
  34. package/dist/requests/types/standard-financial-statements.d.ts.map +1 -0
  35. package/dist/requests/types/standard-financial-statements.js +3 -0
  36. package/dist/requests/types/standard-financial-statements.js.map +1 -0
  37. package/dist/requests/types/unauthenticated.d.ts +4 -0
  38. package/dist/requests/types/unauthenticated.d.ts.map +1 -1
  39. package/dist/requests/unauthenticated.d.ts.map +1 -1
  40. package/dist/requests/unauthenticated.js +1 -0
  41. package/dist/requests/unauthenticated.js.map +1 -1
  42. package/dist/schema/standard-financial-statement.d.ts +21 -0
  43. package/dist/schema/standard-financial-statement.d.ts.map +1 -0
  44. package/dist/schema/standard-financial-statement.js +3 -0
  45. package/dist/schema/standard-financial-statement.js.map +1 -0
  46. package/dist/tokens.d.ts +2 -4
  47. package/dist/tokens.d.ts.map +1 -1
  48. package/dist/tokens.js +13 -2
  49. package/dist/tokens.js.map +1 -1
  50. package/package.json +6 -5
  51. package/readme.md +130 -30
  52. package/scripts/assert-github-actions-publish.js +11 -1
  53. package/scripts/check-secrets.js +66 -0
  54. package/.idea/codeStyles/Project.xml +0 -21
  55. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  56. package/.idea/dbnavigator.xml +0 -450
  57. package/.idea/git_toolbox_blame.xml +0 -6
  58. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  59. package/.idea/jsLinters/eslint.xml +0 -6
  60. package/.idea/modules.xml +0 -8
  61. package/.idea/moneyhub-api-client.iml +0 -12
  62. package/.idea/prettier.xml +0 -6
  63. package/.idea/vcs.xml +0 -6
  64. package/.idea/workspace.xml +0 -338
package/dist/tokens.js CHANGED
@@ -72,10 +72,12 @@ This function now requires an object with the following properties:
72
72
  "code_verifier" // required for PKCE
73
73
  }
74
74
  }
75
+
76
+ For server-side PKCE verifier retrieval, use exchangeCodeForTokensUsingPKCE instead.
75
77
  `;
76
78
  exports.default = ({ client, config, }) => {
77
79
  const { identityServiceUrl, client: { redirect_uri, request_object_signing_alg, keys, client_id }, } = config;
78
- const exchangeCodeForTokens = (0, exchange_code_for_token_1.default)({
80
+ const { exchangeCodeForTokens, exchangeCodeForTokensUsingPKCE, } = (0, exchange_code_for_token_1.default)({
79
81
  client,
80
82
  redirectUri: redirect_uri,
81
83
  });
@@ -102,13 +104,22 @@ exports.default = ({ client, config, }) => {
102
104
  const requestObj = filterUndefined({ state, code, id_token, nonce });
103
105
  return client.authorizationCallback(redirect_uri, requestObj, verify);
104
106
  },
105
- exchangeCodeForTokens: ({ paramsFromCallback, localParams }) => {
107
+ exchangeCodeForTokens: (options) => {
108
+ const { paramsFromCallback, localParams } = options;
106
109
  if (!paramsFromCallback || !localParams) {
107
110
  console.error(exchangeCodeForTokensErrorMessage);
108
111
  throw new Error("Missing parameters");
109
112
  }
110
113
  return exchangeCodeForTokens({ paramsFromCallback, localParams });
111
114
  },
115
+ exchangeCodeForTokensUsingPKCE: (options) => {
116
+ const { paramsFromCallback, localParams } = options;
117
+ if (!paramsFromCallback || !localParams) {
118
+ console.error(exchangeCodeForTokensErrorMessage);
119
+ throw new Error("Missing parameters");
120
+ }
121
+ return exchangeCodeForTokensUsingPKCE(options);
122
+ },
112
123
  refreshTokens: ({ refreshToken }) => client.refresh(refreshToken),
113
124
  getClientCredentialTokens: ({ scope, sub }) => client.grant({
114
125
  grant_type: "client_credentials",
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA0B;AAC1B,2CAA4B;AAG5B,+CAAgC;AAChC,wFAAoE;AAEpE,MAAM,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,EAAE,EAAE,CAC7B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAEnE,MAAM,eAAe,GAAG,KAAK,EAAE,EAC7B,GAAG,EACH,GAAG,EACH,QAAQ,EACR,MAAM,EACN,GAAG,EACH,UAAU,EACV,cAAc,GAAG,KAAK,GASrB,EAAE,EAAE,CACL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C;QAED,yBAAyB;KAC1B,CAAA;AACH,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@mft/moneyhub-api-client",
3
- "version": "6.99.0",
3
+ "version": "6.101.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
9
  "lint-fix": "eslint src/ --fix",
10
+ "check-secrets": "node scripts/check-secrets.js",
10
11
  "test": "mocha --require ts-node/register --config test/opts/integration.json",
11
12
  "test-ci": "mocha --require ts-node/register --config test/opts/integration-ci.json",
12
13
  "test-caas": "mocha --require ts-node/register --config test/opts/integration-caas.json",
@@ -26,20 +27,20 @@
26
27
  "api",
27
28
  "openid"
28
29
  ],
29
- "author": "Moneyub Financial Technology",
30
+ "author": "Moneyhub Financial Technology",
30
31
  "homepage": "https://github.com/moneyhub/moneyhub-api-client",
31
32
  "repository": "moneyhub/moneyhub-api-client",
32
33
  "license": "ISC",
33
34
  "engines": {
34
- "node": ">= 12.0.0"
35
+ "node": ">= 18.0.0"
35
36
  },
36
37
  "dependencies": {
37
38
  "@isaacs/ttlcache": "^2.1.4",
38
- "form-data": "^3.0.4",
39
+ "form-data": "^3.0.5",
39
40
  "got": "^11.8.5",
40
41
  "jose": "^5.2.3",
41
42
  "openid-client": "^5.6.5",
42
- "query-string": "^7.1.1",
43
+ "query-string": "^9.5.1",
43
44
  "ramda": "^0.27.2"
44
45
  },
45
46
  "overrides": {
package/readme.md CHANGED
@@ -26,6 +26,9 @@ 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
+ - Create reseller check requests and get consent history
30
+ - Standard financial statements
31
+ - Legacy bank connections listing
29
32
  - CAAS (Categorisation as a Service) API for advanced transaction enrichment and categorisation
30
33
 
31
34
  Currently this library supports `client_secret_basic`, `client_secret_jwt` and `private_key_jwt` authentication.
@@ -64,7 +67,7 @@ const {Moneyhub} = require("@mft/moneyhub-api-client")
64
67
 
65
68
  ## Publishing (maintainers)
66
69
 
67
- Official releases are published to npm by **GitHub Actions** when a [GitHub Release](https://github.com/moneyhub/moneyhub-api-client/releases) is published (see `.github/workflows/publish.yml`). Do not rely on publishing from a developer machine.
70
+ Official releases are published to npm by **GitHub Actions** when a [GitHub Release](https://github.com/moneyhub/moneyhub-api-client/releases) is published (see `.github/workflows/publish.yml`). The publish workflow runs lint and build on GitHub-hosted runners. Live integration tests are not part of publish; they run in the private synced repository (allowlisted IPs / secrets). Do not rely on publishing from a developer machine.
68
71
 
69
72
  The `prepublishOnly` lifecycle script runs **`scripts/assert-github-actions-publish.js`** before the build. It exits with an error unless `GITHUB_ACTIONS` is set (as it is in GitHub Actions), so a normal local `npm publish` is blocked. That reduces accidental publishes; it is **not** a security boundary on its own—npm access control and trusted publishing still matter.
70
73
 
@@ -74,9 +77,10 @@ To bypass the check in a **documented emergency** only, you can run `npm publish
74
77
 
75
78
  To use this API client you will need:
76
79
 
80
+ - Node.js >= 18.0.0
77
81
  - A `client_id`, `client_secret` and `redirect_uri` of a registered API client
78
82
  - The url of the Moneyhub identity service for the environment you are connecting to (https://identity.moneyhub.co.uk)
79
- - The url for the API gateway for the environment that you are connecting to (https://api.moneyhub.co.uk/v2.0)
83
+ - The url for the API gateway for the environment that you are connecting to (https://api.moneyhub.co.uk/v3)
80
84
 
81
85
  ## To install
82
86
 
@@ -257,6 +261,8 @@ The `expirationDateTime` and `transactionFromDateTime` options can be set accord
257
261
 
258
262
  Set `enableAsync` to true if you wish to make an AIS connection that won't wait for accounts and transactions to be fetched.
259
263
 
264
+ Set `accVerification` to true to add the `mh:account_verification` claim. This is independent of `enableAsync`.
265
+
260
266
  **Note:** all methods generate an authorise URL using the Pushed Authorisation Request (PAR) method, see [here](https://docs.moneyhubenterprise.com/docs/pushed-authorisation-requests-par) for more details.
261
267
 
262
268
  #### `getAuthorizeUrl`
@@ -280,6 +286,20 @@ const url = await moneyhub.getAuthorizeUrl({
280
286
  expirationDateTime: "2022-09-01T00:00:00.000Z", // optional
281
287
  transactionFromDateTime: "2020-09-01T00:00:00.000Z", // optional,
282
288
  enableAsync: false, // optional
289
+ accVerification: false, // optional - adds mh:account_verification independently of enableAsync
290
+ });
291
+
292
+ // FAPI 2 / PKCE (server-side storage — never expose code_verifier to the browser)
293
+ const url = await moneyhub.getAuthorizeUrl({
294
+ scope: "openid bank-id-scope",
295
+ state: "your-state",
296
+ nonce: "your-nonce",
297
+ pkce: {
298
+ generate: true,
299
+ storeVerifier: async ({state, codeVerifier}) => {
300
+ await storeVerifierServerSide(state, codeVerifier); // e.g. Redis keyed by state
301
+ },
302
+ },
283
303
  });
284
304
 
285
305
  // Default claims if none are provided
@@ -399,24 +419,6 @@ const defaultClaims = {
399
419
 
400
420
  #### `getRefreshAuthorizeUrlForCreatedUser`
401
421
 
402
- #### `getAuthorizeUrlLegacy`
403
-
404
- This method returns an authorize url for your API client using the legacy method (where a request object is generated and passed in as the `request` query parameter). You can redirect a user to this url, after which they will be redirected back to your `redirect_uri`. It has the same method signature as `getAuthorizeUrl`
405
-
406
- ```javascript
407
- const url = await moneyhub.getAuthorizeUrlLegacy({
408
- scope: "openid bank-id-scope other-data-scopes",
409
- state: " your state value", // optional
410
- nonce: "your nonce value", //optional
411
- claims: claimsObject, // optional
412
- permissions: ["ReadBeneficiariesDetail"], // optional - set of extra permissions to set for auth URL
413
- permissionsAction: "replace" // optional - replace default consent permissions. Defaults to "add"
414
- expirationDateTime: "2022-09-01T00:00:00.000Z", // optional
415
- transactionFromDateTime: "2020-09-01T00:00:00.000Z", // optional,
416
- enableAsync: false, // optional
417
- });
418
- ```
419
-
420
422
  This is a helper function that returns an authorize url for a specific user to refresh an existing connection. This function uses the scope `openid refresh`. (Only relevant for legacy connections)
421
423
 
422
424
  ```javascript
@@ -444,6 +446,24 @@ const defaultClaims = {
444
446
  };
445
447
  ```
446
448
 
449
+ #### `getAuthorizeUrlLegacy`
450
+
451
+ This method returns an authorize url for your API client using the legacy method (where a request object is generated and passed in as the `request` query parameter). You can redirect a user to this url, after which they will be redirected back to your `redirect_uri`. It has the same method signature as `getAuthorizeUrl`
452
+
453
+ ```javascript
454
+ const url = await moneyhub.getAuthorizeUrlLegacy({
455
+ scope: "openid bank-id-scope other-data-scopes",
456
+ state: " your state value", // optional
457
+ nonce: "your nonce value", //optional
458
+ claims: claimsObject, // optional
459
+ permissions: ["ReadBeneficiariesDetail"], // optional - set of extra permissions to set for auth URL
460
+ permissionsAction: "replace" // optional - replace default consent permissions. Defaults to "add"
461
+ expirationDateTime: "2022-09-01T00:00:00.000Z", // optional
462
+ transactionFromDateTime: "2020-09-01T00:00:00.000Z", // optional,
463
+ enableAsync: false, // optional
464
+ });
465
+ ```
466
+
447
467
  #### `exchangeCodeForTokensLegacy`
448
468
 
449
469
  This is a legacy method to get tokens for a user.
@@ -469,6 +489,7 @@ This method requires an object with two properties:
469
489
 
470
490
  - `paramsFromCallback` : an object with all the params received at your redirect uri
471
491
  - `localParams` : an object with params that you have in the local session for the user.
492
+ - `pkce` : optional hook to retrieve a stored `code_verifier` server-side (see below)
472
493
 
473
494
  ```javascript
474
495
  const tokens = await moneyhub.exchangeCodeForTokens({
@@ -483,9 +504,18 @@ const tokens = await moneyhub.exchangeCodeForTokens({
483
504
  "sub": "the user id", // optional, but without this param, requests where there are missing cookies will fail
484
505
  "max_age", // optional, not normally required
485
506
  "response_type" // recommended to enhance securirty
486
- "code_verifier" // required if PKCE is used
507
+ "code_verifier" // required if PKCE is used (or use pkce.consumeVerifier)
487
508
  }
488
509
  })
510
+
511
+ // FAPI 2 / server-side PKCE — retrieve and delete stored verifier keyed by state
512
+ const tokens = await moneyhub.exchangeCodeForTokens({
513
+ paramsFromCallback: { code, state },
514
+ localParams: { state, nonce, sub: userId, response_type: "code" },
515
+ pkce: {
516
+ consumeVerifier: async ({ state }) => consumeVerifierServerSide(state),
517
+ },
518
+ })
489
519
  ```
490
520
 
491
521
  #### `getClientCredentialTokens`
@@ -850,7 +880,7 @@ Similar to getAccounts method, however this method does not return `transactionD
850
880
 
851
881
  ```javascript
852
882
  const queryParams = { limit: 10, offset: 5 , showTransacionData: false, showPerformanceScore: true};
853
- const accounts = await moneyhub.getAccounts({
883
+ const accounts = await moneyhub.getAccountsList({
854
884
  userId: "userId",
855
885
  params: queryParams,
856
886
  }, options);
@@ -862,7 +892,7 @@ Similar to getAccountsWithDetails method, however this method does not return `t
862
892
 
863
893
  ```javascript
864
894
  const queryParams = { limit: 10, offset: 5 };
865
- const accounts = await moneyhub.getAccountsWithDetails({
895
+ const accounts = await moneyhub.getAccountsListWithDetails({
866
896
  userId: "userId",
867
897
  params: queryParams,
868
898
  }, options);
@@ -1004,6 +1034,28 @@ const statements = await moneyhub.getAccountStatementsWithDetail({
1004
1034
  }, options);
1005
1035
  ```
1006
1036
 
1037
+ #### `getStandardFinancialStatements`
1038
+
1039
+ List standard financial statement reports for a user (Money Advice Service schema metadata). Uses the scope `standard_financial_statement:read`.
1040
+
1041
+ ```javascript
1042
+ const statements = await moneyhub.getStandardFinancialStatements({
1043
+ userId: "userId",
1044
+ params: {limit: 10, offset: 0},
1045
+ }, options);
1046
+ ```
1047
+
1048
+ #### `getStandardFinancialStatement`
1049
+
1050
+ Get a single standard financial statement report by id. Uses the scope `standard_financial_statement:read`.
1051
+
1052
+ ```javascript
1053
+ const statement = await moneyhub.getStandardFinancialStatement({
1054
+ userId: "userId",
1055
+ reportId: "reportId",
1056
+ }, options);
1057
+ ```
1058
+
1007
1059
  #### `createAccount`
1008
1060
 
1009
1061
  Create a manual account for a user. This function uses the scopes `accounts:read accounts:write:all`
@@ -1353,11 +1405,9 @@ const accounts = await moneyhub.getOsipAccounts({
1353
1405
  Get an account for a user. This function uses the scope `osip:read`.
1354
1406
 
1355
1407
  ```javascript
1356
- const queryParams = { limit: 10, offset: 5 };
1357
- const accounts = await moneyhub.getOsipAccounts({
1408
+ const account = await moneyhub.getOsipAccount({
1358
1409
  userId: "userId",
1359
1410
  accountId: "accountId",
1360
- params: queryParams,
1361
1411
  });
1362
1412
  ```
1363
1413
 
@@ -1367,7 +1417,7 @@ Get account holdings for an account. This function uses the scope `osip:read`.
1367
1417
 
1368
1418
  ```javascript
1369
1419
  const queryParams = { limit: 10, offset: 5 };
1370
- const accounts = await moneyhub.getOsipAccounts({
1420
+ const holdings = await moneyhub.getOsipAccountHoldings({
1371
1421
  userId: "userId",
1372
1422
  accountId: "accountId",
1373
1423
  params: queryParams,
@@ -1380,7 +1430,7 @@ Get account transactions. This function uses the scope `osip:read`.
1380
1430
 
1381
1431
  ```javascript
1382
1432
  const queryParams = { limit: 10, offset: 5 };
1383
- const accounts = await moneyhub.getOsipAccounts({
1433
+ const transactions = await moneyhub.getOsipAccountTransactions({
1384
1434
  userId: "userId",
1385
1435
  accountId: "accountId",
1386
1436
  params: queryParams,
@@ -1728,6 +1778,18 @@ const payees = await moneyhub.getPayees({
1728
1778
  });
1729
1779
  ```
1730
1780
 
1781
+ #### `getPayee`
1782
+
1783
+ Get a single registered payee by id. This function uses the scope `payee:read`.
1784
+
1785
+ ```javascript
1786
+ const payee = await moneyhub.getPayee({
1787
+ id: "payee-id",
1788
+ });
1789
+ ```
1790
+
1791
+ Example script: `node examples/payments/get-payee.js -i payee-id`.
1792
+
1731
1793
  #### `getPayments`
1732
1794
 
1733
1795
  This method returns a list of initiated payments. This function uses the scope `payment:read`
@@ -1995,7 +2057,7 @@ const recurringPayment = await moneyhub.getRecurringPayment({
1995
2057
  This method creates a payment using the recurring payment consent. This function uses the scope `recurring_payment:create`
1996
2058
 
1997
2059
  ```javascript
1998
- const recurringPayments = await moneyhub.getRecurringPayments({
2060
+ const recurringPayment = await moneyhub.makeRecurringPayment({
1999
2061
  recurringPaymentId: "Id of the recurring payment consent",
2000
2062
  payment: {
2001
2063
  payeeId: "payee-id", // optional
@@ -2016,6 +2078,22 @@ const revokedRecurringPayment = await moneyhub.revokeRecurringPayment({
2016
2078
  });
2017
2079
  ```
2018
2080
 
2081
+ #### `confirmFundsForRecurringPayment`
2082
+
2083
+ Confirm that funds are available for a payment under an existing recurring payment consent. This function uses the scope `recurring_payment:funds_confirmation`.
2084
+
2085
+ ```javascript
2086
+ const fundsConfirmation = await moneyhub.confirmFundsForRecurringPayment({
2087
+ recurringPaymentId: "Id of the recurring payment consent",
2088
+ fundsConfirmation: {
2089
+ amount: "10.00",
2090
+ currency: "GBP",
2091
+ },
2092
+ });
2093
+ ```
2094
+
2095
+ Example script: `node examples/recurring-payments/confirm-funds.js -i recurring-payment-id -a 10.00`.
2096
+
2019
2097
  #### `getRegularTransactions`
2020
2098
 
2021
2099
  Get all the regular transactions for a user, there is an option to pass an account ID as a parameter as a filter. This function uses the scope `accounts:read`, `transactions:read:all` and `regular_transactions:read`
@@ -2221,6 +2299,20 @@ const resellerCheck = await moneyhub.createResellerCheckRequest({
2221
2299
  }, options);
2222
2300
  ```
2223
2301
 
2302
+ #### `getConsentHistory`
2303
+
2304
+ Get consent history for the API client, optionally filtered by user. This function uses the scope `consent_history:read`.
2305
+
2306
+ ```javascript
2307
+ const consentHistory = await moneyhub.getConsentHistory({
2308
+ limit: 10, // optional
2309
+ offset: 0, // optional
2310
+ userId: "user-id", // optional
2311
+ });
2312
+ ```
2313
+
2314
+ Example script: `node examples/consent-history/get-history.js -u user-id`.
2315
+
2224
2316
  ### CAAS API
2225
2317
 
2226
2318
  The CAAS (Categorisation as a Service) API provides advanced transaction enrichment, categorisation, and management capabilities. All CAAS endpoints use dedicated scopes prefixed with `caas:`.
@@ -2288,7 +2380,7 @@ Example script: `node examples/caas/transactions/get-enhanced-transaction.js -a
2288
2380
 
2289
2381
  #### `caasPatchTransaction`
2290
2382
 
2291
- Update a transaction's user-defined category via the CAAS endpoint. This function uses the scope `caas:transactions:write` and returns the updated transaction data under `data`. The optional `recategorisationType` query parameter (`single` or `future`, defaulting to `single`) controls whether the change applies to this transaction only or to all future matching transactions.
2383
+ Update a transaction's user-defined category via the CAAS endpoint. This function uses the scope `caas:transactions:write` and returns the updated transaction data under `data`. Pass `recategorisationType` as a query parameter: `single` (this transaction only), `future` (this transaction and future matches), or `past-and-future` (this transaction, historical matches, and future matches). Defaults to `single` when omitted.
2292
2384
 
2293
2385
  ```javascript
2294
2386
  const result = await moneyhub.caasPatchTransaction({
@@ -2481,6 +2573,14 @@ This method will resolve with a list of all the API connections that a user can
2481
2573
  const availableConnections = await moneyhub.listAPIConnections();
2482
2574
  ```
2483
2575
 
2576
+ #### `listLegacyConnections`
2577
+
2578
+ This method will resolve with a list of legacy connections from Identity (`.well-known/legacy-connections`).
2579
+
2580
+ ```javascript
2581
+ const availableConnections = await moneyhub.listLegacyConnections();
2582
+ ```
2583
+
2484
2584
  #### `listTestConnections`
2485
2585
 
2486
2586
  This method will resolve with a list of all the Test connections that a user can connect to.
@@ -1,10 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  // prepublishOnly guard; emergency bypass: npm publish --ignore-scripts
3
+ const allowedRepo = "moneyhub/moneyhub-api-client";
4
+
3
5
  if (process.env.GITHUB_ACTIONS !== "true") {
4
6
  console.error(
5
7
  "Publishing this package is restricted to GitHub Actions. " +
6
- "Create a GitHub Release to trigger the publish workflow. " +
8
+ "Create a GitHub Release on moneyhub/moneyhub-api-client to trigger the publish workflow. " +
7
9
  "For a documented emergency bypass, use npm publish --ignore-scripts."
8
10
  );
9
11
  process.exit(1);
10
12
  }
13
+
14
+ if (process.env.GITHUB_REPOSITORY !== allowedRepo) {
15
+ console.error(
16
+ `Publishing this package is restricted to ${allowedRepo}. ` +
17
+ `Current repository: ${process.env.GITHUB_REPOSITORY || "(unset)"}.`
18
+ );
19
+ process.exit(1);
20
+ }
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ const {execFileSync} = require("child_process")
3
+
4
+ const git = args => execFileSync("git", args, {encoding: "utf8"})
5
+
6
+ const blockedPaths = [
7
+ "examples/config.js",
8
+ ]
9
+
10
+ const secretPatterns = [
11
+ {
12
+ name: "PEM private key",
13
+ regex: /-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----/,
14
+ },
15
+ {
16
+ name: "JWK private component (\"d\")",
17
+ regex: /"d"\s*:\s*"[A-Za-z0-9_-]{20,}"/,
18
+ },
19
+ {
20
+ name: "Real client_secret value",
21
+ regex: /client_secret"?\s*[:=]\s*"(?!your client secret")[^"]{8,}"/,
22
+ },
23
+ ]
24
+
25
+ const getStagedFiles = () => {
26
+ const output = git(["diff", "--cached", "--name-only", "--diff-filter=ACM", "--no-renames"])
27
+ return output.split("\n").map(line => line.trim()).filter(Boolean)
28
+ }
29
+
30
+ const getStagedContent = file => git(["show", `:${file}`])
31
+
32
+ const scanFile = file => {
33
+ const findings = []
34
+ if (blockedPaths.includes(file)) {
35
+ findings.push(`${file}: file is blocked from being committed (use examples/config.example.js as a template and keep secrets in the git-ignored examples/config.js)`)
36
+ return findings
37
+ }
38
+ let content
39
+ try {
40
+ content = getStagedContent(file)
41
+ } catch (err) {
42
+ findings.push(`${file}: unable to read staged content, cannot verify it is secret-free (${err.message})`)
43
+ return findings
44
+ }
45
+ secretPatterns.forEach(({name, regex}) => {
46
+ if (regex.test(content)) {
47
+ findings.push(`${file}: matched "${name}"`)
48
+ }
49
+ })
50
+ return findings
51
+ }
52
+
53
+ const main = () => {
54
+ const files = getStagedFiles()
55
+ const findings = files.flatMap(scanFile)
56
+ if (findings.length === 0) {
57
+ process.exit(0)
58
+ }
59
+ console.error("\nCommit blocked: potential secrets detected in staged changes\n")
60
+ findings.forEach(finding => console.error(` - ${finding}`))
61
+ console.error("\nRemove the secrets, unstage the file, and commit again.")
62
+ console.error("If this is a false positive, review the staged content before bypassing.\n")
63
+ process.exit(1)
64
+ }
65
+
66
+ main()
@@ -1,21 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <JSCodeStyleSettings version="0">
4
- <option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
5
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
6
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
7
- <option name="FORCE_QUOTE_STYlE" value="true" />
8
- </JSCodeStyleSettings>
9
- <codeStyleSettings language="JavaScript">
10
- <option name="BLOCK_COMMENT_ADD_SPACE" value="true" />
11
- <option name="KEEP_BLANK_LINES_IN_CODE" value="3" />
12
- <option name="INDENT_CASE_FROM_SWITCH" value="false" />
13
- <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
14
- <option name="ALIGN_MULTILINE_FOR" value="false" />
15
- <indentOptions>
16
- <option name="INDENT_SIZE" value="2" />
17
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
18
- </indentOptions>
19
- </codeStyleSettings>
20
- </code_scheme>
21
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
- </state>
5
- </component>