@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.
Files changed (51) hide show
  1. package/.repo-context.json +1 -1
  2. package/.sdd/manifest.json +14 -4
  3. package/AGENTS.md +2 -2
  4. package/README.md +1 -1
  5. package/dist/config.js +1 -1
  6. package/dist/config.js.map +1 -1
  7. package/dist/credentials-config.js +9 -1
  8. package/dist/credentials-config.js.map +1 -1
  9. package/dist/interceptors/auth.js +10 -1
  10. package/dist/interceptors/auth.js.map +1 -1
  11. package/dist/lib/batcher.js +1 -1
  12. package/dist/lib/credentials/credentials.js +15 -2
  13. package/dist/lib/credentials/credentials.js.map +1 -1
  14. package/dist/lib/credentials/token.js +23 -9
  15. package/dist/lib/credentials/token.js.map +1 -1
  16. package/dist/lib/interceptors/service.js +5 -1
  17. package/dist/lib/interceptors/service.js.map +1 -1
  18. package/dist/lib/services/catalog-auth.js +114 -0
  19. package/dist/lib/services/catalog-auth.js.map +1 -0
  20. package/dist/lib/services/services.js +46 -3
  21. package/dist/lib/services/services.js.map +1 -1
  22. package/dist/lib/services-v2/services-v2.js +40 -3
  23. package/dist/lib/services-v2/services-v2.js.map +1 -1
  24. package/dist/plugins/logger.js +1 -1
  25. package/dist/webex-core.js +2 -2
  26. package/dist/webex-core.js.map +1 -1
  27. package/docs/getting-started.md +2 -2
  28. package/package.json +13 -13
  29. package/src/config.js +1 -1
  30. package/src/credentials-config.js +9 -0
  31. package/src/interceptors/auth.js +14 -1
  32. package/src/lib/credentials/credentials.js +13 -1
  33. package/src/lib/credentials/docs/README.md +18 -17
  34. package/src/lib/credentials/token.js +15 -8
  35. package/src/lib/interceptors/service.js +11 -3
  36. package/src/lib/services/catalog-auth.js +112 -0
  37. package/src/lib/services/docs/README.md +4 -4
  38. package/src/lib/services/services.js +54 -2
  39. package/src/lib/services-v2/docs/README.md +4 -4
  40. package/src/lib/services-v2/services-v2.ts +48 -2
  41. package/test/fixtures/activation-email.ts +1 -1
  42. package/test/integration/spec/credentials/credentials.js +3 -1
  43. package/test/integration/spec/credentials/token.js +8 -0
  44. package/test/integration/spec/services/service-catalog.js +5 -0
  45. package/test/integration/spec/unit-browser/token.js +7 -2
  46. package/test/unit/spec/credentials/credentials.js +79 -0
  47. package/test/unit/spec/credentials/token.js +259 -6
  48. package/test/unit/spec/interceptors/auth.js +36 -1
  49. package/test/unit/spec/services/interceptors/service.js +35 -1
  50. package/test/unit/spec/services/services.js +318 -9
  51. package/test/unit/spec/services-v2/services-v2.ts +240 -13
