@webex/webex-core 3.13.0-next.1 → 3.13.0-next.10
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/.repo-context.json +1 -1
- package/.sdd/manifest.json +14 -4
- package/AGENTS.md +2 -2
- package/README.md +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/credentials-config.js +9 -1
- package/dist/credentials-config.js.map +1 -1
- package/dist/interceptors/auth.js +10 -1
- package/dist/interceptors/auth.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +15 -2
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/token.js +23 -9
- package/dist/lib/credentials/token.js.map +1 -1
- package/dist/lib/interceptors/service.js +5 -1
- package/dist/lib/interceptors/service.js.map +1 -1
- package/dist/lib/services/catalog-auth.js +114 -0
- package/dist/lib/services/catalog-auth.js.map +1 -0
- package/dist/lib/services/services.js +46 -3
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +40 -3
- package/dist/lib/services-v2/services-v2.js.map +1 -1
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +2 -2
- package/dist/webex-core.js.map +1 -1
- package/docs/getting-started.md +2 -2
- package/package.json +13 -13
- package/src/config.js +1 -1
- package/src/credentials-config.js +9 -0
- package/src/interceptors/auth.js +14 -1
- package/src/lib/credentials/credentials.js +13 -1
- package/src/lib/credentials/docs/README.md +18 -17
- package/src/lib/credentials/token.js +15 -8
- package/src/lib/interceptors/service.js +11 -3
- package/src/lib/services/catalog-auth.js +112 -0
- package/src/lib/services/docs/README.md +4 -4
- package/src/lib/services/services.js +54 -2
- package/src/lib/services-v2/docs/README.md +4 -4
- package/src/lib/services-v2/services-v2.ts +48 -2
- package/test/fixtures/activation-email.ts +1 -1
- package/test/integration/spec/credentials/credentials.js +3 -1
- package/test/integration/spec/credentials/token.js +8 -0
- package/test/integration/spec/services/service-catalog.js +5 -0
- package/test/integration/spec/unit-browser/token.js +7 -2
- package/test/unit/spec/credentials/credentials.js +79 -0
- package/test/unit/spec/credentials/token.js +259 -6
- package/test/unit/spec/interceptors/auth.js +36 -1
- package/test/unit/spec/services/interceptors/service.js +35 -1
- package/test/unit/spec/services/services.js +318 -9
- package/test/unit/spec/services-v2/services-v2.ts +240 -13
|
@@ -13,8 +13,8 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
15
|
exports.default = void 0;
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
17
16
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
17
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
18
18
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/applyDecoratedDescriptor"));
|
|
19
19
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
20
20
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
|
|
@@ -264,8 +264,9 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
264
264
|
}
|
|
265
265
|
return _promise.default.reject(new Error('cannot downscope access token'));
|
|
266
266
|
}
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
var availableScope = this.scope || this.config.scope;
|
|
268
|
+
if ((0, _scope.diffScopes)(scope, availableScope) !== '') {
|
|
269
|
+
return _promise.default.reject(new Error("new scope (".concat(scope, ") is not subset of the available scopes (").concat(availableScope, ")")));
|
|
269
270
|
}
|
|
270
271
|
|
|
271
272
|
// Since we're going to use scope as the index in our token collection, it's
|
|
@@ -277,7 +278,7 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
277
278
|
// Ideally, we could depend on the service to communicate this error, but
|
|
278
279
|
// all we get is "invalid scope", which, to the lay person, implies
|
|
279
280
|
// something wrong with *one* of the scopes, not the whole thing.
|
|
280
|
-
if (scope === (0, _scope.sortScope)(
|
|
281
|
+
if (scope === (0, _scope.sortScope)(availableScope)) {
|
|
281
282
|
return _promise.default.reject(new Error('token: scope reduction requires a reduced scope'));
|
|
282
283
|
}
|
|
283
284
|
return this.webex.request({
|
|
@@ -338,10 +339,16 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
338
339
|
* {@link config.credentials.refreshCallback()}
|
|
339
340
|
* @instance
|
|
340
341
|
* @memberof Token
|
|
342
|
+
* @param {Object} [options={}]
|
|
343
|
+
* @param {string} [options.scope] Scope to request on refresh, if same or narrower than existing scope
|
|
344
|
+
* @param {string} [options.upgradeScope] Scope to request on refresh, if broader than existing scope
|
|
341
345
|
* @returns {Promise<Token>}
|
|
342
346
|
*/
|
|
343
347
|
refresh: function refresh() {
|
|
344
348
|
var _this3 = this;
|
|
349
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
350
|
+
scope = _ref.scope,
|
|
351
|
+
upgradeScope = _ref.upgradeScope;
|
|
345
352
|
if (!this.canRefresh) {
|
|
346
353
|
throw new Error('Not enough information available to refresh this access token');
|
|
347
354
|
}
|
|
@@ -350,16 +357,23 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
350
357
|
if (!this.config.refreshCallback) {
|
|
351
358
|
throw new Error('Cannot refresh access token without refreshCallback');
|
|
352
359
|
}
|
|
353
|
-
promise = _promise.default.resolve(this.config.refreshCallback(this.webex, this
|
|
360
|
+
promise = _promise.default.resolve(this.config.refreshCallback(this.webex, this, {
|
|
361
|
+
scope: scope,
|
|
362
|
+
upgradeScope: upgradeScope
|
|
363
|
+
}));
|
|
354
364
|
}
|
|
355
365
|
return (promise || this.webex.request({
|
|
356
366
|
method: 'POST',
|
|
357
367
|
uri: this.config.tokenUrl,
|
|
358
|
-
form: {
|
|
368
|
+
form: _objectSpread(_objectSpread({
|
|
359
369
|
grant_type: 'refresh_token',
|
|
360
370
|
redirect_uri: this.config.redirect_uri,
|
|
361
371
|
refresh_token: this.refresh_token
|
|
362
|
-
},
|
|
372
|
+
}, scope && {
|
|
373
|
+
scope: scope
|
|
374
|
+
}), upgradeScope && {
|
|
375
|
+
upgrade_scope: upgradeScope
|
|
376
|
+
}),
|
|
363
377
|
auth: {
|
|
364
378
|
user: this.config.client_id,
|
|
365
379
|
pass: this.config.client_secret,
|
|
@@ -395,7 +409,7 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
395
409
|
_this3.unset('previousToken');
|
|
396
410
|
}
|
|
397
411
|
obj.previousToken = _this3;
|
|
398
|
-
obj.scope = _this3.scope;
|
|
412
|
+
obj.scope = obj.scope || scope || _this3.scope;
|
|
399
413
|
return new Token(obj, {
|
|
400
414
|
parent: _this3.parent
|
|
401
415
|
});
|
|
@@ -532,7 +546,7 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
532
546
|
return res.body;
|
|
533
547
|
});
|
|
534
548
|
},
|
|
535
|
-
version: "3.13.0-next.
|
|
549
|
+
version: "3.13.0-next.10"
|
|
536
550
|
}, (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));
|
|
537
551
|
var _default = exports.default = Token;
|
|
538
552
|
//# sourceMappingURL=token.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_lodash","require","_common","_commonTimers","_webexHttpError","_interopRequireDefault","_webexPlugin","_scope","_grantErrors","_interopRequireWildcard","_dec","_obj","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","_typeof","has","get","set","_t","hasOwnProperty","call","_Object$defineProperty","_Object$getOwnPropertyDescriptor2","ownKeys","_Object$keys","_Object$getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","_Object$getOwnPropertyDescriptors","_Object$defineProperties","processGrantError","res","statusCode","_promise","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","concat","namespace","props","expires_in","refresh_token_expires","refresh_token_expires_in","type","session","previousToken","downscope","_this","logger","info","Error","trace","diffScopes","sortScope","webex","request","method","uri","tokenUrl","addAuthHeader","form","grant_type","token","self_contained_token","then","_assign","parent","initialize","_this2","attrs","undefined","options","_apply","prototype","_now","safeSetTimeout","refresh","_this3","promise","resolve","redirect_uri","auth","user","pass","sendImmediately","shouldRefreshAccessToken","obj","pick","process","env","NODE_ENV","revoke","unset","catch","_this4","revokeUrl","token_type_hint","_this$_filterSetParam","_filterSetParameters","_this$_filterSetParam2","_slicedToArray2","includes","_attrs$access_token$s","split","_attrs$access_token$s2","now","toString","validate","_this5","service","resource","reason","convApi","CONVERSATION_SERVICE","CONVERSATION_SERVICE_URL","headers","authorization","version","_applyDecoratedDescriptor2","_getOwnPropertyDescriptor","_default","exports"],"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":";;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAEA,IAAAG,eAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAC,uBAAA,CAAAR,OAAA;AAAuD,IAAAS,IAAA,EAAAC,IAAA;AAZvD;AACA;AACA;AAFA,SAAAF,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,QAAA,MAAAC,CAAA,OAAAD,QAAA,IAAAE,CAAA,OAAAF,QAAA,YAAAL,uBAAA,YAAAA,wBAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA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_interopRequireDefault","_webexPlugin","_scope","_grantErrors","_interopRequireWildcard","_dec","_obj","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","_typeof","has","get","set","_t","hasOwnProperty","call","_Object$defineProperty","_Object$getOwnPropertyDescriptor2","ownKeys","_Object$keys","_Object$getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","_Object$getOwnPropertyDescriptors","_Object$defineProperties","processGrantError","res","statusCode","_promise","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","concat","namespace","props","expires_in","refresh_token_expires","refresh_token_expires_in","type","session","previousToken","downscope","_this","logger","info","Error","trace","availableScope","diffScopes","sortScope","webex","request","method","uri","tokenUrl","addAuthHeader","form","grant_type","token","self_contained_token","then","_assign","parent","initialize","_this2","attrs","undefined","options","_apply","prototype","_now","safeSetTimeout","refresh","_this3","_ref","upgradeScope","promise","resolve","redirect_uri","upgrade_scope","auth","user","pass","sendImmediately","shouldRefreshAccessToken","obj","pick","process","env","NODE_ENV","revoke","unset","catch","_this4","revokeUrl","token_type_hint","_this$_filterSetParam","_filterSetParameters","_this$_filterSetParam2","_slicedToArray2","includes","_attrs$access_token$s","split","_attrs$access_token$s2","now","toString","validate","_this5","service","resource","reason","convApi","CONVERSATION_SERVICE","CONVERSATION_SERVICE_URL","headers","authorization","version","_applyDecoratedDescriptor2","_getOwnPropertyDescriptor","_default","exports"],"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 const availableScope = this.scope || this.config.scope;\n\n if (diffScopes(scope, availableScope) !== '') {\n return Promise.reject(\n new Error(`new scope (${scope}) is not subset of the available scopes (${availableScope})`)\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(availableScope)) {\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 * @param {Object} [options={}]\n * @param {string} [options.scope] Scope to request on refresh, if same or narrower than existing scope\n * @param {string} [options.upgradeScope] Scope to request on refresh, if broader than existing scope\n * @returns {Promise<Token>}\n */\n refresh({scope, upgradeScope} = {}) {\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(\n this.config.refreshCallback(this.webex, this, {scope, upgradeScope})\n );\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 ...(scope && {scope}),\n ...(upgradeScope && {upgrade_scope: upgradeScope}),\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 = obj.scope || 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":";;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAEA,IAAAG,eAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,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ACPC,aAAa,YAAAnF,MAAA,CAAY2E,MAAI,CAACzF,YAAY;QAC5C;MACF,CAAC,CAAC;IACJ,CAAC,CAAC,CACD0C,IAAI,CAAC,UAAChE,GAAG;MAAA,OAAKA,GAAG,CAACO,IAAI;IAAA,EAAC;EAC5B,CAAC;EAAAiH,OAAA;AACH,CAAC,MAAAC,0BAAA,CAAAnJ,OAAA,EAAAX,IAAA,gBAAAD,IAAA,OAAAgK,yBAAA,CAAApJ,OAAA,EAAAX,IAAA,gBAAAA,IAAA,OAAA8J,0BAAA,CAAAnJ,OAAA,EAAAX,IAAA,cA5OEoD,iBAAS,OAAA2G,yBAAA,CAAApJ,OAAA,EAAAX,IAAA,cAAAA,IAAA,OAAA8J,0BAAA,CAAAnJ,OAAA,EAAAX,IAAA,aA0FToD,iBAAS,OAAA2G,yBAAA,CAAApJ,OAAA,EAAAX,IAAA,aAAAA,IAAA,GAAAA,IAAA,CAkJX,CAAC;AAAC,IAAAgK,QAAA,GAAAC,OAAA,CAAAtJ,OAAA,GAEYsC,KAAK","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
14
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
15
15
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
16
16
|
var _httpCore = require("@webex/http-core");
|
|
17
|
+
var _catalogAuth = require("../services/catalog-auth");
|
|
17
18
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
18
19
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /*!
|
|
19
20
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
@@ -62,7 +63,10 @@ var ServiceInterceptor = exports.default = /*#__PURE__*/function (_Interceptor)
|
|
|
62
63
|
// Generate the combined service url and resource.
|
|
63
64
|
options.uri = _this.generateUri(serviceUrl, resource);
|
|
64
65
|
return options;
|
|
65
|
-
}).catch(function () {
|
|
66
|
+
}).catch(function (error) {
|
|
67
|
+
if (error && (0, _catalogAuth.isCatalogAuthReason)(error.reason)) {
|
|
68
|
+
return _promise.default.reject(error);
|
|
69
|
+
}
|
|
66
70
|
return _promise.default.reject(new Error("service-interceptor: '".concat(service, "' is not a known service")));
|
|
67
71
|
});
|
|
68
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_httpCore","require","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","_Reflect$construct","constructor","apply","Boolean","prototype","valueOf","call","trailingSlashes","ServiceInterceptor","exports","_Interceptor","_classCallCheck2","arguments","_inherits2","_createClass2","key","value","onRequest","options","_this","uri","normalizeOptions","validateOptions","services","webex","internal","service","resource","waitForServiceTimeout","waitForService","name","timeout","then","serviceUrl","generateUri","catch","_promise","reject","Error","concat","length","undefined","formattedService","replace","formattedResource","api","create","Interceptor"],"sources":["service.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\nconst trailingSlashes = /(?:^\\/)|(?:\\/$)/;\n\n/**\n * @class\n */\nexport default class ServiceInterceptor extends Interceptor {\n /**\n * @returns {ServiceInterceptor}\n */\n static create() {\n /* eslint no-invalid-this: [0] */\n return new ServiceInterceptor({webex: this});\n }\n\n /* eslint-disable no-param-reassign */\n /**\n * @see Interceptor#onRequest\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n onRequest(options) {\n // Validate that the PTO includes a uri property.\n if (options.uri) {\n return options;\n }\n\n // Normalize and validate the PTO.\n this.normalizeOptions(options);\n this.validateOptions(options);\n\n // Destructure commonly referenced namespaces.\n const {services} = this.webex.internal;\n const {service, resource, waitForServiceTimeout} = options;\n\n // Attempt to collect the service url.\n return services\n .waitForService({name: service, timeout: waitForServiceTimeout})\n .then((serviceUrl) => {\n // Generate the combined service url and resource.\n options.uri = this.generateUri(serviceUrl, resource);\n\n return options;\n })\n .catch(()
|
|
1
|
+
{"version":3,"names":["_httpCore","require","_catalogAuth","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","_Reflect$construct","constructor","apply","Boolean","prototype","valueOf","call","trailingSlashes","ServiceInterceptor","exports","_Interceptor","_classCallCheck2","arguments","_inherits2","_createClass2","key","value","onRequest","options","_this","uri","normalizeOptions","validateOptions","services","webex","internal","service","resource","waitForServiceTimeout","waitForService","name","timeout","then","serviceUrl","generateUri","catch","error","isCatalogAuthReason","reason","_promise","reject","Error","concat","length","undefined","formattedService","replace","formattedResource","api","create","Interceptor"],"sources":["service.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\nimport {isCatalogAuthReason} from '../services/catalog-auth';\n\nconst trailingSlashes = /(?:^\\/)|(?:\\/$)/;\n\n/**\n * @class\n */\nexport default class ServiceInterceptor extends Interceptor {\n /**\n * @returns {ServiceInterceptor}\n */\n static create() {\n /* eslint no-invalid-this: [0] */\n return new ServiceInterceptor({webex: this});\n }\n\n /* eslint-disable no-param-reassign */\n /**\n * @see Interceptor#onRequest\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n onRequest(options) {\n // Validate that the PTO includes a uri property.\n if (options.uri) {\n return options;\n }\n\n // Normalize and validate the PTO.\n this.normalizeOptions(options);\n this.validateOptions(options);\n\n // Destructure commonly referenced namespaces.\n const {services} = this.webex.internal;\n const {service, resource, waitForServiceTimeout} = options;\n\n // Attempt to collect the service url.\n return services\n .waitForService({name: service, timeout: waitForServiceTimeout})\n .then((serviceUrl) => {\n // Generate the combined service url and resource.\n options.uri = this.generateUri(serviceUrl, resource);\n\n return options;\n })\n .catch((error) => {\n if (error && isCatalogAuthReason(error.reason)) {\n return Promise.reject(error);\n }\n\n return Promise.reject(\n new Error(`service-interceptor: '${service}' is not a known service`)\n );\n });\n }\n\n /* eslint-disable class-methods-use-this */\n /**\n * Generate a usable request uri string from a service url and a resouce.\n *\n * @param {string} serviceUrl - The service url.\n * @param {string} [resource] - The resouce to be appended to the service url.\n * @returns {string} - The combined service url and resource.\n */\n generateUri(serviceUrl, resource = '') {\n const formattedService = serviceUrl.replace(trailingSlashes, '');\n const formattedResource = resource.replace(trailingSlashes, '');\n\n return `${formattedService}/${formattedResource}`;\n }\n\n /**\n * Normalizes request options relative to service identification.\n *\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n normalizeOptions(options) {\n // Validate if the api property is used.\n if (options.api) {\n // Assign the service property the value of the api property if necessary.\n options.service = options.service || options.api;\n delete options.api;\n }\n }\n\n /**\n * Validates that the appropriate options for this interceptor are present.\n *\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n validateOptions(options) {\n if (!options.resource) {\n throw new Error('a `resource` parameter is required');\n }\n\n if (!options.service) {\n throw new Error(\"a valid 'service' parameter is required\");\n }\n }\n /* eslint-enable class-methods-use-this, no-param-reassign */\n}\n"],"mappings":";;;;;;;;;;;;;;;AAIA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAA6D,SAAAE,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,CAAAC,OAAA,EAAAH,CAAA,OAAAI,2BAAA,CAAAD,OAAA,EAAAJ,CAAA,EAAAM,yBAAA,KAAAC,kBAAA,CAAAN,CAAA,EAAAC,CAAA,YAAAC,gB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B;IACF;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAAjC,GAAA;IAAAC,KAAA,EAMA,SAAAM,eAAeA,CAACJ,OAAO,EAAE;MACvB,IAAI,CAACA,OAAO,CAACS,QAAQ,EAAE;QACrB,MAAM,IAAIc,KAAK,CAAC,oCAAoC,CAAC;MACvD;MAEA,IAAI,CAACvB,OAAO,CAACQ,OAAO,EAAE;QACpB,MAAM,IAAIe,KAAK,CAAC,yCAAyC,CAAC;MAC5D;IACF;IACA;EAAA;IAAA1B,GAAA;IAAAC,KAAA;IA7FA;AACF;AACA;IACE,SAAOiC,MAAMA,CAAA,EAAG;MACd;MACA,OAAO,IAAIzC,kBAAkB,CAAC;QAACgB,KAAK,EAAE;MAAI,CAAC,CAAC;IAC9C;EAAC;AAAA,EAP6C0B,qBAAW","ignoreList":[]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.INVALID_ACCESS_TOKEN = exports.ACCESS_DENIED = void 0;
|
|
9
|
+
exports.classifyCatalogAuthFailure = classifyCatalogAuthFailure;
|
|
10
|
+
exports.clearCatalogAuthFailure = clearCatalogAuthFailure;
|
|
11
|
+
exports.getCatalogAuthFailure = getCatalogAuthFailure;
|
|
12
|
+
exports.isCatalogAuthReason = isCatalogAuthReason;
|
|
13
|
+
exports.isWrappedCatalogAuthFailure = isWrappedCatalogAuthFailure;
|
|
14
|
+
exports.recordCatalogAuthFailure = recordCatalogAuthFailure;
|
|
15
|
+
exports.serviceLookupError = serviceLookupError;
|
|
16
|
+
var _weakMap = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/weak-map"));
|
|
17
|
+
var _grantErrors = require("../credentials/grant-errors");
|
|
18
|
+
var INVALID_ACCESS_TOKEN = exports.INVALID_ACCESS_TOKEN = 'invalid_access_token';
|
|
19
|
+
var ACCESS_DENIED = exports.ACCESS_DENIED = 'access_denied';
|
|
20
|
+
var catalogAuthFailures = new _weakMap.default();
|
|
21
|
+
var catalogAuthReplayLimit = /^Failed after \d+ replay attempts$/;
|
|
22
|
+
var reasonByStatus = {
|
|
23
|
+
401: INVALID_ACCESS_TOKEN,
|
|
24
|
+
403: ACCESS_DENIED
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A catalog 401 can arrive as an OAuth refresh failure or the auth replay limit.
|
|
29
|
+
* @param {Error} error
|
|
30
|
+
* @returns {boolean}
|
|
31
|
+
*/
|
|
32
|
+
function isWrappedCatalogAuthFailure(error) {
|
|
33
|
+
return error instanceof _grantErrors.OAuthError || typeof (error === null || error === void 0 ? void 0 : error.message) === 'string' && catalogAuthReplayLimit.test(error.message);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {string} reason
|
|
38
|
+
* @returns {boolean}
|
|
39
|
+
*/
|
|
40
|
+
function isCatalogAuthReason(reason) {
|
|
41
|
+
return reason === INVALID_ACCESS_TOKEN || reason === ACCESS_DENIED;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Classify a postauth catalog failure.
|
|
46
|
+
* A result is stored. Null means any previously stored failure should be cleared.
|
|
47
|
+
* Network errors and HTTP 5xx stay null.
|
|
48
|
+
* @param {Error} error
|
|
49
|
+
* @returns {{status: number, reason: string}|null}
|
|
50
|
+
*/
|
|
51
|
+
function classifyCatalogAuthFailure(error) {
|
|
52
|
+
var status = error && (error.catalogAuthStatus || error.statusCode || error.status);
|
|
53
|
+
var reason = reasonByStatus[status];
|
|
54
|
+
if (reason) {
|
|
55
|
+
return {
|
|
56
|
+
status: status,
|
|
57
|
+
reason: reason
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (isWrappedCatalogAuthFailure(error)) {
|
|
61
|
+
return {
|
|
62
|
+
status: 401,
|
|
63
|
+
reason: INVALID_ACCESS_TOKEN
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {object} services
|
|
71
|
+
* @param {Error} error
|
|
72
|
+
* @returns {void}
|
|
73
|
+
*/
|
|
74
|
+
function recordCatalogAuthFailure(services, error) {
|
|
75
|
+
var authFailure = classifyCatalogAuthFailure(error);
|
|
76
|
+
if (authFailure) {
|
|
77
|
+
catalogAuthFailures.set(services, authFailure);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
catalogAuthFailures.delete(services);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {object} services
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
function clearCatalogAuthFailure(services) {
|
|
88
|
+
catalogAuthFailures.delete(services);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {object} services
|
|
93
|
+
* @returns {{status: number, reason: string}|null}
|
|
94
|
+
*/
|
|
95
|
+
function getCatalogAuthFailure(services) {
|
|
96
|
+
return catalogAuthFailures.get(services) || null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param {object} services
|
|
101
|
+
* @param {string} fallbackMessage
|
|
102
|
+
* @returns {Error}
|
|
103
|
+
*/
|
|
104
|
+
function serviceLookupError(services, fallbackMessage) {
|
|
105
|
+
var authFailure = getCatalogAuthFailure(services);
|
|
106
|
+
if (authFailure && isCatalogAuthReason(authFailure.reason)) {
|
|
107
|
+
var authError = new Error(authFailure.reason);
|
|
108
|
+
authError.reason = authFailure.reason;
|
|
109
|
+
authError.statusCode = authFailure.status;
|
|
110
|
+
return authError;
|
|
111
|
+
}
|
|
112
|
+
return new Error(fallbackMessage);
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=catalog-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_grantErrors","require","INVALID_ACCESS_TOKEN","exports","ACCESS_DENIED","catalogAuthFailures","_weakMap","default","catalogAuthReplayLimit","reasonByStatus","isWrappedCatalogAuthFailure","error","OAuthError","message","test","isCatalogAuthReason","reason","classifyCatalogAuthFailure","status","catalogAuthStatus","statusCode","recordCatalogAuthFailure","services","authFailure","set","delete","clearCatalogAuthFailure","getCatalogAuthFailure","get","serviceLookupError","fallbackMessage","authError","Error"],"sources":["catalog-auth.js"],"sourcesContent":["import {OAuthError} from '../credentials/grant-errors';\n\nexport const INVALID_ACCESS_TOKEN = 'invalid_access_token';\nexport const ACCESS_DENIED = 'access_denied';\n\nconst catalogAuthFailures = new WeakMap();\nconst catalogAuthReplayLimit = /^Failed after \\d+ replay attempts$/;\nconst reasonByStatus = {\n 401: INVALID_ACCESS_TOKEN,\n 403: ACCESS_DENIED,\n};\n\n/**\n * A catalog 401 can arrive as an OAuth refresh failure or the auth replay limit.\n * @param {Error} error\n * @returns {boolean}\n */\nexport function isWrappedCatalogAuthFailure(error) {\n return (\n error instanceof OAuthError ||\n (typeof error?.message === 'string' && catalogAuthReplayLimit.test(error.message))\n );\n}\n\n/**\n * @param {string} reason\n * @returns {boolean}\n */\nexport function isCatalogAuthReason(reason) {\n return reason === INVALID_ACCESS_TOKEN || reason === ACCESS_DENIED;\n}\n\n/**\n * Classify a postauth catalog failure.\n * A result is stored. Null means any previously stored failure should be cleared.\n * Network errors and HTTP 5xx stay null.\n * @param {Error} error\n * @returns {{status: number, reason: string}|null}\n */\nexport function classifyCatalogAuthFailure(error) {\n const status = error && (error.catalogAuthStatus || error.statusCode || error.status);\n const reason = reasonByStatus[status];\n\n if (reason) {\n return {\n status,\n reason,\n };\n }\n\n if (isWrappedCatalogAuthFailure(error)) {\n return {\n status: 401,\n reason: INVALID_ACCESS_TOKEN,\n };\n }\n\n return null;\n}\n\n/**\n * @param {object} services\n * @param {Error} error\n * @returns {void}\n */\nexport function recordCatalogAuthFailure(services, error) {\n const authFailure = classifyCatalogAuthFailure(error);\n\n if (authFailure) {\n catalogAuthFailures.set(services, authFailure);\n\n return;\n }\n\n catalogAuthFailures.delete(services);\n}\n\n/**\n * @param {object} services\n * @returns {void}\n */\nexport function clearCatalogAuthFailure(services) {\n catalogAuthFailures.delete(services);\n}\n\n/**\n * @param {object} services\n * @returns {{status: number, reason: string}|null}\n */\nexport function getCatalogAuthFailure(services) {\n return catalogAuthFailures.get(services) || null;\n}\n\n/**\n * @param {object} services\n * @param {string} fallbackMessage\n * @returns {Error}\n */\nexport function serviceLookupError(services, fallbackMessage) {\n const authFailure = getCatalogAuthFailure(services);\n\n if (authFailure && isCatalogAuthReason(authFailure.reason)) {\n const authError = new Error(authFailure.reason);\n\n authError.reason = authFailure.reason;\n authError.statusCode = authFailure.status;\n\n return authError;\n }\n\n return new Error(fallbackMessage);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,IAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,sBAAsB;AACnD,IAAME,aAAa,GAAAD,OAAA,CAAAC,aAAA,GAAG,eAAe;AAE5C,IAAMC,mBAAmB,GAAG,IAAAC,QAAA,CAAAC,OAAA,CAAY,CAAC;AACzC,IAAMC,sBAAsB,GAAG,oCAAoC;AACnE,IAAMC,cAAc,GAAG;EACrB,GAAG,EAAEP,oBAAoB;EACzB,GAAG,EAAEE;AACP,CAAC;;AAED;AACA;AACA;AACA;AACA;AACO,SAASM,2BAA2BA,CAACC,KAAK,EAAE;EACjD,OACEA,KAAK,YAAYC,uBAAU,IAC1B,QAAOD,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEE,OAAO,MAAK,QAAQ,IAAIL,sBAAsB,CAACM,IAAI,CAACH,KAAK,CAACE,OAAO,CAAE;AAEtF;;A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IAAMP,WAAW,GAAGI,qBAAqB,CAACL,QAAQ,CAAC;EAEnD,IAAIC,WAAW,IAAIR,mBAAmB,CAACQ,WAAW,CAACP,MAAM,CAAC,EAAE;IAC1D,IAAMe,SAAS,GAAG,IAAIC,KAAK,CAACT,WAAW,CAACP,MAAM,CAAC;IAE/Ce,SAAS,CAACf,MAAM,GAAGO,WAAW,CAACP,MAAM;IACrCe,SAAS,CAACX,UAAU,GAAGG,WAAW,CAACL,MAAM;IAEzC,OAAOa,SAAS;EAClB;EAEA,OAAO,IAAIC,KAAK,CAACF,eAAe,CAAC;AACnC","ignoreList":[]}
|
|
@@ -25,6 +25,7 @@ var _sha = _interopRequireDefault(require("crypto-js/sha256"));
|
|
|
25
25
|
var _lodash = require("lodash");
|
|
26
26
|
var _webexPlugin = _interopRequireDefault(require("../webex-plugin"));
|
|
27
27
|
var _metrics = _interopRequireDefault(require("../metrics"));
|
|
28
|
+
var _catalogAuth = require("./catalog-auth");
|
|
28
29
|
var _serviceCatalog = _interopRequireDefault(require("./service-catalog"));
|
|
29
30
|
var _serviceRegistry = _interopRequireDefault(require("./service-registry"));
|
|
30
31
|
var _serviceState = _interopRequireDefault(require("./service-state"));
|
|
@@ -122,6 +123,39 @@ var Services = _webexPlugin.default.extend({
|
|
|
122
123
|
_getCatalog: function _getCatalog() {
|
|
123
124
|
return this._catalogs.get(this.webex);
|
|
124
125
|
},
|
|
126
|
+
/**
|
|
127
|
+
* Remember a postauth catalog failure caused by HTTP 401 or 403.
|
|
128
|
+
* 401 means the access token was rejected. 403 means the token can be
|
|
129
|
+
* valid and the caller still has no access. A refresh or replay failure
|
|
130
|
+
* that replaced a catalog 401 is recorded as invalid_access_token.
|
|
131
|
+
* A refresh 403 keeps that original 401 on error.catalogAuthStatus.
|
|
132
|
+
* Other failures clear any previously stored auth failure.
|
|
133
|
+
*
|
|
134
|
+
* @private
|
|
135
|
+
* @param {Error} error
|
|
136
|
+
* @returns {void}
|
|
137
|
+
*/
|
|
138
|
+
_recordCatalogAuthFailure: function _recordCatalogAuthFailure(error) {
|
|
139
|
+
(0, _catalogAuth.recordCatalogAuthFailure)(this, error);
|
|
140
|
+
},
|
|
141
|
+
/**
|
|
142
|
+
* @private
|
|
143
|
+
* @returns {{status: number, reason: string}|null}
|
|
144
|
+
*/
|
|
145
|
+
_getCatalogAuthFailure: function _getCatalogAuthFailure() {
|
|
146
|
+
return (0, _catalogAuth.getCatalogAuthFailure)(this);
|
|
147
|
+
},
|
|
148
|
+
/**
|
|
149
|
+
* Build the rejection for a service that could not be resolved.
|
|
150
|
+
* A stored catalog auth failure replaces the generic not-found text.
|
|
151
|
+
*
|
|
152
|
+
* @private
|
|
153
|
+
* @param {string} fallbackMessage
|
|
154
|
+
* @returns {Error}
|
|
155
|
+
*/
|
|
156
|
+
_serviceLookupError: function _serviceLookupError(fallbackMessage) {
|
|
157
|
+
return (0, _catalogAuth.serviceLookupError)(this, fallbackMessage);
|
|
158
|
+
},
|
|
125
159
|
/**
|
|
126
160
|
* Safely access localStorage if available; returns the Storage or null.
|
|
127
161
|
* @returns {Storage|null}
|
|
@@ -392,8 +426,17 @@ var Services = _webexPlugin.default.extend({
|
|
|
392
426
|
catalog.updateServiceUrls(serviceGroup, formattedServiceHostMap);
|
|
393
427
|
_this.updateCredentialsConfig();
|
|
394
428
|
catalog.status[serviceGroup].collecting = false;
|
|
429
|
+
|
|
430
|
+
// A successful postauth catalog replaces any remembered 401/403.
|
|
431
|
+
// Preauth and signin updates leave that marker alone.
|
|
432
|
+
if (serviceGroup === 'postauth') {
|
|
433
|
+
(0, _catalogAuth.clearCatalogAuthFailure)(_this);
|
|
434
|
+
}
|
|
395
435
|
}).catch(function (error) {
|
|
396
436
|
catalog.status[serviceGroup].collecting = false;
|
|
437
|
+
if (serviceGroup === 'postauth') {
|
|
438
|
+
_this._recordCatalogAuthFailure(error);
|
|
439
|
+
}
|
|
397
440
|
return _promise.default.reject(error);
|
|
398
441
|
}));
|
|
399
442
|
case 7:
|
|
@@ -812,7 +855,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
812
855
|
service_name: name
|
|
813
856
|
}
|
|
814
857
|
});
|
|
815
|
-
return _promise.default.reject(
|
|
858
|
+
return _promise.default.reject(this._serviceLookupError("services: service '".concat(name, "' was not found in any of the catalogs")));
|
|
816
859
|
}
|
|
817
860
|
return new _promise.default(function (resolve, reject) {
|
|
818
861
|
var groupsToCheck = ['preauth', 'signin', 'postauth'];
|
|
@@ -835,7 +878,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
835
878
|
service_name: name
|
|
836
879
|
}
|
|
837
880
|
});
|
|
838
|
-
reject(
|
|
881
|
+
reject(_this6._serviceLookupError("services: service '".concat(name, "' was not found after waiting")));
|
|
839
882
|
});
|
|
840
883
|
});
|
|
841
884
|
},
|
|
@@ -1647,7 +1690,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1647
1690
|
}, _callee6);
|
|
1648
1691
|
})));
|
|
1649
1692
|
},
|
|
1650
|
-
version: "3.13.0-next.
|
|
1693
|
+
version: "3.13.0-next.10"
|
|
1651
1694
|
});
|
|
1652
1695
|
/* eslint-enable no-underscore-dangle */
|
|
1653
1696
|
var _default = exports.default = Services;
|