cozy-harvest-lib 9.0.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,53 @@
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.2.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.1.2...cozy-harvest-lib@9.2.0) (2022-05-09)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add BI connection creation via BI webview ([35ea078](https://github.com/cozy/cozy-libs/commit/35ea07805b5604d7882051bc0f7b43b38516922f))
12
+ * Unit tests + comments ([93e960e](https://github.com/cozy/cozy-libs/commit/93e960ee3236df742b8665d4d79cf6cf675d4f8f))
13
+
14
+
15
+
16
+
17
+
18
+ ## 9.1.2 (2022-05-05)
19
+
20
+ **Note:** Version bump only for package cozy-harvest-lib
21
+
22
+
23
+
24
+
25
+
26
+ ## [9.1.1](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.1.0...cozy-harvest-lib@9.1.1) (2022-05-02)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * bump form-data from 3.0.0 to 4.0.0 ([0a8546f](https://github.com/cozy/cozy-libs/commit/0a8546f2712a8164ff2bd08dfb60230bf97e1b85))
32
+
33
+
34
+
35
+
36
+
37
+ # [9.1.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.0.0...cozy-harvest-lib@9.1.0) (2022-05-02)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * Multiple fixes after review ([0351500](https://github.com/cozy/cozy-libs/commit/0351500e1845df6ef4a31211aec6061090ccf66e))
43
+
44
+
45
+ ### Features
46
+
47
+ * Open InAppBrowser via cozy-intent when in flaghip app ([5ee31ea](https://github.com/cozy/cozy-libs/commit/5ee31eafcb62e23a6242386bb6b09312f778e871))
48
+
49
+
50
+
51
+
52
+
6
53
  # [9.0.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@8.4.3...cozy-harvest-lib@9.0.0) (2022-04-29)
7
54
 
8
55
 
@@ -0,0 +1,65 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import { useEffect } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { useWebviewIntent } from 'cozy-intent';
6
+ import logger from '../logger';
7
+
8
+ var InAppBrowser = function InAppBrowser(_ref) {
9
+ var url = _ref.url,
10
+ onClose = _ref.onClose;
11
+ var webviewIntent = useWebviewIntent();
12
+ useEffect(function () {
13
+ function insideEffect() {
14
+ return _insideEffect.apply(this, arguments);
15
+ }
16
+
17
+ function _insideEffect() {
18
+ _insideEffect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
19
+ var result;
20
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
21
+ while (1) {
22
+ switch (_context.prev = _context.next) {
23
+ case 0:
24
+ if (!webviewIntent) {
25
+ _context.next = 5;
26
+ break;
27
+ }
28
+
29
+ _context.next = 3;
30
+ return webviewIntent.call('showInAppBrowser', {
31
+ url: url
32
+ });
33
+
34
+ case 3:
35
+ result = _context.sent;
36
+
37
+ if ((result === null || result === void 0 ? void 0 : result.type) === 'cancel' && onClose) {
38
+ onClose();
39
+ } else if ((result === null || result === void 0 ? void 0 : result.type) !== 'dismiss') {
40
+ logger.error('Unexpected InAppBrowser result', result);
41
+ }
42
+
43
+ case 5:
44
+ case "end":
45
+ return _context.stop();
46
+ }
47
+ }
48
+ }, _callee);
49
+ }));
50
+ return _insideEffect.apply(this, arguments);
51
+ }
52
+
53
+ insideEffect();
54
+ return function cleanup() {
55
+ webviewIntent.call('closeInAppBrowser');
56
+ };
57
+ }, [webviewIntent, url, onClose]);
58
+ return null;
59
+ };
60
+
61
+ InAppBrowser.propTypes = {
62
+ url: PropTypes.string.isRequired,
63
+ onClose: PropTypes.func
64
+ };
65
+ export default InAppBrowser;
@@ -0,0 +1,104 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import React from 'react';
4
+ import { render, waitFor } from '@testing-library/react';
5
+ import InAppBrowser from './InAppBrowser';
6
+ import { WebviewIntentProvider } from 'cozy-intent';
7
+ describe('InAppBrowser', function () {
8
+ it('should call showInAppBrowser', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
9
+ var url, intentCall, webviewService;
10
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
11
+ while (1) {
12
+ switch (_context.prev = _context.next) {
13
+ case 0:
14
+ url = 'https://test.url';
15
+ intentCall = jest.fn();
16
+ webviewService = {
17
+ call: intentCall
18
+ };
19
+ intentCall.mockResolvedValue({
20
+ type: 'dismiss'
21
+ });
22
+ render( /*#__PURE__*/React.createElement(WebviewIntentProvider, {
23
+ webviewService: webviewService
24
+ }, /*#__PURE__*/React.createElement(InAppBrowser, {
25
+ url: url
26
+ })));
27
+ expect(webviewService.call).toHaveBeenNthCalledWith(1, 'showInAppBrowser', {
28
+ url: url
29
+ });
30
+
31
+ case 6:
32
+ case "end":
33
+ return _context.stop();
34
+ }
35
+ }
36
+ }, _callee);
37
+ })));
38
+ it('should call onClose when user closes the inAppBrowser in app', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
39
+ var url, intentCall, webviewService, onClose;
40
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
41
+ while (1) {
42
+ switch (_context2.prev = _context2.next) {
43
+ case 0:
44
+ url = 'https://test.url';
45
+ intentCall = jest.fn();
46
+ webviewService = {
47
+ call: intentCall
48
+ };
49
+ onClose = jest.fn();
50
+ intentCall.mockResolvedValue({
51
+ type: 'cancel'
52
+ });
53
+ render( /*#__PURE__*/React.createElement(WebviewIntentProvider, {
54
+ webviewService: webviewService
55
+ }, /*#__PURE__*/React.createElement(InAppBrowser, {
56
+ url: url,
57
+ onClose: onClose
58
+ })));
59
+ _context2.next = 8;
60
+ return waitFor(function () {
61
+ return expect(onClose).toHaveBeenCalledTimes(1);
62
+ });
63
+
64
+ case 8:
65
+ expect(onClose).toHaveBeenCalledWith();
66
+
67
+ case 9:
68
+ case "end":
69
+ return _context2.stop();
70
+ }
71
+ }
72
+ }, _callee2);
73
+ })));
74
+ it('should call closeInAppBrowser when the component is unmounted', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
75
+ var url, intentCall, webviewService, _render, unmount;
76
+
77
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
78
+ while (1) {
79
+ switch (_context3.prev = _context3.next) {
80
+ case 0:
81
+ url = 'https://test.url';
82
+ intentCall = jest.fn();
83
+ webviewService = {
84
+ call: intentCall
85
+ };
86
+ intentCall.mockResolvedValue({
87
+ type: 'dismiss'
88
+ });
89
+ _render = render( /*#__PURE__*/React.createElement(WebviewIntentProvider, {
90
+ webviewService: webviewService
91
+ }, /*#__PURE__*/React.createElement(InAppBrowser, {
92
+ url: url
93
+ }))), unmount = _render.unmount;
94
+ unmount();
95
+ expect(webviewService.call).toHaveBeenNthCalledWith(2, 'closeInAppBrowser');
96
+
97
+ case 7:
98
+ case "end":
99
+ return _context3.stop();
100
+ }
101
+ }
102
+ }, _callee3);
103
+ })));
104
+ });
@@ -15,9 +15,11 @@ import PropTypes from 'prop-types';
15
15
  import { withClient } from 'cozy-client';