@@ -1 +1 @@
1
- {"version":3,"names":["_events","require","_util","_interopRequireDefault","_common","_httpCore","_lodash","_ampersandState","_uuid","_auth","_catalogUrl","_networkTiming","_payloadTransformer","_redirect","_requestEvent","_requestLogger","_requestTiming","_responseLogger","_webexHttpError","_userAgent","_proxy","_webexTrackingId","_webexUserAgent","_rateLimit","_embargo","_defaultOptions","_hostmap","_config","_storage","_webexCorePluginMixin","_webexInternalCorePluginMixin","_webexInternalCore","_obj","ownKeys","e","r","t","_Object$keys2","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor2","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","interceptors","WebexTrackingIdInterceptor","create","RequestEventInterceptor","RateLimitInterceptor","RequestLoggerInterceptor","process","env","ENABLE_NETWORK_LOGGING","ENABLE_VERBOSE_NETWORK_LOGGING","undefined","ResponseLoggerInterceptor","RequestTimingInterceptor","ServiceInterceptor","CatalogUrlInterceptor","UserAgentInterceptor","ProxyInterceptor","WebexUserAgentInterceptor","AuthInterceptor","KmsDryErrorInterceptor","PayloadTransformerInterceptor","ConversationInterceptor","RedirectInterceptor","HttpStatusInterceptor","error","WebexHttpError","NetworkTimingInterceptor","EmbargoInterceptor","DefaultOptionsInterceptor","HostMapInterceptor","preInterceptors","postInterceptors","MAX_FILE_SIZE_IN_MB","WebexCore","AmpState","extend","version","children","internal","WebexInternalCore","constructor","attrs","options","credentials","supertoken","access_token","path","val","get","unset","set","bearerValidator","trim","_apply","derived","boundedStorage","deps","fn","makeWebexStore","unboundedStorage","ready","_this","loaded","_keys","_children","reduce","name","session","config","type","request","setOnce","sessionId","refresh","_this$credentials","transform","direction","object","_this2","predicates","payloadTransformer","p","ctx","webex","_promise","all","map","test","then","shouldTransform","extract","target","data","d","Boolean","promise","_ref","alias","applyNamedTransform","resolve","_this3","_len","rest","Array","_key","isString","unshift","_len2","args","_key2","concat","transforms","tx","_ctx","last","getWindow","window","initialize","_this4","merge","trigger","onLoaded","stopListening","nextTick","listenToAndRun","onReady","prototype","key","listenTo","_len3","_key3","addInterceptor","ints","_this4$config$service","interceptorsObj","interceptor","isFunction","services","validateCatalogUrls","includes","requestDefaults","json","prepareFetchOptions","setTimingsAndFetch","_setTimingsAndFetch","uuid","v4","setConfig","newConfig","token","split","console","warn","replace","info","inspect","depth","util","omit","serialize","props","logout","_this5","_len4","_key4","refresh_token","_assign","onBeforeLogout","reverse","_ref2","plugin","catch","err","logger","clear","_this5$credentials","invalidate","_this5$authorization","authorization","measure","metrics","_this$metrics","sendUnstructured","upload","_this6","file","reject","Error","phases","finalize","defaultsDeep","method","body","uploadProtocol","withCredentials","headers","shunt","EventEmitter","_uploadPhaseInitialize","_uploadPhaseUpload","transferEvents","_len5","_key5","_uploadPhaseFinalize","res","proxyEvents","_this7","debug","_len6","_key6","fileUploadSizeLimitInBytes","fileUploadSizeLimit","currentFileSizeInBytes","byteLength","_uploadAbortSession","_uploadApplySession","response","_this8","url","abortErrorDetails","fileUploadSizeLimitInMB","message","_stringify","opts","phaseOptions","phaseKey","startsWith","substr","_deleteProperty","_this9","NODE_ENV","on","event","total","_this0","_applyDecoratedDescriptor2","retry","_getOwnPropertyDescriptor","mixinWebexInternalCorePlugins","mixinWebexCorePlugins","_default","exports","registerPlugin","registerInternalPlugin"],"sources":["webex-core.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {EventEmitter} from 'events';\nimport util from 'util';\n\nimport {proxyEvents, retry, transferEvents} from '@webex/common';\nimport {\n HttpStatusInterceptor,\n defaults as requestDefaults,\n protoprepareFetchOptions as prepareFetchOptions,\n setTimingsAndFetch as _setTimingsAndFetch,\n} from '@webex/http-core';\nimport {defaultsDeep, get, isFunction, isString, last, merge, omit, set, unset} from 'lodash';\nimport AmpState from 'ampersand-state';\nimport uuid from 'uuid';\n\nimport AuthInterceptor from './interceptors/auth';\nimport CatalogUrlInterceptor from './interceptors/catalog-url';\nimport NetworkTimingInterceptor from './interceptors/network-timing';\nimport PayloadTransformerInterceptor from './interceptors/payload-transformer';\nimport RedirectInterceptor from './interceptors/redirect';\nimport RequestEventInterceptor from './interceptors/request-event';\nimport RequestLoggerInterceptor from './interceptors/request-logger';\nimport RequestTimingInterceptor from './interceptors/request-timing';\nimport ResponseLoggerInterceptor from './interceptors/response-logger';\nimport WebexHttpError from './lib/webex-http-error';\nimport UserAgentInterceptor from './interceptors/user-agent';\nimport ProxyInterceptor from './interceptors/proxy';\nimport WebexTrackingIdInterceptor from './interceptors/webex-tracking-id';\nimport WebexUserAgentInterceptor from './interceptors/webex-user-agent';\nimport RateLimitInterceptor from './interceptors/rate-limit';\nimport EmbargoInterceptor from './interceptors/embargo';\nimport DefaultOptionsInterceptor from './interceptors/default-options';\nimport HostMapInterceptor from './lib/interceptors/hostmap';\nimport config from './config';\nimport {makeWebexStore} from './lib/storage';\nimport mixinWebexCorePlugins from './lib/webex-core-plugin-mixin';\nimport mixinWebexInternalCorePlugins from './lib/webex-internal-core-plugin-mixin';\nimport WebexInternalCore from './webex-internal-core';\n\n// TODO replace the Interceptor.create with Reflect.construct (\n// Interceptor.create exists because new was really hard to call on an array of\n// constructors)\nconst interceptors = {\n WebexTrackingIdInterceptor: WebexTrackingIdInterceptor.create,\n RequestEventInterceptor: RequestEventInterceptor.create,\n RateLimitInterceptor: RateLimitInterceptor.create,\n /* eslint-disable no-extra-parens */\n RequestLoggerInterceptor:\n process.env.ENABLE_NETWORK_LOGGING || process.env.ENABLE_VERBOSE_NETWORK_LOGGING\n ? RequestLoggerInterceptor.create\n : undefined,\n ResponseLoggerInterceptor:\n process.env.ENABLE_NETWORK_LOGGING || process.env.ENABLE_VERBOSE_NETWORK_LOGGING\n ? ResponseLoggerInterceptor.create\n : undefined,\n /* eslint-enable no-extra-parens */\n RequestTimingInterceptor: RequestTimingInterceptor.create,\n ServiceInterceptor: undefined,\n CatalogUrlInterceptor: CatalogUrlInterceptor.create,\n UserAgentInterceptor: UserAgentInterceptor.create,\n ProxyInterceptor: ProxyInterceptor.create,\n WebexUserAgentInterceptor: WebexUserAgentInterceptor.create,\n AuthInterceptor: AuthInterceptor.create,\n KmsDryErrorInterceptor: undefined,\n PayloadTransformerInterceptor: PayloadTransformerInterceptor.create,\n ConversationInterceptor: undefined,\n RedirectInterceptor: RedirectInterceptor.create,\n HttpStatusInterceptor() {\n return HttpStatusInterceptor.create({\n error: WebexHttpError,\n });\n },\n NetworkTimingInterceptor: NetworkTimingInterceptor.create,\n EmbargoInterceptor: EmbargoInterceptor.create,\n DefaultOptionsInterceptor: DefaultOptionsInterceptor.create,\n HostMapInterceptor: HostMapInterceptor.create,\n};\n\nconst preInterceptors = [\n 'ResponseLoggerInterceptor',\n 'RequestTimingInterceptor',\n 'RequestEventInterceptor',\n 'WebexTrackingIdInterceptor',\n 'RateLimitInterceptor',\n 'CatalogUrlInterceptor',\n];\n\nconst postInterceptors = [\n 'HttpStatusInterceptor',\n 'NetworkTimingInterceptor',\n 'EmbargoInterceptor',\n 'RequestLoggerInterceptor',\n 'RateLimitInterceptor',\n];\n\nconst MAX_FILE_SIZE_IN_MB = 2048;\n\n/**\n * @class\n */\nconst WebexCore = AmpState.extend({\n version: PACKAGE_VERSION,\n\n children: {\n internal: WebexInternalCore,\n },\n\n constructor(attrs = {}, options) {\n if (typeof attrs === 'string') {\n attrs = {\n credentials: {\n supertoken: {\n // eslint-disable-next-line camelcase\n access_token: attrs,\n },\n },\n };\n } else {\n // Reminder: order is important here\n [\n 'credentials.authorization',\n 'authorization',\n 'credentials.supertoken.supertoken',\n 'supertoken',\n 'access_token',\n 'credentials.authorization.supertoken',\n ].forEach((path) => {\n const val = get(attrs, path);\n\n if (val) {\n unset(attrs, path);\n set(attrs, 'credentials.supertoken', val);\n }\n });\n\n ['credentials', 'credentials.authorization'].forEach((path) => {\n const val = get(attrs, path);\n\n if (typeof val === 'string') {\n unset(attrs, path);\n set(attrs, 'credentials.supertoken', val);\n }\n });\n\n if (typeof get(attrs, 'credentials.access_token') === 'string') {\n // Send access_token to get validated and corrected and then set it\n set(\n attrs,\n 'credentials.access_token',\n this.bearerValidator(get(attrs, 'credentials.access_token').trim())\n );\n\n set(attrs, 'credentials.supertoken', attrs.credentials);\n }\n }\n\n return Reflect.apply(AmpState, this, [attrs, options]);\n },\n\n derived: {\n boundedStorage: {\n deps: [],\n fn() {\n return makeWebexStore('bounded', this);\n },\n },\n unboundedStorage: {\n deps: [],\n fn() {\n return makeWebexStore('unbounded', this);\n },\n },\n ready: {\n deps: ['loaded', 'internal.ready'],\n fn() {\n return (\n this.loaded &&\n Object.keys(this._children).reduce(\n (ready, name) => ready && this[name] && this[name].ready !== false,\n true\n )\n );\n },\n },\n },\n\n session: {\n config: {\n type: 'object',\n },\n /**\n * When true, indicates that the initial load from the storage layer is\n * complete\n * @instance\n * @memberof WebexCore\n * @type {boolean}\n */\n loaded: {\n default: false,\n type: 'boolean',\n },\n request: {\n setOnce: true,\n // It's supposed to be a function, but that's not a type defined in\n // Ampersand\n type: 'any',\n },\n sessionId: {\n type: 'string',\n },\n },\n\n /**\n * @instance\n * @memberof WebexCore\n * @param {[type]} args\n * @returns {[type]}\n */\n refresh(...args) {\n return this.credentials.refresh(...args);\n },\n\n /**\n * Applies the directionally appropriate transforms to the specified object\n * @param {string} direction\n * @param {Object} object\n * @returns {Promise}\n */\n transform(direction, object) {\n const predicates = this.config.payloadTransformer.predicates.filter(\n (p) => !p.direction || p.direction === direction\n );\n const ctx = {\n webex: this,\n };\n\n return Promise.all(\n predicates.map((p) =>\n p.test(ctx, object).then((shouldTransform) => {\n if (!shouldTransform) {\n return undefined;\n }\n\n return (\n p\n .extract(object)\n // eslint-disable-next-line max-nested-callbacks\n .then((target) => ({\n name: p.name,\n target,\n }))\n );\n })\n )\n )\n .then((data) =>\n data\n .filter((d) => Boolean(d))\n // eslint-disable-next-line max-nested-callbacks\n .reduce(\n (promise, {name, target, alias}) =>\n promise.then(() => {\n if (alias) {\n return this.applyNamedTransform(direction, alias, target);\n }\n\n return this.applyNamedTransform(direction, name, target);\n }),\n Promise.resolve()\n )\n )\n .then(() => object);\n },\n\n /**\n * Applies the directionally appropriate transform to the specified parameters\n * @param {string} direction\n * @param {Object} ctx\n * @param {string} name\n * @returns {Promise}\n */\n applyNamedTransform(direction, ctx, name, ...rest) {\n if (isString(ctx)) {\n rest.unshift(name);\n name = ctx;\n ctx = {\n webex: this,\n transform: (...args) => this.applyNamedTransform(direction, ctx, ...args),\n };\n }\n\n const transforms = ctx.webex.config.payloadTransformer.transforms.filter(\n (tx) => tx.name === name && (!tx.direction || tx.direction === direction)\n );\n\n // too many implicit returns on the same line is difficult to interpret\n // eslint-disable-next-line arrow-body-style\n return transforms\n .reduce(\n (promise, tx) =>\n promise.then(() => {\n if (tx.alias) {\n return ctx.transform(tx.alias, ...rest);\n }\n\n return Promise.resolve(tx.fn(ctx, ...rest));\n }),\n Promise.resolve()\n )\n .then(() => last(rest));\n },\n\n /**\n * @private\n * @returns {Window}\n */\n getWindow() {\n // eslint-disable-next-line\n return window;\n },\n\n /**\n * Initializer\n *\n * @emits WebexCore#loaded\n * @emits WebexCore#ready\n * @instance\n * @memberof WebexCore\n * @param {Object} attrs\n * @returns {WebexCore}\n */\n initialize(attrs = {}) {\n this.config = merge({}, config, attrs.config);\n\n // There's some unfortunateness with the way {@link AmpersandState#children}\n // get initialized. We'll fire the change:config event so that\n // {@link WebexPlugin#initialize()} can use\n // `this.listenToOnce(parent, 'change:config', () => {});` to act on config\n // during initialization\n this.trigger('change:config');\n\n const onLoaded = () => {\n if (this.loaded) {\n /**\n * Fires when all data has been loaded from the storage layer\n * @event loaded\n * @instance\n * @memberof WebexCore\n */\n this.trigger('loaded');\n\n this.stopListening(this, 'change:loaded', onLoaded);\n }\n };\n\n // This needs to run on nextTick or we'll never be able to wire up listeners\n process.nextTick(() => {\n this.listenToAndRun(this, 'change:loaded', onLoaded);\n });\n\n const onReady = () => {\n if (this.ready) {\n /**\n * Fires when all plugins have fully initialized\n * @event ready\n * @instance\n * @memberof WebexCore\n */\n this.trigger('ready');\n\n this.stopListening(this, 'change:ready', onReady);\n }\n };\n\n // This needs to run on nextTick or we'll never be able to wire up listeners\n process.nextTick(() => {\n this.listenToAndRun(this, 'change:ready', onReady);\n });\n\n // Make nested events propagate in a consistent manner\n Object.keys(this.constructor.prototype._children).forEach((key) => {\n this.listenTo(this[key], 'change', (...args) => {\n args.unshift(`change:${key}`);\n this.trigger(...args);\n });\n });\n\n const addInterceptor = (ints, key) => {\n const interceptorsObj = this.config.interceptors || interceptors;\n const interceptor = interceptorsObj[key];\n\n if (!isFunction(interceptor)) {\n return ints;\n }\n\n // CatalogUrlInterceptor is opt-in via config.services.validateCatalogUrls\n if (key === 'CatalogUrlInterceptor' && this.config.services?.validateCatalogUrls !== true) {\n return ints;\n }\n\n ints.push(Reflect.apply(interceptor, this, []));\n\n return ints;\n };\n\n let ints = [];\n\n if (this.config.interceptors) {\n Object.keys(this.config.interceptors).reduce(addInterceptor, ints);\n } else {\n ints = preInterceptors.reduce(addInterceptor, ints);\n ints = Object.keys(interceptors)\n .filter((key) => !(preInterceptors.includes(key) || postInterceptors.includes(key)))\n .reduce(addInterceptor, ints);\n ints = postInterceptors.reduce(addInterceptor, ints);\n }\n\n this.request = requestDefaults({\n json: true,\n interceptors: ints,\n });\n\n this.prepareFetchOptions = prepareFetchOptions({\n json: true,\n interceptors: ints,\n });\n\n this.setTimingsAndFetch = _setTimingsAndFetch;\n\n let sessionId = `${get(this, 'config.trackingIdPrefix', 'webex-js-sdk')}_${get(\n this,\n 'config.trackingIdBase',\n uuid.v4()\n )}`;\n\n if (get(this, 'config.trackingIdSuffix')) {\n sessionId += `_${get(this, 'config.trackingIdSuffix')}`;\n }\n\n this.sessionId = sessionId;\n },\n\n /**\n * setConfig\n *\n * Allows updating config\n *\n * @instance\n * @memberof WebexCore\n * @param {Object} newConfig\n * @returns {null}\n */\n setConfig(newConfig = {}) {\n this.config = merge({}, this.config, newConfig);\n },\n\n /**\n *\n * Check if access token is correctly formated and correct if it's not\n * Warn user if token string has errors in it\n * @param {string} token\n * @returns {string}\n */\n bearerValidator(token) {\n if (token.includes('Bearer') && token.split(' ').length - 1 === 0) {\n console.warn(\n `Your access token does not have a space between 'Bearer' and the token, please add a space to it or replace it with this already fixed version:\\n\\n${token\n .replace('Bearer', 'Bearer ')\n .replace(/\\s+/g, ' ')}`\n );\n console.info(\n \"Tip: You don't need to add 'Bearer' to the access_token field. The token by itself is fine\"\n );\n\n return token.replace('Bearer', 'Bearer ').replace(/\\s+/g, ' ');\n }\n // Allow elseIf return\n // eslint-disable-next-line no-else-return\n else if (token.split(' ').length - 1 > 1) {\n console.warn(\n `Your access token has ${\n token.split(' ').length - 2\n } too many spaces, please use this format:\\n\\n${token.replace(/\\s+/g, ' ')}`\n );\n console.info(\n \"Tip: You don't need to add 'Bearer' to the access_token field, the token by itself is fine\"\n );\n\n return token.replace(/\\s+/g, ' ');\n }\n\n return token.replace(/\\s+/g, ' '); // Clean it anyway (just in case)\n },\n\n /**\n * @instance\n * @memberof WebexPlugin\n * @param {number} depth\n * @private\n * @returns {Object}\n */\n inspect(depth) {\n return util.inspect(\n omit(\n this.serialize({\n props: true,\n session: true,\n derived: true,\n }),\n 'boundedStorage',\n 'unboundedStorage',\n 'request',\n 'config'\n ),\n {depth}\n );\n },\n\n /**\n * Invokes all `onBeforeLogout` handlers in the scope of their plugin, clears\n * all stores, and revokes the access token\n * Note: If you're using the sdk in a server environment, you may be more\n * interested in {@link `webex.internal.mercury.disconnect()`| Mercury#disconnect()}\n * and {@link `webex.internal.device.unregister()`|Device#unregister()}\n * or {@link `webex.phone.unregister()`|Phone#unregister}\n * @instance\n * @memberof WebexCore\n * @param {Object} options Passed as the first argument to all\n * `onBeforeLogout` handlers\n * @returns {Promise}\n */\n logout(options, ...rest) {\n // prefer the refresh token, but for clients that don't have one, fallback\n // to the access token\n const token =\n this.credentials.supertoken &&\n (this.credentials.supertoken.refresh_token || this.credentials.supertoken.access_token);\n\n options = Object.assign({token}, options);\n\n // onBeforeLogout should be executed in the opposite order in which handlers\n // were registered. In that way, wdm unregister() will be above mercury\n // disconnect(), but disconnect() will execute first.\n // eslint-disable-next-line arrow-body-style\n return this.config.onBeforeLogout\n .reverse()\n .reduce(\n (promise, {plugin, fn}) =>\n promise.then(() => {\n return (\n Promise.resolve(\n Reflect.apply(fn, this[plugin] || this.internal[plugin], [options, ...rest])\n )\n // eslint-disable-next-line max-nested-callbacks\n .catch((err) => {\n this.logger.warn(`onBeforeLogout from plugin ${plugin}: failed`, err);\n })\n );\n }),\n Promise.resolve()\n )\n .then(() => Promise.all([this.boundedStorage.clear(), this.unboundedStorage.clear()]))\n .then(() => this.credentials.invalidate(...rest))\n .then(\n () =>\n this.authorization &&\n this.authorization.logout &&\n this.authorization.logout(options, ...rest)\n )\n .then(() => this.trigger('client:logout'));\n },\n\n /**\n * General purpose wrapper to submit metrics via the metrics plugin (if the\n * metrics plugin is installed)\n * @instance\n * @memberof WebexCore\n * @returns {Promise}\n */\n measure(...args) {\n if (this.metrics) {\n return this.metrics.sendUnstructured(...args);\n }\n\n return Promise.resolve();\n },\n\n /**\n * Uploads a file provided in `file` property\n *\n * @param {Object} options\n * @returns {Promise}\n */\n upload(options) {\n if (!options || !options.file) {\n return Promise.reject(new Error('`options.file` is required'));\n }\n\n options.phases = options.phases || {};\n options.phases.initialize = options.phases.initialize || {};\n options.phases.upload = options.phases.upload || {};\n options.phases.finalize = options.phases.finalize || {};\n\n defaultsDeep(\n options.phases.initialize,\n {\n method: 'POST',\n body: {\n uploadProtocol: 'content-length',\n },\n },\n omit(options, 'file', 'phases')\n );\n\n defaultsDeep(options.phases.upload, {\n method: 'PUT',\n json: false,\n withCredentials: false,\n body: options.file,\n headers: {\n 'x-trans-id': uuid.v4(),\n authorization: undefined,\n },\n });\n\n defaultsDeep(\n options.phases.finalize,\n {\n method: 'POST',\n },\n omit(options, 'file', 'phases')\n );\n\n const shunt = new EventEmitter();\n\n const promise = this._uploadPhaseInitialize(options)\n .then(() => {\n const p = this._uploadPhaseUpload(options);\n\n transferEvents('progress', p, shunt);\n\n return p;\n })\n .then((...args) => this._uploadPhaseFinalize(options, ...args))\n .then((res) => ({...res.body, ...res.headers}));\n\n proxyEvents(shunt, promise);\n\n return promise;\n },\n\n _uploadPhaseInitialize: function _uploadPhaseInitialize(options) {\n this.logger.debug('client: initiating upload session');\n\n return this.request(options.phases.initialize)\n .then((...args) => {\n const fileUploadSizeLimitInBytes =\n (args[0].body.fileUploadSizeLimit || MAX_FILE_SIZE_IN_MB) * 1024 * 1024;\n const currentFileSizeInBytes = options.file.byteLength;\n\n if (fileUploadSizeLimitInBytes && fileUploadSizeLimitInBytes < currentFileSizeInBytes) {\n return this._uploadAbortSession(currentFileSizeInBytes, ...args);\n }\n\n return this._uploadApplySession(options, ...args);\n })\n .then((res) => {\n this.logger.debug('client: initiated upload session');\n\n return res;\n });\n },\n\n _uploadAbortSession(currentFileSizeInBytes, response) {\n this.logger.debug('client: deleting uploaded file');\n\n return this.request({\n method: 'DELETE',\n url: response.body.url,\n headers: response.options.headers,\n }).then(() => {\n this.logger.debug('client: deleting uploaded file complete');\n\n const abortErrorDetails = {\n currentFileSizeInBytes,\n fileUploadSizeLimitInMB: response.body.fileUploadSizeLimit || MAX_FILE_SIZE_IN_MB,\n message: 'file-upload-size-limit-enabled',\n };\n\n return Promise.reject(new Error(`${JSON.stringify(abortErrorDetails)}`));\n });\n },\n\n _uploadApplySession(options, res) {\n const session = res.body;\n\n ['upload', 'finalize'].reduce((opts, key) => {\n opts[key] = Object.keys(opts[key]).reduce((phaseOptions, phaseKey) => {\n if (phaseKey.startsWith('$')) {\n phaseOptions[phaseKey.substr(1)] = phaseOptions[phaseKey](session);\n Reflect.deleteProperty(phaseOptions, phaseKey);\n }\n\n return phaseOptions;\n }, opts[key]);\n\n return opts;\n }, options.phases);\n },\n\n @retry\n _uploadPhaseUpload(options) {\n this.logger.debug('client: uploading file');\n\n const promise = this.request(options.phases.upload).then((res) => {\n this.logger.debug('client: uploaded file');\n\n return res;\n });\n\n proxyEvents(options.phases.upload.upload, promise);\n\n /* istanbul ignore else */\n if (process.env.NODE_ENV === 'test') {\n promise.on('progress', (event) => {\n this.logger.info('upload progress', event.loaded, event.total);\n });\n }\n\n return promise;\n },\n\n _uploadPhaseFinalize: function _uploadPhaseFinalize(options) {\n this.logger.debug('client: finalizing upload session');\n\n return this.request(options.phases.finalize).then((res) => {\n this.logger.debug('client: finalized upload session');\n\n return res;\n });\n },\n});\n\nWebexCore.version = PACKAGE_VERSION;\n\nmixinWebexInternalCorePlugins(WebexInternalCore, config, interceptors);\nmixinWebexCorePlugins(WebexCore, config, interceptors);\n\nexport default WebexCore;\n\n/**\n * @method registerPlugin\n * @param {string} name\n * @param {function} constructor\n * @param {Object} options\n * @param {Array<string>} options.proxies\n * @param {Object} options.interceptors\n * @returns {null}\n */\nexport function registerPlugin(name, constructor, options = {}) {\n WebexCore.registerPlugin(name, constructor, options);\n}\n\n/**\n * Registers plugins used by internal products that do not talk to public APIs.\n * @method registerInternalPlugin\n * @param {string} name\n * @param {function} constructor\n * @param {Object} options\n * @param {Object} options.interceptors\n * @private\n * @returns {null}\n */\nexport function registerInternalPlugin(name, constructor, options) {\n WebexInternalCore.registerPlugin(name, constructor, options);\n}\n"],"mappings":";;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,IAAI,EAAE1B,WAAW,EAAgB;EAAA,IAAdE,OAAO,GAAAnD,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAmB,SAAA,GAAAnB,SAAA,MAAG,CAAC,CAAC;EAC5D0C,SAAS,CAACiN,cAAc,CAAChL,IAAI,EAAE1B,WAAW,EAAEE,OAAO,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASyM,sBAAsBA,CAACjL,IAAI,EAAE1B,WAAW,EAAEE,OAAO,EAAE;EACjEH,0BAAiB,CAAC2M,cAAc,CAAChL,IAAI,EAAE1B,WAAW,EAAEE,OAAO,CAAC;AAC9D","ignoreList":[]}
1
+ {"version":3,"names":["_events","require","_util","_interopRequireDefault","_common","_httpCore","_lodash","_ampersandState","_uuid","_auth","_catalogUrl","_networkTiming","_payloadTransformer","_redirect","_requestEvent","_requestLogger","_requestTiming","_responseLogger","_webexHttpError","_userAgent","_proxy","_webexTrackingId","_webexUserAgent","_rateLimit","_embargo","_defaultOptions","_hostmap","_config","_storage","_webexCorePluginMixin","_webexInternalCorePluginMixin","_webexInternalCore","_obj","ownKeys","e","r","t","_Object$keys2","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor2","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","interceptors","WebexTrackingIdInterceptor","create","RequestEventInterceptor","RateLimitInterceptor","RequestLoggerInterceptor","process","env","ENABLE_NETWORK_LOGGING","ENABLE_VERBOSE_NETWORK_LOGGING","undefined","ResponseLoggerInterceptor","RequestTimingInterceptor","ServiceInterceptor","CatalogUrlInterceptor","UserAgentInterceptor","ProxyInterceptor","WebexUserAgentInterceptor","AuthInterceptor","KmsDryErrorInterceptor","PayloadTransformerInterceptor","ConversationInterceptor","RedirectInterceptor","HttpStatusInterceptor","error","WebexHttpError","NetworkTimingInterceptor","EmbargoInterceptor","DefaultOptionsInterceptor","HostMapInterceptor","preInterceptors","postInterceptors","MAX_FILE_SIZE_IN_MB","WebexCore","AmpState","extend","version","children","internal","WebexInternalCore","constructor","attrs","options","credentials","supertoken","access_token","path","val","get","unset","set","bearerValidator","trim","_apply","derived","boundedStorage","deps","fn","makeWebexStore","unboundedStorage","ready","_this","loaded","_keys","_children","reduce","name","session","config","type","request","setOnce","sessionId","refresh","_this$credentials","transform","direction","object","_this2","predicates","payloadTransformer","p","ctx","webex","_promise","all","map","test","then","shouldTransform","extract","target","data","d","Boolean","promise","_ref","alias","applyNamedTransform","resolve","_this3","_len","rest","Array","_key","isString","unshift","_len2","args","_key2","concat","transforms","tx","_ctx","last","getWindow","window","initialize","_this4","merge","trigger","onLoaded","stopListening","nextTick","listenToAndRun","onReady","prototype","key","listenTo","_len3","_key3","addInterceptor","ints","_this4$config$service","interceptorsObj","interceptor","isFunction","services","validateCatalogUrls","includes","requestDefaults","json","prepareFetchOptions","setTimingsAndFetch","_setTimingsAndFetch","uuid","v4","setConfig","newConfig","token","split","console","warn","replace","info","inspect","depth","util","omit","serialize","props","logout","_this5","_len4","_key4","refresh_token","_assign","onBeforeLogout","reverse","_ref2","plugin","catch","err","logger","clear","_this5$credentials","invalidate","_this5$authorization","authorization","measure","metrics","_this$metrics","sendUnstructured","upload","_this6","file","reject","Error","phases","finalize","defaultsDeep","method","body","uploadProtocol","withCredentials","headers","shunt","EventEmitter","_uploadPhaseInitialize","_uploadPhaseUpload","transferEvents","_len5","_key5","_uploadPhaseFinalize","res","proxyEvents","_this7","debug","_len6","_key6","fileUploadSizeLimitInBytes","fileUploadSizeLimit","currentFileSizeInBytes","byteLength","_uploadAbortSession","_uploadApplySession","response","_this8","url","abortErrorDetails","fileUploadSizeLimitInMB","message","_stringify","opts","phaseOptions","phaseKey","startsWith","substr","_deleteProperty","_this9","NODE_ENV","on","event","total","_this0","_applyDecoratedDescriptor2","retry","_getOwnPropertyDescriptor","mixinWebexInternalCorePlugins","mixinWebexCorePlugins","_default","exports","registerPlugin","registerInternalPlugin"],"sources":["webex-core.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {EventEmitter} from 'events';\nimport util from 'util';\n\nimport {proxyEvents, retry, transferEvents} from '@webex/common';\nimport {\n HttpStatusInterceptor,\n defaults as requestDefaults,\n protoprepareFetchOptions as prepareFetchOptions,\n setTimingsAndFetch as _setTimingsAndFetch,\n} from '@webex/http-core';\nimport {defaultsDeep, get, isFunction, isString, last, merge, omit, set, unset} from 'lodash';\nimport AmpState from 'ampersand-state';\nimport uuid from 'uuid';\n\nimport AuthInterceptor from './interceptors/auth';\nimport CatalogUrlInterceptor from './interceptors/catalog-url';\nimport NetworkTimingInterceptor from './interceptors/network-timing';\nimport PayloadTransformerInterceptor from './interceptors/payload-transformer';\nimport RedirectInterceptor from './interceptors/redirect';\nimport RequestEventInterceptor from './interceptors/request-event';\nimport RequestLoggerInterceptor from './interceptors/request-logger';\nimport RequestTimingInterceptor from './interceptors/request-timing';\nimport ResponseLoggerInterceptor from './interceptors/response-logger';\nimport WebexHttpError from './lib/webex-http-error';\nimport UserAgentInterceptor from './interceptors/user-agent';\nimport ProxyInterceptor from './interceptors/proxy';\nimport WebexTrackingIdInterceptor from './interceptors/webex-tracking-id';\nimport WebexUserAgentInterceptor from './interceptors/webex-user-agent';\nimport RateLimitInterceptor from './interceptors/rate-limit';\nimport EmbargoInterceptor from './interceptors/embargo';\nimport DefaultOptionsInterceptor from './interceptors/default-options';\nimport HostMapInterceptor from './lib/interceptors/hostmap';\nimport config from './config';\nimport {makeWebexStore} from './lib/storage';\nimport mixinWebexCorePlugins from './lib/webex-core-plugin-mixin';\nimport mixinWebexInternalCorePlugins from './lib/webex-internal-core-plugin-mixin';\nimport WebexInternalCore from './webex-internal-core';\n\n// TODO replace the Interceptor.create with Reflect.construct (\n// Interceptor.create exists because new was really hard to call on an array of\n// constructors)\nconst interceptors = {\n WebexTrackingIdInterceptor: WebexTrackingIdInterceptor.create,\n RequestEventInterceptor: RequestEventInterceptor.create,\n RateLimitInterceptor: RateLimitInterceptor.create,\n /* eslint-disable no-extra-parens */\n RequestLoggerInterceptor:\n process.env.ENABLE_NETWORK_LOGGING || process.env.ENABLE_VERBOSE_NETWORK_LOGGING\n ? RequestLoggerInterceptor.create\n : undefined,\n ResponseLoggerInterceptor:\n process.env.ENABLE_NETWORK_LOGGING || process.env.ENABLE_VERBOSE_NETWORK_LOGGING\n ? ResponseLoggerInterceptor.create\n : undefined,\n /* eslint-enable no-extra-parens */\n RequestTimingInterceptor: RequestTimingInterceptor.create,\n ServiceInterceptor: undefined,\n CatalogUrlInterceptor: CatalogUrlInterceptor.create,\n UserAgentInterceptor: UserAgentInterceptor.create,\n ProxyInterceptor: ProxyInterceptor.create,\n WebexUserAgentInterceptor: WebexUserAgentInterceptor.create,\n AuthInterceptor: AuthInterceptor.create,\n KmsDryErrorInterceptor: undefined,\n PayloadTransformerInterceptor: PayloadTransformerInterceptor.create,\n ConversationInterceptor: undefined,\n RedirectInterceptor: RedirectInterceptor.create,\n HttpStatusInterceptor() {\n return HttpStatusInterceptor.create({\n error: WebexHttpError,\n });\n },\n NetworkTimingInterceptor: NetworkTimingInterceptor.create,\n EmbargoInterceptor: EmbargoInterceptor.create,\n DefaultOptionsInterceptor: DefaultOptionsInterceptor.create,\n HostMapInterceptor: HostMapInterceptor.create,\n};\n\nconst preInterceptors = [\n 'ResponseLoggerInterceptor',\n 'RequestTimingInterceptor',\n 'RequestEventInterceptor',\n 'WebexTrackingIdInterceptor',\n 'RateLimitInterceptor',\n 'CatalogUrlInterceptor',\n];\n\nconst postInterceptors = [\n 'HttpStatusInterceptor',\n 'NetworkTimingInterceptor',\n 'EmbargoInterceptor',\n 'RequestLoggerInterceptor',\n 'RateLimitInterceptor',\n];\n\nconst MAX_FILE_SIZE_IN_MB = 2048;\n\n/**\n * @class\n */\nconst WebexCore = AmpState.extend({\n version: PACKAGE_VERSION,\n\n children: {\n internal: WebexInternalCore,\n },\n\n constructor(attrs = {}, options) {\n if (typeof attrs === 'string') {\n attrs = {\n credentials: {\n supertoken: {\n // eslint-disable-next-line camelcase\n access_token: attrs,\n },\n },\n };\n } else {\n // Reminder: order is important here\n [\n 'credentials.authorization',\n 'authorization',\n 'credentials.supertoken.supertoken',\n 'supertoken',\n 'access_token',\n 'credentials.authorization.supertoken',\n ].forEach((path) => {\n const val = get(attrs, path);\n\n if (val) {\n unset(attrs, path);\n set(attrs, 'credentials.supertoken', val);\n }\n });\n\n ['credentials', 'credentials.authorization'].forEach((path) => {\n const val = get(attrs, path);\n\n if (typeof val === 'string') {\n unset(attrs, path);\n set(attrs, 'credentials.supertoken', val);\n }\n });\n\n if (typeof get(attrs, 'credentials.access_token') === 'string') {\n // Send access_token to get validated and corrected and then set it\n set(\n attrs,\n 'credentials.access_token',\n this.bearerValidator(get(attrs, 'credentials.access_token').trim())\n );\n\n set(attrs, 'credentials.supertoken', attrs.credentials);\n }\n }\n\n return Reflect.apply(AmpState, this, [attrs, options]);\n },\n\n derived: {\n boundedStorage: {\n deps: [],\n fn() {\n return makeWebexStore('bounded', this);\n },\n },\n unboundedStorage: {\n deps: [],\n fn() {\n return makeWebexStore('unbounded', this);\n },\n },\n ready: {\n deps: ['loaded', 'internal.ready'],\n fn() {\n return (\n this.loaded &&\n Object.keys(this._children).reduce(\n (ready, name) => ready && this[name] && this[name].ready !== false,\n true\n )\n );\n },\n },\n },\n\n session: {\n config: {\n type: 'object',\n },\n /**\n * When true, indicates that the initial load from the storage layer is\n * complete\n * @instance\n * @memberof WebexCore\n * @type {boolean}\n */\n loaded: {\n default: false,\n type: 'boolean',\n },\n request: {\n setOnce: true,\n // It's supposed to be a function, but that's not a type defined in\n // Ampersand\n type: 'any',\n },\n sessionId: {\n type: 'string',\n },\n },\n\n /**\n * @instance\n * @memberof WebexCore\n * @param {[type]} args\n * @returns {[type]}\n */\n refresh(...args) {\n return this.credentials.refresh(...args);\n },\n\n /**\n * Applies the directionally appropriate transforms to the specified object\n * @param {string} direction\n * @param {Object} object\n * @returns {Promise}\n */\n transform(direction, object) {\n const predicates = this.config.payloadTransformer.predicates.filter(\n (p) => !p.direction || p.direction === direction\n );\n const ctx = {\n webex: this,\n };\n\n return Promise.all(\n predicates.map((p) =>\n p.test(ctx, object).then((shouldTransform) => {\n if (!shouldTransform) {\n return undefined;\n }\n\n return (\n p\n .extract(object)\n // eslint-disable-next-line max-nested-callbacks\n .then((target) => ({\n name: p.name,\n target,\n }))\n );\n })\n )\n )\n .then((data) =>\n data\n .filter((d) => Boolean(d))\n // eslint-disable-next-line max-nested-callbacks\n .reduce(\n (promise, {name, target, alias}) =>\n promise.then(() => {\n if (alias) {\n return this.applyNamedTransform(direction, alias, target);\n }\n\n return this.applyNamedTransform(direction, name, target);\n }),\n Promise.resolve()\n )\n )\n .then(() => object);\n },\n\n /**\n * Applies the directionally appropriate transform to the specified parameters\n * @param {string} direction\n * @param {Object} ctx\n * @param {string} name\n * @returns {Promise}\n */\n applyNamedTransform(direction, ctx, name, ...rest) {\n if (isString(ctx)) {\n rest.unshift(name);\n name = ctx;\n ctx = {\n webex: this,\n transform: (...args) => this.applyNamedTransform(direction, ctx, ...args),\n };\n }\n\n const transforms = ctx.webex.config.payloadTransformer.transforms.filter(\n (tx) => tx.name === name && (!tx.direction || tx.direction === direction)\n );\n\n // too many implicit returns on the same line is difficult to interpret\n // eslint-disable-next-line arrow-body-style\n return transforms\n .reduce(\n (promise, tx) =>\n promise.then(() => {\n if (tx.alias) {\n return ctx.transform(tx.alias, ...rest);\n }\n\n return Promise.resolve(tx.fn(ctx, ...rest));\n }),\n Promise.resolve()\n )\n .then(() => last(rest));\n },\n\n /**\n * @private\n * @returns {Window}\n */\n getWindow() {\n // eslint-disable-next-line\n return window;\n },\n\n /**\n * Initializer\n *\n * @emits WebexCore#loaded\n * @emits WebexCore#ready\n * @instance\n * @memberof WebexCore\n * @param {Object} attrs\n * @returns {WebexCore}\n */\n initialize(attrs = {}) {\n this.config = merge({}, config, attrs.config);\n\n // There's some unfortunateness with the way {@link AmpersandState#children}\n // get initialized. We'll fire the change:config event so that\n // {@link WebexPlugin#initialize()} can use\n // `this.listenToOnce(parent, 'change:config', () => {});` to act on config\n // during initialization\n this.trigger('change:config');\n\n const onLoaded = () => {\n if (this.loaded) {\n /**\n * Fires when all data has been loaded from the storage layer\n * @event loaded\n * @instance\n * @memberof WebexCore\n */\n this.trigger('loaded');\n\n this.stopListening(this, 'change:loaded', onLoaded);\n }\n };\n\n // This needs to run on nextTick or we'll never be able to wire up listeners\n process.nextTick(() => {\n this.listenToAndRun(this, 'change:loaded', onLoaded);\n });\n\n const onReady = () => {\n if (this.ready) {\n /**\n * Fires when all plugins have fully initialized\n * @event ready\n * @instance\n * @memberof WebexCore\n */\n this.trigger('ready');\n\n this.stopListening(this, 'change:ready', onReady);\n }\n };\n\n // This needs to run on nextTick or we'll never be able to wire up listeners\n process.nextTick(() => {\n this.listenToAndRun(this, 'change:ready', onReady);\n });\n\n // Make nested events propagate in a consistent manner\n Object.keys(this.constructor.prototype._children).forEach((key) => {\n this.listenTo(this[key], 'change', (...args) => {\n args.unshift(`change:${key}`);\n this.trigger(...args);\n });\n });\n\n const addInterceptor = (ints, key) => {\n const interceptorsObj = this.config.interceptors || interceptors;\n const interceptor = interceptorsObj[key];\n\n if (!isFunction(interceptor)) {\n return ints;\n }\n\n // CatalogUrlInterceptor is opt-in via config.services.validateCatalogUrls\n if (key === 'CatalogUrlInterceptor' && this.config.services?.validateCatalogUrls !== true) {\n return ints;\n }\n\n ints.push(Reflect.apply(interceptor, this, []));\n\n return ints;\n };\n\n let ints = [];\n\n if (this.config.interceptors) {\n Object.keys(this.config.interceptors).reduce(addInterceptor, ints);\n } else {\n ints = preInterceptors.reduce(addInterceptor, ints);\n ints = Object.keys(interceptors)\n .filter((key) => !(preInterceptors.includes(key) || postInterceptors.includes(key)))\n .reduce(addInterceptor, ints);\n ints = postInterceptors.reduce(addInterceptor, ints);\n }\n\n this.request = requestDefaults({\n json: true,\n interceptors: ints,\n });\n\n this.prepareFetchOptions = prepareFetchOptions({\n json: true,\n interceptors: ints,\n });\n\n this.setTimingsAndFetch = _setTimingsAndFetch;\n\n let sessionId = `${get(this, 'config.trackingIdPrefix', 'webex-js-sdk')}_${get(\n this,\n 'config.trackingIdBase',\n uuid.v4()\n )}`;\n\n if (get(this, 'config.trackingIdSuffix')) {\n sessionId += `_${get(this, 'config.trackingIdSuffix')}`;\n }\n\n this.sessionId = sessionId;\n },\n\n /**\n * setConfig\n *\n * Allows updating config\n *\n * @instance\n * @memberof WebexCore\n * @param {Object} newConfig\n * @returns {null}\n */\n setConfig(newConfig = {}) {\n this.config = merge({}, this.config, newConfig);\n },\n\n /**\n *\n * Check if access token is correctly formated and correct if it's not\n * Warn user if token string has errors in it\n * @param {string} token\n * @returns {string}\n */\n bearerValidator(token) {\n if (token.includes('Bearer') && token.split(' ').length - 1 === 0) {\n console.warn(\n `Your access token does not have a space between 'Bearer' and the token, please add a space to it or replace it with this already fixed version:\\n\\n${token\n .replace('Bearer', 'Bearer ')\n .replace(/\\s+/g, ' ')}`\n );\n console.info(\n \"Tip: You don't need to add 'Bearer' to the access_token field. The token by itself is fine\"\n );\n\n return token.replace('Bearer', 'Bearer ').replace(/\\s+/g, ' ');\n }\n // Allow elseIf return\n // eslint-disable-next-line no-else-return\n else if (token.split(' ').length - 1 > 1) {\n console.warn(\n `Your access token has ${\n token.split(' ').length - 2\n } too many spaces, please use this format:\\n\\n${token.replace(/\\s+/g, ' ')}`\n );\n console.info(\n \"Tip: You don't need to add 'Bearer' to the access_token field, the token by itself is fine\"\n );\n\n return token.replace(/\\s+/g, ' ');\n }\n\n return token.replace(/\\s+/g, ' '); // Clean it anyway (just in case)\n },\n\n /**\n * @instance\n * @memberof WebexPlugin\n * @param {number} depth\n * @private\n * @returns {Object}\n */\n inspect(depth) {\n return util.inspect(\n omit(\n this.serialize({\n props: true,\n session: true,\n derived: true,\n }),\n 'boundedStorage',\n 'unboundedStorage',\n 'request',\n 'config'\n ),\n {depth}\n );\n },\n\n /**\n * Invokes all `onBeforeLogout` handlers in the scope of their plugin, clears\n * all stores, and revokes the access token\n * Note: If you're using the sdk in a server environment, you may be more\n * interested in {@link `webex.internal.mercury.disconnect()`| Mercury#disconnect()}\n * and {@link `webex.internal.device.unregister()`|Device#unregister()}\n * or {@link `webex.phone.unregister()`|Phone#unregister}\n * @instance\n * @memberof WebexCore\n * @param {Object} options Passed as the first argument to all\n * `onBeforeLogout` handlers\n * @returns {Promise}\n */\n logout(options, ...rest) {\n // prefer the refresh token, but for clients that don't have one, fallback\n // to the access token\n const token =\n this.credentials.supertoken &&\n (this.credentials.supertoken.refresh_token || this.credentials.supertoken.access_token);\n\n options = Object.assign({token}, options);\n\n // onBeforeLogout should be executed in the opposite order in which handlers\n // were registered. In that way, wdm unregister() will be above mercury\n // disconnect(), but disconnect() will execute first.\n // eslint-disable-next-line arrow-body-style\n return this.config.onBeforeLogout\n .reverse()\n .reduce(\n (promise, {plugin, fn}) =>\n promise.then(() => {\n return (\n Promise.resolve(\n Reflect.apply(fn, this[plugin] || this.internal[plugin], [options, ...rest])\n )\n // eslint-disable-next-line max-nested-callbacks\n .catch((err) => {\n this.logger.warn(`onBeforeLogout from plugin ${plugin}: failed`, err);\n })\n );\n }),\n Promise.resolve()\n )\n .then(() => Promise.all([this.boundedStorage.clear(), this.unboundedStorage.clear()]))\n .then(() => this.credentials.invalidate(...rest))\n .then(\n () =>\n this.authorization &&\n this.authorization.logout &&\n this.authorization.logout(options, ...rest)\n )\n .then(() => this.trigger('client:logout'));\n },\n\n /**\n * General purpose wrapper to submit metrics via the metrics plugin (if the\n * metrics plugin is installed)\n * @instance\n * @memberof WebexCore\n * @returns {Promise}\n */\n measure(...args) {\n if (this.metrics) {\n return this.metrics.sendUnstructured(...args);\n }\n\n return Promise.resolve();\n },\n\n /**\n * Uploads a file provided in `file` property\n *\n * @param {Object} options\n * @returns {Promise}\n */\n upload(options) {\n if (!options || !options.file) {\n return Promise.reject(new Error('`options.file` is required'));\n }\n\n options.phases = options.phases || {};\n options.phases.initialize = options.phases.initialize || {};\n options.phases.upload = options.phases.upload || {};\n options.phases.finalize = options.phases.finalize || {};\n\n defaultsDeep(\n options.phases.initialize,\n {\n method: 'POST',\n body: {\n uploadProtocol: 'content-length',\n },\n },\n omit(options, 'file', 'phases')\n );\n\n defaultsDeep(options.phases.upload, {\n method: 'PUT',\n json: false,\n withCredentials: false,\n body: options.file,\n headers: {\n 'x-trans-id': uuid.v4(),\n authorization: undefined,\n },\n });\n\n defaultsDeep(\n options.phases.finalize,\n {\n method: 'POST',\n },\n omit(options, 'file', 'phases')\n );\n\n const shunt = new EventEmitter();\n\n const promise = this._uploadPhaseInitialize(options)\n .then(() => {\n const p = this._uploadPhaseUpload(options);\n\n transferEvents('progress', p, shunt);\n\n return p;\n })\n .then((...args) => this._uploadPhaseFinalize(options, ...args))\n .then((res) => ({...res.body, ...res.headers}));\n\n proxyEvents(shunt, promise);\n\n return promise;\n },\n\n _uploadPhaseInitialize: function _uploadPhaseInitialize(options) {\n this.logger.debug('client: initiating upload session');\n\n return this.request(options.phases.initialize)\n .then((...args) => {\n const fileUploadSizeLimitInBytes =\n (args[0].body.fileUploadSizeLimit || MAX_FILE_SIZE_IN_MB) * 1024 * 1024;\n const currentFileSizeInBytes = options.file.byteLength;\n\n if (fileUploadSizeLimitInBytes && fileUploadSizeLimitInBytes < currentFileSizeInBytes) {\n return this._uploadAbortSession(currentFileSizeInBytes, ...args);\n }\n\n return this._uploadApplySession(options, ...args);\n })\n .then((res) => {\n this.logger.debug('client: initiated upload session');\n\n return res;\n });\n },\n\n _uploadAbortSession(currentFileSizeInBytes, response) {\n this.logger.debug('client: deleting uploaded file');\n\n return this.request({\n method: 'DELETE',\n url: response.body.url,\n headers: response.options.headers,\n }).then(() => {\n this.logger.debug('client: deleting uploaded file complete');\n\n const abortErrorDetails = {\n currentFileSizeInBytes,\n fileUploadSizeLimitInMB: response.body.fileUploadSizeLimit || MAX_FILE_SIZE_IN_MB,\n message: 'file-upload-size-limit-enabled',\n };\n\n return Promise.reject(new Error(`${JSON.stringify(abortErrorDetails)}`));\n });\n },\n\n _uploadApplySession(options, res) {\n const session = res.body;\n\n ['upload', 'finalize'].reduce((opts, key) => {\n opts[key] = Object.keys(opts[key]).reduce((phaseOptions, phaseKey) => {\n if (phaseKey.startsWith('$')) {\n phaseOptions[phaseKey.substr(1)] = phaseOptions[phaseKey](session);\n Reflect.deleteProperty(phaseOptions, phaseKey);\n }\n\n return phaseOptions;\n }, opts[key]);\n\n return opts;\n }, options.phases);\n },\n\n @retry\n _uploadPhaseUpload(options) {\n this.logger.debug('client: uploading file');\n\n const promise = this.request(options.phases.upload).then((res) => {\n this.logger.debug('client: uploaded file');\n\n return res;\n });\n\n proxyEvents(options.phases.upload.upload, promise);\n\n /* istanbul ignore else */\n if (process.env.NODE_ENV === 'test') {\n promise.on('progress', (event) => {\n this.logger.info('upload progress', event.loaded, event.total);\n });\n }\n\n return promise;\n },\n\n _uploadPhaseFinalize: function _uploadPhaseFinalize(options) {\n this.logger.debug('client: finalizing upload session');\n\n return this.request(options.phases.finalize).then((res) => {\n this.logger.debug('client: finalized upload session');\n\n return res;\n });\n },\n});\n\nWebexCore.version = PACKAGE_VERSION;\n\nmixinWebexInternalCorePlugins(WebexInternalCore, config, interceptors);\nmixinWebexCorePlugins(WebexCore, config, interceptors);\n\nexport default WebexCore;\n\n/**\n * @method registerPlugin\n * @param {string} name\n * @param {function} constructor\n * @param {Object} options\n * @param {Array<string>} options.proxies\n * @param {Object} options.interceptors\n * @returns {null}\n */\nexport function registerPlugin(name, constructor, options = {}) {\n WebexCore.registerPlugin(name, constructor, options);\n}\n\n/**\n * Registers plugins used by internal products that do not talk to public APIs.\n * @method registerInternalPlugin\n * @param {string} name\n * @param {function} constructor\n * @param {Object} options\n * @param {Object} options.interceptors\n * @private\n * @returns {null}\n */\nexport function registerInternalPlugin(name, constructor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ACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASiN,cAAcA,CAAChL,IAAI,EAAE1B,WAAW,EAAgB;EAAA,IAAdE,OAAO,GAAAnD,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAmB,SAAA,GAAAnB,SAAA,MAAG,CAAC,CAAC;EAC5D0C,SAAS,CAACiN,cAAc,CAAChL,IAAI,EAAE1B,WAAW,EAAEE,OAAO,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASyM,sBAAsBA,CAACjL,IAAI,EAAE1B,WAAW,EAAEE,OAAO,EAAE;EACjEH,0BAAiB,CAAC2M,cAAc,CAAChL,IAAI,EAAE1B,WAAW,EAAEE,OAAO,CAAC;AAC9D","ignoreList":[]}
@@ -29,7 +29,7 @@ runs from the workspace root.
29
29
  ## Install
30
30
 
31
31
  ```bash
32
- yarn install
32
+ yarn
33
33
  ```
34
34
 
35
35
  ## Build
@@ -83,7 +83,7 @@ yarn workspace @webex/webex-core test:unit
83
83
 
84
84
  ## First-run verification
85
85
 
86
- 1. Run `yarn install`.
86
+ 1. Run `yarn`.
87
87
  2. Run `yarn workspace @webex/webex-core test:unit --targets lib/batcher.js`.
88
88
  3. Run `yarn workspace @webex/webex-core test:style`.
89
89
 
package/package.json CHANGED
@@ -33,16 +33,16 @@
33
33
  "@sinonjs/fake-timers": "^6.0.1",
34
34
  "@webex/babel-config-legacy": "0.0.0",
35
35
  "@webex/eslint-config-legacy": "0.0.0",
36
- "@webex/internal-plugin-device": "3.13.0-next.1",
36
+ "@webex/internal-plugin-device": "3.13.0-next.10",
37
37
  "@webex/jest-config-legacy": "0.0.0",
38
38
  "@webex/legacy-tools": "0.0.0",
39
- "@webex/plugin-logger": "3.13.0-next.1",
40
- "@webex/test-helper-chai": "3.12.0-next.13",
41
- "@webex/test-helper-make-local-url": "3.12.0-next.13",
42
- "@webex/test-helper-mocha": "3.12.0-next.13",
43
- "@webex/test-helper-mock-webex": "3.12.0-next.13",
44
- "@webex/test-helper-refresh-callback": "3.12.0-next.13",
45
- "@webex/test-helper-test-users": "3.12.0-next.13",
39
+ "@webex/plugin-logger": "3.13.0-next.10",
40
+ "@webex/test-helper-chai": "3.13.0-next.4",
41
+ "@webex/test-helper-make-local-url": "3.13.0-next.4",
42
+ "@webex/test-helper-mocha": "3.13.0-next.4",
43
+ "@webex/test-helper-mock-webex": "3.13.0-next.4",
44
+ "@webex/test-helper-refresh-callback": "3.13.0-next.4",
45
+ "@webex/test-helper-test-users": "3.13.0-next.4",
46
46
  "chai": "^4.3.4",
47
47
  "chai-as-promised": "^7.1.1",
48
48
  "eslint": "^8.24.0",
@@ -50,10 +50,10 @@
50
50
  "sinon": "^9.2.4"
51
51
  },
