cozy-client 26.0.1 → 27.1.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 +38 -0
- package/dist/CozyClient.js +19 -15
- package/dist/CozyClient.spec.js +16 -3
- package/dist/models/file.js +3 -4
- package/package.json +3 -3
- package/types/CozyClient.d.ts +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
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
|
+
# [27.1.0](https://github.com/cozy/cozy-client/compare/v27.0.1...v27.1.0) (2021-11-04)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package cozy-client
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [27.0.1](https://github.com/cozy/cozy-client/compare/v27.0.0...v27.0.1) (2021-11-04)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* Build new OAuth client from old OAuth client ([a8ecfd0](https://github.com/cozy/cozy-client/commit/a8ecfd0344d86ba7c45e2589442bb836ba274a89))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [27.0.0](https://github.com/cozy/cozy-client/compare/v26.0.2...v27.0.0) (2021-11-03)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package cozy-client
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [26.0.2](https://github.com/cozy/cozy-client/compare/v26.0.1...v26.0.2) (2021-11-01)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* Use regex supported by Safari ([1497318](https://github.com/cozy/cozy-client/commit/149731833c1830f4091f9361d717413caac4e664))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
## [26.0.1](https://github.com/cozy/cozy-client/compare/v26.0.0...v26.0.1) (2021-10-30)
|
|
7
45
|
|
|
8
46
|
**Note:** Version bump only for package cozy-client
|
package/dist/CozyClient.js
CHANGED
|
@@ -360,6 +360,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
360
360
|
* a client with a cookie-based instance of cozy-client-js.
|
|
361
361
|
*
|
|
362
362
|
* @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
|
|
363
|
+
* @param {object} options - CozyStackClient options
|
|
363
364
|
* @returns {CozyClient}
|
|
364
365
|
*/
|
|
365
366
|
|
|
@@ -2276,7 +2277,8 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2276
2277
|
*
|
|
2277
2278
|
* Warning: unlike other instantiators, this one needs to be awaited.
|
|
2278
2279
|
*
|
|
2279
|
-
* @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
|
|
2280
|
+
* @param {OldCozyClient} oldClient - An OAuth instance of the deprecated cozy-client
|
|
2281
|
+
* @param {object} options - CozyStackClient options
|
|
2280
2282
|
* @returns {Promise<CozyClient>} An instance of a client, configured from the old client
|
|
2281
2283
|
*/
|
|
2282
2284
|
|
|
@@ -2284,30 +2286,32 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2284
2286
|
key: "fromOldOAuthClient",
|
|
2285
2287
|
value: function () {
|
|
2286
2288
|
var _fromOldOAuthClient = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(oldClient, options) {
|
|
2287
|
-
var
|
|
2289
|
+
var credentials, oauthOptions;
|
|
2288
2290
|
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
2289
2291
|
while (1) {
|
|
2290
2292
|
switch (_context17.prev = _context17.next) {
|
|
2291
2293
|
case 0:
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
if (!hasOauthCreds) {
|
|
2294
|
+
if (!oldClient._oauth) {
|
|
2295
2295
|
_context17.next = 8;
|
|
2296
2296
|
break;
|
|
2297
2297
|
}
|
|
2298
2298
|
|
|
2299
|
-
_context17.next =
|
|
2300
|
-
return oldClient.
|
|
2299
|
+
_context17.next = 3;
|
|
2300
|
+
return oldClient.authorize();
|
|
2301
2301
|
|
|
2302
|
-
case
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
token: token
|
|
2307
|
-
|
|
2302
|
+
case 3:
|
|
2303
|
+
credentials = _context17.sent;
|
|
2304
|
+
oauthOptions = {
|
|
2305
|
+
oauth: credentials.client,
|
|
2306
|
+
token: credentials.token,
|
|
2307
|
+
scope: credentials.token.scope
|
|
2308
|
+
};
|
|
2309
|
+
return _context17.abrupt("return", new CozyClient(_objectSpread(_objectSpread({
|
|
2310
|
+
uri: oldClient._url
|
|
2311
|
+
}, oauthOptions), options)));
|
|
2308
2312
|
|
|
2309
2313
|
case 8:
|
|
2310
|
-
throw new Error('
|
|
2314
|
+
throw new Error('Cannot instantiate a new client: old client is not an OAuth client. CozyClient.fromOldClient might be more suitable.');
|
|
2311
2315
|
|
|
2312
2316
|
case 9:
|
|
2313
2317
|
case "end":
|
|
@@ -2411,7 +2415,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2411
2415
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2412
2416
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2413
2417
|
|
|
2414
|
-
CozyClient.version = "
|
|
2418
|
+
CozyClient.version = "27.1.0";
|
|
2415
2419
|
|
|
2416
2420
|
_microee.default.mixin(CozyClient);
|
|
2417
2421
|
|
package/dist/CozyClient.spec.js
CHANGED
|
@@ -143,17 +143,30 @@ describe('CozyClient initialization', () => {
|
|
|
143
143
|
it('can be instantiated from an oauth-based old client', async () => {
|
|
144
144
|
// Not using a real cozy-client-js here not to have to add it as a dep
|
|
145
145
|
const url = 'https://testcozy.mycozy.cloud'
|
|
146
|
-
const
|
|
146
|
+
const oauth = {
|
|
147
|
+
clientID: 'my-client'
|
|
148
|
+
// ... other OAuth client attributes
|
|
149
|
+
}
|
|
150
|
+
const token = {
|
|
151
|
+
tokenType: 'bearer',
|
|
152
|
+
accessToken: 'access-token',
|
|
153
|
+
refreshToken: 'refresh-token',
|
|
154
|
+
scope: ['io.cozy.files']
|
|
155
|
+
}
|
|
147
156
|
const oldClient = {
|
|
148
157
|
_url: url,
|
|
149
158
|
_oauth: true,
|
|
150
|
-
|
|
159
|
+
authorize: () => ({
|
|
160
|
+
client: oauth,
|
|
151
161
|
token
|
|
152
162
|
})
|
|
153
163
|
}
|
|
154
164
|
const client = await CozyClient.fromOldOAuthClient(oldClient)
|
|
165
|
+
console.log({ stackClient: client.stackClient })
|
|
155
166
|
expect(client.stackClient.uri).toBe(url)
|
|
156
|
-
expect(client.stackClient.
|
|
167
|
+
expect(client.stackClient.oauthOptions.clientID).toBe(oauth.clientID)
|
|
168
|
+
expect(client.stackClient.token.accessToken).toBe(token.accessToken)
|
|
169
|
+
expect(client.stackClient.scope).toBe(token.scope)
|
|
157
170
|
})
|
|
158
171
|
|
|
159
172
|
it('can be instantiated from dataset injected by the Stack in DOM', async () => {
|
package/dist/models/file.js
CHANGED
|
@@ -690,15 +690,14 @@ exports.overrideFileForPath = overrideFileForPath;
|
|
|
690
690
|
|
|
691
691
|
var generateNewFileNameOnConflict = function generateNewFileNameOnConflict(filenameWithoutExtension) {
|
|
692
692
|
//Check if the string ends by _1
|
|
693
|
-
var regex = new RegExp('(
|
|
694
|
-
|
|
693
|
+
var regex = new RegExp('(_)([0-9]+)$');
|
|
695
694
|
var matches = filenameWithoutExtension.match(regex);
|
|
696
695
|
|
|
697
696
|
if (matches) {
|
|
698
|
-
var versionNumber = parseInt(matches[
|
|
697
|
+
var versionNumber = parseInt(matches[2]); //increment versionNumber
|
|
699
698
|
|
|
700
699
|
versionNumber++;
|
|
701
|
-
var newFilenameWithoutExtension = filenameWithoutExtension.replace(
|
|
700
|
+
var newFilenameWithoutExtension = filenameWithoutExtension.replace(new RegExp('(_)([0-9]+)$'), "_".concat(versionNumber));
|
|
702
701
|
return newFilenameWithoutExtension;
|
|
703
702
|
} else {
|
|
704
703
|
return "".concat(filenameWithoutExtension, "_1");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "27.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"cozy-device-helper": "^1.12.0",
|
|
22
22
|
"cozy-flags": "2.7.1",
|
|
23
23
|
"cozy-logger": "^1.6.0",
|
|
24
|
-
"cozy-stack-client": "^
|
|
24
|
+
"cozy-stack-client": "^27.1.0",
|
|
25
25
|
"json-stable-stringify": "^1.0.1",
|
|
26
26
|
"lodash": "^4.17.13",
|
|
27
27
|
"microee": "^0.0.6",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"react-native-inappbrowser-reborn": "^3.5.1"
|
|
69
69
|
},
|
|
70
70
|
"sideEffects": false,
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "b51301e21377602016243ed5a7d4d432075af7ef"
|
|
72
72
|
}
|
package/types/CozyClient.d.ts
CHANGED
|
@@ -61,19 +61,21 @@ declare class CozyClient {
|
|
|
61
61
|
* a client with a cookie-based instance of cozy-client-js.
|
|
62
62
|
*
|
|
63
63
|
* @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
|
|
64
|
+
* @param {object} options - CozyStackClient options
|
|
64
65
|
* @returns {CozyClient}
|
|
65
66
|
*/
|
|
66
|
-
static fromOldClient(oldClient: OldCozyClient, options:
|
|
67
|
+
static fromOldClient(oldClient: OldCozyClient, options: object): CozyClient;
|
|
67
68
|
/**
|
|
68
69
|
* To help with the transition from cozy-client-js to cozy-client, it is possible to instantiate
|
|
69
70
|
* a client with an OAuth-based instance of cozy-client-js.
|
|
70
71
|
*
|
|
71
72
|
* Warning: unlike other instantiators, this one needs to be awaited.
|
|
72
73
|
*
|
|
73
|
-
* @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
|
|
74
|
+
* @param {OldCozyClient} oldClient - An OAuth instance of the deprecated cozy-client
|
|
75
|
+
* @param {object} options - CozyStackClient options
|
|
74
76
|
* @returns {Promise<CozyClient>} An instance of a client, configured from the old client
|
|
75
77
|
*/
|
|
76
|
-
static fromOldOAuthClient(oldClient: OldCozyClient, options:
|
|
78
|
+
static fromOldOAuthClient(oldClient: OldCozyClient, options: object): Promise<CozyClient>;
|
|
77
79
|
/**
|
|
78
80
|
* In konnector/service context, CozyClient can be instantiated from
|
|
79
81
|
* environment variables
|