16
16
  import { translate } from 'cozy-ui/transpiled/react/I18n';
17
17
  import CozyRealtime from 'cozy-realtime';
18
+ import { isFlagshipApp } from 'cozy-device-helper';
18
19
  import { prepareOAuth, checkOAuthData, terminateOAuth, OAUTH_REALTIME_CHANNEL } from '../helpers/oauth'; // TODO use PopUp from cozy-ui
19
20
 
20
21
  import Popup from './Popup';
22
+ import InAppBrowser from './InAppBrowser';
21
23
  var OAUTH_POPUP_HEIGHT = 800;
22
24
  var OAUTH_POPUP_WIDTH = 800;
23
25
  /**
@@ -177,14 +179,17 @@ export var OAuthWindow = /*#__PURE__*/function (_PureComponent) {
177
179
  var _this$state = this.state,
178
180
  oAuthUrl = _this$state.oAuthUrl,
179
181
  succeed = _this$state.succeed;
180
- return oAuthUrl && !succeed && /*#__PURE__*/React.createElement(Popup, {
182
+ return oAuthUrl && !succeed && (!isFlagshipApp() ? /*#__PURE__*/React.createElement(Popup, {
181
183
  url: oAuthUrl,
182
184
  height: OAUTH_POPUP_HEIGHT,
183
185
  width: OAUTH_POPUP_WIDTH,
184
186
  onClose: this.handleClose,
185
187
  onUrlChange: this.handleUrlChange,
186
188
  title: t("oauth.window.title")
187
- });
189
+ }) : /*#__PURE__*/React.createElement(InAppBrowser, {
190
+ url: oAuthUrl,
191
+ onClose: this.handleClose
192
+ }));
188
193
  }
