box-node-sdk 1.35.0 → 1.37.2
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/api-request-manager.d.ts +38 -0
- package/lib/api-request-manager.js +48 -55
- package/lib/api-request-manager.js.map +1 -0
- package/lib/api-request.d.ts +141 -0
- package/lib/api-request.js +202 -281
- package/lib/api-request.js.map +1 -0
- package/lib/box-client.d.ts +269 -0
- package/lib/box-client.js +551 -713
- package/lib/box-client.js.map +1 -0
- package/lib/box-node-sdk.d.ts +216 -0
- package/lib/box-node-sdk.js +317 -352
- package/lib/box-node-sdk.js.map +1 -0
- package/lib/chunked-uploader.d.ts +129 -0
- package/lib/chunked-uploader.js +287 -358
- package/lib/chunked-uploader.js.map +1 -0
- package/lib/enterprise-event-stream.d.ts +82 -0
- package/lib/enterprise-event-stream.js +189 -203
- package/lib/enterprise-event-stream.js.map +1 -0
- package/lib/event-stream.d.ts +92 -0
- package/lib/event-stream.js +274 -302
- package/lib/event-stream.js.map +1 -0
- package/lib/managers/collaboration-allowlist.d.ts +137 -0
- package/lib/managers/collaboration-allowlist.js +200 -0
- package/lib/managers/collaboration-allowlist.js.map +1 -0
- package/lib/managers/collaboration-whitelist.d.ts +3 -0
- package/lib/managers/collaboration-whitelist.js +8 -222
- package/lib/managers/collaboration-whitelist.js.map +1 -0
- package/lib/managers/collaborations.d.ts +166 -0
- package/lib/managers/collaborations.js +225 -258
- package/lib/managers/collaborations.js.map +1 -0
- package/lib/managers/collections.d.ts +42 -0
- package/lib/managers/collections.js +45 -50
- package/lib/managers/collections.js.map +1 -0
- package/lib/managers/comments.d.ts +103 -0
- package/lib/managers/comments.js +158 -173
- package/lib/managers/comments.js.map +1 -0
- package/lib/managers/device-pins.d.ts +52 -0
- package/lib/managers/device-pins.js +75 -88
- package/lib/managers/device-pins.js.map +1 -0
- package/lib/managers/enterprise.d.ts +162 -0
- package/lib/managers/enterprise.js +168 -199
- package/lib/managers/enterprise.js.map +1 -0
- package/lib/managers/events.d.ts +177 -0
- package/lib/managers/events.js +230 -254
- package/lib/managers/events.js.map +1 -0
- package/lib/managers/files.d.ts +772 -0
- package/lib/managers/files.js +1400 -1602
- package/lib/managers/files.js.map +1 -0
- package/lib/managers/folders.d.ts +347 -0
- package/lib/managers/folders.js +551 -567
- package/lib/managers/folders.js.map +1 -0
- package/lib/managers/groups.d.ts +202 -0
- package/lib/managers/groups.js +238 -287
- package/lib/managers/groups.js.map +1 -0
- package/lib/managers/legal-hold-policies.d.ts +190 -0
- package/lib/managers/legal-hold-policies.js +228 -272
- package/lib/managers/legal-hold-policies.js.map +1 -0
- package/lib/managers/metadata.d.ts +228 -0
- package/lib/managers/metadata.js +265 -328
- package/lib/managers/metadata.js.map +1 -0
- package/lib/managers/recent-items.d.ts +38 -0
- package/lib/managers/recent-items.js +32 -39
- package/lib/managers/recent-items.js.map +1 -0
- package/lib/managers/retention-policies.d.ts +213 -0
- package/lib/managers/retention-policies.js +235 -281
- package/lib/managers/retention-policies.js.map +1 -0
- package/lib/managers/search.d.ts +82 -0
- package/lib/managers/search.js +68 -88
- package/lib/managers/search.js.map +1 -0
- package/lib/managers/shared-items.d.ts +33 -0
- package/lib/managers/shared-items.js +54 -62
- package/lib/managers/shared-items.js.map +1 -0
- package/lib/managers/storage-policies.d.ts +86 -0
- package/lib/managers/storage-policies.js +108 -142
- package/lib/managers/storage-policies.js.map +1 -0
- package/lib/managers/tasks.d.ts +161 -0
- package/lib/managers/tasks.js +219 -260
- package/lib/managers/tasks.js.map +1 -0
- package/lib/managers/terms-of-service.d.ts +161 -0
- package/lib/managers/terms-of-service.js +250 -273
- package/lib/managers/terms-of-service.js.map +1 -0
- package/lib/managers/trash.d.ts +30 -0
- package/lib/managers/trash.js +30 -41
- package/lib/managers/trash.js.map +1 -0
- package/lib/managers/users.d.ts +131 -0
- package/lib/managers/users.js +160 -203
- package/lib/managers/users.js.map +1 -0
- package/lib/managers/web-links.d.ts +127 -0
- package/lib/managers/web-links.js +183 -209
- package/lib/managers/web-links.js.map +1 -0
- package/lib/managers/webhooks.d.ts +166 -0
- package/lib/managers/webhooks.js +312 -305
- package/lib/managers/webhooks.js.map +1 -0
- package/lib/sessions/anonymous-session.d.ts +69 -0
- package/lib/sessions/anonymous-session.js +88 -102
- package/lib/sessions/anonymous-session.js.map +1 -0
- package/lib/sessions/app-auth-session.d.ts +92 -0
- package/lib/sessions/app-auth-session.js +140 -160
- package/lib/sessions/app-auth-session.js.map +1 -0
- package/lib/sessions/basic-session.d.ts +56 -0
- package/lib/sessions/basic-session.js +40 -50
- package/lib/sessions/basic-session.js.map +1 -0
- package/lib/sessions/persistent-session.d.ts +96 -0
- package/lib/sessions/persistent-session.js +191 -211
- package/lib/sessions/persistent-session.js.map +1 -0
- package/lib/token-manager.d.ts +191 -0
- package/lib/token-manager.js +390 -465
- package/lib/token-manager.js.map +1 -0
- package/lib/util/config.d.ts +86 -0
- package/lib/util/config.js +124 -152
- package/lib/util/config.js.map +1 -0
- package/lib/util/errors.d.ts +50 -0
- package/lib/util/errors.js +134 -145
- package/lib/util/errors.js.map +1 -0
- package/lib/util/exponential-backoff.d.ts +11 -0
- package/lib/util/exponential-backoff.js +10 -22
- package/lib/util/exponential-backoff.js.map +1 -0
- package/lib/util/paging-iterator.d.ts +53 -0
- package/lib/util/paging-iterator.js +202 -218
- package/lib/util/paging-iterator.js.map +1 -0
- package/lib/util/url-path.d.ts +16 -0
- package/lib/util/url-path.js +20 -35
- package/lib/util/url-path.js.map +1 -0
- package/package.json +24 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-manager.js","sourceRoot":"","sources":["../src/token-manager.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,iFAAiF;AACjF,eAAe;AACf,iFAAiF;AAEjF,sDAA+B;AAC/B,4DAA0C;AAC1C,8DAA+B;AAC/B,8CAAwB;AAExB,yDAAmC;AACnC,mFA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AE,OAA6B;QACxD,IAAI,MAAM,GAKN;YACH,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,MAAM;YAC1C,IAAI,EAAE;gBACL,KAAK,OAAA;gBACL,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;gBAC/B,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;aACvC;SACD,CAAC;QAEF,IAAI,OAAO,IAAI,OAAO,CAAC,EAAE,EAAE;YAC1B,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC;SACxC;QAED,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IACF,mBAAC;AAAD,CAAC,AAtaD,IAsaC;AAOD,iBAAS,YAAY,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Configuration Object
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for App Auth
|
|
7
|
+
* @typedef {Object} AppAuthConfig
|
|
8
|
+
* @property {string} keyID The ID of the public key used for app auth
|
|
9
|
+
* @property {string|Buffer} privateKey The private key used for app auth
|
|
10
|
+
* @property {string} passphrase The passphrase associated with the private key
|
|
11
|
+
* @property {string} [algorithm=RS256] The signing algorithm to use, "RS256", "RS384", or "RS512"
|
|
12
|
+
* @property {int} [expirationTime=30] Number of seconds the JWT should live for
|
|
13
|
+
* @property {boolean} [verifyTimestamp=false] Whether the timestamp when the auth token is created should be validated
|
|
14
|
+
*/
|
|
15
|
+
declare type AppAuthConfig = {
|
|
16
|
+
keyID: string;
|
|
17
|
+
privateKey: string | Buffer;
|
|
18
|
+
passphrase: string;
|
|
19
|
+
algorithm: 'RS256' | 'RS384' | 'RS512';
|
|
20
|
+
expirationTime: number;
|
|
21
|
+
verifyTimestamp: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Configuration settings used to initialize and customize the SDK
|
|
25
|
+
*
|
|
26
|
+
* @typedef {Object} UserConfigurationOptions
|
|
27
|
+
* @property {string} clientID Client ID of your Box Application
|
|
28
|
+
* @property {string} clientSecret Client secret of your Box Application
|
|
29
|
+
* @property {string} [apiRootURL] The root URL to Box [Default: 'https://api.box.com']
|
|
30
|
+
* @property {string} [uploadAPIRootURL] The root URL to Box for uploads [Default: 'https://upload.box.com/api']
|
|
31
|
+
* @property {string} [authorizeRootURL] The root URL for the authorization screen [Default: 'https://account.box.com/api']
|
|
32
|
+
* @property {int} [uploadRequestTimeoutMS] Timeout after which an upload request is aborted [Default: 60000]
|
|
33
|
+
* @property {int} [retryIntervalMS] Time between auto-retries of the API call on a temp failure [Default: 2000]
|
|
34
|
+
* @property {int} [numMaxRetries] Max # of times a temporarily-failed request should be retried before propagating a permanent failure [Default: 5]
|
|
35
|
+
* @property {int} [expiredBufferMS] Time before expiration, in milliseconds, when we begin to treat tokens as expired [Default: 3 min.]
|
|
36
|
+
* @property {Object} [request] Request options
|
|
37
|
+
* @property {boolean} [request.strictSSL] Set to false to disable strict SSL checking, which allows using Dev APIs [Default: true]
|
|
38
|
+
* @property {?AppAuthConfig} appAuth Optional configuration for App Auth
|
|
39
|
+
*/
|
|
40
|
+
declare type UserConfigurationOptions = {
|
|
41
|
+
clientID: string;
|
|
42
|
+
clientSecret: string;
|
|
43
|
+
apiRootURL: string;
|
|
44
|
+
uploadAPIRootURL: string;
|
|
45
|
+
authorizeRootURL: string;
|
|
46
|
+
uploadRequestTimeoutMS: number;
|
|
47
|
+
retryIntervalMS: number;
|
|
48
|
+
numMaxRetries: number;
|
|
49
|
+
expiredBufferMS: number;
|
|
50
|
+
request: {
|
|
51
|
+
agentClass: any;
|
|
52
|
+
agentOptions: any;
|
|
53
|
+
strictSSL: boolean;
|
|
54
|
+
};
|
|
55
|
+
appAuth?: AppAuthConfig;
|
|
56
|
+
proxy?: {
|
|
57
|
+
url: string;
|
|
58
|
+
username: string;
|
|
59
|
+
password: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A Config Object holds the configuration options of the current setup. These are all
|
|
64
|
+
* customizable by the user, and will default if no value is specified in the given params
|
|
65
|
+
* object. The object is frozen on initialization, so that no values can be changed after
|
|
66
|
+
* setup.
|
|
67
|
+
*
|
|
68
|
+
* @param {UserConfigurationOptions} params - The config options set by the user
|
|
69
|
+
* @constructor
|
|
70
|
+
*/
|
|
71
|
+
declare class Config {
|
|
72
|
+
_params: Required<UserConfigurationOptions>;
|
|
73
|
+
[key: string]: any;
|
|
74
|
+
constructor(params: UserConfigurationOptions);
|
|
75
|
+
/**
|
|
76
|
+
* Extend the current config into a new config with new params overriding old ones
|
|
77
|
+
* @param {UserConfigurationOptions} params The override options
|
|
78
|
+
* @returns {Config} The extended configuration
|
|
79
|
+
*/
|
|
80
|
+
extend(params: UserConfigurationOptions): Config;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @module box-node-sdk/lib/util/config
|
|
84
|
+
* @see {@Link Config}
|
|
85
|
+
*/
|
|
86
|
+
export = Config;
|
package/lib/util/config.js
CHANGED
|
@@ -1,103 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview Configuration Object
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
var assert = require("assert");
|
|
25
|
+
var https = __importStar(require("https"));
|
|
26
|
+
var url = __importStar(require("url"));
|
|
27
|
+
var ProxyAgent = require("proxy-agent");
|
|
7
28
|
// ------------------------------------------------------------------------------
|
|
8
29
|
// Requirements
|
|
9
30
|
// ------------------------------------------------------------------------------
|
|
10
|
-
var
|
|
11
|
-
https = require('https'),
|
|
12
|
-
merge = require('merge-options'),
|
|
13
|
-
sdkVersion = require('../../package.json').version,
|
|
14
|
-
ProxyAgent = require('proxy-agent'),
|
|
15
|
-
url = require('url');
|
|
16
|
-
|
|
31
|
+
var merge = require('merge-options'), sdkVersion = require('../../package.json').version;
|
|
17
32
|
// ------------------------------------------------------------------------------
|
|
18
33
|
// Private
|
|
19
34
|
// ------------------------------------------------------------------------------
|
|
20
|
-
|
|
21
35
|
var nodeVersion = process.version;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Configuration for App Auth
|
|
25
|
-
* @typedef {Object} AppAuthConfig
|
|
26
|
-
* @property {string} keyID The ID of the public key used for app auth
|
|
27
|
-
* @property {string|Buffer} privateKey The private key used for app auth
|
|
28
|
-
* @property {string} passphrase The passphrase associated with the private key
|
|
29
|
-
* @property {string} [algorithm=RS256] The signing algorithm to use, "RS256", "RS384", or "RS512"
|
|
30
|
-
* @property {int} [expirationTime=30] Number of seconds the JWT should live for
|
|
31
|
-
* @property {boolean} [verifyTimestamp=false] Whether the timestamp when the auth token is created should be validated
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Configuration settings used to initialize and customize the SDK
|
|
36
|
-
*
|
|
37
|
-
* @typedef {Object} UserConfigurationOptions
|
|
38
|
-
* @property {string} clientID Client ID of your Box Application
|
|
39
|
-
* @property {string} clientSecret Client secret of your Box Application
|
|
40
|
-
* @property {string} [apiRootURL] The root URL to Box [Default: 'https://api.box.com']
|
|
41
|
-
* @property {string} [uploadAPIRootURL] The root URL to Box for uploads [Default: 'https://upload.box.com/api']
|
|
42
|
-
* @property {string} [authorizeRootURL] The root URL for the authorization screen [Default: 'https://account.box.com/api']
|
|
43
|
-
* @property {int} [uploadRequestTimeoutMS] Timeout after which an upload request is aborted [Default: 60000]
|
|
44
|
-
* @property {int} [retryIntervalMS] Time between auto-retries of the API call on a temp failure [Default: 2000]
|
|
45
|
-
* @property {int} [numMaxRetries] Max # of times a temporarily-failed request should be retried before propagating a permanent failure [Default: 5]
|
|
46
|
-
* @property {int} [expiredBufferMS] Time before expiration, in milliseconds, when we begin to treat tokens as expired [Default: 3 min.]
|
|
47
|
-
* @property {Object} [request] Request options
|
|
48
|
-
* @property {boolean} [request.strictSSL] Set to false to disable strict SSL checking, which allows using Dev APIs [Default: true]
|
|
49
|
-
* @property {?AppAuthConfig} appAuth Optional configuration for App Auth
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
36
|
var defaults = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
37
|
+
clientID: null,
|
|
38
|
+
clientSecret: null,
|
|
39
|
+
apiRootURL: 'https://api.box.com',
|
|
40
|
+
uploadAPIRootURL: 'https://upload.box.com/api',
|
|
41
|
+
authorizeRootURL: 'https://account.box.com/api',
|
|
42
|
+
apiVersion: '2.0',
|
|
43
|
+
uploadRequestTimeoutMS: 60000,
|
|
44
|
+
retryIntervalMS: 2000,
|
|
45
|
+
numMaxRetries: 5,
|
|
46
|
+
retryStrategy: null,
|
|
47
|
+
expiredBufferMS: 180000,
|
|
48
|
+
staleBufferMS: 0,
|
|
49
|
+
appAuth: undefined,
|
|
50
|
+
iterators: false,
|
|
51
|
+
enterpriseID: undefined,
|
|
52
|
+
analyticsClient: null,
|
|
53
|
+
proxy: {
|
|
54
|
+
url: null,
|
|
55
|
+
username: null,
|
|
56
|
+
password: null,
|
|
57
|
+
},
|
|
58
|
+
request: {
|
|
59
|
+
// By default, require API SSL cert to be valid
|
|
60
|
+
strictSSL: true,
|
|
61
|
+
// Use an agent with keep-alive enabled to avoid performing SSL handshake per connection
|
|
62
|
+
agentClass: https.Agent,
|
|
63
|
+
agentOptions: {
|
|
64
|
+
keepAlive: true,
|
|
65
|
+
},
|
|
66
|
+
// Encode requests as JSON. Encode the response as well if JSON is returned.
|
|
67
|
+
json: true,
|
|
68
|
+
// Do not encode the response as a string, since the response could be a file. return Buffers instead.
|
|
69
|
+
encoding: null,
|
|
70
|
+
// A redirect is usually information we want to handle, so don't automatically follow
|
|
71
|
+
followRedirect: false,
|
|
72
|
+
// By default, we attach a version-specific user-agent string to SDK requests
|
|
73
|
+
headers: {
|
|
74
|
+
'User-Agent': "Box Node.js SDK v" + sdkVersion + " (Node " + nodeVersion + ")",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
93
77
|
};
|
|
94
|
-
|
|
95
78
|
var appAuthDefaults = {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
79
|
+
algorithm: 'RS256',
|
|
80
|
+
expirationTime: 30,
|
|
81
|
+
verifyTimestamp: false,
|
|
99
82
|
};
|
|
100
|
-
|
|
101
83
|
/**
|
|
102
84
|
* Validate the basic Config values needed for the SDK to function
|
|
103
85
|
* @param {UserConfigurationOptions} params The user-supplied config values
|
|
@@ -106,11 +88,10 @@ var appAuthDefaults = {
|
|
|
106
88
|
* @private
|
|
107
89
|
*/
|
|
108
90
|
function validateBasicParams(params) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
91
|
+
// Assert that the given params valid, and that required values are present
|
|
92
|
+
assert(typeof params.clientID === 'string', '"clientID" must be set via init() before using the SDK.');
|
|
93
|
+
assert(typeof params.clientSecret === 'string', '"clientSecret" must be set via init() before using the SDK.');
|
|
112
94
|
}
|
|
113
|
-
|
|
114
95
|
/**
|
|
115
96
|
* Validate app auth-specific Config values
|
|
116
97
|
* @param {Object} appAuth The user-supplied app auth values
|
|
@@ -119,24 +100,20 @@ function validateBasicParams(params) {
|
|
|
119
100
|
* @private
|
|
120
101
|
*/
|
|
121
102
|
function validateAppAuthParams(appAuth) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (typeof appAuth.expirationTime !== 'undefined') {
|
|
136
|
-
assert(Number.isInteger(appAuth.expirationTime) && appAuth.expirationTime > 0 && appAuth.expirationTime <= 60, 'Valid token expiration time (0 - 60) must be provided in app auth params');
|
|
137
|
-
}
|
|
103
|
+
assert(typeof appAuth.keyID === 'string', 'Key ID must be provided in app auth params');
|
|
104
|
+
assert(typeof appAuth.privateKey === 'string' ||
|
|
105
|
+
appAuth.privateKey instanceof Buffer, 'Private key must be provided in app auth params');
|
|
106
|
+
assert(typeof appAuth.passphrase === 'string' && appAuth.passphrase.length > 0, 'Passphrase must be provided in app auth params');
|
|
107
|
+
var validAlgorithms = ['RS256', 'RS384', 'RS512'];
|
|
108
|
+
if (typeof appAuth.algorithm !== 'undefined') {
|
|
109
|
+
assert(validAlgorithms.indexOf(appAuth.algorithm) > -1, "Algorithm in app auth params must be one of: " + validAlgorithms.join(', '));
|
|
110
|
+
}
|
|
111
|
+
if (typeof appAuth.expirationTime !== 'undefined') {
|
|
112
|
+
assert(Number.isInteger(appAuth.expirationTime) &&
|
|
113
|
+
appAuth.expirationTime > 0 &&
|
|
114
|
+
appAuth.expirationTime <= 60, 'Valid token expiration time (0 - 60) must be provided in app auth params');
|
|
115
|
+
}
|
|
138
116
|
}
|
|
139
|
-
|
|
140
117
|
/**
|
|
141
118
|
* Update the agentClass based on the proxy config values passed in by the user
|
|
142
119
|
* @param {UserConfigurationOptions} params The current Config values
|
|
@@ -144,19 +121,19 @@ function validateAppAuthParams(appAuth) {
|
|
|
144
121
|
* @private
|
|
145
122
|
*/
|
|
146
123
|
function updateRequestAgent(params) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
124
|
+
if (params.proxy.url) {
|
|
125
|
+
params.request.agentClass = ProxyAgent;
|
|
126
|
+
params.request.agentOptions = Object.assign({}, params.request.agentOptions, url.parse(params.proxy.url));
|
|
127
|
+
if (params.proxy.username && params.proxy.password) {
|
|
128
|
+
Object.assign(params.request.agentOptions, {
|
|
129
|
+
auth: params.proxy.username + ":" + params.proxy.password,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
154
133
|
}
|
|
155
|
-
|
|
156
134
|
// ------------------------------------------------------------------------------
|
|
157
135
|
// Public
|
|
158
136
|
// ------------------------------------------------------------------------------
|
|
159
|
-
|
|
160
137
|
/**
|
|
161
138
|
* A Config Object holds the configuration options of the current setup. These are all
|
|
162
139
|
* customizable by the user, and will default if no value is specified in the given params
|
|
@@ -166,40 +143,35 @@ function updateRequestAgent(params) {
|
|
|
166
143
|
* @param {UserConfigurationOptions} params - The config options set by the user
|
|
167
144
|
* @constructor
|
|
168
145
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* @module box-node-sdk/lib/util/config
|
|
203
|
-
* @see {@Link Config}
|
|
204
|
-
*/
|
|
146
|
+
var Config = /** @class */ (function () {
|
|
147
|
+
function Config(params) {
|
|
148
|
+
validateBasicParams(params);
|
|
149
|
+
if (typeof params.appAuth === 'object') {
|
|
150
|
+
validateAppAuthParams(params.appAuth);
|
|
151
|
+
params.appAuth = merge({}, appAuthDefaults, params.appAuth);
|
|
152
|
+
}
|
|
153
|
+
// Ensure that we don't accidentally assign over Config methods
|
|
154
|
+
assert(!params.hasOwnProperty('extend'), 'Config params may not override Config methods');
|
|
155
|
+
assert(!params.hasOwnProperty('_params'), 'Config params may not override Config methods');
|
|
156
|
+
// Set the given params or default value if params property is missing
|
|
157
|
+
this._params = merge(defaults, params);
|
|
158
|
+
updateRequestAgent(this._params);
|
|
159
|
+
Object.assign(this, this._params);
|
|
160
|
+
// Freeze the object so that configuration options cannot be modified
|
|
161
|
+
Object.freeze(this);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Extend the current config into a new config with new params overriding old ones
|
|
165
|
+
* @param {UserConfigurationOptions} params The override options
|
|
166
|
+
* @returns {Config} The extended configuration
|
|
167
|
+
*/
|
|
168
|
+
Config.prototype.extend = function (params) {
|
|
169
|
+
var newParams = merge({}, this._params, params);
|
|
170
|
+
delete newParams.extend;
|
|
171
|
+
delete newParams._params;
|
|
172
|
+
return new Config(newParams);
|
|
173
|
+
};
|
|
174
|
+
return Config;
|
|
175
|
+
}());
|
|
205
176
|
module.exports = Config;
|
|
177
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/util/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;AAEH,+BAAkC;AAClC,2CAA+B;AAC/B,uCAA2B;AAC3B,wCAA2C;AAE3C,iFAAiF;AACjF,eAAe;AACf,iFAAiF;AACjF,IAAM,KAAK,GAAG,OAAO,CAAC,eAAe,CAAC,EACrC,UAAU,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;AAEpD,iFAAiF;AACjF,UAAU;AACV,iFAAiF;AAEjF,IAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;AA6DpC,IAAI,QAAQ,GAAG;IACd,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,IAAI;IAClB,UAAU,EAAE,qBAAqB;IACjC,gBAAgB,EAAE,4BAA4B;IAC9C,gBAAgB,EAAE,6BAA6B;IAC/C,UAAU,EAAE,KAAK;IACjB,sBAAsB,EAAE,KAAK;IAC7B,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,IAAI;IACnB,eAAe,EAAE,MAAM;IACvB,aAAa,EAAE,CAAC;IAChB,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,KAAK;IAChB,YAAY,EAAE,SAAS;IACvB,eAAe,EAAE,IAAI;IACrB,KA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OAAO,KAAK,QAAQ,EAAE;YACvC,qBAAqB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACtC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE,EAAE,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;SAC5D;QAED,+DAA+D;QAC/D,MAAM,CACL,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAChC,+CAA+C,CAC/C,CAAC;QACF,MAAM,CACL,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EACjC,+CAA+C,CAC/C,CAAC;QAEF,sEAAsE;QACtE,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACvC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,qEAAqE;QACrE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,uBAAM,GAAN,UAAO,MAAgC;QACtC,IAAI,SAAS,GAAG,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAChD,OAAO,SAAS,CAAC,MAAM,CAAC;QACxB,OAAO,SAAS,CAAC,OAAO,CAAC;QACzB,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;IACF,aAAC;AAAD,CAAC,AAxCD,IAwCC;AAMD,iBAAS,MAAM,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Errors Helper
|
|
3
|
+
*/
|
|
4
|
+
declare const _default: {
|
|
5
|
+
/**
|
|
6
|
+
* Build a response error with the given message, and attaching meta data from the
|
|
7
|
+
* response data.
|
|
8
|
+
*
|
|
9
|
+
* @param {?APIRequest~ResponseObject} response - The response returned by an APIRequestManager request
|
|
10
|
+
* @param {string} message - the response error message
|
|
11
|
+
* @returns {Errors~ResponseError} an error describing the response error
|
|
12
|
+
*/
|
|
13
|
+
buildResponseError(response: any, message?: string | undefined): any;
|
|
14
|
+
/**
|
|
15
|
+
* Build an authentication error. {@see Errors~AuthError}
|
|
16
|
+
*
|
|
17
|
+
* @param {?APIRequest~ResponseObject} response - The response returned by an APIRequestManager request
|
|
18
|
+
* @param {string} [message] - Optional message for the error
|
|
19
|
+
* @returns {Errors~AuthError} A properly formatted authentication error
|
|
20
|
+
*/
|
|
21
|
+
buildAuthError(response: any, message?: string | undefined): any;
|
|
22
|
+
/**
|
|
23
|
+
* Build the error for an "Unexpected Response" from the API. This is a shortcut for
|
|
24
|
+
* responseError built specifically for the 401 UNEXPECTED response case. It
|
|
25
|
+
* should be called and the error should be propogated to the consumer
|
|
26
|
+
* whenever an unexpected response was recieved from the API.
|
|
27
|
+
*
|
|
28
|
+
* @param {?APIRequest~ResponseObject} response - The response returned by an APIRequestManager request
|
|
29
|
+
* @returns {Errors~ResponseError} an error describing the response error
|
|
30
|
+
*/
|
|
31
|
+
buildUnexpectedResponseError(response: any): any;
|
|
32
|
+
/**
|
|
33
|
+
* Unwrap a Bluebird error and throw it, or just re-throw if the error
|
|
34
|
+
* is not a Bluebird error. This is necessary to preserve errors when
|
|
35
|
+
* a function is promisified.
|
|
36
|
+
* @param {Error} error The error to unwrap
|
|
37
|
+
* @returns {void}
|
|
38
|
+
* @throws {Error} The unwrapped error
|
|
39
|
+
*/
|
|
40
|
+
unwrapAndThrow(error: any): never;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A Helper for building errors across the SDK. Makes sure that easily-forgotten
|
|
44
|
+
* fields aren't missed, and that everything is formatted properly to return to the
|
|
45
|
+
* consumer.
|
|
46
|
+
*
|
|
47
|
+
* @name Errors
|
|
48
|
+
* @module box-node-sdk/lib/util/errors
|
|
49
|
+
*/
|
|
50
|
+
export = _default;
|