box-node-sdk 1.34.2 → 1.37.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 +37 -2
- package/README.md +1 -1
- package/lib/managers/files.js +4 -4
- package/lib/managers/folders.js +63 -0
- package/lib/managers/groups.js +1 -0
- package/lib/managers/metadata.js +1 -0
- package/lib/managers/search.js +2 -0
- package/lib/managers/webhooks.js +13 -1
- package/package.json +14 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Next Release
|
|
4
|
+
|
|
5
|
+
**New Features and Enhancements:**
|
|
6
|
+
|
|
7
|
+
- Add support for copyInstanceOnItemCopy field for metadata templates ([#572](https://github.com/box/box-node-sdk/pull/572))
|
|
8
|
+
|
|
9
|
+
**Bug Fixes:**
|
|
10
|
+
|
|
11
|
+
- Fix webhook signature validation ([#568](https://github.com/box/box-node-sdk/pull/568))
|
|
12
|
+
- Update dependencies to patch security vulnerabilities ([#578](https://github.com/box/box-node-sdk/pull/578))
|
|
13
|
+
|
|
14
|
+
## 1.36.0 (2020-01-27)
|
|
15
|
+
|
|
16
|
+
**New Features and Enhancements:**
|
|
17
|
+
|
|
18
|
+
- Add folder lock functionality ([#560](https://github.com/box/box-node-sdk/pull/560))
|
|
19
|
+
- Add support for filtering groups by name ([#561](https://github.com/box/box-node-sdk/pull/561))
|
|
20
|
+
|
|
21
|
+
**Bug Fixes:**
|
|
22
|
+
|
|
23
|
+
- Update proxy-agent to patch proxy support issue ([#563](https://github.com/box/box-node-sdk/pull/563))
|
|
24
|
+
- Update dependencies to patch security vulnerabilities ([#566](https://github.com/box/box-node-sdk/pull/566))
|
|
25
|
+
|
|
26
|
+
## 1.35.0 (2020-11-02)
|
|
27
|
+
|
|
28
|
+
**New Features and Enhancements:**
|
|
29
|
+
|
|
30
|
+
- Add support for search param to get shared link items ([#547](https://github.com/box/box-node-sdk/pull/547))
|
|
31
|
+
|
|
32
|
+
## 1.34.3 (2020-10-02)
|
|
33
|
+
|
|
34
|
+
**Bug Fixes:**
|
|
35
|
+
|
|
36
|
+
- Upgrade ajv dependency ([#545](https://github.com/box/box-node-sdk/pull/545))
|
|
37
|
+
|
|
3
38
|
## 1.34.2 [2020-08-20]
|
|
4
39
|
|
|
5
40
|
- Make iterator bug fix for uploading files non breaking ([#534](https://github.com/box/box-node-sdk/pull/534))
|
|
@@ -139,11 +174,11 @@ to specify a client ID and secret (thanks to @cbetta)
|
|
|
139
174
|
|
|
140
175
|
## 1.16.0 [2018-04-10]
|
|
141
176
|
|
|
142
|
-
- Added support for [assigning Retention Policies to Metadata Templates](https://github.com/box/box-node-sdk/blob/
|
|
177
|
+
- Added support for [assigning Retention Policies to Metadata Templates](https://github.com/box/box-node-sdk/blob/main/docs/retention-policies.md#assign-retention-policy)
|
|
143
178
|
|
|
144
179
|
## 1.15.0 [2018-03-29]
|
|
145
180
|
|
|
146
|
-
- Fixed [`client.webhooks.validateMessage() and `sdk.validateWebhookMessage()`](https://github.com/box/box-node-sdk/blob/
|
|
181
|
+
- Fixed [`client.webhooks.validateMessage() and `sdk.validateWebhookMessage()`](https://github.com/box/box-node-sdk/blob/main/docs/webhooks.md#validate-a-webhook-message)
|
|
147
182
|
to accept the request body as an `Object`
|
|
148
183
|
- Fixed `sdk.configure()` to correct reconfigure all options
|
|
149
184
|
- Improved error messages for API errors and added the request object as `error.request` for easier debugging
|
package/README.md
CHANGED
|
@@ -184,7 +184,7 @@ client.comments.delete('456')
|
|
|
184
184
|
|
|
185
185
|
For complete documentation about the available operations, please see
|
|
186
186
|
the [SDK documentation pages](./docs) and the auto-generated
|
|
187
|
-
[JSDocs](https://rawgit.com/box/box-node-sdk/
|
|
187
|
+
[JSDocs](https://rawgit.com/box/box-node-sdk/main/docs/jsdoc/index.html).
|
|
188
188
|
These contain detailed information about which methods are available and
|
|
189
189
|
how to use them.
|
|
190
190
|
|
package/lib/managers/files.js
CHANGED
|
@@ -1600,8 +1600,8 @@ Files.prototype.getRepresentationContent = function(fileID, representationType,
|
|
|
1600
1600
|
*
|
|
1601
1601
|
* @param {name} name - The name of the zip file to be created
|
|
1602
1602
|
* @param {Array} items - Array of files or folders to be part of the created zip
|
|
1603
|
-
* @param {Function} [callback] Passed a
|
|
1604
|
-
* @returns {Promise<string>} A promise resolving to
|
|
1603
|
+
* @param {Function} [callback] Passed a zip information object
|
|
1604
|
+
* @returns {Promise<string>} A promise resolving to a zip information object
|
|
1605
1605
|
*/
|
|
1606
1606
|
Files.prototype.createZip = function(name, items, callback) {
|
|
1607
1607
|
var params = {
|
|
@@ -1623,8 +1623,8 @@ Files.prototype.createZip = function(name, items, callback) {
|
|
|
1623
1623
|
* @param {name} name - The name of the zip file to be created
|
|
1624
1624
|
* @param {Array} items - Array of files or folders to be part of the created zip
|
|
1625
1625
|
* @param {Stream} stream - Stream to pipe the readable stream of the zip file
|
|
1626
|
-
* @param {Function} [callback] - Passed a status
|
|
1627
|
-
* @returns {Promise<Readable>} A promise resolving
|
|
1626
|
+
* @param {Function} [callback] - Passed a zip download status object
|
|
1627
|
+
* @returns {Promise<Readable>} A promise resolving to a zip download status object
|
|
1628
1628
|
*/
|
|
1629
1629
|
Files.prototype.downloadZip = function(name, items, stream, callback) {
|
|
1630
1630
|
var downloadStreamOptions = {
|
package/lib/managers/folders.js
CHANGED
|
@@ -15,6 +15,7 @@ var urlPath = require('../util/url-path'),
|
|
|
15
15
|
// Private
|
|
16
16
|
// ------------------------------------------------------------------------------
|
|
17
17
|
var BASE_PATH = '/folders',
|
|
18
|
+
FOLDER_LOCK = '/folder_locks',
|
|
18
19
|
WATERMARK_SUBRESOURCE = '/watermark';
|
|
19
20
|
|
|
20
21
|
|
|
@@ -577,6 +578,68 @@ Folders.prototype.removeWatermark = function(folderID, callback) {
|
|
|
577
578
|
|
|
578
579
|
return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
|
|
579
580
|
};
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Used to lock a Box folder.
|
|
584
|
+
*
|
|
585
|
+
* API Endpoint: '/folder_locks'
|
|
586
|
+
* Method: POST
|
|
587
|
+
*
|
|
588
|
+
* @param {string} folderID - The Box ID of the folder to lock
|
|
589
|
+
* @param {Function} [callback] - Passed the folder lock object if successful, error otherwise
|
|
590
|
+
* @returns {Promise<void>} A promise resolving to a folder lock object
|
|
591
|
+
*/
|
|
592
|
+
Folders.prototype.lock = function(folderID, callback) {
|
|
593
|
+
var params = {
|
|
594
|
+
body: {
|
|
595
|
+
folder: {
|
|
596
|
+
type: 'folder',
|
|
597
|
+
id: folderID
|
|
598
|
+
},
|
|
599
|
+
locked_operations: {
|
|
600
|
+
move: true,
|
|
601
|
+
delete: true
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
return this.client.wrapWithDefaultHandler(this.client.post)(FOLDER_LOCK, params, callback);
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Used to get all locks on a folder.
|
|
610
|
+
*
|
|
611
|
+
* API Endpoint: '/folder_locks'
|
|
612
|
+
* Method: GET
|
|
613
|
+
*
|
|
614
|
+
* @param {string} folderID - The Box ID of the folder to lock
|
|
615
|
+
* @param {Function} [callback] - Passed a collection of folder lock objects if successful, error otherwise
|
|
616
|
+
* @returns {Promise<void>} A promise resolving to a collection of folder lock objects
|
|
617
|
+
*/
|
|
618
|
+
Folders.prototype.getLocks = function(folderID, callback) {
|
|
619
|
+
var params = {
|
|
620
|
+
qs: {
|
|
621
|
+
folder_id: folderID
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
return this.client.wrapWithDefaultHandler(this.client.get)(FOLDER_LOCK, params, callback);
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Used to delete a lock on a folder.
|
|
629
|
+
*
|
|
630
|
+
* API Endpoint: '/folder_locks/:folderLockID'
|
|
631
|
+
* Method: DELETE
|
|
632
|
+
*
|
|
633
|
+
* @param {string} folderLockID - The Box ID of the folder lock
|
|
634
|
+
* @param {Function} [callback] - Empty response body passed if successful, error otherwise
|
|
635
|
+
* @returns {Promise<void>} A promise resolving to nothing
|
|
636
|
+
*/
|
|
637
|
+
Folders.prototype.deleteLock = function(folderLockID, callback) {
|
|
638
|
+
|
|
639
|
+
var apiPath = urlPath(FOLDER_LOCK, folderLockID);
|
|
640
|
+
|
|
641
|
+
return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
|
|
642
|
+
};
|
|
580
643
|
/**
|
|
581
644
|
* @module box-node-sdk/lib/managers/folders
|
|
582
645
|
* @see {@Link Folders}
|
package/lib/managers/groups.js
CHANGED
|
@@ -279,6 +279,7 @@ Groups.prototype.getMemberships = function(groupID, options, callback) {
|
|
|
279
279
|
* Method: GET
|
|
280
280
|
*
|
|
281
281
|
* @param {Object} [options] - Optional parameters, can be left null in most cases
|
|
282
|
+
* @param {string} [options.filter_term] - Limits the results to only groups whose name starts with the search term
|
|
282
283
|
* @param {int} [options.limit] - The number of memberships to retrieve
|
|
283
284
|
* @param {int} [options.offset] - Paging marker, retrieve records starting at this position in the list
|
|
284
285
|
* @param {Function} [callback] - Passed a list of groups if successful, error otherwise
|
package/lib/managers/metadata.js
CHANGED
|
@@ -148,6 +148,7 @@ Metadata.prototype = {
|
|
|
148
148
|
* @param {string} [options.templateKey] - The programmatic key for the template
|
|
149
149
|
* @param {boolean} [options.hidden] - Whether the template should be hidden in the UI
|
|
150
150
|
* @param {string} [options.scope=enterprise] - The scope for the template, only 'enterprise' is supported for now
|
|
151
|
+
* @param {boolean} [options.copyInstanceOnItemCopy] - Whether to include the metadata when a file or folder is copied
|
|
151
152
|
* @param {Function} [callback] - Passed the template if successful, error otherwise
|
|
152
153
|
* @returns {Promise<Object>} A promise resolving to the created template
|
|
153
154
|
*/
|
package/lib/managers/search.js
CHANGED
|
@@ -76,6 +76,8 @@ Search.prototype = {
|
|
|
76
76
|
* @param {string} [options.type] - The type of objects you want to include in the search results. The type can be file, folder, or web_link
|
|
77
77
|
* @param {string} [options.trash_content=non_trashed_only] - Controls whether to search in the trash. The value can be trashed_only or non_trashed_only
|
|
78
78
|
* @param {SearchMetadataFilter[]} [options.mdfilters] - Searches for objects with a specific metadata object association. Searches with the this parameter do not require a query string
|
|
79
|
+
* @param {boolean} [options.include_recent_shared_links] - Determines whether to include items accessible only via shared link in the response.
|
|
80
|
+
* @param {string} [options.fields] - Comma-delimited list of fields to be included in the response
|
|
79
81
|
* @param {int} [options.limit=30] - The number of search results to return, max 200
|
|
80
82
|
* @param {int} [options.offset=0] - The search result at which to start the response, must be a multiple of limit
|
|
81
83
|
* @param {string} [options.sort] - The field on which the results should be sorted, e.g. "modified_at"
|
package/lib/managers/webhooks.js
CHANGED
|
@@ -110,6 +110,17 @@ function validateDeliveryTimestamp(headers, maxMessageAge) {
|
|
|
110
110
|
return true;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Stringify JSON with escaped multibyte Unicode characters to ensure computed signatures match PHP's default behavior
|
|
115
|
+
*
|
|
116
|
+
* @param {Object} body - The parsed JSON object
|
|
117
|
+
* @returns {string} - Stringified JSON with escaped multibyte Unicode characters
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
function jsonStringifyWithEscapedUnicode(body) {
|
|
121
|
+
return JSON.stringify(body).replace(/[\u007f-\uffff]/g, char => `\\u${`0000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
113
124
|
// -----------------------------------------------------------------------------
|
|
114
125
|
// Public
|
|
115
126
|
// -----------------------------------------------------------------------------
|
|
@@ -351,7 +362,8 @@ Webhooks.validateMessage = function(body, headers, primaryKey, secondaryKey, max
|
|
|
351
362
|
// For frameworks like Express that automatically parse JSON
|
|
352
363
|
// bodies into Objects, re-stringify for signature testing
|
|
353
364
|
if (typeof body === 'object') {
|
|
354
|
-
|
|
365
|
+
// Escape forward slashes to ensure a matching signature
|
|
366
|
+
body = jsonStringifyWithEscapedUnicode(body).replace(/\//g, '\\/');
|
|
355
367
|
}
|
|
356
368
|
|
|
357
369
|
if (!validateSignature(body, headers, primaryKey, secondaryKey)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "box-node-sdk",
|
|
3
3
|
"author": "Box <oss@box.com>",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.37.0",
|
|
5
5
|
"description": "Official SDK for Box Plaform APIs",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -32,19 +32,20 @@
|
|
|
32
32
|
"major": "node Makefile.js major"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"ajv": "^6.12.3",
|
|
35
36
|
"bluebird": "^3.7.1",
|
|
36
37
|
"http-status": "^1.4.1",
|
|
37
38
|
"jsonwebtoken": "^8.5.1",
|
|
38
39
|
"merge-options": "^1.0.1",
|
|
39
40
|
"promise-queue": "^2.2.3",
|
|
40
|
-
"proxy-agent": "^
|
|
41
|
+
"proxy-agent": "^4.0.0",
|
|
41
42
|
"request": "^2.88.0",
|
|
42
43
|
"url-template": "^2.0.8",
|
|
43
44
|
"uuid": "^3.3.3"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"chai": "^4.2.0",
|
|
47
|
-
"coveralls": "^3.0
|
|
48
|
+
"coveralls": "^3.1.0",
|
|
48
49
|
"eslint": "^4.19.1",
|
|
49
50
|
"eslint-plugin-node": "^6.0.1",
|
|
50
51
|
"eslint-plugin-promise": "^3.8.0",
|
|
@@ -53,12 +54,13 @@
|
|
|
53
54
|
"jsdoc": "^3.6.3",
|
|
54
55
|
"jsonlint2": "^1.7.1",
|
|
55
56
|
"leche": "^2.3.0",
|
|
56
|
-
"mocha": "^
|
|
57
|
+
"mocha": "^6.0.0",
|
|
57
58
|
"mockery": "^2.1.0",
|
|
58
59
|
"nock": "^9.6.1",
|
|
59
|
-
"np": "^
|
|
60
|
-
"npm-
|
|
61
|
-
"
|
|
60
|
+
"np": "^7.2.0",
|
|
61
|
+
"npm-force-resolutions": "0.0.3",
|
|
62
|
+
"npm-upgrade": "^3.0.0",
|
|
63
|
+
"nyc": "^14.0.0",
|
|
62
64
|
"shelljs": "^0.8.3",
|
|
63
65
|
"shelljs-nodecli": "^0.1.1",
|
|
64
66
|
"sinon": "^7.5.0"
|
|
@@ -66,5 +68,9 @@
|
|
|
66
68
|
"files": [
|
|
67
69
|
"config",
|
|
68
70
|
"lib"
|
|
69
|
-
]
|
|
71
|
+
],
|
|
72
|
+
"resolutions": {
|
|
73
|
+
"handlebars": "4.5.3",
|
|
74
|
+
"minimist": "1.2.5"
|
|
75
|
+
}
|
|
70
76
|
}
|