189
194
  }]);
190
195
 
@@ -522,8 +522,9 @@ export var DumbTriggerManager = /*#__PURE__*/function (_Component) {
522
522
  var showSpinner = submitting && selectedCipher && step === 'ciphersList';
523
523
  var showCiphersList = step === 'ciphersList';
524
524
  var showAccountForm = step === 'accountForm';
525
+ var konnectorPolicy = findKonnectorPolicy(konnector);
525
526
 
526
- if (oauth) {
527
+ if (oauth || konnectorPolicy.isBIWebView) {
527
528
  return /*#__PURE__*/React.createElement(OAuthForm, {
528
529
  client: client,
529
530
  flow: flow,
@@ -88,7 +88,7 @@ export var handleOAuthResponse = function handleOAuthResponse() {
88
88
  * @param {string} cozyUrl cozy url
89
89
  * @param {string} accountType connector slug
90
90
  * @param {string} oAuthStateKey localStorage key
91
- * @param {Object} oAuthConf connector manifest oauth configuration
91
+ * @param {Object} [oAuthConf={}] connector manifest oauth configuration
92
92
  * @param {string} redirectSlug The app we want to redirect the user on after the end of the flow
93
93
  * @param {string} nonce unique nonce string
94
94
  * @param {Object} extraParams some extra parameters to add to the query string
@@ -98,7 +98,8 @@ export var getOAuthUrl = function getOAuthUrl(_ref) {
98
98
  var cozyUrl = _ref.cozyUrl,
99
99
  accountType = _ref.accountType,
100
100
  oAuthStateKey = _ref.oAuthStateKey,
101
- oAuthConf = _ref.oAuthConf,
101
+ _ref$oAuthConf = _ref.oAuthConf,
102
+ oAuthConf = _ref$oAuthConf === void 0 ? {} : _ref$oAuthConf,
102
103
  nonce = _ref.nonce,
103
104
  redirectSlug = _ref.redirectSlug,
104
105
  extraParams = _ref.extraParams;
@@ -1,5 +1,6 @@
1
1
  import logger from './logger';
2
2
  import { konnectorPolicy as biKonnectorPolicy } from './services/budget-insight';
3
+ import { konnectorPolicy as biWebViewPolicy } from './services/biWebView';
3
4
  var defaultKonnectorPolicy = {
4
5
  accountContainsAuth: true,
5
6
  saveInVault: true,
@@ -9,7 +10,7 @@ var defaultKonnectorPolicy = {
9
10
  },
10
11
  name: 'default'
11
12
  };
12
- var policies = [biKonnectorPolicy, defaultKonnectorPolicy].filter(Boolean);
13
+ var policies = [biWebViewPolicy, biKonnectorPolicy, defaultKonnectorPolicy].filter(Boolean);
13
14
  logger.info('Available konnector policies', policies);
14
15
  export var findKonnectorPolicy = function findKonnectorPolicy(konnector) {
15
16
  var policy = policies.find(function (policy) {
@@ -0,0 +1,271 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
+ var _excluded = ["code"];
5
+
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+
10
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
11
+
12
+ /**
13
+ * Interface between Budget Insight and Cozy using BI's webview
14
+ *
15
+ * - Deals with the konnector to get temporary tokens
16
+ */
17
+ import { getBIConnection } from './bi-http';
18
+ import assert from '../assert';
19
+ import logger from '../logger';
20
+ import flag from 'cozy-flags';
21
+ import { fetchExtraOAuthUrlParams, createTemporaryToken, setBIConnectionId, saveBIConfig, findAccountWithBiConnection, convertBIErrortoKonnectorJobError, isBudgetInsightConnector } from './budget-insight';
22
+ import { KonnectorJobError } from '../helpers/konnectors';
23
+ export var isBiWebViewConnector = function isBiWebViewConnector(konnector) {
24
+ return flag('harvest.bi.webview') && isBudgetInsightConnector(konnector);
25
+ };
26
+ /**
27
+ * Runs multiple checks on the bi connection referenced in the given account
28
+ *
29
+ * @param {io.cozy.accounts} options.account The account content
30
+ * @param {ConnectionFlow} options.flow
31
+ * @param {io.cozy.konnectors} options.konnector connector manifest content
32
+ * @param {CozyClient} options.client CozyClient object
33
+ *
34
+ * @return {Integer} Connection Id
35
+ */
36
+
37
+ export var checkBIConnection = /*#__PURE__*/function () {
38
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
39
+ var account, client, konnector, flow, connId, biConfig, tempToken, config, connection, sameAccount, err;
40
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
41
+ while (1) {
42
+ switch (_context.prev = _context.next) {
43
+ case 0:
44
+ account = _ref.account, client = _ref.client, konnector = _ref.konnector, flow = _ref.flow;
45
+ _context.prev = 1;
46
+ connId = getWebviewBIConnectionId(account);
47
+ logger.info('Creating temporary token...');
48
+ _context.next = 6;
49
+ return createTemporaryToken({
50
+ client: client,
51
+ konnector: konnector,
52
+ account: account
53
+ });
54
+
55
+ case 6:
56
+ biConfig = _context.sent;
57
+ saveBIConfig(flow, biConfig);
58
+ tempToken = biConfig.code, config = _objectWithoutProperties(biConfig, _excluded);
59
+ logger.info('Created temporary token');
60
+ assert(tempToken, 'No temporary token');
61
+ logger.info("fetch connection ".concat(connId, "..."));
62
+ _context.next = 14;
63
+ return getBIConnection(config, connId, tempToken);
64
+
65
+ case 14:
66
+ connection = _context.sent;
67
+ _context.next = 17;
68
+ return findAccountWithBiConnection({
69
+ client: client,
70
+ konnector: konnector,
71
+ connectionId: connection.id
72
+ });
73
+
74
+ case 17:
75
+ sameAccount = _context.sent;
76
+
77
+ if (!sameAccount) {
78
+ _context.next = 22;
79
+ break;
80
+ }
81
+
82
+ err = new KonnectorJobError('ACCOUNT_WITH_SAME_IDENTIFIER_ALREADY_DEFINED');
83
+ err.accountId = sameAccount._id;
84
+ throw err;
85
+
86
+ case 22:
87
+ return _context.abrupt("return", connection);
88
+
89
+ case 25:
90
+ _context.prev = 25;
91
+ _context.t0 = _context["catch"](1);
92
+ return _context.abrupt("return", convertBIErrortoKonnectorJobError(_context.t0));
93
+
94
+ case 28:
95
+ case "end":
96
+ return _context.stop();
97
+ }
98
+ }
99
+ }, _callee, null, [[1, 25]]);
100
+ }));
101
+
102
+ return function checkBIConnection(_x) {
103
+ return _ref2.apply(this, arguments);
104
+ };
105
+ }();
106
+ /**
107
+ * Handles webview connection
108
+ *
109
+ * @param {io.cozy.accounts} options.account The account content
110
+ * @param {ConnectionFlow} options.flow
111
+ * @param {io.cozy.konnectors} options.konnector connector manifest content
112
+ * @param {CozyClient} options.client CozyClient object
113
+ *
114
+ * @return {Integer} Connection Id
115
+ */
116
+
117
+ export var handleOAuthAccount = /*#__PURE__*/function () {
118
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
119
+ var account, flow, konnector, client, t, cozyBankId, biWebviewAccount, connectionId;
120
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
121
+ while (1) {
122
+ switch (_context2.prev = _context2.next) {
123
+ case 0:
124
+ account = _ref3.account, flow = _ref3.flow, konnector = _ref3.konnector, client = _ref3.client, t = _ref3.t;
125
+ cozyBankId = getCozyBankId({
126
+ konnector: konnector,
127
+ account: account
128
+ });
129
+ biWebviewAccount = _objectSpread(_objectSpread({}, account), cozyBankId ? {
130
+ auth: {
131
+ bankId: cozyBankId
132
+ }
133
+ } : {});
134
+ connectionId = getWebviewBIConnectionId(biWebviewAccount);
135
+
136
+ if (!connectionId) {
137
+ _context2.next = 12;
138
+ break;
139
+ }
140
+
141
+ logger.info("Found a BI webview connection id: ".concat(connectionId));
142
+ flow.konnector = konnector;
143
+ _context2.next = 9;
144
+ return flow.saveAccount(setBIConnectionId(biWebviewAccount, connectionId));
145
+
146
+ case 9:
147
+ biWebviewAccount = _context2.sent;
148
+ _context2.next = 12;
149
+ return flow.handleFormSubmit({
150
+ client: client,
151
+ account: biWebviewAccount,
152
+ konnector: konnector,
153
+ t: t
154
+ });
155
+
156
+ case 12:
157
+ return _context2.abrupt("return", connectionId);
158
+
159
+ case 13:
160
+ case "end":
161
+ return _context2.stop();
162
+ }
163
+ }
164
+ }, _callee2);
165
+ }));
166
+
167
+ return function handleOAuthAccount(_x2) {
168
+ return _ref4.apply(this, arguments);
169
+ };
170
+ }();
171
+ /**
172
+ * Gets BI webview connection id which is returned in the account by the stack
173
+ * via oauth callback url
174
+ *
175
+ * @param {io.cozy.accounts} The account content created by the stack
176
+ *
177
+ * @return {Integer} Connection Id
178
+ */
179
+
180
+ var getWebviewBIConnectionId = function getWebviewBIConnectionId(account) {
181
+ var _account$oauth, _account$oauth$query, _account$oauth$query$;
182
+
183
+ return Number((account === null || account === void 0 ? void 0 : (_account$oauth = account.oauth) === null || _account$oauth === void 0 ? void 0 : (_account$oauth$query = _account$oauth.query) === null || _account$oauth$query === void 0 ? void 0 : (_account$oauth$query$ = _account$oauth$query.connection_id) === null || _account$oauth$query$ === void 0 ? void 0 : _account$oauth$query$[0]) || null);
184
+ };
185
+ /**
186
+ * Hook from ConnectionFlow after account creation
187
+ *
188
+ * @param {io.cozy.accounts} options.account - created account
189
+ * @param {io.cozy.konnectors} options.konnector - manifest of the konnector for which the account is created
190
+ * @param {ConnectionFlow} options.flow - current ConnectionFlow instance
191
+ * @param {CozyClient} options.client - current CozyClient instance
192
+ *
193
+ * @returns {Promise<io.cozy.accounts>}
194
+ */
195
+
196
+
197
+ export var onBIAccountCreation = /*#__PURE__*/function () {
198
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
199
+ var fullAccount, client, flow, konnector, account, biConnection;
200
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
201
+ while (1) {
202
+ switch (_context3.prev = _context3.next) {
203
+ case 0:
204
+ fullAccount = _ref5.account, client = _ref5.client, flow = _ref5.flow, konnector = _ref5.konnector;
205
+ _context3.next = 3;
206
+ return flow.saveAccount(fullAccount);
207
+
208
+ case 3:
209
+ account = _context3.sent;
210
+ _context3.next = 6;
211
+ return checkBIConnection({
212
+ account: _objectSpread(_objectSpread({}, fullAccount), {}, {
213
+ _id: account._id
214
+ }),
215
+ client: client,
216
+ konnector: konnector,
217
+ flow: flow
218
+ });
219
+
220
+ case 6:
221
+ biConnection = _context3.sent;
222
+ flow.setData({
223
+ biConnection: biConnection
224
+ });
225
+ _context3.next = 10;
226
+ return flow.saveAccount(setBIConnectionId(account, biConnection.id));
227
+
228
+ case 10:
229
+ return _context3.abrupt("return", _context3.sent);
230
+
231
+ case 11:
232
+ case "end":
233
+ return _context3.stop();
234
+ }
235
+ }
236
+ }, _callee3);
237
+ }));
238
+
239
+ return function onBIAccountCreation(_x3) {
240
+ return _ref6.apply(this, arguments);
241
+ };
242
+ }();
243
+ /**
244
+ * Finds the current bankIid in a given konnector or account
245
+ *
246
+ * @param {io.cozy.accounts} options.account The account content
247
+ * @param {io.cozy.konnectors} options.konnector connector manifest content
248
+ */
249
+
250
+ export var getCozyBankId = function getCozyBankId(_ref7) {
251
+ var _konnector$parameters, _account$auth;
252
+
253
+ var konnector = _ref7.konnector,
254
+ account = _ref7.account;
255
+ 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);
256
+
257
+ if (!cozyBankId) {
258
+ logger.error('Could not find any bank id');
259
+ }
260
+
261
+ return cozyBankId;
262
+ };
263
+ export var konnectorPolicy = {
264
+ isBIWebView: true,
265
+ name: 'budget-insight-webview',
266
+ match: isBiWebViewConnector,
267
+ saveInVault: false,
268
+ onAccountCreation: onBIAccountCreation,
269
+ fetchExtraOAuthUrlParams: fetchExtraOAuthUrlParams,
270
+ handleOAuthAccount: handleOAuthAccount
271
+ };