box-node-sdk 2.0.0 → 2.3.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 +239 -205
- package/README.md +48 -18
- package/lib/box-client.d.ts +12 -10
- package/lib/box-client.js +8 -8
- package/lib/box-node-sdk.d.ts +23 -10
- package/lib/box-node-sdk.js +40 -11
- package/lib/box-node-sdk.js.map +1 -1
- package/lib/chunked-uploader.js.map +1 -1
- package/lib/managers/files.d.ts +56 -0
- package/lib/managers/files.js +3 -0
- package/lib/managers/files.js.map +1 -1
- package/lib/managers/folders.d.ts +47 -1
- package/lib/managers/folders.js +1 -4
- package/lib/managers/folders.js.map +1 -1
- package/lib/managers/metadata.d.ts +4 -2
- package/lib/managers/metadata.js +17 -3
- package/lib/managers/metadata.js.map +1 -1
- package/lib/schemas/index.d.ts +3 -3
- package/lib/schemas/index.js +3 -3
- package/lib/schemas/index.js.map +1 -1
- package/lib/sessions/{anonymous-session.d.ts → ccg-session.d.ts} +18 -15
- package/lib/sessions/{anonymous-session.js → ccg-session.js} +23 -23
- package/lib/sessions/ccg-session.js.map +1 -0
- package/lib/token-manager.js +11 -10
- package/lib/token-manager.js.map +1 -1
- package/package.json +9 -7
- package/lib/sessions/anonymous-session.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@ Box Node.js SDK
|
|
|
4
4
|
[](https://greenkeeper.io/)
|
|
5
5
|
|
|
6
6
|
[](http://opensource.box.com/badges)
|
|
7
|
+
[](https://coveralls.io/github/box/box-node-sdk?branch=main)
|
|
7
8
|
|
|
8
9
|
A Node.js interface to the [Box Content API](https://developers.box.com/docs/).
|
|
9
10
|
|
|
@@ -12,7 +13,6 @@ Getting Started Docs: https://developer.box.com/guides/tooling/sdks/node/
|
|
|
12
13
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
13
14
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
14
15
|
|
|
15
|
-
|
|
16
16
|
- [Installation](#installation)
|
|
17
17
|
- [Getting Started](#getting-started)
|
|
18
18
|
- [Creating API Clients](#creating-api-clients)
|
|
@@ -21,21 +21,25 @@ Getting Started Docs: https://developer.box.com/guides/tooling/sdks/node/
|
|
|
21
21
|
- [App Auth Client](#app-auth-client)
|
|
22
22
|
- [Using the Client to Make API Calls](#using-the-client-to-make-api-calls)
|
|
23
23
|
- [Constructing API Calls Manually](#constructing-api-calls-manually)
|
|
24
|
+
- [Versions](#versions)
|
|
25
|
+
- [Supported Version](#supported-version)
|
|
26
|
+
- [Version schedule](#version-schedule)
|
|
24
27
|
- [Questions, Bugs, and Feature Requests?](#questions-bugs-and-feature-requests)
|
|
25
28
|
- [Contributing to the Box Node.js SDK](#contributing-to-the-box-nodejs-sdk)
|
|
29
|
+
- [Changelog](#changelog)
|
|
26
30
|
- [Copyright and License](#copyright-and-license)
|
|
27
31
|
|
|
28
32
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
29
33
|
|
|
30
|
-
Installation
|
|
31
|
-
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
32
36
|
|
|
33
37
|
```
|
|
34
38
|
npm install --save box-node-sdk
|
|
35
39
|
```
|
|
36
40
|
|
|
37
|
-
Getting Started
|
|
38
|
-
|
|
41
|
+
## Getting Started
|
|
42
|
+
|
|
39
43
|
|
|
40
44
|
To get started with the SDK, get a Developer Token from the Configuration page
|
|
41
45
|
of your app in the [Box Developer Console][dev-console].
|
|
@@ -63,8 +67,8 @@ client.users.get(client.CURRENT_USER_ID)
|
|
|
63
67
|
|
|
64
68
|
[dev-console]: https://app.box.com/developers/console
|
|
65
69
|
|
|
66
|
-
Creating API Clients
|
|
67
|
-
|
|
70
|
+
## Creating API Clients
|
|
71
|
+
|
|
68
72
|
|
|
69
73
|
Clients are used to communicate with the API on behalf of a user.
|
|
70
74
|
|
|
@@ -72,7 +76,7 @@ Box supports three different types of client:
|
|
|
72
76
|
|
|
73
77
|
- **Basic Client:** Simple, makes calls via the given access token until the access token expires
|
|
74
78
|
- **Persistent Client:** For use with traditional OAuth2 apps, can refresh its tokens automatically and persist them via a token store
|
|
75
|
-
- **App Auth Client:** Uses the app auth JWT grant to act on behalf of app
|
|
79
|
+
- **App Auth Client:** Uses the app auth JWT grant to act on behalf of app/managed users and create new tokens automatically
|
|
76
80
|
|
|
77
81
|
### Basic Client
|
|
78
82
|
|
|
@@ -130,7 +134,7 @@ var sdk = BoxSDK.getPreconfiguredInstance(sdkConfig);
|
|
|
130
134
|
// so you don't need to specify it here
|
|
131
135
|
var serviceAccountClient = sdk.getAppAuthClient('enterprise');
|
|
132
136
|
|
|
133
|
-
// Get an app user client
|
|
137
|
+
// Get an app user or managed user client
|
|
134
138
|
var appUserClient = sdk.getAppAuthClient('user', 'YOUR-APP-USER-ID');
|
|
135
139
|
```
|
|
136
140
|
|
|
@@ -150,13 +154,13 @@ var sdk = new BoxSDK({
|
|
|
150
154
|
// Get the service account client, used to create and manage app user accounts
|
|
151
155
|
var serviceAccountClient = sdk.getAppAuthClient('enterprise', 'APP_ENTERPRISE_ID');
|
|
152
156
|
|
|
153
|
-
// Get an app user client
|
|
157
|
+
// Get an app user or managed user client
|
|
154
158
|
var appUserClient = sdk.getAppAuthClient('user', 'YOUR-APP-USER-ID');
|
|
155
159
|
```
|
|
156
160
|
|
|
157
161
|
|
|
158
|
-
Using the Client to Make API Calls
|
|
159
|
-
|
|
162
|
+
## Using the Client to Make API Calls
|
|
163
|
+
|
|
160
164
|
|
|
161
165
|
The different API endpoints you can call are represented as methods, grouped into
|
|
162
166
|
managers by the type of object they interact with.
|
|
@@ -218,15 +222,31 @@ client.del('/files/123');
|
|
|
218
222
|
.catch(error => { /* handle any errors */ });
|
|
219
223
|
```
|
|
220
224
|
|
|
221
|
-
|
|
222
|
-
|
|
225
|
+
## Versions
|
|
226
|
+
We use a modified version of [Semantic Versioning](https://semver.org/) for all changes. See [version strategy](VERSIONS.md) for details which is effective from 30 July 2022.
|
|
227
|
+
|
|
228
|
+
### Supported Version
|
|
229
|
+
|
|
230
|
+
Only the current MAJOR version of SDK is supported. New features, functionality, bug fixes, and security updates will only be added to the current MAJOR version.
|
|
231
|
+
|
|
232
|
+
A current release is on the leading edge of our SDK development, and is intended for customers who are in active development and want the latest and greatest features. Instead of stating a release date for a new feature, we set a fixed minor or patch release cadence of maximum 2-3 months (while we may release more often). At the same time, there is no schedule for major or breaking release. Instead, we will communicate one quarter in advance the upcoming breaking change to allow customers to plan for the upgrade. We always recommend that all users run the latest available minor release for whatever major version is in use. We highly recommend upgrading to the latest SDK major release at the earliest convenient time and before the EOL date.
|
|
233
|
+
|
|
234
|
+
### Version schedule
|
|
235
|
+
|
|
236
|
+
| Version | Supported Environments | State | First Release | EOL/Terminated |
|
|
237
|
+
|---------|------------------------|-----------|---------------|----------------|
|
|
238
|
+
| 2 | | Supported | 29 Sep 2021 | TBD |
|
|
239
|
+
| 1 | | EOL | 28 Mar 2019 | 29 Sep 2021 |
|
|
240
|
+
|
|
241
|
+
## Questions, Bugs, and Feature Requests?
|
|
242
|
+
|
|
223
243
|
|
|
224
244
|
[Browse the issues tickets](https://github.com/box/box-node-sdk/issues)! Or, if that doesn't work, [file a new one](https://github.com/box/box-node-sdk/issues/new) and someone will get back to you. If you have general questions about the
|
|
225
245
|
Box API, you can post to the [Box Developer Forum](https://community.box.com/t5/Developer-Forum/bd-p/DeveloperForum).
|
|
226
246
|
|
|
227
247
|
|
|
228
|
-
Contributing to the Box Node.js SDK
|
|
229
|
-
|
|
248
|
+
## Contributing to the Box Node.js SDK
|
|
249
|
+
|
|
230
250
|
|
|
231
251
|
1. Clone this repo.
|
|
232
252
|
1. Run `npm install`.
|
|
@@ -237,8 +257,18 @@ in the `tests/` directory!
|
|
|
237
257
|
|
|
238
258
|
For more information, please see [the Contribution guidelines](./CONTRIBUTING.md).
|
|
239
259
|
|
|
240
|
-
|
|
241
|
-
|
|
260
|
+
## Changelog
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
See [CHANGELOG.md](./CHANGELOG.md).
|
|
264
|
+
|
|
265
|
+
## Documentation
|
|
266
|
+
|
|
267
|
+
You can find guides and tutorials in the `docs` directory.
|
|
268
|
+
|
|
269
|
+
* [Configuration](docs/configuration.md)
|
|
270
|
+
|
|
271
|
+
## Copyright and License
|
|
242
272
|
|
|
243
273
|
Copyright 2018 Box, Inc. All rights reserved.
|
|
244
274
|
|
package/lib/box-client.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Box API Client
|
|
3
3
|
*/
|
|
4
|
+
import Files from './managers/files';
|
|
5
|
+
import Folders from './managers/folders';
|
|
4
6
|
import SignRequests from './managers/sign-requests.generated';
|
|
5
7
|
/**
|
|
6
8
|
* A collaboration role constant
|
|
@@ -30,8 +32,8 @@ declare class BoxClient {
|
|
|
30
32
|
_analyticsClient: any;
|
|
31
33
|
_tokenOptions: any;
|
|
32
34
|
users: any;
|
|
33
|
-
files:
|
|
34
|
-
folders:
|
|
35
|
+
files: Files;
|
|
36
|
+
folders: Folders;
|
|
35
37
|
comments: any;
|
|
36
38
|
collaborations: any;
|
|
37
39
|
groups: any;
|
|
@@ -90,7 +92,7 @@ declare class BoxClient {
|
|
|
90
92
|
* a permanent error, or if usable tokens are not available.
|
|
91
93
|
*
|
|
92
94
|
* @param {Object} params - Request lib params to configure the request
|
|
93
|
-
* @param {
|
|
95
|
+
* @param {Function} [callback] - passed response data
|
|
94
96
|
* @returns {Promise} Promise resolving to the response
|
|
95
97
|
* @private
|
|
96
98
|
*/
|
|
@@ -165,7 +167,7 @@ declare class BoxClient {
|
|
|
165
167
|
*
|
|
166
168
|
* @param {string} path - path to a certain API endpoint (ex: /file)
|
|
167
169
|
* @param {?Object} params - object containing parameters for the request, such as query strings and headers
|
|
168
|
-
* @param {
|
|
170
|
+
* @param {Function} [callback] - passed final API response or err if request failed
|
|
169
171
|
* @returns {void}
|
|
170
172
|
*/
|
|
171
173
|
get(path: string, params?: object | null, callback?: Function): any;
|
|
@@ -174,7 +176,7 @@ declare class BoxClient {
|
|
|
174
176
|
*
|
|
175
177
|
* @param {string} path - path to a certain API endpoint (ex: /file)
|
|
176
178
|
* @param {?Object} params - object containing parameters for the request, such as query strings and headers
|
|
177
|
-
* @param {
|
|
179
|
+
* @param {Function} [callback] - passed final API response or err if request failed
|
|
178
180
|
* @returns {void}
|
|
179
181
|
*/
|
|
180
182
|
post(path: string, params: object | null, callback?: Function): any;
|
|
@@ -183,7 +185,7 @@ declare class BoxClient {
|
|
|
183
185
|
*
|
|
184
186
|
* @param {string} path - path to a certain API endpoint (ex: /file)
|
|
185
187
|
* @param {?Object} params - object containing parameters for the request, such as query strings and headers
|
|
186
|
-
* @param {
|
|
188
|
+
* @param {Function} callback - passed final API response or err if request failed
|
|
187
189
|
* @returns {void}
|
|
188
190
|
*/
|
|
189
191
|
put(path: string, params?: object | null, callback?: Function): any;
|
|
@@ -192,7 +194,7 @@ declare class BoxClient {
|
|
|
192
194
|
*
|
|
193
195
|
* @param {string} path - path to a certain API endpoint (ex: /file)
|
|
194
196
|
* @param {?Object} params - object containing parameters for the request, such as query strings and headers
|
|
195
|
-
* @param {
|
|
197
|
+
* @param {Function} callback - passed final API response or err if request failed
|
|
196
198
|
* @returns {void}
|
|
197
199
|
*/
|
|
198
200
|
del(path: string, params: object | null, callback?: Function): any;
|
|
@@ -201,7 +203,7 @@ declare class BoxClient {
|
|
|
201
203
|
*
|
|
202
204
|
* @param {string} path - Path to an API endpoint (e.g. /files/content)
|
|
203
205
|
* @param {?Object} params - An optional object containing request parameters
|
|
204
|
-
* @param {
|
|
206
|
+
* @param {Function} callback - Called with API call results, or err if call failed
|
|
205
207
|
* @returns {void}
|
|
206
208
|
*/
|
|
207
209
|
options(path: string, params: object | null, callback?: Function): any;
|
|
@@ -210,7 +212,7 @@ declare class BoxClient {
|
|
|
210
212
|
* @param {string} path - path to an upload API endpoint
|
|
211
213
|
* @param {?Object} params - an optional object containing request parameters
|
|
212
214
|
* @param {?Object} formData - multipart form data to include in the upload request {@see https://github.com/mikeal/request#multipartform-data-multipart-form-uploads}
|
|
213
|
-
* @param {
|
|
215
|
+
* @param {Function} callback - called with API call results, or an error if the call failed
|
|
214
216
|
* @returns {void}
|
|
215
217
|
*/
|
|
216
218
|
upload(path: string, params: object | null, formData: object | null, callback: Function): any;
|
|
@@ -245,7 +247,7 @@ declare class BoxClient {
|
|
|
245
247
|
* back to the callback as errors. This is the standard behavior of most endpoints.
|
|
246
248
|
*
|
|
247
249
|
* @param {Function} callback The original callback given by the consumer
|
|
248
|
-
* @returns {?
|
|
250
|
+
* @returns {?Function} A new callback that processes the response before passing it to the callback.
|
|
249
251
|
*/
|
|
250
252
|
defaultResponseHandler(callback: Function): ((err: any, response: any) => void) | null;
|
|
251
253
|
/**
|
package/lib/box-client.js
CHANGED
|
@@ -279,7 +279,7 @@ var BoxClient = /** @class */ (function () {
|
|
|
279
279
|
* a permanent error, or if usable tokens are not available.
|
|
280
280
|
*
|
|
281
281
|
* @param {Object} params - Request lib params to configure the request
|
|
282
|
-
* @param {
|
|
282
|
+
* @param {Function} [callback] - passed response data
|
|
283
283
|
* @returns {Promise} Promise resolving to the response
|
|
284
284
|
* @private
|
|
285
285
|
*/
|
|
@@ -440,7 +440,7 @@ var BoxClient = /** @class */ (function () {
|
|
|
440
440
|
*
|
|
441
441
|
* @param {string} path - path to a certain API endpoint (ex: /file)
|
|
442
442
|
* @param {?Object} params - object containing parameters for the request, such as query strings and headers
|
|
443
|
-
* @param {
|
|
443
|
+
* @param {Function} [callback] - passed final API response or err if request failed
|
|
444
444
|
* @returns {void}
|
|
445
445
|
*/
|
|
446
446
|
BoxClient.prototype.get = function (path, params, callback) {
|
|
@@ -454,7 +454,7 @@ var BoxClient = /** @class */ (function () {
|
|
|
454
454
|
*
|
|
455
455
|
* @param {string} path - path to a certain API endpoint (ex: /file)
|
|
456
456
|
* @param {?Object} params - object containing parameters for the request, such as query strings and headers
|
|
457
|
-
* @param {
|
|
457
|
+
* @param {Function} [callback] - passed final API response or err if request failed
|
|
458
458
|
* @returns {void}
|
|
459
459
|
*/
|
|
460
460
|
BoxClient.prototype.post = function (path, params, callback) {
|
|
@@ -468,7 +468,7 @@ var BoxClient = /** @class */ (function () {
|
|
|
468
468
|
*
|
|
469
469
|
* @param {string} path - path to a certain API endpoint (ex: /file)
|
|
470
470
|
* @param {?Object} params - object containing parameters for the request, such as query strings and headers
|
|
471
|
-
* @param {
|
|
471
|
+
* @param {Function} callback - passed final API response or err if request failed
|
|
472
472
|
* @returns {void}
|
|
473
473
|
*/
|
|
474
474
|
BoxClient.prototype.put = function (path, params, callback) {
|
|
@@ -482,7 +482,7 @@ var BoxClient = /** @class */ (function () {
|
|
|
482
482
|
*
|
|
483
483
|
* @param {string} path - path to a certain API endpoint (ex: /file)
|
|
484
484
|
* @param {?Object} params - object containing parameters for the request, such as query strings and headers
|
|
485
|
-
* @param {
|
|
485
|
+
* @param {Function} callback - passed final API response or err if request failed
|
|
486
486
|
* @returns {void}
|
|
487
487
|
*/
|
|
488
488
|
BoxClient.prototype.del = function (path, params, callback) {
|
|
@@ -496,7 +496,7 @@ var BoxClient = /** @class */ (function () {
|
|
|
496
496
|
*
|
|
497
497
|
* @param {string} path - Path to an API endpoint (e.g. /files/content)
|
|
498
498
|
* @param {?Object} params - An optional object containing request parameters
|
|
499
|
-
* @param {
|
|
499
|
+
* @param {Function} callback - Called with API call results, or err if call failed
|
|
500
500
|
* @returns {void}
|
|
501
501
|
*/
|
|
502
502
|
BoxClient.prototype.options = function (path, params, callback) {
|
|
@@ -510,7 +510,7 @@ var BoxClient = /** @class */ (function () {
|
|
|
510
510
|
* @param {string} path - path to an upload API endpoint
|
|
511
511
|
* @param {?Object} params - an optional object containing request parameters
|
|
512
512
|
* @param {?Object} formData - multipart form data to include in the upload request {@see https://github.com/mikeal/request#multipartform-data-multipart-form-uploads}
|
|
513
|
-
* @param {
|
|
513
|
+
* @param {Function} callback - called with API call results, or an error if the call failed
|
|
514
514
|
* @returns {void}
|
|
515
515
|
*/
|
|
516
516
|
BoxClient.prototype.upload = function (path, params, formData, callback) {
|
|
@@ -543,7 +543,7 @@ var BoxClient = /** @class */ (function () {
|
|
|
543
543
|
* back to the callback as errors. This is the standard behavior of most endpoints.
|
|
544
544
|
*
|
|
545
545
|
* @param {Function} callback The original callback given by the consumer
|
|
546
|
-
* @returns {?
|
|
546
|
+
* @returns {?Function} A new callback that processes the response before passing it to the callback.
|
|
547
547
|
*/
|
|
548
548
|
BoxClient.prototype.defaultResponseHandler = function (callback) {
|
|
549
549
|
var self = this;
|
package/lib/box-node-sdk.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/// <reference types="node" />
|
|
5
5
|
/// <reference types="bluebird" />
|
|
6
6
|
import { EventEmitter } from 'events';
|
|
7
|
-
import
|
|
7
|
+
import CCGAPISession = require('./sessions/ccg-session');
|
|
8
8
|
import APIRequestManager = require('./api-request-manager');
|
|
9
9
|
import BoxClient = require('./box-client');
|
|
10
10
|
import TokenManager = require('./token-manager');
|
|
@@ -36,6 +36,10 @@ import TokenManager = require('./token-manager');
|
|
|
36
36
|
declare type TokenStore = object;
|
|
37
37
|
declare type UserConfigurationOptions = object;
|
|
38
38
|
declare type TokenRequestOptions = object;
|
|
39
|
+
declare type CCGConfig = {
|
|
40
|
+
boxSubjectType: "user" | "enterprise";
|
|
41
|
+
boxSubjectId: string;
|
|
42
|
+
};
|
|
39
43
|
/**
|
|
40
44
|
* A backend NodeJS SDK to interact with the Box V2 API.
|
|
41
45
|
* This is the single entry point for all SDK consumer interactions. This is the only file that a 3rd party app
|
|
@@ -57,7 +61,7 @@ declare class BoxSDKNode extends EventEmitter {
|
|
|
57
61
|
_eventBus: EventEmitter;
|
|
58
62
|
requestManager: APIRequestManager;
|
|
59
63
|
tokenManager: TokenManager;
|
|
60
|
-
|
|
64
|
+
ccgSession: CCGAPISession;
|
|
61
65
|
/**
|
|
62
66
|
* Expose the BoxClient property enumerations to the SDK as a whole. This allows
|
|
63
67
|
* the consumer to access and use these values from anywhere in their application
|
|
@@ -128,19 +132,28 @@ declare class BoxSDKNode extends EventEmitter {
|
|
|
128
132
|
*/
|
|
129
133
|
getPersistentClient(tokenInfo: any, tokenStore?: TokenStore): BoxClient;
|
|
130
134
|
/**
|
|
131
|
-
* Returns
|
|
132
|
-
*
|
|
133
|
-
*
|
|
135
|
+
* Returns a Box Client configured to use Client Credentials Grant for a service account. Requires enterprise ID
|
|
136
|
+
* to be set when configuring SDK instance.
|
|
137
|
+
*
|
|
138
|
+
* @returns {BoxClient} Returns a new Box Client paired to a AnonymousAPISession. All Anonymous API Sessions share the
|
|
134
139
|
* same tokens, which allows them to refresh them efficiently and reduce load on both the application and
|
|
135
140
|
* the API.
|
|
136
|
-
*
|
|
137
|
-
* @returns {BoxClient} Returns a new Box Client paired to a AnonymousAPISession
|
|
138
141
|
*/
|
|
139
142
|
getAnonymousClient(): BoxClient;
|
|
140
143
|
/**
|
|
141
|
-
*
|
|
144
|
+
* Returns a Box Client configured to use Client Credentials Grant for a specified user.
|
|
145
|
+
*
|
|
146
|
+
* @param userId the user ID to use when getting the access token
|
|
147
|
+
* @returns {BoxClient} Returns a new Box Client paired to a AnonymousAPISession. All Anonymous API Sessions share the
|
|
148
|
+
* same tokens, which allows them to refresh them efficiently and reduce load on both the application and
|
|
149
|
+
* the API.
|
|
150
|
+
*/
|
|
151
|
+
getCCGClientForUser(userId: string): BoxClient;
|
|
152
|
+
_getCCGClient(config: CCGConfig): BoxClient;
|
|
153
|
+
/**
|
|
154
|
+
* Create a new client using App Auth for the given entity. This allows either
|
|
142
155
|
* managing App Users (as the enterprise) or performing operations as the App
|
|
143
|
-
* Users themselves (as a user).
|
|
156
|
+
* Users or Managed Users themselves (as a user).
|
|
144
157
|
*
|
|
145
158
|
* @param {string} type The type of entity to operate as, "enterprise" or "user"
|
|
146
159
|
* @param {string} [id] (Optional) The Box ID of the entity to operate as
|
|
@@ -199,7 +212,7 @@ declare class BoxSDKNode extends EventEmitter {
|
|
|
199
212
|
* @param {string} userID The ID of the App User to generate a token for
|
|
200
213
|
* @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant, null for default behavior
|
|
201
214
|
* @param {Function} [callback] Passed the tokens if successful
|
|
202
|
-
* @returns {Promise<TokentInfo>} Promise
|
|
215
|
+
* @returns {Promise<TokentInfo>} Promise resolving to the token info
|
|
203
216
|
*/
|
|
204
217
|
getAppUserTokens(userID: string, options: TokenRequestOptions | Function | null, callback: Function): import("bluebird")<any>;
|
|
205
218
|
/**
|
package/lib/box-node-sdk.js
CHANGED
|
@@ -17,6 +17,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
17
17
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
18
18
|
};
|
|
19
19
|
})();
|
|
20
|
+
var __assign = (this && this.__assign) || function () {
|
|
21
|
+
__assign = Object.assign || function(t) {
|
|
22
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23
|
+
s = arguments[i];
|
|
24
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
25
|
+
t[p] = s[p];
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
};
|
|
29
|
+
return __assign.apply(this, arguments);
|
|
30
|
+
};
|
|
20
31
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
32
|
if (k2 === undefined) k2 = k;
|
|
22
33
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -41,7 +52,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
41
52
|
// ------------------------------------------------------------------------------
|
|
42
53
|
var events_1 = require("events");
|
|
43
54
|
var qs = __importStar(require("querystring"));
|
|
44
|
-
var
|
|
55
|
+
var CCGAPISession = require("./sessions/ccg-session");
|
|
45
56
|
var APIRequestManager = require("./api-request-manager");
|
|
46
57
|
var BoxClient = require("./box-client");
|
|
47
58
|
var TokenManager = require("./token-manager");
|
|
@@ -94,7 +105,7 @@ var BoxSDKNode = /** @class */ (function (_super) {
|
|
|
94
105
|
this.requestManager = new APIRequestManager(this.config, this._eventBus);
|
|
95
106
|
// Initialize the rest of the SDK with the given configuration
|
|
96
107
|
this.tokenManager = new TokenManager(this.config, this.requestManager);
|
|
97
|
-
this.
|
|
108
|
+
this.ccgSession = new CCGAPISession(this.config, this.tokenManager);
|
|
98
109
|
};
|
|
99
110
|
/**
|
|
100
111
|
* Gets the BoxSDKNode instance by passing boxAppSettings json downloaded from the developer console.
|
|
@@ -190,21 +201,39 @@ var BoxSDKNode = /** @class */ (function (_super) {
|
|
|
190
201
|
return new BoxClient(apiSession, this.config, this.requestManager);
|
|
191
202
|
};
|
|
192
203
|
/**
|
|
193
|
-
* Returns
|
|
194
|
-
*
|
|
195
|
-
*
|
|
204
|
+
* Returns a Box Client configured to use Client Credentials Grant for a service account. Requires enterprise ID
|
|
205
|
+
* to be set when configuring SDK instance.
|
|
206
|
+
*
|
|
207
|
+
* @returns {BoxClient} Returns a new Box Client paired to a AnonymousAPISession. All Anonymous API Sessions share the
|
|
196
208
|
* same tokens, which allows them to refresh them efficiently and reduce load on both the application and
|
|
197
209
|
* the API.
|
|
198
|
-
*
|
|
199
|
-
* @returns {BoxClient} Returns a new Box Client paired to a AnonymousAPISession
|
|
200
210
|
*/
|
|
201
211
|
BoxSDKNode.prototype.getAnonymousClient = function () {
|
|
202
|
-
|
|
212
|
+
if (!this.config.enterpriseID) {
|
|
213
|
+
throw new Error('Enterprise ID must be passed');
|
|
214
|
+
}
|
|
215
|
+
return this._getCCGClient({ boxSubjectType: "enterprise", boxSubjectId: this.config.enterpriseID });
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Returns a Box Client configured to use Client Credentials Grant for a specified user.
|
|
219
|
+
*
|
|
220
|
+
* @param userId the user ID to use when getting the access token
|
|
221
|
+
* @returns {BoxClient} Returns a new Box Client paired to a AnonymousAPISession. All Anonymous API Sessions share the
|
|
222
|
+
* same tokens, which allows them to refresh them efficiently and reduce load on both the application and
|
|
223
|
+
* the API.
|
|
224
|
+
*/
|
|
225
|
+
BoxSDKNode.prototype.getCCGClientForUser = function (userId) {
|
|
226
|
+
return this._getCCGClient({ boxSubjectType: "user", boxSubjectId: userId });
|
|
227
|
+
};
|
|
228
|
+
BoxSDKNode.prototype._getCCGClient = function (config) {
|
|
229
|
+
var anonymousTokenManager = new TokenManager(__assign(__assign({}, this.config), config), this.requestManager);
|
|
230
|
+
var newAnonymousSession = new CCGAPISession(this.config, anonymousTokenManager);
|
|
231
|
+
return new BoxClient(newAnonymousSession, this.config, this.requestManager);
|
|
203
232
|
};
|
|
204
233
|
/**
|
|
205
|
-
* Create a new client using App Auth for the given entity.
|
|
234
|
+
* Create a new client using App Auth for the given entity. This allows either
|
|
206
235
|
* managing App Users (as the enterprise) or performing operations as the App
|
|
207
|
-
* Users themselves (as a user).
|
|
236
|
+
* Users or Managed Users themselves (as a user).
|
|
208
237
|
*
|
|
209
238
|
* @param {string} type The type of entity to operate as, "enterprise" or "user"
|
|
210
239
|
* @param {string} [id] (Optional) The Box ID of the entity to operate as
|
|
@@ -293,7 +322,7 @@ var BoxSDKNode = /** @class */ (function (_super) {
|
|
|
293
322
|
* @param {string} userID The ID of the App User to generate a token for
|
|
294
323
|
* @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant, null for default behavior
|
|
295
324
|
* @param {Function} [callback] Passed the tokens if successful
|
|
296
|
-
* @returns {Promise<TokentInfo>} Promise
|
|
325
|
+
* @returns {Promise<TokentInfo>} Promise resolving to the token info
|
|
297
326
|
*/
|
|
298
327
|
BoxSDKNode.prototype.getAppUserTokens = function (userID, options, callback) {
|
|
299
328
|
if (typeof options === 'function') {
|
package/lib/box-node-sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box-node-sdk.js","sourceRoot":"","sources":["../src/box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offset: number;
|
|
29
29
|
size: number;
|
|
30
30
|
};
|
|
31
|
+
declare type FileSharedLinkAccess = 'open' | 'company' | 'collaborators' | null;
|
|
32
|
+
declare type FileSharedLinkPermissions = {
|
|
33
|
+
/**
|
|
34
|
+
* If the shared link allows only to view files. This can only be set when access is set to open or company.
|
|
35
|
+
*/
|
|
36
|
+
can_view?: true;
|
|
37
|
+
/**
|
|
38
|
+
* If the shared link allows only to download files. This can only be set when access is set to open or company.
|
|
39
|
+
*/
|
|
40
|
+
can_download?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* If the shared link allows only to edit files. This can only be set when access is set to open or company.
|
|
43
|
+
*/
|
|
44
|
+
can_edit?: boolean;
|
|
45
|
+
};
|
|
46
|
+
declare type FileSharedLink = {
|
|
47
|
+
/**
|
|
48
|
+
* The level of access for the shared link. This can be restricted to anyone with the link (open),
|
|
49
|
+
* only people within the company (company) and only those who have been invited to the file (collaborators).
|
|
50
|
+
*
|
|
51
|
+
* If not set, this field defaults to the access level specified by the enterprise admin.
|
|
52
|
+
* To create a shared link with this default setting pass the shared_link object with no access field.
|
|
53
|
+
* To remove access and change its value to default one pass the shared_link object with null value access field.
|
|
54
|
+
*/
|
|
55
|
+
access?: FileSharedLinkAccess;
|
|
56
|
+
/**
|
|
57
|
+
* The password required to access the shared link. Set the password to null to remove it.
|
|
58
|
+
* A password can only be set when access is set to open.
|
|
59
|
+
*/
|
|
60
|
+
password?: string | null;
|
|
61
|
+
/**
|
|
62
|
+
* The timestamp at which this shared link will expire. This field can only be set by users with paid accounts.
|
|
63
|
+
* The value must be greater than the current date and time.
|
|
64
|
+
* Example value: '2012-12-12T10:53:43-08:00'
|
|
65
|
+
*/
|
|
66
|
+
unshared_at?: string | null;
|
|
67
|
+
/**
|
|
68
|
+
* Defines a custom vanity name to use in the shared link URL, for example vanity_name: "my-shared-link" will
|
|
69
|
+
* produce a shared link of "https://app.box.com/v/my-shared-link".
|
|
70
|
+
*
|
|
71
|
+
* Custom URLs should not be used when sharing sensitive content as vanity URLs are a lot easier to guess
|
|
72
|
+
* than regular shared links.
|
|
73
|
+
*/
|
|
74
|
+
vanity_name?: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Defines what actions are allowed on a shared link.
|
|
77
|
+
*/
|
|
78
|
+
permissions?: FileSharedLinkPermissions;
|
|
79
|
+
};
|
|
31
80
|
/**
|
|
32
81
|
* Simple manager for interacting with all 'File' endpoints and actions.
|
|
33
82
|
*
|
|
@@ -129,6 +178,7 @@ declare class Files {
|
|
|
129
178
|
update(fileID: string, updates: {
|
|
130
179
|
[key: string]: any;
|
|
131
180
|
etag?: string;
|
|
181
|
+
shared_link?: FileSharedLink;
|
|
132
182
|
}, callback?: Function): any;
|
|
133
183
|
/**
|
|
134
184
|
* Add a file to a given collection
|
|
@@ -268,6 +318,7 @@ declare class Files {
|
|
|
268
318
|
* @param {string} [options.content_created_at] - RFC 3339 timestamp when the file was created
|
|
269
319
|
* @param {string} [options.content_modified_at] - RFC 3339 timestamp when the file was last modified
|
|
270
320
|
* @param {int} [options.content_length] - Optional length of the content. Required if content is a read stream of any type other than fs stream.
|
|
321
|
+
* @param {string} [options.description] - Optional description of the uploaded file.
|
|
271
322
|
* @param {Function} [callback] - called with data about the upload if successful, or an error if the
|
|
272
323
|
* upload failed
|
|
273
324
|
* @returns {Promise<Object>} A promise resolving to the uploaded file
|
|
@@ -276,6 +327,7 @@ declare class Files {
|
|
|
276
327
|
content_created_at?: string;
|
|
277
328
|
content_modified_at?: string;
|
|
278
329
|
content_length?: number;
|
|
330
|
+
description?: string;
|
|
279
331
|
} | Function, callback?: Function): any;
|
|
280
332
|
/**
|
|
281
333
|
* Uploads a new version of a file. Unlike non-upload methods, this method will not perform any retries.
|
|
@@ -291,6 +343,7 @@ declare class Files {
|
|
|
291
343
|
* @param {string} [options.content_modified_at] - RFC 3339 timestamp when the file was last modified
|
|
292
344
|
* @param {string} [options.name] - A new name for the file
|
|
293
345
|
* @param {int} [options.content_length] - Optional length of the content. Required if content is a read stream of any type other than fs stream.
|
|
346
|
+
* @param {string} [options.description] - Optional description of the uploaded new file version.
|
|
294
347
|
* @param {Function} [callback] - called with data about the upload if successful, or an error if the
|
|
295
348
|
* upload failed
|
|
296
349
|
* @returns {Promise<Object>} A promise resolving to the uploaded file
|
|
@@ -299,6 +352,7 @@ declare class Files {
|
|
|
299
352
|
content_modified_at?: string;
|
|
300
353
|
name?: string;
|
|
301
354
|
content_length?: number;
|
|
355
|
+
description?: string;
|
|
302
356
|
} | Function, callback?: Function): any;
|
|
303
357
|
/**
|
|
304
358
|
* Retrieves all metadata associated with a file.
|
|
@@ -597,11 +651,13 @@ declare class Files {
|
|
|
597
651
|
* @param {string} fileHash - The base64-encoded SHA-1 hash of the file being uploaded
|
|
598
652
|
* @param {Object} [options] - Optional parameters set on the created file, can be left null
|
|
599
653
|
* @param {UploadPart[]} [options.parts] The list of uploaded parts to be committed, will be fetched from the API otherwise
|
|
654
|
+
* @param {string} [options.description] - Optional description of the uploaded file.
|
|
600
655
|
* @param {Function} [callback] - Passed the new file information if successful
|
|
601
656
|
* @returns {Promise<Object>} A promise resolving to the uploaded file object
|
|
602
657
|
*/
|
|
603
658
|
commitUploadSession(sessionID: string, fileHash: string, options?: {
|
|
604
659
|
parts?: UploadPart[];
|
|
660
|
+
description?: string;
|
|
605
661
|
}, callback?: Function): any;
|
|
606
662
|
/**
|
|
607
663
|
* Abort an upload session, discarding any chunks that were uploaded to it
|