52
52
  "dependencies": {
53
- "@webex/common": "3.12.0-next.13",
54
- "@webex/common-timers": "3.12.0-next.14",
55
- "@webex/http-core": "3.12.0-next.13",
56
- "@webex/storage-adapter-spec": "3.12.0-next.14",
53
+ "@webex/common": "3.13.0-next.4",
54
+ "@webex/common-timers": "3.13.0-next.4",
55
+ "@webex/http-core": "3.13.0-next.4",
56
+ "@webex/storage-adapter-spec": "3.13.0-next.4",
57
57
  "ampersand-collection": "^2.0.2",
58
58
  "ampersand-events": "^2.0.2",
59
59
  "ampersand-state": "^5.0.3",
@@ -73,5 +73,5 @@
73
73
  "test:style": "eslint ./src/**/*.*",
74
74
  "test:unit": "webex-legacy-tools test --unit --runner jest"
75
75
  },
76
- "version": "3.13.0-next.1"
76
+ "version": "3.13.0-next.10"
77
77
  }
package/src/config.js CHANGED
@@ -84,7 +84,7 @@ export default {
84
84
  *
85
85
  * @type {string}
86
86
  */
87
- u2c: process.env.U2C_SERVICE_URL || 'https://u2c.wbx2.com/u2c/api/v1',
87
+ u2c: process.env.U2C_SERVICE_URL || 'https://u2c.svc.webex.com/u2c/api/v1',
88
88
  },
