@webex/webex-core 3.0.0-beta.4 → 3.0.0-beta.400
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 +44 -64
- 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 +25 -57
- 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/constants.js +14 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/credentials/credentials.js +98 -139
- 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 +25 -14
- 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 +42 -118
- package/dist/lib/credentials/token.js.map +1 -1
- package/dist/lib/page.js +13 -26
- 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 +2 -23
- package/dist/lib/services/interceptors/server-error.js.map +1 -1
- package/dist/lib/services/interceptors/service.js +15 -35
- 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 +12 -91
- 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 +47 -62
- 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 +135 -239
- 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 +2 -16
- 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 +84 -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
- package/src/config.js +9 -11
- package/src/credentials-config.js +110 -72
- package/src/index.js +4 -14
- package/src/interceptors/auth.js +36 -37
- package/src/interceptors/default-options.js +0 -1
- package/src/interceptors/embargo.js +1 -1
- package/src/interceptors/payload-transformer.js +1 -2
- package/src/interceptors/rate-limit.js +8 -5
- package/src/interceptors/redirect.js +14 -8
- package/src/interceptors/request-event.js +4 -8
- package/src/interceptors/request-logger.js +8 -5
- package/src/interceptors/response-logger.js +11 -8
- package/src/interceptors/user-agent.js +1 -2
- package/src/interceptors/webex-user-agent.js +3 -9
- package/src/lib/batcher.js +70 -69
- package/src/lib/constants.js +6 -0
- package/src/lib/credentials/credentials.js +173 -141
- package/src/lib/credentials/grant-errors.js +6 -7
- package/src/lib/credentials/index.js +1 -4
- package/src/lib/credentials/scope.js +24 -8
- package/src/lib/credentials/token-collection.js +1 -1
- package/src/lib/credentials/token.js +95 -81
- package/src/lib/page.js +10 -11
- package/src/lib/services/constants.js +3 -13
- package/src/lib/services/index.js +2 -2
- package/src/lib/services/interceptors/server-error.js +12 -7
- package/src/lib/services/interceptors/service.js +7 -6
- package/src/lib/services/metrics.js +1 -1
- package/src/lib/services/service-catalog.js +112 -100
- package/src/lib/services/service-fed-ramp.js +1 -2
- package/src/lib/services/service-host.js +10 -17
- package/src/lib/services/service-registry.js +69 -96
- package/src/lib/services/service-state.js +4 -6
- package/src/lib/services/service-url.js +24 -23
- package/src/lib/services/services.js +272 -249
- package/src/lib/stateless-webex-plugin.js +4 -2
- package/src/lib/storage/decorators.js +68 -66
- package/src/lib/storage/index.js +4 -6
- package/src/lib/storage/make-webex-plugin-store.js +34 -21
- package/src/lib/storage/make-webex-store.js +6 -7
- package/src/lib/storage/memory-store-adapter.js +3 -3
- package/src/lib/webex-core-plugin-mixin.js +10 -7
- package/src/lib/webex-http-error.js +7 -8
- package/src/lib/webex-internal-core-plugin-mixin.js +9 -6
- package/src/lib/webex-plugin.js +41 -34
- package/src/plugins/logger.js +8 -3
- package/src/webex-core.js +198 -117
- package/src/webex-internal-core.js +15 -9
- package/test/integration/spec/credentials/credentials.js +26 -30
- package/test/integration/spec/credentials/token.js +36 -33
- package/test/integration/spec/services/service-catalog.js +177 -156
- package/test/integration/spec/services/services.js +313 -304
- package/test/integration/spec/webex-core.js +98 -86
- package/test/unit/spec/_setup.js +26 -18
- package/test/unit/spec/credentials/credentials.js +352 -162
- package/test/unit/spec/credentials/scope.js +80 -0
- package/test/unit/spec/credentials/token.js +105 -77
- package/test/unit/spec/interceptors/auth.js +294 -243
- package/test/unit/spec/interceptors/default-options.js +36 -24
- package/test/unit/spec/interceptors/embargo.js +32 -27
- package/test/unit/spec/interceptors/network-timing.js +2 -2
- package/test/unit/spec/interceptors/payload-transformer.js +61 -52
- package/test/unit/spec/interceptors/rate-limit.js +104 -75
- package/test/unit/spec/interceptors/redirect.js +22 -20
- package/test/unit/spec/interceptors/request-timing.js +18 -22
- package/test/unit/spec/interceptors/user-agent.js +28 -16
- package/test/unit/spec/interceptors/webex-tracking-id.js +14 -8
- package/test/unit/spec/interceptors/webex-user-agent.js +83 -37
- package/test/unit/spec/lib/batcher.js +36 -32
- package/test/unit/spec/lib/page.js +36 -32
- package/test/unit/spec/lib/webex-plugin.js +1 -1
- package/test/unit/spec/services/interceptors/server-error.js +67 -90
- package/test/unit/spec/services/interceptors/service.js +23 -28
- package/test/unit/spec/services/service-catalog.js +19 -27
- package/test/unit/spec/services/service-host.js +29 -26
- package/test/unit/spec/services/service-registry.js +128 -170
- package/test/unit/spec/services/service-state.js +13 -22
- package/test/unit/spec/services/service-url.js +24 -43
- package/test/unit/spec/services/services.js +147 -41
- package/test/unit/spec/storage/persist.js +6 -9
- package/test/unit/spec/storage/wait-for-value.js +22 -21
- package/test/unit/spec/webex-core.js +90 -57
- package/test/unit/spec/webex-internal-core.js +56 -31
|
@@ -1,55 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
8
|
-
|
|
4
|
+
var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
5
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
9
6
|
var _Object$getOwnPropertyDescriptor2 = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
10
|
-
|
|
7
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
8
|
+
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
9
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
10
|
+
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
11
11
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
12
|
-
|
|
13
12
|
_Object$defineProperty(exports, "__esModule", {
|
|
14
13
|
value: true
|
|
15
14
|
});
|
|
16
|
-
|
|
17
15
|
exports.default = void 0;
|
|
18
|
-
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
19
17
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
20
|
-
|
|
21
18
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/applyDecoratedDescriptor"));
|
|
22
|
-
|
|
23
19
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
24
|
-
|
|
25
20
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
|
|
26
|
-
|
|
27
21
|
var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
|
|
28
|
-
|
|
29
22
|
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
30
|
-
|
|
31
23
|
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor"));
|
|
32
|
-
|
|
33
24
|
var _pick2 = _interopRequireDefault(require("lodash/pick"));
|
|
34
|
-
|
|
35
25
|
var _common = require("@webex/common");
|
|
36
|
-
|
|
37
26
|
var _commonTimers = require("@webex/common-timers");
|
|
38
|
-
|
|
39
27
|
var _webexHttpError = _interopRequireDefault(require("../webex-http-error"));
|
|
40
|
-
|
|
41
28
|
var _webexPlugin = _interopRequireDefault(require("../webex-plugin"));
|
|
42
|
-
|
|
43
29
|
var _scope = require("./scope");
|
|
44
|
-
|
|
45
30
|
var _grantErrors = _interopRequireWildcard(require("./grant-errors"));
|
|
46
|
-
|
|
47
31
|
var _dec, _obj;
|
|
48
|
-
|
|
49
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); }
|
|
50
|
-
|
|
51
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; }
|
|
52
|
-
|
|
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; }
|
|
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; }
|
|
53
36
|
/* eslint-disable camelcase */
|
|
54
37
|
|
|
55
38
|
/**
|
|
@@ -62,24 +45,19 @@ function processGrantError(res) {
|
|
|
62
45
|
if (res.statusCode !== 400) {
|
|
63
46
|
return _promise.default.reject(res);
|
|
64
47
|
}
|
|
65
|
-
|
|
66
48
|
var ErrorConstructor = _grantErrors.default.select(res.body.error);
|
|
67
|
-
|
|
68
49
|
if (ErrorConstructor === _grantErrors.OAuthError && res instanceof _webexHttpError.default) {
|
|
69
50
|
return _promise.default.reject(res);
|
|
70
51
|
}
|
|
71
|
-
|
|
72
52
|
if (!ErrorConstructor) {
|
|
73
53
|
return _promise.default.reject(res);
|
|
74
54
|
}
|
|
75
|
-
|
|
76
55
|
return _promise.default.reject(new ErrorConstructor(res._res || res));
|
|
77
56
|
}
|
|
57
|
+
|
|
78
58
|
/**
|
|
79
59
|
* @class
|
|
80
60
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
61
|
var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
84
62
|
keyFactory: function keyFactory(scope) {
|
|
85
63
|
return scope;
|
|
@@ -101,7 +79,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
101
79
|
return !!this.access_token && !this.isExpired;
|
|
102
80
|
}
|
|
103
81
|
},
|
|
104
|
-
|
|
105
82
|
/**
|
|
106
83
|
* Indicates that this token can be downscoped. `true` iff
|
|
107
84
|
* {@link config.credentials.client_id} is defined and if
|
|
@@ -122,7 +99,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
122
99
|
return this.canAuthorize && !!this.config.client_id;
|
|
123
100
|
}
|
|
124
101
|
},
|
|
125
|
-
|
|
126
102
|
/**
|
|
127
103
|
* Indicates if this token can be refreshed. `true` iff
|
|
128
104
|
* {@link Token@refresh_token} is defined and
|
|
@@ -143,11 +119,9 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
143
119
|
if (_common.inBrowser) {
|
|
144
120
|
return !!this.refresh_token && !!this.config.refreshCallback;
|
|
145
121
|
}
|
|
146
|
-
|
|
147
122
|
return !!this.refresh_token && !!this.config.client_secret;
|
|
148
123
|
}
|
|
149
124
|
},
|
|
150
|
-
|
|
151
125
|
/**
|
|
152
126
|
* Indicates if this `Token` is expired. `true` iff {@link Token#expires} is
|
|
153
127
|
* defined and is less than {@link Date.now()}.
|
|
@@ -164,7 +138,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
164
138
|
return !!this.expires && this._isExpired;
|
|
165
139
|
}
|
|
166
140
|
},
|
|
167
|
-
|
|
168
141
|
/**
|
|
169
142
|
* Cache for toString()
|
|
170
143
|
* @instance
|
|
@@ -179,7 +152,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
179
152
|
if (!this.access_token || !this.token_type) {
|
|
180
153
|
return '';
|
|
181
154
|
}
|
|
182
|
-
|
|
183
155
|
return "".concat(this.token_type, " ").concat(this.access_token);
|
|
184
156
|
}
|
|
185
157
|
}
|
|
@@ -194,49 +166,42 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
194
166
|
* @type {string}
|
|
195
167
|
*/
|
|
196
168
|
scope: 'string',
|
|
197
|
-
|
|
198
169
|
/**
|
|
199
170
|
* @instance
|
|
200
171
|
* @memberof Token
|
|
201
172
|
* @type {string}
|
|
202
173
|
*/
|
|
203
174
|
access_token: 'string',
|
|
204
|
-
|
|
205
175
|
/**
|
|
206
176
|
* @instance
|
|
207
177
|
* @memberof Token
|
|
208
178
|
* @type {number}
|
|
209
179
|
*/
|
|
210
180
|
expires: 'number',
|
|
211
|
-
|
|
212
181
|
/**
|
|
213
182
|
* @instance
|
|
214
183
|
* @memberof Token
|
|
215
184
|
* @type {number}
|
|
216
185
|
*/
|
|
217
186
|
expires_in: 'number',
|
|
218
|
-
|
|
219
187
|
/**
|
|
220
188
|
* @instance
|
|
221
189
|
* @memberof Token
|
|
222
190
|
* @type {string}
|
|
223
191
|
*/
|
|
224
192
|
refresh_token: 'string',
|
|
225
|
-
|
|
226
193
|
/**
|
|
227
194
|
* @instance
|
|
228
195
|
* @memberof Token
|
|
229
196
|
* @type {number}
|
|
230
197
|
*/
|
|
231
198
|
refresh_token_expires: 'number',
|
|
232
|
-
|
|
233
199
|
/**
|
|
234
200
|
* @instance
|
|
235
201
|
* @memberof Token
|
|
236
202
|
* @type {number}
|
|
237
203
|
*/
|
|
238
204
|
refresh_token_expires_in: 'number',
|
|
239
|
-
|
|
240
205
|
/**
|
|
241
206
|
* @default "Bearer"
|
|
242
207
|
* @instance
|
|
@@ -260,7 +225,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
260
225
|
default: false,
|
|
261
226
|
type: 'boolean'
|
|
262
227
|
},
|
|
263
|
-
|
|
264
228
|
/**
|
|
265
229
|
* Handle to the previous token that we'll revoke when we refresh this
|
|
266
230
|
* token. The idea is to keep allow two valid tokens when a refresh occurs;
|
|
@@ -276,7 +240,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
276
240
|
type: 'state'
|
|
277
241
|
}
|
|
278
242
|
},
|
|
279
|
-
|
|
280
243
|
/**
|
|
281
244
|
* Uses this token to request a new Token with a subset of this Token's scopes
|
|
282
245
|
* @instance
|
|
@@ -286,37 +249,35 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
286
249
|
*/
|
|
287
250
|
downscope: function downscope(scope) {
|
|
288
251
|
var _this = this;
|
|
289
|
-
|
|
290
252
|
this.logger.info("token: downscoping token to ".concat(scope));
|
|
291
|
-
|
|
292
253
|
if (this.isExpired) {
|
|
293
254
|
this.logger.info('token: request received to downscope expired access_token');
|
|
294
255
|
return _promise.default.reject(new Error('cannot downscope expired access token'));
|
|
295
256
|
}
|
|
296
|
-
|
|
297
257
|
if (!this.canDownscope) {
|
|
298
258
|
if (this.config.client_id) {
|
|
299
259
|
this.logger.info('token: request received to downscope invalid access_token');
|
|
300
260
|
} else {
|
|
301
261
|
this.logger.trace('token: cannot downscope without client_id');
|
|
302
262
|
}
|
|
303
|
-
|
|
304
263
|
return _promise.default.reject(new Error('cannot downscope access token'));
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
264
|
+
}
|
|
265
|
+
if ((0, _scope.diffScopes)(scope, this.config.scope) !== '') {
|
|
266
|
+
return _promise.default.reject(new Error("new scope (".concat(scope, ") is not subset of the available scopes (").concat(this.config.scope, ")")));
|
|
267
|
+
}
|
|
308
268
|
|
|
269
|
+
// Since we're going to use scope as the index in our token collection, it's
|
|
270
|
+
// important scopes are always deterministically specified.
|
|
309
271
|
if (scope) {
|
|
310
272
|
scope = (0, _scope.sortScope)(scope);
|
|
311
|
-
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Ideally, we could depend on the service to communicate this error, but
|
|
312
276
|
// all we get is "invalid scope", which, to the lay person, implies
|
|
313
277
|
// something wrong with *one* of the scopes, not the whole thing.
|
|
314
|
-
|
|
315
|
-
|
|
316
278
|
if (scope === (0, _scope.sortScope)(this.config.scope)) {
|
|
317
279
|
return _promise.default.reject(new Error('token: scope reduction requires a reduced scope'));
|
|
318
280
|
}
|
|
319
|
-
|
|
320
281
|
return this.webex.request({
|
|
321
282
|
method: 'POST',
|
|
322
283
|
uri: this.config.tokenUrl,
|
|
@@ -330,7 +291,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
330
291
|
}
|
|
331
292
|
}).then(function (res) {
|
|
332
293
|
_this.logger.info("token: downscoped token to ".concat(scope));
|
|
333
|
-
|
|
334
294
|
return new Token((0, _assign.default)(res.body, {
|
|
335
295
|
scope: scope
|
|
336
296
|
}), {
|
|
@@ -338,7 +298,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
338
298
|
});
|
|
339
299
|
});
|
|
340
300
|
},
|
|
341
|
-
|
|
342
301
|
/**
|
|
343
302
|
* Initializer
|
|
344
303
|
* @instance
|
|
@@ -350,21 +309,18 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
350
309
|
*/
|
|
351
310
|
initialize: function initialize() {
|
|
352
311
|
var _this2 = this;
|
|
353
|
-
|
|
354
312
|
var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
355
313
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
356
314
|
(0, _apply.default)(_webexPlugin.default.prototype.initialize, this, [attrs, options]);
|
|
357
|
-
|
|
358
315
|
if (typeof attrs === 'string') {
|
|
359
316
|
this.access_token = attrs;
|
|
360
317
|
}
|
|
361
|
-
|
|
362
318
|
if (!this.access_token) {
|
|
363
319
|
throw new Error('`access_token` is required');
|
|
364
|
-
}
|
|
365
|
-
// we'll set up a timer the runs when this token should expire.
|
|
366
|
-
|
|
320
|
+
}
|
|
367
321
|
|
|
322
|
+
// We don't want the derived property `isExpired` to need {cache:false}, so
|
|
323
|
+
// we'll set up a timer the runs when this token should expire.
|
|
368
324
|
if (this.expires) {
|
|
369
325
|
if (this.expires < (0, _now.default)()) {
|
|
370
326
|
this._isExpired = true;
|
|
@@ -375,7 +331,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
375
331
|
}
|
|
376
332
|
}
|
|
377
333
|
},
|
|
378
|
-
|
|
379
334
|
/**
|
|
380
335
|
* Refreshes this Token. Relies on
|
|
381
336
|
* {@link config.credentials.refreshCallback()}
|
|
@@ -385,21 +340,16 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
385
340
|
*/
|
|
386
341
|
refresh: function refresh() {
|
|
387
342
|
var _this3 = this;
|
|
388
|
-
|
|
389
343
|
if (!this.canRefresh) {
|
|
390
344
|
throw new Error('Not enough information available to refresh this access token');
|
|
391
345
|
}
|
|
392
|
-
|
|
393
346
|
var promise;
|
|
394
|
-
|
|
395
347
|
if (_common.inBrowser) {
|
|
396
348
|
if (!this.config.refreshCallback) {
|
|
397
349
|
throw new Error('Cannot refresh access token without refreshCallback');
|
|
398
350
|
}
|
|
399
|
-
|
|
400
351
|
promise = _promise.default.resolve(this.config.refreshCallback(this.webex, this));
|
|
401
352
|
}
|
|
402
|
-
|
|
403
353
|
return (promise || this.webex.request({
|
|
404
354
|
method: 'POST',
|
|
405
355
|
uri: this.config.tokenUrl,
|
|
@@ -419,36 +369,29 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
419
369
|
})).then(function (obj) {
|
|
420
370
|
if (!obj) {
|
|
421
371
|
throw new Error('token: refreshCallback() did not produce an object');
|
|
422
|
-
}
|
|
372
|
+
}
|
|
373
|
+
// If the authentication server did not send back a refresh token, copy
|
|
423
374
|
// the current refresh token and related values to the response (note:
|
|
424
375
|
// at time of implementation, CI never sends a new refresh token)
|
|
425
|
-
|
|
426
|
-
|
|
427
376
|
if (!obj.refresh_token) {
|
|
428
377
|
(0, _assign.default)(obj, (0, _pick2.default)(_this3, 'refresh_token', 'refresh_token_expires', 'refresh_token_expires_in'));
|
|
429
|
-
}
|
|
430
|
-
// found a bug in CI; log the details and reject the Promise
|
|
431
|
-
|
|
378
|
+
}
|
|
432
379
|
|
|
380
|
+
// If the new token is the same as the previous token, then we may have
|
|
381
|
+
// found a bug in CI; log the details and reject the Promise
|
|
433
382
|
if (_this3.access_token === obj.access_token) {
|
|
434
|
-
_this3.logger.error('token: new token matches current token');
|
|
435
|
-
|
|
436
|
-
|
|
383
|
+
_this3.logger.error('token: new token matches current token');
|
|
384
|
+
// log the tokens if it is not production
|
|
437
385
|
if (process.env.NODE_ENV !== 'production') {
|
|
438
386
|
_this3.logger.error('token: current token:', _this3.access_token);
|
|
439
|
-
|
|
440
387
|
_this3.logger.error('token: new token:', obj.access_token);
|
|
441
388
|
}
|
|
442
|
-
|
|
443
389
|
return _promise.default.reject(new Error('new token matches current token'));
|
|
444
390
|
}
|
|
445
|
-
|
|
446
391
|
if (_this3.previousToken) {
|
|
447
392
|
_this3.previousToken.revoke();
|
|
448
|
-
|
|
449
393
|
_this3.unset('previousToken');
|
|
450
394
|
}
|
|
451
|
-
|
|
452
395
|
obj.previousToken = _this3;
|
|
453
396
|
obj.scope = _this3.scope;
|
|
454
397
|
return new Token(obj, {
|
|
@@ -456,7 +399,6 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
456
399
|
});
|
|
457
400
|
}).catch(processGrantError);
|
|
458
401
|
},
|
|
459
|
-
|
|
460
402
|
/**
|
|
461
403
|
* Revokes this token and unsets its local properties
|
|
462
404
|
* @instance
|
|
@@ -465,28 +407,25 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
465
407
|
*/
|
|
466
408
|
revoke: function revoke() {
|
|
467
409
|
var _this4 = this;
|
|
468
|
-
|
|
469
410
|
if (this.isExpired) {
|
|
470
411
|
this.logger.info('token: already expired, not making making revocation request');
|
|
471
412
|
return _promise.default.resolve();
|
|
472
413
|
}
|
|
473
|
-
|
|
474
414
|
if (!this.canAuthorize) {
|
|
475
415
|
this.logger.info('token: no longer valid, not making revocation request');
|
|
476
416
|
return _promise.default.resolve();
|
|
477
|
-
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// FIXME we need to use the user token revocation endpoint to revoke a token
|
|
478
420
|
// without a client_secret, but it doesn't current support using a token to
|
|
479
421
|
// revoke itself
|
|
480
422
|
// Note: I'm not making a canRevoke property because there should be changes
|
|
481
423
|
// coming to the user token revocation endpoint that allow us to do this
|
|
482
424
|
// correctly.
|
|
483
|
-
|
|
484
|
-
|
|
485
425
|
if (!this.config.client_secret) {
|
|
486
426
|
this.logger.info('token: no client secret available, not making revocation request');
|
|
487
427
|
return _promise.default.resolve();
|
|
488
428
|
}
|
|
489
|
-
|
|
490
429
|
this.logger.info('token: revoking access token');
|
|
491
430
|
return this.webex.request({
|
|
492
431
|
method: 'POST',
|
|
@@ -503,46 +442,37 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
503
442
|
shouldRefreshAccessToken: false
|
|
504
443
|
}).then(function () {
|
|
505
444
|
_this4.unset(['access_token', 'expires', 'expires_in', 'token_type']);
|
|
506
|
-
|
|
507
445
|
_this4.logger.info('token: access token revoked');
|
|
508
446
|
}).catch(processGrantError);
|
|
509
447
|
},
|
|
510
448
|
set: function set() {
|
|
511
449
|
// eslint-disable-next-line prefer-const
|
|
512
450
|
var _this$_filterSetParam = this._filterSetParameters.apply(this, arguments),
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
451
|
+
_this$_filterSetParam2 = (0, _slicedToArray2.default)(_this$_filterSetParam, 2),
|
|
452
|
+
attrs = _this$_filterSetParam2[0],
|
|
453
|
+
options = _this$_filterSetParam2[1];
|
|
517
454
|
if (!attrs.token_type && attrs.access_token && attrs.access_token.includes(' ')) {
|
|
518
455
|
var _attrs$access_token$s = attrs.access_token.split(' '),
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
attrs = (0, _assign.default)({}, attrs, {
|
|
456
|
+
_attrs$access_token$s2 = (0, _slicedToArray2.default)(_attrs$access_token$s, 2),
|
|
457
|
+
token_type = _attrs$access_token$s2[0],
|
|
458
|
+
access_token = _attrs$access_token$s2[1];
|
|
459
|
+
attrs = _objectSpread(_objectSpread({}, attrs), {}, {
|
|
524
460
|
access_token: access_token,
|
|
525
461
|
token_type: token_type
|
|
526
462
|
});
|
|
527
463
|
}
|
|
528
|
-
|
|
529
464
|
var now = (0, _now.default)();
|
|
530
|
-
|
|
531
465
|
if (!attrs.expires && attrs.expires_in) {
|
|
532
466
|
attrs.expires = now + attrs.expires_in * 1000;
|
|
533
467
|
}
|
|
534
|
-
|
|
535
468
|
if (!attrs.refresh_token_expires && attrs.refresh_token_expires_in) {
|
|
536
469
|
attrs.refresh_token_expires = now + attrs.refresh_token_expires_in * 1000;
|
|
537
470
|
}
|
|
538
|
-
|
|
539
471
|
if (attrs.scope) {
|
|
540
472
|
attrs.scope = (0, _scope.sortScope)(attrs.scope);
|
|
541
473
|
}
|
|
542
|
-
|
|
543
474
|
return (0, _apply.default)(_webexPlugin.default.prototype.set, this, [attrs, options]);
|
|
544
475
|
},
|
|
545
|
-
|
|
546
476
|
/**
|
|
547
477
|
* Renders the token object as an HTTP Header Value
|
|
548
478
|
* @instance
|
|
@@ -554,10 +484,8 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
554
484
|
if (!this._string) {
|
|
555
485
|
throw new Error('cannot stringify Token');
|
|
556
486
|
}
|
|
557
|
-
|
|
558
487
|
return this._string;
|
|
559
488
|
},
|
|
560
|
-
|
|
561
489
|
/**
|
|
562
490
|
* Uses a non-producation api to return information about this token. This
|
|
563
491
|
* method is primarily for tests and will throw if NODE_ENV === production
|
|
@@ -568,11 +496,9 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
568
496
|
*/
|
|
569
497
|
validate: function validate() {
|
|
570
498
|
var _this5 = this;
|
|
571
|
-
|
|
572
499
|
if (process.env.NODE_ENV === 'production') {
|
|
573
500
|
throw new Error('Token#validate() must not be used in production');
|
|
574
501
|
}
|
|
575
|
-
|
|
576
502
|
return this.webex.request({
|
|
577
503
|
method: 'POST',
|
|
578
504
|
service: 'conversation',
|
|
@@ -584,12 +510,11 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
584
510
|
if ('statusCode' in reason) {
|
|
585
511
|
return _promise.default.reject(reason);
|
|
586
512
|
}
|
|
513
|
+
_this5.logger.info("REMINDER: If you're investigating a network error here, it's normal");
|
|
587
514
|
|
|
588
|
-
|
|
515
|
+
// If we got an error that isn't a WebexHttpError, assume the problem is
|
|
589
516
|
// that we don't have the wdm plugin loaded and service/resource isn't
|
|
590
517
|
// a valid means of identifying a request.
|
|
591
|
-
|
|
592
|
-
|
|
593
518
|
var convApi = process.env.CONVERSATION_SERVICE || process.env.CONVERSATION_SERVICE_URL || 'https://conv-a.wbx2.com/conversation/api/v1';
|
|
594
519
|
return _this5.webex.request({
|
|
595
520
|
method: 'POST',
|
|
@@ -605,9 +530,8 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
605
530
|
return res.body;
|
|
606
531
|
});
|
|
607
532
|
},
|
|
608
|
-
version: "3.0.0-beta.
|
|
533
|
+
version: "3.0.0-beta.400"
|
|
609
534
|
}, ((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)));
|
|
610
|
-
|
|
611
535
|
var _default = Token;
|
|
612
536
|
exports.default = _default;
|
|
613
537
|
//# 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 }\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.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 }\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 (promise || this.webex.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 .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(obj, pick(this, 'refresh_token', 'refresh_token_expires', 'refresh_token_expires_in'));\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.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([\n 'access_token',\n 'expires',\n 'expires_in',\n 'token_type'\n ]);\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 = Object.assign({}, 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.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 = process.env.CONVERSATION_SERVICE || process.env.CONVERSATION_SERVICE_URL || '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,gBA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QACJoD,KAAK,EAAE,KAAKrC;MADR;IAJkB,CAAnB,EAQJ6D,KARI,CAQE,UAACY,MAAD,EAAY;MACjB,IAAI,gBAAgBA,MAApB,EAA4B;QAC1B,OAAO,iBAAQ5F,MAAR,CAAe4F,MAAf,CAAP;MACD;;MACD,MAAI,CAACjD,MAAL,CAAYC,IAAZ,CAAiB,uEAAjB,EAJiB,CAMjB;MACA;MACA;;;MACA,IAAMiD,OAAO,GAAGlB,OAAO,CAACC,GAAR,CAAYkB,oBAAZ,IAAoCnB,OAAO,CAACC,GAAR,CAAYmB,wBAAhD,IAA4E,6CAA5F;MAEA,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,CA7BI,EA8BJuC,IA9BI,CA8BC,UAAC5D,GAAD;MAAA,OAASA,GAAG,CAACM,IAAb;IAAA,CA9BD,CAAP;EA+BD,CA3f8B;EAAA;AAAA,CAAnB,kMA8RXQ,iBA9RW,4HA0WXA,iBA1WW,0EAAd;;eA8feH,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","diffScopes","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, diffScopes} 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 if (diffScopes(scope, this.config.scope) !== '') {\n return Promise.reject(\n new Error(\n `new scope (${scope}) is not subset of the available scopes (${this.config.scope})`\n )\n );\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;A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