cozy-client 52.1.1 → 53.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
CHANGED
|
@@ -3049,7 +3049,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3049
3049
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
3050
3050
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
3051
3051
|
|
|
3052
|
-
CozyClient.version = "
|
|
3052
|
+
CozyClient.version = "53.0.0";
|
|
3053
3053
|
|
|
3054
3054
|
_microee.default.mixin(CozyClient);
|
|
3055
3055
|
|
package/dist/models/sharing.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.makeSharingLink = void 0;
|
|
9
9
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
|
|
@@ -31,15 +31,18 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
31
31
|
* @param {object} options - Options
|
|
32
32
|
* @param {string} [options.ttl] - Time to live (bigduration format, e.g. "4Y3M2D1h30m15s")
|
|
33
33
|
* @param {string} [options.password] - To generate a password-protected link
|
|
34
|
+
* @param {string[]} [options.verbs] - Array of verbs to allow on the shared link. Default is ['GET']
|
|
34
35
|
* @returns {Promise<string>} Shared link
|
|
35
36
|
*/
|
|
36
|
-
var
|
|
37
|
+
var makeSharingLink = /*#__PURE__*/function () {
|
|
37
38
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(client, filesIds) {
|
|
38
39
|
var _sharedLink$attribute, _sharedLink$attribute2;
|
|
39
40
|
|
|
40
41
|
var _ref2,
|
|
41
42
|
ttl,
|
|
42
43
|
password,
|
|
44
|
+
_ref2$verbs,
|
|
45
|
+
verbs,
|
|
43
46
|
PERMS,
|
|
44
47
|
_yield$client$save,
|
|
45
48
|
sharedLink,
|
|
@@ -50,14 +53,14 @@ var getSharingLink = /*#__PURE__*/function () {
|
|
|
50
53
|
while (1) {
|
|
51
54
|
switch (_context.prev = _context.next) {
|
|
52
55
|
case 0:
|
|
53
|
-
_ref2 = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}, ttl = _ref2.ttl, password = _ref2.password;
|
|
56
|
+
_ref2 = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}, ttl = _ref2.ttl, password = _ref2.password, _ref2$verbs = _ref2.verbs, verbs = _ref2$verbs === void 0 ? ['GET'] : _ref2$verbs;
|
|
54
57
|
PERMS = _objectSpread(_objectSpread({
|
|
55
58
|
_type: _const.DOCTYPE_PERMISSIONS,
|
|
56
59
|
permissions: {
|
|
57
60
|
files: {
|
|
58
61
|
type: _const.DOCTYPE_FILES,
|
|
59
62
|
values: filesIds,
|
|
60
|
-
verbs:
|
|
63
|
+
verbs: verbs
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
}, ttl && {
|
|
@@ -88,9 +91,9 @@ var getSharingLink = /*#__PURE__*/function () {
|
|
|
88
91
|
}, _callee);
|
|
89
92
|
}));
|
|
90
93
|
|
|
91
|
-
return function
|
|
94
|
+
return function makeSharingLink(_x, _x2) {
|
|
92
95
|
return _ref.apply(this, arguments);
|
|
93
96
|
};
|
|
94
97
|
}();
|
|
95
98
|
|
|
96
|
-
exports.
|
|
99
|
+
exports.makeSharingLink = makeSharingLink;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { makeSharingLink } from './sharing'
|
|
2
2
|
|
|
3
|
-
describe('
|
|
3
|
+
describe('makeSharingLink', () => {
|
|
4
4
|
const mockSharecode = { attributes: { shortcodes: { code: 'shortcode' } } }
|
|
5
5
|
const mockClient = ({ isFlatDomain = false } = {}) => ({
|
|
6
6
|
save: jest.fn(() => ({ data: mockSharecode })),
|
|
@@ -10,7 +10,7 @@ describe('getSharingLink', () => {
|
|
|
10
10
|
const mockFiles = ['fileId01', 'fileId02']
|
|
11
11
|
|
|
12
12
|
it('should generate the right share link if "isFlatDomain" param is not defined', async () => {
|
|
13
|
-
const sharingLink = await
|
|
13
|
+
const sharingLink = await makeSharingLink(mockClient(), mockFiles)
|
|
14
14
|
|
|
15
15
|
expect(sharingLink).toBe(
|
|
16
16
|
'http://drive.cozy.cloud/public?sharecode=shortcode#/'
|
|
@@ -18,7 +18,7 @@ describe('getSharingLink', () => {
|
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
it('should generate the right share link to a nested cozy', async () => {
|
|
21
|
-
const sharingLink = await
|
|
21
|
+
const sharingLink = await makeSharingLink(
|
|
22
22
|
mockClient({ isFlatDomain: false }),
|
|
23
23
|
mockFiles
|
|
24
24
|
)
|
|
@@ -29,7 +29,7 @@ describe('getSharingLink', () => {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
it('should generate the right share link to a flat cozy', async () => {
|
|
32
|
-
const sharingLink = await
|
|
32
|
+
const sharingLink = await makeSharingLink(
|
|
33
33
|
mockClient({ isFlatDomain: true }),
|
|
34
34
|
mockFiles
|
|
35
35
|
)
|
|
@@ -40,14 +40,14 @@ describe('getSharingLink', () => {
|
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
it('should generate the right share link with an correct sharecode', async () => {
|
|
43
|
-
const sharingLink = await
|
|
43
|
+
const sharingLink = await makeSharingLink(mockClient(), mockFiles)
|
|
44
44
|
|
|
45
45
|
expect(sharingLink).toContain('sharecode=shortcode')
|
|
46
46
|
})
|
|
47
47
|
it('should save called with the "ttl" param', async () => {
|
|
48
48
|
const mockSave = jest.fn().mockReturnValue({ data: mockSharecode })
|
|
49
49
|
const client = { ...mockClient(), save: mockSave }
|
|
50
|
-
await
|
|
50
|
+
await makeSharingLink(client, mockFiles, {
|
|
51
51
|
ttl: '1d'
|
|
52
52
|
})
|
|
53
53
|
|
|
@@ -67,7 +67,7 @@ describe('getSharingLink', () => {
|
|
|
67
67
|
it('should save called with the "password" param', async () => {
|
|
68
68
|
const mockSave = jest.fn().mockReturnValue({ data: mockSharecode })
|
|
69
69
|
const client = { ...mockClient(), save: mockSave }
|
|
70
|
-
await
|
|
70
|
+
await makeSharingLink(client, mockFiles, {
|
|
71
71
|
password: 'password'
|
|
72
72
|
})
|
|
73
73
|
|
|
@@ -84,10 +84,29 @@ describe('getSharingLink', () => {
|
|
|
84
84
|
})
|
|
85
85
|
})
|
|
86
86
|
|
|
87
|
+
it('should save called with the "verbs" param', async () => {
|
|
88
|
+
const mockSave = jest.fn().mockReturnValue({ data: mockSharecode })
|
|
89
|
+
const client = { ...mockClient(), save: mockSave }
|
|
90
|
+
await makeSharingLink(client, mockFiles, {
|
|
91
|
+
verbs: ['GET', 'POST']
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
expect(mockSave).toBeCalledWith({
|
|
95
|
+
_type: 'io.cozy.permissions',
|
|
96
|
+
permissions: {
|
|
97
|
+
files: {
|
|
98
|
+
type: 'io.cozy.files',
|
|
99
|
+
values: ['fileId01', 'fileId02'],
|
|
100
|
+
verbs: ['GET', 'POST']
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
|
|
87
106
|
it('should save called without the "ttl" or "password" params', async () => {
|
|
88
107
|
const mockSave = jest.fn().mockReturnValue({ data: mockSharecode })
|
|
89
108
|
const client = { ...mockClient(), save: mockSave }
|
|
90
|
-
await
|
|
109
|
+
await makeSharingLink(client, mockFiles)
|
|
91
110
|
|
|
92
111
|
expect(mockSave).toBeCalledWith({
|
|
93
112
|
_type: 'io.cozy.permissions',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "53.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": "^53.0.0",
|
|
22
22
|
"date-fns": "2.29.3",
|
|
23
23
|
"json-stable-stringify": "^1.0.1",
|
|
24
24
|
"lodash": "^4.17.13",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
73
73
|
},
|
|
74
74
|
"sideEffects": false,
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "ff361d04c014bbbe538d0515eb61f8ec65764f15"
|
|
76
76
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function makeSharingLink(client: CozyClient, filesIds: string[], { ttl, password, verbs }?: {
|
|
2
2
|
ttl: string;
|
|
3
3
|
password: string;
|
|
4
|
+
verbs: string[];
|
|
4
5
|
}): Promise<string>;
|
|
5
6
|
import CozyClient from "../CozyClient";
|