cozy-harvest-lib 9.7.3 → 9.8.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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
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.8.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.7.3...cozy-harvest-lib@9.8.0) (2022-06-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Small fixes after review ([d4f50ba](https://github.com/cozy/cozy-libs/commit/d4f50ba114cd4f8d43fac8545f6356c380edd262))
12
+
13
+
14
+ ### Features
15
+
16
+ * Add BI webview reconnection ([d0f9c9e](https://github.com/cozy/cozy-libs/commit/d0f9c9e556d847e072063eb877d5d4e57ee8cca0))
17
+
18
+
19
+
20
+
21
+
6
22
  ## [9.7.3](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.7.2...cozy-harvest-lib@9.7.3) (2022-06-08)
7
23
 
8
24
 
@@ -102,7 +102,10 @@ var DumbEditAccountModal = withRouter(function (_ref) {
102
102
  onSuccess: redirectToAccount,
103
103
  showError: true,
104
104
  onVaultDismiss: redirectToAccount,
105
- fieldOptions: fieldOptions
105
+ fieldOptions: fieldOptions,
106
+ reconnect: fromReconnect
107
+ }), /*#__PURE__*/React.createElement("div", {
108
+ className: "u-mb-2"
106
109
  })));
107
110
  });
108
111
  export var EditAccountModal = /*#__PURE__*/function (_Component) {
@@ -38,7 +38,6 @@ export var OAuthForm = /*#__PURE__*/function (_PureComponent) {
38
38
  _this.handleOAuthCancel = _this.handleOAuthCancel.bind(_assertThisInitialized(_this));
39
39
  _this.handleExtraParams = _this.handleExtraParams.bind(_assertThisInitialized(_this));
40
40
  _this.state = {
41
- initialValues: null,
42
41
  showingOAuthModal: false
43
42
  };
44
43
  return _this;
@@ -52,9 +51,6 @@ export var OAuthForm = /*#__PURE__*/function (_PureComponent) {
52
51
  konnector = _this$props.konnector,
53
52
  flow = _this$props.flow,
54
53
  client = _this$props.client;
55
- this.setState({
56
- initialValues: account ? account.oauth : null
57
- });
58
54
  var konnectorPolicy = findKonnectorPolicy(konnector);
59
55
 
60
56
  if (konnectorPolicy.fetchExtraOAuthUrlParams) {
@@ -114,25 +110,29 @@ export var OAuthForm = /*#__PURE__*/function (_PureComponent) {
114
110
  var _this$props2 = this.props,
115
111
  konnector = _this$props2.konnector,
116
112
  t = _this$props2.t,
117
- flowState = _this$props2.flowState;
113
+ flowState = _this$props2.flowState,
114
+ reconnect = _this$props2.reconnect,
115
+ account = _this$props2.account;
118
116
  var _this$state = this.state,
119
- initialValues = _this$state.initialValues,
120
117
  showOAuthWindow = _this$state.showOAuthWindow,
121
118
  needExtraParams = _this$state.needExtraParams,
122
119
  extraParams = _this$state.extraParams;
123
120
  var isBusy = showOAuthWindow === true || flowState.running || needExtraParams && !extraParams;
124
- return initialValues ? null : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
121
+ var buttonLabel = reconnect ? 'oauth.reconnect.label' : 'oauth.connect.label';
122
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
125
123
  className: "u-mt-1",
126
124
  busy: isBusy,
127
125
  disabled: isBusy,
128
126
  extension: "full",
129
- label: t('oauth.connect.label'),
127
+ label: t(buttonLabel),
130
128
  onClick: this.handleConnect
131
129
  }), showOAuthWindow && /*#__PURE__*/React.createElement(OAuthWindow, {
132
130
  extraParams: extraParams,
133
131
  konnector: konnector,
132
+ reconnect: reconnect,
134
133
  onSuccess: this.handleAccountId,
135
- onCancel: this.handleOAuthCancel
134
+ onCancel: this.handleOAuthCancel,
135
+ account: account
136
136
  }));
137
137
  }
138
138
  }]);
