cozy-client 28.2.2 → 29.0.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/dist/CozyClient.js +14 -1
- package/dist/CozyClient.spec.js +30 -0
- package/package.json +6 -6
package/dist/CozyClient.js
CHANGED
|
@@ -116,6 +116,18 @@ var referencesUnsupportedError = function referencesUnsupportedError(relationshi
|
|
|
116
116
|
return new Error("The \"".concat(relationshipClassName, "\" relationship does not support references. If you need to add references to a document, its relationship class must have the methods {add,remove}References"));
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
+
var securiseUri = function securiseUri(uri) {
|
|
120
|
+
var _window$cozy;
|
|
121
|
+
|
|
122
|
+
if (uri && (_window$cozy = window['cozy']) !== null && _window$cozy !== void 0 && _window$cozy.isSecureProtocol) {
|
|
123
|
+
var secureUrl = new URL(uri);
|
|
124
|
+
secureUrl.protocol = 'https:';
|
|
125
|
+
return secureUrl.toString();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return uri;
|
|
129
|
+
};
|
|
130
|
+
|
|
119
131
|
var DOC_CREATION = 'creation';
|
|
120
132
|
var DOC_UPDATE = 'update';
|
|
121
133
|
/**
|
|
@@ -220,6 +232,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
220
232
|
}
|
|
221
233
|
|
|
222
234
|
this.appMetadata = appMetadata;
|
|
235
|
+
options.uri = securiseUri(options.uri);
|
|
223
236
|
this.options = options;
|
|
224
237
|
this.queryIdGenerator = new _queries.QueryIDGenerator();
|
|
225
238
|
this.isLogged = false;
|
|
@@ -2537,7 +2550,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2537
2550
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2538
2551
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2539
2552
|
|
|
2540
|
-
CozyClient.version = "
|
|
2553
|
+
CozyClient.version = "29.0.0";
|
|
2541
2554
|
|
|
2542
2555
|
_microee.default.mixin(CozyClient);
|
|
2543
2556
|
|
package/dist/CozyClient.spec.js
CHANGED
|
@@ -72,6 +72,8 @@ describe('CozyClient initialization', () => {
|
|
|
72
72
|
})
|
|
73
73
|
|
|
74
74
|
client = new CozyClient({ links, schema: SCHEMA })
|
|
75
|
+
|
|
76
|
+
delete window.cozy
|
|
75
77
|
})
|
|
76
78
|
|
|
77
79
|
it('should autologin when provided token and uri', () => {
|
|
@@ -250,6 +252,34 @@ describe('CozyClient initialization', () => {
|
|
|
250
252
|
document.querySelector = globalQuerySelectorBefore
|
|
251
253
|
})
|
|
252
254
|
|
|
255
|
+
it('should secure the URL if window.cozy.isSecureProtocol is true', () => {
|
|
256
|
+
window.cozy = {
|
|
257
|
+
isSecureProtocol: true
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const client = new CozyClient({
|
|
261
|
+
uri: 'http://cozy.tools',
|
|
262
|
+
schema: '',
|
|
263
|
+
token: 'SOME_TOKEN'
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
expect(client.options.uri).toBe('https://cozy.tools/')
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
it('should NOT secure the URL if window.cozy.isSecureProtocol is false', () => {
|
|
270
|
+
window.cozy = {
|
|
271
|
+
isSecureProtocol: false
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const client = new CozyClient({
|
|
275
|
+
uri: 'http://cozy.tools',
|
|
276
|
+
schema: '',
|
|
277
|
+
token: 'SOME_TOKEN'
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
expect(client.options.uri).toBe('http://cozy.tools')
|
|
281
|
+
})
|
|
282
|
+
|
|
253
283
|
describe('capabilities', () => {
|
|
254
284
|
it('should instanciate Client with capabilities', () => {
|
|
255
285
|
const options = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "29.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@types/jest": "^26.0.20",
|
|
19
19
|
"@types/lodash": "^4.14.170",
|
|
20
20
|
"btoa": "^1.2.1",
|
|
21
|
-
"cozy-stack-client": "^
|
|
21
|
+
"cozy-stack-client": "^29.0.0",
|
|
22
22
|
"json-stable-stringify": "^1.0.1",
|
|
23
23
|
"lodash": "^4.17.13",
|
|
24
24
|
"microee": "^0.0.6",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/cli": "7.12.8",
|
|
44
|
-
"@cozy/codemods": "1.14.
|
|
44
|
+
"@cozy/codemods": "1.14.4",
|
|
45
45
|
"@material-ui/core": "4.11.3",
|
|
46
46
|
"@testing-library/react": "10.4.9",
|
|
47
47
|
"@testing-library/react-hooks": "3.7.0",
|
|
48
48
|
"babel-plugin-search-and-replace": "1.1.0",
|
|
49
49
|
"btoa": "1.2.1",
|
|
50
|
-
"cozy-device-helper": "1.
|
|
50
|
+
"cozy-device-helper": "2.1.0",
|
|
51
51
|
"cozy-flags": "2.8.6",
|
|
52
52
|
"cozy-logger": "1.7.0",
|
|
53
53
|
"cozy-ui": "48.0.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"typescript": "4.1.5"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"cozy-device-helper": "
|
|
65
|
+
"cozy-device-helper": ">=2.1.0",
|
|
66
66
|
"cozy-flags": ">2.8.6",
|
|
67
67
|
"cozy-logger": ">1.7.0",
|
|
68
68
|
"cozy-ui": ">34.0.0",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
74
74
|
},
|
|
75
75
|
"sideEffects": false,
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "e06be593189751f337a648cca37241005df099af"
|
|
77
77
|
}
|