cozy-harvest-lib 9.22.0 → 9.22.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [9.22.3](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.22.2...cozy-harvest-lib@9.22.3) (2022-07-26)
7
+
8
+ **Note:** Version bump only for package cozy-harvest-lib
9
+
10
+
11
+
12
+
13
+
14
+ ## [9.22.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.22.1...cozy-harvest-lib@9.22.2) (2022-07-21)
15
+
16
+ **Note:** Version bump only for package cozy-harvest-lib
17
+
18
+
19
+
20
+
21
+
22
+ ## [9.22.1](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.22.0...cozy-harvest-lib@9.22.1) (2022-07-20)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * Add bankIds in createTemporaryToken params ([3cfae1d](https://github.com/cozy/cozy-libs/commit/3cfae1d7a6ad34e948e77117529943de19c56ec5))
28
+
29
+
30
+
31
+
32
+
6
33
  # [9.22.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.21.1...cozy-harvest-lib@9.22.0) (2022-07-19)
7
34
 
8
35
 
@@ -563,6 +563,7 @@ function isCacheExpired(_ref17) {
563
563
  *
564
564
  * @param {CozyClient} options.client CozyClient instance
565
565
  * @param {io.cozy.konnectors} options.konnector
566
+ * @param {Array<Number>} options.cozyBankIds List of cozy bank identifiers
566
567
  * @param {createTemporaryTokenResponse} options.tokenCache Previous version of BI temporary token cache
567
568
  * @return {createTemporaryTokenResponse}
568
569
  */
@@ -584,16 +585,17 @@ function updateCache(_x9) {
584
585
 
585
586
  function _updateCache() {
586
587
  _updateCache = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref18) {
587
- var client, konnector, tokenCache, jobResponse, event, saveResult;
588
+ var client, konnector, tokenCache, cozyBankIds, jobResponse, event, saveResult;
588
589
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
589
590
  while (1) {
590
591
  switch (_context10.prev = _context10.next) {
591
592
  case 0:
592
- client = _ref18.client, konnector = _ref18.konnector, tokenCache = _ref18.tokenCache;
593
+ client = _ref18.client, konnector = _ref18.konnector, tokenCache = _ref18.tokenCache, cozyBankIds = _ref18.cozyBankIds;
593
594
  _context10.next = 3;
594
595
  return client.stackClient.jobs.create('konnector', {
595
596
  mode: 'getTemporaryToken',
596
- konnector: konnector.slug
597
+ konnector: konnector.slug,
598
+ bankIds: cozyBankIds
597
599
  }, {}, true);
598
600
 
599
601
  case 3:
@@ -646,30 +648,31 @@ export var createTemporaryToken = /*#__PURE__*/function () {
646
648
 
647
649
  case 4:
648
650
  tokenCache = _context8.sent;
651
+ cozyBankIds = getCozyBankIds({
652
+ konnector: konnector,
653
+ account: account
654
+ });
649
655
 
650
656
  if (!isCacheExpired({
651
657
  tokenCache: tokenCache
652
658
  })) {
653
- _context8.next = 10;
659
+ _context8.next = 11;
654
660
  break;
655
661
  }
656
662
 
657
663
  logger.debug('temporaryToken cache is expired. Updating');
658
- _context8.next = 9;
664
+ _context8.next = 10;
659
665
  return updateCache({
660
666
  client: client,
661
667
  konnector: konnector,
662
- tokenCache: tokenCache
668
+ tokenCache: tokenCache,
669
+ cozyBankIds: cozyBankIds
663
670
  });
664
671
 
665
- case 9:
672
+ case 10:
666
673
  tokenCache = _context8.sent;
667
674
 
668
- case 10:
669
- cozyBankIds = getCozyBankIds({
670
- konnector: konnector,
671
- account: account
672
- });
675
+ case 11:
673
676
  assert(cozyBankIds.length, 'createTemporaryToken: Could not determine cozyBankIds from account or konnector');
674
677
  assert((_tokenCache = tokenCache) === null || _tokenCache === void 0 ? void 0 : _tokenCache.biMapping, 'createTemporaryToken: could not find a BI mapping in createTemporaryToken response, you should update your konnector to the last version');
675
678
  _tokenCache2 = tokenCache, biMapping = _tokenCache2.biMapping;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "9.22.0",
3
+ "version": "9.22.3",
4
4
  "description": "Provides logic, modules and components for Cozy's harvest applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -57,7 +57,7 @@
57
57
  "cozy-flags": "^2.10.0",
58
58
  "cozy-intent": "^2.3.0",
59
59
  "cozy-keys-lib": "^4.1.9",
60
- "cozy-realtime": "^4.2.1",
60
+ "cozy-realtime": "^4.2.2",
61
61
  "cozy-ui": "60.6.0",
62
62
  "enzyme": "3.11.0",
63
63
  "enzyme-adapter-react-16": "1.15.6",
@@ -77,6 +77,7 @@
77
77
  "peerDependencies": {
78
78
  "@babel/runtime": ">=7.12.5",
79
79
  "@material-ui/core": ">=4",
80
+ "@material-ui/lab": "4.0.0-alpha.60",
80
81
  "cozy-client": ">=27.17.0",
81
82
  "cozy-device-helper": ">=1.10.2",
82
83
  "cozy-flags": ">=2.3.5",
@@ -89,5 +90,5 @@
89
90
  "react-router-dom": "^5.0.1"
90
91
  },
91
92
  "sideEffects": false,
92
- "gitHead": "03471ca36c3923eb3936b2429a741b05854746df"
93
+ "gitHead": "6bfb68f221c204c40e54baab55cc25655e71a548"
93
94
  }
@@ -350,15 +350,17 @@ function isCacheExpired({ tokenCache }) {
350
350
  *
351
351
  * @param {CozyClient} options.client CozyClient instance
352
352
  * @param {io.cozy.konnectors} options.konnector
353
+ * @param {Array<Number>} options.cozyBankIds List of cozy bank identifiers
353
354
  * @param {createTemporaryTokenResponse} options.tokenCache Previous version of BI temporary token cache
354
355
  * @return {createTemporaryTokenResponse}
355
356
  */
356
- async function updateCache({ client, konnector, tokenCache }) {
357
+ async function updateCache({ client, konnector, tokenCache, cozyBankIds }) {
357
358
  const jobResponse = await client.stackClient.jobs.create(
358
359
  'konnector',
359
360
  {
360
361
  mode: 'getTemporaryToken',
361
- konnector: konnector.slug
362
+ konnector: konnector.slug,
363
+ bankIds: cozyBankIds
362
364
  },
363
365
  {},
364
366
  true
@@ -395,13 +397,17 @@ export const createTemporaryToken = async ({ client, konnector, account }) => {
395
397
  )
396
398
 
397
399
  let tokenCache = await getBiTemporaryTokenFromCache({ client })
400
+ const cozyBankIds = getCozyBankIds({ konnector, account })
398
401
  if (isCacheExpired({ tokenCache })) {
399
402
  logger.debug('temporaryToken cache is expired. Updating')
400
- tokenCache = await updateCache({ client, konnector, tokenCache })
403
+ tokenCache = await updateCache({
404
+ client,
405
+ konnector,
406
+ tokenCache,
407
+ cozyBankIds
408
+ })
401
409
  }
402
410
 
403
- const cozyBankIds = getCozyBankIds({ konnector, account })
404
-
405
411
  assert(
406
412
  cozyBankIds.length,
407
413
  'createTemporaryToken: Could not determine cozyBankIds from account or konnector'