cozy-harvest-lib 9.25.0 → 9.26.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 +13 -0
- package/dist/components/KonnectorConfiguration/ConfigurationTab/BIContractActivationWindow.spec.js +35 -22
- package/dist/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.js +16 -20
- package/dist/components/OAuthForm.js +2 -2
- package/dist/components/OAuthForm.spec.js +0 -1
- package/dist/services/biWebView.js +129 -151
- package/dist/services/biWebView.spec.js +110 -89
- package/package.json +2 -2
- package/src/components/KonnectorConfiguration/ConfigurationTab/BIContractActivationWindow.spec.jsx +17 -13
- package/src/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.jsx +17 -24
- package/src/components/OAuthForm.jsx +2 -2
- package/src/components/OAuthForm.spec.js +0 -1
- package/src/services/biWebView.js +19 -23
- package/src/services/biWebView.spec.js +51 -32
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
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.26.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.25.0...cozy-harvest-lib@9.26.0) (2022-08-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Detect reconnect explicitely ([b092392](https://github.com/cozy/cozy-libs/commit/b0923923727bdb08123bd78073a0dda238361f02))
|
|
12
|
+
* Handle cas with multiple bank ids ([9729626](https://github.com/cozy/cozy-libs/commit/97296267e941265a08ad052f1e5a62c3830566f2))
|
|
13
|
+
* Use BI account creation webview to handle accounts synchonization ([1b5e5ff](https://github.com/cozy/cozy-libs/commit/1b5e5ff06b6c98b14d0d8c388d31970ae36bfac0))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
# [9.25.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.24.4...cozy-harvest-lib@9.25.0) (2022-08-05)
|
|
7
20
|
|
|
8
21
|
|
package/dist/components/KonnectorConfiguration/ConfigurationTab/BIContractActivationWindow.spec.js
CHANGED
|
@@ -4,15 +4,14 @@ import React from 'react';
|
|
|
4
4
|
import CozyClient from 'cozy-client';
|
|
5
5
|
import { render, fireEvent, act, waitFor } from '@testing-library/react';
|
|
6
6
|
import AppLike from '../../../../test/AppLike';
|
|
7
|
-
|
|
8
|
-
var fetchContractSynchronizationUrl = jest.fn();
|
|
7
|
+
var fetchExtraOAuthUrlParams = jest.fn();
|
|
9
8
|
var refreshContracts = jest.fn();
|
|
10
9
|
jest.mock('../../../konnector-policies', function () {
|
|
11
10
|
return {
|
|
12
11
|
findKonnectorPolicy: jest.fn()
|
|
13
12
|
};
|
|
14
13
|
});
|
|
15
|
-
jest.mock('
|
|
14
|
+
jest.mock('../../Popup', function () {
|
|
16
15
|
return jest.fn().mockImplementation(function (_ref) {
|
|
17
16
|
var onClose = _ref.onClose;
|
|
18
17
|
setTimeout(onClose, 1);
|
|
@@ -26,14 +25,18 @@ jest.mock('../../InAppBrowser', function () {
|
|
|
26
25
|
return null;
|
|
27
26
|
});
|
|
28
27
|
});
|
|
28
|
+
jest.mock('../../../helpers/oauth');
|
|
29
|
+
jest.mock('cozy-realtime');
|
|
29
30
|
jest.mock('cozy-device-helper');
|
|
31
|
+
import BIContractActivationWindow from './BiContractActivationWindow';
|
|
30
32
|
import { findKonnectorPolicy } from '../../../konnector-policies';
|
|
31
|
-
import Popup from '
|
|
33
|
+
import Popup from '../../Popup';
|
|
32
34
|
import InAppBrowser from '../../InAppBrowser';
|
|
33
35
|
import { isFlagshipApp } from 'cozy-device-helper';
|
|
36
|
+
import { prepareOAuth } from '../../../helpers/oauth';
|
|
34
37
|
findKonnectorPolicy.mockImplementation(function () {
|
|
35
38
|
return {
|
|
36
|
-
|
|
39
|
+
fetchExtraOAuthUrlParams: fetchExtraOAuthUrlParams,
|
|
37
40
|
refreshContracts: refreshContracts
|
|
38
41
|
};
|
|
39
42
|
});
|
|
@@ -66,12 +69,17 @@ describe('BIContractActivationWindow', function () {
|
|
|
66
69
|
while (1) {
|
|
67
70
|
switch (_context3.prev = _context3.next) {
|
|
68
71
|
case 0:
|
|
72
|
+
prepareOAuth.mockImplementation(function () {
|
|
73
|
+
return {
|
|
74
|
+
oAuthUrl: 'https://test.url'
|
|
75
|
+
};
|
|
76
|
+
});
|
|
69
77
|
isFlagshipApp.mockImplementation(function () {
|
|
70
78
|
return false;
|
|
71
79
|
});
|
|
72
|
-
|
|
80
|
+
fetchExtraOAuthUrlParams.mockResolvedValue({});
|
|
73
81
|
_setup = setup(), getByRole = _setup.getByRole;
|
|
74
|
-
_context3.next =
|
|
82
|
+
_context3.next = 6;
|
|
75
83
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
76
84
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
77
85
|
while (1) {
|
|
@@ -90,8 +98,8 @@ describe('BIContractActivationWindow', function () {
|
|
|
90
98
|
}, _callee);
|
|
91
99
|
})));
|
|
92
100
|
|
|
93
|
-
case
|
|
94
|
-
_context3.next =
|
|
101
|
+
case 6:
|
|
102
|
+
_context3.next = 8;
|
|
95
103
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
96
104
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
97
105
|
while (1) {
|
|
@@ -111,14 +119,14 @@ describe('BIContractActivationWindow', function () {
|
|
|
111
119
|
}, _callee2);
|
|
112
120
|
})));
|
|
113
121
|
|
|
114
|
-
case
|
|
115
|
-
expect(
|
|
122
|
+
case 8:
|
|
123
|
+
expect(fetchExtraOAuthUrlParams).toHaveBeenCalled();
|
|
116
124
|
expect(refreshContracts).toHaveBeenCalledTimes(1);
|
|
117
125
|
expect(Popup).toHaveBeenCalledWith(expect.objectContaining({
|
|
118
|
-
|
|
119
|
-
}),
|
|
126
|
+
url: 'https://test.url'
|
|
127
|
+
}), {});
|
|
120
128
|
|
|
121
|
-
case
|
|
129
|
+
case 11:
|
|
122
130
|
case "end":
|
|
123
131
|
return _context3.stop();
|
|
124
132
|
}
|
|
@@ -135,9 +143,14 @@ describe('BIContractActivationWindow', function () {
|
|
|
135
143
|
isFlagshipApp.mockImplementation(function () {
|
|
136
144
|
return true;
|
|
137
145
|
});
|
|
138
|
-
|
|
146
|
+
prepareOAuth.mockImplementation(function () {
|
|
147
|
+
return {
|
|
148
|
+
oAuthUrl: 'https://testiab.url'
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
fetchExtraOAuthUrlParams.mockResolvedValue({});
|
|
139
152
|
_setup2 = setup(), getByRole = _setup2.getByRole;
|
|
140
|
-
_context6.next =
|
|
153
|
+
_context6.next = 6;
|
|
141
154
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
142
155
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
143
156
|
while (1) {
|
|
@@ -156,8 +169,8 @@ describe('BIContractActivationWindow', function () {
|
|
|
156
169
|
}, _callee4);
|
|
157
170
|
})));
|
|
158
171
|
|
|
159
|
-
case
|
|
160
|
-
_context6.next =
|
|
172
|
+
case 6:
|
|
173
|
+
_context6.next = 8;
|
|
161
174
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
162
175
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
163
176
|
while (1) {
|
|
@@ -177,14 +190,14 @@ describe('BIContractActivationWindow', function () {
|
|
|
177
190
|
}, _callee5);
|
|
178
191
|
})));
|
|
179
192
|
|
|
180
|
-
case
|
|
181
|
-
expect(
|
|
193
|
+
case 8:
|
|
194
|
+
expect(fetchExtraOAuthUrlParams).toHaveBeenCalled();
|
|
182
195
|
expect(refreshContracts).toHaveBeenCalledTimes(1);
|
|
183
196
|
expect(InAppBrowser).toHaveBeenCalledWith(expect.objectContaining({
|
|
184
|
-
url: '
|
|
197
|
+
url: 'https://testiab.url'
|
|
185
198
|
}), expect.anything());
|
|
186
199
|
|
|
187
|
-
case
|
|
200
|
+
case 11:
|
|
188
201
|
case "end":
|
|
189
202
|
return _context6.stop();
|
|
190
203
|
}
|
package/dist/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.js
CHANGED
|
@@ -5,11 +5,9 @@ import React, { useState, useEffect } from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { useClient } from 'cozy-client';
|
|
7
7
|
import Button from 'cozy-ui/transpiled/react/MuiCozyTheme/Buttons';
|
|
8
|
-
import Popup from 'cozy-ui/transpiled/react/Popup';
|
|
9
8
|
import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem';
|
|
10
9
|
import { findKonnectorPolicy } from '../../../konnector-policies';
|
|
11
|
-
import
|
|
12
|
-
import InAppBrowser from '../../InAppBrowser';
|
|
10
|
+
import OAuthWindow from '../../OAuthWindow';
|
|
13
11
|
import withLocales from '../../hoc/withLocales';
|
|
14
12
|
import { intentsApiProptype, innerAccountModalOverridesProptype } from '../../../helpers/proptypes';
|
|
15
13
|
|
|
@@ -22,8 +20,8 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
|
|
|
22
20
|
|
|
23
21
|
var _useState = useState(null),
|
|
24
22
|
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
extraParams = _useState2[0],
|
|
24
|
+
setExtraParams = _useState2[1];
|
|
27
25
|
|
|
28
26
|
var _useState3 = useState(false),
|
|
29
27
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
@@ -91,7 +89,7 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
|
|
|
91
89
|
switch (_context2.prev = _context2.next) {
|
|
92
90
|
case 0:
|
|
93
91
|
_context2.next = 2;
|
|
94
|
-
return konnectorPolicy.
|
|
92
|
+
return konnectorPolicy.fetchExtraOAuthUrlParams({
|
|
95
93
|
client: client,
|
|
96
94
|
account: account,
|
|
97
95
|
konnector: konnector
|
|
@@ -99,7 +97,7 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
|
|
|
99
97
|
|
|
100
98
|
case 2:
|
|
101
99
|
result = _context2.sent;
|
|
102
|
-
|
|
100
|
+
setExtraParams(result);
|
|
103
101
|
|
|
104
102
|
case 4:
|
|
105
103
|
case "end":
|
|
@@ -111,29 +109,27 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
|
|
|
111
109
|
return _handleLinkFetch.apply(this, arguments);
|
|
112
110
|
}
|
|
113
111
|
|
|
114
|
-
if (konnectorPolicy.
|
|
112
|
+
if (konnectorPolicy.fetchExtraOAuthUrlParams) {
|
|
115
113
|
handleLinkFetch();
|
|
116
114
|
}
|
|
117
115
|
}, [konnector.slug, account, client, konnectorPolicy]);
|
|
118
|
-
if (!konnectorPolicy.
|
|
116
|
+
if (!konnectorPolicy.fetchExtraOAuthUrlParams) return null;
|
|
119
117
|
var ButtonWrapper = innerAccountModalOverrides !== null && innerAccountModalOverrides !== void 0 && innerAccountModalOverrides.SyncButtonWrapperComp ? innerAccountModalOverrides.SyncButtonWrapperComp : React.Fragment;
|
|
120
118
|
return /*#__PURE__*/React.createElement(ListItem, null, /*#__PURE__*/React.createElement(ButtonWrapper, null, /*#__PURE__*/React.createElement(Button, {
|
|
121
119
|
variant: "text",
|
|
122
120
|
color: "primary",
|
|
123
|
-
disabled: !
|
|
121
|
+
disabled: !extraParams,
|
|
124
122
|
onClick: function onClick() {
|
|
125
123
|
return setWindowVisible(true);
|
|
126
124
|
}
|
|
127
|
-
}, t('contracts.handle-synchronization'))), isWindowVisible &&
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
onClose: onPopupClosed
|
|
136
|
-
})));
|
|
125
|
+
}, t('contracts.handle-synchronization'))), isWindowVisible && /*#__PURE__*/React.createElement(OAuthWindow, {
|
|
126
|
+
extraParams: extraParams,
|
|
127
|
+
konnector: konnector,
|
|
128
|
+
account: account,
|
|
129
|
+
intentsApi: intentsApi,
|
|
130
|
+
onSuccess: onPopupClosed,
|
|
131
|
+
onCancel: onPopupClosed
|
|
132
|
+
}));
|
|
137
133
|
};
|
|
138
134
|
|
|
139
135
|
BIContractActivationWindow.propTypes = {
|
|
@@ -68,10 +68,10 @@ export var OAuthForm = /*#__PURE__*/function (_PureComponent) {
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
konnectorPolicy.fetchExtraOAuthUrlParams({
|
|
71
|
-
flow: flow,
|
|
72
71
|
account: account,
|
|
73
72
|
konnector: konnector,
|
|
74
|
-
client: client
|
|
73
|
+
client: client,
|
|
74
|
+
reconnect: reconnect
|
|
75
75
|
}).then(this.handleExtraParams);
|
|
76
76
|
}
|
|
77
77
|
|