89
89
 
90
90
  /**
@@ -110,6 +110,15 @@ const CredentialsConfig = AmpState.extend({
110
110
  * @type {string}
111
111
  */
112
112
  cisService: ['string', false, 'webex'],
113
+
114
+ /**
115
+ * Whether the client is permitted to upgrade its refresh token scope
116
+ * Should only be set to true if client has extended feature 'refresh-token-scopes-upgrade-allowed'
117
+ * If true, the refresh token scope will be requested to be increased or decreased on refresh,
118
+ * to match the configured scope.
119
+ * @type {boolean}
120
+ */
121
+ canUpgradeScope: ['boolean', false, false],
113
122
  },
114
123
 
115
124
  derived: {
@@ -130,7 +130,20 @@ export default class AuthInterceptor extends Interceptor {
130
130
  }
131
131
 
132
132
  if (this.webex.credentials.canRefresh) {
133
- return this.webex.credentials.refresh().then(() => this.replay(options));
133
+ return this.webex.credentials
134
+ .refresh()
135
+ .catch((error) => {
136
+ const refreshStatus = error && (error.statusCode || error.status);
137
+
138
+ // A refresh 403 is not a catalog 403. Keep the original 401 for
139
+ // catalog auth reporting and leave statusCode unchanged.
140
+ if (reason.statusCode === 401 && refreshStatus === 403 && error) {
141
+ error.catalogAuthStatus = 401;
142
+ }
143
+
144
+ return Promise.reject(error);
145
+ })
146
+ .then(() => this.replay(options));
134
147
  }
135
148
  }
