cozy-client 27.23.0 → 27.24.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.
@@ -2537,7 +2537,7 @@ var CozyClient = /*#__PURE__*/function () {
2537
2537
  CozyClient.hooks = CozyClient.hooks || {};
2538
2538
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2539
2539
 
2540
- CozyClient.version = "27.23.0";
2540
+ CozyClient.version = "27.24.0";
2541
2541
 
2542
2542
  _microee.default.mixin(CozyClient);
2543
2543
 
@@ -17,15 +17,24 @@ var _reactNative = require("react-native");
17
17
 
18
18
  //@ts-ignore
19
19
  //@ts-ignore
20
-
20
+ var USER_CANCELED = 'USER_CANCELED';
21
21
  /**
22
22
  * Opens a ReactNative InAppBrowser
23
23
  * and resolves with the URL containing
24
24
  * the token
25
25
  *
26
+ * When the user close the InAppBrowser, the promise
27
+ * rejects with USER_CANCELED message
28
+ *
29
+ * When the redirection URL contains `error=access_denied`
30
+ * the promise rejects with USER_CANCELED message. This means
31
+ * that the user closed the authorization popup
32
+ *
26
33
  * @param {string} url
27
34
  * @returns {Promise}
35
+ * @throws Will throw an "USER_CANCELED" message when the user cancel the authorization process
28
36
  */
37
+
29
38
  var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
30
39
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
31
40
  return _regenerator.default.wrap(function _callee$(_context) {
@@ -43,11 +52,12 @@ var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
43
52
  enableBarCollapsing: false,
44
53
  // Android Properties
45
54
  showTitle: true,
46
- toolbarColor: '#6200EE',
55
+ toolbarColor: '#8e9094',
47
56
  secondaryToolbarColor: 'black',
48
57
  enableUrlBarHiding: true,
49
58
  enableDefaultShare: true,
50
59
  forceCloseOnRedirection: false,
60
+ showInRecents: true,
51
61
  // Specify full animation resource identifier(package:anim/name)
52
62
  // or only resource name(in case of animation bundled with app).
53
63
  animations: {
@@ -56,6 +66,10 @@ var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
56
66
  endEnter: 'slide_in_left',
57
67
  endExit: 'slide_out_right'
58
68
  }
69
+ }).then(function (result) {
70
+ if (result.type === 'cancel') {
71
+ reject(USER_CANCELED);
72
+ }
59
73
  });
60
74
 
61
75
  var removeListener = function removeListener() {
@@ -67,6 +81,7 @@ var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
67
81
  var sanitizedUrl = url;
68
82
  var accessCode = /\?access_code=(.+)$/.test(url);
69
83
  var state = /\?state=(.+)$/.test(url);
84
+ var closeSignal = /\?error=access_denied$/.test(url);
70
85
 
71
86
  if (accessCode || state) {
72
87
  if (_reactNative.Platform.OS === 'ios') {
@@ -87,6 +102,8 @@ var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
87
102
  removeListener();
88
103
 
89
104
  _reactNativeInappbrowserReborn.InAppBrowser.close();
105
+ } else if (closeSignal) {
106
+ reject(USER_CANCELED);
90
107
  }
91
108
  };
92
109
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "27.23.0",
3
+ "version": "27.24.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -71,5 +71,5 @@
71
71
  "react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
72
72
  },
73
73
  "sideEffects": false,
74
- "gitHead": "d22e7abb96fe8b3393e3152f631176b0a4eafaeb"
74
+ "gitHead": "1b797059e18e7acfca9666ae8292dabe05a4eaff"
75
75
  }