@webex/webex-core 3.0.0-beta.15 → 3.0.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.js +1 -11
- package/dist/config.js.map +1 -1
- package/dist/credentials-config.js +0 -20
- package/dist/credentials-config.js.map +1 -1
- package/dist/index.js +0 -76
- package/dist/index.js.map +1 -1
- package/dist/interceptors/auth.js +22 -55
- package/dist/interceptors/auth.js.map +1 -1
- package/dist/interceptors/default-options.js +0 -20
- package/dist/interceptors/default-options.js.map +1 -1
- package/dist/interceptors/embargo.js +0 -21
- package/dist/interceptors/embargo.js.map +1 -1
- package/dist/interceptors/network-timing.js +2 -21
- package/dist/interceptors/network-timing.js.map +1 -1
- package/dist/interceptors/payload-transformer.js +2 -22
- package/dist/interceptors/payload-transformer.js.map +1 -1
- package/dist/interceptors/rate-limit.js +21 -53
- package/dist/interceptors/rate-limit.js.map +1 -1
- package/dist/interceptors/redirect.js +4 -33
- package/dist/interceptors/redirect.js.map +1 -1
- package/dist/interceptors/request-event.js +3 -30
- package/dist/interceptors/request-event.js.map +1 -1
- package/dist/interceptors/request-logger.js +1 -30
- package/dist/interceptors/request-logger.js.map +1 -1
- package/dist/interceptors/request-timing.js +3 -22
- package/dist/interceptors/request-timing.js.map +1 -1
- package/dist/interceptors/response-logger.js +2 -31
- package/dist/interceptors/response-logger.js.map +1 -1
- package/dist/interceptors/user-agent.js +2 -29
- package/dist/interceptors/user-agent.js.map +1 -1
- package/dist/interceptors/webex-tracking-id.js +5 -28
- package/dist/interceptors/webex-tracking-id.js.map +1 -1
- package/dist/interceptors/webex-user-agent.js +5 -38
- package/dist/interceptors/webex-user-agent.js.map +1 -1
- package/dist/lib/batcher.js +3 -51
- package/dist/lib/batcher.js.map +1 -1
- package/dist/lib/credentials/credentials.js +28 -123
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/grant-errors.js +0 -49
- package/dist/lib/credentials/grant-errors.js.map +1 -1
- package/dist/lib/credentials/index.js +1 -13
- package/dist/lib/credentials/index.js.map +1 -1
- package/dist/lib/credentials/scope.js +1 -7
- package/dist/lib/credentials/scope.js.map +1 -1
- package/dist/lib/credentials/token-collection.js +1 -7
- package/dist/lib/credentials/token-collection.js.map +1 -1
- package/dist/lib/credentials/token.js +29 -122
- package/dist/lib/credentials/token.js.map +1 -1
- package/dist/lib/page.js +12 -27
- package/dist/lib/page.js.map +1 -1
- package/dist/lib/services/constants.js +0 -2
- package/dist/lib/services/constants.js.map +1 -1
- package/dist/lib/services/index.js +1 -28
- package/dist/lib/services/index.js.map +1 -1
- package/dist/lib/services/interceptors/server-error.js +0 -21
- package/dist/lib/services/interceptors/server-error.js.map +1 -1
- package/dist/lib/services/interceptors/service.js +11 -33
- package/dist/lib/services/interceptors/service.js.map +1 -1
- package/dist/lib/services/metrics.js +0 -2
- package/dist/lib/services/metrics.js.map +1 -1
- package/dist/lib/services/service-catalog.js +10 -90
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/service-fed-ramp.js +0 -2
- package/dist/lib/services/service-fed-ramp.js.map +1 -1
- package/dist/lib/services/service-host.js +41 -56
- package/dist/lib/services/service-host.js.map +1 -1
- package/dist/lib/services/service-registry.js +78 -90
- package/dist/lib/services/service-registry.js.map +1 -1
- package/dist/lib/services/service-state.js +3 -15
- package/dist/lib/services/service-state.js.map +1 -1
- package/dist/lib/services/service-url.js +4 -25
- package/dist/lib/services/service-url.js.map +1 -1
- package/dist/lib/services/services.js +116 -234
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/stateless-webex-plugin.js +5 -28
- package/dist/lib/stateless-webex-plugin.js.map +1 -1
- package/dist/lib/storage/decorators.js +19 -62
- package/dist/lib/storage/decorators.js.map +1 -1
- package/dist/lib/storage/errors.js +0 -23
- package/dist/lib/storage/errors.js.map +1 -1
- package/dist/lib/storage/index.js +0 -14
- package/dist/lib/storage/index.js.map +1 -1
- package/dist/lib/storage/make-webex-plugin-store.js +11 -41
- package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
- package/dist/lib/storage/make-webex-store.js +8 -30
- package/dist/lib/storage/make-webex-store.js.map +1 -1
- package/dist/lib/storage/memory-store-adapter.js +1 -19
- package/dist/lib/storage/memory-store-adapter.js.map +1 -1
- package/dist/lib/webex-core-plugin-mixin.js +9 -29
- package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-http-error.js +1 -31
- package/dist/lib/webex-http-error.js.map +1 -1
- package/dist/lib/webex-internal-core-plugin-mixin.js +9 -29
- package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-plugin.js +6 -40
- package/dist/lib/webex-plugin.js.map +1 -1
- package/dist/plugins/logger.js +3 -17
- package/dist/plugins/logger.js.map +1 -1
- package/dist/webex-core.js +79 -203
- package/dist/webex-core.js.map +1 -1
- package/dist/webex-internal-core.js +0 -10
- package/dist/webex-internal-core.js.map +1 -1
- package/package.json +14 -14
|
@@ -1,69 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
-
|
|
5
4
|
var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
6
|
-
|
|
7
5
|
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
8
|
-
|
|
9
6
|
var _Object$getOwnPropertyDescriptor2 = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
10
|
-
|
|
11
7
|
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
12
|
-
|
|
13
8
|
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
14
|
-
|
|
15
9
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
16
|
-
|
|
17
10
|
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
18
|
-
|
|
19
11
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
20
|
-
|
|
21
12
|
_Object$defineProperty(exports, "__esModule", {
|
|
22
13
|
value: true
|
|
23
14
|
});
|
|
24
|
-
|
|
25
15
|
exports.default = void 0;
|
|
26
|
-
|
|
27
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
28
|
-
|
|
29
17
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
30
|
-
|
|
31
18
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/applyDecoratedDescriptor"));
|
|
32
|
-
|
|
33
19
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
34
|
-
|
|
35
20
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
|
|
36
|
-
|
|
37
21
|
var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
|
|
38
|
-
|
|
39
22
|
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
40
|
-
|
|
41
23
|
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor"));
|
|
42
|
-
|
|
43
24
|
var _pick2 = _interopRequireDefault(require("lodash/pick"));
|
|
44
|
-
|
|
45
25
|
var _common = require("@webex/common");
|
|
46
|
-
|
|
47
26
|
var _commonTimers = require("@webex/common-timers");
|
|
48
|
-
|
|
49
27
|
var _webexHttpError = _interopRequireDefault(require("../webex-http-error"));
|
|
50
|
-
|
|
51
28
|
var _webexPlugin = _interopRequireDefault(require("../webex-plugin"));
|
|
52
|
-
|
|
53
29
|
var _scope = require("./scope");
|
|
54
|
-
|
|
55
30
|
var _grantErrors = _interopRequireWildcard(require("./grant-errors"));
|
|
56
|
-
|
|
57
31
|
var _dec, _obj;
|
|
58
|
-
|
|
59
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
60
|
-
|
|
61
33
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor2; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor2(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
62
|
-
|
|
63
34
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor2(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
64
|
-
|
|
65
35
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor2(source, key)); }); } return target; }
|
|
66
|
-
|
|
67
36
|
/* eslint-disable camelcase */
|
|
68
37
|
|
|
69
38
|
/**
|
|
@@ -76,24 +45,19 @@ function processGrantError(res) {
|
|
|
76
45
|
if (res.statusCode !== 400) {
|
|
77
46
|
return _promise.default.reject(res);
|
|
78
47
|
}
|
|
79
|
-
|
|
80
48
|
var ErrorConstructor = _grantErrors.default.select(res.body.error);
|
|
81
|
-
|
|
82
49
|
if (ErrorConstructor === _grantErrors.OAuthError && res instanceof _webexHttpError.default) {
|
|
83
50
|
return _promise.default.reject(res);
|
|
84
51
|
}
|
|
85
|
-
|
|
86
52
|
if (!ErrorConstructor) {
|
|
87
53
|
return _promise.default.reject(res);
|
|
88
54
|
}
|
|
89
|
-
|
|
90
55
|
return _promise.default.reject(new ErrorConstructor(res._res || res));
|
|
91
56
|
}
|
|
57
|
+
|
|
92
58
|
/**
|
|
93
59
|
* @class
|
|
94
60
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
61
|
var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
98
62
|
keyFactory: function keyFactory(scope) {
|
|
99
63
|
return scope;
|
|
@@ -115,7 +79,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
115
79
|
return !!this.access_token && !this.isExpired;
|
|
116
80
|
}
|
|
117
81
|
},
|
|
118
|
-
|
|
119
82
|
/**
|
|
120
83
|
* Indicates that this token can be downscoped. `true` iff
|
|
121
84
|
* {@link config.credentials.client_id} is defined and if
|
|
@@ -136,7 +99,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
136
99
|
return this.canAuthorize && !!this.config.client_id;
|
|
137
100
|
}
|
|
138
101
|
},
|
|
139
|
-
|
|
140
102
|
/**
|
|
141
103
|
* Indicates if this token can be refreshed. `true` iff
|
|
142
104
|
* {@link Token@refresh_token} is defined and
|
|
@@ -157,11 +119,9 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
157
119
|
if (_common.inBrowser) {
|
|
158
120
|
return !!this.refresh_token && !!this.config.refreshCallback;
|
|
159
121
|
}
|
|
160
|
-
|
|
161
122
|
return !!this.refresh_token && !!this.config.client_secret;
|
|
162
123
|
}
|
|
163
124
|
},
|
|
164
|
-
|
|
165
125
|
/**
|
|
166
126
|
* Indicates if this `Token` is expired. `true` iff {@link Token#expires} is
|
|
167
127
|
* defined and is less than {@link Date.now()}.
|
|
@@ -178,7 +138,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
178
138
|
return !!this.expires && this._isExpired;
|
|
179
139
|
}
|
|
180
140
|
},
|
|
181
|
-
|
|
182
141
|
/**
|
|
183
142
|
* Cache for toString()
|
|
184
143
|
* @instance
|
|
@@ -193,7 +152,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
193
152
|
if (!this.access_token || !this.token_type) {
|
|
194
153
|
return '';
|
|
195
154
|
}
|
|
196
|
-
|
|
197
155
|
return "".concat(this.token_type, " ").concat(this.access_token);
|
|
198
156
|
}
|
|
199
157
|
}
|
|
@@ -208,49 +166,42 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
208
166
|
* @type {string}
|
|
209
167
|
*/
|
|
210
168
|
scope: 'string',
|
|
211
|
-
|
|
212
169
|
/**
|
|
213
170
|
* @instance
|
|
214
171
|
* @memberof Token
|
|
215
172
|
* @type {string}
|
|
216
173
|
*/
|
|
217
174
|
access_token: 'string',
|
|
218
|
-
|
|
219
175
|
/**
|
|
220
176
|
* @instance
|
|
221
177
|
* @memberof Token
|
|
222
178
|
* @type {number}
|
|
223
179
|
*/
|
|
224
180
|
expires: 'number',
|
|
225
|
-
|
|
226
181
|
/**
|
|
227
182
|
* @instance
|
|
228
183
|
* @memberof Token
|
|
229
184
|
* @type {number}
|
|
230
185
|
*/
|
|
231
186
|
expires_in: 'number',
|
|
232
|
-
|
|
233
187
|
/**
|
|
234
188
|
* @instance
|
|
235
189
|
* @memberof Token
|
|
236
190
|
* @type {string}
|
|
237
191
|
*/
|
|
238
192
|
refresh_token: 'string',
|
|
239
|
-
|
|
240
193
|
/**
|
|
241
194
|
* @instance
|
|
242
195
|
* @memberof Token
|
|
243
196
|
* @type {number}
|
|
244
197
|
*/
|
|
245
198
|
refresh_token_expires: 'number',
|
|
246
|
-
|
|
247
199
|
/**
|
|
248
200
|
* @instance
|
|
249
201
|
* @memberof Token
|
|
250
202
|
* @type {number}
|
|
251
203
|
*/
|
|
252
204
|
refresh_token_expires_in: 'number',
|
|
253
|
-
|
|
254
205
|
/**
|
|
255
206
|
* @default "Bearer"
|
|
256
207
|
* @instance
|
|
@@ -274,7 +225,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
274
225
|
default: false,
|
|
275
226
|
type: 'boolean'
|
|
276
227
|
},
|
|
277
|
-
|
|
278
228
|
/**
|
|
279
229
|
* Handle to the previous token that we'll revoke when we refresh this
|
|
280
230
|
* token. The idea is to keep allow two valid tokens when a refresh occurs;
|
|
@@ -290,7 +240,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
290
240
|
type: 'state'
|
|
291
241
|
}
|
|
292
242
|
},
|
|
293
|
-
|
|
294
243
|
/**
|
|
295
244
|
* Uses this token to request a new Token with a subset of this Token's scopes
|
|
296
245
|
* @instance
|
|
@@ -300,37 +249,32 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
300
249
|
*/
|
|
301
250
|
downscope: function downscope(scope) {
|
|
302
251
|
var _this = this;
|
|
303
|
-
|
|
304
252
|
this.logger.info("token: downscoping token to ".concat(scope));
|
|
305
|
-
|
|
306
253
|
if (this.isExpired) {
|
|
307
254
|
this.logger.info('token: request received to downscope expired access_token');
|
|
308
255
|
return _promise.default.reject(new Error('cannot downscope expired access token'));
|
|
309
256
|
}
|
|
310
|
-
|
|
311
257
|
if (!this.canDownscope) {
|
|
312
258
|
if (this.config.client_id) {
|
|
313
259
|
this.logger.info('token: request received to downscope invalid access_token');
|
|
314
260
|
} else {
|
|
315
261
|
this.logger.trace('token: cannot downscope without client_id');
|
|
316
262
|
}
|
|
317
|
-
|
|
318
263
|
return _promise.default.reject(new Error('cannot downscope access token'));
|
|
319
|
-
}
|
|
320
|
-
// important scopes are always deterministically specified.
|
|
321
|
-
|
|
264
|
+
}
|
|
322
265
|
|
|
266
|
+
// Since we're going to use scope as the index in our token collection, it's
|
|
267
|
+
// important scopes are always deterministically specified.
|
|
323
268
|
if (scope) {
|
|
324
269
|
scope = (0, _scope.sortScope)(scope);
|
|
325
|
-
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Ideally, we could depend on the service to communicate this error, but
|
|
326
273
|
// all we get is "invalid scope", which, to the lay person, implies
|
|
327
274
|
// something wrong with *one* of the scopes, not the whole thing.
|
|
328
|
-
|
|
329
|
-
|
|
330
275
|
if (scope === (0, _scope.sortScope)(this.config.scope)) {
|
|
331
276
|
return _promise.default.reject(new Error('token: scope reduction requires a reduced scope'));
|
|
332
277
|
}
|
|
333
|
-
|
|
334
278
|
return this.webex.request({
|
|
335
279
|
method: 'POST',
|
|
336
280
|
uri: this.config.tokenUrl,
|
|
@@ -344,7 +288,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
344
288
|
}
|
|
345
289
|
}).then(function (res) {
|
|
346
290
|
_this.logger.info("token: downscoped token to ".concat(scope));
|
|
347
|
-
|
|
348
291
|
return new Token((0, _assign.default)(res.body, {
|
|
349
292
|
scope: scope
|
|
350
293
|
}), {
|
|
@@ -352,7 +295,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
352
295
|
});
|
|
353
296
|
});
|
|
354
297
|
},
|
|
355
|
-
|
|
356
298
|
/**
|
|
357
299
|
* Initializer
|
|
358
300
|
* @instance
|
|
@@ -364,21 +306,18 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
364
306
|
*/
|
|
365
307
|
initialize: function initialize() {
|
|
366
308
|
var _this2 = this;
|
|
367
|
-
|
|
368
309
|
var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
369
310
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
370
311
|
(0, _apply.default)(_webexPlugin.default.prototype.initialize, this, [attrs, options]);
|
|
371
|
-
|
|
372
312
|
if (typeof attrs === 'string') {
|
|
373
313
|
this.access_token = attrs;
|
|
374
314
|
}
|
|
375
|
-
|
|
376
315
|
if (!this.access_token) {
|
|
377
316
|
throw new Error('`access_token` is required');
|
|
378
|
-
}
|
|
379
|
-
// we'll set up a timer the runs when this token should expire.
|
|
380
|
-
|
|
317
|
+
}
|
|
381
318
|
|
|
319
|
+
// We don't want the derived property `isExpired` to need {cache:false}, so
|
|
320
|
+
// we'll set up a timer the runs when this token should expire.
|
|
382
321
|
if (this.expires) {
|
|
383
322
|
if (this.expires < (0, _now.default)()) {
|
|
384
323
|
this._isExpired = true;
|
|
@@ -389,7 +328,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
389
328
|
}
|
|
390
329
|
}
|
|
391
330
|
},
|
|
392
|
-
|
|
393
331
|
/**
|
|
394
332
|
* Refreshes this Token. Relies on
|
|
395
333
|
* {@link config.credentials.refreshCallback()}
|
|
@@ -399,21 +337,16 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
399
337
|
*/
|
|
400
338
|
refresh: function refresh() {
|
|
401
339
|
var _this3 = this;
|
|
402
|
-
|
|
403
340
|
if (!this.canRefresh) {
|
|
404
341
|
throw new Error('Not enough information available to refresh this access token');
|
|
405
342
|
}
|
|
406
|
-
|
|
407
343
|
var promise;
|
|
408
|
-
|
|
409
344
|
if (_common.inBrowser) {
|
|
410
345
|
if (!this.config.refreshCallback) {
|
|
411
346
|
throw new Error('Cannot refresh access token without refreshCallback');
|
|
412
347
|
}
|
|
413
|
-
|
|
414
348
|
promise = _promise.default.resolve(this.config.refreshCallback(this.webex, this));
|
|
415
349
|
}
|
|
416
|
-
|
|
417
350
|
return (promise || this.webex.request({
|
|
418
351
|
method: 'POST',
|
|
419
352
|
uri: this.config.tokenUrl,
|
|
@@ -433,36 +366,29 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
433
366
|
})).then(function (obj) {
|
|
434
367
|
if (!obj) {
|
|
435
368
|
throw new Error('token: refreshCallback() did not produce an object');
|
|
436
|
-
}
|
|
369
|
+
}
|
|
370
|
+
// If the authentication server did not send back a refresh token, copy
|
|
437
371
|
// the current refresh token and related values to the response (note:
|
|
438
372
|
// at time of implementation, CI never sends a new refresh token)
|
|
439
|
-
|
|
440
|
-
|
|
441
373
|
if (!obj.refresh_token) {
|
|
442
374
|
(0, _assign.default)(obj, (0, _pick2.default)(_this3, 'refresh_token', 'refresh_token_expires', 'refresh_token_expires_in'));
|
|
443
|
-
}
|
|
444
|
-
// found a bug in CI; log the details and reject the Promise
|
|
445
|
-
|
|
375
|
+
}
|
|
446
376
|
|
|
377
|
+
// If the new token is the same as the previous token, then we may have
|
|
378
|
+
// found a bug in CI; log the details and reject the Promise
|
|
447
379
|
if (_this3.access_token === obj.access_token) {
|
|
448
|
-
_this3.logger.error('token: new token matches current token');
|
|
449
|
-
|
|
450
|
-
|
|
380
|
+
_this3.logger.error('token: new token matches current token');
|
|
381
|
+
// log the tokens if it is not production
|
|
451
382
|
if (process.env.NODE_ENV !== 'production') {
|
|
452
383
|
_this3.logger.error('token: current token:', _this3.access_token);
|
|
453
|
-
|
|
454
384
|
_this3.logger.error('token: new token:', obj.access_token);
|
|
455
385
|
}
|
|
456
|
-
|
|
457
386
|
return _promise.default.reject(new Error('new token matches current token'));
|
|
458
387
|
}
|
|
459
|
-
|
|
460
388
|
if (_this3.previousToken) {
|
|
461
389
|
_this3.previousToken.revoke();
|
|
462
|
-
|
|
463
390
|
_this3.unset('previousToken');
|
|
464
391
|
}
|
|
465
|
-
|
|
466
392
|
obj.previousToken = _this3;
|
|
467
393
|
obj.scope = _this3.scope;
|
|
468
394
|
return new Token(obj, {
|
|
@@ -470,7 +396,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
470
396
|
});
|
|
471
397
|
}).catch(processGrantError);
|
|
472
398
|
},
|
|
473
|
-
|
|
474
399
|
/**
|
|
475
400
|
* Revokes this token and unsets its local properties
|
|
476
401
|
* @instance
|
|
@@ -479,28 +404,25 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
479
404
|
*/
|
|
480
405
|
revoke: function revoke() {
|
|
481
406
|
var _this4 = this;
|
|
482
|
-
|
|
483
407
|
if (this.isExpired) {
|
|
484
408
|
this.logger.info('token: already expired, not making making revocation request');
|
|
485
409
|
return _promise.default.resolve();
|
|
486
410
|
}
|
|
487
|
-
|
|
488
411
|
if (!this.canAuthorize) {
|
|
489
412
|
this.logger.info('token: no longer valid, not making revocation request');
|
|
490
413
|
return _promise.default.resolve();
|
|
491
|
-
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// FIXME we need to use the user token revocation endpoint to revoke a token
|
|
492
417
|
// without a client_secret, but it doesn't current support using a token to
|
|
493
418
|
// revoke itself
|
|
494
419
|
// Note: I'm not making a canRevoke property because there should be changes
|
|
495
420
|
// coming to the user token revocation endpoint that allow us to do this
|
|
496
421
|
// correctly.
|
|
497
|
-
|
|
498
|
-
|
|
499
422
|
if (!this.config.client_secret) {
|
|
500
423
|
this.logger.info('token: no client secret available, not making revocation request');
|
|
501
424
|
return _promise.default.resolve();
|
|
502
425
|
}
|
|
503
|
-
|
|
504
426
|
this.logger.info('token: revoking access token');
|
|
505
427
|
return this.webex.request({
|
|
506
428
|
method: 'POST',
|
|
@@ -517,46 +439,37 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
517
439
|
shouldRefreshAccessToken: false
|
|
518
440
|
}).then(function () {
|
|
519
441
|
_this4.unset(['access_token', 'expires', 'expires_in', 'token_type']);
|
|
520
|
-
|
|
521
442
|
_this4.logger.info('token: access token revoked');
|
|
522
443
|
}).catch(processGrantError);
|
|
523
444
|
},
|
|
524
445
|
set: function set() {
|
|
525
446
|
// eslint-disable-next-line prefer-const
|
|
526
447
|
var _this$_filterSetParam = this._filterSetParameters.apply(this, arguments),
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
448
|
+
_this$_filterSetParam2 = (0, _slicedToArray2.default)(_this$_filterSetParam, 2),
|
|
449
|
+
attrs = _this$_filterSetParam2[0],
|
|
450
|
+
options = _this$_filterSetParam2[1];
|
|
531
451
|
if (!attrs.token_type && attrs.access_token && attrs.access_token.includes(' ')) {
|
|
532
452
|
var _attrs$access_token$s = attrs.access_token.split(' '),
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
453
|
+
_attrs$access_token$s2 = (0, _slicedToArray2.default)(_attrs$access_token$s, 2),
|
|
454
|
+
token_type = _attrs$access_token$s2[0],
|
|
455
|
+
access_token = _attrs$access_token$s2[1];
|
|
537
456
|
attrs = _objectSpread(_objectSpread({}, attrs), {}, {
|
|
538
457
|
access_token: access_token,
|
|
539
458
|
token_type: token_type
|
|
540
459
|
});
|
|
541
460
|
}
|
|
542
|
-
|
|
543
461
|
var now = (0, _now.default)();
|
|
544
|
-
|
|
545
462
|
if (!attrs.expires && attrs.expires_in) {
|
|
546
463
|
attrs.expires = now + attrs.expires_in * 1000;
|
|
547
464
|
}
|
|
548
|
-
|
|
549
465
|
if (!attrs.refresh_token_expires && attrs.refresh_token_expires_in) {
|
|
550
466
|
attrs.refresh_token_expires = now + attrs.refresh_token_expires_in * 1000;
|
|
551
467
|
}
|
|
552
|
-
|
|
553
468
|
if (attrs.scope) {
|
|
554
469
|
attrs.scope = (0, _scope.sortScope)(attrs.scope);
|
|
555
470
|
}
|
|
556
|
-
|
|
557
471
|
return (0, _apply.default)(_webexPlugin.default.prototype.set, this, [attrs, options]);
|
|
558
472
|
},
|
|
559
|
-
|
|
560
473
|
/**
|
|
561
474
|
* Renders the token object as an HTTP Header Value
|
|
562
475
|
* @instance
|
|
@@ -568,10 +481,8 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
568
481
|
if (!this._string) {
|
|
569
482
|
throw new Error('cannot stringify Token');
|
|
570
483
|
}
|
|
571
|
-
|
|
572
484
|
return this._string;
|
|
573
485
|
},
|
|
574
|
-
|
|
575
486
|
/**
|
|
576
487
|
* Uses a non-producation api to return information about this token. This
|
|
577
488
|
* method is primarily for tests and will throw if NODE_ENV === production
|
|
@@ -582,11 +493,9 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
582
493
|
*/
|
|
583
494
|
validate: function validate() {
|
|
584
495
|
var _this5 = this;
|
|
585
|
-
|
|
586
496
|
if (process.env.NODE_ENV === 'production') {
|
|
587
497
|
throw new Error('Token#validate() must not be used in production');
|
|
588
498
|
}
|
|
589
|
-
|
|
590
499
|
return this.webex.request({
|
|
591
500
|
method: 'POST',
|
|
592
501
|
service: 'conversation',
|
|
@@ -598,12 +507,11 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
598
507
|
if ('statusCode' in reason) {
|
|
599
508
|
return _promise.default.reject(reason);
|
|
600
509
|
}
|
|
510
|
+
_this5.logger.info("REMINDER: If you're investigating a network error here, it's normal");
|
|
601
511
|
|
|
602
|
-
|
|
512
|
+
// If we got an error that isn't a WebexHttpError, assume the problem is
|
|
603
513
|
// that we don't have the wdm plugin loaded and service/resource isn't
|
|
604
514
|
// a valid means of identifying a request.
|
|
605
|
-
|
|
606
|
-
|
|
607
515
|
var convApi = process.env.CONVERSATION_SERVICE || process.env.CONVERSATION_SERVICE_URL || 'https://conv-a.wbx2.com/conversation/api/v1';
|
|
608
516
|
return _this5.webex.request({
|
|
609
517
|
method: 'POST',
|
|
@@ -619,9 +527,8 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
619
527
|
return res.body;
|
|
620
528
|
});
|
|
621
529
|
},
|
|
622
|
-
version: "3.0.0-beta.
|
|
530
|
+
version: "3.0.0-beta.16"
|
|
623
531
|
}, ((0, _applyDecoratedDescriptor2.default)(_obj, "downscope", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, "downscope"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "revoke", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "revoke"), _obj)), _obj)));
|
|
624
|
-
|
|
625
532
|
var _default = Token;
|
|
626
533
|
exports.default = _default;
|
|
627
534
|
//# sourceMappingURL=token.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["processGrantError","res","statusCode","reject","ErrorConstructor","grantErrors","select","body","error","OAuthError","WebexHttpError","_res","Token","WebexPlugin","extend","oneFlight","keyFactory","scope","derived","canAuthorize","deps","fn","access_token","isExpired","canDownscope","config","client_id","canRefresh","inBrowser","refresh_token","refreshCallback","client_secret","expires","_isExpired","_string","token_type","namespace","props","expires_in","refresh_token_expires","refresh_token_expires_in","default","type","session","previousToken","downscope","logger","info","Error","trace","sortScope","webex","request","method","uri","tokenUrl","addAuthHeader","form","grant_type","token","self_contained_token","then","parent","initialize","attrs","options","prototype","safeSetTimeout","refresh","promise","resolve","redirect_uri","auth","user","pass","sendImmediately","shouldRefreshAccessToken","obj","process","env","NODE_ENV","revoke","unset","catch","revokeUrl","token_type_hint","set","_filterSetParameters","includes","split","now","toString","validate","service","resource","reason","convApi","CONVERSATION_SERVICE","CONVERSATION_SERVICE_URL","headers","authorization"],"sources":["token.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {pick} from 'lodash';\nimport {inBrowser, oneFlight} from '@webex/common';\nimport {safeSetTimeout} from '@webex/common-timers';\n\nimport WebexHttpError from '../webex-http-error';\nimport WebexPlugin from '../webex-plugin';\n\nimport {sortScope} from './scope';\nimport grantErrors, {OAuthError} from './grant-errors';\n\n/* eslint-disable camelcase */\n\n/**\n * Parse response from CI and converts to structured error when appropriate\n * @param {WebexHttpError} res\n * @private\n * @returns {GrantError}\n */\nfunction processGrantError(res) {\n if (res.statusCode !== 400) {\n return Promise.reject(res);\n }\n\n const ErrorConstructor = grantErrors.select(res.body.error);\n\n if (ErrorConstructor === OAuthError && res instanceof WebexHttpError) {\n return Promise.reject(res);\n }\n if (!ErrorConstructor) {\n return Promise.reject(res);\n }\n\n return Promise.reject(new ErrorConstructor(res._res || res));\n}\n\n/**\n * @class\n */\nconst Token = WebexPlugin.extend({\n derived: {\n /**\n * Indicates if this token can be used in an auth header. `true` iff\n * {@link Token#access_token} is defined and {@link Token#isExpired} is\n * false.\n * @instance\n * @memberof Token\n * @readonly\n * @type {boolean}\n */\n canAuthorize: {\n deps: ['access_token', 'isExpired'],\n fn() {\n return !!this.access_token && !this.isExpired;\n },\n },\n\n /**\n * Indicates that this token can be downscoped. `true` iff\n * {@link config.credentials.client_id} is defined and if\n * {@link Token#canAuthorize} is true\n *\n * Note: since {@link config} is not evented, we can't listen for changes to\n * {@link config.credentials.client_id}. As such,\n * {@link config.credentials.client_id} must always be set before\n * instantiating a {@link Token}\n * @instance\n * @memberof Token\n * @readonly\n * @type {boolean}\n */\n canDownscope: {\n deps: ['canAuthorize'],\n fn() {\n return this.canAuthorize && !!this.config.client_id;\n },\n },\n\n /**\n * Indicates if this token can be refreshed. `true` iff\n * {@link Token@refresh_token} is defined and\n * {@link config.credentials.refreshCallback()} is defined\n *\n * Note: since {@link config} is not evented, we can't listen for changes to\n * {@link config.credentials.refreshCallback()}. As such,\n * {@link config.credentials.refreshCallback()} must always be set before\n * instantiating a {@link Token}\n * @instance\n * @memberof Token\n * @readonly\n * @type {boolean}\n */\n canRefresh: {\n deps: ['refresh_token'],\n fn() {\n if (inBrowser) {\n return !!this.refresh_token && !!this.config.refreshCallback;\n }\n\n return !!this.refresh_token && !!this.config.client_secret;\n },\n },\n\n /**\n * Indicates if this `Token` is expired. `true` iff {@link Token#expires} is\n * defined and is less than {@link Date.now()}.\n * @instance\n * @memberof Token\n * @readonly\n * @type {boolean}\n */\n isExpired: {\n deps: ['expires', '_isExpired'],\n fn() {\n // in order to avoid setting `cache:false`, we'll use a private property\n // and a timer rather than comparing to `Date.now()`;\n return !!this.expires && this._isExpired;\n },\n },\n\n /**\n * Cache for toString()\n * @instance\n * @memberof Token\n * @private\n * @readonly\n * @type {string}\n */\n _string: {\n deps: ['access_token', 'token_type'],\n fn() {\n if (!this.access_token || !this.token_type) {\n return '';\n }\n\n return `${this.token_type} ${this.access_token}`;\n },\n },\n },\n\n namespace: 'Credentials',\n\n props: {\n /**\n * Used for indexing in the credentials userTokens collection\n * @instance\n * @memberof Token\n * @private\n * @type {string}\n */\n scope: 'string',\n /**\n * @instance\n * @memberof Token\n * @type {string}\n */\n access_token: 'string',\n /**\n * @instance\n * @memberof Token\n * @type {number}\n */\n expires: 'number',\n /**\n * @instance\n * @memberof Token\n * @type {number}\n */\n expires_in: 'number',\n /**\n * @instance\n * @memberof Token\n * @type {string}\n */\n refresh_token: 'string',\n /**\n * @instance\n * @memberof Token\n * @type {number}\n */\n refresh_token_expires: 'number',\n /**\n * @instance\n * @memberof Token\n * @type {number}\n */\n refresh_token_expires_in: 'number',\n /**\n * @default \"Bearer\"\n * @instance\n * @memberof Token\n * @type {string}\n */\n token_type: {\n default: 'Bearer',\n type: 'string',\n },\n },\n\n session: {\n /**\n * Used by {@link Token#isExpired} to avoid doing a Date comparison.\n * @instance\n * @memberof Token\n * @private\n * @type {boolean}\n */\n _isExpired: {\n default: false,\n type: 'boolean',\n },\n /**\n * Handle to the previous token that we'll revoke when we refresh this\n * token. The idea is to keep allow two valid tokens when a refresh occurs;\n * we don't want revoke a token that's in the middle of being used, so when\n * we do a token refresh, we won't revoke the token being refreshed, but\n * we'll revoke the previous one.\n * @instance\n * @memberof Token\n * @private\n * @type {Object}\n */\n previousToken: {\n type: 'state',\n },\n },\n\n @oneFlight({\n keyFactory(scope) {\n return scope;\n },\n })\n /**\n * Uses this token to request a new Token with a subset of this Token's scopes\n * @instance\n * @memberof Token\n * @param {string} scope\n * @returns {Promise<Token>}\n */\n downscope(scope) {\n this.logger.info(`token: downscoping token to ${scope}`);\n\n if (this.isExpired) {\n this.logger.info('token: request received to downscope expired access_token');\n\n return Promise.reject(new Error('cannot downscope expired access token'));\n }\n\n if (!this.canDownscope) {\n if (this.config.client_id) {\n this.logger.info('token: request received to downscope invalid access_token');\n } else {\n this.logger.trace('token: cannot downscope without client_id');\n }\n\n return Promise.reject(new Error('cannot downscope access token'));\n }\n\n // Since we're going to use scope as the index in our token collection, it's\n // important scopes are always deterministically specified.\n if (scope) {\n scope = sortScope(scope);\n }\n\n // Ideally, we could depend on the service to communicate this error, but\n // all we get is \"invalid scope\", which, to the lay person, implies\n // something wrong with *one* of the scopes, not the whole thing.\n if (scope === sortScope(this.config.scope)) {\n return Promise.reject(new Error('token: scope reduction requires a reduced scope'));\n }\n\n return this.webex\n .request({\n method: 'POST',\n uri: this.config.tokenUrl,\n addAuthHeader: false,\n form: {\n grant_type: 'urn:cisco:oauth:grant-type:scope-reduction',\n token: this.access_token,\n scope,\n client_id: this.config.client_id,\n self_contained_token: true,\n },\n })\n .then((res) => {\n this.logger.info(`token: downscoped token to ${scope}`);\n\n return new Token(Object.assign(res.body, {scope}), {parent: this.parent});\n });\n },\n\n /**\n * Initializer\n * @instance\n * @memberof Token\n * @param {Object} [attrs={}]\n * @param {Object} [options={}]\n * @see {@link WebexPlugin#initialize()}\n * @returns {Token}\n */\n initialize(attrs = {}, options = {}) {\n Reflect.apply(WebexPlugin.prototype.initialize, this, [attrs, options]);\n\n if (typeof attrs === 'string') {\n this.access_token = attrs;\n }\n\n if (!this.access_token) {\n throw new Error('`access_token` is required');\n }\n\n // We don't want the derived property `isExpired` to need {cache:false}, so\n // we'll set up a timer the runs when this token should expire.\n if (this.expires) {\n if (this.expires < Date.now()) {\n this._isExpired = true;\n } else {\n safeSetTimeout(() => {\n this._isExpired = true;\n }, this.expires - Date.now());\n }\n }\n },\n\n @oneFlight\n /**\n * Refreshes this Token. Relies on\n * {@link config.credentials.refreshCallback()}\n * @instance\n * @memberof Token\n * @returns {Promise<Token>}\n */\n refresh() {\n if (!this.canRefresh) {\n throw new Error('Not enough information available to refresh this access token');\n }\n\n let promise;\n\n if (inBrowser) {\n if (!this.config.refreshCallback) {\n throw new Error('Cannot refresh access token without refreshCallback');\n }\n\n promise = Promise.resolve(this.config.refreshCallback(this.webex, this));\n }\n\n return (\n promise ||\n this.webex\n .request({\n method: 'POST',\n uri: this.config.tokenUrl,\n form: {\n grant_type: 'refresh_token',\n redirect_uri: this.config.redirect_uri,\n refresh_token: this.refresh_token,\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true,\n },\n shouldRefreshAccessToken: false,\n })\n .then((res) => res.body)\n )\n .then((obj) => {\n if (!obj) {\n throw new Error('token: refreshCallback() did not produce an object');\n }\n // If the authentication server did not send back a refresh token, copy\n // the current refresh token and related values to the response (note:\n // at time of implementation, CI never sends a new refresh token)\n if (!obj.refresh_token) {\n Object.assign(\n obj,\n pick(this, 'refresh_token', 'refresh_token_expires', 'refresh_token_expires_in')\n );\n }\n\n // If the new token is the same as the previous token, then we may have\n // found a bug in CI; log the details and reject the Promise\n if (this.access_token === obj.access_token) {\n this.logger.error('token: new token matches current token');\n // log the tokens if it is not production\n if (process.env.NODE_ENV !== 'production') {\n this.logger.error('token: current token:', this.access_token);\n this.logger.error('token: new token:', obj.access_token);\n }\n\n return Promise.reject(new Error('new token matches current token'));\n }\n\n if (this.previousToken) {\n this.previousToken.revoke();\n this.unset('previousToken');\n }\n\n obj.previousToken = this;\n obj.scope = this.scope;\n\n return new Token(obj, {parent: this.parent});\n })\n .catch(processGrantError);\n },\n\n @oneFlight\n /**\n * Revokes this token and unsets its local properties\n * @instance\n * @memberof Token\n * @returns {Promise}\n */\n revoke() {\n if (this.isExpired) {\n this.logger.info('token: already expired, not making making revocation request');\n\n return Promise.resolve();\n }\n\n if (!this.canAuthorize) {\n this.logger.info('token: no longer valid, not making revocation request');\n\n return Promise.resolve();\n }\n\n // FIXME we need to use the user token revocation endpoint to revoke a token\n // without a client_secret, but it doesn't current support using a token to\n // revoke itself\n // Note: I'm not making a canRevoke property because there should be changes\n // coming to the user token revocation endpoint that allow us to do this\n // correctly.\n if (!this.config.client_secret) {\n this.logger.info('token: no client secret available, not making revocation request');\n\n return Promise.resolve();\n }\n\n this.logger.info('token: revoking access token');\n\n return this.webex\n .request({\n method: 'POST',\n uri: this.config.revokeUrl,\n form: {\n token: this.access_token,\n token_type_hint: 'access_token',\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true,\n },\n shouldRefreshAccessToken: false,\n })\n .then(() => {\n this.unset(['access_token', 'expires', 'expires_in', 'token_type']);\n this.logger.info('token: access token revoked');\n })\n .catch(processGrantError);\n },\n\n set(...args) {\n // eslint-disable-next-line prefer-const\n let [attrs, options] = this._filterSetParameters(...args);\n\n if (!attrs.token_type && attrs.access_token && attrs.access_token.includes(' ')) {\n const [token_type, access_token] = attrs.access_token.split(' ');\n\n attrs = {...attrs, access_token, token_type};\n }\n const now = Date.now();\n\n if (!attrs.expires && attrs.expires_in) {\n attrs.expires = now + attrs.expires_in * 1000;\n }\n\n if (!attrs.refresh_token_expires && attrs.refresh_token_expires_in) {\n attrs.refresh_token_expires = now + attrs.refresh_token_expires_in * 1000;\n }\n\n if (attrs.scope) {\n attrs.scope = sortScope(attrs.scope);\n }\n\n return Reflect.apply(WebexPlugin.prototype.set, this, [attrs, options]);\n },\n\n /**\n * Renders the token object as an HTTP Header Value\n * @instance\n * @memberof Token\n * @returns {string}\n * @see {@link Object#toString()}\n */\n toString() {\n if (!this._string) {\n throw new Error('cannot stringify Token');\n }\n\n return this._string;\n },\n\n /**\n * Uses a non-producation api to return information about this token. This\n * method is primarily for tests and will throw if NODE_ENV === production\n * @instance\n * @memberof Token\n * @private\n * @returns {Promise}\n */\n validate() {\n if (process.env.NODE_ENV === 'production') {\n throw new Error('Token#validate() must not be used in production');\n }\n\n return this.webex\n .request({\n method: 'POST',\n service: 'conversation',\n resource: 'users/validateAuthToken',\n body: {\n token: this.access_token,\n },\n })\n .catch((reason) => {\n if ('statusCode' in reason) {\n return Promise.reject(reason);\n }\n this.logger.info(\"REMINDER: If you're investigating a network error here, it's normal\");\n\n // If we got an error that isn't a WebexHttpError, assume the problem is\n // that we don't have the wdm plugin loaded and service/resource isn't\n // a valid means of identifying a request.\n const convApi =\n process.env.CONVERSATION_SERVICE ||\n process.env.CONVERSATION_SERVICE_URL ||\n 'https://conv-a.wbx2.com/conversation/api/v1';\n\n return this.webex.request({\n method: 'POST',\n uri: `${convApi}/users/validateAuthToken`,\n body: {\n token: this.access_token,\n },\n headers: {\n authorization: `Bearer ${this.access_token}`,\n },\n });\n })\n .then((res) => res.body);\n },\n});\n\nexport default Token;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;;;;;;;;;;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAT,CAA2BC,GAA3B,EAAgC;EAC9B,IAAIA,GAAG,CAACC,UAAJ,KAAmB,GAAvB,EAA4B;IAC1B,OAAO,iBAAQC,MAAR,CAAeF,GAAf,CAAP;EACD;;EAED,IAAMG,gBAAgB,GAAGC,oBAAA,CAAYC,MAAZ,CAAmBL,GAAG,CAACM,IAAJ,CAASC,KAA5B,CAAzB;;EAEA,IAAIJ,gBAAgB,KAAKK,uBAArB,IAAmCR,GAAG,YAAYS,uBAAtD,EAAsE;I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5F,MAAR,CAAe4F,MAAf,CAAP;MACD;;MACD,MAAI,CAACjD,MAAL,CAAYC,IAAZ,CAAiB,qEAAjB,EAJiB,CAMjB;MACA;MACA;;;MACA,IAAMiD,OAAO,GACXlB,OAAO,CAACC,GAAR,CAAYkB,oBAAZ,IACAnB,OAAO,CAACC,GAAR,CAAYmB,wBADZ,IAEA,6CAHF;MAKA,OAAO,MAAI,CAAC/C,KAAL,CAAWC,OAAX,CAAmB;QACxBC,MAAM,EAAE,MADgB;QAExBC,GAAG,YAAK0C,OAAL,6BAFqB;QAGxBzF,IAAI,EAAE;UACJoD,KAAK,EAAE,MAAI,CAACrC;QADR,CAHkB;QAMxB6E,OAAO,EAAE;UACPC,aAAa,mBAAY,MAAI,CAAC9E,YAAjB;QADN;MANe,CAAnB,CAAP;IAUD,CAjCI,EAkCJuC,IAlCI,CAkCC,UAAC5D,GAAD;MAAA,OAASA,GAAG,CAACM,IAAb;IAAA,CAlCD,CAAP;EAmCD,CAjgB8B;EAAA;AAAA,CAAnB,kMA6RXQ,iBA7RW,4HAgXXA,iBAhXW,0EAAd;;eAogBeH,K"}
|
|
1
|
+
{"version":3,"names":["processGrantError","res","statusCode","reject","ErrorConstructor","grantErrors","select","body","error","OAuthError","WebexHttpError","_res","Token","WebexPlugin","extend","oneFlight","keyFactory","scope","derived","canAuthorize","deps","fn","access_token","isExpired","canDownscope","config","client_id","canRefresh","inBrowser","refresh_token","refreshCallback","client_secret","expires","_isExpired","_string","token_type","namespace","props","expires_in","refresh_token_expires","refresh_token_expires_in","default","type","session","previousToken","downscope","logger","info","Error","trace","sortScope","webex","request","method","uri","tokenUrl","addAuthHeader","form","grant_type","token","self_contained_token","then","parent","initialize","attrs","options","prototype","safeSetTimeout","refresh","promise","resolve","redirect_uri","auth","user","pass","sendImmediately","shouldRefreshAccessToken","obj","process","env","NODE_ENV","revoke","unset","catch","revokeUrl","token_type_hint","set","_filterSetParameters","includes","split","now","toString","validate","service","resource","reason","convApi","CONVERSATION_SERVICE","CONVERSATION_SERVICE_URL","headers","authorization"],"sources":["token.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {pick} from 'lodash';\nimport {inBrowser, oneFlight} from '@webex/common';\nimport {safeSetTimeout} from '@webex/common-timers';\n\nimport WebexHttpError from '../webex-http-error';\nimport WebexPlugin from '../webex-plugin';\n\nimport {sortScope} from './scope';\nimport grantErrors, {OAuthError} from './grant-errors';\n\n/* eslint-disable camelcase */\n\n/**\n * Parse response from CI and converts to structured error when appropriate\n * @param {WebexHttpError} res\n * @private\n * @returns {GrantError}\n */\nfunction processGrantError(res) {\n if (res.statusCode !== 400) {\n return Promise.reject(res);\n }\n\n const ErrorConstructor = grantErrors.select(res.body.error);\n\n if (ErrorConstructor === OAuthError && res instanceof WebexHttpError) {\n return Promise.reject(res);\n }\n if (!ErrorConstructor) {\n return Promise.reject(res);\n }\n\n return Promise.reject(new ErrorConstructor(res._res || res));\n}\n\n/**\n * @class\n */\nconst Token = WebexPlugin.extend({\n derived: {\n /**\n * Indicates if this token can be used in an auth header. `true` iff\n * {@link Token#access_token} is defined and {@link Token#isExpired} is\n * false.\n * @instance\n * @memberof Token\n * @readonly\n * @type {boolean}\n */\n canAuthorize: {\n deps: ['access_token', 'isExpired'],\n fn() {\n return !!this.access_token && !this.isExpired;\n },\n },\n\n /**\n * Indicates that this token can be downscoped. `true` iff\n * {@link config.credentials.client_id} is defined and if\n * {@link Token#canAuthorize} is true\n *\n * Note: since {@link config} is not evented, we can't listen for changes to\n * {@link config.credentials.client_id}. As such,\n * {@link config.credentials.client_id} must always be set before\n * instantiating a {@link Token}\n * @instance\n * @memberof Token\n * @readonly\n * @type {boolean}\n */\n canDownscope: {\n deps: ['canAuthorize'],\n fn() {\n return this.canAuthorize && !!this.config.client_id;\n },\n },\n\n /**\n * Indicates if this token can be refreshed. `true` iff\n * {@link Token@refresh_token} is defined and\n * {@link config.credentials.refreshCallback()} is defined\n *\n * Note: since {@link config} is not evented, we can't listen for changes to\n * {@link config.credentials.refreshCallback()}. As such,\n * {@link config.credentials.refreshCallback()} must always be set before\n * instantiating a {@link Token}\n * @instance\n * @memberof Token\n * @readonly\n * @type {boolean}\n */\n canRefresh: {\n deps: ['refresh_token'],\n fn() {\n if (inBrowser) {\n return !!this.refresh_token && !!this.config.refreshCallback;\n }\n\n return !!this.refresh_token && !!this.config.client_secret;\n },\n },\n\n /**\n * Indicates if this `Token` is expired. `true` iff {@link Token#expires} is\n * defined and is less than {@link Date.now()}.\n * @instance\n * @memberof Token\n * @readonly\n * @type {boolean}\n */\n isExpired: {\n deps: ['expires', '_isExpired'],\n fn() {\n // in order to avoid setting `cache:false`, we'll use a private property\n // and a timer rather than comparing to `Date.now()`;\n return !!this.expires && this._isExpired;\n },\n },\n\n /**\n * Cache for toString()\n * @instance\n * @memberof Token\n * @private\n * @readonly\n * @type {string}\n */\n _string: {\n deps: ['access_token', 'token_type'],\n fn() {\n if (!this.access_token || !this.token_type) {\n return '';\n }\n\n return `${this.token_type} ${this.access_token}`;\n },\n },\n },\n\n namespace: 'Credentials',\n\n props: {\n /**\n * Used for indexing in the credentials userTokens collection\n * @instance\n * @memberof Token\n * @private\n * @type {string}\n */\n scope: 'string',\n /**\n * @instance\n * @memberof Token\n * @type {string}\n */\n access_token: 'string',\n /**\n * @instance\n * @memberof Token\n * @type {number}\n */\n expires: 'number',\n /**\n * @instance\n * @memberof Token\n * @type {number}\n */\n expires_in: 'number',\n /**\n * @instance\n * @memberof Token\n * @type {string}\n */\n refresh_token: 'string',\n /**\n * @instance\n * @memberof Token\n * @type {number}\n */\n refresh_token_expires: 'number',\n /**\n * @instance\n * @memberof Token\n * @type {number}\n */\n refresh_token_expires_in: 'number',\n /**\n * @default \"Bearer\"\n * @instance\n * @memberof Token\n * @type {string}\n */\n token_type: {\n default: 'Bearer',\n type: 'string',\n },\n },\n\n session: {\n /**\n * Used by {@link Token#isExpired} to avoid doing a Date comparison.\n * @instance\n * @memberof Token\n * @private\n * @type {boolean}\n */\n _isExpired: {\n default: false,\n type: 'boolean',\n },\n /**\n * Handle to the previous token that we'll revoke when we refresh this\n * token. The idea is to keep allow two valid tokens when a refresh occurs;\n * we don't want revoke a token that's in the middle of being used, so when\n * we do a token refresh, we won't revoke the token being refreshed, but\n * we'll revoke the previous one.\n * @instance\n * @memberof Token\n * @private\n * @type {Object}\n */\n previousToken: {\n type: 'state',\n },\n },\n\n @oneFlight({\n keyFactory(scope) {\n return scope;\n },\n })\n /**\n * Uses this token to request a new Token with a subset of this Token's scopes\n * @instance\n * @memberof Token\n * @param {string} scope\n * @returns {Promise<Token>}\n */\n downscope(scope) {\n this.logger.info(`token: downscoping token to ${scope}`);\n\n if (this.isExpired) {\n this.logger.info('token: request received to downscope expired access_token');\n\n return Promise.reject(new Error('cannot downscope expired access token'));\n }\n\n if (!this.canDownscope) {\n if (this.config.client_id) {\n this.logger.info('token: request received to downscope invalid access_token');\n } else {\n this.logger.trace('token: cannot downscope without client_id');\n }\n\n return Promise.reject(new Error('cannot downscope access token'));\n }\n\n // Since we're going to use scope as the index in our token collection, it's\n // important scopes are always deterministically specified.\n if (scope) {\n scope = sortScope(scope);\n }\n\n // Ideally, we could depend on the service to communicate this error, but\n // all we get is \"invalid scope\", which, to the lay person, implies\n // something wrong with *one* of the scopes, not the whole thing.\n if (scope === sortScope(this.config.scope)) {\n return Promise.reject(new Error('token: scope reduction requires a reduced scope'));\n }\n\n return this.webex\n .request({\n method: 'POST',\n uri: this.config.tokenUrl,\n addAuthHeader: false,\n form: {\n grant_type: 'urn:cisco:oauth:grant-type:scope-reduction',\n token: this.access_token,\n scope,\n client_id: this.config.client_id,\n self_contained_token: true,\n },\n })\n .then((res) => {\n this.logger.info(`token: downscoped token to ${scope}`);\n\n return new Token(Object.assign(res.body, {scope}), {parent: this.parent});\n });\n },\n\n /**\n * Initializer\n * @instance\n * @memberof Token\n * @param {Object} [attrs={}]\n * @param {Object} [options={}]\n * @see {@link WebexPlugin#initialize()}\n * @returns {Token}\n */\n initialize(attrs = {}, options = {}) {\n Reflect.apply(WebexPlugin.prototype.initialize, this, [attrs, options]);\n\n if (typeof attrs === 'string') {\n this.access_token = attrs;\n }\n\n if (!this.access_token) {\n throw new Error('`access_token` is required');\n }\n\n // We don't want the derived property `isExpired` to need {cache:false}, so\n // we'll set up a timer the runs when this token should expire.\n if (this.expires) {\n if (this.expires < Date.now()) {\n this._isExpired = true;\n } else {\n safeSetTimeout(() => {\n this._isExpired = true;\n }, this.expires - Date.now());\n }\n }\n },\n\n @oneFlight\n /**\n * Refreshes this Token. Relies on\n * {@link config.credentials.refreshCallback()}\n * @instance\n * @memberof Token\n * @returns {Promise<Token>}\n */\n refresh() {\n if (!this.canRefresh) {\n throw new Error('Not enough information available to refresh this access token');\n }\n\n let promise;\n\n if (inBrowser) {\n if (!this.config.refreshCallback) {\n throw new Error('Cannot refresh access token without refreshCallback');\n }\n\n promise = Promise.resolve(this.config.refreshCallback(this.webex, this));\n }\n\n return (\n promise ||\n this.webex\n .request({\n method: 'POST',\n uri: this.config.tokenUrl,\n form: {\n grant_type: 'refresh_token',\n redirect_uri: this.config.redirect_uri,\n refresh_token: this.refresh_token,\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true,\n },\n shouldRefreshAccessToken: false,\n })\n .then((res) => res.body)\n )\n .then((obj) => {\n if (!obj) {\n throw new Error('token: refreshCallback() did not produce an object');\n }\n // If the authentication server did not send back a refresh token, copy\n // the current refresh token and related values to the response (note:\n // at time of implementation, CI never sends a new refresh token)\n if (!obj.refresh_token) {\n Object.assign(\n obj,\n pick(this, 'refresh_token', 'refresh_token_expires', 'refresh_token_expires_in')\n );\n }\n\n // If the new token is the same as the previous token, then we may have\n // found a bug in CI; log the details and reject the Promise\n if (this.access_token === obj.access_token) {\n this.logger.error('token: new token matches current token');\n // log the tokens if it is not production\n if (process.env.NODE_ENV !== 'production') {\n this.logger.error('token: current token:', this.access_token);\n this.logger.error('token: new token:', obj.access_token);\n }\n\n return Promise.reject(new Error('new token matches current token'));\n }\n\n if (this.previousToken) {\n this.previousToken.revoke();\n this.unset('previousToken');\n }\n\n obj.previousToken = this;\n obj.scope = this.scope;\n\n return new Token(obj, {parent: this.parent});\n })\n .catch(processGrantError);\n },\n\n @oneFlight\n /**\n * Revokes this token and unsets its local properties\n * @instance\n * @memberof Token\n * @returns {Promise}\n */\n revoke() {\n if (this.isExpired) {\n this.logger.info('token: already expired, not making making revocation request');\n\n return Promise.resolve();\n }\n\n if (!this.canAuthorize) {\n this.logger.info('token: no longer valid, not making revocation request');\n\n return Promise.resolve();\n }\n\n // FIXME we need to use the user token revocation endpoint to revoke a token\n // without a client_secret, but it doesn't current support using a token to\n // revoke itself\n // Note: I'm not making a canRevoke property because there should be changes\n // coming to the user token revocation endpoint that allow us to do this\n // correctly.\n if (!this.config.client_secret) {\n this.logger.info('token: no client secret available, not making revocation request');\n\n return Promise.resolve();\n }\n\n this.logger.info('token: revoking access token');\n\n return this.webex\n .request({\n method: 'POST',\n uri: this.config.revokeUrl,\n form: {\n token: this.access_token,\n token_type_hint: 'access_token',\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true,\n },\n shouldRefreshAccessToken: false,\n })\n .then(() => {\n this.unset(['access_token', 'expires', 'expires_in', 'token_type']);\n this.logger.info('token: access token revoked');\n })\n .catch(processGrantError);\n },\n\n set(...args) {\n // eslint-disable-next-line prefer-const\n let [attrs, options] = this._filterSetParameters(...args);\n\n if (!attrs.token_type && attrs.access_token && attrs.access_token.includes(' ')) {\n const [token_type, access_token] = attrs.access_token.split(' ');\n\n attrs = {...attrs, access_token, token_type};\n }\n const now = Date.now();\n\n if (!attrs.expires && attrs.expires_in) {\n attrs.expires = now + attrs.expires_in * 1000;\n }\n\n if (!attrs.refresh_token_expires && attrs.refresh_token_expires_in) {\n attrs.refresh_token_expires = now + attrs.refresh_token_expires_in * 1000;\n }\n\n if (attrs.scope) {\n attrs.scope = sortScope(attrs.scope);\n }\n\n return Reflect.apply(WebexPlugin.prototype.set, this, [attrs, options]);\n },\n\n /**\n * Renders the token object as an HTTP Header Value\n * @instance\n * @memberof Token\n * @returns {string}\n * @see {@link Object#toString()}\n */\n toString() {\n if (!this._string) {\n throw new Error('cannot stringify Token');\n }\n\n return this._string;\n },\n\n /**\n * Uses a non-producation api to return information about this token. This\n * method is primarily for tests and will throw if NODE_ENV === production\n * @instance\n * @memberof Token\n * @private\n * @returns {Promise}\n */\n validate() {\n if (process.env.NODE_ENV === 'production') {\n throw new Error('Token#validate() must not be used in production');\n }\n\n return this.webex\n .request({\n method: 'POST',\n service: 'conversation',\n resource: 'users/validateAuthToken',\n body: {\n token: this.access_token,\n },\n })\n .catch((reason) => {\n if ('statusCode' in reason) {\n return Promise.reject(reason);\n }\n this.logger.info(\"REMINDER: If you're investigating a network error here, it's normal\");\n\n // If we got an error that isn't a WebexHttpError, assume the problem is\n // that we don't have the wdm plugin loaded and service/resource isn't\n // a valid means of identifying a request.\n const convApi =\n process.env.CONVERSATION_SERVICE ||\n process.env.CONVERSATION_SERVICE_URL ||\n 'https://conv-a.wbx2.com/conversation/api/v1';\n\n return this.webex.request({\n method: 'POST',\n uri: `${convApi}/users/validateAuthToken`,\n body: {\n token: this.access_token,\n },\n headers: {\n authorization: `Bearer ${this.access_token}`,\n },\n });\n })\n .then((res) => res.body);\n },\n});\n\nexport default Token;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA;AACA;AAEA;AACA;AAEA;AACA;AAAuD;AAAA;AAAA;AAAA;AAAA;AAEvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAiB,CAACC,GAAG,EAAE;EAC9B,IAAIA,GAAG,CAACC,UAAU,KAAK,GAAG,EAAE;IAC1B,OAAO,iBAAQC,MAAM,CAACF,GAAG,CAAC;EAC5B;EAEA,IAAMG,gBAAgB,GAAGC,oBAAW,CAACC,MAAM,CAACL,GAAG,CAACM,IAAI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