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":"webhooks.js","sourceRoot":"","sources":["../../src/managers/webhooks.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF,8DAAuC;AACvC,kDAA4B;AAG5B,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAEhF;;;G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CAAC,sBAAsB;QACnD,QAAQ,EAAE,kBAAkB,CAAC,sBAAsB;QACnD,OAAO,EAAE,kBAAkB,CAAC,qBAAqB;QACjD,OAAO,EAAE,kBAAkB,CAAC,qBAAqB;KACjD;IACD,WAAW,EAAE;QACZ,OAAO,EAAE,kBAAkB,CAAC,mBAAmB;QAC/C,OAAO,EAAE,kBAAkB,CAAC,mBAAmB;QAC/C,OAAO,EAAE,kBAAkB,CAAC,mBAAmB;KAC/C;CACD,CAAC;AAEF,QAAQ,CAAC,SAAS,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;AAM9D,iBAAS,QAAQ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview An Anonymous Box API Session.
|
|
3
|
+
*/
|
|
4
|
+
declare type Config = any;
|
|
5
|
+
declare type TokenManager = any;
|
|
6
|
+
declare type TokenInfo = any;
|
|
7
|
+
declare type TokenRequestOptions = any;
|
|
8
|
+
/**
|
|
9
|
+
* An Anonymous Box API Session.
|
|
10
|
+
*
|
|
11
|
+
* The Anonymous API Session holds a Client Credentials accessToken, which it
|
|
12
|
+
* returns to the client so that it may make calls on behalf of anonymous users.
|
|
13
|
+
*
|
|
14
|
+
* Anonymous tokens will be refreshed in the background if a request is made within the
|
|
15
|
+
* "stale buffer" (defaults to 10 minutes before the token is set to expire).
|
|
16
|
+
* If the token is also expired, all incoming requests will be held until a fresh token
|
|
17
|
+
* is retrieved.
|
|
18
|
+
*
|
|
19
|
+
* @param {Config} config The SDK configuration options
|
|
20
|
+
* @param {TokenManager} tokenManager The TokenManager
|
|
21
|
+
* @constructor
|
|
22
|
+
*/
|
|
23
|
+
declare class AnonymousSession {
|
|
24
|
+
_config: Config;
|
|
25
|
+
_tokenManager: TokenManager;
|
|
26
|
+
_tokenInfo: TokenInfo;
|
|
27
|
+
_refreshPromise: Promise<any> | null;
|
|
28
|
+
constructor(config: Config, tokenManager: TokenManager);
|
|
29
|
+
/**
|
|
30
|
+
* Initiate a refresh of the anonymous access tokens. New tokens should be passed to the
|
|
31
|
+
* caller, and then cached for later use.
|
|
32
|
+
*
|
|
33
|
+
* @param {?TokenRequestOptions} [options] - Sets optional behavior for the token grant
|
|
34
|
+
* @returns {Promise<string>} Promise resolving to the access token
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
_refreshAnonymousAccessToken(options?: TokenRequestOptions): Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* Produces a valid, anonymous access token.
|
|
40
|
+
* Performs a refresh before returning if the current token is expired. If the current
|
|
41
|
+
* token is considered stale but still valid, return the current token but initiate a
|
|
42
|
+
* new refresh in the background.
|
|
43
|
+
*
|
|
44
|
+
* @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
|
|
45
|
+
* @returns {Promise<string>} Promise resolving to the access token
|
|
46
|
+
*/
|
|
47
|
+
getAccessToken(options?: TokenRequestOptions): Promise<any>;
|
|
48
|
+
/**
|
|
49
|
+
* Revokes the anonymous token used by this anonymous session, and clears the saved tokenInfo.
|
|
50
|
+
*
|
|
51
|
+
* @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
|
|
52
|
+
* @returns {Promise} Promise resolving if the revoke succeeds
|
|
53
|
+
*/
|
|
54
|
+
revokeTokens(options?: TokenRequestOptions): any;
|
|
55
|
+
/**
|
|
56
|
+
* Return the anonymous session token, since there is no need to downscope a
|
|
57
|
+
* token that does not have any associated user credentials.
|
|
58
|
+
* @param {string|string[]} scopes The scope(s) requested for the new token
|
|
59
|
+
* @param {string} [resource] The absolute URL of an API resource to scope the new token to
|
|
60
|
+
* @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
|
|
61
|
+
* @returns {Promise<TokenInfo>} Promise resolving to the new token info
|
|
62
|
+
*/
|
|
63
|
+
exchangeToken(scopes: string | string[], resource?: string, options?: TokenRequestOptions): Promise<any>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @module box-node-sdk/lib/sessions/anonymous-session
|
|
67
|
+
* @see {@Link AnonymousSession}
|
|
68
|
+
*/
|
|
69
|
+
export = AnonymousSession;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview An Anonymous Box API Session.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
'use strict';
|
|
6
|
-
|
|
7
5
|
// ------------------------------------------------------------------------------
|
|
8
6
|
// Requirements
|
|
9
7
|
// ------------------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
const Promise = require('bluebird');
|
|
12
|
-
|
|
8
|
+
var bluebird_1 = require("bluebird");
|
|
13
9
|
// ------------------------------------------------------------------------------
|
|
14
10
|
// Private
|
|
15
11
|
// ------------------------------------------------------------------------------
|
|
16
|
-
|
|
17
12
|
// ------------------------------------------------------------------------------
|
|
18
13
|
// Public
|
|
19
14
|
// ------------------------------------------------------------------------------
|
|
20
|
-
|
|
21
15
|
/**
|
|
22
16
|
* An Anonymous Box API Session.
|
|
23
17
|
*
|
|
@@ -33,98 +27,90 @@ const Promise = require('bluebird');
|
|
|
33
27
|
* @param {TokenManager} tokenManager The TokenManager
|
|
34
28
|
* @constructor
|
|
35
29
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// Pass back the entire token info object, not just the acces token,
|
|
122
|
-
// to maintain parity with the other session classes
|
|
123
|
-
.then(() => this._tokenInfo);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @module box-node-sdk/lib/sessions/anonymous-session
|
|
128
|
-
* @see {@Link AnonymousSession}
|
|
129
|
-
*/
|
|
30
|
+
var AnonymousSession = /** @class */ (function () {
|
|
31
|
+
function AnonymousSession(config, tokenManager) {
|
|
32
|
+
this._config = config;
|
|
33
|
+
this._tokenManager = tokenManager;
|
|
34
|
+
// The TokenInfo object for this anonymous session
|
|
35
|
+
this._tokenInfo = null;
|
|
36
|
+
this._refreshPromise = null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Initiate a refresh of the anonymous access tokens. New tokens should be passed to the
|
|
40
|
+
* caller, and then cached for later use.
|
|
41
|
+
*
|
|
42
|
+
* @param {?TokenRequestOptions} [options] - Sets optional behavior for the token grant
|
|
43
|
+
* @returns {Promise<string>} Promise resolving to the access token
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
AnonymousSession.prototype._refreshAnonymousAccessToken = function (options) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
// If tokens aren't already being refreshed, start the refresh
|
|
49
|
+
if (!this._refreshPromise) {
|
|
50
|
+
// Initiate a refresh
|
|
51
|
+
this._refreshPromise = this._tokenManager
|
|
52
|
+
.getTokensClientCredentialsGrant(options)
|
|
53
|
+
.then(function (tokenInfo) {
|
|
54
|
+
// Set new token info and propagate the new access token
|
|
55
|
+
_this._tokenInfo = tokenInfo;
|
|
56
|
+
return tokenInfo.accessToken;
|
|
57
|
+
})
|
|
58
|
+
.finally(function () {
|
|
59
|
+
// Refresh complete, clear promise
|
|
60
|
+
_this._refreshPromise = null;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return this._refreshPromise;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Produces a valid, anonymous access token.
|
|
67
|
+
* Performs a refresh before returning if the current token is expired. If the current
|
|
68
|
+
* token is considered stale but still valid, return the current token but initiate a
|
|
69
|
+
* new refresh in the background.
|
|
70
|
+
*
|
|
71
|
+
* @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
|
|
72
|
+
* @returns {Promise<string>} Promise resolving to the access token
|
|
73
|
+
*/
|
|
74
|
+
AnonymousSession.prototype.getAccessToken = function (options) {
|
|
75
|
+
// If the current token is no longer fresh, get a new token. All incoming
|
|
76
|
+
// requests will be held until a fresh token is retrieved.
|
|
77
|
+
var expirationBuffer = Math.max(this._config.expiredBufferMS, this._config.staleBufferMS);
|
|
78
|
+
if (!this._tokenInfo ||
|
|
79
|
+
!this._tokenManager.isAccessTokenValid(this._tokenInfo, expirationBuffer)) {
|
|
80
|
+
return this._refreshAnonymousAccessToken(options);
|
|
81
|
+
}
|
|
82
|
+
// Your token is not currently stale! Return the current access token.
|
|
83
|
+
return bluebird_1.Promise.resolve(this._tokenInfo.accessToken);
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Revokes the anonymous token used by this anonymous session, and clears the saved tokenInfo.
|
|
87
|
+
*
|
|
88
|
+
* @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
|
|
89
|
+
* @returns {Promise} Promise resolving if the revoke succeeds
|
|
90
|
+
*/
|
|
91
|
+
AnonymousSession.prototype.revokeTokens = function (options) {
|
|
92
|
+
// The current anonymous token is revoked (but a new one will be created automatically as needed).
|
|
93
|
+
var tokenInfo = this._tokenInfo || {}, accessToken = tokenInfo.accessToken;
|
|
94
|
+
this._tokenInfo = null;
|
|
95
|
+
return this._tokenManager.revokeTokens(accessToken, options);
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Return the anonymous session token, since there is no need to downscope a
|
|
99
|
+
* token that does not have any associated user credentials.
|
|
100
|
+
* @param {string|string[]} scopes The scope(s) requested for the new token
|
|
101
|
+
* @param {string} [resource] The absolute URL of an API resource to scope the new token to
|
|
102
|
+
* @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
|
|
103
|
+
* @returns {Promise<TokenInfo>} Promise resolving to the new token info
|
|
104
|
+
*/
|
|
105
|
+
AnonymousSession.prototype.exchangeToken = function (scopes, resource, options) {
|
|
106
|
+
var _this = this;
|
|
107
|
+
// We need to get the access token, in case it hasn't been generated yet
|
|
108
|
+
return (this.getAccessToken(options)
|
|
109
|
+
// Pass back the entire token info object, not just the acces token,
|
|
110
|
+
// to maintain parity with the other session classes
|
|
111
|
+
.then(function () { return _this._tokenInfo; }));
|
|
112
|
+
};
|
|
113
|
+
return AnonymousSession;
|
|
114
|
+
}());
|
|
130
115
|
module.exports = AnonymousSession;
|
|
116
|
+
//# sourceMappingURL=anonymous-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anonymous-session.js","sourceRoot":"","sources":["../../src/sessions/anonymous-session.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH,iFAAiF;AACjF,eAAe;AACf,iFAAiF;AAEjF,qCAAmC;AAWnC,iFAAiF;AACjF,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AC,OAAO,CAAC,CAAC;SAClD;QAED,sEAAsE;QACtE,OAAO,kBAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACH,uCAAY,GAAZ,UAAa,OAA6B;QACzC,kGAAkG;QAClG,IAAI,SAAS,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,EACpC,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;OAOG;IACH,wCAAa,GAAb,UACC,MAAyB,EACzB,QAAiB,EACjB,OAA6B;QAH9B,iBAYC;QAPA,wEAAwE;QACxE,OAAO,CACN,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YAC3B,oEAAoE;YACpE,oDAAoD;aACnD,IAAI,CAAC,cAAM,OAAA,KAAI,CAAC,UAAU,EAAf,CAAe,CAAC,CAC7B,CAAC;IACH,CAAC;IACF,uBAAC;AAAD,CAAC,AA1GD,IA0GC;AAMD,iBAAS,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview App Auth Box API Session.
|
|
3
|
+
*/
|
|
4
|
+
declare type Config = any;
|
|
5
|
+
declare type TokenManager = any;
|
|
6
|
+
declare type TokenStore = any;
|
|
7
|
+
declare type TokenInfo = any;
|
|
8
|
+
declare type TokenRequestOptions = any;
|
|
9
|
+
/**
|
|
10
|
+
* App Auth Box API Session.
|
|
11
|
+
*
|
|
12
|
+
* The App Auth API Session holds an accessToken for an app user or enterprise,
|
|
13
|
+
* which it returns to the client so that it may make calls on behalf of
|
|
14
|
+
* these entities.
|
|
15
|
+
*
|
|
16
|
+
* These access tokens will be refreshed in the background if a request is made within the
|
|
17
|
+
* "stale buffer" (defaults to 10 minutes before the token is set to expire).
|
|
18
|
+
* If the token is also expired, all incoming requests will be held until a fresh token
|
|
19
|
+
* is retrieved.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} type The type of the entity to authenticate the app auth session as, "user" or "enterprise"
|
|
22
|
+
* @param {string} id The Box ID of the entity to authenticate as
|
|
23
|
+
* @param {Config} config The SDK configuration options
|
|
24
|
+
* @param {TokenManager} tokenManager The TokenManager
|
|
25
|
+
* @param {TokenStore} [tokenStore] The token store instance to use for caching token info
|
|
26
|
+
* @constructor
|
|
27
|
+
*/
|
|
28
|
+
declare class AppAuthSession {
|
|
29
|
+
_type: string;
|
|
30
|
+
_id: string;
|
|
31
|
+
_config: Config;
|
|
32
|
+
_tokenManager: TokenManager;
|
|
33
|
+
_tokenStore: TokenStore | null;
|
|
34
|
+
_tokenInfo: TokenInfo;
|
|
35
|
+
_refreshPromise: Promise<any> | null;
|
|
36
|
+
constructor(type: string, id: string, config: Config, tokenManager: TokenManager, tokenStore?: TokenStore);
|
|
37
|
+
/**
|
|
38
|
+
* Initiate a refresh of the app auth access tokens. New tokens should be passed
|
|
39
|
+
* to the caller, and then cached for later use.
|
|
40
|
+
*
|
|
41
|
+
* @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
|
|
42
|
+
* @returns {Promise<string>} Promise resolving to the access token
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
_refreshAppAuthAccessToken(options?: TokenRequestOptions): Promise<any> | null;
|
|
46
|
+
/**
|
|
47
|
+
* Produces a valid, app auth access token.
|
|
48
|
+
* Performs a refresh before returning if the current token is expired. If the current
|
|
49
|
+
* token is considered stale but still valid, return the current token but initiate a
|
|
50
|
+
* new refresh in the background.
|
|
51
|
+
*
|
|
52
|
+
* @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
|
|
53
|
+
* @returns {Promise<string>} Promise resolving to the access token
|
|
54
|
+
*/
|
|
55
|
+
getAccessToken(options?: TokenRequestOptions): any;
|
|
56
|
+
/**
|
|
57
|
+
* Revokes the app auth token used by this session, and clears the saved tokenInfo.
|
|
58
|
+
*
|
|
59
|
+
* @param {TokenRequestOptions} [options]- Sets optional behavior for the token grant
|
|
60
|
+
* @returns {Promise} Promise resolving if the revoke succeeds
|
|
61
|
+
*/
|
|
62
|
+
revokeTokens(options: TokenRequestOptions): any;
|
|
63
|
+
/**
|
|
64
|
+
* Exchange the client access token for one with lower scope
|
|
65
|
+
* @param {string|string[]} scopes The scope(s) requested for the new token
|
|
66
|
+
* @param {string} [resource] The absolute URL of an API resource to scope the new token to
|
|
67
|
+
* @param {Object} [options] - Optional parameters
|
|
68
|
+
* @param {TokenRequestOptions} [options.tokenRequestOptions] - Sets optional behavior for the token grant
|
|
69
|
+
* @param {ActorParams} [options.actor] - Optional actor parameters for creating annotator tokens
|
|
70
|
+
* @returns {Promise<TokenInfo>} Promise resolving to the new token info
|
|
71
|
+
*/
|
|
72
|
+
exchangeToken(scopes: string | string[], resource?: string, options?: {
|
|
73
|
+
tokenRequestOptions?: TokenRequestOptions;
|
|
74
|
+
actor?: any;
|
|
75
|
+
}): any;
|
|
76
|
+
/**
|
|
77
|
+
* Handle an an "Expired Tokens" Error. If our tokens are expired, we need to clear the token
|
|
78
|
+
* store (if present) before continuing.
|
|
79
|
+
*
|
|
80
|
+
* @param {Errors~ExpiredTokensError} err An "expired tokens" error including information
|
|
81
|
+
* about the request/response.
|
|
82
|
+
* @returns {Promise<Error>} Promise resolving to an error. This will
|
|
83
|
+
* usually be the original response error, but could an error from trying to access the
|
|
84
|
+
* token store as well.
|
|
85
|
+
*/
|
|
86
|
+
handleExpiredTokensError(err: any): any;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @module box-node-sdk/lib/sessions/app-auth-session
|
|
90
|
+
* @see {@Link AppAuthSession}
|
|
91
|
+
*/
|
|
92
|
+
export = AppAuthSession;
|