136
149
 
@@ -594,8 +594,20 @@ const Credentials = WebexPlugin.extend({
594
594
  this.webex.internal.services.updateCredentialsConfig();
595
595
  }
596
596
 
597
+ let scope;
598
+ let upgradeScope;
599
+
600
+ if (this.config.canUpgradeScope) {
601
+ const newScopes = diffScopes(this.config.scope, supertoken.scope);
602
+ if (newScopes !== '') {
603
+ upgradeScope = this.config.scope;
604
+ } else {
605
+ scope = this.config.scope;
606
+ }
607
+ }
608
+
597
609
  return supertoken
598
- .refresh()
610
+ .refresh({scope, upgradeScope})
599
611
  .catch((error) => {
600
612
  if (error instanceof OAuthError) {
601
613
  // Error: super token refresh failed with 400 status code.
@@ -165,7 +165,8 @@ are no feature flags.
165
165
  | `cisService` | prop | none; default `webex` | Declared but not read by `Credentials`; see Pitfalls |
166
166
  | `activationUrl`, `generateOtpUrl`, `validateOtpUrl`, `logoutUrl`, `thirdPartyLoginUrl`, `setPasswordUrl` | derived, uncached | none | Recomputed on each read from `idbroker.url` or `identity.url` |
167
167
  | `tokenUrl`, `revokeUrl` | derived, uncached | `TOKEN_URL`, `REVOKE_URL` override the derived value | Used by every grant and revoke request |
168
- | `refreshCallback` | extra property | none | Browser refresh hook `(webex, token) => Promise<object>`; makes browser tokens refreshable |
168
+ | `refreshCallback` | extra property | none | Browser refresh hook `(webex, token, {scope, upgradeScope}) => Promise<object>`; makes browser tokens refreshable |
169
+ | `canUpgradeScope` | prop | none | Defaults to `false`. Enable only when the client has the `refresh-token-scopes-upgrade-allowed` extended feature; the SDK trusts this flag and does not check the feature itself. When enabled, refresh requests the configured scopes through `upgrade_scope` if any are missing from the supertoken, otherwise through `scope`, intentionally narrowing a broader token |
169
170
  | `jwtRefreshCallback` | extra property | none | JWT-mode refresh hook `(webex) => Promise<jwt>`; makes `canRefresh` true unconditionally |
170
171
 
171
172
  ## Dependencies
@@ -194,13 +195,13 @@ are no feature flags.
194
195
  | `MOD-005` | `canAuthorize` is true iff an access token exists and the token is not expired; `canDownscope` additionally requires `client_id` in configuration | A token must not be presented, or used to mint children, after it has lapsed | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js` | none | Present |
195
196
  | `MOD-006` | `Token.canRefresh` requires a refresh token plus `refreshCallback` in a browser build, or plus `client_secret` in Node | Not stated in code or tests. Code shows only that the browser delegates to a host callback and Node uses the client secret | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js`, `test/integration/spec/unit-browser/token.js` | WHY not stated in code or tests. The two platform branches only run under their own runner | Weak |
196
197
  | `MOD-007` | `toString` returns `<token_type> <access_token>` and throws `cannot stringify Token` when either is missing | The result is used verbatim as the `Authorization` header value | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js` | none | Present |
197
- | `MOD-008` | `Token.downscope` rejects when the token is expired, cannot downscope, requests a scope outside `config.scope`, or requests a scope equal to the full configured scope; otherwise it POSTs a scope-reduction grant without an auth header and returns a new `Token` carrying the sorted requested scope | The service answers only `invalid scope`, which misleads when the whole set is the problem, so the module reports the cause itself | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js`, `test/integration/spec/credentials/token.js` | Gap: the success path's response mapping is asserted only through the scope sort and the live integration test; the equal-to-full-scope rejection is covered only by the integration test | Present |
198
+ | `MOD-008` | `Token.downscope` rejects when the token is expired, cannot downscope, requests a scope outside the token's known scope, or requests a scope equal to that full scope; tokens without scope metadata fall back to `config.scope` for these checks. Otherwise it POSTs a scope-reduction grant without an auth header and returns a new `Token` carrying the sorted requested scope | The source token, rather than current client configuration, is authoritative after a scope upgrade or configuration change. The fallback preserves legacy and externally supplied tokens without scope metadata. The service answers only `invalid scope`, which misleads when the whole set is the problem, so the module reports the cause itself | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js`, `test/integration/spec/credentials/token.js` | The success path's response mapping is asserted only through the requested scope and the live integration test; the equal-to-full-scope rejection is covered only by the integration test | Present |
198
199
  | `MOD-009` | `Token.downscope` calls are de-duplicated per scope string | Not stated in code or tests | `src/lib/credentials/token.js` | none found | WHY not stated in code or tests. Gap: no test issues two concurrent downscopes | Weak |
199
200
  | `MOD-010` | `Token.refresh` throws `Not enough information available to refresh this access token` when `canRefresh` is false | Not stated in code or tests | `src/lib/credentials/token.js` | none found | WHY not stated in code or tests. Gap: the throw is untested. Note it is a synchronous throw, not a rejection | Weak |
200
- | `MOD-011` | In Node, `Token.refresh` POSTs a `refresh_token` grant to the token URL with the client id and secret as Basic credentials and `shouldRefreshAccessToken: false`; in a browser it awaits `config.refreshCallback(webex, token)` | Not stated in code or tests (including the reason for `shouldRefreshAccessToken: false`) | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js`, `test/integration/spec/unit-browser/token.js` | WHY not stated in code or tests. The request shape (form fields, auth) is not asserted | Weak |
201
+ | `MOD-011` | In Node, `Token.refresh` POSTs a `refresh_token` grant to the token URL with the client id and secret as Basic credentials and `shouldRefreshAccessToken: false`; in a browser it awaits `config.refreshCallback(webex, token, {scope, upgradeScope})`. When supplied, `scope` is sent as `scope` and `upgradeScope` as `upgrade_scope` by the built-in Node request and the first-party browser callback; absent values are omitted from the form | The optional callback argument preserves compatibility with existing custom callbacks while allowing both transports to request explicit scopes or a scope upgrade | `src/lib/credentials/token.js`, `../plugin-authorization-browser-first-party/src/config.js` | `test/unit/spec/credentials/token.js`, `test/integration/spec/unit-browser/token.js`, `../plugin-authorization-browser-first-party/test/unit/spec/authorization.js` | Browser callback propagation is covered by the browser-only token tests; the first-party callback request shape is covered by its package unit tests | Present |
201
202
  | `MOD-012` | A refresh result without a `refresh_token` inherits the current token's `refresh_token`, `refresh_token_expires`, and `refresh_token_expires_in` | The identity service does not send a new refresh token on refresh, per the in-source comment | `src/lib/credentials/token.js` | `test/integration/spec/credentials/token.js` | Gap: no unit test pins the inheritance | Present |
202
203
  | `MOD-013` | `Token.refresh` rejects with `new token matches current token` when the service returns the same access token, and logs the old and new token values at error level unless `NODE_ENV` is `production` | Identical tokens indicate a service defect; the values are logged for diagnosis outside production only | `src/lib/credentials/token.js` | none found | Gap: untested. See the security pitfall | Present |
203
- | `MOD-014` | After a refresh, the new `Token` records the old one as `previousToken` and keeps the old scope; the next refresh revokes the older `previousToken` first | Two valid tokens overlap so that a request in flight with the old token is not cut off | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js`, `test/integration/spec/unit-browser/token.js` | The revoke call is neither awaited nor error-handled | Present |
204
+ | `MOD-014` | After a refresh, the new `Token` records the old one as `previousToken` and uses the scope returned by the token service. When the response omits scope, it falls back to the explicitly requested `scope`, then the old scope; it never assumes `upgradeScope` was granted. The next refresh revokes the older `previousToken` first | The returned scope is authoritative for partial grants, and an omitted scope must not undo intentional narrowing in the local metadata. Two valid tokens overlap so that a request in flight with the old token is not cut off | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js`, `test/integration/spec/unit-browser/token.js` | The revoke call is neither awaited nor error-handled | Present |
204
205
  | `MOD-015` | `Token.revoke` resolves without a request when the token is expired, cannot authorize, or no `client_secret` is configured; otherwise it POSTs to the revoke URL and, on success, unsets `access_token`, `expires`, `expires_in`, and `token_type` while keeping the refresh-token fields | The revoke endpoint requires client credentials, and the refresh token must survive for later refresh | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js`, `test/integration/spec/credentials/token.js` | Browsers never revoke; the in-source comment records this as a known limitation | Present |
205
206
  | `MOD-016` | A non-400 failure from a grant, refresh, or revoke call is re-rejected unchanged; a 400 is converted to the matching grant-error subclass built from the underlying response | The unit test selects the error class from the OAuth `error` string, so callers can branch on class | `src/lib/credentials/token.js`, `src/lib/credentials/grant-errors.js` | `test/unit/spec/credentials/credentials.js` | Gap: `processGrantError` itself has no direct test; the one assertion constructs the error class by hand | Present |
206
207
  | `MOD-017` | `grantErrors.select` returns the subclass for `invalid_request`, `invalid_client`, `invalid_grant`, `unauthorized_client`, `unsupported_grant_type`, and `invalid_scope`, and the base `OAuthError` for anything else | Not stated in code or tests; only the `select` fallback to the base class is code-evident | `src/lib/credentials/grant-errors.js` | `test/unit/spec/credentials/credentials.js` | WHY not stated in code or tests. Gap: only `invalid_request` is exercised | Weak |
@@ -220,7 +221,7 @@ are no feature flags.
220
221
  | `MOD-031` | `getUserToken` rejects with `Current state cannot produce an access token` when `canAuthorize` is false | After logout no token may be returned | `src/lib/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | none | Present |
221
222
  | `MOD-032` | `getUserToken` waits for the storage restore attempt and, while `isRefreshing` is true, for the next `change:isRefreshing` before choosing a token; concurrent calls for one scope share a flight | A caller must not receive a token a refresh is about to supersede | `src/lib/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | Gap: the wait on storage restore has no test here | Present |
222
223
  | `MOD-033` | When downscoping fails, `Credentials.downscope` logs a warning, submits the downscope-failed metric with the requested scope and reason, and resolves a token copied from the supertoken | The SDK stays usable when the scope-reduction endpoint is unavailable, at the cost of broader privileges | `src/lib/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | The fallback ignores the requested scope when the supertoken has its own; see Pitfalls | Present |
223
- | `MOD-034` | `refresh` is serialized per instance, sets `isRefreshing` for its duration, delegates to `jwtRefreshCallback` then the authorization plugin in JWT mode, and otherwise refreshes the supertoken | One refresh at a time prevents refresh-token races and concurrent mint storms | `src/lib/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | Gap: the JWT branch is untested here, and `isRefreshing` toggling is asserted only indirectly | Present |
224
+ | `MOD-034` | `refresh` is serialized per instance, sets `isRefreshing` for its duration, delegates to `jwtRefreshCallback` then the authorization plugin in JWT mode, and otherwise refreshes the supertoken. Outside JWT mode, when `canUpgradeScope` is true, it requests the full configured scope through `upgrade_scope` if any configured scopes are absent from the supertoken, otherwise through `scope`, intentionally narrowing a broader token. When disabled, neither field is requested; JWT refresh bypasses this selection | One refresh at a time prevents refresh-token races and concurrent mint storms. Configured-scope selection is opt-in and retries still-missing configured scopes on later refreshes | `src/lib/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | Gap: the JWT branch is untested here, and `isRefreshing` toggling is asserted only indirectly | Present |
224
225
  | `MOD-035` | After a supertoken refresh, `refresh` stores the new supertoken, clears the old timer, warns and submits a metric when configured scopes are missing from the supertoken, downscopes each existing user token to its still-valid scope, revokes the old one, swaps it in, and reschedules | Child tokens must be re-derived from the new supertoken so none outlive the old grant | `src/lib/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | The reschedule assertion compares against an undefined `expires`, so it does not prove the argument | Present |
225
226
  | `MOD-036` | An `OAuthError` from the supertoken refresh removes the supertoken and all user tokens, triggers `client:InvalidRequestError` on the SDK object, and rethrows | An invalid refresh token is unrecoverable and the application needs the chance to log the user out | `src/lib/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | The test stubs `unset` and asserts only inside `catch`; user-token removal is unasserted | Present |
226
227
  | `MOD-037` | `scheduleRefresh` refreshes immediately when the time has passed, otherwise sets one timer for a random 60 to 90 percent of the remaining lifetime | The source documents a 60 to 90 percent window ahead of expiry; the reason for the randomization is not stated in code or tests | `src/lib/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | WHY for randomization not stated in code or tests. The result of the immediate or timed `refresh()` is not observed | Weak |
@@ -417,11 +418,11 @@ sequenceDiagram
417
418
  T-->>C: reject unchanged
418
419
  end
419
420
  end
420
- C->>T: Token.refresh()
421
+ C->>T: Token.refresh({scope, upgradeScope})
421
422
  alt canRefresh is false
422
423
  T-->>C: throw synchronously "Not enough information available to refresh this access token"
423
424
  else browser build
424
- T->>H: refreshCallback(webex, token)
425
+ T->>H: refreshCallback(webex, token, {scope, upgradeScope})
425
426
  alt no object produced
426
427
  H-->>T: falsy or non-object
427
428
  T-->>C: reject "refreshCallback() did not produce an object"
@@ -429,7 +430,7 @@ sequenceDiagram
429
430
  H-->>T: token fields
430
431
  end
431
432
  else Node build
432
- T->>E: POST refresh_token grant (Basic client credentials)
433
+ T->>E: POST refresh_token grant, with scope or upgrade_scope when supplied (Basic client credentials)
433
434
  alt 400
434
435
  E-->>T: 400 OAuth error body
435
436
  T-->>C: reject with grant error
@@ -444,7 +445,7 @@ sequenceDiagram
444
445
  alt same access token as current
445
446
  T-->>C: reject "new token matches current token"
446
447
  else different
447
- T->>T: inherit refresh_token fields if absent, set previousToken
448
+ T->>T: inherit refresh_token fields if absent, use returned scope then requested scope then old scope, set previousToken
448
449
  T->>T: revoke older previousToken (not awaited)
449
450
  T-->>C: new Token
450
451
  end
@@ -551,7 +552,7 @@ accessors. A `Token` finds its SDK object through its parent or its collection,
551
552
  | --- | --- | --- | --- | --- | --- |
552
553
  | SDK to identity broker token endpoint (refresh, client credentials, scope reduction) | HTTPS form POST via `webex.request`; Basic client credentials on refresh and client credentials, none on scope reduction | One request per call; `Credentials.refresh` runs downscopes after the supertoken refresh settles and runs them in parallel | Grant types are `refresh_token`, `client_credentials`, and a scope-reduction URN | No timeout or retry here. Refresh, revoke, and client-credentials requests set `shouldRefreshAccessToken: false`; the scope-reduction request instead sets `addAuthHeader: false` | Failures reject; only refresh failures with an OAuth error trigger clearing |
553
554
  | SDK to broker revoke endpoint | HTTPS form POST | After the replacement token exists | Revokes an access token with a type hint | None | Failure logged and ignored on the refresh path |
554
- | SDK to host application | `refreshCallback` or `jwtRefreshCallback` | Called inside the refresh flight | Callback contract is `(webex, token)` or `(webex)` | Unbounded; the module imposes no timeout on the callback | Rejection or a falsy result rejects the refresh |
555
+ | SDK to host application | `refreshCallback` or `jwtRefreshCallback` | Called inside the refresh flight | Callback contract is `(webex, token, {scope, upgradeScope})` or `(webex)`; the third refresh-callback argument is optional for backward compatibility | Unbounded; the module imposes no timeout on the callback | Rejection or a falsy result rejects the refresh |
555
556
  | SDK to authorization plugin | Direct method call in JWT mode | After the JWT callback resolves | Plugin must expose `requestAccessTokenFromJwt` | None | Rejection rejects the refresh |
556
557
 
557
558
  ## Client state model
@@ -573,7 +574,7 @@ accessors. A `Token` finds its SDK object through its parent or its collection,
573
574
  | --- | --- | --- | --- | --- |
574
575
  | `INV-001` | A `Token` always has an access token at construction | A token without a secret is meaningless | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js` |
575
576
  | `INV-002` | A token may authorize only while it has an access token and is not expired | Never present a lapsed or revoked token | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js` |
576
- | `INV-003` | A downscoped token's scope is a strict subset of the configured scope | Child tokens must narrow privilege, per the in-source rationale about unhelpful service errors | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js` |
577
+ | `INV-003` | A downscoped token's scope is a strict subset of its source token's known scope, falling back to the configured scope when the source token has no scope metadata | Child tokens must narrow the privilege actually held by their source token, including upgraded supertokens whose scopes exceed current configuration | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js` |
577
578
  | `INV-004` | Scope strings used as an index or for comparison are always in sorted order | The collection and the supertoken short-circuit compare strings | `src/lib/credentials/scope.js`, `src/lib/credentials/credentials.js` | `test/unit/spec/credentials/scope.js` |
578
579
  | `INV-005` | See `MOD-012`: a refreshed token never loses its refresh token | The service never issues a new one on refresh | `src/lib/credentials/token.js` | none found |
579
580
  | `INV-006` | See `MOD-015`: revocation never removes the refresh-token fields | The session must remain refreshable after its access token is revoked | `src/lib/credentials/token.js` | `test/unit/spec/credentials/token.js` |
@@ -657,7 +658,7 @@ means `canAuthorize` is false.
657
658
  | Third-party login URL (`oauth2provider`, `returnURL`, `state`) | Broker-specific | `src/lib/credentials/credentials.js` | The identity broker | State encoded identically to the authorize URL |
658
659
  | Logout URL (`cisService`, `goto`, plus caller options) | Broker-specific | `src/lib/credentials/credentials.js` | The identity broker | Caller options override both defaults |
659
660
  | Client-credentials grant form | OAuth 2.0 | `src/lib/credentials/credentials.js` | The identity broker | Form fields `grant_type`, `scope`, `self_contained_token`; client credentials in Basic auth |
660
- | Refresh-token grant form | OAuth 2.0 | `src/lib/credentials/token.js` | The identity broker | Form fields `grant_type`, `redirect_uri`, `refresh_token`; client credentials in Basic auth |
661
+ | Refresh-token grant form | OAuth 2.0 | `src/lib/credentials/token.js` | The identity broker | Form fields `grant_type`, `redirect_uri`, `refresh_token`, optional `scope` or `upgrade_scope`; client credentials in Basic auth |
661
662
  | Scope-reduction grant form | Cisco extension (`urn:cisco:oauth:grant-type:scope-reduction`) | `src/lib/credentials/token.js` | The identity broker | Form fields `grant_type`, `token`, `scope`, `client_id`, `self_contained_token`; no auth header; the token travels in the body |
662
663
  | Revoke form | OAuth 2.0 | `src/lib/credentials/token.js` | The identity broker | Form fields `token`, `token_type_hint`; client credentials in Basic auth |
663
664
  | Token response body | OAuth 2.0 | The identity broker | `src/lib/credentials/token.js` | `expires_in` and `refresh_token_expires_in` seconds are converted to absolute millisecond timestamps |
@@ -675,8 +676,8 @@ service contract.
675
676
  | No access token at `Token` construction | Throws `` `access_token` is required`` | Fix the input | None | `src/lib/credentials/token.js` |
676
677
  | `getUserToken` when nothing can authorize | Rejects `Current state cannot produce an access token` | Re-authenticate | Caller-owned | `src/lib/credentials/credentials.js` |
677
678
  | Downscope of an expired or unconfigured token | Rejects with `cannot downscope expired access token` or `cannot downscope access token` | Treated by `Credentials` as a downscope failure and falls back | Supertoken fallback | `src/lib/credentials/token.js` |
678
- | Requested scope outside configured scope | Rejects `new scope (...) is not subset of the available scopes (...)` | Fix the scope | Fallback for `getUserToken` | `src/lib/credentials/token.js` |
679
- | Requested scope equals the full configured scope | Rejects `token: scope reduction requires a reduced scope` | Use the supertoken | Fallback for `getUserToken` | `src/lib/credentials/token.js` |
679
+ | Requested scope outside the source token's known scope (or configured scope when token scope is absent) | Rejects `new scope (...) is not subset of the available scopes (...)` | Fix the scope | Fallback for `getUserToken` | `src/lib/credentials/token.js` |
680
+ | Requested scope equals the source token's full known scope (or configured scope when token scope is absent) | Rejects `token: scope reduction requires a reduced scope` | Use the source token | Fallback for `getUserToken` | `src/lib/credentials/token.js` |
680
681
  | `Token.refresh` without capability | Throws synchronously `Not enough information available to refresh this access token` | Check `canRefresh` first | None | `src/lib/credentials/token.js` |
681
682
  | Browser refresh without a callback result | Rejects `token: refreshCallback() did not produce an object` | Fix the callback | Next 401 or timer | `src/lib/credentials/token.js` |
682
683
  | Service returned the same access token | Rejects `new token matches current token` | Report a service defect | Next 401 or timer | `src/lib/credentials/token.js` |
@@ -793,10 +794,10 @@ No API report or type declaration exists for this module; the sources above are
793
794
  | `MOD-008`, `INV-003` | Unit, Integration | `test/unit/spec/credentials/token.js`, `test/integration/spec/credentials/token.js` | `test/unit/spec/credentials/token.js` | Equal-to-full-scope rejection is integration only |
794
795
  | `MOD-009` | none | none found | none found | No concurrent-downscope test |
795
796
  | `MOD-010` | none | none found | none found | The synchronous throw is untested |
796
- | `MOD-011` | Unit, Integration | `test/unit/spec/credentials/token.js`, `test/integration/spec/credentials/token.js` | none found | Request fields and Basic auth are not asserted |
797
+ | `MOD-011` | Unit, Integration | `test/unit/spec/credentials/token.js`, `test/integration/spec/credentials/token.js`, `test/integration/spec/unit-browser/token.js`, `../plugin-authorization-browser-first-party/test/unit/spec/authorization.js` | `test/unit/spec/credentials/token.js`, `../plugin-authorization-browser-first-party/test/unit/spec/authorization.js` | Browser callback propagation runs only in the browser test tier |
797
798
  | `MOD-012`, `INV-005` | Integration | `test/integration/spec/credentials/token.js` | none found | No unit test; relies on a live service |
798
799
  | `MOD-013`, `INV-007` | none | none found | none found | The identical-token path and the production log branch are untested |
799
- | `MOD-014` | Unit, Integration | `test/unit/spec/credentials/token.js`, `test/integration/spec/unit-browser/token.js` | none found | Revoke failure on the previous token is not tested |
800
+ | `MOD-014` | Unit, Integration | `test/unit/spec/credentials/token.js`, `test/integration/spec/unit-browser/token.js` | `test/unit/spec/credentials/token.js` | Omitted-scope fallback and revoke failure on the previous token are not tested |
800
801
  | `MOD-015`, `INV-006` | Unit, Integration | `test/unit/spec/credentials/token.js`, `test/integration/spec/credentials/token.js` | `test/unit/spec/credentials/token.js` (three no-op cases) | The request payload is not asserted |
801
802
  | `MOD-016` | Unit | `test/unit/spec/credentials/credentials.js` | none found | `processGrantError` and the plain-`OAuthError` carve-out are untested |
802
803
  | `MOD-017` | Unit | `test/unit/spec/credentials/credentials.js` | none found | Five of six codes, and the fallback, are unasserted |
@@ -816,7 +817,7 @@ No API report or type declaration exists for this module; the sources above are
816
817
  | `MOD-031`, `INV-008` | Unit | `test/unit/spec/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | none |
817
818
  | `MOD-032`, `INV-009` | Unit | `test/unit/spec/credentials/credentials.js` | none found | Storage-restore wait untested |
818
819
  | `MOD-033` | Unit | `test/unit/spec/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | Effect of the supertoken scope on the fallback is unasserted |
819
- | `MOD-034` | Unit | `test/unit/spec/credentials/credentials.js` | none found | JWT branch and flag toggling untested |
820
+ | `MOD-034` | Unit | `test/unit/spec/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` | JWT branch and flag toggling untested |
820
821
  | `MOD-035` | Unit | `test/unit/spec/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` (revoke rejects, scope mismatch) | Reschedule argument not proven |
821
822
  | `MOD-036` | Unit | `test/unit/spec/credentials/credentials.js` | none found | Weak: `unset` stubbed, assertions inside `catch` |
822
823
  | `MOD-037` | Unit | `test/unit/spec/credentials/credentials.js` | `test/unit/spec/credentials/credentials.js` (expired path) | No assertion on a failing refresh from the timer |