@@ -150,6 +150,9 @@ OAuthForm.propTypes = {
150
150
  onSuccess: PropTypes.func,
151
151
 
152
152
  /** Translation function */
153
- t: PropTypes.func.isRequired
153
+ t: PropTypes.func.isRequired,
154
+
155
+ /** Is it a reconnection or not */
156
+ reconnect: PropTypes.bool
154
157
  };
155
158
  export default compose(translate(), withConnectionFlow())(OAuthForm);
@@ -30,7 +30,7 @@ describe('OAuthForm', function () {
30
30
  })).getElement();
31
31
  expect(component).toMatchSnapshot();
32
32
  });
33
- it('should not render button when update', function () {
33
+ it('should render reconnect button when updating an account', function () {
34
34
  var component = shallow( /*#__PURE__*/React.createElement(OAuthForm, {
35
35
  flowState: {},
36
36
  account: {
@@ -39,9 +39,10 @@ describe('OAuthForm', function () {
39
39
  }
40
40
  },
41
41
  konnector: fixtures.konnector,
42
+ reconnect: true,
42
43
  t: t
43
44
  })).getElement();
44
- expect(component).toBeNull();
45
+ expect(component).toMatchSnapshot();
45
46
  });
46
47
  it('should call policy fetchExtraOAuthUrlParams with proper params', function () {
47
48
  shallow( /*#__PURE__*/React.createElement(OAuthForm, {
@@ -65,13 +65,15 @@ export var OAuthWindow = /*#__PURE__*/function (_PureComponent) {
65
65
  client = _this$props.client,
66
66
  konnector = _this$props.konnector,
67
67
  redirectSlug = _this$props.redirectSlug,
68
- extraParams = _this$props.extraParams;
68
+ extraParams = _this$props.extraParams,
69
+ reconnect = _this$props.reconnect,
70
+ account = _this$props.account;
69
71
  this.realtime = new CozyRealtime({
70
72
  client: client
71
73
  });
72
74
  this.realtime.subscribe('notified', 'io.cozy.accounts', OAUTH_REALTIME_CHANNEL, this.handleMessage);
73
75
 
74
- var _prepareOAuth = prepareOAuth(client, konnector, redirectSlug, extraParams),
76
+ var _prepareOAuth = prepareOAuth(client, konnector, redirectSlug, extraParams, reconnect, account),
75
77
  oAuthStateKey = _prepareOAuth.oAuthStateKey,
76
78
  oAuthUrl = _prepareOAuth.oAuthUrl;
77
79
 
@@ -210,6 +212,12 @@ OAuthWindow.propTypes = {
210
212
  onCancel: PropTypes.func,
211
213
 
212
214
  /** The app we want to redirect the user on, after the OAuth flow. It used by the stack */
213
- redirectSlug: PropTypes.string
215
+ redirectSlug: PropTypes.string,
216
+
217
+ /** Is it a reconnection or not */
218
+ reconnect: PropTypes.bool,
219
+
220
+ /** Existing account */
221
+ account: PropTypes.object
214
222
  };
215
223
  export default translate()(withClient(OAuthWindow));
@@ -507,7 +507,8 @@ export var DumbTriggerManager = /*#__PURE__*/function (_Component) {
507
507
  flow = _this$props5.flow,
508
508
  flowState = _this$props5.flowState,
509
509
  client = _this$props5.client,
510
- OAuthFormWrapperComp = _this$props5.OAuthFormWrapperComp;
510
+ OAuthFormWrapperComp = _this$props5.OAuthFormWrapperComp,
511
+ reconnect = _this$props5.reconnect;
511
512
  var submitting = flowState.running;
512
513
  var _this$state = this.state,
513
514
  account = _this$state.account,
@@ -527,6 +528,7 @@ export var DumbTriggerManager = /*#__PURE__*/function (_Component) {
527
528
  client: client,
528
529
  flow: flow,
529
530
  account: account,
531
+ reconnect: reconnect,
530
532
  konnector: konnector,
531
533
  onSuccess: this.handleOAuthAccountId
532
534
  }));
@@ -617,7 +619,10 @@ DumbTriggerManager.propTypes = {
617
619
  flow: PropTypes.object,
618
620
  flowState: PropTypes.object,
619
621
  // Used to inject a component around OAuthForm, and so customize the UI from the app
620
- OAuthFormWrapperComp: PropTypes.node
622
+ OAuthFormWrapperComp: PropTypes.node,
623
+
624
+ /** Is it a reconnection or not */
625
+ reconnect: PropTypes.bool
621
626
  };
622
627
  var TriggerManager = compose(translate(), withClient, withVaultUnlockContext, withConnectionFlow())(DumbTriggerManager); // TriggerManager is exported wrapped in FlowProvider to avoid breaking changes.
623
628
 
@@ -12,3 +12,16 @@ exports[`OAuthForm should render 1`] = `
12
12
  />
13
13
  </React.Fragment>
14
14
  `;
15
+
16
+ exports[`OAuthForm should render reconnect button when update 1`] = `
17
+ <React.Fragment>
18
+ <DefaultButton
19
+ busy={true}
20
+ className="u-mt-1"
21
+ disabled={true}
22
+ extension="full"
23
+ label="oauth.reconnect.label"
24
+ onClick={[Function]}
25
+ />
26
+ </React.Fragment>
27
+ `;
@@ -1,3 +1,4 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  import uuid from 'uuid/v4';
2
3
  import get from 'lodash/get';
3
4
  import CozyClient from 'cozy-client';
@@ -94,6 +95,9 @@ export var handleOAuthResponse = function handleOAuthResponse() {
94
95
  * @param {string} redirectSlug The app we want to redirect the user on after the end of the flow
95
96
  * @param {string} nonce unique nonce string
96
97
  * @param {Object} extraParams some extra parameters to add to the query string
98
+ * @param {Boolean} reconnect Are we trying to reconnect an existing account ?
99
+ * @param {io.cozy.accounts} account targeted account if any
100
+ * @returns {String} final OAuth url string
97
101
  */
98
102
 
99
103
  export var getOAuthUrl = function getOAuthUrl(_ref) {
@@ -104,25 +108,35 @@ export var getOAuthUrl = function getOAuthUrl(_ref) {
104
108
  oAuthConf = _ref$oAuthConf === void 0 ? {} : _ref$oAuthConf,
105
109
  nonce = _ref.nonce,
106
110
  redirectSlug = _ref.redirectSlug,
107
- extraParams = _ref.extraParams;
108
- var oAuthUrl = "".concat(cozyUrl, "/accounts/").concat(accountType, "/start?state=").concat(oAuthStateKey, "&nonce=").concat(nonce);
111
+ extraParams = _ref.extraParams,
112
+ reconnect = _ref.reconnect,
113
+ account = _ref.account;
114
+ var startOrReconnect = reconnect ? 'reconnect' : 'start';
115
+ var accountIdParam = reconnect ? account._id + '/' : '';
116
+ var oAuthUrl = new URL("".concat(cozyUrl, "/accounts/").concat(accountType, "/").concat(accountIdParam).concat(startOrReconnect));
117
+ oAuthUrl.searchParams.set('state', oAuthStateKey);
118
+ oAuthUrl.searchParams.set('nonce', nonce);
109
119
 
110
120
  if (oAuthConf.scope !== undefined && oAuthConf.scope !== null && oAuthConf.scope !== false) {
111
121
  var urlScope = Array.isArray(oAuthConf.scope) ? oAuthConf.scope.join('+') : oAuthConf.scope;
112
- oAuthUrl += "&scope=".concat(urlScope);
122
+ oAuthUrl.searchParams.set('scope', urlScope);
113
123
  }
114
124
 
115
125
  if (redirectSlug) {
116
- oAuthUrl += "&slug=".concat(redirectSlug);
126
+ oAuthUrl.searchParams.set('slug', redirectSlug);
117
127
  }
118
128
 
119
129
  if (extraParams) {
120
- for (var key in extraParams) {
121
- oAuthUrl += "&".concat(key, "=").concat(extraParams[key]);
122
- }
130
+ Object.entries(extraParams).forEach(function (_ref2) {
131
+ var _ref3 = _slicedToArray(_ref2, 2),
132
+ key = _ref3[0],
133
+ value = _ref3[1];
134
+
135
+ return oAuthUrl.searchParams.set(key, value);
136
+ });
123
137
  }
124
138
 
125
- return oAuthUrl;
139
+ return oAuthUrl.toString();
126
140
  };
127
141
 
128
142
  var getAppSlug = function getAppSlug(client) {
@@ -135,12 +149,16 @@ var getAppSlug = function getAppSlug(client) {
135
149
  * @param {string} domain Cozy domain
136
150
  * @param {Object} konnector
137
151
  * @param {string} redirectSlug The app we want to redirect the user on after the end of the flow
138
- * @return {Object} Object containing: `oAuthUrl` (URL of cozy stack
139
- * OAuth endpoint) and `oAuthStateKey` (localStorage key)
152
+ * @param {Object} extraParams some extra parameters to add to the query string
153
+ * @param {Boolean} reconnect Are we trying to reconnect an existing account ?
154
+ * @param {io.cozy.accounts} account targetted account if any
155
+ * @return {Object} Object containing: `oAuthUrl` (URL of cozy stack OAuth endpoint) and `oAuthStateKey` (localStorage key)
140
156
  */
141
157
 
142
158
 
143
159
  export var prepareOAuth = function prepareOAuth(client, konnector, redirectSlug, extraParams) {
160
+ var reconnect = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
161
+ var account = arguments.length > 5 ? arguments[5] : undefined;
144
162
  var oauth = konnector.oauth;
145
163
  var accountType = konnectors.getAccountType(konnector); // We use localStorage to store the account related data
146
164
  // We will later check in localStorage that the received information is
@@ -159,7 +177,9 @@ export var prepareOAuth = function prepareOAuth(client, konnector, redirectSlug,
159
177
  oAuthConf: oauth,
160
178
  nonce: Date.now(),
161
179
  redirectSlug: redirectSlug || getAppSlug(client),
162
- extraParams: extraParams
180
+ extraParams: extraParams,
181
+ reconnect: reconnect,
182
+ account: account
163
183
  });
164
184
  return {
165
185
  oAuthStateKey: oAuthStateKey,
@@ -53,7 +53,7 @@ describe('Oauth helper', function () {
53
53
  scope: ['thescope', 'thescope2']
54
54
  }
55
55
  }));
56
- expect(url).toEqual('https://cozyurl/accounts/testslug/start?state=statekey&nonce=1234&scope=thescope+thescope2');
56
+ expect(url).toEqual('https://cozyurl/accounts/testslug/start?state=statekey&nonce=1234&scope=thescope%2Bthescope2');
57
57
  });
58
58
  it('should use redirectSlug if present', function () {
59
59
  var url = getOAuthUrl(_objectSpread(_objectSpread({}, defaultConf), {}, {
@@ -72,6 +72,20 @@ describe('Oauth helper', function () {
72
72
  }));
73
73
  expect(url).toEqual('https://cozyurl/accounts/testslug/start?state=statekey&nonce=1234&token=thetoken&id_connector=40');
74
74
  });
75
+ it('should return reconnect url with account id if reconnect', function () {
76
+ var url = getOAuthUrl(_objectSpread(_objectSpread({}, defaultConf), {}, {
77
+ oAuthConf: {},
78
+ account: {
79
+ _id: 'accountid'
80
+ },
81
+ reconnect: true,
82
+ extraParams: {
83
+ code: 'thecode',
84
+ connection_id: 12345
85
+ }
86
+ }));
87
+ expect(url).toEqual('https://cozyurl/accounts/testslug/accountid/reconnect?state=statekey&nonce=1234&code=thecode&connection_id=12345');
88
+ });
75
89
  });
76
90
  describe('handleOAuthResponse', function () {
77
91
  var originalLocation;
@@ -386,6 +386,9 @@
386
386
  }
387
387
  },
388
388
  "oauth": {
389
+ "reconnect": {
390
+ "label": "Reconnect"
391
+ },
389
392
  "connect": {
390
393
  "label": "Connect"
391
394
  },
@@ -386,6 +386,9 @@
386
386
  }
387
387
  },
388
388
  "oauth": {
389
+ "reconnect": {
390
+ "label": "Se reconnecter"
391
+ },
389
392
  "connect": {
390
393
  "label": "Connecter"
391
394
  },
@@ -25,7 +25,7 @@ import { getBIConnection, getBIConnectionAccountsList } from './bi-http';
25
25
  import assert from '../assert';
26
26
  import logger from '../logger';
27
27
  import flag from 'cozy-flags';
28
- import { setBIConnectionId, saveBIConfig, findAccountWithBiConnection, convertBIErrortoKonnectorJobError, isBudgetInsightConnector } from './budget-insight';
28
+ import { setBIConnectionId, saveBIConfig, findAccountWithBiConnection, convertBIErrortoKonnectorJobError, isBudgetInsightConnector, getBIConnectionIdFromAccount } from './budget-insight';
29
29
  import { KonnectorJobError } from '../helpers/konnectors';
30
30
  import { waitForRealtimeEvent } from './jobUtils';
31
31
  import '../types';
@@ -288,16 +288,62 @@ export var onBIAccountCreation = /*#__PURE__*/function () {
288
288
  return _ref8.apply(this, arguments);
289
289
  };
290
290
  }();
291
- export var fetchExtraOAuthUrlParams = /*#__PURE__*/function () {
292
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref9) {
293
- var client, konnector, account, _yield$createTemporar2, token, biBankId, biBankIds;
291
+ /**
292
+ * Create OAuth extra parameters specific to reconnect webview
293
+ *
294
+ * @param {Number} options.biBankId - Connector bank id (compatible with non webview bi connectors)
295
+ * @param {Array<Number>} options.biBankIds - connector bank ids (for webview connectors)
296
+ * @param {String} options.token - BI temporary token
297
+ * @param {Number} options.connId - BI bi connection id
298
+ * @return {Object}
299
+ */
294
300
 
301
+ var getReconnectExtraOAuthUrlParams = /*#__PURE__*/function () {
302
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref9) {
303
+ var biBankId, biBankIds, token, connId;
295
304
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
296
305
  while (1) {
297
306
  switch (_context5.prev = _context5.next) {
298
307
  case 0:
299
- client = _ref9.client, konnector = _ref9.konnector, account = _ref9.account;
300
- _context5.next = 3;
308
+ biBankId = _ref9.biBankId, biBankIds = _ref9.biBankIds, token = _ref9.token, connId = _ref9.connId;
309
+ return _context5.abrupt("return", {
310
+ id_connector: biBankId || biBankIds,
311
+ code: token,
312
+ connection_id: connId
313
+ });
314
+
315
+ case 2:
316
+ case "end":
317
+ return _context5.stop();
318
+ }
319
+ }
320
+ }, _callee5);
321
+ }));
322
+
323
+ return function getReconnectExtraOAuthUrlParams(_x5) {
324
+ return _ref10.apply(this, arguments);
325
+ };
326
+ }();
327
+ /**
328
+ * Create OAuth extra parameters
329
+ *
330
+ * @param {CozyClient} options.client - CozyClient instance
331
+ * @param {io.cozy.konnectors} options.konnector connector manifest content
332
+ * @param {io.cozy.accounts} options.account The account content
333
+ * @return {Promise<Object>}
334
+ */
335
+
336
+
337
+ export var fetchExtraOAuthUrlParams = /*#__PURE__*/function () {
338
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref11) {
339
+ var client, konnector, account, _yield$createTemporar2, token, biBankId, biBankIds, connId, isReconnect;
340
+
341
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
342
+ while (1) {
343
+ switch (_context6.prev = _context6.next) {
344
+ case 0:
345
+ client = _ref11.client, konnector = _ref11.konnector, account = _ref11.account;
346
+ _context6.next = 3;
301
347
  return createTemporaryToken({
302
348
  client: client,
303
349
  konnector: konnector,
@@ -305,25 +351,41 @@ export var fetchExtraOAuthUrlParams = /*#__PURE__*/function () {
305
351
  });
306
352
 
307
353
  case 3:
308
- _yield$createTemporar2 = _context5.sent;
354
+ _yield$createTemporar2 = _context6.sent;
309
355
  token = _yield$createTemporar2.code;
310
356
  biBankId = _yield$createTemporar2.biBankId;
311
357
  biBankIds = _yield$createTemporar2.biBankIds;
312
- return _context5.abrupt("return", {
358
+ connId = getBIConnectionIdFromAccount(account);
359
+ isReconnect = Boolean(connId);
360
+
361
+ if (!isReconnect) {
362
+ _context6.next = 13;
363
+ break;
364
+ }
365
+
366
+ return _context6.abrupt("return", getReconnectExtraOAuthUrlParams({
367
+ biBankId: biBankId,
368
+ biBankIds: biBankIds,
369
+ token: token,
370
+ connId: connId
371
+ }));
372
+
373
+ case 13:
374
+ return _context6.abrupt("return", {
313
375
  id_connector: biBankId || biBankIds,
314
376
  token: token
315
377
  });
316
378
 
317
- case 8:
379
+ case 14:
318
380
  case "end":
319
- return _context5.stop();
381
+ return _context6.stop();
320
382
  }
321
383
  }
322
- }, _callee5);
384
+ }, _callee6);
323
385
  }));
324
386
 
325
- return function fetchExtraOAuthUrlParams(_x5) {
326
- return _ref10.apply(this, arguments);
387
+ return function fetchExtraOAuthUrlParams(_x6) {
388
+ return _ref12.apply(this, arguments);
327
389
  };
328
390
  }();
329
391
  /**
@@ -334,11 +396,11 @@ export var fetchExtraOAuthUrlParams = /*#__PURE__*/function () {
334
396
  * @return {Array<String>} - list of bank ids
335
397
  */
336
398
 
337
- export var getCozyBankIds = function getCozyBankIds(_ref11) {
399
+ export var getCozyBankIds = function getCozyBankIds(_ref13) {
338
400
  var _konnector$parameters, _account$auth, _konnector$fields, _konnector$fields$ban;
339
401
 
340
- var konnector = _ref11.konnector,
341
- account = _ref11.account;
402
+ var konnector = _ref13.konnector,
403
+ account = _ref13.account;
342
404
  var cozyBankId = (konnector === null || konnector === void 0 ? void 0 : (_konnector$parameters = konnector.parameters) === null || _konnector$parameters === void 0 ? void 0 : _konnector$parameters.bankId) || (account === null || account === void 0 ? void 0 : (_account$auth = account.auth) === null || _account$auth === void 0 ? void 0 : _account$auth.bankId);
343
405
 
344
406
  if (cozyBankId) {
@@ -364,17 +426,17 @@ export var getCozyBankIds = function getCozyBankIds(_ref11) {
364
426
  */
365
427
 
366
428
  export var refreshContracts = /*#__PURE__*/function () {
367
- var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref12) {
429
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref14) {
368
430
  var _account$relationship, _account$relationship2;
369
431
 
370
432
  var client, konnector, account, biConfig, code, config, connectionId, _yield$getBIConnectio, contracts, contractsById, currentContractsList, _iterator, _step, currentContract, disabledValue;
371
433
 
372
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
434
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
373
435
  while (1) {
374
- switch (_context6.prev = _context6.next) {
436
+ switch (_context7.prev = _context7.next) {
375
437
  case 0:
376
- client = _ref12.client, konnector = _ref12.konnector, account = _ref12.account;
377
- _context6.next = 3;
438
+ client = _ref14.client, konnector = _ref14.konnector, account = _ref14.account;
439
+ _context7.next = 3;
378
440
  return createTemporaryToken({
379
441
  client: client,
380
442
  konnector: konnector,
@@ -382,14 +444,14 @@ export var refreshContracts = /*#__PURE__*/function () {
382
444
  });
383
445
 
384
446
  case 3:
385
- biConfig = _context6.sent;
447
+ biConfig = _context7.sent;
386
448
  code = biConfig.code, config = _objectWithoutProperties(biConfig, _excluded2);
387
449
  connectionId = getWebviewBIConnectionId(account);
388
- _context6.next = 8;
450
+ _context7.next = 8;
389
451
  return getBIConnectionAccountsList(config, connectionId, code);
390
452
 
391
453
  case 8:
392
- _yield$getBIConnectio = _context6.sent;
454
+ _yield$getBIConnectio = _context7.sent;
393
455
  contracts = _yield$getBIConnectio.accounts;
394
456
  contractsById = contracts.reduce(function (memo, contract) {
395
457
  return _objectSpread(_objectSpread({}, memo), {}, _defineProperty({}, contract.id + '', contract.disabled));
@@ -410,19 +472,19 @@ export var refreshContracts = /*#__PURE__*/function () {
410
472
  _iterator.f();
411
473
  }
412
474
 
413
- _context6.next = 16;
475
+ _context7.next = 16;
414
476
  return client.save(account);
415
477
 
416
478
  case 16:
417
479
  case "end":
418
- return _context6.stop();
480
+ return _context7.stop();
419
481
  }
420
482
  }
421
- }, _callee6);
483
+ }, _callee7);
422
484
  }));
423
485
 
424
- return function refreshContracts(_x6) {
425
- return _ref13.apply(this, arguments);
486
+ return function refreshContracts(_x7) {
487
+ return _ref15.apply(this, arguments);
426
488
  };
427
489
  }();
428
490
 
@@ -441,20 +503,20 @@ function convertBIDateToStandardDate(biDate) {
441
503
 
442
504
 
443
505
  export var createTemporaryToken = /*#__PURE__*/function () {
444
- var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref14) {
506
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref16) {
445
507
  var client, konnector, account, cozyBankIds, jobResponse, event;
446
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
508
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
447
509
  while (1) {
448
- switch (_context7.prev = _context7.next) {
510
+ switch (_context8.prev = _context8.next) {
449
511
  case 0:
450
- client = _ref14.client, konnector = _ref14.konnector, account = _ref14.account;
512
+ client = _ref16.client, konnector = _ref16.konnector, account = _ref16.account;
451
513
  assert(konnector.slug, 'createTemporaryToken: konnector passed in options has no slug');
452
514
  cozyBankIds = getCozyBankIds({
453
515
  konnector: konnector,
454
516
  account: account
455
517
  });
456
518
  assert(cozyBankIds.length, 'createTemporaryToken: Could not determine cozyBankId from account or konnector');
457
- _context7.next = 6;
519
+ _context8.next = 6;
458
520
  return client.stackClient.jobs.create('konnector', {
459
521
  mode: 'getTemporaryToken',
460
522
  konnector: konnector.slug,
@@ -462,24 +524,24 @@ export var createTemporaryToken = /*#__PURE__*/function () {
462
524
  }, {}, true);
463
525
 
464
526
  case 6:
465
- jobResponse = _context7.sent;
466
- _context7.next = 9;
527
+ jobResponse = _context8.sent;
528
+ _context8.next = 9;
467
529
  return waitForRealtimeEvent(client, jobResponse.data.attributes, 'result', TEMP_TOKEN_TIMOUT_S * 1000);
468
530
 
469
531
  case 9:
470
- event = _context7.sent;
471
- return _context7.abrupt("return", event.data.result);
532
+ event = _context8.sent;
533
+ return _context8.abrupt("return", event.data.result);
472
534
 
473
535
  case 11:
474
536
  case "end":
475
- return _context7.stop();
537
+ return _context8.stop();
476
538
  }
477
539
  }
478
- }, _callee7);
540
+ }, _callee8);
479
541
  }));
480
542
 
481
- return function createTemporaryToken(_x7) {
482
- return _ref15.apply(this, arguments);
543
+ return function createTemporaryToken(_x8) {
544
+ return _ref17.apply(this, arguments);
483
545
  };
484
546
  }();
485
547
  export var konnectorPolicy = {