@webex/cc-store 1.28.0-ccwidgets.50 → 1.28.0-ccwidgets.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +31 -20
- package/dist/types/store.d.ts +6 -3
- package/dist/types/store.types.d.ts +17 -5
- package/dist/types/storeEventsWrapper.d.ts +16 -11
- package/dist/types/util.d.ts +2 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2511,7 +2511,7 @@ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-co
|
|
|
2511
2511
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2512
2512
|
|
|
2513
2513
|
"use strict";
|
|
2514
|
-
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _Object$keys2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _keys = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\"));\nvar _assign = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/assign */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/assign.js\"));\nvar _deleteProperty = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/delete-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/delete-property.js\"));\nvar _now = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/date/now */ \"../../../node_modules/@babel/runtime-corejs2/core-js/date/now.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/slicedToArray.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _url = _interopRequireDefault(__webpack_require__(/*! url */ \"../../../node_modules/url/url.js\"));\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/common/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _backoff = _interopRequireDefault(__webpack_require__(/*! backoff */ \"../../../node_modules/backoff/index.js\"));\nvar _socket = _interopRequireDefault(__webpack_require__(/*! ./socket */ \"../../../node_modules/@webex/internal-plugin-mercury/dist/socket/index.js\"));\nvar _errors = __webpack_require__(/*! ./errors */ \"../../../node_modules/@webex/internal-plugin-mercury/dist/errors.js\");\nvar _dec, _dec2, _obj;\n/* eslint-disable require-jsdoc */\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nfunction ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\nvar normalReconnectReasons = ['idle', 'done (forced)', 'pong not received', 'pong mismatch'];\nvar Mercury = _webexCore.WebexPlugin.extend((_dec = (0, _common.deprecated)('Mercury#listen(): Use Mercury#connect() instead'), _dec2 = (0, _common.deprecated)('Mercury#stopListening(): Use Mercury#disconnect() instead'), (_obj = {\n namespace: 'Mercury',\n lastError: undefined,\n session: {\n connected: {\n default: false,\n type: 'boolean'\n },\n connecting: {\n default: false,\n type: 'boolean'\n },\n hasEverConnected: {\n default: false,\n type: 'boolean'\n },\n socket: 'object',\n localClusterServiceUrls: 'object',\n mercuryTimeOffset: {\n default: undefined,\n type: 'number'\n }\n },\n derived: {\n listening: {\n deps: ['connected'],\n fn: function fn() {\n return this.connected;\n }\n }\n },\n initialize: function initialize() {\n var _this = this;\n /*\n When one of these legacy feature gets updated, this event would be triggered\n * group-message-notifications\n * mention-notifications\n * thread-notifications\n */\n this.on('event:featureToggle_update', function (envelope) {\n if (envelope && envelope.data) {\n _this.webex.internal.feature.updateFeature(envelope.data.featureToggle);\n }\n });\n },\n /**\n * Get the last error.\n * @returns {any} The last error.\n */\n getLastError: function getLastError() {\n return this.lastError;\n },\n connect: function connect(webSocketUrl) {\n var _this2 = this;\n if (this.connected) {\n this.logger.info(\"\".concat(this.namespace, \": already connected, will not connect again\"));\n return _promise.default.resolve();\n }\n this.connecting = true;\n this.logger.info(\"\".concat(this.namespace, \": starting connection attempt\"));\n this.logger.info(\"\".concat(this.namespace, \": debug_mercury_logging stack: \"), new Error('debug_mercury_logging').stack);\n return _promise.default.resolve(this.webex.internal.device.registered || this.webex.internal.device.register()).then(function () {\n _this2.logger.info(\"\".concat(_this2.namespace, \": connecting\"));\n return _this2._connectWithBackoff(webSocketUrl);\n });\n },\n logout: function logout() {\n this.logger.info(\"\".concat(this.namespace, \": logout() called\"));\n this.logger.info(\"\".concat(this.namespace, \": debug_mercury_logging stack: \"), new Error('debug_mercury_logging').stack);\n return this.disconnect(this.config.beforeLogoutOptionsCloseReason && !normalReconnectReasons.includes(this.config.beforeLogoutOptionsCloseReason) ? {\n code: 3050,\n reason: this.config.beforeLogoutOptionsCloseReason\n } : undefined);\n },\n disconnect: function disconnect(options) {\n var _this3 = this;\n return new _promise.default(function (resolve) {\n if (_this3.backoffCall) {\n _this3.logger.info(\"\".concat(_this3.namespace, \": aborting connection\"));\n _this3.backoffCall.abort();\n }\n if (_this3.socket) {\n _this3.socket.removeAllListeners('message');\n _this3.once('offline', resolve);\n resolve(_this3.socket.close(options || undefined));\n }\n resolve();\n });\n },\n listen: function listen() {\n /* eslint no-invalid-this: [0] */\n return this.connect();\n },\n stopListening: function stopListening() {\n /* eslint no-invalid-this: [0] */\n return this.disconnect();\n },\n processRegistrationStatusEvent: function processRegistrationStatusEvent(message) {\n this.localClusterServiceUrls = message.localClusterServiceUrls;\n },\n _applyOverrides: function _applyOverrides(event) {\n if (!event || !event.headers) {\n return;\n }\n var headerKeys = (0, _keys.default)(event.headers);\n headerKeys.forEach(function (keyPath) {\n (0, _lodash.set)(event, keyPath, event.headers[keyPath]);\n });\n },\n _prepareUrl: function _prepareUrl(webSocketUrl) {\n var _this4 = this;\n if (!webSocketUrl) {\n webSocketUrl = this.webex.internal.device.webSocketUrl;\n }\n return this.webex.internal.feature.getFeature('developer', 'web-high-availability').then(function (haMessagingEnabled) {\n if (haMessagingEnabled) {\n return _this4.webex.internal.services.convertUrlToPriorityHostUrl(webSocketUrl);\n }\n return webSocketUrl;\n }).then(function (wsUrl) {\n webSocketUrl = wsUrl;\n }).then(function () {\n return _this4.webex.internal.feature.getFeature('developer', 'web-shared-mercury');\n }).then(function (webSharedMercury) {\n webSocketUrl = _url.default.parse(webSocketUrl, true);\n (0, _assign.default)(webSocketUrl.query, {\n outboundWireFormat: 'text',\n bufferStates: true,\n aliasHttpStatus: true\n });\n if (webSharedMercury) {\n (0, _assign.default)(webSocketUrl.query, {\n mercuryRegistrationStatus: true,\n isRegistrationRefreshEnabled: true\n });\n (0, _deleteProperty.default)(webSocketUrl.query, 'bufferStates');\n }\n if ((0, _lodash.get)(_this4, 'webex.config.device.ephemeral', false)) {\n webSocketUrl.query.multipleConnections = true;\n }\n webSocketUrl.query.clientTimestamp = (0, _now.default)();\n return _url.default.format(webSocketUrl);\n });\n },\n _attemptConnection: function _attemptConnection(socketUrl, callback) {\n var _this5 = this;\n var socket = new _socket.default();\n var attemptWSUrl;\n socket.on('close', function () {\n return _this5._onclose.apply(_this5, arguments);\n });\n socket.on('message', function () {\n return _this5._onmessage.apply(_this5, arguments);\n });\n socket.on('pong', function () {\n return _this5._setTimeOffset.apply(_this5, arguments);\n });\n socket.on('sequence-mismatch', function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return _this5._emit.apply(_this5, ['sequence-mismatch'].concat(args));\n });\n socket.on('ping-pong-latency', function () {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return _this5._emit.apply(_this5, ['ping-pong-latency'].concat(args));\n });\n _promise.default.all([this._prepareUrl(socketUrl), this.webex.credentials.getUserToken()]).then(function (_ref) {\n var _ref2 = (0, _slicedToArray2.default)(_ref, 2),\n webSocketUrl = _ref2[0],\n token = _ref2[1];\n if (!_this5.backoffCall) {\n var msg = \"\".concat(_this5.namespace, \": prevent socket open when backoffCall no longer defined\");\n _this5.logger.info(msg);\n return _promise.default.reject(new Error(msg));\n }\n attemptWSUrl = webSocketUrl;\n var options = {\n forceCloseDelay: _this5.config.forceCloseDelay,\n pingInterval: _this5.config.pingInterval,\n pongTimeout: _this5.config.pongTimeout,\n token: token.toString(),\n trackingId: \"\".concat(_this5.webex.sessionId, \"_\").concat((0, _now.default)()),\n logger: _this5.logger\n };\n\n // if the consumer has supplied request options use them\n if (_this5.webex.config.defaultMercuryOptions) {\n _this5.logger.info(\"\".concat(_this5.namespace, \": setting custom options\"));\n options = _objectSpread(_objectSpread({}, options), _this5.webex.config.defaultMercuryOptions);\n }\n\n // Set the socket before opening it. This allows a disconnect() to close\n // the socket if it is in the process of being opened.\n _this5.socket = socket;\n _this5.logger.info(\"\".concat(_this5.namespace, \" connection url: \").concat(webSocketUrl));\n return socket.open(webSocketUrl, options);\n }).then(function () {\n _this5.logger.info(\"\".concat(_this5.namespace, \": connected to mercury, success, action: connected, url: \").concat(attemptWSUrl));\n callback();\n return _this5.webex.internal.feature.getFeature('developer', 'web-high-availability').then(function (haMessagingEnabled) {\n if (haMessagingEnabled) {\n return _this5.webex.internal.device.refresh();\n }\n return _promise.default.resolve();\n });\n }).catch(function (reason) {\n var _this5$backoffCall, _this5$backoffCall3;\n _this5.lastError = reason; // remember the last error\n\n // Suppress connection errors that appear to be network related. This\n // may end up suppressing metrics during outages, but we might not care\n // (especially since many of our outages happen in a way that client\n // metrics can't be trusted).\n if (reason.code !== 1006 && _this5.backoffCall && ((_this5$backoffCall = _this5.backoffCall) === null || _this5$backoffCall === void 0 ? void 0 : _this5$backoffCall.getNumRetries()) > 0) {\n var _this5$backoffCall2;\n _this5._emit('connection_failed', reason, {\n retries: (_this5$backoffCall2 = _this5.backoffCall) === null || _this5$backoffCall2 === void 0 ? void 0 : _this5$backoffCall2.getNumRetries()\n });\n }\n _this5.logger.info(\"\".concat(_this5.namespace, \": connection attempt failed\"), reason, ((_this5$backoffCall3 = _this5.backoffCall) === null || _this5$backoffCall3 === void 0 ? void 0 : _this5$backoffCall3.getNumRetries()) === 0 ? reason.stack : '');\n // UnknownResponse is produced by IE for any 4XXX; treated it like a bad\n // web socket url and let WDM handle the token checking\n if (reason instanceof _errors.UnknownResponse) {\n _this5.logger.info(\"\".concat(_this5.namespace, \": received unknown response code, refreshing device registration\"));\n return _this5.webex.internal.device.refresh().then(function () {\n return callback(reason);\n });\n }\n // NotAuthorized implies expired token\n if (reason instanceof _errors.NotAuthorized) {\n _this5.logger.info(\"\".concat(_this5.namespace, \": received authorization error, reauthorizing\"));\n return _this5.webex.credentials.refresh({\n force: true\n }).then(function () {\n return callback(reason);\n });\n }\n // // NotFound implies expired web socket url\n // else if (reason instanceof NotFound) {\n // this.logger.info(`mercury: received not found error, refreshing device registration`);\n // return this.webex.internal.device.refresh()\n // .then(() => callback(reason));\n // }\n // BadRequest implies current credentials are for a Service Account\n // Forbidden implies current user is not entitle for Webex\n if (reason instanceof _errors.BadRequest || reason instanceof _errors.Forbidden) {\n _this5.logger.warn(\"\".concat(_this5.namespace, \": received unrecoverable response from mercury\"));\n _this5.backoffCall.abort();\n return callback(reason);\n }\n if (reason instanceof _errors.ConnectionError) {\n return _this5.webex.internal.feature.getFeature('developer', 'web-high-availability').then(function (haMessagingEnabled) {\n if (haMessagingEnabled) {\n _this5.logger.info(\"\".concat(_this5.namespace, \": received a generic connection error, will try to connect to another datacenter. failed, action: 'failed', url: \").concat(attemptWSUrl, \" error: \").concat(reason.message));\n return _this5.webex.internal.services.markFailedUrl(attemptWSUrl);\n }\n return null;\n }).then(function () {\n return callback(reason);\n });\n }\n return callback(reason);\n }).catch(function (reason) {\n _this5.logger.error(\"\".concat(_this5.namespace, \": failed to handle connection failure\"), reason);\n callback(reason);\n });\n },\n _connectWithBackoff: function _connectWithBackoff(webSocketUrl) {\n var _this6 = this;\n return new _promise.default(function (resolve, reject) {\n // eslint gets confused about whether or not call is actually used\n // eslint-disable-next-line prefer-const\n var call;\n var onComplete = function onComplete(err) {\n _this6.connecting = false;\n _this6.backoffCall = undefined;\n if (err) {\n _this6.logger.info(\"\".concat(_this6.namespace, \": failed to connect after \").concat(call.getNumRetries(), \" retries; log statement about next retry was inaccurate; \").concat(err));\n return reject(err);\n }\n _this6.connected = true;\n _this6.hasEverConnected = true;\n _this6._emit('online');\n return resolve();\n };\n\n // eslint-disable-next-line prefer-reflect\n call = _backoff.default.call(function (callback) {\n _this6.logger.info(\"\".concat(_this6.namespace, \": executing connection attempt \").concat(call.getNumRetries()));\n _this6._attemptConnection(webSocketUrl, callback);\n }, onComplete);\n call.setStrategy(new _backoff.default.ExponentialStrategy({\n initialDelay: _this6.config.backoffTimeReset,\n maxDelay: _this6.config.backoffTimeMax\n }));\n if (_this6.config.initialConnectionMaxRetries && !_this6.hasEverConnected) {\n call.failAfter(_this6.config.initialConnectionMaxRetries);\n } else if (_this6.config.maxRetries) {\n call.failAfter(_this6.config.maxRetries);\n }\n call.on('abort', function () {\n _this6.logger.info(\"\".concat(_this6.namespace, \": connection aborted\"));\n reject(new Error('Mercury Connection Aborted'));\n });\n call.on('callback', function (err) {\n if (err) {\n var number = call.getNumRetries();\n var delay = Math.min(call.strategy_.nextBackoffDelay_, _this6.config.backoffTimeMax);\n _this6.logger.info(\"\".concat(_this6.namespace, \": failed to connect; attempting retry \").concat(number + 1, \" in \").concat(delay, \" ms\"));\n /* istanbul ignore if */\n if (true) {\n _this6.logger.debug(\"\".concat(_this6.namespace, \": \"), err, err.stack);\n }\n return;\n }\n _this6.logger.info(\"\".concat(_this6.namespace, \": connected\"));\n });\n call.start();\n _this6.backoffCall = call;\n });\n },\n _emit: function _emit() {\n for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n try {\n this.trigger.apply(this, args);\n } catch (error) {\n this.logger.error(\"\".concat(this.namespace, \": error occurred in event handler:\"), error, ' with args: ', args);\n }\n },\n _getEventHandlers: function _getEventHandlers(eventType) {\n var _eventType$split = eventType.split('.'),\n _eventType$split2 = (0, _slicedToArray2.default)(_eventType$split, 2),\n namespace = _eventType$split2[0],\n name = _eventType$split2[1];\n var handlers = [];\n if (!this.webex[namespace] && !this.webex.internal[namespace]) {\n return handlers;\n }\n var handlerName = (0, _lodash.camelCase)(\"process_\".concat(name, \"_event\"));\n if ((this.webex[namespace] || this.webex.internal[namespace])[handlerName]) {\n handlers.push({\n name: handlerName,\n namespace: namespace\n });\n }\n return handlers;\n },\n _onclose: function _onclose(event) {\n // I don't see any way to avoid the complexity or statement count in here.\n /* eslint complexity: [0] */\n\n try {\n var reason = event.reason && event.reason.toLowerCase();\n var socketUrl = this.socket.url;\n this.socket.removeAllListeners();\n this.unset('socket');\n this.connected = false;\n this._emit('offline', event);\n switch (event.code) {\n case 1003:\n // metric: disconnect\n this.logger.info(\"\".concat(this.namespace, \": Mercury service rejected last message; will not reconnect: \").concat(event.reason));\n this._emit('offline.permanent', event);\n break;\n case 4000:\n // metric: disconnect\n this.logger.info(\"\".concat(this.namespace, \": socket replaced; will not reconnect\"));\n this._emit('offline.replaced', event);\n break;\n case 1001:\n case 1005:\n case 1006:\n case 1011:\n this.logger.info(\"\".concat(this.namespace, \": socket disconnected; reconnecting\"));\n this._emit('offline.transient', event);\n this._reconnect(socketUrl);\n // metric: disconnect\n // if (code == 1011 && reason !== ping error) metric: unexpected disconnect\n break;\n case 1000:\n case 3050:\n // 3050 indicates logout form of closure, default to old behavior, use config reason defined by consumer to proceed with the permanent block\n if (normalReconnectReasons.includes(reason)) {\n this.logger.info(\"\".concat(this.namespace, \": socket disconnected; reconnecting\"));\n this._emit('offline.transient', event);\n this._reconnect(socketUrl);\n // metric: disconnect\n // if (reason === done forced) metric: force closure\n } else {\n this.logger.info(\"\".concat(this.namespace, \": socket disconnected; will not reconnect: \").concat(event.reason));\n this._emit('offline.permanent', event);\n }\n break;\n default:\n this.logger.info(\"\".concat(this.namespace, \": socket disconnected unexpectedly; will not reconnect\"));\n // unexpected disconnect\n this._emit('offline.permanent', event);\n }\n } catch (error) {\n this.logger.error(\"\".concat(this.namespace, \": error occurred in close handler\"), error);\n }\n },\n _onmessage: function _onmessage(event) {\n var _this7 = this;\n this._setTimeOffset(event);\n var envelope = event.data;\n if (process.env.ENABLE_MERCURY_LOGGING) {\n this.logger.debug(\"\".concat(this.namespace, \": message envelope: \"), envelope);\n }\n var data = envelope.data;\n this._applyOverrides(data);\n return this._getEventHandlers(data.eventType).reduce(function (promise, handler) {\n return promise.then(function () {\n var namespace = handler.namespace,\n name = handler.name;\n return new _promise.default(function (resolve) {\n return resolve((_this7.webex[namespace] || _this7.webex.internal[namespace])[name](data));\n }).catch(function (reason) {\n return _this7.logger.error(\"\".concat(_this7.namespace, \": error occurred in autowired event handler for \").concat(data.eventType), reason);\n });\n });\n }, _promise.default.resolve()).then(function () {\n _this7._emit('event', event.data);\n var _data$eventType$split = data.eventType.split('.'),\n _data$eventType$split2 = (0, _slicedToArray2.default)(_data$eventType$split, 1),\n namespace = _data$eventType$split2[0];\n if (namespace === data.eventType) {\n _this7._emit(\"event:\".concat(namespace), envelope);\n } else {\n _this7._emit(\"event:\".concat(namespace), envelope);\n _this7._emit(\"event:\".concat(data.eventType), envelope);\n }\n }).catch(function (reason) {\n _this7.logger.error(\"\".concat(_this7.namespace, \": error occurred processing socket message\"), reason);\n });\n },\n _setTimeOffset: function _setTimeOffset(event) {\n var wsWriteTimestamp = event.data.wsWriteTimestamp;\n if (typeof wsWriteTimestamp === 'number' && wsWriteTimestamp > 0) {\n this.mercuryTimeOffset = (0, _now.default)() - wsWriteTimestamp;\n }\n },\n _reconnect: function _reconnect(webSocketUrl) {\n this.logger.info(\"\".concat(this.namespace, \": reconnecting\"));\n return this.connect(webSocketUrl);\n },\n version: \"3.8.0-next.13\"\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"connect\", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, \"connect\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"disconnect\", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, \"disconnect\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"listen\", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, \"listen\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"stopListening\", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, \"stopListening\"), _obj)), _obj)));\nvar _default = exports[\"default\"] = Mercury;\n//# sourceMappingURL=mercury.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/internal-plugin-mercury/dist/mercury.js?");
|
|
2514
|
+
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _Object$keys2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _keys = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\"));\nvar _assign = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/assign */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/assign.js\"));\nvar _deleteProperty = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/delete-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/delete-property.js\"));\nvar _now = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/date/now */ \"../../../node_modules/@babel/runtime-corejs2/core-js/date/now.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/slicedToArray.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _url = _interopRequireDefault(__webpack_require__(/*! url */ \"../../../node_modules/url/url.js\"));\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/common/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _backoff = _interopRequireDefault(__webpack_require__(/*! backoff */ \"../../../node_modules/backoff/index.js\"));\nvar _socket = _interopRequireDefault(__webpack_require__(/*! ./socket */ \"../../../node_modules/@webex/internal-plugin-mercury/dist/socket/index.js\"));\nvar _errors = __webpack_require__(/*! ./errors */ \"../../../node_modules/@webex/internal-plugin-mercury/dist/errors.js\");\nvar _dec, _dec2, _obj;\n/* eslint-disable require-jsdoc */\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nfunction ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\nvar normalReconnectReasons = ['idle', 'done (forced)', 'pong not received', 'pong mismatch'];\nvar Mercury = _webexCore.WebexPlugin.extend((_dec = (0, _common.deprecated)('Mercury#listen(): Use Mercury#connect() instead'), _dec2 = (0, _common.deprecated)('Mercury#stopListening(): Use Mercury#disconnect() instead'), (_obj = {\n namespace: 'Mercury',\n lastError: undefined,\n session: {\n connected: {\n default: false,\n type: 'boolean'\n },\n connecting: {\n default: false,\n type: 'boolean'\n },\n hasEverConnected: {\n default: false,\n type: 'boolean'\n },\n socket: 'object',\n localClusterServiceUrls: 'object',\n mercuryTimeOffset: {\n default: undefined,\n type: 'number'\n }\n },\n derived: {\n listening: {\n deps: ['connected'],\n fn: function fn() {\n return this.connected;\n }\n }\n },\n initialize: function initialize() {\n var _this = this;\n /*\n When one of these legacy feature gets updated, this event would be triggered\n * group-message-notifications\n * mention-notifications\n * thread-notifications\n */\n this.on('event:featureToggle_update', function (envelope) {\n if (envelope && envelope.data) {\n _this.webex.internal.feature.updateFeature(envelope.data.featureToggle);\n }\n });\n },\n /**\n * Get the last error.\n * @returns {any} The last error.\n */\n getLastError: function getLastError() {\n return this.lastError;\n },\n connect: function connect(webSocketUrl) {\n var _this2 = this;\n if (this.connected) {\n this.logger.info(\"\".concat(this.namespace, \": already connected, will not connect again\"));\n return _promise.default.resolve();\n }\n this.connecting = true;\n this.logger.info(\"\".concat(this.namespace, \": starting connection attempt\"));\n this.logger.info(\"\".concat(this.namespace, \": debug_mercury_logging stack: \"), new Error('debug_mercury_logging').stack);\n return _promise.default.resolve(this.webex.internal.device.registered || this.webex.internal.device.register()).then(function () {\n _this2.logger.info(\"\".concat(_this2.namespace, \": connecting\"));\n return _this2._connectWithBackoff(webSocketUrl);\n });\n },\n logout: function logout() {\n this.logger.info(\"\".concat(this.namespace, \": logout() called\"));\n this.logger.info(\"\".concat(this.namespace, \": debug_mercury_logging stack: \"), new Error('debug_mercury_logging').stack);\n return this.disconnect(this.config.beforeLogoutOptionsCloseReason && !normalReconnectReasons.includes(this.config.beforeLogoutOptionsCloseReason) ? {\n code: 3050,\n reason: this.config.beforeLogoutOptionsCloseReason\n } : undefined);\n },\n disconnect: function disconnect(options) {\n var _this3 = this;\n return new _promise.default(function (resolve) {\n if (_this3.backoffCall) {\n _this3.logger.info(\"\".concat(_this3.namespace, \": aborting connection\"));\n _this3.backoffCall.abort();\n }\n if (_this3.socket) {\n _this3.socket.removeAllListeners('message');\n _this3.once('offline', resolve);\n resolve(_this3.socket.close(options || undefined));\n }\n resolve();\n });\n },\n listen: function listen() {\n /* eslint no-invalid-this: [0] */\n return this.connect();\n },\n stopListening: function stopListening() {\n /* eslint no-invalid-this: [0] */\n return this.disconnect();\n },\n processRegistrationStatusEvent: function processRegistrationStatusEvent(message) {\n this.localClusterServiceUrls = message.localClusterServiceUrls;\n },\n _applyOverrides: function _applyOverrides(event) {\n if (!event || !event.headers) {\n return;\n }\n var headerKeys = (0, _keys.default)(event.headers);\n headerKeys.forEach(function (keyPath) {\n (0, _lodash.set)(event, keyPath, event.headers[keyPath]);\n });\n },\n _prepareUrl: function _prepareUrl(webSocketUrl) {\n var _this4 = this;\n if (!webSocketUrl) {\n webSocketUrl = this.webex.internal.device.webSocketUrl;\n }\n return this.webex.internal.feature.getFeature('developer', 'web-high-availability').then(function (haMessagingEnabled) {\n if (haMessagingEnabled) {\n return _this4.webex.internal.services.convertUrlToPriorityHostUrl(webSocketUrl);\n }\n return webSocketUrl;\n }).then(function (wsUrl) {\n webSocketUrl = wsUrl;\n }).then(function () {\n return _this4.webex.internal.feature.getFeature('developer', 'web-shared-mercury');\n }).then(function (webSharedMercury) {\n webSocketUrl = _url.default.parse(webSocketUrl, true);\n (0, _assign.default)(webSocketUrl.query, {\n outboundWireFormat: 'text',\n bufferStates: true,\n aliasHttpStatus: true\n });\n if (webSharedMercury) {\n (0, _assign.default)(webSocketUrl.query, {\n mercuryRegistrationStatus: true,\n isRegistrationRefreshEnabled: true\n });\n (0, _deleteProperty.default)(webSocketUrl.query, 'bufferStates');\n }\n if ((0, _lodash.get)(_this4, 'webex.config.device.ephemeral', false)) {\n webSocketUrl.query.multipleConnections = true;\n }\n webSocketUrl.query.clientTimestamp = (0, _now.default)();\n return _url.default.format(webSocketUrl);\n });\n },\n _attemptConnection: function _attemptConnection(socketUrl, callback) {\n var _this5 = this;\n var socket = new _socket.default();\n var attemptWSUrl;\n socket.on('close', function () {\n return _this5._onclose.apply(_this5, arguments);\n });\n socket.on('message', function () {\n return _this5._onmessage.apply(_this5, arguments);\n });\n socket.on('pong', function () {\n return _this5._setTimeOffset.apply(_this5, arguments);\n });\n socket.on('sequence-mismatch', function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return _this5._emit.apply(_this5, ['sequence-mismatch'].concat(args));\n });\n socket.on('ping-pong-latency', function () {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return _this5._emit.apply(_this5, ['ping-pong-latency'].concat(args));\n });\n _promise.default.all([this._prepareUrl(socketUrl), this.webex.credentials.getUserToken()]).then(function (_ref) {\n var _ref2 = (0, _slicedToArray2.default)(_ref, 2),\n webSocketUrl = _ref2[0],\n token = _ref2[1];\n if (!_this5.backoffCall) {\n var msg = \"\".concat(_this5.namespace, \": prevent socket open when backoffCall no longer defined\");\n _this5.logger.info(msg);\n return _promise.default.reject(new Error(msg));\n }\n attemptWSUrl = webSocketUrl;\n var options = {\n forceCloseDelay: _this5.config.forceCloseDelay,\n pingInterval: _this5.config.pingInterval,\n pongTimeout: _this5.config.pongTimeout,\n token: token.toString(),\n trackingId: \"\".concat(_this5.webex.sessionId, \"_\").concat((0, _now.default)()),\n logger: _this5.logger\n };\n\n // if the consumer has supplied request options use them\n if (_this5.webex.config.defaultMercuryOptions) {\n _this5.logger.info(\"\".concat(_this5.namespace, \": setting custom options\"));\n options = _objectSpread(_objectSpread({}, options), _this5.webex.config.defaultMercuryOptions);\n }\n\n // Set the socket before opening it. This allows a disconnect() to close\n // the socket if it is in the process of being opened.\n _this5.socket = socket;\n _this5.logger.info(\"\".concat(_this5.namespace, \" connection url: \").concat(webSocketUrl));\n return socket.open(webSocketUrl, options);\n }).then(function () {\n _this5.logger.info(\"\".concat(_this5.namespace, \": connected to mercury, success, action: connected, url: \").concat(attemptWSUrl));\n callback();\n return _this5.webex.internal.feature.getFeature('developer', 'web-high-availability').then(function (haMessagingEnabled) {\n if (haMessagingEnabled) {\n return _this5.webex.internal.device.refresh();\n }\n return _promise.default.resolve();\n });\n }).catch(function (reason) {\n var _this5$backoffCall, _this5$backoffCall3;\n _this5.lastError = reason; // remember the last error\n\n // Suppress connection errors that appear to be network related. This\n // may end up suppressing metrics during outages, but we might not care\n // (especially since many of our outages happen in a way that client\n // metrics can't be trusted).\n if (reason.code !== 1006 && _this5.backoffCall && ((_this5$backoffCall = _this5.backoffCall) === null || _this5$backoffCall === void 0 ? void 0 : _this5$backoffCall.getNumRetries()) > 0) {\n var _this5$backoffCall2;\n _this5._emit('connection_failed', reason, {\n retries: (_this5$backoffCall2 = _this5.backoffCall) === null || _this5$backoffCall2 === void 0 ? void 0 : _this5$backoffCall2.getNumRetries()\n });\n }\n _this5.logger.info(\"\".concat(_this5.namespace, \": connection attempt failed\"), reason, ((_this5$backoffCall3 = _this5.backoffCall) === null || _this5$backoffCall3 === void 0 ? void 0 : _this5$backoffCall3.getNumRetries()) === 0 ? reason.stack : '');\n // UnknownResponse is produced by IE for any 4XXX; treated it like a bad\n // web socket url and let WDM handle the token checking\n if (reason instanceof _errors.UnknownResponse) {\n _this5.logger.info(\"\".concat(_this5.namespace, \": received unknown response code, refreshing device registration\"));\n return _this5.webex.internal.device.refresh().then(function () {\n return callback(reason);\n });\n }\n // NotAuthorized implies expired token\n if (reason instanceof _errors.NotAuthorized) {\n _this5.logger.info(\"\".concat(_this5.namespace, \": received authorization error, reauthorizing\"));\n return _this5.webex.credentials.refresh({\n force: true\n }).then(function () {\n return callback(reason);\n });\n }\n // // NotFound implies expired web socket url\n // else if (reason instanceof NotFound) {\n // this.logger.info(`mercury: received not found error, refreshing device registration`);\n // return this.webex.internal.device.refresh()\n // .then(() => callback(reason));\n // }\n // BadRequest implies current credentials are for a Service Account\n // Forbidden implies current user is not entitle for Webex\n if (reason instanceof _errors.BadRequest || reason instanceof _errors.Forbidden) {\n _this5.logger.warn(\"\".concat(_this5.namespace, \": received unrecoverable response from mercury\"));\n _this5.backoffCall.abort();\n return callback(reason);\n }\n if (reason instanceof _errors.ConnectionError) {\n return _this5.webex.internal.feature.getFeature('developer', 'web-high-availability').then(function (haMessagingEnabled) {\n if (haMessagingEnabled) {\n _this5.logger.info(\"\".concat(_this5.namespace, \": received a generic connection error, will try to connect to another datacenter. failed, action: 'failed', url: \").concat(attemptWSUrl, \" error: \").concat(reason.message));\n return _this5.webex.internal.services.markFailedUrl(attemptWSUrl);\n }\n return null;\n }).then(function () {\n return callback(reason);\n });\n }\n return callback(reason);\n }).catch(function (reason) {\n _this5.logger.error(\"\".concat(_this5.namespace, \": failed to handle connection failure\"), reason);\n callback(reason);\n });\n },\n _connectWithBackoff: function _connectWithBackoff(webSocketUrl) {\n var _this6 = this;\n return new _promise.default(function (resolve, reject) {\n // eslint gets confused about whether or not call is actually used\n // eslint-disable-next-line prefer-const\n var call;\n var onComplete = function onComplete(err) {\n _this6.connecting = false;\n _this6.backoffCall = undefined;\n if (err) {\n _this6.logger.info(\"\".concat(_this6.namespace, \": failed to connect after \").concat(call.getNumRetries(), \" retries; log statement about next retry was inaccurate; \").concat(err));\n return reject(err);\n }\n _this6.connected = true;\n _this6.hasEverConnected = true;\n _this6._emit('online');\n return resolve();\n };\n\n // eslint-disable-next-line prefer-reflect\n call = _backoff.default.call(function (callback) {\n _this6.logger.info(\"\".concat(_this6.namespace, \": executing connection attempt \").concat(call.getNumRetries()));\n _this6._attemptConnection(webSocketUrl, callback);\n }, onComplete);\n call.setStrategy(new _backoff.default.ExponentialStrategy({\n initialDelay: _this6.config.backoffTimeReset,\n maxDelay: _this6.config.backoffTimeMax\n }));\n if (_this6.config.initialConnectionMaxRetries && !_this6.hasEverConnected) {\n call.failAfter(_this6.config.initialConnectionMaxRetries);\n } else if (_this6.config.maxRetries) {\n call.failAfter(_this6.config.maxRetries);\n }\n call.on('abort', function () {\n _this6.logger.info(\"\".concat(_this6.namespace, \": connection aborted\"));\n reject(new Error('Mercury Connection Aborted'));\n });\n call.on('callback', function (err) {\n if (err) {\n var number = call.getNumRetries();\n var delay = Math.min(call.strategy_.nextBackoffDelay_, _this6.config.backoffTimeMax);\n _this6.logger.info(\"\".concat(_this6.namespace, \": failed to connect; attempting retry \").concat(number + 1, \" in \").concat(delay, \" ms\"));\n /* istanbul ignore if */\n if (true) {\n _this6.logger.debug(\"\".concat(_this6.namespace, \": \"), err, err.stack);\n }\n return;\n }\n _this6.logger.info(\"\".concat(_this6.namespace, \": connected\"));\n });\n call.start();\n _this6.backoffCall = call;\n });\n },\n _emit: function _emit() {\n for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n try {\n this.trigger.apply(this, args);\n } catch (error) {\n this.logger.error(\"\".concat(this.namespace, \": error occurred in event handler:\"), error, ' with args: ', args);\n }\n },\n _getEventHandlers: function _getEventHandlers(eventType) {\n var _eventType$split = eventType.split('.'),\n _eventType$split2 = (0, _slicedToArray2.default)(_eventType$split, 2),\n namespace = _eventType$split2[0],\n name = _eventType$split2[1];\n var handlers = [];\n if (!this.webex[namespace] && !this.webex.internal[namespace]) {\n return handlers;\n }\n var handlerName = (0, _lodash.camelCase)(\"process_\".concat(name, \"_event\"));\n if ((this.webex[namespace] || this.webex.internal[namespace])[handlerName]) {\n handlers.push({\n name: handlerName,\n namespace: namespace\n });\n }\n return handlers;\n },\n _onclose: function _onclose(event) {\n // I don't see any way to avoid the complexity or statement count in here.\n /* eslint complexity: [0] */\n\n try {\n var reason = event.reason && event.reason.toLowerCase();\n var socketUrl = this.socket.url;\n this.socket.removeAllListeners();\n this.unset('socket');\n this.connected = false;\n this._emit('offline', event);\n switch (event.code) {\n case 1003:\n // metric: disconnect\n this.logger.info(\"\".concat(this.namespace, \": Mercury service rejected last message; will not reconnect: \").concat(event.reason));\n this._emit('offline.permanent', event);\n break;\n case 4000:\n // metric: disconnect\n this.logger.info(\"\".concat(this.namespace, \": socket replaced; will not reconnect\"));\n this._emit('offline.replaced', event);\n break;\n case 1001:\n case 1005:\n case 1006:\n case 1011:\n this.logger.info(\"\".concat(this.namespace, \": socket disconnected; reconnecting\"));\n this._emit('offline.transient', event);\n this._reconnect(socketUrl);\n // metric: disconnect\n // if (code == 1011 && reason !== ping error) metric: unexpected disconnect\n break;\n case 1000:\n case 3050:\n // 3050 indicates logout form of closure, default to old behavior, use config reason defined by consumer to proceed with the permanent block\n if (normalReconnectReasons.includes(reason)) {\n this.logger.info(\"\".concat(this.namespace, \": socket disconnected; reconnecting\"));\n this._emit('offline.transient', event);\n this._reconnect(socketUrl);\n // metric: disconnect\n // if (reason === done forced) metric: force closure\n } else {\n this.logger.info(\"\".concat(this.namespace, \": socket disconnected; will not reconnect: \").concat(event.reason));\n this._emit('offline.permanent', event);\n }\n break;\n default:\n this.logger.info(\"\".concat(this.namespace, \": socket disconnected unexpectedly; will not reconnect\"));\n // unexpected disconnect\n this._emit('offline.permanent', event);\n }\n } catch (error) {\n this.logger.error(\"\".concat(this.namespace, \": error occurred in close handler\"), error);\n }\n },\n _onmessage: function _onmessage(event) {\n var _this7 = this;\n this._setTimeOffset(event);\n var envelope = event.data;\n if (process.env.ENABLE_MERCURY_LOGGING) {\n this.logger.debug(\"\".concat(this.namespace, \": message envelope: \"), envelope);\n }\n var data = envelope.data;\n this._applyOverrides(data);\n return this._getEventHandlers(data.eventType).reduce(function (promise, handler) {\n return promise.then(function () {\n var namespace = handler.namespace,\n name = handler.name;\n return new _promise.default(function (resolve) {\n return resolve((_this7.webex[namespace] || _this7.webex.internal[namespace])[name](data));\n }).catch(function (reason) {\n return _this7.logger.error(\"\".concat(_this7.namespace, \": error occurred in autowired event handler for \").concat(data.eventType), reason);\n });\n });\n }, _promise.default.resolve()).then(function () {\n _this7._emit('event', event.data);\n var _data$eventType$split = data.eventType.split('.'),\n _data$eventType$split2 = (0, _slicedToArray2.default)(_data$eventType$split, 1),\n namespace = _data$eventType$split2[0];\n if (namespace === data.eventType) {\n _this7._emit(\"event:\".concat(namespace), envelope);\n } else {\n _this7._emit(\"event:\".concat(namespace), envelope);\n _this7._emit(\"event:\".concat(data.eventType), envelope);\n }\n }).catch(function (reason) {\n _this7.logger.error(\"\".concat(_this7.namespace, \": error occurred processing socket message\"), reason);\n });\n },\n _setTimeOffset: function _setTimeOffset(event) {\n var wsWriteTimestamp = event.data.wsWriteTimestamp;\n if (typeof wsWriteTimestamp === 'number' && wsWriteTimestamp > 0) {\n this.mercuryTimeOffset = (0, _now.default)() - wsWriteTimestamp;\n }\n },\n _reconnect: function _reconnect(webSocketUrl) {\n this.logger.info(\"\".concat(this.namespace, \": reconnecting\"));\n return this.connect(webSocketUrl);\n },\n version: \"3.8.0-next.14\"\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"connect\", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, \"connect\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"disconnect\", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, \"disconnect\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"listen\", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, \"listen\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"stopListening\", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, \"stopListening\"), _obj)), _obj)));\nvar _default = exports[\"default\"] = Mercury;\n//# sourceMappingURL=mercury.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/internal-plugin-mercury/dist/mercury.js?");
|
|
2515
2515
|
|
|
2516
2516
|
/***/ }),
|
|
2517
2517
|
|
|
@@ -2962,7 +2962,7 @@ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-co
|
|
|
2962
2962
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2963
2963
|
|
|
2964
2964
|
"use strict";
|
|
2965
|
-
eval("\n\nvar _Object$keys = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _now = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/date/now */ \"../../../node_modules/@babel/runtime-corejs2/core-js/date/now.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/common/dist/index.js\");\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _commonTimers = __webpack_require__(/*! @webex/common-timers */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/common-timers/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! uuid */ \"../../../node_modules/uuid/index.js\"));\nvar _metrics = _interopRequireDefault(__webpack_require__(/*! ./metrics */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/metrics.js\"));\nvar _constants = __webpack_require__(/*! ./constants */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/constants.js\");\nvar _featuresModel = _interopRequireDefault(__webpack_require__(/*! ./features/features-model */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/features/features-model.js\"));\nvar _ipNetworkDetector = _interopRequireDefault(__webpack_require__(/*! ./ipNetworkDetector */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/ipNetworkDetector.js\"));\nvar _types = __webpack_require__(/*! ./types */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/types.js\");\nvar _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _obj; // Internal Dependencies\nfunction ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\n/**\n * Determine if the plugin should be initialized based on cached storage.\n *\n * @returns {boolean} - If the device is ephemeral.\n */\nfunction decider() {\n return !this.config.ephemeral;\n}\nvar Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)('@'), _dec2 = (0, _webexCore.waitForValue)('@'), _dec3 = (0, _webexCore.waitForValue)('@'), _dec4 = (0, _webexCore.waitForValue)('@'), _dec5 = (0, _common.deprecated)('device#markUrlFailedAndGetNew(): Use services#markFailedUrl()'), _dec6 = (0, _webexCore.persist)('@', decider), (_obj = {\n // Ampersand property members.\n\n namespace: 'Device',\n // Allow for extra properties to prevent the plugin from failing due to\n // **WDM** service DTO changes.\n extraProperties: 'allow',\n idAttribute: 'url',\n children: {\n /**\n * The class object that contains all of the feature collections.\n *\n * @type {FeaturesModel}\n */\n features: _featuresModel.default,\n /**\n * Helper class for detecting what IP network version (ipv4, ipv6) we're on.\n *\n * @type {IpNetworkDetector}\n */\n ipNetworkDetector: _ipNetworkDetector.default\n },\n /**\n * A collection of device properties mostly assigned by the retrieved DTO from\n * the **WDM** service that are mapped against the ampersand properties.\n *\n * @type {Object}\n */\n props: {\n /**\n * This property determines whether or not giphy support is enabled.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n clientMessagingGiphy: 'string',\n /**\n * This property should store the company name.\n *\n * @type {string}\n */\n customerCompanyName: 'string',\n /**\n * This property should store the logo url.\n *\n * @type {string}\n */\n customerLogoUrl: 'string',\n /**\n * This property doesn't have any real values, but is sent during device\n * refresh to prevent the **wdm** service from falling back to an iOS device\n * type.\n *\n * @type {string}\n */\n deviceType: 'string',\n /**\n * This property should store the help url.\n *\n * @type {string}\n */\n helpUrl: 'string',\n /**\n * This property should store the intranet inactivity timer duration.\n *\n * @type {number}\n */\n intranetInactivityDuration: 'number',\n /**\n * This property stores the url required to validate if the device is able\n * to actively reach the intranet network.\n *\n * @type {string}\n */\n intranetInactivityCheckUrl: 'string',\n /**\n * This property stores the inactivity timer duration, and could possibly\n * deprecate the `intranetInactivityDuration` property.\n *\n * @type {number}\n */\n inNetworkInactivityDuration: 'number',\n /**\n * This property stores the ECM (external content management) enabled value\n * for the whole organization.\n *\n * @type {boolean}\n */\n ecmEnabledForAllUsers: ['boolean', false, false],\n /**\n * This property stores an array of ECM (external content management)\n * providers that are currently available.\n *\n * @returns {Array<string>}\n */\n ecmSupportedStorageProviders: ['array', false, function () {\n return [];\n }],\n /**\n * This property stores the modification time value retrieved from the\n * **WDM** endpoint formatted as ISO 8601.\n *\n * @type {string}\n */\n modificationTime: 'string',\n /**\n * This property stores the navigation bar color.\n *\n * @type {string}\n */\n navigationBarColor: 'string',\n /**\n * This property stores the partner company's name when available.\n *\n * @type {string}\n */\n partnerCompanyName: 'string',\n /**\n * This property stores the partner company's logo when available.\n *\n * @type {string}\n */\n partnerLogoUrl: 'string',\n /**\n * This property stores the availability of people data from the **WDM**\n * service.\n *\n * @type {boolean}\n */\n peopleInsightsEnabled: 'boolean',\n /**\n * This property stores the reporting site's description when available.\n *\n * @type {string}\n */\n reportingSiteDesc: 'string',\n /**\n * This property stores the reporting site's access url when available.\n *\n * @type {string}\n */\n reportingSiteUrl: 'string',\n /**\n * This property stores the encryption key url when available.\n *\n * @type {string}\n */\n searchEncryptionKeyUrl: 'string',\n /**\n * This property stores the availability of support-provided text from the\n * **WDM** service.\n *\n * @type {boolean}\n */\n showSupportText: 'boolean',\n /**\n * This property stores the support provider's company name when available.\n *\n * @type {string}\n */\n supportProviderCompanyName: 'string',\n /**\n * This property stores the support provider's logo url when available.\n *\n * @type {string}\n */\n supportProviderLogoUrl: 'string',\n /**\n * This property stores the device's url retrieved from a registration\n * request. This property gets set via the initial registration process by a\n * `this.set()` method.\n *\n * @type {string}\n */\n url: 'string',\n /**\n * This property stores the device's userId uuid value, which can also be\n * derived from the device's registerd user's userId retrieved from\n * the **Hydra** service.\n *\n * @type {string}\n */\n userId: 'string',\n /**\n * This property stores whether or not file sharing is enabled\n *\n * @type {'BLOCK_BOTH' | 'BLOCK_UPLOAD'}\n */\n webFileShareControl: 'string',\n /**\n * This property stores the current web socket url used by the registered\n * device.\n *\n * @type {string}\n */\n webSocketUrl: 'string',\n /**\n * This property stores the value indicating whether or not white board file\n * sharing is enabled for the current device.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n whiteboardFileShareControl: 'string'\n },\n /**\n * A list of derived properties that populate based when their parent data\n * available via the device's properties.\n *\n * @type {Object}\n */\n derived: {\n /**\n * This property determines if the current device is registered.\n *\n * @type {boolean}\n */\n registered: {\n deps: ['url'],\n /**\n * Checks if the device is registered by validating that the url exists.\n * Amperstand does not allow this to method to be written as an arrow\n * function.\n *\n * @returns {boolean}\n */\n fn: function fn() {\n return !!this.url;\n }\n }\n },\n /**\n * Stores timer data as well as other state details.\n *\n * @type {Object}\n */\n session: {\n /**\n * This property stores the logout timer object\n *\n * @type {any}\n */\n logoutTimer: 'any',\n /**\n * This property stores the date for the last activity the user made\n * with the current device.\n *\n * @type {number}\n */\n lastUserActivityDate: 'number',\n /**\n * This property stores whether or not the reachability check has been\n * performed to prevent the reachability check from performing its\n * operation more than once after a successful check.\n *\n * @returns {boolean}\n */\n isReachabilityChecked: ['boolean', false, false],\n /**\n * This property stores whether or not the next refresh or register request should request energy forecast data\n * in order to prevent over fetching energy forecasts\n *\n * @type {boolean}\n */\n energyForecastConfig: 'boolean',\n /**\n * This property stores whether or not the current device is in a meeting\n * to prevent an unneeded timeout of a meeting due to inactivity.\n *\n * @type {boolean}\n */\n isInMeeting: 'boolean',\n /**\n * This property identifies if the device is currently in network to prevent\n * the `resetLogoutTimer()` method from being called repeatedly once its\n * known client is connected to the organization's internal network.\n *\n * @type {boolean}\n */\n isInNetwork: 'boolean'\n },\n // Event method members.\n /**\n * Trigger meeting started event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingStarted: function meetingStarted() {\n this.webex.trigger('meeting started');\n },\n /**\n * Trigger meeting ended event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingEnded: function meetingEnded() {\n this.webex.trigger('meeting ended');\n },\n /**\n * Set the value of energy forecast config for the current registered device.\n * @param {boolean} [energyForecastConfig=false] - fetch an energy forecast on the next refresh/register\n * @returns {void}\n */\n setEnergyForecastConfig: function setEnergyForecastConfig() {\n var energyForecastConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n this.energyForecastConfig = energyForecastConfig;\n },\n refresh: function refresh() {\n var _this = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: refreshing');\n\n // Validate that the device can be registered.\n return this.canRegister().then(function () {\n // Validate if the device is not registered and register instead.\n if (!_this.registered) {\n _this.logger.info('device: device not registered, registering');\n return _this.register(deviceRegistrationOptions);\n }\n\n // Merge body configurations, overriding defaults.\n var body = _objectSpread(_objectSpread({}, _this.serialize()), _this.config.body ? _this.config.body : {});\n\n // Remove unneeded properties from the body object.\n delete body.features;\n delete body.mediaCluster;\n delete body.etag;\n\n // Append a ttl value if the device is marked as ephemeral.\n if (_this.config.ephemeral) {\n body.ttl = _this.config.ephemeralDeviceTTL;\n }\n\n // Merge header configurations, overriding defaults.\n var headers = _objectSpread(_objectSpread(_objectSpread({}, _this.config.defaults.headers ? _this.config.defaults.headers : {}), _this.config.headers ? _this.config.headers : {}), _this.etag ? {\n 'If-None-Match': _this.etag\n } : {});\n var _deviceRegistrationOp = deviceRegistrationOptions.includeDetails,\n includeDetails = _deviceRegistrationOp === void 0 ? _types.CatalogDetails.all : _deviceRegistrationOp;\n var requestId = _uuid.default.v4();\n _this.set('refresh-request-id', requestId);\n return _this.request({\n method: 'PUT',\n uri: _this.url,\n body: body,\n headers: headers,\n qs: {\n includeUpstreamServices: \"\".concat(includeDetails).concat(_this.config.energyForecast && _this.energyForecastConfig ? ',energyforecast' : '')\n }\n }).then(function (response) {\n // If we've signed out in the mean time, the request ID will have changed\n if (_this.get('refresh-request-id') !== requestId) {\n _this.logger.info('device: refresh request ID mismatch, ignoring response');\n return _promise.default.resolve();\n }\n return _this.processRegistrationSuccess(response);\n }).catch(function (reason) {\n // Handle a 404 error, which indicates that the device is no longer\n // valid and needs to be registered as a new device.\n if (reason.statusCode === 404) {\n _this.logger.info('device: refresh failed, device is not valid');\n _this.logger.info('device: attempting to register a new device');\n _this.clear();\n return _this.register(deviceRegistrationOptions);\n }\n return _promise.default.reject(reason);\n });\n });\n },\n /**\n * Fetches the web devices and deletes the third of them which are not recent devices in use\n * @returns {Promise<void, Error>}\n */\n deleteDevices: function deleteDevices() {\n var _this2 = this;\n // Fetch devices with a GET request\n return this.request({\n method: 'GET',\n service: 'wdm',\n resource: 'devices'\n }).then(function (response) {\n var devices = response.body.devices;\n var _this2$_getBody = _this2._getBody(),\n deviceType = _this2$_getBody.deviceType;\n\n // Filter devices of type deviceType\n var webDevices = devices.filter(function (item) {\n return item.deviceType === deviceType;\n });\n var sortedDevices = (0, _lodash.orderBy)(webDevices, [function (item) {\n return new Date(item.modificationTime);\n }]);\n\n // If there are more than two devices, delete the last third\n if (sortedDevices.length > 2) {\n var totalItems = sortedDevices.length;\n var countToDelete = Math.ceil(totalItems / 3);\n var urlsToDelete = sortedDevices.slice(0, countToDelete).map(function (item) {\n return item.url;\n });\n return _promise.default.race(urlsToDelete.map(function (url) {\n return _this2.request({\n uri: url,\n method: 'DELETE'\n });\n }));\n }\n return _promise.default.resolve();\n }).catch(function (error) {\n _this2.logger.error('Failed to retrieve devices:', error);\n return _promise.default.reject(error);\n });\n },\n register: function register() {\n var _this3 = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: registering');\n this.webex.internal.newMetrics.callDiagnosticMetrics.setDeviceInfo(this);\n\n // Validate that the device can be registered.\n return this.canRegister().then(function () {\n // Validate if the device is already registered and refresh instead.\n if (_this3.registered) {\n _this3.logger.info('device: device already registered, refreshing');\n return _this3.refresh(deviceRegistrationOptions);\n }\n return _this3._registerInternal(deviceRegistrationOptions).catch(function (error) {\n var _error$body;\n if ((error === null || error === void 0 ? void 0 : (_error$body = error.body) === null || _error$body === void 0 ? void 0 : _error$body.message) === 'User has excessive device registrations') {\n return _this3.deleteDevices().then(function () {\n return _this3._registerInternal(deviceRegistrationOptions);\n });\n }\n throw error;\n });\n });\n },\n _getBody: function _getBody() {\n return _objectSpread(_objectSpread({}, this.config.defaults.body ? this.config.defaults.body : {}), this.config.body ? this.config.body : {});\n },\n _registerInternal: function _registerInternal() {\n var _this4 = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: making registration request');\n\n // Merge body configurations, overriding defaults.\n var body = this._getBody();\n\n // Merge header configurations, overriding defaults.\n var headers = _objectSpread(_objectSpread({}, this.config.defaults.headers ? this.config.defaults.headers : {}), this.config.headers ? this.config.headers : {});\n\n // Append a ttl value if the device is marked as ephemeral\n if (this.config.ephemeral) {\n body.ttl = this.config.ephemeralDeviceTTL;\n }\n this.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.request'\n });\n var _deviceRegistrationOp2 = deviceRegistrationOptions.includeDetails,\n includeDetails = _deviceRegistrationOp2 === void 0 ? _types.CatalogDetails.all : _deviceRegistrationOp2;\n var requestId = _uuid.default.v4();\n this.set('register-request-id', requestId);\n\n // This will be replaced by a `create()` method.\n return this.request({\n method: 'POST',\n service: 'wdm',\n resource: 'devices',\n body: body,\n headers: headers,\n qs: {\n includeUpstreamServices: \"\".concat(includeDetails).concat(this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : '')\n }\n }).catch(function (error) {\n _this4.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response'\n });\n throw error;\n }).then(function (response) {\n // If we've signed out in the mean time, the request ID will have changed\n if (_this4.get('register-request-id') !== requestId) {\n _this4.logger.info('device: register request ID mismatch, ignoring response');\n return _promise.default.resolve();\n }\n\n // Do not add any processing of response above this as that will affect timestamp\n _this4.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response'\n });\n _this4.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_SUCCESSFUL);\n return _this4.processRegistrationSuccess(response);\n }).catch(function (error) {\n _this4.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_FAILED, {\n fields: {\n error: error\n }\n });\n throw error;\n });\n },\n unregister: function unregister() {\n var _this5 = this;\n this.logger.info('device: unregistering');\n if (!this.registered) {\n this.logger.warn('device: not registered');\n return _promise.default.resolve();\n }\n return this.request({\n uri: this.url,\n method: 'DELETE'\n }).then(function () {\n return _this5.clear();\n }).catch(function (reason) {\n if (reason.statusCode === 404) {\n _this5.logger.info('device: 404 when deleting device, device is already deleted, clearing device');\n _this5.clear();\n }\n throw reason;\n });\n },\n /* eslint-enable require-jsdoc */\n // Helper method members\n /**\n * Determine if registration methods can be performed. This method utilizes\n * the `services` plugin to confirm if the appropriate service urls are\n * available for device registration.\n *\n * @returns {Promise<void, Error>}\n */\n canRegister: function canRegister() {\n this.logger.info('device: validating if registration can occur');\n\n // Destructure the services plugin for ease of reference.\n var services = this.webex.internal.services;\n\n // Wait for the postauth catalog to populate.\n return services.waitForCatalog('postauth', this.config.canRegisterWaitDuration).then(function () {\n return (\n // Validate that the service exists after waiting for the catalog.\n services.get('wdm') ? _promise.default.resolve() : _promise.default.reject(new Error(['device: cannot register,', \"'wdm' service is not available from the postauth catalog\"].join(' ')))\n );\n });\n },\n /**\n * Check if the device can currently reach the inactivity check url.\n *\n * @returns {Promise<void, Error>}\n */\n checkNetworkReachability: function checkNetworkReachability() {\n var _this6 = this;\n this.logger.info('device: checking network reachability');\n\n // Validate if the device has been checked and reset the logout timer.\n if (this.isReachabilityChecked) {\n return _promise.default.resolve(this.resetLogoutTimer());\n }\n this.isReachabilityChecked = true;\n\n // Validate if the device has a intranet checking url.\n if (!this.intranetInactivityCheckUrl) {\n this.isInNetwork = false;\n return _promise.default.resolve(this.resetLogoutTimer());\n }\n\n // Clear unnecessary headers for reachability request.\n var headers = {\n 'cisco-no-http-redirect': null,\n 'spark-user-agent': null,\n trackingid: null\n };\n\n // Send the network reachability request.\n return this.request({\n headers: headers,\n method: 'GET',\n uri: this.intranetInactivityCheckUrl\n }).then(function () {\n _this6.isInNetwork = true;\n return _promise.default.resolve(_this6.resetLogoutTimer());\n }).catch(function () {\n _this6.logger.info('device: did not reach ping endpoint');\n _this6.logger.info('device: triggering off-network timer');\n _this6.isInNetwork = false;\n return _promise.default.resolve(_this6.resetLogoutTimer());\n });\n },\n /**\n * Clears the registration ttl value if available.\n *\n * @param {Object} options - Values to be cleared.\n * @returns {void}\n */\n clear: function clear() {\n this.logger.info('device: clearing registered device');\n\n // Prototype the extended class in order to preserve the parent member.\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n (0, _apply.default)(_webexCore.WebexPlugin.prototype.clear, this, args);\n },\n /**\n * Get the current websocket url with the appropriate priority host.\n *\n * @param {boolean} [wait=false] - Willing to wait on a valid url.\n * @returns {Promise<string, Error>} - The priority-mapped web socket url.\n */\n getWebSocketUrl: function getWebSocketUrl() {\n var _this7 = this;\n var wait = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n this.logger.info('device: getting the current websocket url');\n\n // Destructure the services plugin for ease of reference.\n var services = this.webex.internal.services;\n\n // Validate if the method should wait for registration.\n if (wait) {\n return this.waitForRegistration().then(function () {\n return services.convertUrlToPriorityHostUrl(_this7.webSocketUrl);\n }).catch(function (error) {\n _this7.logger.warn(error.message);\n return _promise.default.reject(new Error('device: failed to get the current websocket url'));\n });\n }\n\n // Validate if the device is registered.\n if (!this.registered) {\n return _promise.default.reject(new Error('device: cannot get websocket url, device is not registered'));\n }\n\n // Attempt to collect the priority-host-mapped web socket URL.\n var wsUrl = services.convertUrlToPriorityHostUrl(this.webSocketUrl);\n\n // Validate that the url was collected.\n if (wsUrl) {\n return _promise.default.resolve(wsUrl);\n }\n return _promise.default.reject(new Error('device: failed to get the current websocket url'));\n },\n /**\n * Process a successful device registration.\n *\n * @param {Object} response - response object from registration success.\n * @returns {void}\n */\n processRegistrationSuccess: function processRegistrationSuccess(response) {\n var _this8 = this;\n this.logger.info('device: received registration payload');\n\n // Clone the response body for service cleaning.\n var body = _objectSpread({}, response.body);\n\n // Clean service data.\n delete body.services;\n delete body.serviceHostMap;\n var _ref = response.headers || {},\n etag = _ref.etag;\n if (this.etag && etag && this.etag === etag) {\n // If current etag matches the previous one and we have sent\n // If-None-Match header the developer and entitlement feature\n // toggles will not be returned\n var features = body.features;\n delete body.features;\n // When using the etag feature cache, user and entitlement features are still returned\n this.features.user.reset(features.user);\n this.features.entitlement.reset(features.entitlement);\n }\n\n // Assign the recieved DTO from **WDM** to this device.\n this.set(body);\n\n // Assign the new etag to this device.\n this.set({\n etag: etag\n });\n\n // Validate if device is ephemeral and setup refresh timer.\n if (this.config.ephemeral) {\n this.logger.info('device: enqueuing device refresh');\n var delay = (this.config.ephemeralDeviceTTL / 2 + 60) * 1000;\n this.refreshTimer = (0, _commonTimers.safeSetTimeout)(function () {\n return _this8.refresh();\n }, delay);\n }\n\n // Emit the registration:success event.\n this.trigger(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, this);\n },\n /**\n * Reset the current local logout timer for the registered device if\n * registered.\n *\n * @returns {void}\n */\n resetLogoutTimer: function resetLogoutTimer() {\n this.logger.info('device: resetting logout timer');\n\n // Clear current logout timer.\n clearTimeout(this.logoutTimer);\n\n // Remove last activity date event listener.\n this.off('change:lastUserActivityDate');\n\n // Remove the logout timer.\n this.unset('logoutTimer');\n\n // Validate if the device is currently in a meeting and is configured to\n // required inactivity enforcement.\n if (!this.isInMeeting && this.config.enableInactivityEnforcement && this.isReachabilityChecked) {\n if (this.isInNetwork) {\n this.setLogoutTimer(this.inNetworkInactivityDuration);\n } else {\n this.setLogoutTimer(this.intranetInactivityDuration);\n }\n }\n },\n /**\n * Set the value of the logout timer for the current registered device.\n *\n * @param {number} duration - Value in seconds of the new logout timer.\n * @returns {void}\n */\n setLogoutTimer: function setLogoutTimer(duration) {\n var _this9 = this;\n this.logger.info('device: setting logout timer');\n if (!duration || duration <= 0) {\n return;\n }\n\n // Setup user activity date event listener.\n this.on('change:lastUserActivityDate', function () {\n _this9.resetLogoutTimer();\n });\n\n // Initialize a new timer.\n this.logoutTimer = (0, _commonTimers.safeSetTimeout)(function () {\n _this9.webex.logout();\n }, duration * 1000);\n },\n /**\n * Wait for the device to be registered.\n *\n * @param {number} [timeout=10] - The maximum duration to wait, in seconds.\n * @returns {Promise<void, Error>}\n */\n waitForRegistration: function waitForRegistration() {\n var _this10 = this;\n var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;\n this.logger.info('device: waiting for registration');\n return new _promise.default(function (resolve, reject) {\n if (_this10.registered) {\n resolve();\n }\n var timeoutTimer = (0, _commonTimers.safeSetTimeout)(function () {\n return reject(new Error('device: timeout occured while waiting for registration'));\n }, timeout * 1000);\n _this10.once(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, function () {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n markUrlFailedAndGetNew: function markUrlFailedAndGetNew(url) {\n return _promise.default.resolve(this.webex.internal.services.markFailedUrl(url));\n },\n initialize: function initialize() {\n var _this11 = this;\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n // Prototype the extended class in order to preserve the parent member.\n (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args);\n\n // Initialize feature events and listeners.\n _constants.FEATURE_COLLECTION_NAMES.forEach(function (collectionName) {\n _this11.features.on(\"change:\".concat(collectionName), function (model, value, options) {\n _this11.trigger('change', _this11, options);\n _this11.trigger('change:features', _this11, _this11.features, options);\n });\n });\n\n // Initialize network reachability checking event for url change.\n this.on('change:intranetInactivityCheckUrl', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:intranetInactivityDuration', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:inNetworkInactivityDuration', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize listener for activity checking.\n this.listenTo(this.webex, 'user-activity', function () {\n _this11.lastUserActivityDate = (0, _now.default)();\n });\n\n // Initialize listener for meeting started event.\n this.listenTo(this.webex, 'meeting started', function () {\n _this11.isInMeeting = true;\n _this11.resetLogoutTimer();\n });\n\n // Initialize listener for meeting ended event.\n this.listenTo(this.webex, 'meeting ended', function () {\n _this11.isInMeeting = false;\n _this11.resetLogoutTimer();\n });\n } /* eslint-enable require-jsdoc */,\n version: \"3.8.0-next.11\"\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"refresh\", [_common.oneFlight, _dec], (0, _getOwnPropertyDescriptor.default)(_obj, \"refresh\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"register\", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, \"register\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"_registerInternal\", [_common.oneFlight, _dec3], (0, _getOwnPropertyDescriptor.default)(_obj, \"_registerInternal\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"unregister\", [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor.default)(_obj, \"unregister\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"markUrlFailedAndGetNew\", [_dec5], (0, _getOwnPropertyDescriptor.default)(_obj, \"markUrlFailedAndGetNew\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"initialize\", [_dec6], (0, _getOwnPropertyDescriptor.default)(_obj, \"initialize\"), _obj)), _obj)));\nvar _default = exports[\"default\"] = Device;\n//# sourceMappingURL=device.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/device.js?");
|
|
2965
|
+
eval("\n\nvar _Object$keys = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _now = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/date/now */ \"../../../node_modules/@babel/runtime-corejs2/core-js/date/now.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/common/dist/index.js\");\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _commonTimers = __webpack_require__(/*! @webex/common-timers */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/common-timers/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! uuid */ \"../../../node_modules/uuid/index.js\"));\nvar _metrics = _interopRequireDefault(__webpack_require__(/*! ./metrics */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/metrics.js\"));\nvar _constants = __webpack_require__(/*! ./constants */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/constants.js\");\nvar _featuresModel = _interopRequireDefault(__webpack_require__(/*! ./features/features-model */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/features/features-model.js\"));\nvar _ipNetworkDetector = _interopRequireDefault(__webpack_require__(/*! ./ipNetworkDetector */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/ipNetworkDetector.js\"));\nvar _types = __webpack_require__(/*! ./types */ \"../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/types.js\");\nvar _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _obj; // Internal Dependencies\nfunction ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\n/**\n * Determine if the plugin should be initialized based on cached storage.\n *\n * @returns {boolean} - If the device is ephemeral.\n */\nfunction decider() {\n return !this.config.ephemeral;\n}\nvar Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)('@'), _dec2 = (0, _webexCore.waitForValue)('@'), _dec3 = (0, _webexCore.waitForValue)('@'), _dec4 = (0, _webexCore.waitForValue)('@'), _dec5 = (0, _common.deprecated)('device#markUrlFailedAndGetNew(): Use services#markFailedUrl()'), _dec6 = (0, _webexCore.persist)('@', decider), (_obj = {\n // Ampersand property members.\n\n namespace: 'Device',\n // Allow for extra properties to prevent the plugin from failing due to\n // **WDM** service DTO changes.\n extraProperties: 'allow',\n idAttribute: 'url',\n children: {\n /**\n * The class object that contains all of the feature collections.\n *\n * @type {FeaturesModel}\n */\n features: _featuresModel.default,\n /**\n * Helper class for detecting what IP network version (ipv4, ipv6) we're on.\n *\n * @type {IpNetworkDetector}\n */\n ipNetworkDetector: _ipNetworkDetector.default\n },\n /**\n * A collection of device properties mostly assigned by the retrieved DTO from\n * the **WDM** service that are mapped against the ampersand properties.\n *\n * @type {Object}\n */\n props: {\n /**\n * This property determines whether or not giphy support is enabled.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n clientMessagingGiphy: 'string',\n /**\n * This property should store the company name.\n *\n * @type {string}\n */\n customerCompanyName: 'string',\n /**\n * This property should store the logo url.\n *\n * @type {string}\n */\n customerLogoUrl: 'string',\n /**\n * This property doesn't have any real values, but is sent during device\n * refresh to prevent the **wdm** service from falling back to an iOS device\n * type.\n *\n * @type {string}\n */\n deviceType: 'string',\n /**\n * This property should store the help url.\n *\n * @type {string}\n */\n helpUrl: 'string',\n /**\n * This property should store the intranet inactivity timer duration.\n *\n * @type {number}\n */\n intranetInactivityDuration: 'number',\n /**\n * This property stores the url required to validate if the device is able\n * to actively reach the intranet network.\n *\n * @type {string}\n */\n intranetInactivityCheckUrl: 'string',\n /**\n * This property stores the inactivity timer duration, and could possibly\n * deprecate the `intranetInactivityDuration` property.\n *\n * @type {number}\n */\n inNetworkInactivityDuration: 'number',\n /**\n * This property stores the ECM (external content management) enabled value\n * for the whole organization.\n *\n * @type {boolean}\n */\n ecmEnabledForAllUsers: ['boolean', false, false],\n /**\n * This property stores an array of ECM (external content management)\n * providers that are currently available.\n *\n * @returns {Array<string>}\n */\n ecmSupportedStorageProviders: ['array', false, function () {\n return [];\n }],\n /**\n * This property stores the modification time value retrieved from the\n * **WDM** endpoint formatted as ISO 8601.\n *\n * @type {string}\n */\n modificationTime: 'string',\n /**\n * This property stores the navigation bar color.\n *\n * @type {string}\n */\n navigationBarColor: 'string',\n /**\n * This property stores the partner company's name when available.\n *\n * @type {string}\n */\n partnerCompanyName: 'string',\n /**\n * This property stores the partner company's logo when available.\n *\n * @type {string}\n */\n partnerLogoUrl: 'string',\n /**\n * This property stores the availability of people data from the **WDM**\n * service.\n *\n * @type {boolean}\n */\n peopleInsightsEnabled: 'boolean',\n /**\n * This property stores the reporting site's description when available.\n *\n * @type {string}\n */\n reportingSiteDesc: 'string',\n /**\n * This property stores the reporting site's access url when available.\n *\n * @type {string}\n */\n reportingSiteUrl: 'string',\n /**\n * This property stores the encryption key url when available.\n *\n * @type {string}\n */\n searchEncryptionKeyUrl: 'string',\n /**\n * This property stores the availability of support-provided text from the\n * **WDM** service.\n *\n * @type {boolean}\n */\n showSupportText: 'boolean',\n /**\n * This property stores the support provider's company name when available.\n *\n * @type {string}\n */\n supportProviderCompanyName: 'string',\n /**\n * This property stores the support provider's logo url when available.\n *\n * @type {string}\n */\n supportProviderLogoUrl: 'string',\n /**\n * This property stores the device's url retrieved from a registration\n * request. This property gets set via the initial registration process by a\n * `this.set()` method.\n *\n * @type {string}\n */\n url: 'string',\n /**\n * This property stores the device's userId uuid value, which can also be\n * derived from the device's registerd user's userId retrieved from\n * the **Hydra** service.\n *\n * @type {string}\n */\n userId: 'string',\n /**\n * This property stores whether or not file sharing is enabled\n *\n * @type {'BLOCK_BOTH' | 'BLOCK_UPLOAD'}\n */\n webFileShareControl: 'string',\n /**\n * This property stores the current web socket url used by the registered\n * device.\n *\n * @type {string}\n */\n webSocketUrl: 'string',\n /**\n * This property stores the value indicating whether or not white board file\n * sharing is enabled for the current device.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n whiteboardFileShareControl: 'string'\n },\n /**\n * A list of derived properties that populate based when their parent data\n * available via the device's properties.\n *\n * @type {Object}\n */\n derived: {\n /**\n * This property determines if the current device is registered.\n *\n * @type {boolean}\n */\n registered: {\n deps: ['url'],\n /**\n * Checks if the device is registered by validating that the url exists.\n * Amperstand does not allow this to method to be written as an arrow\n * function.\n *\n * @returns {boolean}\n */\n fn: function fn() {\n return !!this.url;\n }\n }\n },\n /**\n * Stores timer data as well as other state details.\n *\n * @type {Object}\n */\n session: {\n /**\n * This property stores the logout timer object\n *\n * @type {any}\n */\n logoutTimer: 'any',\n /**\n * This property stores the date for the last activity the user made\n * with the current device.\n *\n * @type {number}\n */\n lastUserActivityDate: 'number',\n /**\n * This property stores whether or not the reachability check has been\n * performed to prevent the reachability check from performing its\n * operation more than once after a successful check.\n *\n * @returns {boolean}\n */\n isReachabilityChecked: ['boolean', false, false],\n /**\n * This property stores whether or not the next refresh or register request should request energy forecast data\n * in order to prevent over fetching energy forecasts\n *\n * @type {boolean}\n */\n energyForecastConfig: 'boolean',\n /**\n * This property stores whether or not the current device is in a meeting\n * to prevent an unneeded timeout of a meeting due to inactivity.\n *\n * @type {boolean}\n */\n isInMeeting: 'boolean',\n /**\n * This property identifies if the device is currently in network to prevent\n * the `resetLogoutTimer()` method from being called repeatedly once its\n * known client is connected to the organization's internal network.\n *\n * @type {boolean}\n */\n isInNetwork: 'boolean'\n },\n // Event method members.\n /**\n * Trigger meeting started event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingStarted: function meetingStarted() {\n this.webex.trigger('meeting started');\n },\n /**\n * Trigger meeting ended event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingEnded: function meetingEnded() {\n this.webex.trigger('meeting ended');\n },\n /**\n * Set the value of energy forecast config for the current registered device.\n * @param {boolean} [energyForecastConfig=false] - fetch an energy forecast on the next refresh/register\n * @returns {void}\n */\n setEnergyForecastConfig: function setEnergyForecastConfig() {\n var energyForecastConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n this.energyForecastConfig = energyForecastConfig;\n },\n refresh: function refresh() {\n var _this = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: refreshing');\n\n // Validate that the device can be registered.\n return this.canRegister().then(function () {\n // Validate if the device is not registered and register instead.\n if (!_this.registered) {\n _this.logger.info('device: device not registered, registering');\n return _this.register(deviceRegistrationOptions);\n }\n\n // Merge body configurations, overriding defaults.\n var body = _objectSpread(_objectSpread({}, _this.serialize()), _this.config.body ? _this.config.body : {});\n\n // Remove unneeded properties from the body object.\n delete body.features;\n delete body.mediaCluster;\n delete body.etag;\n\n // Append a ttl value if the device is marked as ephemeral.\n if (_this.config.ephemeral) {\n body.ttl = _this.config.ephemeralDeviceTTL;\n }\n\n // Merge header configurations, overriding defaults.\n var headers = _objectSpread(_objectSpread(_objectSpread({}, _this.config.defaults.headers ? _this.config.defaults.headers : {}), _this.config.headers ? _this.config.headers : {}), _this.etag ? {\n 'If-None-Match': _this.etag\n } : {});\n var _deviceRegistrationOp = deviceRegistrationOptions.includeDetails,\n includeDetails = _deviceRegistrationOp === void 0 ? _types.CatalogDetails.all : _deviceRegistrationOp;\n var requestId = _uuid.default.v4();\n _this.set('refresh-request-id', requestId);\n return _this.request({\n method: 'PUT',\n uri: _this.url,\n body: body,\n headers: headers,\n qs: {\n includeUpstreamServices: \"\".concat(includeDetails).concat(_this.config.energyForecast && _this.energyForecastConfig ? ',energyforecast' : '')\n }\n }).then(function (response) {\n // If we've signed out in the mean time, the request ID will have changed\n if (_this.get('refresh-request-id') !== requestId) {\n _this.logger.info('device: refresh request ID mismatch, ignoring response');\n return _promise.default.resolve();\n }\n return _this.processRegistrationSuccess(response);\n }).catch(function (reason) {\n // Handle a 404 error, which indicates that the device is no longer\n // valid and needs to be registered as a new device.\n if (reason.statusCode === 404) {\n _this.logger.info('device: refresh failed, device is not valid');\n _this.logger.info('device: attempting to register a new device');\n _this.clear();\n return _this.register(deviceRegistrationOptions);\n }\n return _promise.default.reject(reason);\n });\n });\n },\n /**\n * Fetches the web devices and deletes the third of them which are not recent devices in use\n * @returns {Promise<void, Error>}\n */\n deleteDevices: function deleteDevices() {\n var _this2 = this;\n // Fetch devices with a GET request\n return this.request({\n method: 'GET',\n service: 'wdm',\n resource: 'devices'\n }).then(function (response) {\n var devices = response.body.devices;\n var _this2$_getBody = _this2._getBody(),\n deviceType = _this2$_getBody.deviceType;\n\n // Filter devices of type deviceType\n var webDevices = devices.filter(function (item) {\n return item.deviceType === deviceType;\n });\n var sortedDevices = (0, _lodash.orderBy)(webDevices, [function (item) {\n return new Date(item.modificationTime);\n }]);\n\n // If there are more than two devices, delete the last third\n if (sortedDevices.length > 2) {\n var totalItems = sortedDevices.length;\n var countToDelete = Math.ceil(totalItems / 3);\n var urlsToDelete = sortedDevices.slice(0, countToDelete).map(function (item) {\n return item.url;\n });\n return _promise.default.race(urlsToDelete.map(function (url) {\n return _this2.request({\n uri: url,\n method: 'DELETE'\n });\n }));\n }\n return _promise.default.resolve();\n }).catch(function (error) {\n _this2.logger.error('Failed to retrieve devices:', error);\n return _promise.default.reject(error);\n });\n },\n register: function register() {\n var _this3 = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: registering');\n this.webex.internal.newMetrics.callDiagnosticMetrics.setDeviceInfo(this);\n\n // Validate that the device can be registered.\n return this.canRegister().then(function () {\n // Validate if the device is already registered and refresh instead.\n if (_this3.registered) {\n _this3.logger.info('device: device already registered, refreshing');\n return _this3.refresh(deviceRegistrationOptions);\n }\n return _this3._registerInternal(deviceRegistrationOptions).catch(function (error) {\n var _error$body;\n if ((error === null || error === void 0 ? void 0 : (_error$body = error.body) === null || _error$body === void 0 ? void 0 : _error$body.message) === 'User has excessive device registrations') {\n return _this3.deleteDevices().then(function () {\n return _this3._registerInternal(deviceRegistrationOptions);\n });\n }\n throw error;\n });\n });\n },\n _getBody: function _getBody() {\n return _objectSpread(_objectSpread({}, this.config.defaults.body ? this.config.defaults.body : {}), this.config.body ? this.config.body : {});\n },\n _registerInternal: function _registerInternal() {\n var _this4 = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: making registration request');\n\n // Merge body configurations, overriding defaults.\n var body = this._getBody();\n\n // Merge header configurations, overriding defaults.\n var headers = _objectSpread(_objectSpread({}, this.config.defaults.headers ? this.config.defaults.headers : {}), this.config.headers ? this.config.headers : {});\n\n // Append a ttl value if the device is marked as ephemeral\n if (this.config.ephemeral) {\n body.ttl = this.config.ephemeralDeviceTTL;\n }\n this.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.request'\n });\n var _deviceRegistrationOp2 = deviceRegistrationOptions.includeDetails,\n includeDetails = _deviceRegistrationOp2 === void 0 ? _types.CatalogDetails.all : _deviceRegistrationOp2;\n var requestId = _uuid.default.v4();\n this.set('register-request-id', requestId);\n\n // This will be replaced by a `create()` method.\n return this.request({\n method: 'POST',\n service: 'wdm',\n resource: 'devices',\n body: body,\n headers: headers,\n qs: {\n includeUpstreamServices: \"\".concat(includeDetails).concat(this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : '')\n }\n }).catch(function (error) {\n _this4.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response'\n });\n throw error;\n }).then(function (response) {\n // If we've signed out in the mean time, the request ID will have changed\n if (_this4.get('register-request-id') !== requestId) {\n _this4.logger.info('device: register request ID mismatch, ignoring response');\n return _promise.default.resolve();\n }\n\n // Do not add any processing of response above this as that will affect timestamp\n _this4.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response'\n });\n _this4.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_SUCCESSFUL);\n return _this4.processRegistrationSuccess(response);\n }).catch(function (error) {\n _this4.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_FAILED, {\n fields: {\n error: error\n }\n });\n throw error;\n });\n },\n unregister: function unregister() {\n var _this5 = this;\n this.logger.info('device: unregistering');\n if (!this.registered) {\n this.logger.warn('device: not registered');\n return _promise.default.resolve();\n }\n return this.request({\n uri: this.url,\n method: 'DELETE'\n }).then(function () {\n return _this5.clear();\n }).catch(function (reason) {\n if (reason.statusCode === 404) {\n _this5.logger.info('device: 404 when deleting device, device is already deleted, clearing device');\n _this5.clear();\n }\n throw reason;\n });\n },\n /* eslint-enable require-jsdoc */\n // Helper method members\n /**\n * Determine if registration methods can be performed. This method utilizes\n * the `services` plugin to confirm if the appropriate service urls are\n * available for device registration.\n *\n * @returns {Promise<void, Error>}\n */\n canRegister: function canRegister() {\n this.logger.info('device: validating if registration can occur');\n\n // Destructure the services plugin for ease of reference.\n var services = this.webex.internal.services;\n\n // Wait for the postauth catalog to populate.\n return services.waitForCatalog('postauth', this.config.canRegisterWaitDuration).then(function () {\n return (\n // Validate that the service exists after waiting for the catalog.\n services.get('wdm') ? _promise.default.resolve() : _promise.default.reject(new Error(['device: cannot register,', \"'wdm' service is not available from the postauth catalog\"].join(' ')))\n );\n });\n },\n /**\n * Check if the device can currently reach the inactivity check url.\n *\n * @returns {Promise<void, Error>}\n */\n checkNetworkReachability: function checkNetworkReachability() {\n var _this6 = this;\n this.logger.info('device: checking network reachability');\n\n // Validate if the device has been checked and reset the logout timer.\n if (this.isReachabilityChecked) {\n return _promise.default.resolve(this.resetLogoutTimer());\n }\n this.isReachabilityChecked = true;\n\n // Validate if the device has a intranet checking url.\n if (!this.intranetInactivityCheckUrl) {\n this.isInNetwork = false;\n return _promise.default.resolve(this.resetLogoutTimer());\n }\n\n // Clear unnecessary headers for reachability request.\n var headers = {\n 'cisco-no-http-redirect': null,\n 'spark-user-agent': null,\n trackingid: null\n };\n\n // Send the network reachability request.\n return this.request({\n headers: headers,\n method: 'GET',\n uri: this.intranetInactivityCheckUrl\n }).then(function () {\n _this6.isInNetwork = true;\n return _promise.default.resolve(_this6.resetLogoutTimer());\n }).catch(function () {\n _this6.logger.info('device: did not reach ping endpoint');\n _this6.logger.info('device: triggering off-network timer');\n _this6.isInNetwork = false;\n return _promise.default.resolve(_this6.resetLogoutTimer());\n });\n },\n /**\n * Clears the registration ttl value if available.\n *\n * @param {Object} options - Values to be cleared.\n * @returns {void}\n */\n clear: function clear() {\n this.logger.info('device: clearing registered device');\n\n // Prototype the extended class in order to preserve the parent member.\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n (0, _apply.default)(_webexCore.WebexPlugin.prototype.clear, this, args);\n },\n /**\n * Get the current websocket url with the appropriate priority host.\n *\n * @param {boolean} [wait=false] - Willing to wait on a valid url.\n * @returns {Promise<string, Error>} - The priority-mapped web socket url.\n */\n getWebSocketUrl: function getWebSocketUrl() {\n var _this7 = this;\n var wait = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n this.logger.info('device: getting the current websocket url');\n\n // Destructure the services plugin for ease of reference.\n var services = this.webex.internal.services;\n\n // Validate if the method should wait for registration.\n if (wait) {\n return this.waitForRegistration().then(function () {\n return services.convertUrlToPriorityHostUrl(_this7.webSocketUrl);\n }).catch(function (error) {\n _this7.logger.warn(error.message);\n return _promise.default.reject(new Error('device: failed to get the current websocket url'));\n });\n }\n\n // Validate if the device is registered.\n if (!this.registered) {\n return _promise.default.reject(new Error('device: cannot get websocket url, device is not registered'));\n }\n\n // Attempt to collect the priority-host-mapped web socket URL.\n var wsUrl = services.convertUrlToPriorityHostUrl(this.webSocketUrl);\n\n // Validate that the url was collected.\n if (wsUrl) {\n return _promise.default.resolve(wsUrl);\n }\n return _promise.default.reject(new Error('device: failed to get the current websocket url'));\n },\n /**\n * Process a successful device registration.\n *\n * @param {Object} response - response object from registration success.\n * @returns {void}\n */\n processRegistrationSuccess: function processRegistrationSuccess(response) {\n var _this8 = this;\n this.logger.info('device: received registration payload');\n\n // Clone the response body for service cleaning.\n var body = _objectSpread({}, response.body);\n\n // Clean service data.\n delete body.services;\n delete body.serviceHostMap;\n var _ref = response.headers || {},\n etag = _ref.etag;\n if (this.etag && etag && this.etag === etag) {\n // If current etag matches the previous one and we have sent\n // If-None-Match header the developer and entitlement feature\n // toggles will not be returned\n var features = body.features;\n delete body.features;\n // When using the etag feature cache, user and entitlement features are still returned\n this.features.user.reset(features.user);\n this.features.entitlement.reset(features.entitlement);\n }\n\n // Assign the recieved DTO from **WDM** to this device.\n this.set(body);\n\n // Assign the new etag to this device.\n this.set({\n etag: etag\n });\n\n // Validate if device is ephemeral and setup refresh timer.\n if (this.config.ephemeral) {\n this.logger.info('device: enqueuing device refresh');\n var delay = (this.config.ephemeralDeviceTTL / 2 + 60) * 1000;\n this.refreshTimer = (0, _commonTimers.safeSetTimeout)(function () {\n return _this8.refresh();\n }, delay);\n }\n\n // Emit the registration:success event.\n this.trigger(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, this);\n },\n /**\n * Reset the current local logout timer for the registered device if\n * registered.\n *\n * @returns {void}\n */\n resetLogoutTimer: function resetLogoutTimer() {\n this.logger.info('device: resetting logout timer');\n\n // Clear current logout timer.\n clearTimeout(this.logoutTimer);\n\n // Remove last activity date event listener.\n this.off('change:lastUserActivityDate');\n\n // Remove the logout timer.\n this.unset('logoutTimer');\n\n // Validate if the device is currently in a meeting and is configured to\n // required inactivity enforcement.\n if (!this.isInMeeting && this.config.enableInactivityEnforcement && this.isReachabilityChecked) {\n if (this.isInNetwork) {\n this.setLogoutTimer(this.inNetworkInactivityDuration);\n } else {\n this.setLogoutTimer(this.intranetInactivityDuration);\n }\n }\n },\n /**\n * Set the value of the logout timer for the current registered device.\n *\n * @param {number} duration - Value in seconds of the new logout timer.\n * @returns {void}\n */\n setLogoutTimer: function setLogoutTimer(duration) {\n var _this9 = this;\n this.logger.info('device: setting logout timer');\n if (!duration || duration <= 0) {\n return;\n }\n\n // Setup user activity date event listener.\n this.on('change:lastUserActivityDate', function () {\n _this9.resetLogoutTimer();\n });\n\n // Initialize a new timer.\n this.logoutTimer = (0, _commonTimers.safeSetTimeout)(function () {\n _this9.webex.logout();\n }, duration * 1000);\n },\n /**\n * Wait for the device to be registered.\n *\n * @param {number} [timeout=10] - The maximum duration to wait, in seconds.\n * @returns {Promise<void, Error>}\n */\n waitForRegistration: function waitForRegistration() {\n var _this10 = this;\n var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;\n this.logger.info('device: waiting for registration');\n return new _promise.default(function (resolve, reject) {\n if (_this10.registered) {\n resolve();\n }\n var timeoutTimer = (0, _commonTimers.safeSetTimeout)(function () {\n return reject(new Error('device: timeout occured while waiting for registration'));\n }, timeout * 1000);\n _this10.once(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, function () {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n markUrlFailedAndGetNew: function markUrlFailedAndGetNew(url) {\n return _promise.default.resolve(this.webex.internal.services.markFailedUrl(url));\n },\n initialize: function initialize() {\n var _this11 = this;\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n // Prototype the extended class in order to preserve the parent member.\n (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args);\n\n // Initialize feature events and listeners.\n _constants.FEATURE_COLLECTION_NAMES.forEach(function (collectionName) {\n _this11.features.on(\"change:\".concat(collectionName), function (model, value, options) {\n _this11.trigger('change', _this11, options);\n _this11.trigger('change:features', _this11, _this11.features, options);\n });\n });\n\n // Initialize network reachability checking event for url change.\n this.on('change:intranetInactivityCheckUrl', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:intranetInactivityDuration', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:inNetworkInactivityDuration', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize listener for activity checking.\n this.listenTo(this.webex, 'user-activity', function () {\n _this11.lastUserActivityDate = (0, _now.default)();\n });\n\n // Initialize listener for meeting started event.\n this.listenTo(this.webex, 'meeting started', function () {\n _this11.isInMeeting = true;\n _this11.resetLogoutTimer();\n });\n\n // Initialize listener for meeting ended event.\n this.listenTo(this.webex, 'meeting ended', function () {\n _this11.isInMeeting = false;\n _this11.resetLogoutTimer();\n });\n } /* eslint-enable require-jsdoc */,\n version: \"3.8.0-next.12\"\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"refresh\", [_common.oneFlight, _dec], (0, _getOwnPropertyDescriptor.default)(_obj, \"refresh\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"register\", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, \"register\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"_registerInternal\", [_common.oneFlight, _dec3], (0, _getOwnPropertyDescriptor.default)(_obj, \"_registerInternal\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"unregister\", [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor.default)(_obj, \"unregister\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"markUrlFailedAndGetNew\", [_dec5], (0, _getOwnPropertyDescriptor.default)(_obj, \"markUrlFailedAndGetNew\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"initialize\", [_dec6], (0, _getOwnPropertyDescriptor.default)(_obj, \"initialize\"), _obj)), _obj)));\nvar _default = exports[\"default\"] = Device;\n//# sourceMappingURL=device.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/device.js?");
|
|
2966
2966
|
|
|
2967
2967
|
/***/ }),
|
|
2968
2968
|
|
|
@@ -3039,7 +3039,7 @@ eval("\n\nvar _Reflect$construct = __webpack_require__(/*! @babel/runtime-corejs
|
|
|
3039
3039
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3040
3040
|
|
|
3041
3041
|
"use strict";
|
|
3042
|
-
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/regenerator */ \"../../../node_modules/@babel/runtime-corejs2/regenerator/index.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js\"));\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\n/*!\n * Copyright (c) 2015-2023 Cisco Systems, Inc. See LICENSE file.\n */\n\nvar STATE = {\n INITIAL: 'initial',\n IN_PROGRESS: 'in-progress',\n IDLE: 'idle'\n};\n\n/**\n * @class\n */\nvar IpNetworkDetector = _webexCore.WebexPlugin.extend({\n idAttribute: 'IpNetworkDetectorId',\n namespace: 'Device',\n props: {\n firstIpV4: ['number', true, -1],\n // time [ms] it took to receive first IPv4 candidate\n firstIpV6: ['number', true, -1],\n // time [ms] it took to receive first IPv6 candidate\n firstMdns: ['number', true, -1],\n // time [ms] it took to receive first mDNS candidate\n totalTime: ['number', true, -1],\n // total time [ms] it took to do the last IP network detection\n state: ['string', true, STATE.INITIAL],\n pendingDetection: ['object', false, undefined]\n },\n derived: {\n /**\n * True if we know we're on an IPv4 network,\n * False if we know that we are not on an IPv4 network,\n * undefined if we are not sure\n */\n supportsIpV4: {\n deps: ['firstIpV4', 'firstIpV6', 'firstMdns', 'totalTime'],\n /**\n * Function for calculating the value of supportsIpV4 prop\n * @returns {boolean | undefined}\n */\n fn: function fn() {\n if (this.firstIpV4 >= 0) {\n return true;\n }\n if (this.totalTime < 0) {\n // we haven't completed the detection, yet\n return undefined;\n }\n if (this.receivedOnlyMDnsCandidates()) {\n return undefined;\n }\n return false;\n }\n },\n /**\n * True if we know we're on an IPv6 network,\n * False if we know that we are not on an IPv6 network,\n * undefined if we are not sure\n */\n supportsIpV6: {\n deps: ['firstIpV4', 'firstIpV6', 'firstMdns', 'totalTime'],\n /**\n * Function for calculating the value of supportsIpV6 prop\n * @returns {boolean | undefined}\n */\n fn: function fn() {\n if (this.firstIpV6 >= 0) {\n return true;\n }\n if (this.totalTime < 0) {\n // we haven't completed the detection, yet\n return undefined;\n }\n if (this.receivedOnlyMDnsCandidates()) {\n return undefined;\n }\n return false;\n }\n }\n },\n /**\n * Returns true if we have received only mDNS candidates - browsers usually do that if we don't have any user media permissions\n *\n * @private\n * @returns {boolean}\n */\n receivedOnlyMDnsCandidates: function receivedOnlyMDnsCandidates() {\n return this.totalTime >= 0 && this.firstMdns >= 0 && this.firstIpV4 < 0 && this.firstIpV6 < 0;\n },\n /**\n *\n * @param {RTCPeerConnection} pc Peer connection to use\n * @private\n * @returns {Promise<void>}\n */\n gatherLocalCandidates: function gatherLocalCandidates(pc) {\n var _this = this;\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {\n return _regenerator.default.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n return _context.abrupt(\"return\", new _promise.default(function (resolve, reject) {\n var done = false;\n _this.firstIpV4 = -1;\n _this.firstIpV6 = -1;\n _this.firstMdns = -1;\n _this.totalTime = -1;\n var startTime = performance.now();\n var doneGatheringIceCandidates = function doneGatheringIceCandidates() {\n if (done) {\n return;\n }\n done = true;\n _this.totalTime = performance.now() - startTime;\n resolve();\n };\n pc.onicecandidate = function (event) {\n var _event$candidate;\n if ((_event$candidate = event.candidate) !== null && _event$candidate !== void 0 && _event$candidate.address) {\n if (event.candidate.address.endsWith('.local')) {\n // if we don't have camera/mic permissions, browser just gives us mDNS candidates\n if (_this.firstMdns === -1) {\n _this.firstMdns = performance.now() - startTime;\n }\n } else if (event.candidate.address.includes(':')) {\n if (_this.firstIpV6 === -1) {\n _this.firstIpV6 = performance.now() - startTime;\n }\n } else if (_this.firstIpV4 === -1) {\n _this.firstIpV4 = performance.now() - startTime;\n }\n if (_this.firstIpV4 >= 0 && _this.firstIpV6 >= 0) {\n // if we've got both ipv4 and ipv6 candidates, there is no need to wait for any more candidates, we can resolve now\n resolve();\n }\n } else if (event.candidate === null) {\n doneGatheringIceCandidates();\n }\n };\n pc.onicegatheringstatechange = function () {\n if (pc.iceGatheringState === 'complete') {\n doneGatheringIceCandidates();\n }\n };\n pc.createDataChannel('data');\n pc.createOffer().then(function (offer) {\n return pc.setLocalDescription(offer);\n }).catch(function (e) {\n _this.webex.logger.error('Failed to detect ip network version:', e);\n reject(e);\n });\n }));\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }))();\n },\n /**\n * Detects if we are on IPv4 and/or IPv6 network. Once it resolves, read the\n * supportsIpV4 and supportsIpV6 props to find out the result.\n *\n * @param {boolean} force - if false, the detection will only be done if we haven't managed to get any meaningful results yet\n * @returns {Promise<void>}\n */\n detect: function detect() {\n var _arguments = arguments,\n _this2 = this;\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {\n var force, results, pc, forceParam;\n return _regenerator.default.wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n force = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : false;\n if (!(_this2.state === STATE.IN_PROGRESS)) {\n _context2.next = 4;\n break;\n }\n _this2.pendingDetection = {\n force: force\n };\n return _context2.abrupt(\"return\");\n case 4:\n if (!(!force && _this2.state !== STATE.INITIAL && !_this2.receivedOnlyMDnsCandidates())) {\n _context2.next = 6;\n break;\n }\n return _context2.abrupt(\"return\");\n case 6:\n _context2.prev = 6;\n _this2.state = STATE.IN_PROGRESS;\n pc = new RTCPeerConnection();\n _context2.next = 11;\n return _this2.gatherLocalCandidates(pc);\n case 11:\n results = _context2.sent;\n case 12:\n _context2.prev = 12;\n pc.close();\n _this2.state = STATE.IDLE;\n return _context2.finish(12);\n case 16:\n if (_this2.pendingDetection) {\n forceParam = _this2.pendingDetection.force;\n _this2.pendingDetection = undefined;\n _this2.detect(forceParam);\n }\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[6,, 12, 16]]);\n }))();\n },\n version: \"3.8.0-next.
|
|
3042
|
+
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/regenerator */ \"../../../node_modules/@babel/runtime-corejs2/regenerator/index.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js\"));\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\n/*!\n * Copyright (c) 2015-2023 Cisco Systems, Inc. See LICENSE file.\n */\n\nvar STATE = {\n INITIAL: 'initial',\n IN_PROGRESS: 'in-progress',\n IDLE: 'idle'\n};\n\n/**\n * @class\n */\nvar IpNetworkDetector = _webexCore.WebexPlugin.extend({\n idAttribute: 'IpNetworkDetectorId',\n namespace: 'Device',\n props: {\n firstIpV4: ['number', true, -1],\n // time [ms] it took to receive first IPv4 candidate\n firstIpV6: ['number', true, -1],\n // time [ms] it took to receive first IPv6 candidate\n firstMdns: ['number', true, -1],\n // time [ms] it took to receive first mDNS candidate\n totalTime: ['number', true, -1],\n // total time [ms] it took to do the last IP network detection\n state: ['string', true, STATE.INITIAL],\n pendingDetection: ['object', false, undefined]\n },\n derived: {\n /**\n * True if we know we're on an IPv4 network,\n * False if we know that we are not on an IPv4 network,\n * undefined if we are not sure\n */\n supportsIpV4: {\n deps: ['firstIpV4', 'firstIpV6', 'firstMdns', 'totalTime'],\n /**\n * Function for calculating the value of supportsIpV4 prop\n * @returns {boolean | undefined}\n */\n fn: function fn() {\n if (this.firstIpV4 >= 0) {\n return true;\n }\n if (this.totalTime < 0) {\n // we haven't completed the detection, yet\n return undefined;\n }\n if (this.receivedOnlyMDnsCandidates()) {\n return undefined;\n }\n return false;\n }\n },\n /**\n * True if we know we're on an IPv6 network,\n * False if we know that we are not on an IPv6 network,\n * undefined if we are not sure\n */\n supportsIpV6: {\n deps: ['firstIpV4', 'firstIpV6', 'firstMdns', 'totalTime'],\n /**\n * Function for calculating the value of supportsIpV6 prop\n * @returns {boolean | undefined}\n */\n fn: function fn() {\n if (this.firstIpV6 >= 0) {\n return true;\n }\n if (this.totalTime < 0) {\n // we haven't completed the detection, yet\n return undefined;\n }\n if (this.receivedOnlyMDnsCandidates()) {\n return undefined;\n }\n return false;\n }\n }\n },\n /**\n * Returns true if we have received only mDNS candidates - browsers usually do that if we don't have any user media permissions\n *\n * @private\n * @returns {boolean}\n */\n receivedOnlyMDnsCandidates: function receivedOnlyMDnsCandidates() {\n return this.totalTime >= 0 && this.firstMdns >= 0 && this.firstIpV4 < 0 && this.firstIpV6 < 0;\n },\n /**\n *\n * @param {RTCPeerConnection} pc Peer connection to use\n * @private\n * @returns {Promise<void>}\n */\n gatherLocalCandidates: function gatherLocalCandidates(pc) {\n var _this = this;\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {\n return _regenerator.default.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n return _context.abrupt(\"return\", new _promise.default(function (resolve, reject) {\n var done = false;\n _this.firstIpV4 = -1;\n _this.firstIpV6 = -1;\n _this.firstMdns = -1;\n _this.totalTime = -1;\n var startTime = performance.now();\n var doneGatheringIceCandidates = function doneGatheringIceCandidates() {\n if (done) {\n return;\n }\n done = true;\n _this.totalTime = performance.now() - startTime;\n resolve();\n };\n pc.onicecandidate = function (event) {\n var _event$candidate;\n if ((_event$candidate = event.candidate) !== null && _event$candidate !== void 0 && _event$candidate.address) {\n if (event.candidate.address.endsWith('.local')) {\n // if we don't have camera/mic permissions, browser just gives us mDNS candidates\n if (_this.firstMdns === -1) {\n _this.firstMdns = performance.now() - startTime;\n }\n } else if (event.candidate.address.includes(':')) {\n if (_this.firstIpV6 === -1) {\n _this.firstIpV6 = performance.now() - startTime;\n }\n } else if (_this.firstIpV4 === -1) {\n _this.firstIpV4 = performance.now() - startTime;\n }\n if (_this.firstIpV4 >= 0 && _this.firstIpV6 >= 0) {\n // if we've got both ipv4 and ipv6 candidates, there is no need to wait for any more candidates, we can resolve now\n resolve();\n }\n } else if (event.candidate === null) {\n doneGatheringIceCandidates();\n }\n };\n pc.onicegatheringstatechange = function () {\n if (pc.iceGatheringState === 'complete') {\n doneGatheringIceCandidates();\n }\n };\n pc.createDataChannel('data');\n pc.createOffer().then(function (offer) {\n return pc.setLocalDescription(offer);\n }).catch(function (e) {\n _this.webex.logger.error('Failed to detect ip network version:', e);\n reject(e);\n });\n }));\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }))();\n },\n /**\n * Detects if we are on IPv4 and/or IPv6 network. Once it resolves, read the\n * supportsIpV4 and supportsIpV6 props to find out the result.\n *\n * @param {boolean} force - if false, the detection will only be done if we haven't managed to get any meaningful results yet\n * @returns {Promise<void>}\n */\n detect: function detect() {\n var _arguments = arguments,\n _this2 = this;\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {\n var force, results, pc, forceParam;\n return _regenerator.default.wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n force = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : false;\n if (!(_this2.state === STATE.IN_PROGRESS)) {\n _context2.next = 4;\n break;\n }\n _this2.pendingDetection = {\n force: force\n };\n return _context2.abrupt(\"return\");\n case 4:\n if (!(!force && _this2.state !== STATE.INITIAL && !_this2.receivedOnlyMDnsCandidates())) {\n _context2.next = 6;\n break;\n }\n return _context2.abrupt(\"return\");\n case 6:\n _context2.prev = 6;\n _this2.state = STATE.IN_PROGRESS;\n pc = new RTCPeerConnection();\n _context2.next = 11;\n return _this2.gatherLocalCandidates(pc);\n case 11:\n results = _context2.sent;\n case 12:\n _context2.prev = 12;\n pc.close();\n _this2.state = STATE.IDLE;\n return _context2.finish(12);\n case 16:\n if (_this2.pendingDetection) {\n forceParam = _this2.pendingDetection.force;\n _this2.pendingDetection = undefined;\n _this2.detect(forceParam);\n }\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[6,, 12, 16]]);\n }))();\n },\n version: \"3.8.0-next.12\"\n});\nvar _default = exports[\"default\"] = IpNetworkDetector;\n//# sourceMappingURL=ipNetworkDetector.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/internal-plugin-mercury/node_modules/@webex/internal-plugin-device/dist/ipNetworkDetector.js?");
|
|
3043
3043
|
|
|
3044
3044
|
/***/ }),
|
|
3045
3045
|
|
|
@@ -3303,7 +3303,7 @@ eval("\n\nvar _typeof = __webpack_require__(/*! @babel/runtime-corejs2/helpers/t
|
|
|
3303
3303
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3304
3304
|
|
|
3305
3305
|
"use strict";
|
|
3306
|
-
eval("\n\nvar _Object$keys = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nexports.getOSNameInternal = getOSNameInternal;\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/internal-plugin-metrics/node_modules/@webex/common/dist/index.js\");\nvar _config = __webpack_require__(/*! ./config */ \"../../../node_modules/@webex/internal-plugin-metrics/dist/config.js\");\nvar _batcher = _interopRequireDefault(__webpack_require__(/*! ./batcher */ \"../../../node_modules/@webex/internal-plugin-metrics/dist/batcher.js\"));\nvar _clientMetricsBatcher = _interopRequireDefault(__webpack_require__(/*! ./client-metrics-batcher */ \"../../../node_modules/@webex/internal-plugin-metrics/dist/client-metrics-batcher.js\"));\nvar _clientMetricsPreloginBatcher = _interopRequireDefault(__webpack_require__(/*! ./client-metrics-prelogin-batcher */ \"../../../node_modules/@webex/internal-plugin-metrics/dist/client-metrics-prelogin-batcher.js\"));\nfunction ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable default-param-last */ /*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nvar _BrowserDetection = (0, _common.BrowserDetection)(),\n getOSName = _BrowserDetection.getOSName,\n getOSVersion = _BrowserDetection.getOSVersion,\n getBrowserName = _BrowserDetection.getBrowserName,\n getBrowserVersion = _BrowserDetection.getBrowserVersion;\nfunction getOSNameInternal() {\n var _OSMap$getOSName;\n return (_OSMap$getOSName = _config.OSMap[getOSName()]) !== null && _OSMap$getOSName !== void 0 ? _OSMap$getOSName : _config.OS_NAME.OTHERS;\n}\nfunction getSparkUserAgent(webex) {\n var _webex$config;\n var _ref = (_webex$config = webex === null || webex === void 0 ? void 0 : webex.config) !== null && _webex$config !== void 0 ? _webex$config : {},\n appName = _ref.appName,\n appVersion = _ref.appVersion,\n appPlatform = _ref.appPlatform;\n var sparkUserAgent = _config.CLIENT_NAME;\n if (appName) {\n sparkUserAgent += \" \".concat(appName, \"/\").concat(appVersion !== null && appVersion !== void 0 ? appVersion : '0.0');\n }\n if (appPlatform) {\n sparkUserAgent += \" \".concat(appPlatform);\n }\n return sparkUserAgent;\n}\nvar Metrics = _webexCore.WebexPlugin.extend({\n children: {\n batcher: _batcher.default,\n clientMetricsBatcher: _clientMetricsBatcher.default,\n clientMetricsPreloginBatcher: _clientMetricsPreloginBatcher.default\n },\n namespace: 'Metrics',\n submit: function submit(key, value) {\n return this.batcher.request(_objectSpread({\n key: key\n }, value));\n },\n /**\n * Returns the payload for submitting client metrics.\n * @param {string} eventName\n * @param {any} props\n * @returns {any} - the payload\n */\n getClientMetricsPayload: function getClientMetricsPayload(eventName, props) {\n var _this$webex$meetings, _this$webex$meetings$, _this$webex$meetings$2;\n if (!eventName) {\n throw Error('Missing behavioral metric name. Please provide one');\n }\n var payload = {\n metricName: eventName\n };\n // @ts-ignore\n var providedClientVersion = (_this$webex$meetings = this.webex.meetings) === null || _this$webex$meetings === void 0 ? void 0 : (_this$webex$meetings$ = _this$webex$meetings.config) === null || _this$webex$meetings$ === void 0 ? void 0 : (_this$webex$meetings$2 = _this$webex$meetings$.metrics) === null || _this$webex$meetings$2 === void 0 ? void 0 : _this$webex$meetings$2.clientVersion;\n payload.tags = _objectSpread(_objectSpread({}, props.tags), {}, {\n browser: getBrowserName(),\n os: getOSNameInternal(),\n appVersion: providedClientVersion,\n // Node does not like this so we need to check if it exists or not\n // eslint-disable-next-line no-undef\n domain: typeof window !== 'undefined' ? window.location.hostname || 'non-browser' : 'non-browser' // Check what else we could measure\n });\n\n payload.fields = _objectSpread(_objectSpread({}, props.fields), {}, {\n browser_version: getBrowserVersion(),\n os_version: getOSVersion(),\n sdk_version: this.webex.version,\n platform: 'Web',\n spark_user_agent: getSparkUserAgent(this.webex),\n client_id: this.webex.credentials.config.client_id\n });\n payload.type = props.type || this.webex.config.metrics.type;\n payload.context = _objectSpread(_objectSpread({}, props.context), {}, {\n app: {\n version: this.webex.version\n },\n locale: 'en-US',\n os: {\n name: getOSNameInternal(),\n version: getOSVersion()\n }\n });\n if (props.eventPayload) {\n payload.eventPayload = props.eventPayload;\n }\n\n // Mocking the time in tests when running in node\n // is impossible so unable to use Date.now()\n payload.timestamp = new Date().valueOf();\n return payload;\n },\n /**\n * This corresponds to #sendSemiStructured() in the deprecated metrics handler\n * @param {string} eventName\n * @param {Object} props\n * @param {string} preLoginId\n * @returns {Object} HttpResponse object\n */\n submitClientMetrics: function submitClientMetrics(eventName) {\n var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var preLoginId = arguments.length > 2 ? arguments[2] : undefined;\n var payload = this.getClientMetricsPayload(eventName, props);\n if (preLoginId) {\n this.clientMetricsPreloginBatcher.savePreLoginId(preLoginId);\n return this.clientMetricsPreloginBatcher.request(payload);\n }\n return this.clientMetricsBatcher.request(payload);\n },\n /**\n * Issue request to alias a user's pre-login ID with their CI UUID\n * @param {string} preLoginId\n * @returns {Object} HttpResponse object\n */\n aliasUser: function aliasUser(preLoginId) {\n return this.request({\n method: 'POST',\n api: 'metrics',\n resource: 'clientmetrics',\n headers: {\n 'x-prelogin-userid': preLoginId\n },\n body: {},\n qs: {\n alias: true\n }\n });\n },\n version: \"3.8.0-next.
|
|
3306
|
+
eval("\n\nvar _Object$keys = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nexports.getOSNameInternal = getOSNameInternal;\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/internal-plugin-metrics/node_modules/@webex/common/dist/index.js\");\nvar _config = __webpack_require__(/*! ./config */ \"../../../node_modules/@webex/internal-plugin-metrics/dist/config.js\");\nvar _batcher = _interopRequireDefault(__webpack_require__(/*! ./batcher */ \"../../../node_modules/@webex/internal-plugin-metrics/dist/batcher.js\"));\nvar _clientMetricsBatcher = _interopRequireDefault(__webpack_require__(/*! ./client-metrics-batcher */ \"../../../node_modules/@webex/internal-plugin-metrics/dist/client-metrics-batcher.js\"));\nvar _clientMetricsPreloginBatcher = _interopRequireDefault(__webpack_require__(/*! ./client-metrics-prelogin-batcher */ \"../../../node_modules/@webex/internal-plugin-metrics/dist/client-metrics-prelogin-batcher.js\"));\nfunction ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable default-param-last */ /*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nvar _BrowserDetection = (0, _common.BrowserDetection)(),\n getOSName = _BrowserDetection.getOSName,\n getOSVersion = _BrowserDetection.getOSVersion,\n getBrowserName = _BrowserDetection.getBrowserName,\n getBrowserVersion = _BrowserDetection.getBrowserVersion;\nfunction getOSNameInternal() {\n var _OSMap$getOSName;\n return (_OSMap$getOSName = _config.OSMap[getOSName()]) !== null && _OSMap$getOSName !== void 0 ? _OSMap$getOSName : _config.OS_NAME.OTHERS;\n}\nfunction getSparkUserAgent(webex) {\n var _webex$config;\n var _ref = (_webex$config = webex === null || webex === void 0 ? void 0 : webex.config) !== null && _webex$config !== void 0 ? _webex$config : {},\n appName = _ref.appName,\n appVersion = _ref.appVersion,\n appPlatform = _ref.appPlatform;\n var sparkUserAgent = _config.CLIENT_NAME;\n if (appName) {\n sparkUserAgent += \" \".concat(appName, \"/\").concat(appVersion !== null && appVersion !== void 0 ? appVersion : '0.0');\n }\n if (appPlatform) {\n sparkUserAgent += \" \".concat(appPlatform);\n }\n return sparkUserAgent;\n}\nvar Metrics = _webexCore.WebexPlugin.extend({\n children: {\n batcher: _batcher.default,\n clientMetricsBatcher: _clientMetricsBatcher.default,\n clientMetricsPreloginBatcher: _clientMetricsPreloginBatcher.default\n },\n namespace: 'Metrics',\n submit: function submit(key, value) {\n return this.batcher.request(_objectSpread({\n key: key\n }, value));\n },\n /**\n * Returns the payload for submitting client metrics.\n * @param {string} eventName\n * @param {any} props\n * @returns {any} - the payload\n */\n getClientMetricsPayload: function getClientMetricsPayload(eventName, props) {\n var _this$webex$meetings, _this$webex$meetings$, _this$webex$meetings$2;\n if (!eventName) {\n throw Error('Missing behavioral metric name. Please provide one');\n }\n var payload = {\n metricName: eventName\n };\n // @ts-ignore\n var providedClientVersion = (_this$webex$meetings = this.webex.meetings) === null || _this$webex$meetings === void 0 ? void 0 : (_this$webex$meetings$ = _this$webex$meetings.config) === null || _this$webex$meetings$ === void 0 ? void 0 : (_this$webex$meetings$2 = _this$webex$meetings$.metrics) === null || _this$webex$meetings$2 === void 0 ? void 0 : _this$webex$meetings$2.clientVersion;\n payload.tags = _objectSpread(_objectSpread({}, props.tags), {}, {\n browser: getBrowserName(),\n os: getOSNameInternal(),\n appVersion: providedClientVersion,\n // Node does not like this so we need to check if it exists or not\n // eslint-disable-next-line no-undef\n domain: typeof window !== 'undefined' ? window.location.hostname || 'non-browser' : 'non-browser' // Check what else we could measure\n });\n\n payload.fields = _objectSpread(_objectSpread({}, props.fields), {}, {\n browser_version: getBrowserVersion(),\n os_version: getOSVersion(),\n sdk_version: this.webex.version,\n platform: 'Web',\n spark_user_agent: getSparkUserAgent(this.webex),\n client_id: this.webex.credentials.config.client_id\n });\n payload.type = props.type || this.webex.config.metrics.type;\n payload.context = _objectSpread(_objectSpread({}, props.context), {}, {\n app: {\n version: this.webex.version\n },\n locale: 'en-US',\n os: {\n name: getOSNameInternal(),\n version: getOSVersion()\n }\n });\n if (props.eventPayload) {\n payload.eventPayload = props.eventPayload;\n }\n\n // Mocking the time in tests when running in node\n // is impossible so unable to use Date.now()\n payload.timestamp = new Date().valueOf();\n return payload;\n },\n /**\n * This corresponds to #sendSemiStructured() in the deprecated metrics handler\n * @param {string} eventName\n * @param {Object} props\n * @param {string} preLoginId\n * @returns {Object} HttpResponse object\n */\n submitClientMetrics: function submitClientMetrics(eventName) {\n var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var preLoginId = arguments.length > 2 ? arguments[2] : undefined;\n var payload = this.getClientMetricsPayload(eventName, props);\n if (preLoginId) {\n this.clientMetricsPreloginBatcher.savePreLoginId(preLoginId);\n return this.clientMetricsPreloginBatcher.request(payload);\n }\n return this.clientMetricsBatcher.request(payload);\n },\n /**\n * Issue request to alias a user's pre-login ID with their CI UUID\n * @param {string} preLoginId\n * @returns {Object} HttpResponse object\n */\n aliasUser: function aliasUser(preLoginId) {\n return this.request({\n method: 'POST',\n api: 'metrics',\n resource: 'clientmetrics',\n headers: {\n 'x-prelogin-userid': preLoginId\n },\n body: {},\n qs: {\n alias: true\n }\n });\n },\n version: \"3.8.0-next.12\"\n});\nvar _default = exports[\"default\"] = Metrics;\n//# sourceMappingURL=metrics.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/internal-plugin-metrics/dist/metrics.js?");
|
|
3307
3307
|
|
|
3308
3308
|
/***/ }),
|
|
3309
3309
|
|
|
@@ -3952,7 +3952,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
|
|
|
3952
3952
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3953
3953
|
|
|
3954
3954
|
"use strict";
|
|
3955
|
-
eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _events = _interopRequireDefault(__webpack_require__(/*! events */ \"../../../node_modules/events/events.js\"));\nvar _calling = __webpack_require__(/*! @webex/calling */ \"../../../node_modules/@webex/calling/dist/module/index.js\");\nvar _types = __webpack_require__(/*! ./types */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/types.js\");\nvar _constants = __webpack_require__(/*! ../../constants */ \"../../../node_modules/@webex/plugin-cc/dist/constants.js\");\nvar _types2 = __webpack_require__(/*! ../config/types */ \"../../../node_modules/@webex/plugin-cc/dist/services/config/types.js\");\nvar _types3 = __webpack_require__(/*! ../../types */ \"../../../node_modules/@webex/plugin-cc/dist/types.js\");\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ../../logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _ = _interopRequireDefault(__webpack_require__(/*! . */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/index.js\"));\nvar _MetricsManager = _interopRequireDefault(__webpack_require__(/*! ../../metrics/MetricsManager */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/MetricsManager.js\"));\nvar _constants2 = __webpack_require__(/*! ../../metrics/constants */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/constants.js\");\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nclass TaskManager extends _events.default {\n /**\n * @param contact - Routing Contact layer. Talks to AQMReq layer to convert events to promises\n * @param webCallingService - Webrtc Service Layer\n * @param webSocketManager - Websocket Manager to maintain websocket connection and keepalives\n */\n constructor(contact, webCallingService, webSocketManager) {\n super();\n this.contact = contact;\n this.taskCollection = {};\n this.webCallingService = webCallingService;\n this.webSocketManager = webSocketManager;\n this.metricsManager = _MetricsManager.default.getInstance();\n this.registerTaskListeners();\n this.registerIncomingCallEvent();\n }\n handleIncomingWebCall = call => {\n const currentTask = Object.values(this.taskCollection).find(task => task.data.interaction.mediaType === 'telephony');\n if (currentTask) {\n this.webCallingService.mapCallToTask(call.getCallId(), currentTask.data.interactionId);\n _loggerProxy.default.log('Call mapped to task', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'handleIncomingWebCall'\n });\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, currentTask);\n }\n this.call = call;\n };\n registerIncomingCallEvent() {\n this.webCallingService.on(_calling.LINE_EVENTS.INCOMING_CALL, this.handleIncomingWebCall);\n }\n unregisterIncomingCallEvent() {\n this.webCallingService.off(_calling.LINE_EVENTS.INCOMING_CALL, this.handleIncomingWebCall);\n }\n registerTaskListeners() {\n this.webSocketManager.on('message', event => {\n const payload = JSON.parse(event);\n // Re-emit the task events to the task object\n let task;\n if (payload.data?.type) {\n if (Object.values(_types2.CC_TASK_EVENTS).includes(payload.data.type)) {\n task = this.taskCollection[payload.data.interactionId];\n if (task) {\n task.emit(payload.data.type, payload.data);\n }\n }\n switch (payload.data.type) {\n case _types2.CC_EVENTS.AGENT_CONTACT:\n task = new _.default(this.contact, this.webCallingService, {\n ...payload.data,\n wrapUpRequired: payload.data.interaction?.participants?.[payload.data.agentId]?.isWrapUp || false\n });\n this.taskCollection[payload.data.interactionId] = task;\n this.emit(_types.TASK_EVENTS.TASK_HYDRATE, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_RESERVED:\n task = new _.default(this.contact, this.webCallingService, {\n ...payload.data,\n isConsulted: false\n }); // Ensure isConsulted prop exists\n this.taskCollection[payload.data.interactionId] = task;\n if (this.webCallingService.loginOption !== _types3.LoginOption.BROWSER || task.data.interaction.mediaType !== _types.MEDIA_CHANNEL.TELEPHONY // for digital channels\n ) {\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, task);\n } else if (this.call) {\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, task);\n }\n break;\n case _types2.CC_EVENTS.AGENT_OFFER_CONTACT:\n // We don't have to emit any event here since this will be result of promise.\n task = this.updateTaskData(task, payload.data);\n _loggerProxy.default.log('Agent offer contact', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'registerTaskListeners'\n });\n break;\n case _types2.CC_EVENTS.AGENT_OUTBOUND_FAILED:\n // We don't have to emit any event here since this will be result of promise.\n if (task.data) {\n this.removeTaskFromCollection(task);\n }\n _loggerProxy.default.log('Agent outbound failed', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'registerTaskListeners'\n });\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_ASSIGNED:\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_ASSIGNED, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_UNASSIGNED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: true\n });\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_OFFER_RONA:\n task = this.updateTaskData(task, payload.data);\n this.metricsManager.trackEvent(_constants2.METRIC_EVENT_NAMES.AGENT_RONA, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(payload.data),\n taskId: payload.data.interactionId,\n reason: payload.data.reason\n }, ['behavioral', 'operational']);\n this.handleTaskCleanup(task);\n task.emit(_types.TASK_EVENTS.TASK_REJECT, payload.data.reason);\n break;\n case _types2.CC_EVENTS.CONTACT_ENDED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: payload.data.interaction.state !== 'new'\n });\n this.handleTaskCleanup(task);\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_HELD:\n // As soon as the main interaction is held, we need to emit TASK_HOLD\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_HOLD, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_UNHELD:\n // As soon as the main interaction is unheld, we need to emit TASK_RESUME\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_RESUME, task);\n break;\n case _types2.CC_EVENTS.AGENT_VTEAM_TRANSFERRED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: true\n });\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CTQ_CANCEL_FAILED:\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_QUEUE_FAILED, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_CREATED:\n // Received when self agent initiates a consult\n task = this.updateTaskData(task, {\n ...payload.data,\n isConsulted: false // This ensures that the task consult status is always reset\n });\n // Do not emit anything since this be received only as a result of an API invocation(handled by a promise)\n break;\n case _types2.CC_EVENTS.AGENT_OFFER_CONSULT:\n // Received when other agent sends us a consult offer\n task = this.updateTaskData(task, {\n ...payload.data,\n isConsulted: true // This ensures that the task is marked as us being requested for a consult\n });\n\n break;\n case _types2.CC_EVENTS.AGENT_CONSULTING:\n // Received when agent is in an active consult state\n task = this.updateTaskData(task, payload.data);\n if (task.data.isConsulted) {\n // Fire only if you are the agent who received the consult request\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_ACCEPTED, task);\n } else {\n // Fire only if you are the agent who initiated the consult\n task.emit(_types.TASK_EVENTS.TASK_CONSULTING, task);\n }\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_FAILED:\n // This can only be received by the agent who initiated the consult.\n // We need not emit any event here since this will be result of promise\n task = this.updateTaskData(task, payload.data);\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_ENDED:\n task = this.updateTaskData(task, payload.data);\n if (task.data.isConsulted) {\n // This will be the end state of the task as soon as we end the consult in case of\n // us being offered a consult\n this.removeTaskFromCollection(task);\n }\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CTQ_CANCELLED:\n // This event is received when the consult using queue is cancelled using API\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, task);\n break;\n case _types2.CC_EVENTS.AGENT_WRAPUP:\n task = this.updateTaskData(task, payload.data);\n break;\n case _types2.CC_EVENTS.AGENT_WRAPPEDUP:\n this.removeTaskFromCollection(task);\n break;\n default:\n break;\n }\n }\n });\n }\n updateTaskData(task, taskData) {\n if (!task) {\n return undefined;\n }\n if (!taskData?.interactionId) {\n _loggerProxy.default.warn('Received task update with missing interactionId', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'updateTaskData'\n });\n }\n try {\n const currentTask = task.updateTaskData(taskData);\n this.taskCollection[taskData.interactionId] = currentTask;\n return currentTask;\n } catch (error) {\n _loggerProxy.default.error(`Failed to update task ${taskData.interactionId}`, {\n module: _constants.TASK_MANAGER_FILE,\n method: 'updateTaskData'\n });\n return task;\n }\n }\n removeTaskFromCollection(task) {\n if (task?.data?.interactionId) {\n delete this.taskCollection[task.data.interactionId];\n _loggerProxy.default.info(`Task removed from collection: ${task.data.interactionId}`, {\n module: _constants.TASK_MANAGER_FILE,\n method: 'removeTaskFromCollection'\n });\n }\n }\n handleTaskCleanup(task) {\n if (this.webCallingService.loginOption === _types3.LoginOption.BROWSER && task.data.interaction.mediaType === 'telephony') {\n task.unregisterWebCallListeners();\n this.webCallingService.cleanUpCall();\n }\n if (task.data.interaction.state === 'new') {\n // Only remove tasks in 'new' state immediately. For other states,\n // retain tasks until they complete wrap-up, unless the task disconnected before being answered.\n this.removeTaskFromCollection(task);\n }\n }\n\n /**\n * @param taskId - Unique identifier for each task\n */\n getTask = taskId => {\n return this.taskCollection[taskId];\n };\n\n /**\n * @param taskId - Unique identifier for each task\n */\n getAllTasks = () => {\n return this.taskCollection;\n };\n\n /**\n * @param contact - Routing Contact layer. Talks to AQMReq layer to convert events to promises\n * @param webCallingService - Webrtc Service Layer\n * @param webSocketManager - Websocket Manager to maintain websocket connection and keepalives\n */\n static getTaskManager = (contact, webCallingService, webSocketManager) => {\n if (!this.taskManager) {\n this.taskManager = new TaskManager(contact, webCallingService, webSocketManager);\n }\n return this.taskManager;\n };\n}\nexports[\"default\"] = TaskManager;\n//# sourceMappingURL=TaskManager.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/services/task/TaskManager.js?");
|
|
3955
|
+
eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _events = _interopRequireDefault(__webpack_require__(/*! events */ \"../../../node_modules/events/events.js\"));\nvar _calling = __webpack_require__(/*! @webex/calling */ \"../../../node_modules/@webex/calling/dist/module/index.js\");\nvar _types = __webpack_require__(/*! ./types */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/types.js\");\nvar _constants = __webpack_require__(/*! ../../constants */ \"../../../node_modules/@webex/plugin-cc/dist/constants.js\");\nvar _types2 = __webpack_require__(/*! ../config/types */ \"../../../node_modules/@webex/plugin-cc/dist/services/config/types.js\");\nvar _types3 = __webpack_require__(/*! ../../types */ \"../../../node_modules/@webex/plugin-cc/dist/types.js\");\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ../../logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _ = _interopRequireDefault(__webpack_require__(/*! . */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/index.js\"));\nvar _MetricsManager = _interopRequireDefault(__webpack_require__(/*! ../../metrics/MetricsManager */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/MetricsManager.js\"));\nvar _constants2 = __webpack_require__(/*! ../../metrics/constants */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/constants.js\");\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nclass TaskManager extends _events.default {\n /**\n * @param contact - Routing Contact layer. Talks to AQMReq layer to convert events to promises\n * @param webCallingService - Webrtc Service Layer\n * @param webSocketManager - Websocket Manager to maintain websocket connection and keepalives\n */\n constructor(contact, webCallingService, webSocketManager) {\n super();\n this.contact = contact;\n this.taskCollection = {};\n this.webCallingService = webCallingService;\n this.webSocketManager = webSocketManager;\n this.metricsManager = _MetricsManager.default.getInstance();\n this.registerTaskListeners();\n this.registerIncomingCallEvent();\n }\n handleIncomingWebCall = call => {\n const currentTask = Object.values(this.taskCollection).find(task => task.data.interaction.mediaType === 'telephony');\n if (currentTask) {\n this.webCallingService.mapCallToTask(call.getCallId(), currentTask.data.interactionId);\n _loggerProxy.default.log('Call mapped to task', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'handleIncomingWebCall'\n });\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, currentTask);\n }\n this.call = call;\n };\n registerIncomingCallEvent() {\n this.webCallingService.on(_calling.LINE_EVENTS.INCOMING_CALL, this.handleIncomingWebCall);\n }\n unregisterIncomingCallEvent() {\n this.webCallingService.off(_calling.LINE_EVENTS.INCOMING_CALL, this.handleIncomingWebCall);\n }\n registerTaskListeners() {\n this.webSocketManager.on('message', event => {\n const payload = JSON.parse(event);\n // Re-emit the task events to the task object\n let task;\n if (payload.data?.type) {\n if (Object.values(_types2.CC_TASK_EVENTS).includes(payload.data.type)) {\n task = this.taskCollection[payload.data.interactionId];\n }\n switch (payload.data.type) {\n case _types2.CC_EVENTS.AGENT_CONTACT:\n task = new _.default(this.contact, this.webCallingService, {\n ...payload.data,\n wrapUpRequired: payload.data.interaction?.participants?.[payload.data.agentId]?.isWrapUp || false\n });\n this.taskCollection[payload.data.interactionId] = task;\n this.emit(_types.TASK_EVENTS.TASK_HYDRATE, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_RESERVED:\n task = new _.default(this.contact, this.webCallingService, {\n ...payload.data,\n isConsulted: false\n }); // Ensure isConsulted prop exists\n this.taskCollection[payload.data.interactionId] = task;\n if (this.webCallingService.loginOption !== _types3.LoginOption.BROWSER || task.data.interaction.mediaType !== _types.MEDIA_CHANNEL.TELEPHONY // for digital channels\n ) {\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, task);\n } else if (this.call) {\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, task);\n }\n break;\n case _types2.CC_EVENTS.AGENT_OFFER_CONTACT:\n // We don't have to emit any event here since this will be result of promise.\n task = this.updateTaskData(task, payload.data);\n _loggerProxy.default.log('Agent offer contact', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'registerTaskListeners'\n });\n break;\n case _types2.CC_EVENTS.AGENT_OUTBOUND_FAILED:\n // We don't have to emit any event here since this will be result of promise.\n if (task.data) {\n this.removeTaskFromCollection(task);\n }\n _loggerProxy.default.log('Agent outbound failed', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'registerTaskListeners'\n });\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_ASSIGNED:\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_ASSIGNED, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_UNASSIGNED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: true\n });\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_OFFER_RONA:\n task = this.updateTaskData(task, payload.data);\n this.metricsManager.trackEvent(_constants2.METRIC_EVENT_NAMES.AGENT_RONA, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(payload.data),\n taskId: payload.data.interactionId,\n reason: payload.data.reason\n }, ['behavioral', 'operational']);\n this.handleTaskCleanup(task);\n task.emit(_types.TASK_EVENTS.TASK_REJECT, payload.data.reason);\n break;\n case _types2.CC_EVENTS.CONTACT_ENDED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: payload.data.interaction.state !== 'new'\n });\n this.handleTaskCleanup(task);\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_HELD:\n // As soon as the main interaction is held, we need to emit TASK_HOLD\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_HOLD, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_UNHELD:\n // As soon as the main interaction is unheld, we need to emit TASK_RESUME\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_RESUME, task);\n break;\n case _types2.CC_EVENTS.AGENT_VTEAM_TRANSFERRED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: true\n });\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CTQ_CANCEL_FAILED:\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_QUEUE_FAILED, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_CREATED:\n // Received when self agent initiates a consult\n task = this.updateTaskData(task, {\n ...payload.data,\n isConsulted: false // This ensures that the task consult status is always reset\n });\n // Do not emit anything since this be received only as a result of an API invocation(handled by a promise)\n break;\n case _types2.CC_EVENTS.AGENT_OFFER_CONSULT:\n // Received when other agent sends us a consult offer\n task = this.updateTaskData(task, {\n ...payload.data,\n isConsulted: true // This ensures that the task is marked as us being requested for a consult\n });\n\n break;\n case _types2.CC_EVENTS.AGENT_CONSULTING:\n // Received when agent is in an active consult state\n task = this.updateTaskData(task, payload.data);\n if (task.data.isConsulted) {\n // Fire only if you are the agent who received the consult request\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_ACCEPTED, task);\n } else {\n // Fire only if you are the agent who initiated the consult\n task.emit(_types.TASK_EVENTS.TASK_CONSULTING, task);\n }\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_FAILED:\n // This can only be received by the agent who initiated the consult.\n // We need not emit any event here since this will be result of promise\n task = this.updateTaskData(task, payload.data);\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_ENDED:\n task = this.updateTaskData(task, payload.data);\n if (task.data.isConsulted) {\n // This will be the end state of the task as soon as we end the consult in case of\n // us being offered a consult\n this.removeTaskFromCollection(task);\n }\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CTQ_CANCELLED:\n // This event is received when the consult using queue is cancelled using API\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, task);\n break;\n case _types2.CC_EVENTS.AGENT_WRAPUP:\n task = this.updateTaskData(task, payload.data);\n break;\n case _types2.CC_EVENTS.AGENT_WRAPPEDUP:\n this.removeTaskFromCollection(task);\n break;\n default:\n break;\n }\n if (task) {\n task.emit(payload.data.type, payload.data);\n }\n }\n });\n }\n updateTaskData(task, taskData) {\n if (!task) {\n return undefined;\n }\n if (!taskData?.interactionId) {\n _loggerProxy.default.warn('Received task update with missing interactionId', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'updateTaskData'\n });\n }\n try {\n const currentTask = task.updateTaskData(taskData);\n this.taskCollection[taskData.interactionId] = currentTask;\n return currentTask;\n } catch (error) {\n _loggerProxy.default.error(`Failed to update task ${taskData.interactionId}`, {\n module: _constants.TASK_MANAGER_FILE,\n method: 'updateTaskData'\n });\n return task;\n }\n }\n removeTaskFromCollection(task) {\n if (task?.data?.interactionId) {\n delete this.taskCollection[task.data.interactionId];\n _loggerProxy.default.info(`Task removed from collection: ${task.data.interactionId}`, {\n module: _constants.TASK_MANAGER_FILE,\n method: 'removeTaskFromCollection'\n });\n }\n }\n handleTaskCleanup(task) {\n if (this.webCallingService.loginOption === _types3.LoginOption.BROWSER && task.data.interaction.mediaType === 'telephony') {\n task.unregisterWebCallListeners();\n this.webCallingService.cleanUpCall();\n }\n if (task.data.interaction.state === 'new') {\n // Only remove tasks in 'new' state immediately. For other states,\n // retain tasks until they complete wrap-up, unless the task disconnected before being answered.\n this.removeTaskFromCollection(task);\n }\n }\n\n /**\n * @param taskId - Unique identifier for each task\n */\n getTask = taskId => {\n return this.taskCollection[taskId];\n };\n\n /**\n * @param taskId - Unique identifier for each task\n */\n getAllTasks = () => {\n return this.taskCollection;\n };\n\n /**\n * @param contact - Routing Contact layer. Talks to AQMReq layer to convert events to promises\n * @param webCallingService - Webrtc Service Layer\n * @param webSocketManager - Websocket Manager to maintain websocket connection and keepalives\n */\n static getTaskManager = (contact, webCallingService, webSocketManager) => {\n if (!this.taskManager) {\n this.taskManager = new TaskManager(contact, webCallingService, webSocketManager);\n }\n return this.taskManager;\n };\n}\nexports[\"default\"] = TaskManager;\n//# sourceMappingURL=TaskManager.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/services/task/TaskManager.js?");
|
|
3956
3956
|
|
|
3957
3957
|
/***/ }),
|
|
3958
3958
|
|
|
@@ -4238,7 +4238,7 @@ eval("\n\nvar _Reflect$construct = __webpack_require__(/*! @babel/runtime-corejs
|
|
|
4238
4238
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4239
4239
|
|
|
4240
4240
|
"use strict";
|
|
4241
|
-
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _map = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/map */ \"../../../node_modules/@babel/runtime-corejs2/core-js/map.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common/dist/index.js\");\nvar _webexPlugin = _interopRequireDefault(__webpack_require__(/*! ./webex-plugin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-plugin.js\"));\nvar _webexHttpError = _interopRequireDefault(__webpack_require__(/*! ./webex-http-error */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-http-error.js\"));\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * Base class for coalescing requests to batched APIs\n * @class Batcher\n */\nvar Batcher = _webexPlugin.default.extend({\n session: {\n deferreds: {\n type: 'object',\n default: function _default() {\n return new _map.default();\n }\n },\n queue: {\n type: 'array',\n default: function _default() {\n return [];\n }\n }\n },\n derived: {\n bounce: {\n fn: function fn() {\n var _this = this;\n return (0, _common.cappedDebounce)(function () {\n return _this.executeQueue.apply(_this, arguments);\n }, this.config.batcherWait, {\n maxCalls: this.config.batcherMaxCalls,\n maxWait: this.config.batcherMaxWait\n });\n }\n }\n },\n /**\n * Requests an item from a batched API\n * @param {Object} item\n * @returns {Promise<mixed>}\n */\n request: function request(item) {\n var _this2 = this;\n // So far, I can't find a way to avoid three layers of nesting here.\n /* eslint max-nested-callbacks: [0] */\n var defer = new _common.Defer();\n this.fingerprintRequest(item).then(function (idx) {\n if (_this2.deferreds.has(idx)) {\n defer.resolve(_this2.deferreds.get(idx).promise);\n return;\n }\n _this2.deferreds.set(idx, defer);\n _this2.prepareItem(item).then(function (req) {\n defer.promise = defer.promise.then((0, _common.tap)(function () {\n return _this2.deferreds.delete(idx);\n })).catch(function (reason) {\n _this2.deferreds.delete(idx);\n return _promise.default.reject(reason);\n });\n _this2.enqueue(req).then(function () {\n return _this2.bounce();\n }).catch(function (reason) {\n return defer.reject(reason);\n });\n }).catch(function (reason) {\n return defer.reject(reason);\n });\n }).catch(function (reason) {\n return defer.reject(reason);\n });\n return defer.promise;\n },\n /**\n * Adds an item to the queue.\n * Intended to be overridden\n * @param {mixed} req\n * @returns {Promise<undefined>}\n */\n enqueue: function enqueue(req) {\n this.queue.push(req);\n return _promise.default.resolve();\n },\n /**\n * Transform the item before adding it to the queue\n * Intended to be overridden\n * @param {mixed} item\n * @returns {Promise<mixed>}\n */\n prepareItem: function prepareItem(item) {\n return _promise.default.resolve(item);\n },\n /**\n * Detaches the current queue, does any appropriate transforms, and submits it\n * to the API.\n * @returns {Promise<undefined>}\n */\n executeQueue: function executeQueue() {\n var _this3 = this;\n var queue = this.queue.splice(0, this.config.batcherMaxCalls);\n return new _promise.default(function (resolve) {\n resolve(_this3.prepareRequest(queue).then(function (payload) {\n return _this3.submitHttpRequest(payload).then(function (res) {\n return _this3.handleHttpSuccess(res);\n });\n }).catch(function (reason) {\n if (reason instanceof _webexHttpError.default) {\n return _this3.handleHttpError(reason);\n }\n return _promise.default.all(queue.map(function (item) {\n return _this3.getDeferredForRequest(item).then(function (defer) {\n defer.reject(reason);\n });\n }));\n }));\n }).catch(function (reason) {\n _this3.logger.error( false ? 0 : reason.stack);\n return _promise.default.reject(reason);\n });\n },\n /**\n * Performs any final transforms on the queue before submitting it to the API\n * Intended to be overridden\n * @param {Object|Array} queue\n * @returns {Promise<Object>}\n */\n prepareRequest: function prepareRequest(queue) {\n return _promise.default.resolve(queue);\n },\n /**\n * Submits the prepared request body to the API.\n * This method *must* be overridden\n * @param {Object} payload\n * @returns {Promise<HttpResponseObject>}\n */\n // eslint-disable-next-line no-unused-vars\n submitHttpRequest: function submitHttpRequest(payload) {\n throw new Error('request() must be implemented');\n },\n /**\n * Actions taken when the http request returns a success\n * Intended to be overridden\n * @param {Promise<HttpResponseObject>} res\n * @returns {Promise<undefined>}\n */\n handleHttpSuccess: function handleHttpSuccess(res) {\n var _this4 = this;\n return _promise.default.all((res.body && res.body.items || res.body).map(function (item) {\n return _this4.acceptItem(item);\n }));\n },\n /**\n * Actions taken when the http request returns a failure. Typically, this\n * means failing the entire queue, but could be overridden in some\n * implementations to e.g. reenqueue.\n * Intended to be overridden\n * @param {WebexHttpError} reason\n * @returns {Promise<undefined>}\n */\n handleHttpError: function handleHttpError(reason) {\n var _this5 = this;\n if (reason instanceof _webexHttpError.default) {\n if ((0, _lodash.has)(reason, 'options.body.map')) {\n return _promise.default.all(reason.options.body.map(function (item) {\n return _this5.getDeferredForRequest(item).then(function (defer) {\n defer.reject(reason);\n });\n }));\n }\n }\n this.logger.error('http error handler called without a WebexHttpError object', reason);\n return _promise.default.reject(reason);\n },\n /**\n * Determines if the item succeeded or failed and delegates accordingly\n * @param {Object} item\n * @returns {Promise<undefined>}\n */\n acceptItem: function acceptItem(item) {\n var _this6 = this;\n return this.didItemFail(item).then(function (didFail) {\n if (didFail) {\n return _this6.handleItemFailure(item);\n }\n return _this6.handleItemSuccess(item);\n });\n },\n /**\n * Indicates if the specified response item implies a success or a failure\n * Intended to be overridden\n * @param {Object} item\n * @returns {Promise<Boolean>}\n */\n // eslint-disable-next-line no-unused-vars\n didItemFail: function didItemFail(item) {\n return _promise.default.resolve(false);\n },\n /**\n * Finds the Defer for the specified item and rejects its promise\n * Intended to be overridden\n * @param {Object} item\n * @returns {Promise<undefined>}\n */\n handleItemFailure: function handleItemFailure(item) {\n return this.getDeferredForResponse(item).then(function (defer) {\n defer.reject(item);\n });\n },\n /**\n * Finds the Defer for the specified item and resolves its promise\n * Intended to be overridden\n * @param {Object} item\n * @returns {Promise<undefined>}\n */\n handleItemSuccess: function handleItemSuccess(item) {\n return this.getDeferredForResponse(item).then(function (defer) {\n defer.resolve(item);\n });\n },\n /**\n * Returns the Deferred for the specified request item\n * @param {Object} item\n * @returns {Promise<Defer>}\n */\n getDeferredForRequest: function getDeferredForRequest(item) {\n var _this7 = this;\n return this.fingerprintRequest(item).then(function (idx) {\n var defer = _this7.deferreds.get(idx);\n\n /* istanbul ignore if */\n if (!defer) {\n throw new Error('Could not find pending request for received response');\n }\n return defer;\n });\n },\n /**\n * Returns the Deferred for the specified response item\n * @param {Object} item\n * @returns {Promise<Defer>}\n */\n getDeferredForResponse: function getDeferredForResponse(item) {\n var _this8 = this;\n return this.fingerprintResponse(item).then(function (idx) {\n var defer = _this8.deferreds.get(idx);\n\n /* istanbul ignore if */\n if (!defer) {\n throw new Error('Could not find pending request for received response');\n }\n return defer;\n });\n },\n /**\n * Generates a unique identifier for the item in a request payload\n * Intended to be overridden\n * Note that overrides must return a primitive.\n * @param {Object} item\n * @returns {Promise<primitive>}\n */\n // eslint-disable-next-line no-unused-vars\n fingerprintRequest: function fingerprintRequest(item) {\n throw new Error('fingerprintRequest() must be implemented');\n },\n /**\n * Generates a unique identifier for the item in a response payload\n * Intended to be overridden\n * Note that overrides must return a primitive.\n * @param {Object} item\n * @returns {Promise<primitive>}\n */\n // eslint-disable-next-line no-unused-vars\n fingerprintResponse: function fingerprintResponse(item) {\n throw new Error('fingerprintResponse() must be implemented');\n },\n version: \"3.8.0-next.11\"\n});\nvar _default2 = exports[\"default\"] = Batcher;\n//# sourceMappingURL=batcher.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/lib/batcher.js?");
|
|
4241
|
+
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _map = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/map */ \"../../../node_modules/@babel/runtime-corejs2/core-js/map.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common/dist/index.js\");\nvar _webexPlugin = _interopRequireDefault(__webpack_require__(/*! ./webex-plugin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-plugin.js\"));\nvar _webexHttpError = _interopRequireDefault(__webpack_require__(/*! ./webex-http-error */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-http-error.js\"));\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * Base class for coalescing requests to batched APIs\n * @class Batcher\n */\nvar Batcher = _webexPlugin.default.extend({\n session: {\n deferreds: {\n type: 'object',\n default: function _default() {\n return new _map.default();\n }\n },\n queue: {\n type: 'array',\n default: function _default() {\n return [];\n }\n }\n },\n derived: {\n bounce: {\n fn: function fn() {\n var _this = this;\n return (0, _common.cappedDebounce)(function () {\n return _this.executeQueue.apply(_this, arguments);\n }, this.config.batcherWait, {\n maxCalls: this.config.batcherMaxCalls,\n maxWait: this.config.batcherMaxWait\n });\n }\n }\n },\n /**\n * Requests an item from a batched API\n * @param {Object} item\n * @returns {Promise<mixed>}\n */\n request: function request(item) {\n var _this2 = this;\n // So far, I can't find a way to avoid three layers of nesting here.\n /* eslint max-nested-callbacks: [0] */\n var defer = new _common.Defer();\n this.fingerprintRequest(item).then(function (idx) {\n if (_this2.deferreds.has(idx)) {\n defer.resolve(_this2.deferreds.get(idx).promise);\n return;\n }\n _this2.deferreds.set(idx, defer);\n _this2.prepareItem(item).then(function (req) {\n defer.promise = defer.promise.then((0, _common.tap)(function () {\n return _this2.deferreds.delete(idx);\n })).catch(function (reason) {\n _this2.deferreds.delete(idx);\n return _promise.default.reject(reason);\n });\n _this2.enqueue(req).then(function () {\n return _this2.bounce();\n }).catch(function (reason) {\n return defer.reject(reason);\n });\n }).catch(function (reason) {\n return defer.reject(reason);\n });\n }).catch(function (reason) {\n return defer.reject(reason);\n });\n return defer.promise;\n },\n /**\n * Adds an item to the queue.\n * Intended to be overridden\n * @param {mixed} req\n * @returns {Promise<undefined>}\n */\n enqueue: function enqueue(req) {\n this.queue.push(req);\n return _promise.default.resolve();\n },\n /**\n * Transform the item before adding it to the queue\n * Intended to be overridden\n * @param {mixed} item\n * @returns {Promise<mixed>}\n */\n prepareItem: function prepareItem(item) {\n return _promise.default.resolve(item);\n },\n /**\n * Detaches the current queue, does any appropriate transforms, and submits it\n * to the API.\n * @returns {Promise<undefined>}\n */\n executeQueue: function executeQueue() {\n var _this3 = this;\n var queue = this.queue.splice(0, this.config.batcherMaxCalls);\n return new _promise.default(function (resolve) {\n resolve(_this3.prepareRequest(queue).then(function (payload) {\n return _this3.submitHttpRequest(payload).then(function (res) {\n return _this3.handleHttpSuccess(res);\n });\n }).catch(function (reason) {\n if (reason instanceof _webexHttpError.default) {\n return _this3.handleHttpError(reason);\n }\n return _promise.default.all(queue.map(function (item) {\n return _this3.getDeferredForRequest(item).then(function (defer) {\n defer.reject(reason);\n });\n }));\n }));\n }).catch(function (reason) {\n _this3.logger.error( false ? 0 : reason.stack);\n return _promise.default.reject(reason);\n });\n },\n /**\n * Performs any final transforms on the queue before submitting it to the API\n * Intended to be overridden\n * @param {Object|Array} queue\n * @returns {Promise<Object>}\n */\n prepareRequest: function prepareRequest(queue) {\n return _promise.default.resolve(queue);\n },\n /**\n * Submits the prepared request body to the API.\n * This method *must* be overridden\n * @param {Object} payload\n * @returns {Promise<HttpResponseObject>}\n */\n // eslint-disable-next-line no-unused-vars\n submitHttpRequest: function submitHttpRequest(payload) {\n throw new Error('request() must be implemented');\n },\n /**\n * Actions taken when the http request returns a success\n * Intended to be overridden\n * @param {Promise<HttpResponseObject>} res\n * @returns {Promise<undefined>}\n */\n handleHttpSuccess: function handleHttpSuccess(res) {\n var _this4 = this;\n return _promise.default.all((res.body && res.body.items || res.body).map(function (item) {\n return _this4.acceptItem(item);\n }));\n },\n /**\n * Actions taken when the http request returns a failure. Typically, this\n * means failing the entire queue, but could be overridden in some\n * implementations to e.g. reenqueue.\n * Intended to be overridden\n * @param {WebexHttpError} reason\n * @returns {Promise<undefined>}\n */\n handleHttpError: function handleHttpError(reason) {\n var _this5 = this;\n if (reason instanceof _webexHttpError.default) {\n if ((0, _lodash.has)(reason, 'options.body.map')) {\n return _promise.default.all(reason.options.body.map(function (item) {\n return _this5.getDeferredForRequest(item).then(function (defer) {\n defer.reject(reason);\n });\n }));\n }\n }\n this.logger.error('http error handler called without a WebexHttpError object', reason);\n return _promise.default.reject(reason);\n },\n /**\n * Determines if the item succeeded or failed and delegates accordingly\n * @param {Object} item\n * @returns {Promise<undefined>}\n */\n acceptItem: function acceptItem(item) {\n var _this6 = this;\n return this.didItemFail(item).then(function (didFail) {\n if (didFail) {\n return _this6.handleItemFailure(item);\n }\n return _this6.handleItemSuccess(item);\n });\n },\n /**\n * Indicates if the specified response item implies a success or a failure\n * Intended to be overridden\n * @param {Object} item\n * @returns {Promise<Boolean>}\n */\n // eslint-disable-next-line no-unused-vars\n didItemFail: function didItemFail(item) {\n return _promise.default.resolve(false);\n },\n /**\n * Finds the Defer for the specified item and rejects its promise\n * Intended to be overridden\n * @param {Object} item\n * @returns {Promise<undefined>}\n */\n handleItemFailure: function handleItemFailure(item) {\n return this.getDeferredForResponse(item).then(function (defer) {\n defer.reject(item);\n });\n },\n /**\n * Finds the Defer for the specified item and resolves its promise\n * Intended to be overridden\n * @param {Object} item\n * @returns {Promise<undefined>}\n */\n handleItemSuccess: function handleItemSuccess(item) {\n return this.getDeferredForResponse(item).then(function (defer) {\n defer.resolve(item);\n });\n },\n /**\n * Returns the Deferred for the specified request item\n * @param {Object} item\n * @returns {Promise<Defer>}\n */\n getDeferredForRequest: function getDeferredForRequest(item) {\n var _this7 = this;\n return this.fingerprintRequest(item).then(function (idx) {\n var defer = _this7.deferreds.get(idx);\n\n /* istanbul ignore if */\n if (!defer) {\n throw new Error('Could not find pending request for received response');\n }\n return defer;\n });\n },\n /**\n * Returns the Deferred for the specified response item\n * @param {Object} item\n * @returns {Promise<Defer>}\n */\n getDeferredForResponse: function getDeferredForResponse(item) {\n var _this8 = this;\n return this.fingerprintResponse(item).then(function (idx) {\n var defer = _this8.deferreds.get(idx);\n\n /* istanbul ignore if */\n if (!defer) {\n throw new Error('Could not find pending request for received response');\n }\n return defer;\n });\n },\n /**\n * Generates a unique identifier for the item in a request payload\n * Intended to be overridden\n * Note that overrides must return a primitive.\n * @param {Object} item\n * @returns {Promise<primitive>}\n */\n // eslint-disable-next-line no-unused-vars\n fingerprintRequest: function fingerprintRequest(item) {\n throw new Error('fingerprintRequest() must be implemented');\n },\n /**\n * Generates a unique identifier for the item in a response payload\n * Intended to be overridden\n * Note that overrides must return a primitive.\n * @param {Object} item\n * @returns {Promise<primitive>}\n */\n // eslint-disable-next-line no-unused-vars\n fingerprintResponse: function fingerprintResponse(item) {\n throw new Error('fingerprintResponse() must be implemented');\n },\n version: \"3.8.0-next.12\"\n});\nvar _default2 = exports[\"default\"] = Batcher;\n//# sourceMappingURL=batcher.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/lib/batcher.js?");
|
|
4242
4242
|
|
|
4243
4243
|
/***/ }),
|
|
4244
4244
|
|
|
@@ -4260,7 +4260,7 @@ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-co
|
|
|
4260
4260
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4261
4261
|
|
|
4262
4262
|
"use strict";
|
|
4263
|
-
eval("\n\nvar _typeof = __webpack_require__(/*! @babel/runtime-corejs2/helpers/typeof */ \"../../../node_modules/@babel/runtime-corejs2/helpers/typeof.js\");\nvar _Object$keys2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _WeakMap = __webpack_require__(/*! @babel/runtime-corejs2/core-js/weak-map */ \"../../../node_modules/@babel/runtime-corejs2/core-js/weak-map.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _deleteProperty = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/delete-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/delete-property.js\"));\nvar _stringify = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/json/stringify */ \"../../../node_modules/@babel/runtime-corejs2/core-js/json/stringify.js\"));\nvar _keys = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _now = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/date/now */ \"../../../node_modules/@babel/runtime-corejs2/core-js/date/now.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"../../../node_modules/querystring-es3/index.js\"));\nvar _url = _interopRequireDefault(__webpack_require__(/*! url */ \"../../../node_modules/url/url.js\"));\nvar _jsonwebtoken = _interopRequireDefault(__webpack_require__(/*! jsonwebtoken */ \"../../../node_modules/jsonwebtoken/index.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common/dist/index.js\");\nvar _commonTimers = __webpack_require__(/*! @webex/common-timers */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common-timers/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _webexPlugin = _interopRequireDefault(__webpack_require__(/*! ../webex-plugin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-plugin.js\"));\nvar _decorators = __webpack_require__(/*! ../storage/decorators */ \"../../../node_modules/@webex/webex-core/dist/lib/storage/decorators.js\");\nvar _grantErrors = _interopRequireWildcard(__webpack_require__(/*! ./grant-errors */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/grant-errors.js\"));\nvar _scope = __webpack_require__(/*! ./scope */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/scope.js\");\nvar _token = _interopRequireDefault(__webpack_require__(/*! ./token */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/token.js\"));\nvar _tokenCollection = _interopRequireDefault(__webpack_require__(/*! ./token-collection */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/token-collection.js\"));\nvar _constants = __webpack_require__(/*! ../constants */ \"../../../node_modules/@webex/webex-core/dist/lib/constants.js\");\nvar _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _obj;\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nfunction _getRequireWildcardCache(e) { if (\"function\" != typeof _WeakMap) return null; var r = new _WeakMap(), t = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }\nfunction _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \"object\" != _typeof(e) && \"function\" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = _Object$defineProperty && _Object$getOwnPropertyDescriptor2; for (var u in e) if (\"default\" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor2(e, u) : null; i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }\nfunction ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\n/**\n * @class\n */\nvar Credentials = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({\n keyFactory: function keyFactory(scope) {\n return scope;\n }\n}), _dec2 = (0, _decorators.waitForValue)('@'), _dec3 = (0, _decorators.persist)('@'), _dec4 = (0, _decorators.waitForValue)('@'), _dec5 = (0, _common.whileInFlight)('isRefreshing'), _dec6 = (0, _decorators.waitForValue)('@'), (_obj = {\n collections: {\n userTokens: _tokenCollection.default\n },\n dataTypes: {\n token: (0, _common.makeStateDataType)(_token.default, 'token').dataType\n },\n derived: {\n canAuthorize: {\n deps: ['supertoken', 'supertoken.canAuthorize', 'canRefresh'],\n fn: function fn() {\n return Boolean(this.supertoken && this.supertoken.canAuthorize || this.canRefresh);\n }\n },\n canRefresh: {\n deps: ['supertoken', 'supertoken.canRefresh'],\n fn: function fn() {\n // If we're operating in JWT mode, we have to delegate to the consumer\n if (this.config.jwtRefreshCallback) {\n return true;\n }\n return Boolean(this.supertoken && this.supertoken.canRefresh);\n }\n },\n isUnverifiedGuest: {\n deps: ['supertoken'],\n /**\n * Returns true if the user is an unverified guest\n * @returns {boolean}\n */\n fn: function fn() {\n var isGuest = false;\n try {\n isGuest = JSON.parse(_common.base64.decode(this.supertoken.access_token.split('.')[1])).user_type === 'guest';\n } catch (_unused) {\n /* the non-guest token is formatted differently so catch is expected */\n }\n return isGuest;\n }\n }\n },\n props: {\n supertoken: (0, _common.makeStateDataType)(_token.default, 'token').prop\n },\n namespace: 'Credentials',\n session: {\n isRefreshing: {\n default: false,\n type: 'boolean'\n },\n /**\n * Becomes `true` once the {@link loaded} event fires.\n * @see {@link WebexPlugin#ready}\n * @instance\n * @memberof Credentials\n * @type {boolean}\n */\n ready: {\n default: false,\n type: 'boolean'\n },\n refreshTimer: {\n default: undefined,\n type: 'any'\n }\n },\n /**\n * Generates an OAuth Login URL. Prefers the api.ciscospark.com proxy if the\n * instance is initialize with an authorizatUrl, but fallsback to idbroker\n * as the base otherwise.\n * @instance\n * @memberof Credentials\n * @param {Object} [options={}]\n * @returns {string}\n */\n buildLoginUrl: function buildLoginUrl() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {\n clientType: 'public'\n };\n /* eslint-disable camelcase */\n if (options.state && !(0, _lodash.isObject)(options.state)) {\n throw new Error('if specified, `options.state` must be an object');\n }\n options.client_id = this.config.client_id;\n options.redirect_uri = this.config.redirect_uri;\n options.scope = this.config.scope;\n options = (0, _lodash.cloneDeep)(options);\n if (!options.response_type) {\n options.response_type = options.clientType === 'public' ? 'token' : 'code';\n }\n (0, _deleteProperty.default)(options, 'clientType');\n if (options.state) {\n if (!(0, _lodash.isEmpty)(options.state)) {\n options.state = _common.base64.toBase64Url((0, _stringify.default)(options.state));\n } else {\n delete options.state;\n }\n }\n return \"\".concat(this.config.authorizeUrl, \"?\").concat(_querystring.default.stringify(options));\n /* eslint-enable camelcase */\n },\n /**\n * Get the determined OrgId.\n *\n * @throws {Error} - If the OrgId could not be determined.\n * @returns {string} - The OrgId.\n */\n getOrgId: function getOrgId() {\n this.logger.info('credentials: attempting to retrieve the OrgId from token');\n try {\n // Attempt to extract a client-authenticated token's OrgId.\n this.logger.info('credentials: trying to extract OrgId from JWT');\n return this.extractOrgIdFromJWT(this.supertoken.access_token);\n } catch (e) {\n // Attempt to extract a user token's OrgId.\n this.logger.info('credentials: could not extract OrgId from JWT');\n this.logger.info('credentials: attempting to extract OrgId from user token');\n try {\n var _this$supertoken;\n return this.extractOrgIdFromUserToken((_this$supertoken = this.supertoken) === null || _this$supertoken === void 0 ? void 0 : _this$supertoken.access_token);\n } catch (f) {\n this.logger.info('credentials: could not extract OrgId from user token');\n throw f;\n }\n }\n },\n /**\n * Extract the OrgId [realm] from a provided JWT.\n *\n * @private\n * @param {string} token - The JWT to extract the OrgId from.\n * @throws {Error} - If the token does not pass JWT general/realm validation.\n * @returns {string} - The OrgId.\n */\n extractOrgIdFromJWT: function extractOrgIdFromJWT() {\n var token = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n // Decoded the provided token.\n var decodedJWT = _jsonwebtoken.default.decode(token);\n\n // Validate that the provided token is a JWT.\n if (!decodedJWT) {\n throw new Error('unable to extract the OrgId from the provided JWT');\n }\n if (!decodedJWT.realm) {\n throw new Error('the provided JWT does not contain an OrgId');\n }\n\n // Return the OrgId [realm].\n return decodedJWT.realm;\n },\n /**\n * Extract the OrgId [realm] from a provided user token.\n *\n * @private\n * @param {string} token - The user token to extract the OrgId from.\n * @throws {Error} - Will throw an error if the provided token is invalid.\n * @returns {string} - The OrgId.\n */\n extractOrgIdFromUserToken: function extractOrgIdFromUserToken() {\n var token = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n // Split the provided token into subsections.\n var fields = token.split('_');\n\n // Validate that the provided token has the proper amount of sections.\n if (fields.length !== 3) {\n throw new Error(\"the provided token is not a valid format, token has \".concat(fields.length, \" sections\"));\n }\n\n // Return the token section that contains the OrgId.\n return fields[2];\n },\n /**\n * Generates a Logout URL\n * @instance\n * @memberof Credentials\n * @param {Object} [options={}]\n * @returns {[type]}\n */\n buildLogoutUrl: function buildLogoutUrl() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return \"\".concat(this.config.logoutUrl, \"?\").concat(_querystring.default.stringify(_objectSpread({\n cisService: this.config.service,\n goto: this.config.redirect_uri\n }, options)));\n },\n /**\n * Generates a number between 60% - 90% of expired value\n * @instance\n * @memberof Credentials\n * @param {number} expiration\n * @private\n * @returns {number}\n */\n calcRefreshTimeout: function calcRefreshTimeout(expiration) {\n return Math.floor((Math.floor(Math.random() * 4) + 6) / 10 * expiration);\n },\n constructor: function constructor() {\n var _this = this;\n // HACK to deal with the fact that AmpersandState#dataTypes#set is a pure\n // function.\n this._dataTypes = (0, _lodash.cloneDeep)(this._dataTypes);\n (0, _keys.default)(this._dataTypes).forEach(function (key) {\n if (_this._dataTypes[key].set) {\n _this._dataTypes[key].set = _this._dataTypes[key].set.bind(_this);\n }\n });\n // END HACK\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n (0, _apply.default)(_webexPlugin.default, this, args);\n },\n /**\n * Downscopes a token\n * @instance\n * @memberof Credentials\n * @param {string} scope\n * @private\n * @returns {Promise<Token>}\n */\n downscope: function downscope(scope) {\n var _this2 = this;\n return this.supertoken.downscope(scope).catch(function (reason) {\n var _reason$body;\n var failReason = (_reason$body = reason === null || reason === void 0 ? void 0 : reason.body) !== null && _reason$body !== void 0 ? _reason$body : reason;\n _this2.logger.warn(\"credentials: failed to downscope supertoken to \\\"\".concat(scope, \"\\\"\"), failReason);\n _this2.logger.trace(\"credentials: falling back to supertoken for \".concat(scope));\n _this2.webex.internal.metrics.submitClientMetrics(_constants.METRICS.JS_SDK_CREDENTIALS_DOWNSCOPE_FAILED, {\n fields: {\n requestedScope: scope,\n failReason: failReason\n }\n });\n return _promise.default.resolve(new _token.default(_objectSpread({\n scope: scope\n }, _this2.supertoken.serialize())), {\n parent: _this2\n });\n });\n },\n /**\n * Requests a client credentials grant and returns the token. Given the\n * limited use for such tokens as this time, this method does not cache its\n * token.\n * @instance\n * @memberof Credentials\n * @param {Object} options\n * @returns {Promise<Token>}\n */\n getClientToken: function getClientToken() {\n var _this3 = this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('credentials: requesting client credentials grant');\n return this.webex.request({\n /* eslint-disable camelcase */\n method: 'POST',\n uri: options.uri || this.config.tokenUrl,\n form: {\n grant_type: 'client_credentials',\n scope: options.scope || 'webexsquare:admin',\n self_contained_token: true\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true\n },\n shouldRefreshAccessToken: false\n /* eslint-enable camelcase */\n }).then(function (res) {\n return new _token.default(res.body, {\n parent: _this3\n });\n }).catch(function (res) {\n if (res.statusCode !== 400) {\n return _promise.default.reject(res);\n }\n var ErrorConstructor = _grantErrors.default.select(res.body.error);\n return _promise.default.reject(new ErrorConstructor(res._res || res));\n });\n },\n /**\n * Resolves with a token with the specified scopes. If no scope is specified,\n * defaults to omit(webex.credentials.scope, 'spark:kms'). If no such token is\n * available, downscopes the supertoken to that scope.\n * @instance\n * @memberof Credentials\n * @param {string} scope\n * @returns {Promise<Token>}\n */\n getUserToken: function getUserToken(scope) {\n var _this4 = this;\n return _promise.default.resolve(!this.isRefreshing || new _promise.default(function (resolve) {\n _this4.logger.info('credentials: token refresh inflight; delaying getUserToken until refresh completes');\n _this4.once('change:isRefreshing', function () {\n _this4.logger.info('credentials: token refresh complete; reinvoking getUserToken');\n resolve();\n });\n })).then(function () {\n if (!_this4.canAuthorize) {\n _this4.logger.info('credentials: cannot produce an access token from current state');\n return _promise.default.reject(new Error('Current state cannot produce an access token'));\n }\n if (!scope) {\n scope = (0, _scope.filterScope)('spark:kms', _this4.supertoken.scope);\n }\n scope = (0, _scope.sortScope)(scope);\n if (scope === (0, _scope.sortScope)(_this4.supertoken.scope)) {\n return _promise.default.resolve(_this4.supertoken);\n }\n var token = _this4.userTokens.get(scope);\n\n // we should also check for the token.access_token since token object does\n // not get cleared on unsetting while logging out.\n if (!token || !token.access_token) {\n return _this4.downscope(scope).then((0, _common.tap)(function (t) {\n return _this4.userTokens.add(t);\n }));\n }\n return _promise.default.resolve(token);\n });\n },\n /**\n * Initializer\n * @instance\n * @memberof Credentials\n * @param {Object} attrs\n * @param {Object} options\n * @private\n * @returns {Credentials}\n */\n initialize: function initialize(attrs, options) {\n var _this5 = this;\n if (attrs) {\n if (typeof attrs === 'string') {\n this.supertoken = attrs;\n }\n if (attrs.access_token) {\n this.supertoken = attrs;\n }\n if (attrs.authorization) {\n if (attrs.authorization.supertoken) {\n this.supertoken = attrs.authorization.supertoken;\n } else {\n this.supertoken = attrs.authorization;\n }\n }\n\n // schedule refresh\n if (this.supertoken && this.supertoken.expires) {\n this.scheduleRefresh(this.supertoken.expires);\n }\n }\n (0, _apply.default)(_webexPlugin.default.prototype.initialize, this, [attrs, options]);\n this.listenToOnce(this.parent, 'change:config', function () {\n if (_this5.config.authorizationString) {\n var parsed = _url.default.parse(_this5.config.authorizationString, true);\n\n /* eslint-disable camelcase */\n _this5.config.client_id = parsed.query.client_id;\n _this5.config.redirect_uri = parsed.query.redirect_uri;\n _this5.config.scope = parsed.query.scope;\n _this5.config.authorizeUrl = parsed.href.substr(0, parsed.href.indexOf('?'));\n /* eslint-enable camelcase */\n }\n });\n\n this.webex.once('loaded', function () {\n _this5.ready = true;\n });\n },\n /**\n * Clears all tokens from store them from the stores.\n *\n * This is no longer quite the right name for this method, but all of the\n * alternatives I'm coming up with are already taken.\n * @instance\n * @memberof Credentials\n * @returns {Promise}\n */\n invalidate: function invalidate() {\n this.logger.info('credentials: invalidating tokens');\n\n // clear refresh timer\n if (this.refreshTimer) {\n clearTimeout(this.refreshTimer);\n this.unset('refreshTimer');\n }\n try {\n this.unset('supertoken');\n } catch (err) {\n this.logger.warn('credentials: failed to clear supertoken', err);\n }\n while (this.userTokens.models.length) {\n try {\n this.userTokens.remove(this.userTokens.models[0]);\n } catch (err) {\n this.logger.warn('credentials: failed to remove user token', err);\n }\n }\n this.logger.info('credentials: finished removing tokens');\n\n // Return a promise to give the storage layer a tick or two to clear\n // localStorage\n return _promise.default.resolve();\n },\n /**\n * Removes the supertoken and child tokens, then refreshes the supertoken;\n * subsequent calls to {@link Credentials#getUserToken()} will re-downscope\n * child tokens. Enqueus revocation of previous previousTokens. Yes, that's\n * the correct number of \"previous\"es.\n * @instance\n * @memberof Credentials\n * @returns {Promise}\n */\n refresh: function refresh() {\n var _this6 = this;\n this.logger.info('credentials: refresh requested');\n var supertoken = this.supertoken;\n var tokens = (0, _lodash.clone)(this.userTokens.models);\n\n // This is kind of a leaky abstraction, since it relies on the authorization\n // plugin, but the only alternatives I see are\n // 1. put all JWT support in core\n // 2. have separate jwt and non-jwt auth plugins\n // while I like #2 from a code simplicity standpoint, the third-party DX\n // isn't great\n if (this.config.jwtRefreshCallback) {\n return this.config.jwtRefreshCallback(this.webex)\n // eslint-disable-next-line no-shadow\n .then(function (jwt) {\n return _this6.webex.authorization.requestAccessTokenFromJwt({\n jwt: jwt\n });\n });\n }\n if (this.webex.internal.services) {\n this.webex.internal.services.updateCredentialsConfig();\n }\n return supertoken.refresh().catch(function (error) {\n if (error instanceof _grantErrors.OAuthError) {\n // Error: super token refresh failed with 400 status code.\n // Hence emit an event to the client, an opportunity to logout.\n _this6.unset('supertoken');\n while (_this6.userTokens.models.length) {\n try {\n _this6.userTokens.remove(_this6.userTokens.models[0]);\n } catch (err) {\n _this6.logger.warn('credentials: failed to remove user token', err);\n }\n }\n _this6.webex.trigger('client:InvalidRequestError');\n }\n return _promise.default.reject(error);\n }).then(function (st) {\n // clear refresh timer\n if (_this6.refreshTimer) {\n clearTimeout(_this6.refreshTimer);\n _this6.unset('refreshTimer');\n }\n _this6.supertoken = st;\n var invalidScopes = (0, _scope.diffScopes)(_this6.config.scope, st.scope);\n if (invalidScopes !== '') {\n _this6.logger.warn(\"credentials: \\\"\".concat(invalidScopes, \"\\\" scope(s) are invalid because not listed in the supertoken, they will be excluded from user token requests.\"));\n _this6.webex.internal.metrics.submitClientMetrics(_constants.METRICS.JS_SDK_CREDENTIALS_TOKEN_REFRESH_SCOPE_MISMATCH, {\n fields: {\n invalidScopes: invalidScopes\n }\n });\n }\n return _promise.default.all(tokens.map(function (token) {\n var tokenScope = (0, _scope.filterScope)((0, _scope.diffScopes)(token.scope, st.scope), token.scope);\n return _this6.downscope(tokenScope)\n // eslint-disable-next-line max-nested-callbacks\n .then(function (t) {\n _this6.logger.info(\"credentials: revoking token for \".concat(token.scope));\n return token.revoke().catch(function (err) {\n _this6.logger.warn('credentials: failed to revoke user token', err);\n }).then(function () {\n _this6.userTokens.remove(token.scope);\n _this6.userTokens.add(t);\n });\n });\n }));\n }).then(function () {\n _this6.scheduleRefresh(_this6.supertoken.expires);\n });\n },\n /**\n * Schedules a token refresh or refreshes the token if token has expired\n * @instance\n * @memberof Credentials\n * @param {number} expires\n * @private\n * @returns {undefined}\n */\n scheduleRefresh: function scheduleRefresh(expires) {\n var _this7 = this;\n var expiresIn = expires - (0, _now.default)();\n if (expiresIn > 0) {\n var timeoutLength = this.calcRefreshTimeout(expiresIn);\n this.refreshTimer = (0, _commonTimers.safeSetTimeout)(function () {\n return _this7.refresh();\n }, timeoutLength);\n } else {\n this.refresh();\n }\n },\n version: \"3.8.0-next.11\"\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"getUserToken\", [_dec, _dec2], (0, _getOwnPropertyDescriptor.default)(_obj, \"getUserToken\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"initialize\", [_dec3], (0, _getOwnPropertyDescriptor.default)(_obj, \"initialize\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"invalidate\", [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor.default)(_obj, \"invalidate\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"refresh\", [_common.oneFlight, _dec5, _dec6], (0, _getOwnPropertyDescriptor.default)(_obj, \"refresh\"), _obj)), _obj)));\nvar _default = exports[\"default\"] = Credentials;\n//# sourceMappingURL=credentials.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/lib/credentials/credentials.js?");
|
|
4263
|
+
eval("\n\nvar _typeof = __webpack_require__(/*! @babel/runtime-corejs2/helpers/typeof */ \"../../../node_modules/@babel/runtime-corejs2/helpers/typeof.js\");\nvar _Object$keys2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _WeakMap = __webpack_require__(/*! @babel/runtime-corejs2/core-js/weak-map */ \"../../../node_modules/@babel/runtime-corejs2/core-js/weak-map.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _deleteProperty = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/delete-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/delete-property.js\"));\nvar _stringify = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/json/stringify */ \"../../../node_modules/@babel/runtime-corejs2/core-js/json/stringify.js\"));\nvar _keys = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _now = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/date/now */ \"../../../node_modules/@babel/runtime-corejs2/core-js/date/now.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"../../../node_modules/querystring-es3/index.js\"));\nvar _url = _interopRequireDefault(__webpack_require__(/*! url */ \"../../../node_modules/url/url.js\"));\nvar _jsonwebtoken = _interopRequireDefault(__webpack_require__(/*! jsonwebtoken */ \"../../../node_modules/jsonwebtoken/index.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common/dist/index.js\");\nvar _commonTimers = __webpack_require__(/*! @webex/common-timers */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common-timers/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _webexPlugin = _interopRequireDefault(__webpack_require__(/*! ../webex-plugin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-plugin.js\"));\nvar _decorators = __webpack_require__(/*! ../storage/decorators */ \"../../../node_modules/@webex/webex-core/dist/lib/storage/decorators.js\");\nvar _grantErrors = _interopRequireWildcard(__webpack_require__(/*! ./grant-errors */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/grant-errors.js\"));\nvar _scope = __webpack_require__(/*! ./scope */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/scope.js\");\nvar _token = _interopRequireDefault(__webpack_require__(/*! ./token */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/token.js\"));\nvar _tokenCollection = _interopRequireDefault(__webpack_require__(/*! ./token-collection */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/token-collection.js\"));\nvar _constants = __webpack_require__(/*! ../constants */ \"../../../node_modules/@webex/webex-core/dist/lib/constants.js\");\nvar _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _obj;\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nfunction _getRequireWildcardCache(e) { if (\"function\" != typeof _WeakMap) return null; var r = new _WeakMap(), t = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }\nfunction _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \"object\" != _typeof(e) && \"function\" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = _Object$defineProperty && _Object$getOwnPropertyDescriptor2; for (var u in e) if (\"default\" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor2(e, u) : null; i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }\nfunction ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\n/**\n * @class\n */\nvar Credentials = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({\n keyFactory: function keyFactory(scope) {\n return scope;\n }\n}), _dec2 = (0, _decorators.waitForValue)('@'), _dec3 = (0, _decorators.persist)('@'), _dec4 = (0, _decorators.waitForValue)('@'), _dec5 = (0, _common.whileInFlight)('isRefreshing'), _dec6 = (0, _decorators.waitForValue)('@'), (_obj = {\n collections: {\n userTokens: _tokenCollection.default\n },\n dataTypes: {\n token: (0, _common.makeStateDataType)(_token.default, 'token').dataType\n },\n derived: {\n canAuthorize: {\n deps: ['supertoken', 'supertoken.canAuthorize', 'canRefresh'],\n fn: function fn() {\n return Boolean(this.supertoken && this.supertoken.canAuthorize || this.canRefresh);\n }\n },\n canRefresh: {\n deps: ['supertoken', 'supertoken.canRefresh'],\n fn: function fn() {\n // If we're operating in JWT mode, we have to delegate to the consumer\n if (this.config.jwtRefreshCallback) {\n return true;\n }\n return Boolean(this.supertoken && this.supertoken.canRefresh);\n }\n },\n isUnverifiedGuest: {\n deps: ['supertoken'],\n /**\n * Returns true if the user is an unverified guest\n * @returns {boolean}\n */\n fn: function fn() {\n var isGuest = false;\n try {\n isGuest = JSON.parse(_common.base64.decode(this.supertoken.access_token.split('.')[1])).user_type === 'guest';\n } catch (_unused) {\n /* the non-guest token is formatted differently so catch is expected */\n }\n return isGuest;\n }\n }\n },\n props: {\n supertoken: (0, _common.makeStateDataType)(_token.default, 'token').prop\n },\n namespace: 'Credentials',\n session: {\n isRefreshing: {\n default: false,\n type: 'boolean'\n },\n /**\n * Becomes `true` once the {@link loaded} event fires.\n * @see {@link WebexPlugin#ready}\n * @instance\n * @memberof Credentials\n * @type {boolean}\n */\n ready: {\n default: false,\n type: 'boolean'\n },\n refreshTimer: {\n default: undefined,\n type: 'any'\n }\n },\n /**\n * Generates an OAuth Login URL. Prefers the api.ciscospark.com proxy if the\n * instance is initialize with an authorizatUrl, but fallsback to idbroker\n * as the base otherwise.\n * @instance\n * @memberof Credentials\n * @param {Object} [options={}]\n * @returns {string}\n */\n buildLoginUrl: function buildLoginUrl() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {\n clientType: 'public'\n };\n /* eslint-disable camelcase */\n if (options.state && !(0, _lodash.isObject)(options.state)) {\n throw new Error('if specified, `options.state` must be an object');\n }\n options.client_id = this.config.client_id;\n options.redirect_uri = this.config.redirect_uri;\n options.scope = this.config.scope;\n options = (0, _lodash.cloneDeep)(options);\n if (!options.response_type) {\n options.response_type = options.clientType === 'public' ? 'token' : 'code';\n }\n (0, _deleteProperty.default)(options, 'clientType');\n if (options.state) {\n if (!(0, _lodash.isEmpty)(options.state)) {\n options.state = _common.base64.toBase64Url((0, _stringify.default)(options.state));\n } else {\n delete options.state;\n }\n }\n return \"\".concat(this.config.authorizeUrl, \"?\").concat(_querystring.default.stringify(options));\n /* eslint-enable camelcase */\n },\n /**\n * Get the determined OrgId.\n *\n * @throws {Error} - If the OrgId could not be determined.\n * @returns {string} - The OrgId.\n */\n getOrgId: function getOrgId() {\n this.logger.info('credentials: attempting to retrieve the OrgId from token');\n try {\n // Attempt to extract a client-authenticated token's OrgId.\n this.logger.info('credentials: trying to extract OrgId from JWT');\n return this.extractOrgIdFromJWT(this.supertoken.access_token);\n } catch (e) {\n // Attempt to extract a user token's OrgId.\n this.logger.info('credentials: could not extract OrgId from JWT');\n this.logger.info('credentials: attempting to extract OrgId from user token');\n try {\n var _this$supertoken;\n return this.extractOrgIdFromUserToken((_this$supertoken = this.supertoken) === null || _this$supertoken === void 0 ? void 0 : _this$supertoken.access_token);\n } catch (f) {\n this.logger.info('credentials: could not extract OrgId from user token');\n throw f;\n }\n }\n },\n /**\n * Extract the OrgId [realm] from a provided JWT.\n *\n * @private\n * @param {string} token - The JWT to extract the OrgId from.\n * @throws {Error} - If the token does not pass JWT general/realm validation.\n * @returns {string} - The OrgId.\n */\n extractOrgIdFromJWT: function extractOrgIdFromJWT() {\n var token = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n // Decoded the provided token.\n var decodedJWT = _jsonwebtoken.default.decode(token);\n\n // Validate that the provided token is a JWT.\n if (!decodedJWT) {\n throw new Error('unable to extract the OrgId from the provided JWT');\n }\n if (!decodedJWT.realm) {\n throw new Error('the provided JWT does not contain an OrgId');\n }\n\n // Return the OrgId [realm].\n return decodedJWT.realm;\n },\n /**\n * Extract the OrgId [realm] from a provided user token.\n *\n * @private\n * @param {string} token - The user token to extract the OrgId from.\n * @throws {Error} - Will throw an error if the provided token is invalid.\n * @returns {string} - The OrgId.\n */\n extractOrgIdFromUserToken: function extractOrgIdFromUserToken() {\n var token = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n // Split the provided token into subsections.\n var fields = token.split('_');\n\n // Validate that the provided token has the proper amount of sections.\n if (fields.length !== 3) {\n throw new Error(\"the provided token is not a valid format, token has \".concat(fields.length, \" sections\"));\n }\n\n // Return the token section that contains the OrgId.\n return fields[2];\n },\n /**\n * Generates a Logout URL\n * @instance\n * @memberof Credentials\n * @param {Object} [options={}]\n * @returns {[type]}\n */\n buildLogoutUrl: function buildLogoutUrl() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return \"\".concat(this.config.logoutUrl, \"?\").concat(_querystring.default.stringify(_objectSpread({\n cisService: this.config.service,\n goto: this.config.redirect_uri\n }, options)));\n },\n /**\n * Generates a number between 60% - 90% of expired value\n * @instance\n * @memberof Credentials\n * @param {number} expiration\n * @private\n * @returns {number}\n */\n calcRefreshTimeout: function calcRefreshTimeout(expiration) {\n return Math.floor((Math.floor(Math.random() * 4) + 6) / 10 * expiration);\n },\n constructor: function constructor() {\n var _this = this;\n // HACK to deal with the fact that AmpersandState#dataTypes#set is a pure\n // function.\n this._dataTypes = (0, _lodash.cloneDeep)(this._dataTypes);\n (0, _keys.default)(this._dataTypes).forEach(function (key) {\n if (_this._dataTypes[key].set) {\n _this._dataTypes[key].set = _this._dataTypes[key].set.bind(_this);\n }\n });\n // END HACK\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n (0, _apply.default)(_webexPlugin.default, this, args);\n },\n /**\n * Downscopes a token\n * @instance\n * @memberof Credentials\n * @param {string} scope\n * @private\n * @returns {Promise<Token>}\n */\n downscope: function downscope(scope) {\n var _this2 = this;\n return this.supertoken.downscope(scope).catch(function (reason) {\n var _reason$body;\n var failReason = (_reason$body = reason === null || reason === void 0 ? void 0 : reason.body) !== null && _reason$body !== void 0 ? _reason$body : reason;\n _this2.logger.warn(\"credentials: failed to downscope supertoken to \\\"\".concat(scope, \"\\\"\"), failReason);\n _this2.logger.trace(\"credentials: falling back to supertoken for \".concat(scope));\n _this2.webex.internal.metrics.submitClientMetrics(_constants.METRICS.JS_SDK_CREDENTIALS_DOWNSCOPE_FAILED, {\n fields: {\n requestedScope: scope,\n failReason: failReason\n }\n });\n return _promise.default.resolve(new _token.default(_objectSpread({\n scope: scope\n }, _this2.supertoken.serialize())), {\n parent: _this2\n });\n });\n },\n /**\n * Requests a client credentials grant and returns the token. Given the\n * limited use for such tokens as this time, this method does not cache its\n * token.\n * @instance\n * @memberof Credentials\n * @param {Object} options\n * @returns {Promise<Token>}\n */\n getClientToken: function getClientToken() {\n var _this3 = this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('credentials: requesting client credentials grant');\n return this.webex.request({\n /* eslint-disable camelcase */\n method: 'POST',\n uri: options.uri || this.config.tokenUrl,\n form: {\n grant_type: 'client_credentials',\n scope: options.scope || 'webexsquare:admin',\n self_contained_token: true\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true\n },\n shouldRefreshAccessToken: false\n /* eslint-enable camelcase */\n }).then(function (res) {\n return new _token.default(res.body, {\n parent: _this3\n });\n }).catch(function (res) {\n if (res.statusCode !== 400) {\n return _promise.default.reject(res);\n }\n var ErrorConstructor = _grantErrors.default.select(res.body.error);\n return _promise.default.reject(new ErrorConstructor(res._res || res));\n });\n },\n /**\n * Resolves with a token with the specified scopes. If no scope is specified,\n * defaults to omit(webex.credentials.scope, 'spark:kms'). If no such token is\n * available, downscopes the supertoken to that scope.\n * @instance\n * @memberof Credentials\n * @param {string} scope\n * @returns {Promise<Token>}\n */\n getUserToken: function getUserToken(scope) {\n var _this4 = this;\n return _promise.default.resolve(!this.isRefreshing || new _promise.default(function (resolve) {\n _this4.logger.info('credentials: token refresh inflight; delaying getUserToken until refresh completes');\n _this4.once('change:isRefreshing', function () {\n _this4.logger.info('credentials: token refresh complete; reinvoking getUserToken');\n resolve();\n });\n })).then(function () {\n if (!_this4.canAuthorize) {\n _this4.logger.info('credentials: cannot produce an access token from current state');\n return _promise.default.reject(new Error('Current state cannot produce an access token'));\n }\n if (!scope) {\n scope = (0, _scope.filterScope)('spark:kms', _this4.supertoken.scope);\n }\n scope = (0, _scope.sortScope)(scope);\n if (scope === (0, _scope.sortScope)(_this4.supertoken.scope)) {\n return _promise.default.resolve(_this4.supertoken);\n }\n var token = _this4.userTokens.get(scope);\n\n // we should also check for the token.access_token since token object does\n // not get cleared on unsetting while logging out.\n if (!token || !token.access_token) {\n return _this4.downscope(scope).then((0, _common.tap)(function (t) {\n return _this4.userTokens.add(t);\n }));\n }\n return _promise.default.resolve(token);\n });\n },\n /**\n * Initializer\n * @instance\n * @memberof Credentials\n * @param {Object} attrs\n * @param {Object} options\n * @private\n * @returns {Credentials}\n */\n initialize: function initialize(attrs, options) {\n var _this5 = this;\n if (attrs) {\n if (typeof attrs === 'string') {\n this.supertoken = attrs;\n }\n if (attrs.access_token) {\n this.supertoken = attrs;\n }\n if (attrs.authorization) {\n if (attrs.authorization.supertoken) {\n this.supertoken = attrs.authorization.supertoken;\n } else {\n this.supertoken = attrs.authorization;\n }\n }\n\n // schedule refresh\n if (this.supertoken && this.supertoken.expires) {\n this.scheduleRefresh(this.supertoken.expires);\n }\n }\n (0, _apply.default)(_webexPlugin.default.prototype.initialize, this, [attrs, options]);\n this.listenToOnce(this.parent, 'change:config', function () {\n if (_this5.config.authorizationString) {\n var parsed = _url.default.parse(_this5.config.authorizationString, true);\n\n /* eslint-disable camelcase */\n _this5.config.client_id = parsed.query.client_id;\n _this5.config.redirect_uri = parsed.query.redirect_uri;\n _this5.config.scope = parsed.query.scope;\n _this5.config.authorizeUrl = parsed.href.substr(0, parsed.href.indexOf('?'));\n /* eslint-enable camelcase */\n }\n });\n\n this.webex.once('loaded', function () {\n _this5.ready = true;\n });\n },\n /**\n * Clears all tokens from store them from the stores.\n *\n * This is no longer quite the right name for this method, but all of the\n * alternatives I'm coming up with are already taken.\n * @instance\n * @memberof Credentials\n * @returns {Promise}\n */\n invalidate: function invalidate() {\n this.logger.info('credentials: invalidating tokens');\n\n // clear refresh timer\n if (this.refreshTimer) {\n clearTimeout(this.refreshTimer);\n this.unset('refreshTimer');\n }\n try {\n this.unset('supertoken');\n } catch (err) {\n this.logger.warn('credentials: failed to clear supertoken', err);\n }\n while (this.userTokens.models.length) {\n try {\n this.userTokens.remove(this.userTokens.models[0]);\n } catch (err) {\n this.logger.warn('credentials: failed to remove user token', err);\n }\n }\n this.logger.info('credentials: finished removing tokens');\n\n // Return a promise to give the storage layer a tick or two to clear\n // localStorage\n return _promise.default.resolve();\n },\n /**\n * Removes the supertoken and child tokens, then refreshes the supertoken;\n * subsequent calls to {@link Credentials#getUserToken()} will re-downscope\n * child tokens. Enqueus revocation of previous previousTokens. Yes, that's\n * the correct number of \"previous\"es.\n * @instance\n * @memberof Credentials\n * @returns {Promise}\n */\n refresh: function refresh() {\n var _this6 = this;\n this.logger.info('credentials: refresh requested');\n var supertoken = this.supertoken;\n var tokens = (0, _lodash.clone)(this.userTokens.models);\n\n // This is kind of a leaky abstraction, since it relies on the authorization\n // plugin, but the only alternatives I see are\n // 1. put all JWT support in core\n // 2. have separate jwt and non-jwt auth plugins\n // while I like #2 from a code simplicity standpoint, the third-party DX\n // isn't great\n if (this.config.jwtRefreshCallback) {\n return this.config.jwtRefreshCallback(this.webex)\n // eslint-disable-next-line no-shadow\n .then(function (jwt) {\n return _this6.webex.authorization.requestAccessTokenFromJwt({\n jwt: jwt\n });\n });\n }\n if (this.webex.internal.services) {\n this.webex.internal.services.updateCredentialsConfig();\n }\n return supertoken.refresh().catch(function (error) {\n if (error instanceof _grantErrors.OAuthError) {\n // Error: super token refresh failed with 400 status code.\n // Hence emit an event to the client, an opportunity to logout.\n _this6.unset('supertoken');\n while (_this6.userTokens.models.length) {\n try {\n _this6.userTokens.remove(_this6.userTokens.models[0]);\n } catch (err) {\n _this6.logger.warn('credentials: failed to remove user token', err);\n }\n }\n _this6.webex.trigger('client:InvalidRequestError');\n }\n return _promise.default.reject(error);\n }).then(function (st) {\n // clear refresh timer\n if (_this6.refreshTimer) {\n clearTimeout(_this6.refreshTimer);\n _this6.unset('refreshTimer');\n }\n _this6.supertoken = st;\n var invalidScopes = (0, _scope.diffScopes)(_this6.config.scope, st.scope);\n if (invalidScopes !== '') {\n _this6.logger.warn(\"credentials: \\\"\".concat(invalidScopes, \"\\\" scope(s) are invalid because not listed in the supertoken, they will be excluded from user token requests.\"));\n _this6.webex.internal.metrics.submitClientMetrics(_constants.METRICS.JS_SDK_CREDENTIALS_TOKEN_REFRESH_SCOPE_MISMATCH, {\n fields: {\n invalidScopes: invalidScopes\n }\n });\n }\n return _promise.default.all(tokens.map(function (token) {\n var tokenScope = (0, _scope.filterScope)((0, _scope.diffScopes)(token.scope, st.scope), token.scope);\n return _this6.downscope(tokenScope)\n // eslint-disable-next-line max-nested-callbacks\n .then(function (t) {\n _this6.logger.info(\"credentials: revoking token for \".concat(token.scope));\n return token.revoke().catch(function (err) {\n _this6.logger.warn('credentials: failed to revoke user token', err);\n }).then(function () {\n _this6.userTokens.remove(token.scope);\n _this6.userTokens.add(t);\n });\n });\n }));\n }).then(function () {\n _this6.scheduleRefresh(_this6.supertoken.expires);\n });\n },\n /**\n * Schedules a token refresh or refreshes the token if token has expired\n * @instance\n * @memberof Credentials\n * @param {number} expires\n * @private\n * @returns {undefined}\n */\n scheduleRefresh: function scheduleRefresh(expires) {\n var _this7 = this;\n var expiresIn = expires - (0, _now.default)();\n if (expiresIn > 0) {\n var timeoutLength = this.calcRefreshTimeout(expiresIn);\n this.refreshTimer = (0, _commonTimers.safeSetTimeout)(function () {\n return _this7.refresh();\n }, timeoutLength);\n } else {\n this.refresh();\n }\n },\n version: \"3.8.0-next.12\"\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"getUserToken\", [_dec, _dec2], (0, _getOwnPropertyDescriptor.default)(_obj, \"getUserToken\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"initialize\", [_dec3], (0, _getOwnPropertyDescriptor.default)(_obj, \"initialize\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"invalidate\", [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor.default)(_obj, \"invalidate\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"refresh\", [_common.oneFlight, _dec5, _dec6], (0, _getOwnPropertyDescriptor.default)(_obj, \"refresh\"), _obj)), _obj)));\nvar _default = exports[\"default\"] = Credentials;\n//# sourceMappingURL=credentials.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/lib/credentials/credentials.js?");
|
|
4264
4264
|
|
|
4265
4265
|
/***/ }),
|
|
4266
4266
|
|
|
@@ -4315,7 +4315,7 @@ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-co
|
|
|
4315
4315
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4316
4316
|
|
|
4317
4317
|
"use strict";
|
|
4318
|
-
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _typeof = __webpack_require__(/*! @babel/runtime-corejs2/helpers/typeof */ \"../../../node_modules/@babel/runtime-corejs2/helpers/typeof.js\");\nvar _Object$keys = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _WeakMap = __webpack_require__(/*! @babel/runtime-corejs2/core-js/weak-map */ \"../../../node_modules/@babel/runtime-corejs2/core-js/weak-map.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/slicedToArray.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _assign = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/assign */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/assign.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _now = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/date/now */ \"../../../node_modules/@babel/runtime-corejs2/core-js/date/now.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common/dist/index.js\");\nvar _commonTimers = __webpack_require__(/*! @webex/common-timers */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common-timers/dist/index.js\");\nvar _webexHttpError = _interopRequireDefault(__webpack_require__(/*! ../webex-http-error */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-http-error.js\"));\nvar _webexPlugin = _interopRequireDefault(__webpack_require__(/*! ../webex-plugin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-plugin.js\"));\nvar _scope = __webpack_require__(/*! ./scope */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/scope.js\");\nvar _grantErrors = _interopRequireWildcard(__webpack_require__(/*! ./grant-errors */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/grant-errors.js\"));\nvar _dec, _obj;\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nfunction _getRequireWildcardCache(e) { if (\"function\" != typeof _WeakMap) return null; var r = new _WeakMap(), t = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }\nfunction _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \"object\" != _typeof(e) && \"function\" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = _Object$defineProperty && _Object$getOwnPropertyDescriptor2; for (var u in e) if (\"default\" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor2(e, u) : null; i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }\nfunction ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\n/* eslint-disable camelcase */\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.default.reject(res);\n }\n var ErrorConstructor = _grantErrors.default.select(res.body.error);\n if (ErrorConstructor === _grantErrors.OAuthError && res instanceof _webexHttpError.default) {\n return _promise.default.reject(res);\n }\n if (!ErrorConstructor) {\n return _promise.default.reject(res);\n }\n return _promise.default.reject(new ErrorConstructor(res._res || res));\n}\n\n/**\n * @class\n */\nvar Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({\n keyFactory: function keyFactory(scope) {\n return scope;\n }\n}), (_obj = {\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: function fn() {\n return !!this.access_token && !this.isExpired;\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: function fn() {\n return this.canAuthorize && !!this.config.client_id;\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: function fn() {\n if (_common.inBrowser) {\n return !!this.refresh_token && !!this.config.refreshCallback;\n }\n return !!this.refresh_token && !!this.config.client_secret;\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: function 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 * 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: function fn() {\n if (!this.access_token || !this.token_type) {\n return '';\n }\n return \"\".concat(this.token_type, \" \").concat(this.access_token);\n }\n }\n },\n namespace: 'Credentials',\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 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 * 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: function downscope(scope) {\n var _this = this;\n this.logger.info(\"token: downscoping token to \".concat(scope));\n if (this.isExpired) {\n this.logger.info('token: request received to downscope expired access_token');\n return _promise.default.reject(new Error('cannot downscope expired access token'));\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 return _promise.default.reject(new Error('cannot downscope access token'));\n }\n if ((0, _scope.diffScopes)(scope, this.config.scope) !== '') {\n return _promise.default.reject(new Error(\"new scope (\".concat(scope, \") is not subset of the available scopes (\").concat(this.config.scope, \")\")));\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 = (0, _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 === (0, _scope.sortScope)(this.config.scope)) {\n return _promise.default.reject(new Error('token: scope reduction requires a reduced scope'));\n }\n return this.webex.request({\n method: 'POST',\n uri: this.config.tokenUrl,\n addAuthHeader: false,\n form: {\n grant_type: 'urn:cisco:oauth:grant-type:scope-reduction',\n token: this.access_token,\n scope: scope,\n client_id: this.config.client_id,\n self_contained_token: true\n }\n }).then(function (res) {\n _this.logger.info(\"token: downscoped token to \".concat(scope));\n return new Token((0, _assign.default)(res.body, {\n scope: scope\n }), {\n 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: function initialize() {\n var _this2 = this;\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n (0, _apply.default)(_webexPlugin.default.prototype.initialize, this, [attrs, options]);\n if (typeof attrs === 'string') {\n this.access_token = attrs;\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 < (0, _now.default)()) {\n this._isExpired = true;\n } else {\n (0, _commonTimers.safeSetTimeout)(function () {\n _this2._isExpired = true;\n }, this.expires - (0, _now.default)());\n }\n }\n },\n /**\n * Refreshes this Token. Relies on\n * {@link config.credentials.refreshCallback()}\n * @instance\n * @memberof Token\n * @returns {Promise<Token>}\n */\n refresh: function refresh() {\n var _this3 = this;\n if (!this.canRefresh) {\n throw new Error('Not enough information available to refresh this access token');\n }\n var promise;\n if (_common.inBrowser) {\n if (!this.config.refreshCallback) {\n throw new Error('Cannot refresh access token without refreshCallback');\n }\n promise = _promise.default.resolve(this.config.refreshCallback(this.webex, this));\n }\n return (promise || this.webex.request({\n method: 'POST',\n uri: this.config.tokenUrl,\n form: {\n grant_type: 'refresh_token',\n redirect_uri: this.config.redirect_uri,\n refresh_token: this.refresh_token\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true\n },\n shouldRefreshAccessToken: false\n }).then(function (res) {\n return res.body;\n })).then(function (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 (0, _assign.default)(obj, (0, _lodash.pick)(_this3, 'refresh_token', 'refresh_token_expires', 'refresh_token_expires_in'));\n }\n\n // If the new token is the same as the previous token, then we may have\n // found a bug in CI; log the details and reject the Promise\n if (_this3.access_token === obj.access_token) {\n _this3.logger.error('token: new token matches current token');\n // log the tokens if it is not production\n if (true) {\n _this3.logger.error('token: current token:', _this3.access_token);\n _this3.logger.error('token: new token:', obj.access_token);\n }\n return _promise.default.reject(new Error('new token matches current token'));\n }\n if (_this3.previousToken) {\n _this3.previousToken.revoke();\n _this3.unset('previousToken');\n }\n obj.previousToken = _this3;\n obj.scope = _this3.scope;\n return new Token(obj, {\n parent: _this3.parent\n });\n }).catch(processGrantError);\n },\n /**\n * Revokes this token and unsets its local properties\n * @instance\n * @memberof Token\n * @returns {Promise}\n */\n revoke: function revoke() {\n var _this4 = this;\n if (this.isExpired) {\n this.logger.info('token: already expired, not making making revocation request');\n return _promise.default.resolve();\n }\n if (!this.canAuthorize) {\n this.logger.info('token: no longer valid, not making revocation request');\n return _promise.default.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 return _promise.default.resolve();\n }\n this.logger.info('token: revoking access token');\n return this.webex.request({\n method: 'POST',\n uri: this.config.revokeUrl,\n form: {\n token: this.access_token,\n token_type_hint: 'access_token'\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true\n },\n shouldRefreshAccessToken: false\n }).then(function () {\n _this4.unset(['access_token', 'expires', 'expires_in', 'token_type']);\n _this4.logger.info('token: access token revoked');\n }).catch(processGrantError);\n },\n set: function set() {\n // eslint-disable-next-line prefer-const\n var _this$_filterSetParam = this._filterSetParameters.apply(this, arguments),\n _this$_filterSetParam2 = (0, _slicedToArray2.default)(_this$_filterSetParam, 2),\n attrs = _this$_filterSetParam2[0],\n options = _this$_filterSetParam2[1];\n if (!attrs.token_type && attrs.access_token && attrs.access_token.includes(' ')) {\n var _attrs$access_token$s = attrs.access_token.split(' '),\n _attrs$access_token$s2 = (0, _slicedToArray2.default)(_attrs$access_token$s, 2),\n token_type = _attrs$access_token$s2[0],\n access_token = _attrs$access_token$s2[1];\n attrs = _objectSpread(_objectSpread({}, attrs), {}, {\n access_token: access_token,\n token_type: token_type\n });\n }\n var now = (0, _now.default)();\n if (!attrs.expires && attrs.expires_in) {\n attrs.expires = now + attrs.expires_in * 1000;\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 if (attrs.scope) {\n attrs.scope = (0, _scope.sortScope)(attrs.scope);\n }\n return (0, _apply.default)(_webexPlugin.default.prototype.set, this, [attrs, options]);\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: function toString() {\n if (!this._string) {\n throw new Error('cannot stringify Token');\n }\n return this._string;\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: function validate() {\n var _this5 = this;\n if (false) {}\n return this.webex.request({\n method: 'POST',\n service: 'conversation',\n resource: 'users/validateAuthToken',\n body: {\n token: this.access_token\n }\n }).catch(function (reason) {\n if ('statusCode' in reason) {\n return _promise.default.reject(reason);\n }\n _this5.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 var convApi = process.env.CONVERSATION_SERVICE || process.env.CONVERSATION_SERVICE_URL || 'https://conv-a.wbx2.com/conversation/api/v1';\n return _this5.webex.request({\n method: 'POST',\n uri: \"\".concat(convApi, \"/users/validateAuthToken\"),\n body: {\n token: _this5.access_token\n },\n headers: {\n authorization: \"Bearer \".concat(_this5.access_token)\n }\n });\n }).then(function (res) {\n return res.body;\n });\n },\n version: \"3.8.0-next.11\"\n}, ((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)));\nvar _default = exports[\"default\"] = Token;\n//# sourceMappingURL=token.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/lib/credentials/token.js?");
|
|
4318
|
+
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _typeof = __webpack_require__(/*! @babel/runtime-corejs2/helpers/typeof */ \"../../../node_modules/@babel/runtime-corejs2/helpers/typeof.js\");\nvar _Object$keys = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _WeakMap = __webpack_require__(/*! @babel/runtime-corejs2/core-js/weak-map */ \"../../../node_modules/@babel/runtime-corejs2/core-js/weak-map.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/slicedToArray.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _assign = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/assign */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/assign.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _now = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/date/now */ \"../../../node_modules/@babel/runtime-corejs2/core-js/date/now.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common/dist/index.js\");\nvar _commonTimers = __webpack_require__(/*! @webex/common-timers */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common-timers/dist/index.js\");\nvar _webexHttpError = _interopRequireDefault(__webpack_require__(/*! ../webex-http-error */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-http-error.js\"));\nvar _webexPlugin = _interopRequireDefault(__webpack_require__(/*! ../webex-plugin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-plugin.js\"));\nvar _scope = __webpack_require__(/*! ./scope */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/scope.js\");\nvar _grantErrors = _interopRequireWildcard(__webpack_require__(/*! ./grant-errors */ \"../../../node_modules/@webex/webex-core/dist/lib/credentials/grant-errors.js\"));\nvar _dec, _obj;\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nfunction _getRequireWildcardCache(e) { if (\"function\" != typeof _WeakMap) return null; var r = new _WeakMap(), t = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }\nfunction _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \"object\" != _typeof(e) && \"function\" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = _Object$defineProperty && _Object$getOwnPropertyDescriptor2; for (var u in e) if (\"default\" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor2(e, u) : null; i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }\nfunction ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\n/* eslint-disable camelcase */\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.default.reject(res);\n }\n var ErrorConstructor = _grantErrors.default.select(res.body.error);\n if (ErrorConstructor === _grantErrors.OAuthError && res instanceof _webexHttpError.default) {\n return _promise.default.reject(res);\n }\n if (!ErrorConstructor) {\n return _promise.default.reject(res);\n }\n return _promise.default.reject(new ErrorConstructor(res._res || res));\n}\n\n/**\n * @class\n */\nvar Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({\n keyFactory: function keyFactory(scope) {\n return scope;\n }\n}), (_obj = {\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: function fn() {\n return !!this.access_token && !this.isExpired;\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: function fn() {\n return this.canAuthorize && !!this.config.client_id;\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: function fn() {\n if (_common.inBrowser) {\n return !!this.refresh_token && !!this.config.refreshCallback;\n }\n return !!this.refresh_token && !!this.config.client_secret;\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: function 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 * 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: function fn() {\n if (!this.access_token || !this.token_type) {\n return '';\n }\n return \"\".concat(this.token_type, \" \").concat(this.access_token);\n }\n }\n },\n namespace: 'Credentials',\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 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 * 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: function downscope(scope) {\n var _this = this;\n this.logger.info(\"token: downscoping token to \".concat(scope));\n if (this.isExpired) {\n this.logger.info('token: request received to downscope expired access_token');\n return _promise.default.reject(new Error('cannot downscope expired access token'));\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 return _promise.default.reject(new Error('cannot downscope access token'));\n }\n if ((0, _scope.diffScopes)(scope, this.config.scope) !== '') {\n return _promise.default.reject(new Error(\"new scope (\".concat(scope, \") is not subset of the available scopes (\").concat(this.config.scope, \")\")));\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 = (0, _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 === (0, _scope.sortScope)(this.config.scope)) {\n return _promise.default.reject(new Error('token: scope reduction requires a reduced scope'));\n }\n return this.webex.request({\n method: 'POST',\n uri: this.config.tokenUrl,\n addAuthHeader: false,\n form: {\n grant_type: 'urn:cisco:oauth:grant-type:scope-reduction',\n token: this.access_token,\n scope: scope,\n client_id: this.config.client_id,\n self_contained_token: true\n }\n }).then(function (res) {\n _this.logger.info(\"token: downscoped token to \".concat(scope));\n return new Token((0, _assign.default)(res.body, {\n scope: scope\n }), {\n 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: function initialize() {\n var _this2 = this;\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n (0, _apply.default)(_webexPlugin.default.prototype.initialize, this, [attrs, options]);\n if (typeof attrs === 'string') {\n this.access_token = attrs;\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 < (0, _now.default)()) {\n this._isExpired = true;\n } else {\n (0, _commonTimers.safeSetTimeout)(function () {\n _this2._isExpired = true;\n }, this.expires - (0, _now.default)());\n }\n }\n },\n /**\n * Refreshes this Token. Relies on\n * {@link config.credentials.refreshCallback()}\n * @instance\n * @memberof Token\n * @returns {Promise<Token>}\n */\n refresh: function refresh() {\n var _this3 = this;\n if (!this.canRefresh) {\n throw new Error('Not enough information available to refresh this access token');\n }\n var promise;\n if (_common.inBrowser) {\n if (!this.config.refreshCallback) {\n throw new Error('Cannot refresh access token without refreshCallback');\n }\n promise = _promise.default.resolve(this.config.refreshCallback(this.webex, this));\n }\n return (promise || this.webex.request({\n method: 'POST',\n uri: this.config.tokenUrl,\n form: {\n grant_type: 'refresh_token',\n redirect_uri: this.config.redirect_uri,\n refresh_token: this.refresh_token\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true\n },\n shouldRefreshAccessToken: false\n }).then(function (res) {\n return res.body;\n })).then(function (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 (0, _assign.default)(obj, (0, _lodash.pick)(_this3, 'refresh_token', 'refresh_token_expires', 'refresh_token_expires_in'));\n }\n\n // If the new token is the same as the previous token, then we may have\n // found a bug in CI; log the details and reject the Promise\n if (_this3.access_token === obj.access_token) {\n _this3.logger.error('token: new token matches current token');\n // log the tokens if it is not production\n if (true) {\n _this3.logger.error('token: current token:', _this3.access_token);\n _this3.logger.error('token: new token:', obj.access_token);\n }\n return _promise.default.reject(new Error('new token matches current token'));\n }\n if (_this3.previousToken) {\n _this3.previousToken.revoke();\n _this3.unset('previousToken');\n }\n obj.previousToken = _this3;\n obj.scope = _this3.scope;\n return new Token(obj, {\n parent: _this3.parent\n });\n }).catch(processGrantError);\n },\n /**\n * Revokes this token and unsets its local properties\n * @instance\n * @memberof Token\n * @returns {Promise}\n */\n revoke: function revoke() {\n var _this4 = this;\n if (this.isExpired) {\n this.logger.info('token: already expired, not making making revocation request');\n return _promise.default.resolve();\n }\n if (!this.canAuthorize) {\n this.logger.info('token: no longer valid, not making revocation request');\n return _promise.default.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 return _promise.default.resolve();\n }\n this.logger.info('token: revoking access token');\n return this.webex.request({\n method: 'POST',\n uri: this.config.revokeUrl,\n form: {\n token: this.access_token,\n token_type_hint: 'access_token'\n },\n auth: {\n user: this.config.client_id,\n pass: this.config.client_secret,\n sendImmediately: true\n },\n shouldRefreshAccessToken: false\n }).then(function () {\n _this4.unset(['access_token', 'expires', 'expires_in', 'token_type']);\n _this4.logger.info('token: access token revoked');\n }).catch(processGrantError);\n },\n set: function set() {\n // eslint-disable-next-line prefer-const\n var _this$_filterSetParam = this._filterSetParameters.apply(this, arguments),\n _this$_filterSetParam2 = (0, _slicedToArray2.default)(_this$_filterSetParam, 2),\n attrs = _this$_filterSetParam2[0],\n options = _this$_filterSetParam2[1];\n if (!attrs.token_type && attrs.access_token && attrs.access_token.includes(' ')) {\n var _attrs$access_token$s = attrs.access_token.split(' '),\n _attrs$access_token$s2 = (0, _slicedToArray2.default)(_attrs$access_token$s, 2),\n token_type = _attrs$access_token$s2[0],\n access_token = _attrs$access_token$s2[1];\n attrs = _objectSpread(_objectSpread({}, attrs), {}, {\n access_token: access_token,\n token_type: token_type\n });\n }\n var now = (0, _now.default)();\n if (!attrs.expires && attrs.expires_in) {\n attrs.expires = now + attrs.expires_in * 1000;\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 if (attrs.scope) {\n attrs.scope = (0, _scope.sortScope)(attrs.scope);\n }\n return (0, _apply.default)(_webexPlugin.default.prototype.set, this, [attrs, options]);\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: function toString() {\n if (!this._string) {\n throw new Error('cannot stringify Token');\n }\n return this._string;\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: function validate() {\n var _this5 = this;\n if (false) {}\n return this.webex.request({\n method: 'POST',\n service: 'conversation',\n resource: 'users/validateAuthToken',\n body: {\n token: this.access_token\n }\n }).catch(function (reason) {\n if ('statusCode' in reason) {\n return _promise.default.reject(reason);\n }\n _this5.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 var convApi = process.env.CONVERSATION_SERVICE || process.env.CONVERSATION_SERVICE_URL || 'https://conv-a.wbx2.com/conversation/api/v1';\n return _this5.webex.request({\n method: 'POST',\n uri: \"\".concat(convApi, \"/users/validateAuthToken\"),\n body: {\n token: _this5.access_token\n },\n headers: {\n authorization: \"Bearer \".concat(_this5.access_token)\n }\n });\n }).then(function (res) {\n return res.body;\n });\n },\n version: \"3.8.0-next.12\"\n}, ((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)));\nvar _default = exports[\"default\"] = Token;\n//# sourceMappingURL=token.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/lib/credentials/token.js?");
|
|
4319
4319
|
|
|
4320
4320
|
/***/ }),
|
|
4321
4321
|
|
|
@@ -4469,7 +4469,7 @@ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-co
|
|
|
4469
4469
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4470
4470
|
|
|
4471
4471
|
"use strict";
|
|
4472
|
-
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _Object$keys2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = exports.DEFAULT_CLUSTER_SERVICE = exports.DEFAULT_CLUSTER = void 0;\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/slicedToArray.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _weakMap = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/weak-map */ \"../../../node_modules/@babel/runtime-corejs2/core-js/weak-map.js\"));\nvar _keys = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _sha = _interopRequireDefault(__webpack_require__(/*! crypto-js/sha256 */ \"../../../node_modules/crypto-js/sha256.js\"));\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _webexPlugin = _interopRequireDefault(__webpack_require__(/*! ../webex-plugin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-plugin.js\"));\nvar _metrics = _interopRequireDefault(__webpack_require__(/*! ./metrics */ \"../../../node_modules/@webex/webex-core/dist/lib/services/metrics.js\"));\nvar _serviceCatalog = _interopRequireDefault(__webpack_require__(/*! ./service-catalog */ \"../../../node_modules/@webex/webex-core/dist/lib/services/service-catalog.js\"));\nvar _serviceRegistry = _interopRequireDefault(__webpack_require__(/*! ./service-registry */ \"../../../node_modules/@webex/webex-core/dist/lib/services/service-registry.js\"));\nvar _serviceState = _interopRequireDefault(__webpack_require__(/*! ./service-state */ \"../../../node_modules/@webex/webex-core/dist/lib/services/service-state.js\"));\nvar _serviceFedRamp = _interopRequireDefault(__webpack_require__(/*! ./service-fed-ramp */ \"../../../node_modules/@webex/webex-core/dist/lib/services/service-fed-ramp.js\"));\nvar _constants = __webpack_require__(/*! ./constants */ \"../../../node_modules/@webex/webex-core/dist/lib/services/constants.js\");\nfunction ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }\nvar trailingSlashes = /(?:^\\/)|(?:\\/$)/;\n\n// The default cluster when one is not provided (usually as 'US' from hydra)\nvar DEFAULT_CLUSTER = exports.DEFAULT_CLUSTER = 'urn:TEAM:us-east-2_a';\n// The default service name for convo (currently identityLookup due to some weird CSB issue)\nvar DEFAULT_CLUSTER_SERVICE = exports.DEFAULT_CLUSTER_SERVICE = 'identityLookup';\nvar CLUSTER_SERVICE = process.env.WEBEX_CONVERSATION_CLUSTER_SERVICE || DEFAULT_CLUSTER_SERVICE;\nvar DEFAULT_CLUSTER_IDENTIFIER = process.env.WEBEX_CONVERSATION_DEFAULT_CLUSTER || \"\".concat(DEFAULT_CLUSTER, \":\").concat(CLUSTER_SERVICE);\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nvar Services = _webexPlugin.default.extend({\n namespace: 'Services',\n /**\n * The {@link WeakMap} of {@link ServiceRegistry} class instances that are\n * keyed with WebexCore instances.\n *\n * @instance\n * @type {WeakMap<WebexCore, ServiceRegistry>}\n * @private\n * @memberof Services\n */\n registries: new _weakMap.default(),\n /**\n * The {@link WeakMap} of {@link ServiceState} class instances that are\n * keyed with WebexCore instances.\n *\n * @instance\n * @type {WeakMap<WebexCore, ServiceState>}\n * @private\n * @memberof Services\n */\n states: new _weakMap.default(),\n props: {\n validateDomains: ['boolean', false, true],\n initFailed: ['boolean', false, false]\n },\n _catalogs: new _weakMap.default(),\n _serviceUrls: null,\n _hostCatalog: null,\n /**\n * Get the registry associated with this webex instance.\n *\n * @private\n * @memberof Services\n * @returns {ServiceRegistry} - The associated {@link ServiceRegistry}.\n */\n getRegistry: function getRegistry() {\n return this.registries.get(this.webex);\n },\n /**\n * Get the state associated with this webex instance.\n *\n * @private\n * @memberof Services\n * @returns {ServiceState} - The associated {@link ServiceState}.\n */\n getState: function getState() {\n return this.states.get(this.webex);\n },\n /**\n * @private\n * Get the current catalog based on the assocaited\n * webex instance.\n * @returns {ServiceCatalog}\n */\n _getCatalog: function _getCatalog() {\n return this._catalogs.get(this.webex);\n },\n /**\n * Get a service url from the current services list by name\n * from the associated instance catalog.\n * @param {string} name\n * @param {boolean} [priorityHost]\n * @param {string} [serviceGroup]\n * @returns {string|undefined}\n */\n get: function get(name, priorityHost, serviceGroup) {\n var catalog = this._getCatalog();\n return catalog.get(name, priorityHost, serviceGroup);\n },\n /**\n * Determine if the catalog contains a specific service\n *\n * @param {string} serviceName - The service name to validate.\n * @returns {boolean} - True if the service exists.\n */\n hasService: function hasService(serviceName) {\n return !!this.get(serviceName);\n },\n /**\n * Determine if a whilelist exists in the service catalog.\n *\n * @returns {boolean} - True if a allowed domains list exists.\n */\n hasAllowedDomains: function hasAllowedDomains() {\n var catalog = this._getCatalog();\n return catalog.getAllowedDomains().length > 0;\n },\n /**\n * Generate a service catalog as an object from\n * the associated instance catalog.\n * @param {boolean} [priorityHost] - use highest priority host if set to `true`\n * @param {string} [serviceGroup]\n * @returns {Record<string, string>}\n */\n list: function list(priorityHost, serviceGroup) {\n var catalog = this._getCatalog();\n return catalog.list(priorityHost, serviceGroup);\n },\n /**\n * Mark a priority host service url as failed.\n * This will mark the host associated with the\n * `ServiceUrl` to be removed from the its\n * respective host array, and then return the next\n * viable host from the `ServiceUrls` host array,\n * or the `ServiceUrls` default url if no other priority\n * hosts are available, or if `noPriorityHosts` is set to\n * `true`.\n * @param {string} url\n * @param {boolean} noPriorityHosts\n * @returns {string}\n */\n markFailedUrl: function markFailedUrl(url, noPriorityHosts) {\n var catalog = this._getCatalog();\n return catalog.markFailedUrl(url, noPriorityHosts);\n },\n /**\n * saves all the services from the pre and post catalog service\n * @param {Object} serviceUrls\n * @returns {void}\n */\n _updateServiceUrls: function _updateServiceUrls(serviceUrls) {\n this._serviceUrls = _objectSpread(_objectSpread({}, this._serviceUrls), serviceUrls);\n },\n /**\n * saves the hostCatalog object\n * @param {Object} hostCatalog\n * @returns {void}\n */\n _updateHostCatalog: function _updateHostCatalog(hostCatalog) {\n this._hostCatalog = _objectSpread(_objectSpread({}, this._hostCatalog), hostCatalog);\n },\n /**\n * Update a list of `serviceUrls` to the most current\n * catalog via the defined `discoveryUrl` then returns the current\n * list of services.\n * @param {object} [param]\n * @param {string} [param.from] - This accepts `limited` or `signin`\n * @param {object} [param.query] - This accepts `email`, `orgId` or `userId` key values\n * @param {string} [param.query.email] - must be a standard-format email\n * @param {string} [param.query.orgId] - must be an organization id\n * @param {string} [param.query.userId] - must be a user id\n * @param {string} [param.token] - used for signin catalog\n * @returns {Promise<object>}\n */\n updateServices: function updateServices() {\n var _this = this;\n var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n from = _ref.from,\n query = _ref.query,\n token = _ref.token,\n forceRefresh = _ref.forceRefresh;\n var catalog = this._getCatalog();\n var formattedQuery;\n var serviceGroup;\n\n // map catalog name to service group name.\n switch (from) {\n case 'limited':\n serviceGroup = 'preauth';\n break;\n case 'signin':\n serviceGroup = 'signin';\n break;\n default:\n serviceGroup = 'postauth';\n break;\n }\n\n // confirm catalog update for group is not in progress.\n if (catalog.status[serviceGroup].collecting) {\n return this.waitForCatalog(serviceGroup);\n }\n catalog.status[serviceGroup].collecting = true;\n if (serviceGroup === 'preauth') {\n var queryKey = query && (0, _keys.default)(query)[0];\n if (!['email', 'emailhash', 'userId', 'orgId', 'mode'].includes(queryKey)) {\n return _promise.default.reject(new Error('a query param of email, emailhash, userId, orgId, or mode is required'));\n }\n }\n // encode email when query key is email\n if (serviceGroup === 'preauth' || serviceGroup === 'signin') {\n var _queryKey = (0, _keys.default)(query)[0];\n formattedQuery = {};\n if (_queryKey === 'email' && query.email) {\n formattedQuery.emailhash = (0, _sha.default)(query.email.toLowerCase()).toString();\n } else {\n formattedQuery[_queryKey] = query[_queryKey];\n }\n }\n return this._fetchNewServiceHostmap({\n from: from,\n token: token,\n query: formattedQuery,\n forceRefresh: forceRefresh\n }).then(function (serviceHostMap) {\n catalog.updateServiceUrls(serviceGroup, serviceHostMap);\n _this.updateCredentialsConfig();\n catalog.status[serviceGroup].collecting = false;\n }).catch(function (error) {\n catalog.status[serviceGroup].collecting = false;\n return _promise.default.reject(error);\n });\n },\n /**\n * User validation parameter transfer object for {@link validateUser}.\n * @param {object} ValidateUserPTO\n * @property {string} ValidateUserPTO.email - The email of the user.\n * @property {string} [ValidateUserPTO.reqId] - The activation requester.\n * @property {object} [ValidateUserPTO.activationOptions] - Extra options to pass when sending the activation\n * @property {object} [ValidateUserPTO.preloginUserId] - The prelogin user id to set when sending the activation.\n */\n /**\n * User validation return transfer object for {@link validateUser}.\n * @param {object} ValidateUserRTO\n * @property {boolean} ValidateUserRTO.activated - If the user is activated.\n * @property {boolean} ValidateUserRTO.exists - If the user exists.\n * @property {string} ValidateUserRTO.details - A descriptive status message.\n * @property {object} ValidateUserRTO.user - **License** service user object.\n */\n /**\n * Validate if a user is activated and update the service catalogs as needed\n * based on the user's activation status.\n *\n * @param {ValidateUserPTO} - The parameter transfer object.\n * @returns {ValidateUserRTO} - The return transfer object.\n */\n validateUser: function validateUser(_ref2) {\n var _this2 = this;\n var email = _ref2.email,\n _ref2$reqId = _ref2.reqId,\n reqId = _ref2$reqId === void 0 ? 'WEBCLIENT' : _ref2$reqId,\n _ref2$forceRefresh = _ref2.forceRefresh,\n forceRefresh = _ref2$forceRefresh === void 0 ? false : _ref2$forceRefresh,\n _ref2$activationOptio = _ref2.activationOptions,\n activationOptions = _ref2$activationOptio === void 0 ? {} : _ref2$activationOptio,\n preloginUserId = _ref2.preloginUserId;\n this.logger.info('services: validating a user');\n\n // Validate that an email parameter key was provided.\n if (!email) {\n return _promise.default.reject(new Error('`email` is required'));\n }\n\n // Destructure the credentials object.\n var canAuthorize = this.webex.credentials.canAuthorize;\n\n // Validate that the user is already authorized.\n if (canAuthorize) {\n return this.updateServices({\n forceRefresh: forceRefresh\n }).then(function () {\n return _this2.webex.credentials.getUserToken();\n }).then(function (token) {\n return _this2.sendUserActivation({\n email: email,\n reqId: reqId,\n token: token.toString(),\n activationOptions: activationOptions,\n preloginUserId: preloginUserId\n });\n }).then(function (userObj) {\n return {\n activated: true,\n exists: true,\n details: 'user is authorized via a user token',\n user: userObj\n };\n });\n }\n\n // Destructure the client authorization details.\n /* eslint-disable camelcase */\n var _this$webex$credentia = this.webex.credentials.config,\n client_id = _this$webex$credentia.client_id,\n client_secret = _this$webex$credentia.client_secret;\n\n // Validate that client authentication details exist.\n if (!client_id || !client_secret) {\n return _promise.default.reject(new Error('client authentication details are not available'));\n }\n /* eslint-enable camelcase */\n\n // Declare a class-memeber-scoped token for usage within the promise chain.\n var token;\n\n // Begin client authentication user validation.\n return this.collectPreauthCatalog({\n email: email\n }).then(function () {\n // Retrieve the service url from the updated catalog. This is required\n // since `WebexCore` is usually not fully initialized at the time this\n // request completes.\n var idbrokerService = _this2.get('idbroker', true);\n\n // Collect the client auth token.\n return _this2.webex.credentials.getClientToken({\n uri: \"\".concat(idbrokerService, \"idb/oauth2/v1/access_token\"),\n scope: 'webexsquare:admin webexsquare:get_conversation Identity:SCIM'\n });\n }).then(function (tokenObj) {\n // Generate the token string.\n token = tokenObj.toString();\n\n // Collect the signin catalog using the client auth information.\n return _this2.collectSigninCatalog({\n email: email,\n token: token,\n forceRefresh: forceRefresh\n });\n })\n // Validate if collecting the signin catalog failed and populate the RTO\n // with the appropriate content.\n .catch(function (error) {\n return {\n exists: error.name !== 'NotFound',\n activated: false,\n details: error.name !== 'NotFound' ? 'user exists but is not activated' : 'user does not exist and is not activated'\n };\n })\n // Validate if the previous promise resolved with an RTO and populate the\n // new RTO accordingly.\n .then(function (rto) {\n return _promise.default.all([rto || {\n activated: true,\n exists: true,\n details: 'user exists and is activated'\n }, _this2.sendUserActivation({\n email: email,\n reqId: reqId,\n token: token,\n activationOptions: activationOptions,\n preloginUserId: preloginUserId\n })]);\n }).then(function (_ref3) {\n var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),\n rto = _ref4[0],\n user = _ref4[1];\n return _objectSpread(_objectSpread({}, rto), {}, {\n user: user\n });\n }).catch(function (error) {\n var response = {\n statusCode: error.statusCode,\n responseText: error.body && error.body.message,\n body: error.body\n };\n return _promise.default.reject(response);\n });\n },\n /**\n * Get user meeting preferences (preferred webex site).\n *\n * @returns {object} - User Information including user preferrences .\n */\n getMeetingPreferences: function getMeetingPreferences() {\n var _this3 = this;\n return this.request({\n method: 'GET',\n service: 'hydra',\n resource: 'meetingPreferences'\n }).then(function (res) {\n _this3.logger.info('services: received user region info');\n return res.body;\n }).catch(function (err) {\n _this3.logger.info('services: was not able to fetch user login information', err);\n // resolve successfully even if request failed\n });\n },\n /**\n * Fetches client region info such as countryCode and timezone.\n *\n * @returns {object} - The region info object.\n */\n fetchClientRegionInfo: function fetchClientRegionInfo() {\n var _this4 = this;\n var services = this.webex.config.services;\n return this.request({\n uri: services.discovery.sqdiscovery,\n addAuthHeader: false,\n headers: {\n 'spark-user-agent': null\n },\n timeout: 5000\n }).then(function (res) {\n _this4.logger.info('services: received user region info');\n return res.body;\n }).catch(function (err) {\n _this4.logger.info('services: was not able to get user region info', err);\n // resolve successfully even if request failed\n });\n },\n /**\n * User activation parameter transfer object for {@link sendUserActivation}.\n * @typedef {object} SendUserActivationPTO\n * @property {string} SendUserActivationPTO.email - The email of the user.\n * @property {string} SendUserActivationPTO.reqId - The activation requester.\n * @property {string} SendUserActivationPTO.token - The client auth token.\n * @property {object} SendUserActivationPTO.activationOptions - Extra options to pass when sending the activation.\n * @property {object} SendUserActivationPTO.preloginUserId - The prelogin user id to set when sending the activation.\n */\n /**\n * Send a request to activate a user using a client token.\n *\n * @param {SendUserActivationPTO} - The Parameter transfer object.\n * @returns {LicenseDTO} - The DTO returned from the **License** service.\n */\n sendUserActivation: function sendUserActivation(_ref5) {\n var _this5 = this;\n var email = _ref5.email,\n reqId = _ref5.reqId,\n token = _ref5.token,\n activationOptions = _ref5.activationOptions,\n preloginUserId = _ref5.preloginUserId;\n this.logger.info('services: sending user activation request');\n var countryCode;\n var timezone;\n\n // try to fetch client region info first\n return this.fetchClientRegionInfo().then(function (clientRegionInfo) {\n if (clientRegionInfo) {\n countryCode = clientRegionInfo.countryCode;\n timezone = clientRegionInfo.timezone;\n }\n\n // Send the user activation request to the **License** service.\n return _this5.request({\n service: 'license',\n resource: 'users/activations',\n method: 'POST',\n headers: {\n accept: 'application/json',\n authorization: token,\n 'x-prelogin-userid': preloginUserId\n },\n body: _objectSpread({\n email: email,\n reqId: reqId,\n countryCode: countryCode,\n timeZone: timezone\n }, activationOptions),\n shouldRefreshAccessToken: false\n });\n })\n // On success, return the **License** user object.\n .then(function (_ref6) {\n var body = _ref6.body;\n return body;\n })\n // On failure, reject with error from **License**.\n .catch(function (error) {\n return _promise.default.reject(error);\n });\n },\n /**\n * Updates a given service group i.e. preauth, signin, postauth with a new hostmap.\n * @param {string} serviceGroup - preauth, signin, postauth\n * @param {object} hostMap - The new hostmap to update the service group with.\n * @returns {Promise<void>}\n */\n updateCatalog: function updateCatalog(serviceGroup, hostMap) {\n var catalog = this._getCatalog();\n var serviceHostMap = this._formatReceivedHostmap(hostMap);\n return catalog.updateServiceUrls(serviceGroup, serviceHostMap);\n },\n /**\n * simplified method to update the preauth catalog via email\n *\n * @param {object} query\n * @param {string} query.email - A standard format email.\n * @param {string} query.orgId - The user's OrgId.\n * @param {boolean} forceRefresh - Boolean to bypass u2c cache control header\n * @returns {Promise<void>}\n */\n collectPreauthCatalog: function collectPreauthCatalog(query) {\n var forceRefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n if (!query) {\n return this.updateServices({\n from: 'limited',\n query: {\n mode: 'DEFAULT_BY_PROXIMITY'\n },\n forceRefresh: forceRefresh\n });\n }\n return this.updateServices({\n from: 'limited',\n query: query,\n forceRefresh: forceRefresh\n });\n },\n /**\n * simplified method to update the signin catalog via email and token\n * @param {object} param\n * @param {string} param.email - must be a standard-format email\n * @param {string} param.token - must be a client token\n * @returns {Promise<void>}\n */\n collectSigninCatalog: function collectSigninCatalog() {\n var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n email = _ref7.email,\n token = _ref7.token,\n forceRefresh = _ref7.forceRefresh;\n if (!email) {\n return _promise.default.reject(new Error('`email` is required'));\n }\n if (!token) {\n return _promise.default.reject(new Error('`token` is required'));\n }\n return this.updateServices({\n from: 'signin',\n query: {\n email: email\n },\n token: token,\n forceRefresh: forceRefresh\n });\n },\n /**\n * Updates credentials config to utilize u2c catalog\n * urls.\n * @returns {void}\n */\n updateCredentialsConfig: function updateCredentialsConfig() {\n var _this$list = this.list(true),\n idbroker = _this$list.idbroker,\n identity = _this$list.identity;\n if (idbroker && identity) {\n var _this$webex$config$cr = this.webex.config.credentials,\n authorizationString = _this$webex$config$cr.authorizationString,\n authorizeUrl = _this$webex$config$cr.authorizeUrl;\n\n // This must be set outside of the setConfig method used to assign the\n // idbroker and identity url values.\n this.webex.config.credentials.authorizeUrl = authorizationString ? authorizeUrl : \"\".concat(idbroker.replace(trailingSlashes, ''), \"/idb/oauth2/v1/authorize\");\n this.webex.setConfig({\n credentials: {\n idbroker: {\n url: idbroker.replace(trailingSlashes, '') // remove trailing slash\n },\n\n identity: {\n url: identity.replace(trailingSlashes, '') // remove trailing slash\n }\n }\n });\n }\n },\n /**\n * Wait until the service catalog is available,\n * or reject afte ra timeout of 60 seconds.\n * @param {string} serviceGroup\n * @param {number} [timeout] - in seconds\n * @returns {Promise<void>}\n */\n waitForCatalog: function waitForCatalog(serviceGroup, timeout) {\n var catalog = this._getCatalog();\n var supertoken = this.webex.credentials.supertoken;\n if (serviceGroup === 'postauth' && supertoken && supertoken.access_token && !catalog.status.postauth.collecting && !catalog.status.postauth.ready) {\n if (!catalog.status.preauth.ready) {\n return this.initServiceCatalogs();\n }\n return this.updateServices();\n }\n return catalog.waitForCatalog(serviceGroup, timeout);\n },\n /**\n * Service waiting parameter transfer object for {@link waitForService}.\n *\n * @typedef {object} WaitForServicePTO\n * @property {string} [WaitForServicePTO.name] - The service name.\n * @property {string} [WaitForServicePTO.url] - The service url.\n * @property {string} [WaitForServicePTO.timeout] - wait duration in seconds.\n */\n /**\n * Wait until the service has been ammended to any service catalog. This\n * method prioritizes the service name over the service url when searching.\n *\n * @param {WaitForServicePTO} - The parameter transfer object.\n * @returns {Promise<string>} - Resolves to the priority host of a service.\n */\n waitForService: function waitForService(_ref8) {\n var _this6 = this;\n var name = _ref8.name,\n _ref8$timeout = _ref8.timeout,\n timeout = _ref8$timeout === void 0 ? 5 : _ref8$timeout,\n url = _ref8.url;\n var services = this.webex.config.services;\n\n // Save memory by grabbing the catalog after there isn't a priortyURL\n var catalog = this._getCatalog();\n var fetchFromServiceUrl = services.servicesNotNeedValidation.find(function (service) {\n return service === name;\n });\n if (fetchFromServiceUrl) {\n return _promise.default.resolve(this._serviceUrls[name]);\n }\n var priorityUrl = this.get(name, true);\n var priorityUrlObj = this.getServiceFromUrl(url);\n if (priorityUrl || priorityUrlObj) {\n return _promise.default.resolve(priorityUrl || priorityUrlObj.priorityUrl);\n }\n if (catalog.isReady) {\n if (url) {\n return _promise.default.resolve(url);\n }\n this.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_SERVICE_NOT_FOUND, {\n fields: {\n service_name: name\n }\n });\n return _promise.default.reject(new Error(\"services: service '\".concat(name, \"' was not found in any of the catalogs\")));\n }\n return new _promise.default(function (resolve, reject) {\n var groupsToCheck = ['preauth', 'signin', 'postauth'];\n var checkCatalog = function checkCatalog(catalogGroup) {\n return catalog.waitForCatalog(catalogGroup, timeout).then(function () {\n var scopedPriorityUrl = _this6.get(name, true);\n var scopedPrioriryUrlObj = _this6.getServiceFromUrl(url);\n if (scopedPriorityUrl || scopedPrioriryUrlObj) {\n resolve(scopedPriorityUrl || scopedPrioriryUrlObj.priorityUrl);\n }\n }).catch(function () {\n return undefined;\n });\n };\n _promise.default.all(groupsToCheck.map(function (group) {\n return checkCatalog(group);\n })).then(function () {\n _this6.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_SERVICE_NOT_FOUND, {\n fields: {\n service_name: name\n }\n });\n reject(new Error(\"services: service '\".concat(name, \"' was not found after waiting\")));\n });\n });\n },\n /**\n * Looks up the hostname in the host catalog\n * and replaces it with the first host if it finds it\n * @param {string} uri\n * @returns {string} uri with the host replaced\n */\n replaceHostFromHostmap: function replaceHostFromHostmap(uri) {\n var url = new URL(uri);\n var hostCatalog = this._hostCatalog;\n if (!hostCatalog) {\n return uri;\n }\n var host = hostCatalog[url.host];\n if (host && host[0]) {\n var newHost = host[0].host;\n url.host = newHost;\n return url.toString();\n }\n return uri;\n },\n /**\n * @private\n * Organize a received hostmap from a service\n * catalog endpoint.\n * @param {object} serviceHostmap\n * @returns {object}\n */\n _formatReceivedHostmap: function _formatReceivedHostmap(serviceHostmap) {\n this._updateHostCatalog(serviceHostmap.hostCatalog);\n var extractId = function extractId(entry) {\n return entry.id.split(':')[3];\n };\n var formattedHostmap = [];\n\n // for each of the services in the serviceLinks, find the matching host in the catalog\n (0, _keys.default)(serviceHostmap.serviceLinks).forEach(function (serviceName) {\n var _formattedHost$hosts;\n var serviceUrl = serviceHostmap.serviceLinks[serviceName];\n var host;\n try {\n host = new URL(serviceUrl).host;\n } catch (e) {\n return;\n }\n var matchingCatalogEntry = serviceHostmap.hostCatalog[host];\n var formattedHost = {\n name: serviceName,\n defaultUrl: serviceUrl,\n defaultHost: host,\n hosts: []\n };\n formattedHostmap.push(formattedHost);\n\n // If the catalog does not have any hosts we will be unable to find the service ID\n // so can't search for other hosts\n if (!matchingCatalogEntry || !matchingCatalogEntry[0]) {\n return;\n }\n var serviceId = extractId(matchingCatalogEntry[0]);\n (0, _lodash.forEach)(matchingCatalogEntry, function (entry) {\n // The ids for all hosts within a hostCatalog entry should be the same\n // but for safety, only add host entries that have the same id as the first one\n if (extractId(entry) === serviceId) {\n formattedHost.hosts.push(_objectSpread(_objectSpread({}, entry), {}, {\n homeCluster: true\n }));\n }\n });\n var otherHosts = [];\n\n // find the services in the host catalog that have the same id\n // and add them to the otherHosts\n (0, _lodash.forEach)(serviceHostmap.hostCatalog, function (entry) {\n // exclude the matching catalog entry as we have already added that\n if (entry === matchingCatalogEntry) {\n return;\n }\n (0, _lodash.forEach)(entry, function (entryHost) {\n // only add hosts that have the correct id\n if (extractId(entryHost) === serviceId) {\n otherHosts.push(_objectSpread(_objectSpread({}, entryHost), {}, {\n homeCluster: false\n }));\n }\n });\n });\n (_formattedHost$hosts = formattedHost.hosts).push.apply(_formattedHost$hosts, otherHosts);\n });\n\n // update all the service urls in the host catalog\n\n this._updateServiceUrls(serviceHostmap.serviceLinks);\n this._updateHostCatalog(serviceHostmap.hostCatalog);\n return formattedHostmap;\n },\n /**\n * Get the clusterId associated with a URL string.\n * @param {string} url\n * @returns {string} - Cluster ID of url provided\n */\n getClusterId: function getClusterId(url) {\n var catalog = this._getCatalog();\n return catalog.findClusterId(url);\n },\n /**\n * Get a service value from a provided clusterId. This method will\n * return an object containing both the name and url of a found service.\n * @param {object} params\n * @param {string} params.clusterId - clusterId of found service\n * @param {boolean} [params.priorityHost] - returns priority host url if true\n * @param {string} [params.serviceGroup] - specify service group\n * @returns {object} service\n * @returns {string} service.name\n * @returns {string} service.url\n */\n getServiceFromClusterId: function getServiceFromClusterId(params) {\n var catalog = this._getCatalog();\n return catalog.findServiceFromClusterId(params);\n },\n /**\n * @param {String} cluster the cluster containing the id\n * @param {UUID} [id] the id of the conversation.\n * If empty, just return the base URL.\n * @returns {String} url of the service\n */\n getServiceUrlFromClusterId: function getServiceUrlFromClusterId() {\n var _ref9 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref9$cluster = _ref9.cluster,\n cluster = _ref9$cluster === void 0 ? 'us' : _ref9$cluster;\n var clusterId = cluster === 'us' ? DEFAULT_CLUSTER_IDENTIFIER : cluster;\n\n // Determine if cluster has service name (non-US clusters from hydra do not)\n if (clusterId.split(':').length < 4) {\n // Add Service to cluster identifier\n clusterId = \"\".concat(cluster, \":\").concat(CLUSTER_SERVICE);\n }\n var _ref10 = this.getServiceFromClusterId({\n clusterId: clusterId\n }) || {},\n url = _ref10.url;\n if (!url) {\n throw Error(\"Could not find service for cluster [\".concat(cluster, \"]\"));\n }\n return url;\n },\n /**\n * Get a service object from a service url if the service url exists in the\n * catalog.\n *\n * @param {string} url - The url to be validated.\n * @returns {object} - Service object.\n * @returns {object.name} - The name of the service found.\n * @returns {object.priorityUrl} - The priority url of the found service.\n * @returns {object.defaultUrl} - The default url of the found service.\n */\n getServiceFromUrl: function getServiceFromUrl() {\n var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n var service = this._getCatalog().findServiceUrlFromUrl(url);\n if (!service) {\n return undefined;\n }\n return {\n name: service.name,\n priorityUrl: service.get(true),\n defaultUrl: service.get()\n };\n },\n /**\n * Verify that a provided url exists in the service\n * catalog.\n * @param {string} url\n * @returns {boolean} - true if exists, false otherwise\n */\n isServiceUrl: function isServiceUrl(url) {\n var catalog = this._getCatalog();\n return !!catalog.findServiceUrlFromUrl(url);\n },\n /**\n * Determine if a provided url is in the catalog's allowed domains.\n *\n * @param {string} url - The url to match allowed domains against.\n * @returns {boolean} - True if the url provided is allowed.\n */\n isAllowedDomainUrl: function isAllowedDomainUrl(url) {\n var catalog = this._getCatalog();\n return !!catalog.findAllowedDomain(url);\n },\n /**\n * Converts the host portion of the url from default host\n * to a priority host\n *\n * @param {string} url a service url that contains a default host\n * @returns {string} a service url that contains the top priority host.\n * @throws if url isn't a service url\n */\n convertUrlToPriorityHostUrl: function convertUrlToPriorityHostUrl() {\n var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n var data = this.getServiceFromUrl(url);\n if (!data) {\n throw Error(\"No service associated with url: [\".concat(url, \"]\"));\n }\n return url.replace(data.defaultUrl, data.priorityUrl);\n },\n /**\n * @private\n * Simplified method wrapper for sending a request to get\n * an updated service hostmap.\n * @param {object} [param]\n * @param {string} [param.from] - This accepts `limited` or `signin`\n * @param {object} [param.query] - This accepts `email`, `orgId` or `userId` key values\n * @param {string} [param.query.email] - must be a standard-format email\n * @param {string} [param.query.orgId] - must be an organization id\n * @param {string} [param.query.userId] - must be a user id\n * @param {string} [param.token] - used for signin catalog\n * @returns {Promise<object>}\n */\n _fetchNewServiceHostmap: function _fetchNewServiceHostmap() {\n var _this7 = this;\n var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n from = _ref11.from,\n query = _ref11.query,\n token = _ref11.token,\n forceRefresh = _ref11.forceRefresh;\n var service = 'u2c';\n var resource = from ? \"/\".concat(from, \"/catalog\") : '/catalog';\n var qs = _objectSpread(_objectSpread({}, query), {}, {\n format: 'hostmap'\n });\n if (forceRefresh) {\n qs.timestamp = new Date().getTime();\n }\n var requestObject = {\n method: 'GET',\n service: service,\n resource: resource,\n qs: qs\n };\n if (token) {\n requestObject.headers = {\n authorization: token\n };\n }\n return this.webex.internal.newMetrics.callDiagnosticLatencies.measureLatency(function () {\n return _this7.request(requestObject);\n }, 'internal.get.u2c.time').then(function (_ref12) {\n var body = _ref12.body;\n return _this7._formatReceivedHostmap(body);\n });\n },\n /**\n * Initialize the discovery services and the whitelisted services.\n *\n * @returns {void}\n */\n initConfig: function initConfig() {\n // Get the catalog and destructure the services config.\n var catalog = this._getCatalog();\n var _this$webex$config = this.webex.config,\n services = _this$webex$config.services,\n fedramp = _this$webex$config.fedramp;\n\n // Validate that the services configuration exists.\n if (services) {\n if (fedramp) {\n services.discovery = _serviceFedRamp.default;\n }\n // Check for discovery services.\n if (services.discovery) {\n // Format the discovery configuration into an injectable array.\n var formattedDiscoveryServices = (0, _keys.default)(services.discovery).map(function (key) {\n return {\n name: key,\n defaultUrl: services.discovery[key]\n };\n });\n\n // Inject formatted discovery services into services catalog.\n catalog.updateServiceUrls('discovery', formattedDiscoveryServices);\n }\n if (services.override) {\n // Format the override configuration into an injectable array.\n var formattedOverrideServices = (0, _keys.default)(services.override).map(function (key) {\n return {\n name: key,\n defaultUrl: services.override[key]\n };\n });\n\n // Inject formatted override services into services catalog.\n catalog.updateServiceUrls('override', formattedOverrideServices);\n }\n\n // if not fedramp, append on the commercialAllowedDomains\n if (!fedramp) {\n services.allowedDomains = (0, _lodash.union)(services.allowedDomains, _constants.COMMERCIAL_ALLOWED_DOMAINS);\n }\n\n // Check for allowed host domains.\n if (services.allowedDomains) {\n // Store the allowed domains as a property of the catalog.\n catalog.setAllowedDomains(services.allowedDomains);\n }\n\n // Set `validateDomains` property to match configuration\n this.validateDomains = services.validateDomains;\n }\n },\n /**\n * Make the initial requests to collect the root catalogs.\n *\n * @returns {Promise<void, Error>} - Errors if the token is unavailable.\n */\n initServiceCatalogs: function initServiceCatalogs() {\n var _this8 = this;\n this.logger.info('services: initializing initial service catalogs');\n\n // Destructure the credentials plugin.\n var credentials = this.webex.credentials;\n\n // Init a promise chain. Must be done as a Promise.resolve() to allow\n // credentials#getOrgId() to properly throw.\n return _promise.default.resolve()\n // Get the user's OrgId.\n .then(function () {\n return credentials.getOrgId();\n })\n // Begin collecting the preauth/limited catalog.\n .then(function (orgId) {\n return _this8.collectPreauthCatalog({\n orgId: orgId\n });\n }).then(function () {\n // Validate if the token is authorized.\n if (credentials.canAuthorize) {\n // Attempt to collect the postauth catalog.\n return _this8.updateServices().catch(function () {\n _this8.initFailed = true;\n _this8.logger.warn('services: cannot retrieve postauth catalog');\n });\n }\n\n // Return a resolved promise for consistent return value.\n return _promise.default.resolve();\n });\n },\n /**\n * Initializer\n *\n * @instance\n * @memberof Services\n * @returns {Services}\n */\n initialize: function initialize() {\n var _this9 = this;\n var catalog = new _serviceCatalog.default();\n var registry = new _serviceRegistry.default();\n var state = new _serviceState.default();\n this._catalogs.set(this.webex, catalog);\n this.registries.set(this.webex, registry);\n this.states.set(this.webex, state);\n\n // Listen for configuration changes once.\n this.listenToOnce(this.webex, 'change:config', function () {\n _this9.initConfig();\n });\n\n // wait for webex instance to be ready before attempting\n // to update the service catalogs\n this.listenToOnce(this.webex, 'ready', function () {\n var supertoken = _this9.webex.credentials.supertoken;\n // Validate if the supertoken exists.\n if (supertoken && supertoken.access_token) {\n _this9.initServiceCatalogs().then(function () {\n catalog.isReady = true;\n }).catch(function (error) {\n _this9.initFailed = true;\n _this9.logger.error(\"services: failed to init initial services when credentials available, \".concat(error === null || error === void 0 ? void 0 : error.message));\n });\n } else {\n var email = _this9.webex.config.email;\n _this9.collectPreauthCatalog(email ? {\n email: email\n } : undefined).catch(function (error) {\n _this9.initFailed = true;\n _this9.logger.error(\"services: failed to init initial services when no credentials available, \".concat(error === null || error === void 0 ? void 0 : error.message));\n });\n }\n });\n },\n version: \"3.8.0-next.11\"\n});\n/* eslint-enable no-underscore-dangle */\nvar _default = exports[\"default\"] = Services;\n//# sourceMappingURL=services.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/lib/services/services.js?");
|
|
4472
|
+
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _Object$keys2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = exports.DEFAULT_CLUSTER_SERVICE = exports.DEFAULT_CLUSTER = void 0;\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/slicedToArray.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _weakMap = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/weak-map */ \"../../../node_modules/@babel/runtime-corejs2/core-js/weak-map.js\"));\nvar _keys = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _sha = _interopRequireDefault(__webpack_require__(/*! crypto-js/sha256 */ \"../../../node_modules/crypto-js/sha256.js\"));\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _webexPlugin = _interopRequireDefault(__webpack_require__(/*! ../webex-plugin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-plugin.js\"));\nvar _metrics = _interopRequireDefault(__webpack_require__(/*! ./metrics */ \"../../../node_modules/@webex/webex-core/dist/lib/services/metrics.js\"));\nvar _serviceCatalog = _interopRequireDefault(__webpack_require__(/*! ./service-catalog */ \"../../../node_modules/@webex/webex-core/dist/lib/services/service-catalog.js\"));\nvar _serviceRegistry = _interopRequireDefault(__webpack_require__(/*! ./service-registry */ \"../../../node_modules/@webex/webex-core/dist/lib/services/service-registry.js\"));\nvar _serviceState = _interopRequireDefault(__webpack_require__(/*! ./service-state */ \"../../../node_modules/@webex/webex-core/dist/lib/services/service-state.js\"));\nvar _serviceFedRamp = _interopRequireDefault(__webpack_require__(/*! ./service-fed-ramp */ \"../../../node_modules/@webex/webex-core/dist/lib/services/service-fed-ramp.js\"));\nvar _constants = __webpack_require__(/*! ./constants */ \"../../../node_modules/@webex/webex-core/dist/lib/services/constants.js\");\nfunction ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }\nvar trailingSlashes = /(?:^\\/)|(?:\\/$)/;\n\n// The default cluster when one is not provided (usually as 'US' from hydra)\nvar DEFAULT_CLUSTER = exports.DEFAULT_CLUSTER = 'urn:TEAM:us-east-2_a';\n// The default service name for convo (currently identityLookup due to some weird CSB issue)\nvar DEFAULT_CLUSTER_SERVICE = exports.DEFAULT_CLUSTER_SERVICE = 'identityLookup';\nvar CLUSTER_SERVICE = process.env.WEBEX_CONVERSATION_CLUSTER_SERVICE || DEFAULT_CLUSTER_SERVICE;\nvar DEFAULT_CLUSTER_IDENTIFIER = process.env.WEBEX_CONVERSATION_DEFAULT_CLUSTER || \"\".concat(DEFAULT_CLUSTER, \":\").concat(CLUSTER_SERVICE);\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nvar Services = _webexPlugin.default.extend({\n namespace: 'Services',\n /**\n * The {@link WeakMap} of {@link ServiceRegistry} class instances that are\n * keyed with WebexCore instances.\n *\n * @instance\n * @type {WeakMap<WebexCore, ServiceRegistry>}\n * @private\n * @memberof Services\n */\n registries: new _weakMap.default(),\n /**\n * The {@link WeakMap} of {@link ServiceState} class instances that are\n * keyed with WebexCore instances.\n *\n * @instance\n * @type {WeakMap<WebexCore, ServiceState>}\n * @private\n * @memberof Services\n */\n states: new _weakMap.default(),\n props: {\n validateDomains: ['boolean', false, true],\n initFailed: ['boolean', false, false]\n },\n _catalogs: new _weakMap.default(),\n _serviceUrls: null,\n _hostCatalog: null,\n /**\n * Get the registry associated with this webex instance.\n *\n * @private\n * @memberof Services\n * @returns {ServiceRegistry} - The associated {@link ServiceRegistry}.\n */\n getRegistry: function getRegistry() {\n return this.registries.get(this.webex);\n },\n /**\n * Get the state associated with this webex instance.\n *\n * @private\n * @memberof Services\n * @returns {ServiceState} - The associated {@link ServiceState}.\n */\n getState: function getState() {\n return this.states.get(this.webex);\n },\n /**\n * @private\n * Get the current catalog based on the assocaited\n * webex instance.\n * @returns {ServiceCatalog}\n */\n _getCatalog: function _getCatalog() {\n return this._catalogs.get(this.webex);\n },\n /**\n * Get a service url from the current services list by name\n * from the associated instance catalog.\n * @param {string} name\n * @param {boolean} [priorityHost]\n * @param {string} [serviceGroup]\n * @returns {string|undefined}\n */\n get: function get(name, priorityHost, serviceGroup) {\n var catalog = this._getCatalog();\n return catalog.get(name, priorityHost, serviceGroup);\n },\n /**\n * Determine if the catalog contains a specific service\n *\n * @param {string} serviceName - The service name to validate.\n * @returns {boolean} - True if the service exists.\n */\n hasService: function hasService(serviceName) {\n return !!this.get(serviceName);\n },\n /**\n * Determine if a whilelist exists in the service catalog.\n *\n * @returns {boolean} - True if a allowed domains list exists.\n */\n hasAllowedDomains: function hasAllowedDomains() {\n var catalog = this._getCatalog();\n return catalog.getAllowedDomains().length > 0;\n },\n /**\n * Generate a service catalog as an object from\n * the associated instance catalog.\n * @param {boolean} [priorityHost] - use highest priority host if set to `true`\n * @param {string} [serviceGroup]\n * @returns {Record<string, string>}\n */\n list: function list(priorityHost, serviceGroup) {\n var catalog = this._getCatalog();\n return catalog.list(priorityHost, serviceGroup);\n },\n /**\n * Mark a priority host service url as failed.\n * This will mark the host associated with the\n * `ServiceUrl` to be removed from the its\n * respective host array, and then return the next\n * viable host from the `ServiceUrls` host array,\n * or the `ServiceUrls` default url if no other priority\n * hosts are available, or if `noPriorityHosts` is set to\n * `true`.\n * @param {string} url\n * @param {boolean} noPriorityHosts\n * @returns {string}\n */\n markFailedUrl: function markFailedUrl(url, noPriorityHosts) {\n var catalog = this._getCatalog();\n return catalog.markFailedUrl(url, noPriorityHosts);\n },\n /**\n * saves all the services from the pre and post catalog service\n * @param {Object} serviceUrls\n * @returns {void}\n */\n _updateServiceUrls: function _updateServiceUrls(serviceUrls) {\n this._serviceUrls = _objectSpread(_objectSpread({}, this._serviceUrls), serviceUrls);\n },\n /**\n * saves the hostCatalog object\n * @param {Object} hostCatalog\n * @returns {void}\n */\n _updateHostCatalog: function _updateHostCatalog(hostCatalog) {\n this._hostCatalog = _objectSpread(_objectSpread({}, this._hostCatalog), hostCatalog);\n },\n /**\n * Update a list of `serviceUrls` to the most current\n * catalog via the defined `discoveryUrl` then returns the current\n * list of services.\n * @param {object} [param]\n * @param {string} [param.from] - This accepts `limited` or `signin`\n * @param {object} [param.query] - This accepts `email`, `orgId` or `userId` key values\n * @param {string} [param.query.email] - must be a standard-format email\n * @param {string} [param.query.orgId] - must be an organization id\n * @param {string} [param.query.userId] - must be a user id\n * @param {string} [param.token] - used for signin catalog\n * @returns {Promise<object>}\n */\n updateServices: function updateServices() {\n var _this = this;\n var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n from = _ref.from,\n query = _ref.query,\n token = _ref.token,\n forceRefresh = _ref.forceRefresh;\n var catalog = this._getCatalog();\n var formattedQuery;\n var serviceGroup;\n\n // map catalog name to service group name.\n switch (from) {\n case 'limited':\n serviceGroup = 'preauth';\n break;\n case 'signin':\n serviceGroup = 'signin';\n break;\n default:\n serviceGroup = 'postauth';\n break;\n }\n\n // confirm catalog update for group is not in progress.\n if (catalog.status[serviceGroup].collecting) {\n return this.waitForCatalog(serviceGroup);\n }\n catalog.status[serviceGroup].collecting = true;\n if (serviceGroup === 'preauth') {\n var queryKey = query && (0, _keys.default)(query)[0];\n if (!['email', 'emailhash', 'userId', 'orgId', 'mode'].includes(queryKey)) {\n return _promise.default.reject(new Error('a query param of email, emailhash, userId, orgId, or mode is required'));\n }\n }\n // encode email when query key is email\n if (serviceGroup === 'preauth' || serviceGroup === 'signin') {\n var _queryKey = (0, _keys.default)(query)[0];\n formattedQuery = {};\n if (_queryKey === 'email' && query.email) {\n formattedQuery.emailhash = (0, _sha.default)(query.email.toLowerCase()).toString();\n } else {\n formattedQuery[_queryKey] = query[_queryKey];\n }\n }\n return this._fetchNewServiceHostmap({\n from: from,\n token: token,\n query: formattedQuery,\n forceRefresh: forceRefresh\n }).then(function (serviceHostMap) {\n catalog.updateServiceUrls(serviceGroup, serviceHostMap);\n _this.updateCredentialsConfig();\n catalog.status[serviceGroup].collecting = false;\n }).catch(function (error) {\n catalog.status[serviceGroup].collecting = false;\n return _promise.default.reject(error);\n });\n },\n /**\n * User validation parameter transfer object for {@link validateUser}.\n * @param {object} ValidateUserPTO\n * @property {string} ValidateUserPTO.email - The email of the user.\n * @property {string} [ValidateUserPTO.reqId] - The activation requester.\n * @property {object} [ValidateUserPTO.activationOptions] - Extra options to pass when sending the activation\n * @property {object} [ValidateUserPTO.preloginUserId] - The prelogin user id to set when sending the activation.\n */\n /**\n * User validation return transfer object for {@link validateUser}.\n * @param {object} ValidateUserRTO\n * @property {boolean} ValidateUserRTO.activated - If the user is activated.\n * @property {boolean} ValidateUserRTO.exists - If the user exists.\n * @property {string} ValidateUserRTO.details - A descriptive status message.\n * @property {object} ValidateUserRTO.user - **License** service user object.\n */\n /**\n * Validate if a user is activated and update the service catalogs as needed\n * based on the user's activation status.\n *\n * @param {ValidateUserPTO} - The parameter transfer object.\n * @returns {ValidateUserRTO} - The return transfer object.\n */\n validateUser: function validateUser(_ref2) {\n var _this2 = this;\n var email = _ref2.email,\n _ref2$reqId = _ref2.reqId,\n reqId = _ref2$reqId === void 0 ? 'WEBCLIENT' : _ref2$reqId,\n _ref2$forceRefresh = _ref2.forceRefresh,\n forceRefresh = _ref2$forceRefresh === void 0 ? false : _ref2$forceRefresh,\n _ref2$activationOptio = _ref2.activationOptions,\n activationOptions = _ref2$activationOptio === void 0 ? {} : _ref2$activationOptio,\n preloginUserId = _ref2.preloginUserId;\n this.logger.info('services: validating a user');\n\n // Validate that an email parameter key was provided.\n if (!email) {\n return _promise.default.reject(new Error('`email` is required'));\n }\n\n // Destructure the credentials object.\n var canAuthorize = this.webex.credentials.canAuthorize;\n\n // Validate that the user is already authorized.\n if (canAuthorize) {\n return this.updateServices({\n forceRefresh: forceRefresh\n }).then(function () {\n return _this2.webex.credentials.getUserToken();\n }).then(function (token) {\n return _this2.sendUserActivation({\n email: email,\n reqId: reqId,\n token: token.toString(),\n activationOptions: activationOptions,\n preloginUserId: preloginUserId\n });\n }).then(function (userObj) {\n return {\n activated: true,\n exists: true,\n details: 'user is authorized via a user token',\n user: userObj\n };\n });\n }\n\n // Destructure the client authorization details.\n /* eslint-disable camelcase */\n var _this$webex$credentia = this.webex.credentials.config,\n client_id = _this$webex$credentia.client_id,\n client_secret = _this$webex$credentia.client_secret;\n\n // Validate that client authentication details exist.\n if (!client_id || !client_secret) {\n return _promise.default.reject(new Error('client authentication details are not available'));\n }\n /* eslint-enable camelcase */\n\n // Declare a class-memeber-scoped token for usage within the promise chain.\n var token;\n\n // Begin client authentication user validation.\n return this.collectPreauthCatalog({\n email: email\n }).then(function () {\n // Retrieve the service url from the updated catalog. This is required\n // since `WebexCore` is usually not fully initialized at the time this\n // request completes.\n var idbrokerService = _this2.get('idbroker', true);\n\n // Collect the client auth token.\n return _this2.webex.credentials.getClientToken({\n uri: \"\".concat(idbrokerService, \"idb/oauth2/v1/access_token\"),\n scope: 'webexsquare:admin webexsquare:get_conversation Identity:SCIM'\n });\n }).then(function (tokenObj) {\n // Generate the token string.\n token = tokenObj.toString();\n\n // Collect the signin catalog using the client auth information.\n return _this2.collectSigninCatalog({\n email: email,\n token: token,\n forceRefresh: forceRefresh\n });\n })\n // Validate if collecting the signin catalog failed and populate the RTO\n // with the appropriate content.\n .catch(function (error) {\n return {\n exists: error.name !== 'NotFound',\n activated: false,\n details: error.name !== 'NotFound' ? 'user exists but is not activated' : 'user does not exist and is not activated'\n };\n })\n // Validate if the previous promise resolved with an RTO and populate the\n // new RTO accordingly.\n .then(function (rto) {\n return _promise.default.all([rto || {\n activated: true,\n exists: true,\n details: 'user exists and is activated'\n }, _this2.sendUserActivation({\n email: email,\n reqId: reqId,\n token: token,\n activationOptions: activationOptions,\n preloginUserId: preloginUserId\n })]);\n }).then(function (_ref3) {\n var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),\n rto = _ref4[0],\n user = _ref4[1];\n return _objectSpread(_objectSpread({}, rto), {}, {\n user: user\n });\n }).catch(function (error) {\n var response = {\n statusCode: error.statusCode,\n responseText: error.body && error.body.message,\n body: error.body\n };\n return _promise.default.reject(response);\n });\n },\n /**\n * Get user meeting preferences (preferred webex site).\n *\n * @returns {object} - User Information including user preferrences .\n */\n getMeetingPreferences: function getMeetingPreferences() {\n var _this3 = this;\n return this.request({\n method: 'GET',\n service: 'hydra',\n resource: 'meetingPreferences'\n }).then(function (res) {\n _this3.logger.info('services: received user region info');\n return res.body;\n }).catch(function (err) {\n _this3.logger.info('services: was not able to fetch user login information', err);\n // resolve successfully even if request failed\n });\n },\n /**\n * Fetches client region info such as countryCode and timezone.\n *\n * @returns {object} - The region info object.\n */\n fetchClientRegionInfo: function fetchClientRegionInfo() {\n var _this4 = this;\n var services = this.webex.config.services;\n return this.request({\n uri: services.discovery.sqdiscovery,\n addAuthHeader: false,\n headers: {\n 'spark-user-agent': null\n },\n timeout: 5000\n }).then(function (res) {\n _this4.logger.info('services: received user region info');\n return res.body;\n }).catch(function (err) {\n _this4.logger.info('services: was not able to get user region info', err);\n // resolve successfully even if request failed\n });\n },\n /**\n * User activation parameter transfer object for {@link sendUserActivation}.\n * @typedef {object} SendUserActivationPTO\n * @property {string} SendUserActivationPTO.email - The email of the user.\n * @property {string} SendUserActivationPTO.reqId - The activation requester.\n * @property {string} SendUserActivationPTO.token - The client auth token.\n * @property {object} SendUserActivationPTO.activationOptions - Extra options to pass when sending the activation.\n * @property {object} SendUserActivationPTO.preloginUserId - The prelogin user id to set when sending the activation.\n */\n /**\n * Send a request to activate a user using a client token.\n *\n * @param {SendUserActivationPTO} - The Parameter transfer object.\n * @returns {LicenseDTO} - The DTO returned from the **License** service.\n */\n sendUserActivation: function sendUserActivation(_ref5) {\n var _this5 = this;\n var email = _ref5.email,\n reqId = _ref5.reqId,\n token = _ref5.token,\n activationOptions = _ref5.activationOptions,\n preloginUserId = _ref5.preloginUserId;\n this.logger.info('services: sending user activation request');\n var countryCode;\n var timezone;\n\n // try to fetch client region info first\n return this.fetchClientRegionInfo().then(function (clientRegionInfo) {\n if (clientRegionInfo) {\n countryCode = clientRegionInfo.countryCode;\n timezone = clientRegionInfo.timezone;\n }\n\n // Send the user activation request to the **License** service.\n return _this5.request({\n service: 'license',\n resource: 'users/activations',\n method: 'POST',\n headers: {\n accept: 'application/json',\n authorization: token,\n 'x-prelogin-userid': preloginUserId\n },\n body: _objectSpread({\n email: email,\n reqId: reqId,\n countryCode: countryCode,\n timeZone: timezone\n }, activationOptions),\n shouldRefreshAccessToken: false\n });\n })\n // On success, return the **License** user object.\n .then(function (_ref6) {\n var body = _ref6.body;\n return body;\n })\n // On failure, reject with error from **License**.\n .catch(function (error) {\n return _promise.default.reject(error);\n });\n },\n /**\n * Updates a given service group i.e. preauth, signin, postauth with a new hostmap.\n * @param {string} serviceGroup - preauth, signin, postauth\n * @param {object} hostMap - The new hostmap to update the service group with.\n * @returns {Promise<void>}\n */\n updateCatalog: function updateCatalog(serviceGroup, hostMap) {\n var catalog = this._getCatalog();\n var serviceHostMap = this._formatReceivedHostmap(hostMap);\n return catalog.updateServiceUrls(serviceGroup, serviceHostMap);\n },\n /**\n * simplified method to update the preauth catalog via email\n *\n * @param {object} query\n * @param {string} query.email - A standard format email.\n * @param {string} query.orgId - The user's OrgId.\n * @param {boolean} forceRefresh - Boolean to bypass u2c cache control header\n * @returns {Promise<void>}\n */\n collectPreauthCatalog: function collectPreauthCatalog(query) {\n var forceRefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n if (!query) {\n return this.updateServices({\n from: 'limited',\n query: {\n mode: 'DEFAULT_BY_PROXIMITY'\n },\n forceRefresh: forceRefresh\n });\n }\n return this.updateServices({\n from: 'limited',\n query: query,\n forceRefresh: forceRefresh\n });\n },\n /**\n * simplified method to update the signin catalog via email and token\n * @param {object} param\n * @param {string} param.email - must be a standard-format email\n * @param {string} param.token - must be a client token\n * @returns {Promise<void>}\n */\n collectSigninCatalog: function collectSigninCatalog() {\n var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n email = _ref7.email,\n token = _ref7.token,\n forceRefresh = _ref7.forceRefresh;\n if (!email) {\n return _promise.default.reject(new Error('`email` is required'));\n }\n if (!token) {\n return _promise.default.reject(new Error('`token` is required'));\n }\n return this.updateServices({\n from: 'signin',\n query: {\n email: email\n },\n token: token,\n forceRefresh: forceRefresh\n });\n },\n /**\n * Updates credentials config to utilize u2c catalog\n * urls.\n * @returns {void}\n */\n updateCredentialsConfig: function updateCredentialsConfig() {\n var _this$list = this.list(true),\n idbroker = _this$list.idbroker,\n identity = _this$list.identity;\n if (idbroker && identity) {\n var _this$webex$config$cr = this.webex.config.credentials,\n authorizationString = _this$webex$config$cr.authorizationString,\n authorizeUrl = _this$webex$config$cr.authorizeUrl;\n\n // This must be set outside of the setConfig method used to assign the\n // idbroker and identity url values.\n this.webex.config.credentials.authorizeUrl = authorizationString ? authorizeUrl : \"\".concat(idbroker.replace(trailingSlashes, ''), \"/idb/oauth2/v1/authorize\");\n this.webex.setConfig({\n credentials: {\n idbroker: {\n url: idbroker.replace(trailingSlashes, '') // remove trailing slash\n },\n\n identity: {\n url: identity.replace(trailingSlashes, '') // remove trailing slash\n }\n }\n });\n }\n },\n /**\n * Wait until the service catalog is available,\n * or reject afte ra timeout of 60 seconds.\n * @param {string} serviceGroup\n * @param {number} [timeout] - in seconds\n * @returns {Promise<void>}\n */\n waitForCatalog: function waitForCatalog(serviceGroup, timeout) {\n var catalog = this._getCatalog();\n var supertoken = this.webex.credentials.supertoken;\n if (serviceGroup === 'postauth' && supertoken && supertoken.access_token && !catalog.status.postauth.collecting && !catalog.status.postauth.ready) {\n if (!catalog.status.preauth.ready) {\n return this.initServiceCatalogs();\n }\n return this.updateServices();\n }\n return catalog.waitForCatalog(serviceGroup, timeout);\n },\n /**\n * Service waiting parameter transfer object for {@link waitForService}.\n *\n * @typedef {object} WaitForServicePTO\n * @property {string} [WaitForServicePTO.name] - The service name.\n * @property {string} [WaitForServicePTO.url] - The service url.\n * @property {string} [WaitForServicePTO.timeout] - wait duration in seconds.\n */\n /**\n * Wait until the service has been ammended to any service catalog. This\n * method prioritizes the service name over the service url when searching.\n *\n * @param {WaitForServicePTO} - The parameter transfer object.\n * @returns {Promise<string>} - Resolves to the priority host of a service.\n */\n waitForService: function waitForService(_ref8) {\n var _this6 = this;\n var name = _ref8.name,\n _ref8$timeout = _ref8.timeout,\n timeout = _ref8$timeout === void 0 ? 5 : _ref8$timeout,\n url = _ref8.url;\n var services = this.webex.config.services;\n\n // Save memory by grabbing the catalog after there isn't a priortyURL\n var catalog = this._getCatalog();\n var fetchFromServiceUrl = services.servicesNotNeedValidation.find(function (service) {\n return service === name;\n });\n if (fetchFromServiceUrl) {\n return _promise.default.resolve(this._serviceUrls[name]);\n }\n var priorityUrl = this.get(name, true);\n var priorityUrlObj = this.getServiceFromUrl(url);\n if (priorityUrl || priorityUrlObj) {\n return _promise.default.resolve(priorityUrl || priorityUrlObj.priorityUrl);\n }\n if (catalog.isReady) {\n if (url) {\n return _promise.default.resolve(url);\n }\n this.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_SERVICE_NOT_FOUND, {\n fields: {\n service_name: name\n }\n });\n return _promise.default.reject(new Error(\"services: service '\".concat(name, \"' was not found in any of the catalogs\")));\n }\n return new _promise.default(function (resolve, reject) {\n var groupsToCheck = ['preauth', 'signin', 'postauth'];\n var checkCatalog = function checkCatalog(catalogGroup) {\n return catalog.waitForCatalog(catalogGroup, timeout).then(function () {\n var scopedPriorityUrl = _this6.get(name, true);\n var scopedPrioriryUrlObj = _this6.getServiceFromUrl(url);\n if (scopedPriorityUrl || scopedPrioriryUrlObj) {\n resolve(scopedPriorityUrl || scopedPrioriryUrlObj.priorityUrl);\n }\n }).catch(function () {\n return undefined;\n });\n };\n _promise.default.all(groupsToCheck.map(function (group) {\n return checkCatalog(group);\n })).then(function () {\n _this6.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_SERVICE_NOT_FOUND, {\n fields: {\n service_name: name\n }\n });\n reject(new Error(\"services: service '\".concat(name, \"' was not found after waiting\")));\n });\n });\n },\n /**\n * Looks up the hostname in the host catalog\n * and replaces it with the first host if it finds it\n * @param {string} uri\n * @returns {string} uri with the host replaced\n */\n replaceHostFromHostmap: function replaceHostFromHostmap(uri) {\n var url = new URL(uri);\n var hostCatalog = this._hostCatalog;\n if (!hostCatalog) {\n return uri;\n }\n var host = hostCatalog[url.host];\n if (host && host[0]) {\n var newHost = host[0].host;\n url.host = newHost;\n return url.toString();\n }\n return uri;\n },\n /**\n * @private\n * Organize a received hostmap from a service\n * catalog endpoint.\n * @param {object} serviceHostmap\n * @returns {object}\n */\n _formatReceivedHostmap: function _formatReceivedHostmap(serviceHostmap) {\n this._updateHostCatalog(serviceHostmap.hostCatalog);\n var extractId = function extractId(entry) {\n return entry.id.split(':')[3];\n };\n var formattedHostmap = [];\n\n // for each of the services in the serviceLinks, find the matching host in the catalog\n (0, _keys.default)(serviceHostmap.serviceLinks).forEach(function (serviceName) {\n var _formattedHost$hosts;\n var serviceUrl = serviceHostmap.serviceLinks[serviceName];\n var host;\n try {\n host = new URL(serviceUrl).host;\n } catch (e) {\n return;\n }\n var matchingCatalogEntry = serviceHostmap.hostCatalog[host];\n var formattedHost = {\n name: serviceName,\n defaultUrl: serviceUrl,\n defaultHost: host,\n hosts: []\n };\n formattedHostmap.push(formattedHost);\n\n // If the catalog does not have any hosts we will be unable to find the service ID\n // so can't search for other hosts\n if (!matchingCatalogEntry || !matchingCatalogEntry[0]) {\n return;\n }\n var serviceId = extractId(matchingCatalogEntry[0]);\n (0, _lodash.forEach)(matchingCatalogEntry, function (entry) {\n // The ids for all hosts within a hostCatalog entry should be the same\n // but for safety, only add host entries that have the same id as the first one\n if (extractId(entry) === serviceId) {\n formattedHost.hosts.push(_objectSpread(_objectSpread({}, entry), {}, {\n homeCluster: true\n }));\n }\n });\n var otherHosts = [];\n\n // find the services in the host catalog that have the same id\n // and add them to the otherHosts\n (0, _lodash.forEach)(serviceHostmap.hostCatalog, function (entry) {\n // exclude the matching catalog entry as we have already added that\n if (entry === matchingCatalogEntry) {\n return;\n }\n (0, _lodash.forEach)(entry, function (entryHost) {\n // only add hosts that have the correct id\n if (extractId(entryHost) === serviceId) {\n otherHosts.push(_objectSpread(_objectSpread({}, entryHost), {}, {\n homeCluster: false\n }));\n }\n });\n });\n (_formattedHost$hosts = formattedHost.hosts).push.apply(_formattedHost$hosts, otherHosts);\n });\n\n // update all the service urls in the host catalog\n\n this._updateServiceUrls(serviceHostmap.serviceLinks);\n this._updateHostCatalog(serviceHostmap.hostCatalog);\n return formattedHostmap;\n },\n /**\n * Get the clusterId associated with a URL string.\n * @param {string} url\n * @returns {string} - Cluster ID of url provided\n */\n getClusterId: function getClusterId(url) {\n var catalog = this._getCatalog();\n return catalog.findClusterId(url);\n },\n /**\n * Get a service value from a provided clusterId. This method will\n * return an object containing both the name and url of a found service.\n * @param {object} params\n * @param {string} params.clusterId - clusterId of found service\n * @param {boolean} [params.priorityHost] - returns priority host url if true\n * @param {string} [params.serviceGroup] - specify service group\n * @returns {object} service\n * @returns {string} service.name\n * @returns {string} service.url\n */\n getServiceFromClusterId: function getServiceFromClusterId(params) {\n var catalog = this._getCatalog();\n return catalog.findServiceFromClusterId(params);\n },\n /**\n * @param {String} cluster the cluster containing the id\n * @param {UUID} [id] the id of the conversation.\n * If empty, just return the base URL.\n * @returns {String} url of the service\n */\n getServiceUrlFromClusterId: function getServiceUrlFromClusterId() {\n var _ref9 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref9$cluster = _ref9.cluster,\n cluster = _ref9$cluster === void 0 ? 'us' : _ref9$cluster;\n var clusterId = cluster === 'us' ? DEFAULT_CLUSTER_IDENTIFIER : cluster;\n\n // Determine if cluster has service name (non-US clusters from hydra do not)\n if (clusterId.split(':').length < 4) {\n // Add Service to cluster identifier\n clusterId = \"\".concat(cluster, \":\").concat(CLUSTER_SERVICE);\n }\n var _ref10 = this.getServiceFromClusterId({\n clusterId: clusterId\n }) || {},\n url = _ref10.url;\n if (!url) {\n throw Error(\"Could not find service for cluster [\".concat(cluster, \"]\"));\n }\n return url;\n },\n /**\n * Get a service object from a service url if the service url exists in the\n * catalog.\n *\n * @param {string} url - The url to be validated.\n * @returns {object} - Service object.\n * @returns {object.name} - The name of the service found.\n * @returns {object.priorityUrl} - The priority url of the found service.\n * @returns {object.defaultUrl} - The default url of the found service.\n */\n getServiceFromUrl: function getServiceFromUrl() {\n var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n var service = this._getCatalog().findServiceUrlFromUrl(url);\n if (!service) {\n return undefined;\n }\n return {\n name: service.name,\n priorityUrl: service.get(true),\n defaultUrl: service.get()\n };\n },\n /**\n * Verify that a provided url exists in the service\n * catalog.\n * @param {string} url\n * @returns {boolean} - true if exists, false otherwise\n */\n isServiceUrl: function isServiceUrl(url) {\n var catalog = this._getCatalog();\n return !!catalog.findServiceUrlFromUrl(url);\n },\n /**\n * Determine if a provided url is in the catalog's allowed domains.\n *\n * @param {string} url - The url to match allowed domains against.\n * @returns {boolean} - True if the url provided is allowed.\n */\n isAllowedDomainUrl: function isAllowedDomainUrl(url) {\n var catalog = this._getCatalog();\n return !!catalog.findAllowedDomain(url);\n },\n /**\n * Converts the host portion of the url from default host\n * to a priority host\n *\n * @param {string} url a service url that contains a default host\n * @returns {string} a service url that contains the top priority host.\n * @throws if url isn't a service url\n */\n convertUrlToPriorityHostUrl: function convertUrlToPriorityHostUrl() {\n var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n var data = this.getServiceFromUrl(url);\n if (!data) {\n throw Error(\"No service associated with url: [\".concat(url, \"]\"));\n }\n return url.replace(data.defaultUrl, data.priorityUrl);\n },\n /**\n * @private\n * Simplified method wrapper for sending a request to get\n * an updated service hostmap.\n * @param {object} [param]\n * @param {string} [param.from] - This accepts `limited` or `signin`\n * @param {object} [param.query] - This accepts `email`, `orgId` or `userId` key values\n * @param {string} [param.query.email] - must be a standard-format email\n * @param {string} [param.query.orgId] - must be an organization id\n * @param {string} [param.query.userId] - must be a user id\n * @param {string} [param.token] - used for signin catalog\n * @returns {Promise<object>}\n */\n _fetchNewServiceHostmap: function _fetchNewServiceHostmap() {\n var _this7 = this;\n var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n from = _ref11.from,\n query = _ref11.query,\n token = _ref11.token,\n forceRefresh = _ref11.forceRefresh;\n var service = 'u2c';\n var resource = from ? \"/\".concat(from, \"/catalog\") : '/catalog';\n var qs = _objectSpread(_objectSpread({}, query), {}, {\n format: 'hostmap'\n });\n if (forceRefresh) {\n qs.timestamp = new Date().getTime();\n }\n var requestObject = {\n method: 'GET',\n service: service,\n resource: resource,\n qs: qs\n };\n if (token) {\n requestObject.headers = {\n authorization: token\n };\n }\n return this.webex.internal.newMetrics.callDiagnosticLatencies.measureLatency(function () {\n return _this7.request(requestObject);\n }, 'internal.get.u2c.time').then(function (_ref12) {\n var body = _ref12.body;\n return _this7._formatReceivedHostmap(body);\n });\n },\n /**\n * Initialize the discovery services and the whitelisted services.\n *\n * @returns {void}\n */\n initConfig: function initConfig() {\n // Get the catalog and destructure the services config.\n var catalog = this._getCatalog();\n var _this$webex$config = this.webex.config,\n services = _this$webex$config.services,\n fedramp = _this$webex$config.fedramp;\n\n // Validate that the services configuration exists.\n if (services) {\n if (fedramp) {\n services.discovery = _serviceFedRamp.default;\n }\n // Check for discovery services.\n if (services.discovery) {\n // Format the discovery configuration into an injectable array.\n var formattedDiscoveryServices = (0, _keys.default)(services.discovery).map(function (key) {\n return {\n name: key,\n defaultUrl: services.discovery[key]\n };\n });\n\n // Inject formatted discovery services into services catalog.\n catalog.updateServiceUrls('discovery', formattedDiscoveryServices);\n }\n if (services.override) {\n // Format the override configuration into an injectable array.\n var formattedOverrideServices = (0, _keys.default)(services.override).map(function (key) {\n return {\n name: key,\n defaultUrl: services.override[key]\n };\n });\n\n // Inject formatted override services into services catalog.\n catalog.updateServiceUrls('override', formattedOverrideServices);\n }\n\n // if not fedramp, append on the commercialAllowedDomains\n if (!fedramp) {\n services.allowedDomains = (0, _lodash.union)(services.allowedDomains, _constants.COMMERCIAL_ALLOWED_DOMAINS);\n }\n\n // Check for allowed host domains.\n if (services.allowedDomains) {\n // Store the allowed domains as a property of the catalog.\n catalog.setAllowedDomains(services.allowedDomains);\n }\n\n // Set `validateDomains` property to match configuration\n this.validateDomains = services.validateDomains;\n }\n },\n /**\n * Make the initial requests to collect the root catalogs.\n *\n * @returns {Promise<void, Error>} - Errors if the token is unavailable.\n */\n initServiceCatalogs: function initServiceCatalogs() {\n var _this8 = this;\n this.logger.info('services: initializing initial service catalogs');\n\n // Destructure the credentials plugin.\n var credentials = this.webex.credentials;\n\n // Init a promise chain. Must be done as a Promise.resolve() to allow\n // credentials#getOrgId() to properly throw.\n return _promise.default.resolve()\n // Get the user's OrgId.\n .then(function () {\n return credentials.getOrgId();\n })\n // Begin collecting the preauth/limited catalog.\n .then(function (orgId) {\n return _this8.collectPreauthCatalog({\n orgId: orgId\n });\n }).then(function () {\n // Validate if the token is authorized.\n if (credentials.canAuthorize) {\n // Attempt to collect the postauth catalog.\n return _this8.updateServices().catch(function () {\n _this8.initFailed = true;\n _this8.logger.warn('services: cannot retrieve postauth catalog');\n });\n }\n\n // Return a resolved promise for consistent return value.\n return _promise.default.resolve();\n });\n },\n /**\n * Initializer\n *\n * @instance\n * @memberof Services\n * @returns {Services}\n */\n initialize: function initialize() {\n var _this9 = this;\n var catalog = new _serviceCatalog.default();\n var registry = new _serviceRegistry.default();\n var state = new _serviceState.default();\n this._catalogs.set(this.webex, catalog);\n this.registries.set(this.webex, registry);\n this.states.set(this.webex, state);\n\n // Listen for configuration changes once.\n this.listenToOnce(this.webex, 'change:config', function () {\n _this9.initConfig();\n });\n\n // wait for webex instance to be ready before attempting\n // to update the service catalogs\n this.listenToOnce(this.webex, 'ready', function () {\n var supertoken = _this9.webex.credentials.supertoken;\n // Validate if the supertoken exists.\n if (supertoken && supertoken.access_token) {\n _this9.initServiceCatalogs().then(function () {\n catalog.isReady = true;\n }).catch(function (error) {\n _this9.initFailed = true;\n _this9.logger.error(\"services: failed to init initial services when credentials available, \".concat(error === null || error === void 0 ? void 0 : error.message));\n });\n } else {\n var email = _this9.webex.config.email;\n _this9.collectPreauthCatalog(email ? {\n email: email\n } : undefined).catch(function (error) {\n _this9.initFailed = true;\n _this9.logger.error(\"services: failed to init initial services when no credentials available, \".concat(error === null || error === void 0 ? void 0 : error.message));\n });\n }\n });\n },\n version: \"3.8.0-next.12\"\n});\n/* eslint-enable no-underscore-dangle */\nvar _default = exports[\"default\"] = Services;\n//# sourceMappingURL=services.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/lib/services/services.js?");
|
|
4473
4473
|
|
|
4474
4474
|
/***/ }),
|
|
4475
4475
|
|
|
@@ -4601,7 +4601,7 @@ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-co
|
|
|
4601
4601
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4602
4602
|
|
|
4603
4603
|
"use strict";
|
|
4604
|
-
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _webexPlugin = _interopRequireDefault(__webpack_require__(/*! ../lib/webex-plugin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-plugin.js\"));\nvar _webexCore = __webpack_require__(/*! ../webex-core */ \"../../../node_modules/@webex/webex-core/dist/webex-core.js\");\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nvar precedence = {\n error: ['log'],\n warn: ['error', 'log'],\n info: ['log'],\n debug: ['info', 'log'],\n trace: ['debug', 'info', 'log']\n};\n\n/**\n * Assigns the specified console method to Logger; uses `precedence` to fallback\n * to other console methods if the current environment doesn't provide the\n * specified level.\n * @param {string} level\n * @returns {Function}\n */\nfunction wrapConsoleMethod(level) {\n /* eslint no-console: [0] */\n var impls = precedence[level];\n if (impls) {\n impls = impls.slice();\n while (!console[level]) {\n level = impls.pop();\n }\n }\n return function wrappedConsoleMethod() {\n var _console;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n /* eslint no-invalid-this: [0] */\n /* istanbul ignore if */\n if (false) {}\n (_console = console)[level].apply(_console, args);\n };\n}\nvar Logger = _webexPlugin.default.extend({\n namespace: 'Logger',\n error: wrapConsoleMethod('error'),\n warn: wrapConsoleMethod('warn'),\n log: wrapConsoleMethod('log'),\n info: wrapConsoleMethod('info'),\n debug: wrapConsoleMethod('debug'),\n trace: wrapConsoleMethod('trace'),\n version: \"3.8.0-next.
|
|
4604
|
+
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _webexPlugin = _interopRequireDefault(__webpack_require__(/*! ../lib/webex-plugin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-plugin.js\"));\nvar _webexCore = __webpack_require__(/*! ../webex-core */ \"../../../node_modules/@webex/webex-core/dist/webex-core.js\");\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nvar precedence = {\n error: ['log'],\n warn: ['error', 'log'],\n info: ['log'],\n debug: ['info', 'log'],\n trace: ['debug', 'info', 'log']\n};\n\n/**\n * Assigns the specified console method to Logger; uses `precedence` to fallback\n * to other console methods if the current environment doesn't provide the\n * specified level.\n * @param {string} level\n * @returns {Function}\n */\nfunction wrapConsoleMethod(level) {\n /* eslint no-console: [0] */\n var impls = precedence[level];\n if (impls) {\n impls = impls.slice();\n while (!console[level]) {\n level = impls.pop();\n }\n }\n return function wrappedConsoleMethod() {\n var _console;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n /* eslint no-invalid-this: [0] */\n /* istanbul ignore if */\n if (false) {}\n (_console = console)[level].apply(_console, args);\n };\n}\nvar Logger = _webexPlugin.default.extend({\n namespace: 'Logger',\n error: wrapConsoleMethod('error'),\n warn: wrapConsoleMethod('warn'),\n log: wrapConsoleMethod('log'),\n info: wrapConsoleMethod('info'),\n debug: wrapConsoleMethod('debug'),\n trace: wrapConsoleMethod('trace'),\n version: \"3.8.0-next.12\"\n});\n(0, _webexCore.registerPlugin)('logger', Logger);\nvar _default = exports[\"default\"] = Logger;\n//# sourceMappingURL=logger.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/plugins/logger.js?");
|
|
4605
4605
|
|
|
4606
4606
|
/***/ }),
|
|
4607
4607
|
|
|
@@ -4612,7 +4612,7 @@ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-co
|
|
|
4612
4612
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4613
4613
|
|
|
4614
4614
|
"use strict";
|
|
4615
|
-
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _Object$keys2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nexports.registerInternalPlugin = registerInternalPlugin;\nexports.registerPlugin = registerPlugin;\nvar _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/regenerator */ \"../../../node_modules/@babel/runtime-corejs2/regenerator/index.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _keys = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _assign = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/assign */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/assign.js\"));\nvar _stringify = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/json/stringify */ \"../../../node_modules/@babel/runtime-corejs2/core-js/json/stringify.js\"));\nvar _deleteProperty = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/delete-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/delete-property.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _events = __webpack_require__(/*! events */ \"../../../node_modules/events/events.js\");\nvar _util = _interopRequireDefault(__webpack_require__(/*! util */ \"../../../node_modules/util/util.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common/dist/index.js\");\nvar _httpCore = __webpack_require__(/*! @webex/http-core */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/http-core/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _ampersandState = _interopRequireDefault(__webpack_require__(/*! ampersand-state */ \"../../../node_modules/ampersand-state/ampersand-state.js\"));\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! uuid */ \"../../../node_modules/uuid/index.js\"));\nvar _auth = _interopRequireDefault(__webpack_require__(/*! ./interceptors/auth */ \"../../../node_modules/@webex/webex-core/dist/interceptors/auth.js\"));\nvar _networkTiming = _interopRequireDefault(__webpack_require__(/*! ./interceptors/network-timing */ \"../../../node_modules/@webex/webex-core/dist/interceptors/network-timing.js\"));\nvar _payloadTransformer = _interopRequireDefault(__webpack_require__(/*! ./interceptors/payload-transformer */ \"../../../node_modules/@webex/webex-core/dist/interceptors/payload-transformer.js\"));\nvar _redirect = _interopRequireDefault(__webpack_require__(/*! ./interceptors/redirect */ \"../../../node_modules/@webex/webex-core/dist/interceptors/redirect.js\"));\nvar _requestEvent = _interopRequireDefault(__webpack_require__(/*! ./interceptors/request-event */ \"../../../node_modules/@webex/webex-core/dist/interceptors/request-event.js\"));\nvar _requestLogger = _interopRequireDefault(__webpack_require__(/*! ./interceptors/request-logger */ \"../../../node_modules/@webex/webex-core/dist/interceptors/request-logger.js\"));\nvar _requestTiming = _interopRequireDefault(__webpack_require__(/*! ./interceptors/request-timing */ \"../../../node_modules/@webex/webex-core/dist/interceptors/request-timing.js\"));\nvar _responseLogger = _interopRequireDefault(__webpack_require__(/*! ./interceptors/response-logger */ \"../../../node_modules/@webex/webex-core/dist/interceptors/response-logger.js\"));\nvar _webexHttpError = _interopRequireDefault(__webpack_require__(/*! ./lib/webex-http-error */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-http-error.js\"));\nvar _userAgent = _interopRequireDefault(__webpack_require__(/*! ./interceptors/user-agent */ \"../../../node_modules/@webex/webex-core/dist/interceptors/user-agent.js\"));\nvar _webexTrackingId = _interopRequireDefault(__webpack_require__(/*! ./interceptors/webex-tracking-id */ \"../../../node_modules/@webex/webex-core/dist/interceptors/webex-tracking-id.js\"));\nvar _webexUserAgent = _interopRequireDefault(__webpack_require__(/*! ./interceptors/webex-user-agent */ \"../../../node_modules/@webex/webex-core/dist/interceptors/webex-user-agent.js\"));\nvar _rateLimit = _interopRequireDefault(__webpack_require__(/*! ./interceptors/rate-limit */ \"../../../node_modules/@webex/webex-core/dist/interceptors/rate-limit.js\"));\nvar _embargo = _interopRequireDefault(__webpack_require__(/*! ./interceptors/embargo */ \"../../../node_modules/@webex/webex-core/dist/interceptors/embargo.js\"));\nvar _defaultOptions = _interopRequireDefault(__webpack_require__(/*! ./interceptors/default-options */ \"../../../node_modules/@webex/webex-core/dist/interceptors/default-options.js\"));\nvar _hostmap = _interopRequireDefault(__webpack_require__(/*! ./lib/services/interceptors/hostmap */ \"../../../node_modules/@webex/webex-core/dist/lib/services/interceptors/hostmap.js\"));\nvar _config = _interopRequireDefault(__webpack_require__(/*! ./config */ \"../../../node_modules/@webex/webex-core/dist/config.js\"));\nvar _storage = __webpack_require__(/*! ./lib/storage */ \"../../../node_modules/@webex/webex-core/dist/lib/storage/index.js\");\nvar _webexCorePluginMixin = _interopRequireDefault(__webpack_require__(/*! ./lib/webex-core-plugin-mixin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-core-plugin-mixin.js\"));\nvar _webexInternalCorePluginMixin = _interopRequireDefault(__webpack_require__(/*! ./lib/webex-internal-core-plugin-mixin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-internal-core-plugin-mixin.js\"));\nvar _webexInternalCore = _interopRequireDefault(__webpack_require__(/*! ./webex-internal-core */ \"../../../node_modules/@webex/webex-core/dist/webex-internal-core.js\"));\nvar _obj;\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nfunction ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\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)\nvar interceptors = {\n WebexTrackingIdInterceptor: _webexTrackingId.default.create,\n RequestEventInterceptor: _requestEvent.default.create,\n RateLimitInterceptor: _rateLimit.default.create,\n /* eslint-disable no-extra-parens */\n RequestLoggerInterceptor: process.env.ENABLE_NETWORK_LOGGING || process.env.ENABLE_VERBOSE_NETWORK_LOGGING ? _requestLogger.default.create : undefined,\n ResponseLoggerInterceptor: process.env.ENABLE_NETWORK_LOGGING || process.env.ENABLE_VERBOSE_NETWORK_LOGGING ? _responseLogger.default.create : undefined,\n /* eslint-enable no-extra-parens */\n RequestTimingInterceptor: _requestTiming.default.create,\n ServiceInterceptor: undefined,\n UserAgentInterceptor: _userAgent.default.create,\n WebexUserAgentInterceptor: _webexUserAgent.default.create,\n AuthInterceptor: _auth.default.create,\n KmsDryErrorInterceptor: undefined,\n PayloadTransformerInterceptor: _payloadTransformer.default.create,\n ConversationInterceptor: undefined,\n RedirectInterceptor: _redirect.default.create,\n HttpStatusInterceptor: function HttpStatusInterceptor() {\n return _httpCore.HttpStatusInterceptor.create({\n error: _webexHttpError.default\n });\n },\n NetworkTimingInterceptor: _networkTiming.default.create,\n EmbargoInterceptor: _embargo.default.create,\n DefaultOptionsInterceptor: _defaultOptions.default.create,\n HostMapInterceptor: _hostmap.default.create\n};\nvar preInterceptors = ['ResponseLoggerInterceptor', 'RequestTimingInterceptor', 'RequestEventInterceptor', 'WebexTrackingIdInterceptor', 'RateLimitInterceptor'];\nvar postInterceptors = ['HttpStatusInterceptor', 'NetworkTimingInterceptor', 'EmbargoInterceptor', 'RequestLoggerInterceptor', 'RateLimitInterceptor'];\nvar MAX_FILE_SIZE_IN_MB = 2048;\n\n/**\n * @class\n */\nvar WebexCore = _ampersandState.default.extend((_obj = {\n version: \"3.8.0-next.11\",\n children: {\n internal: _webexInternalCore.default\n },\n constructor: function constructor() {\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var options = arguments.length > 1 ? arguments[1] : undefined;\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 ['credentials.authorization', 'authorization', 'credentials.supertoken.supertoken', 'supertoken', 'access_token', 'credentials.authorization.supertoken'].forEach(function (path) {\n var val = (0, _lodash.get)(attrs, path);\n if (val) {\n (0, _lodash.unset)(attrs, path);\n (0, _lodash.set)(attrs, 'credentials.supertoken', val);\n }\n });\n ['credentials', 'credentials.authorization'].forEach(function (path) {\n var val = (0, _lodash.get)(attrs, path);\n if (typeof val === 'string') {\n (0, _lodash.unset)(attrs, path);\n (0, _lodash.set)(attrs, 'credentials.supertoken', val);\n }\n });\n if (typeof (0, _lodash.get)(attrs, 'credentials.access_token') === 'string') {\n // Send access_token to get validated and corrected and then set it\n (0, _lodash.set)(attrs, 'credentials.access_token', this.bearerValidator((0, _lodash.get)(attrs, 'credentials.access_token').trim()));\n (0, _lodash.set)(attrs, 'credentials.supertoken', attrs.credentials);\n }\n }\n return (0, _apply.default)(_ampersandState.default, this, [attrs, options]);\n },\n derived: {\n boundedStorage: {\n deps: [],\n fn: function fn() {\n return (0, _storage.makeWebexStore)('bounded', this);\n }\n },\n unboundedStorage: {\n deps: [],\n fn: function fn() {\n return (0, _storage.makeWebexStore)('unbounded', this);\n }\n },\n ready: {\n deps: ['loaded', 'internal.ready'],\n fn: function fn() {\n var _this = this;\n return this.loaded && (0, _keys.default)(this._children).reduce(function (ready, name) {\n return ready && _this[name] && _this[name].ready !== false;\n }, true);\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 * @instance\n * @memberof WebexCore\n * @param {[type]} args\n * @returns {[type]}\n */\n refresh: function refresh() {\n var _this$credentials;\n return (_this$credentials = this.credentials).refresh.apply(_this$credentials, arguments);\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: function transform(direction, object) {\n var _this2 = this;\n var predicates = this.config.payloadTransformer.predicates.filter(function (p) {\n return !p.direction || p.direction === direction;\n });\n var ctx = {\n webex: this\n };\n return _promise.default.all(predicates.map(function (p) {\n return p.test(ctx, object).then(function (shouldTransform) {\n if (!shouldTransform) {\n return undefined;\n }\n return p.extract(object)\n // eslint-disable-next-line max-nested-callbacks\n .then(function (target) {\n return {\n name: p.name,\n target: target\n };\n });\n });\n })).then(function (data) {\n return data.filter(function (d) {\n return Boolean(d);\n })\n // eslint-disable-next-line max-nested-callbacks\n .reduce(function (promise, _ref) {\n var name = _ref.name,\n target = _ref.target,\n alias = _ref.alias;\n return promise.then(function () {\n if (alias) {\n return _this2.applyNamedTransform(direction, alias, target);\n }\n return _this2.applyNamedTransform(direction, name, target);\n });\n }, _promise.default.resolve());\n }).then(function () {\n return 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: function applyNamedTransform(direction, ctx, name) {\n var _this3 = this;\n for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {\n rest[_key - 3] = arguments[_key];\n }\n if ((0, _lodash.isString)(ctx)) {\n rest.unshift(name);\n name = ctx;\n ctx = {\n webex: this,\n transform: function transform() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return _this3.applyNamedTransform.apply(_this3, [direction, ctx].concat(args));\n }\n };\n }\n var transforms = ctx.webex.config.payloadTransformer.transforms.filter(function (tx) {\n return 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.reduce(function (promise, tx) {\n return promise.then(function () {\n if (tx.alias) {\n var _ctx;\n return (_ctx = ctx).transform.apply(_ctx, [tx.alias].concat(rest));\n }\n return _promise.default.resolve(tx.fn.apply(tx, [ctx].concat(rest)));\n });\n }, _promise.default.resolve()).then(function () {\n return (0, _lodash.last)(rest);\n });\n },\n /**\n * @private\n * @returns {Window}\n */\n getWindow: function getWindow() {\n // eslint-disable-next-line\n return window;\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: function initialize() {\n var _this4 = this;\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.config = (0, _lodash.merge)({}, _config.default, 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 var onLoaded = function onLoaded() {\n if (_this4.loaded) {\n /**\n * Fires when all data has been loaded from the storage layer\n * @event loaded\n * @instance\n * @memberof WebexCore\n */\n _this4.trigger('loaded');\n _this4.stopListening(_this4, '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(function () {\n _this4.listenToAndRun(_this4, 'change:loaded', onLoaded);\n });\n var onReady = function onReady() {\n if (_this4.ready) {\n /**\n * Fires when all plugins have fully initialized\n * @event ready\n * @instance\n * @memberof WebexCore\n */\n _this4.trigger('ready');\n _this4.stopListening(_this4, '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(function () {\n _this4.listenToAndRun(_this4, 'change:ready', onReady);\n });\n\n // Make nested events propagate in a consistent manner\n (0, _keys.default)(this.constructor.prototype._children).forEach(function (key) {\n _this4.listenTo(_this4[key], 'change', function () {\n for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n args.unshift(\"change:\".concat(key));\n _this4.trigger.apply(_this4, args);\n });\n });\n var addInterceptor = function addInterceptor(ints, key) {\n var interceptorsObj = _this4.config.interceptors || interceptors;\n var interceptor = interceptorsObj[key];\n if (!(0, _lodash.isFunction)(interceptor)) {\n return ints;\n }\n ints.push((0, _apply.default)(interceptor, _this4, []));\n return ints;\n };\n var ints = [];\n if (this.config.interceptors) {\n (0, _keys.default)(this.config.interceptors).reduce(addInterceptor, ints);\n } else {\n ints = preInterceptors.reduce(addInterceptor, ints);\n ints = (0, _keys.default)(interceptors).filter(function (key) {\n return !(preInterceptors.includes(key) || postInterceptors.includes(key));\n }).reduce(addInterceptor, ints);\n ints = postInterceptors.reduce(addInterceptor, ints);\n }\n this.request = (0, _httpCore.defaults)({\n json: true,\n interceptors: ints\n });\n this.prepareFetchOptions = (0, _httpCore.protoprepareFetchOptions)({\n json: true,\n interceptors: ints\n });\n this.setTimingsAndFetch = _httpCore.setTimingsAndFetch;\n var sessionId = \"\".concat((0, _lodash.get)(this, 'config.trackingIdPrefix', 'webex-js-sdk'), \"_\").concat((0, _lodash.get)(this, 'config.trackingIdBase', _uuid.default.v4()));\n if ((0, _lodash.get)(this, 'config.trackingIdSuffix')) {\n sessionId += \"_\".concat((0, _lodash.get)(this, 'config.trackingIdSuffix'));\n }\n this.sessionId = sessionId;\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: function setConfig() {\n var newConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.config = (0, _lodash.merge)({}, this.config, newConfig);\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: function bearerValidator(token) {\n if (token.includes('Bearer') && token.split(' ').length - 1 === 0) {\n console.warn(\"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\".concat(token.replace('Bearer', 'Bearer ').replace(/\\s+/g, ' ')));\n console.info(\"Tip: You don't need to add 'Bearer' to the access_token field. The token by itself is fine\");\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(\"Your access token has \".concat(token.split(' ').length - 2, \" too many spaces, please use this format:\\n\\n\").concat(token.replace(/\\s+/g, ' ')));\n console.info(\"Tip: You don't need to add 'Bearer' to the access_token field, the token by itself is fine\");\n return token.replace(/\\s+/g, ' ');\n }\n return token.replace(/\\s+/g, ' '); // Clean it anyway (just in case)\n },\n /**\n * @instance\n * @memberof WebexPlugin\n * @param {number} depth\n * @private\n * @returns {Object}\n */\n inspect: function inspect(depth) {\n return _util.default.inspect((0, _lodash.omit)(this.serialize({\n props: true,\n session: true,\n derived: true\n }), 'boundedStorage', 'unboundedStorage', 'request', 'config'), {\n depth: depth\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: function logout(options) {\n var _this5 = this;\n for (var _len4 = arguments.length, rest = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {\n rest[_key4 - 1] = arguments[_key4];\n }\n // prefer the refresh token, but for clients that don't have one, fallback\n // to the access token\n var token = this.credentials.supertoken && (this.credentials.supertoken.refresh_token || this.credentials.supertoken.access_token);\n options = (0, _assign.default)({\n token: token\n }, 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.reverse().reduce(function (promise, _ref2) {\n var plugin = _ref2.plugin,\n fn = _ref2.fn;\n return promise.then(function () {\n return _promise.default.resolve((0, _apply.default)(fn, _this5[plugin] || _this5.internal[plugin], [options].concat(rest)))\n // eslint-disable-next-line max-nested-callbacks\n .catch(function (err) {\n _this5.logger.warn(\"onBeforeLogout from plugin \".concat(plugin, \": failed\"), err);\n });\n });\n }, _promise.default.resolve()).then(function () {\n return _promise.default.all([_this5.boundedStorage.clear(), _this5.unboundedStorage.clear()]);\n }).then(function () {\n var _this5$credentials;\n return (_this5$credentials = _this5.credentials).invalidate.apply(_this5$credentials, rest);\n }).then(function () {\n var _this5$authorization;\n return _this5.authorization && _this5.authorization.logout && (_this5$authorization = _this5.authorization).logout.apply(_this5$authorization, [options].concat(rest));\n }).then(function () {\n return _this5.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: function measure() {\n if (this.metrics) {\n var _this$metrics;\n return (_this$metrics = this.metrics).sendUnstructured.apply(_this$metrics, arguments);\n }\n return _promise.default.resolve();\n },\n upload: function upload(options) {\n var _this6 = this;\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {\n var shunt, promise;\n return _regenerator.default.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n if (options.file) {\n _context.next = 2;\n break;\n }\n return _context.abrupt(\"return\", _promise.default.reject(new Error('`options.file` is required')));\n case 2:\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 (0, _lodash.defaultsDeep)(options.phases.initialize, {\n method: 'POST',\n body: {\n uploadProtocol: 'content-length'\n }\n }, (0, _lodash.omit)(options, 'file', 'phases'));\n (0, _lodash.defaultsDeep)(options.phases.upload, {\n method: 'PUT',\n json: false,\n withCredentials: false,\n body: options.file,\n headers: {\n 'x-trans-id': _uuid.default.v4(),\n authorization: undefined\n }\n });\n (0, _lodash.defaultsDeep)(options.phases.finalize, {\n method: 'POST'\n }, (0, _lodash.omit)(options, 'file', 'phases'));\n shunt = new _events.EventEmitter();\n promise = _this6._uploadPhaseInitialize(options).then(function () {\n var p = _this6._uploadPhaseUpload(options);\n (0, _common.transferEvents)('progress', p, shunt);\n return p;\n }).then(function () {\n for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n args[_key5] = arguments[_key5];\n }\n return _this6._uploadPhaseFinalize.apply(_this6, [options].concat(args));\n }).then(function (res) {\n return _objectSpread(_objectSpread({}, res.body), res.headers);\n });\n (0, _common.proxyEvents)(shunt, promise);\n return _context.abrupt(\"return\", promise);\n case 13:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }))();\n },\n _uploadPhaseInitialize: function _uploadPhaseInitialize(options) {\n var _this7 = this;\n this.logger.debug('client: initiating upload session');\n return this.request(options.phases.initialize).then(function () {\n for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n args[_key6] = arguments[_key6];\n }\n var fileUploadSizeLimitInBytes = (args[0].body.fileUploadSizeLimit || MAX_FILE_SIZE_IN_MB) * 1024 * 1024;\n var currentFileSizeInBytes = options.file.byteLength;\n if (fileUploadSizeLimitInBytes && fileUploadSizeLimitInBytes < currentFileSizeInBytes) {\n return _this7._uploadAbortSession.apply(_this7, [currentFileSizeInBytes].concat(args));\n }\n return _this7._uploadApplySession.apply(_this7, [options].concat(args));\n }).then(function (res) {\n _this7.logger.debug('client: initiated upload session');\n return res;\n });\n },\n _uploadAbortSession: function _uploadAbortSession(currentFileSizeInBytes, response) {\n var _this8 = this;\n this.logger.debug('client: deleting uploaded file');\n return this.request({\n method: 'DELETE',\n url: response.body.url,\n headers: response.options.headers\n }).then(function () {\n _this8.logger.debug('client: deleting uploaded file complete');\n var abortErrorDetails = {\n currentFileSizeInBytes: currentFileSizeInBytes,\n fileUploadSizeLimitInMB: response.body.fileUploadSizeLimit || MAX_FILE_SIZE_IN_MB,\n message: 'file-upload-size-limit-enabled'\n };\n return _promise.default.reject(new Error(\"\".concat((0, _stringify.default)(abortErrorDetails))));\n });\n },\n _uploadApplySession: function _uploadApplySession(options, res) {\n var session = res.body;\n ['upload', 'finalize'].reduce(function (opts, key) {\n opts[key] = (0, _keys.default)(opts[key]).reduce(function (phaseOptions, phaseKey) {\n if (phaseKey.startsWith('$')) {\n phaseOptions[phaseKey.substr(1)] = phaseOptions[phaseKey](session);\n (0, _deleteProperty.default)(phaseOptions, phaseKey);\n }\n return phaseOptions;\n }, opts[key]);\n return opts;\n }, options.phases);\n },\n _uploadPhaseUpload: function _uploadPhaseUpload(options) {\n var _this9 = this;\n this.logger.debug('client: uploading file');\n var promise = this.request(options.phases.upload).then(function (res) {\n _this9.logger.debug('client: uploaded file');\n return res;\n });\n (0, _common.proxyEvents)(options.phases.upload.upload, promise);\n\n /* istanbul ignore else */\n if (false) {}\n return promise;\n },\n _uploadPhaseFinalize: function _uploadPhaseFinalize(options) {\n var _this10 = this;\n this.logger.debug('client: finalizing upload session');\n return this.request(options.phases.finalize).then(function (res) {\n _this10.logger.debug('client: finalized upload session');\n return res;\n });\n }\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"_uploadPhaseUpload\", [_common.retry], (0, _getOwnPropertyDescriptor.default)(_obj, \"_uploadPhaseUpload\"), _obj)), _obj));\nWebexCore.version = \"3.8.0-next.11\";\n(0, _webexInternalCorePluginMixin.default)(_webexInternalCore.default, _config.default, interceptors);\n(0, _webexCorePluginMixin.default)(WebexCore, _config.default, interceptors);\nvar _default = exports[\"default\"] = WebexCore;\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 */\nfunction registerPlugin(name, constructor) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\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 */\nfunction registerInternalPlugin(name, constructor, options) {\n _webexInternalCore.default.registerPlugin(name, constructor, options);\n}\n//# sourceMappingURL=webex-core.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/webex-core.js?");
|
|
4615
|
+
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _Object$keys2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nexports.registerInternalPlugin = registerInternalPlugin;\nexports.registerPlugin = registerPlugin;\nvar _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/regenerator */ \"../../../node_modules/@babel/runtime-corejs2/regenerator/index.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _keys = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _assign = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/assign */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/assign.js\"));\nvar _stringify = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/json/stringify */ \"../../../node_modules/@babel/runtime-corejs2/core-js/json/stringify.js\"));\nvar _deleteProperty = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/delete-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/delete-property.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _events = __webpack_require__(/*! events */ \"../../../node_modules/events/events.js\");\nvar _util = _interopRequireDefault(__webpack_require__(/*! util */ \"../../../node_modules/util/util.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/common/dist/index.js\");\nvar _httpCore = __webpack_require__(/*! @webex/http-core */ \"../../../node_modules/@webex/webex-core/node_modules/@webex/http-core/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _ampersandState = _interopRequireDefault(__webpack_require__(/*! ampersand-state */ \"../../../node_modules/ampersand-state/ampersand-state.js\"));\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! uuid */ \"../../../node_modules/uuid/index.js\"));\nvar _auth = _interopRequireDefault(__webpack_require__(/*! ./interceptors/auth */ \"../../../node_modules/@webex/webex-core/dist/interceptors/auth.js\"));\nvar _networkTiming = _interopRequireDefault(__webpack_require__(/*! ./interceptors/network-timing */ \"../../../node_modules/@webex/webex-core/dist/interceptors/network-timing.js\"));\nvar _payloadTransformer = _interopRequireDefault(__webpack_require__(/*! ./interceptors/payload-transformer */ \"../../../node_modules/@webex/webex-core/dist/interceptors/payload-transformer.js\"));\nvar _redirect = _interopRequireDefault(__webpack_require__(/*! ./interceptors/redirect */ \"../../../node_modules/@webex/webex-core/dist/interceptors/redirect.js\"));\nvar _requestEvent = _interopRequireDefault(__webpack_require__(/*! ./interceptors/request-event */ \"../../../node_modules/@webex/webex-core/dist/interceptors/request-event.js\"));\nvar _requestLogger = _interopRequireDefault(__webpack_require__(/*! ./interceptors/request-logger */ \"../../../node_modules/@webex/webex-core/dist/interceptors/request-logger.js\"));\nvar _requestTiming = _interopRequireDefault(__webpack_require__(/*! ./interceptors/request-timing */ \"../../../node_modules/@webex/webex-core/dist/interceptors/request-timing.js\"));\nvar _responseLogger = _interopRequireDefault(__webpack_require__(/*! ./interceptors/response-logger */ \"../../../node_modules/@webex/webex-core/dist/interceptors/response-logger.js\"));\nvar _webexHttpError = _interopRequireDefault(__webpack_require__(/*! ./lib/webex-http-error */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-http-error.js\"));\nvar _userAgent = _interopRequireDefault(__webpack_require__(/*! ./interceptors/user-agent */ \"../../../node_modules/@webex/webex-core/dist/interceptors/user-agent.js\"));\nvar _webexTrackingId = _interopRequireDefault(__webpack_require__(/*! ./interceptors/webex-tracking-id */ \"../../../node_modules/@webex/webex-core/dist/interceptors/webex-tracking-id.js\"));\nvar _webexUserAgent = _interopRequireDefault(__webpack_require__(/*! ./interceptors/webex-user-agent */ \"../../../node_modules/@webex/webex-core/dist/interceptors/webex-user-agent.js\"));\nvar _rateLimit = _interopRequireDefault(__webpack_require__(/*! ./interceptors/rate-limit */ \"../../../node_modules/@webex/webex-core/dist/interceptors/rate-limit.js\"));\nvar _embargo = _interopRequireDefault(__webpack_require__(/*! ./interceptors/embargo */ \"../../../node_modules/@webex/webex-core/dist/interceptors/embargo.js\"));\nvar _defaultOptions = _interopRequireDefault(__webpack_require__(/*! ./interceptors/default-options */ \"../../../node_modules/@webex/webex-core/dist/interceptors/default-options.js\"));\nvar _hostmap = _interopRequireDefault(__webpack_require__(/*! ./lib/services/interceptors/hostmap */ \"../../../node_modules/@webex/webex-core/dist/lib/services/interceptors/hostmap.js\"));\nvar _config = _interopRequireDefault(__webpack_require__(/*! ./config */ \"../../../node_modules/@webex/webex-core/dist/config.js\"));\nvar _storage = __webpack_require__(/*! ./lib/storage */ \"../../../node_modules/@webex/webex-core/dist/lib/storage/index.js\");\nvar _webexCorePluginMixin = _interopRequireDefault(__webpack_require__(/*! ./lib/webex-core-plugin-mixin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-core-plugin-mixin.js\"));\nvar _webexInternalCorePluginMixin = _interopRequireDefault(__webpack_require__(/*! ./lib/webex-internal-core-plugin-mixin */ \"../../../node_modules/@webex/webex-core/dist/lib/webex-internal-core-plugin-mixin.js\"));\nvar _webexInternalCore = _interopRequireDefault(__webpack_require__(/*! ./webex-internal-core */ \"../../../node_modules/@webex/webex-core/dist/webex-internal-core.js\"));\nvar _obj;\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nfunction ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\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)\nvar interceptors = {\n WebexTrackingIdInterceptor: _webexTrackingId.default.create,\n RequestEventInterceptor: _requestEvent.default.create,\n RateLimitInterceptor: _rateLimit.default.create,\n /* eslint-disable no-extra-parens */\n RequestLoggerInterceptor: process.env.ENABLE_NETWORK_LOGGING || process.env.ENABLE_VERBOSE_NETWORK_LOGGING ? _requestLogger.default.create : undefined,\n ResponseLoggerInterceptor: process.env.ENABLE_NETWORK_LOGGING || process.env.ENABLE_VERBOSE_NETWORK_LOGGING ? _responseLogger.default.create : undefined,\n /* eslint-enable no-extra-parens */\n RequestTimingInterceptor: _requestTiming.default.create,\n ServiceInterceptor: undefined,\n UserAgentInterceptor: _userAgent.default.create,\n WebexUserAgentInterceptor: _webexUserAgent.default.create,\n AuthInterceptor: _auth.default.create,\n KmsDryErrorInterceptor: undefined,\n PayloadTransformerInterceptor: _payloadTransformer.default.create,\n ConversationInterceptor: undefined,\n RedirectInterceptor: _redirect.default.create,\n HttpStatusInterceptor: function HttpStatusInterceptor() {\n return _httpCore.HttpStatusInterceptor.create({\n error: _webexHttpError.default\n });\n },\n NetworkTimingInterceptor: _networkTiming.default.create,\n EmbargoInterceptor: _embargo.default.create,\n DefaultOptionsInterceptor: _defaultOptions.default.create,\n HostMapInterceptor: _hostmap.default.create\n};\nvar preInterceptors = ['ResponseLoggerInterceptor', 'RequestTimingInterceptor', 'RequestEventInterceptor', 'WebexTrackingIdInterceptor', 'RateLimitInterceptor'];\nvar postInterceptors = ['HttpStatusInterceptor', 'NetworkTimingInterceptor', 'EmbargoInterceptor', 'RequestLoggerInterceptor', 'RateLimitInterceptor'];\nvar MAX_FILE_SIZE_IN_MB = 2048;\n\n/**\n * @class\n */\nvar WebexCore = _ampersandState.default.extend((_obj = {\n version: \"3.8.0-next.12\",\n children: {\n internal: _webexInternalCore.default\n },\n constructor: function constructor() {\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var options = arguments.length > 1 ? arguments[1] : undefined;\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 ['credentials.authorization', 'authorization', 'credentials.supertoken.supertoken', 'supertoken', 'access_token', 'credentials.authorization.supertoken'].forEach(function (path) {\n var val = (0, _lodash.get)(attrs, path);\n if (val) {\n (0, _lodash.unset)(attrs, path);\n (0, _lodash.set)(attrs, 'credentials.supertoken', val);\n }\n });\n ['credentials', 'credentials.authorization'].forEach(function (path) {\n var val = (0, _lodash.get)(attrs, path);\n if (typeof val === 'string') {\n (0, _lodash.unset)(attrs, path);\n (0, _lodash.set)(attrs, 'credentials.supertoken', val);\n }\n });\n if (typeof (0, _lodash.get)(attrs, 'credentials.access_token') === 'string') {\n // Send access_token to get validated and corrected and then set it\n (0, _lodash.set)(attrs, 'credentials.access_token', this.bearerValidator((0, _lodash.get)(attrs, 'credentials.access_token').trim()));\n (0, _lodash.set)(attrs, 'credentials.supertoken', attrs.credentials);\n }\n }\n return (0, _apply.default)(_ampersandState.default, this, [attrs, options]);\n },\n derived: {\n boundedStorage: {\n deps: [],\n fn: function fn() {\n return (0, _storage.makeWebexStore)('bounded', this);\n }\n },\n unboundedStorage: {\n deps: [],\n fn: function fn() {\n return (0, _storage.makeWebexStore)('unbounded', this);\n }\n },\n ready: {\n deps: ['loaded', 'internal.ready'],\n fn: function fn() {\n var _this = this;\n return this.loaded && (0, _keys.default)(this._children).reduce(function (ready, name) {\n return ready && _this[name] && _this[name].ready !== false;\n }, true);\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 * @instance\n * @memberof WebexCore\n * @param {[type]} args\n * @returns {[type]}\n */\n refresh: function refresh() {\n var _this$credentials;\n return (_this$credentials = this.credentials).refresh.apply(_this$credentials, arguments);\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: function transform(direction, object) {\n var _this2 = this;\n var predicates = this.config.payloadTransformer.predicates.filter(function (p) {\n return !p.direction || p.direction === direction;\n });\n var ctx = {\n webex: this\n };\n return _promise.default.all(predicates.map(function (p) {\n return p.test(ctx, object).then(function (shouldTransform) {\n if (!shouldTransform) {\n return undefined;\n }\n return p.extract(object)\n // eslint-disable-next-line max-nested-callbacks\n .then(function (target) {\n return {\n name: p.name,\n target: target\n };\n });\n });\n })).then(function (data) {\n return data.filter(function (d) {\n return Boolean(d);\n })\n // eslint-disable-next-line max-nested-callbacks\n .reduce(function (promise, _ref) {\n var name = _ref.name,\n target = _ref.target,\n alias = _ref.alias;\n return promise.then(function () {\n if (alias) {\n return _this2.applyNamedTransform(direction, alias, target);\n }\n return _this2.applyNamedTransform(direction, name, target);\n });\n }, _promise.default.resolve());\n }).then(function () {\n return 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: function applyNamedTransform(direction, ctx, name) {\n var _this3 = this;\n for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {\n rest[_key - 3] = arguments[_key];\n }\n if ((0, _lodash.isString)(ctx)) {\n rest.unshift(name);\n name = ctx;\n ctx = {\n webex: this,\n transform: function transform() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return _this3.applyNamedTransform.apply(_this3, [direction, ctx].concat(args));\n }\n };\n }\n var transforms = ctx.webex.config.payloadTransformer.transforms.filter(function (tx) {\n return 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.reduce(function (promise, tx) {\n return promise.then(function () {\n if (tx.alias) {\n var _ctx;\n return (_ctx = ctx).transform.apply(_ctx, [tx.alias].concat(rest));\n }\n return _promise.default.resolve(tx.fn.apply(tx, [ctx].concat(rest)));\n });\n }, _promise.default.resolve()).then(function () {\n return (0, _lodash.last)(rest);\n });\n },\n /**\n * @private\n * @returns {Window}\n */\n getWindow: function getWindow() {\n // eslint-disable-next-line\n return window;\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: function initialize() {\n var _this4 = this;\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.config = (0, _lodash.merge)({}, _config.default, 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 var onLoaded = function onLoaded() {\n if (_this4.loaded) {\n /**\n * Fires when all data has been loaded from the storage layer\n * @event loaded\n * @instance\n * @memberof WebexCore\n */\n _this4.trigger('loaded');\n _this4.stopListening(_this4, '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(function () {\n _this4.listenToAndRun(_this4, 'change:loaded', onLoaded);\n });\n var onReady = function onReady() {\n if (_this4.ready) {\n /**\n * Fires when all plugins have fully initialized\n * @event ready\n * @instance\n * @memberof WebexCore\n */\n _this4.trigger('ready');\n _this4.stopListening(_this4, '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(function () {\n _this4.listenToAndRun(_this4, 'change:ready', onReady);\n });\n\n // Make nested events propagate in a consistent manner\n (0, _keys.default)(this.constructor.prototype._children).forEach(function (key) {\n _this4.listenTo(_this4[key], 'change', function () {\n for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n args.unshift(\"change:\".concat(key));\n _this4.trigger.apply(_this4, args);\n });\n });\n var addInterceptor = function addInterceptor(ints, key) {\n var interceptorsObj = _this4.config.interceptors || interceptors;\n var interceptor = interceptorsObj[key];\n if (!(0, _lodash.isFunction)(interceptor)) {\n return ints;\n }\n ints.push((0, _apply.default)(interceptor, _this4, []));\n return ints;\n };\n var ints = [];\n if (this.config.interceptors) {\n (0, _keys.default)(this.config.interceptors).reduce(addInterceptor, ints);\n } else {\n ints = preInterceptors.reduce(addInterceptor, ints);\n ints = (0, _keys.default)(interceptors).filter(function (key) {\n return !(preInterceptors.includes(key) || postInterceptors.includes(key));\n }).reduce(addInterceptor, ints);\n ints = postInterceptors.reduce(addInterceptor, ints);\n }\n this.request = (0, _httpCore.defaults)({\n json: true,\n interceptors: ints\n });\n this.prepareFetchOptions = (0, _httpCore.protoprepareFetchOptions)({\n json: true,\n interceptors: ints\n });\n this.setTimingsAndFetch = _httpCore.setTimingsAndFetch;\n var sessionId = \"\".concat((0, _lodash.get)(this, 'config.trackingIdPrefix', 'webex-js-sdk'), \"_\").concat((0, _lodash.get)(this, 'config.trackingIdBase', _uuid.default.v4()));\n if ((0, _lodash.get)(this, 'config.trackingIdSuffix')) {\n sessionId += \"_\".concat((0, _lodash.get)(this, 'config.trackingIdSuffix'));\n }\n this.sessionId = sessionId;\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: function setConfig() {\n var newConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.config = (0, _lodash.merge)({}, this.config, newConfig);\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: function bearerValidator(token) {\n if (token.includes('Bearer') && token.split(' ').length - 1 === 0) {\n console.warn(\"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\".concat(token.replace('Bearer', 'Bearer ').replace(/\\s+/g, ' ')));\n console.info(\"Tip: You don't need to add 'Bearer' to the access_token field. The token by itself is fine\");\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(\"Your access token has \".concat(token.split(' ').length - 2, \" too many spaces, please use this format:\\n\\n\").concat(token.replace(/\\s+/g, ' ')));\n console.info(\"Tip: You don't need to add 'Bearer' to the access_token field, the token by itself is fine\");\n return token.replace(/\\s+/g, ' ');\n }\n return token.replace(/\\s+/g, ' '); // Clean it anyway (just in case)\n },\n /**\n * @instance\n * @memberof WebexPlugin\n * @param {number} depth\n * @private\n * @returns {Object}\n */\n inspect: function inspect(depth) {\n return _util.default.inspect((0, _lodash.omit)(this.serialize({\n props: true,\n session: true,\n derived: true\n }), 'boundedStorage', 'unboundedStorage', 'request', 'config'), {\n depth: depth\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: function logout(options) {\n var _this5 = this;\n for (var _len4 = arguments.length, rest = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {\n rest[_key4 - 1] = arguments[_key4];\n }\n // prefer the refresh token, but for clients that don't have one, fallback\n // to the access token\n var token = this.credentials.supertoken && (this.credentials.supertoken.refresh_token || this.credentials.supertoken.access_token);\n options = (0, _assign.default)({\n token: token\n }, 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.reverse().reduce(function (promise, _ref2) {\n var plugin = _ref2.plugin,\n fn = _ref2.fn;\n return promise.then(function () {\n return _promise.default.resolve((0, _apply.default)(fn, _this5[plugin] || _this5.internal[plugin], [options].concat(rest)))\n // eslint-disable-next-line max-nested-callbacks\n .catch(function (err) {\n _this5.logger.warn(\"onBeforeLogout from plugin \".concat(plugin, \": failed\"), err);\n });\n });\n }, _promise.default.resolve()).then(function () {\n return _promise.default.all([_this5.boundedStorage.clear(), _this5.unboundedStorage.clear()]);\n }).then(function () {\n var _this5$credentials;\n return (_this5$credentials = _this5.credentials).invalidate.apply(_this5$credentials, rest);\n }).then(function () {\n var _this5$authorization;\n return _this5.authorization && _this5.authorization.logout && (_this5$authorization = _this5.authorization).logout.apply(_this5$authorization, [options].concat(rest));\n }).then(function () {\n return _this5.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: function measure() {\n if (this.metrics) {\n var _this$metrics;\n return (_this$metrics = this.metrics).sendUnstructured.apply(_this$metrics, arguments);\n }\n return _promise.default.resolve();\n },\n upload: function upload(options) {\n var _this6 = this;\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {\n var shunt, promise;\n return _regenerator.default.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n if (options.file) {\n _context.next = 2;\n break;\n }\n return _context.abrupt(\"return\", _promise.default.reject(new Error('`options.file` is required')));\n case 2:\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 (0, _lodash.defaultsDeep)(options.phases.initialize, {\n method: 'POST',\n body: {\n uploadProtocol: 'content-length'\n }\n }, (0, _lodash.omit)(options, 'file', 'phases'));\n (0, _lodash.defaultsDeep)(options.phases.upload, {\n method: 'PUT',\n json: false,\n withCredentials: false,\n body: options.file,\n headers: {\n 'x-trans-id': _uuid.default.v4(),\n authorization: undefined\n }\n });\n (0, _lodash.defaultsDeep)(options.phases.finalize, {\n method: 'POST'\n }, (0, _lodash.omit)(options, 'file', 'phases'));\n shunt = new _events.EventEmitter();\n promise = _this6._uploadPhaseInitialize(options).then(function () {\n var p = _this6._uploadPhaseUpload(options);\n (0, _common.transferEvents)('progress', p, shunt);\n return p;\n }).then(function () {\n for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n args[_key5] = arguments[_key5];\n }\n return _this6._uploadPhaseFinalize.apply(_this6, [options].concat(args));\n }).then(function (res) {\n return _objectSpread(_objectSpread({}, res.body), res.headers);\n });\n (0, _common.proxyEvents)(shunt, promise);\n return _context.abrupt(\"return\", promise);\n case 13:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }))();\n },\n _uploadPhaseInitialize: function _uploadPhaseInitialize(options) {\n var _this7 = this;\n this.logger.debug('client: initiating upload session');\n return this.request(options.phases.initialize).then(function () {\n for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n args[_key6] = arguments[_key6];\n }\n var fileUploadSizeLimitInBytes = (args[0].body.fileUploadSizeLimit || MAX_FILE_SIZE_IN_MB) * 1024 * 1024;\n var currentFileSizeInBytes = options.file.byteLength;\n if (fileUploadSizeLimitInBytes && fileUploadSizeLimitInBytes < currentFileSizeInBytes) {\n return _this7._uploadAbortSession.apply(_this7, [currentFileSizeInBytes].concat(args));\n }\n return _this7._uploadApplySession.apply(_this7, [options].concat(args));\n }).then(function (res) {\n _this7.logger.debug('client: initiated upload session');\n return res;\n });\n },\n _uploadAbortSession: function _uploadAbortSession(currentFileSizeInBytes, response) {\n var _this8 = this;\n this.logger.debug('client: deleting uploaded file');\n return this.request({\n method: 'DELETE',\n url: response.body.url,\n headers: response.options.headers\n }).then(function () {\n _this8.logger.debug('client: deleting uploaded file complete');\n var abortErrorDetails = {\n currentFileSizeInBytes: currentFileSizeInBytes,\n fileUploadSizeLimitInMB: response.body.fileUploadSizeLimit || MAX_FILE_SIZE_IN_MB,\n message: 'file-upload-size-limit-enabled'\n };\n return _promise.default.reject(new Error(\"\".concat((0, _stringify.default)(abortErrorDetails))));\n });\n },\n _uploadApplySession: function _uploadApplySession(options, res) {\n var session = res.body;\n ['upload', 'finalize'].reduce(function (opts, key) {\n opts[key] = (0, _keys.default)(opts[key]).reduce(function (phaseOptions, phaseKey) {\n if (phaseKey.startsWith('$')) {\n phaseOptions[phaseKey.substr(1)] = phaseOptions[phaseKey](session);\n (0, _deleteProperty.default)(phaseOptions, phaseKey);\n }\n return phaseOptions;\n }, opts[key]);\n return opts;\n }, options.phases);\n },\n _uploadPhaseUpload: function _uploadPhaseUpload(options) {\n var _this9 = this;\n this.logger.debug('client: uploading file');\n var promise = this.request(options.phases.upload).then(function (res) {\n _this9.logger.debug('client: uploaded file');\n return res;\n });\n (0, _common.proxyEvents)(options.phases.upload.upload, promise);\n\n /* istanbul ignore else */\n if (false) {}\n return promise;\n },\n _uploadPhaseFinalize: function _uploadPhaseFinalize(options) {\n var _this10 = this;\n this.logger.debug('client: finalizing upload session');\n return this.request(options.phases.finalize).then(function (res) {\n _this10.logger.debug('client: finalized upload session');\n return res;\n });\n }\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"_uploadPhaseUpload\", [_common.retry], (0, _getOwnPropertyDescriptor.default)(_obj, \"_uploadPhaseUpload\"), _obj)), _obj));\nWebexCore.version = \"3.8.0-next.12\";\n(0, _webexInternalCorePluginMixin.default)(_webexInternalCore.default, _config.default, interceptors);\n(0, _webexCorePluginMixin.default)(WebexCore, _config.default, interceptors);\nvar _default = exports[\"default\"] = WebexCore;\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 */\nfunction registerPlugin(name, constructor) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\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 */\nfunction registerInternalPlugin(name, constructor, options) {\n _webexInternalCore.default.registerPlugin(name, constructor, options);\n}\n//# sourceMappingURL=webex-core.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/webex-core/dist/webex-core.js?");
|
|
4616
4616
|
|
|
4617
4617
|
/***/ }),
|
|
4618
4618
|
|
|
@@ -12049,7 +12049,7 @@ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-co
|
|
|
12049
12049
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12050
12050
|
|
|
12051
12051
|
"use strict";
|
|
12052
|
-
eval("\n\nvar _Object$keys = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _now = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/date/now */ \"../../../node_modules/@babel/runtime-corejs2/core-js/date/now.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"./node_modules/@webex/common/dist/index.js\");\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _commonTimers = __webpack_require__(/*! @webex/common-timers */ \"./node_modules/@webex/common-timers/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! uuid */ \"../../../node_modules/uuid/index.js\"));\nvar _metrics = _interopRequireDefault(__webpack_require__(/*! ./metrics */ \"./node_modules/@webex/internal-plugin-device/dist/metrics.js\"));\nvar _constants = __webpack_require__(/*! ./constants */ \"./node_modules/@webex/internal-plugin-device/dist/constants.js\");\nvar _featuresModel = _interopRequireDefault(__webpack_require__(/*! ./features/features-model */ \"./node_modules/@webex/internal-plugin-device/dist/features/features-model.js\"));\nvar _ipNetworkDetector = _interopRequireDefault(__webpack_require__(/*! ./ipNetworkDetector */ \"./node_modules/@webex/internal-plugin-device/dist/ipNetworkDetector.js\"));\nvar _types = __webpack_require__(/*! ./types */ \"./node_modules/@webex/internal-plugin-device/dist/types.js\");\nvar _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _obj; // Internal Dependencies\nfunction ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\n/**\n * Determine if the plugin should be initialized based on cached storage.\n *\n * @returns {boolean} - If the device is ephemeral.\n */\nfunction decider() {\n return !this.config.ephemeral;\n}\nvar Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)('@'), _dec2 = (0, _webexCore.waitForValue)('@'), _dec3 = (0, _webexCore.waitForValue)('@'), _dec4 = (0, _webexCore.waitForValue)('@'), _dec5 = (0, _common.deprecated)('device#markUrlFailedAndGetNew(): Use services#markFailedUrl()'), _dec6 = (0, _webexCore.persist)('@', decider), (_obj = {\n // Ampersand property members.\n\n namespace: 'Device',\n // Allow for extra properties to prevent the plugin from failing due to\n // **WDM** service DTO changes.\n extraProperties: 'allow',\n idAttribute: 'url',\n children: {\n /**\n * The class object that contains all of the feature collections.\n *\n * @type {FeaturesModel}\n */\n features: _featuresModel.default,\n /**\n * Helper class for detecting what IP network version (ipv4, ipv6) we're on.\n *\n * @type {IpNetworkDetector}\n */\n ipNetworkDetector: _ipNetworkDetector.default\n },\n /**\n * A collection of device properties mostly assigned by the retrieved DTO from\n * the **WDM** service that are mapped against the ampersand properties.\n *\n * @type {Object}\n */\n props: {\n /**\n * This property determines whether or not giphy support is enabled.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n clientMessagingGiphy: 'string',\n /**\n * This property should store the company name.\n *\n * @type {string}\n */\n customerCompanyName: 'string',\n /**\n * This property should store the logo url.\n *\n * @type {string}\n */\n customerLogoUrl: 'string',\n /**\n * This property doesn't have any real values, but is sent during device\n * refresh to prevent the **wdm** service from falling back to an iOS device\n * type.\n *\n * @type {string}\n */\n deviceType: 'string',\n /**\n * This property should store the help url.\n *\n * @type {string}\n */\n helpUrl: 'string',\n /**\n * This property should store the intranet inactivity timer duration.\n *\n * @type {number}\n */\n intranetInactivityDuration: 'number',\n /**\n * This property stores the url required to validate if the device is able\n * to actively reach the intranet network.\n *\n * @type {string}\n */\n intranetInactivityCheckUrl: 'string',\n /**\n * This property stores the inactivity timer duration, and could possibly\n * deprecate the `intranetInactivityDuration` property.\n *\n * @type {number}\n */\n inNetworkInactivityDuration: 'number',\n /**\n * This property stores the ECM (external content management) enabled value\n * for the whole organization.\n *\n * @type {boolean}\n */\n ecmEnabledForAllUsers: ['boolean', false, false],\n /**\n * This property stores an array of ECM (external content management)\n * providers that are currently available.\n *\n * @returns {Array<string>}\n */\n ecmSupportedStorageProviders: ['array', false, function () {\n return [];\n }],\n /**\n * This property stores the modification time value retrieved from the\n * **WDM** endpoint formatted as ISO 8601.\n *\n * @type {string}\n */\n modificationTime: 'string',\n /**\n * This property stores the navigation bar color.\n *\n * @type {string}\n */\n navigationBarColor: 'string',\n /**\n * This property stores the partner company's name when available.\n *\n * @type {string}\n */\n partnerCompanyName: 'string',\n /**\n * This property stores the partner company's logo when available.\n *\n * @type {string}\n */\n partnerLogoUrl: 'string',\n /**\n * This property stores the availability of people data from the **WDM**\n * service.\n *\n * @type {boolean}\n */\n peopleInsightsEnabled: 'boolean',\n /**\n * This property stores the reporting site's description when available.\n *\n * @type {string}\n */\n reportingSiteDesc: 'string',\n /**\n * This property stores the reporting site's access url when available.\n *\n * @type {string}\n */\n reportingSiteUrl: 'string',\n /**\n * This property stores the encryption key url when available.\n *\n * @type {string}\n */\n searchEncryptionKeyUrl: 'string',\n /**\n * This property stores the availability of support-provided text from the\n * **WDM** service.\n *\n * @type {boolean}\n */\n showSupportText: 'boolean',\n /**\n * This property stores the support provider's company name when available.\n *\n * @type {string}\n */\n supportProviderCompanyName: 'string',\n /**\n * This property stores the support provider's logo url when available.\n *\n * @type {string}\n */\n supportProviderLogoUrl: 'string',\n /**\n * This property stores the device's url retrieved from a registration\n * request. This property gets set via the initial registration process by a\n * `this.set()` method.\n *\n * @type {string}\n */\n url: 'string',\n /**\n * This property stores the device's userId uuid value, which can also be\n * derived from the device's registerd user's userId retrieved from\n * the **Hydra** service.\n *\n * @type {string}\n */\n userId: 'string',\n /**\n * This property stores whether or not file sharing is enabled\n *\n * @type {'BLOCK_BOTH' | 'BLOCK_UPLOAD'}\n */\n webFileShareControl: 'string',\n /**\n * This property stores the current web socket url used by the registered\n * device.\n *\n * @type {string}\n */\n webSocketUrl: 'string',\n /**\n * This property stores the value indicating whether or not white board file\n * sharing is enabled for the current device.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n whiteboardFileShareControl: 'string'\n },\n /**\n * A list of derived properties that populate based when their parent data\n * available via the device's properties.\n *\n * @type {Object}\n */\n derived: {\n /**\n * This property determines if the current device is registered.\n *\n * @type {boolean}\n */\n registered: {\n deps: ['url'],\n /**\n * Checks if the device is registered by validating that the url exists.\n * Amperstand does not allow this to method to be written as an arrow\n * function.\n *\n * @returns {boolean}\n */\n fn: function fn() {\n return !!this.url;\n }\n }\n },\n /**\n * Stores timer data as well as other state details.\n *\n * @type {Object}\n */\n session: {\n /**\n * This property stores the logout timer object\n *\n * @type {any}\n */\n logoutTimer: 'any',\n /**\n * This property stores the date for the last activity the user made\n * with the current device.\n *\n * @type {number}\n */\n lastUserActivityDate: 'number',\n /**\n * This property stores whether or not the reachability check has been\n * performed to prevent the reachability check from performing its\n * operation more than once after a successful check.\n *\n * @returns {boolean}\n */\n isReachabilityChecked: ['boolean', false, false],\n /**\n * This property stores whether or not the next refresh or register request should request energy forecast data\n * in order to prevent over fetching energy forecasts\n *\n * @type {boolean}\n */\n energyForecastConfig: 'boolean',\n /**\n * This property stores whether or not the current device is in a meeting\n * to prevent an unneeded timeout of a meeting due to inactivity.\n *\n * @type {boolean}\n */\n isInMeeting: 'boolean',\n /**\n * This property identifies if the device is currently in network to prevent\n * the `resetLogoutTimer()` method from being called repeatedly once its\n * known client is connected to the organization's internal network.\n *\n * @type {boolean}\n */\n isInNetwork: 'boolean'\n },\n // Event method members.\n /**\n * Trigger meeting started event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingStarted: function meetingStarted() {\n this.webex.trigger('meeting started');\n },\n /**\n * Trigger meeting ended event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingEnded: function meetingEnded() {\n this.webex.trigger('meeting ended');\n },\n /**\n * Set the value of energy forecast config for the current registered device.\n * @param {boolean} [energyForecastConfig=false] - fetch an energy forecast on the next refresh/register\n * @returns {void}\n */\n setEnergyForecastConfig: function setEnergyForecastConfig() {\n var energyForecastConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n this.energyForecastConfig = energyForecastConfig;\n },\n refresh: function refresh() {\n var _this = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: refreshing');\n\n // Validate that the device can be registered.\n return this.canRegister().then(function () {\n // Validate if the device is not registered and register instead.\n if (!_this.registered) {\n _this.logger.info('device: device not registered, registering');\n return _this.register(deviceRegistrationOptions);\n }\n\n // Merge body configurations, overriding defaults.\n var body = _objectSpread(_objectSpread({}, _this.serialize()), _this.config.body ? _this.config.body : {});\n\n // Remove unneeded properties from the body object.\n delete body.features;\n delete body.mediaCluster;\n delete body.etag;\n\n // Append a ttl value if the device is marked as ephemeral.\n if (_this.config.ephemeral) {\n body.ttl = _this.config.ephemeralDeviceTTL;\n }\n\n // Merge header configurations, overriding defaults.\n var headers = _objectSpread(_objectSpread(_objectSpread({}, _this.config.defaults.headers ? _this.config.defaults.headers : {}), _this.config.headers ? _this.config.headers : {}), _this.etag ? {\n 'If-None-Match': _this.etag\n } : {});\n var _deviceRegistrationOp = deviceRegistrationOptions.includeDetails,\n includeDetails = _deviceRegistrationOp === void 0 ? _types.CatalogDetails.all : _deviceRegistrationOp;\n var requestId = _uuid.default.v4();\n _this.set('refresh-request-id', requestId);\n return _this.request({\n method: 'PUT',\n uri: _this.url,\n body: body,\n headers: headers,\n qs: {\n includeUpstreamServices: \"\".concat(includeDetails).concat(_this.config.energyForecast && _this.energyForecastConfig ? ',energyforecast' : '')\n }\n }).then(function (response) {\n // If we've signed out in the mean time, the request ID will have changed\n if (_this.get('refresh-request-id') !== requestId) {\n _this.logger.info('device: refresh request ID mismatch, ignoring response');\n return _promise.default.resolve();\n }\n return _this.processRegistrationSuccess(response);\n }).catch(function (reason) {\n // Handle a 404 error, which indicates that the device is no longer\n // valid and needs to be registered as a new device.\n if (reason.statusCode === 404) {\n _this.logger.info('device: refresh failed, device is not valid');\n _this.logger.info('device: attempting to register a new device');\n _this.clear();\n return _this.register(deviceRegistrationOptions);\n }\n return _promise.default.reject(reason);\n });\n });\n },\n /**\n * Fetches the web devices and deletes the third of them which are not recent devices in use\n * @returns {Promise<void, Error>}\n */\n deleteDevices: function deleteDevices() {\n var _this2 = this;\n // Fetch devices with a GET request\n return this.request({\n method: 'GET',\n service: 'wdm',\n resource: 'devices'\n }).then(function (response) {\n var devices = response.body.devices;\n var _this2$_getBody = _this2._getBody(),\n deviceType = _this2$_getBody.deviceType;\n\n // Filter devices of type deviceType\n var webDevices = devices.filter(function (item) {\n return item.deviceType === deviceType;\n });\n var sortedDevices = (0, _lodash.orderBy)(webDevices, [function (item) {\n return new Date(item.modificationTime);\n }]);\n\n // If there are more than two devices, delete the last third\n if (sortedDevices.length > 2) {\n var totalItems = sortedDevices.length;\n var countToDelete = Math.ceil(totalItems / 3);\n var urlsToDelete = sortedDevices.slice(0, countToDelete).map(function (item) {\n return item.url;\n });\n return _promise.default.race(urlsToDelete.map(function (url) {\n return _this2.request({\n uri: url,\n method: 'DELETE'\n });\n }));\n }\n return _promise.default.resolve();\n }).catch(function (error) {\n _this2.logger.error('Failed to retrieve devices:', error);\n return _promise.default.reject(error);\n });\n },\n register: function register() {\n var _this3 = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: registering');\n this.webex.internal.newMetrics.callDiagnosticMetrics.setDeviceInfo(this);\n\n // Validate that the device can be registered.\n return this.canRegister().then(function () {\n // Validate if the device is already registered and refresh instead.\n if (_this3.registered) {\n _this3.logger.info('device: device already registered, refreshing');\n return _this3.refresh(deviceRegistrationOptions);\n }\n return _this3._registerInternal(deviceRegistrationOptions).catch(function (error) {\n var _error$body;\n if ((error === null || error === void 0 ? void 0 : (_error$body = error.body) === null || _error$body === void 0 ? void 0 : _error$body.message) === 'User has excessive device registrations') {\n return _this3.deleteDevices().then(function () {\n return _this3._registerInternal(deviceRegistrationOptions);\n });\n }\n throw error;\n });\n });\n },\n _getBody: function _getBody() {\n return _objectSpread(_objectSpread({}, this.config.defaults.body ? this.config.defaults.body : {}), this.config.body ? this.config.body : {});\n },\n _registerInternal: function _registerInternal() {\n var _this4 = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: making registration request');\n\n // Merge body configurations, overriding defaults.\n var body = this._getBody();\n\n // Merge header configurations, overriding defaults.\n var headers = _objectSpread(_objectSpread({}, this.config.defaults.headers ? this.config.defaults.headers : {}), this.config.headers ? this.config.headers : {});\n\n // Append a ttl value if the device is marked as ephemeral\n if (this.config.ephemeral) {\n body.ttl = this.config.ephemeralDeviceTTL;\n }\n this.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.request'\n });\n var _deviceRegistrationOp2 = deviceRegistrationOptions.includeDetails,\n includeDetails = _deviceRegistrationOp2 === void 0 ? _types.CatalogDetails.all : _deviceRegistrationOp2;\n var requestId = _uuid.default.v4();\n this.set('register-request-id', requestId);\n\n // This will be replaced by a `create()` method.\n return this.request({\n method: 'POST',\n service: 'wdm',\n resource: 'devices',\n body: body,\n headers: headers,\n qs: {\n includeUpstreamServices: \"\".concat(includeDetails).concat(this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : '')\n }\n }).catch(function (error) {\n _this4.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response'\n });\n throw error;\n }).then(function (response) {\n // If we've signed out in the mean time, the request ID will have changed\n if (_this4.get('register-request-id') !== requestId) {\n _this4.logger.info('device: register request ID mismatch, ignoring response');\n return _promise.default.resolve();\n }\n\n // Do not add any processing of response above this as that will affect timestamp\n _this4.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response'\n });\n _this4.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_SUCCESSFUL);\n return _this4.processRegistrationSuccess(response);\n }).catch(function (error) {\n _this4.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_FAILED, {\n fields: {\n error: error\n }\n });\n throw error;\n });\n },\n unregister: function unregister() {\n var _this5 = this;\n this.logger.info('device: unregistering');\n if (!this.registered) {\n this.logger.warn('device: not registered');\n return _promise.default.resolve();\n }\n return this.request({\n uri: this.url,\n method: 'DELETE'\n }).then(function () {\n return _this5.clear();\n }).catch(function (reason) {\n if (reason.statusCode === 404) {\n _this5.logger.info('device: 404 when deleting device, device is already deleted, clearing device');\n _this5.clear();\n }\n throw reason;\n });\n },\n /* eslint-enable require-jsdoc */\n // Helper method members\n /**\n * Determine if registration methods can be performed. This method utilizes\n * the `services` plugin to confirm if the appropriate service urls are\n * available for device registration.\n *\n * @returns {Promise<void, Error>}\n */\n canRegister: function canRegister() {\n this.logger.info('device: validating if registration can occur');\n\n // Destructure the services plugin for ease of reference.\n var services = this.webex.internal.services;\n\n // Wait for the postauth catalog to populate.\n return services.waitForCatalog('postauth', this.config.canRegisterWaitDuration).then(function () {\n return (\n // Validate that the service exists after waiting for the catalog.\n services.get('wdm') ? _promise.default.resolve() : _promise.default.reject(new Error(['device: cannot register,', \"'wdm' service is not available from the postauth catalog\"].join(' ')))\n );\n });\n },\n /**\n * Check if the device can currently reach the inactivity check url.\n *\n * @returns {Promise<void, Error>}\n */\n checkNetworkReachability: function checkNetworkReachability() {\n var _this6 = this;\n this.logger.info('device: checking network reachability');\n\n // Validate if the device has been checked and reset the logout timer.\n if (this.isReachabilityChecked) {\n return _promise.default.resolve(this.resetLogoutTimer());\n }\n this.isReachabilityChecked = true;\n\n // Validate if the device has a intranet checking url.\n if (!this.intranetInactivityCheckUrl) {\n this.isInNetwork = false;\n return _promise.default.resolve(this.resetLogoutTimer());\n }\n\n // Clear unnecessary headers for reachability request.\n var headers = {\n 'cisco-no-http-redirect': null,\n 'spark-user-agent': null,\n trackingid: null\n };\n\n // Send the network reachability request.\n return this.request({\n headers: headers,\n method: 'GET',\n uri: this.intranetInactivityCheckUrl\n }).then(function () {\n _this6.isInNetwork = true;\n return _promise.default.resolve(_this6.resetLogoutTimer());\n }).catch(function () {\n _this6.logger.info('device: did not reach ping endpoint');\n _this6.logger.info('device: triggering off-network timer');\n _this6.isInNetwork = false;\n return _promise.default.resolve(_this6.resetLogoutTimer());\n });\n },\n /**\n * Clears the registration ttl value if available.\n *\n * @param {Object} options - Values to be cleared.\n * @returns {void}\n */\n clear: function clear() {\n this.logger.info('device: clearing registered device');\n\n // Prototype the extended class in order to preserve the parent member.\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n (0, _apply.default)(_webexCore.WebexPlugin.prototype.clear, this, args);\n },\n /**\n * Get the current websocket url with the appropriate priority host.\n *\n * @param {boolean} [wait=false] - Willing to wait on a valid url.\n * @returns {Promise<string, Error>} - The priority-mapped web socket url.\n */\n getWebSocketUrl: function getWebSocketUrl() {\n var _this7 = this;\n var wait = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n this.logger.info('device: getting the current websocket url');\n\n // Destructure the services plugin for ease of reference.\n var services = this.webex.internal.services;\n\n // Validate if the method should wait for registration.\n if (wait) {\n return this.waitForRegistration().then(function () {\n return services.convertUrlToPriorityHostUrl(_this7.webSocketUrl);\n }).catch(function (error) {\n _this7.logger.warn(error.message);\n return _promise.default.reject(new Error('device: failed to get the current websocket url'));\n });\n }\n\n // Validate if the device is registered.\n if (!this.registered) {\n return _promise.default.reject(new Error('device: cannot get websocket url, device is not registered'));\n }\n\n // Attempt to collect the priority-host-mapped web socket URL.\n var wsUrl = services.convertUrlToPriorityHostUrl(this.webSocketUrl);\n\n // Validate that the url was collected.\n if (wsUrl) {\n return _promise.default.resolve(wsUrl);\n }\n return _promise.default.reject(new Error('device: failed to get the current websocket url'));\n },\n /**\n * Process a successful device registration.\n *\n * @param {Object} response - response object from registration success.\n * @returns {void}\n */\n processRegistrationSuccess: function processRegistrationSuccess(response) {\n var _this8 = this;\n this.logger.info('device: received registration payload');\n\n // Clone the response body for service cleaning.\n var body = _objectSpread({}, response.body);\n\n // Clean service data.\n delete body.services;\n delete body.serviceHostMap;\n var _ref = response.headers || {},\n etag = _ref.etag;\n if (this.etag && etag && this.etag === etag) {\n // If current etag matches the previous one and we have sent\n // If-None-Match header the developer and entitlement feature\n // toggles will not be returned\n var features = body.features;\n delete body.features;\n // When using the etag feature cache, user and entitlement features are still returned\n this.features.user.reset(features.user);\n this.features.entitlement.reset(features.entitlement);\n }\n\n // Assign the recieved DTO from **WDM** to this device.\n this.set(body);\n\n // Assign the new etag to this device.\n this.set({\n etag: etag\n });\n\n // Validate if device is ephemeral and setup refresh timer.\n if (this.config.ephemeral) {\n this.logger.info('device: enqueuing device refresh');\n var delay = (this.config.ephemeralDeviceTTL / 2 + 60) * 1000;\n this.refreshTimer = (0, _commonTimers.safeSetTimeout)(function () {\n return _this8.refresh();\n }, delay);\n }\n\n // Emit the registration:success event.\n this.trigger(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, this);\n },\n /**\n * Reset the current local logout timer for the registered device if\n * registered.\n *\n * @returns {void}\n */\n resetLogoutTimer: function resetLogoutTimer() {\n this.logger.info('device: resetting logout timer');\n\n // Clear current logout timer.\n clearTimeout(this.logoutTimer);\n\n // Remove last activity date event listener.\n this.off('change:lastUserActivityDate');\n\n // Remove the logout timer.\n this.unset('logoutTimer');\n\n // Validate if the device is currently in a meeting and is configured to\n // required inactivity enforcement.\n if (!this.isInMeeting && this.config.enableInactivityEnforcement && this.isReachabilityChecked) {\n if (this.isInNetwork) {\n this.setLogoutTimer(this.inNetworkInactivityDuration);\n } else {\n this.setLogoutTimer(this.intranetInactivityDuration);\n }\n }\n },\n /**\n * Set the value of the logout timer for the current registered device.\n *\n * @param {number} duration - Value in seconds of the new logout timer.\n * @returns {void}\n */\n setLogoutTimer: function setLogoutTimer(duration) {\n var _this9 = this;\n this.logger.info('device: setting logout timer');\n if (!duration || duration <= 0) {\n return;\n }\n\n // Setup user activity date event listener.\n this.on('change:lastUserActivityDate', function () {\n _this9.resetLogoutTimer();\n });\n\n // Initialize a new timer.\n this.logoutTimer = (0, _commonTimers.safeSetTimeout)(function () {\n _this9.webex.logout();\n }, duration * 1000);\n },\n /**\n * Wait for the device to be registered.\n *\n * @param {number} [timeout=10] - The maximum duration to wait, in seconds.\n * @returns {Promise<void, Error>}\n */\n waitForRegistration: function waitForRegistration() {\n var _this10 = this;\n var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;\n this.logger.info('device: waiting for registration');\n return new _promise.default(function (resolve, reject) {\n if (_this10.registered) {\n resolve();\n }\n var timeoutTimer = (0, _commonTimers.safeSetTimeout)(function () {\n return reject(new Error('device: timeout occured while waiting for registration'));\n }, timeout * 1000);\n _this10.once(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, function () {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n markUrlFailedAndGetNew: function markUrlFailedAndGetNew(url) {\n return _promise.default.resolve(this.webex.internal.services.markFailedUrl(url));\n },\n initialize: function initialize() {\n var _this11 = this;\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n // Prototype the extended class in order to preserve the parent member.\n (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args);\n\n // Initialize feature events and listeners.\n _constants.FEATURE_COLLECTION_NAMES.forEach(function (collectionName) {\n _this11.features.on(\"change:\".concat(collectionName), function (model, value, options) {\n _this11.trigger('change', _this11, options);\n _this11.trigger('change:features', _this11, _this11.features, options);\n });\n });\n\n // Initialize network reachability checking event for url change.\n this.on('change:intranetInactivityCheckUrl', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:intranetInactivityDuration', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:inNetworkInactivityDuration', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize listener for activity checking.\n this.listenTo(this.webex, 'user-activity', function () {\n _this11.lastUserActivityDate = (0, _now.default)();\n });\n\n // Initialize listener for meeting started event.\n this.listenTo(this.webex, 'meeting started', function () {\n _this11.isInMeeting = true;\n _this11.resetLogoutTimer();\n });\n\n // Initialize listener for meeting ended event.\n this.listenTo(this.webex, 'meeting ended', function () {\n _this11.isInMeeting = false;\n _this11.resetLogoutTimer();\n });\n } /* eslint-enable require-jsdoc */,\n version: \"3.8.0-next.11\"\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"refresh\", [_common.oneFlight, _dec], (0, _getOwnPropertyDescriptor.default)(_obj, \"refresh\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"register\", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, \"register\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"_registerInternal\", [_common.oneFlight, _dec3], (0, _getOwnPropertyDescriptor.default)(_obj, \"_registerInternal\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"unregister\", [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor.default)(_obj, \"unregister\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"markUrlFailedAndGetNew\", [_dec5], (0, _getOwnPropertyDescriptor.default)(_obj, \"markUrlFailedAndGetNew\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"initialize\", [_dec6], (0, _getOwnPropertyDescriptor.default)(_obj, \"initialize\"), _obj)), _obj)));\nvar _default = exports[\"default\"] = Device;\n//# sourceMappingURL=device.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/@webex/internal-plugin-device/dist/device.js?");
|
|
12052
|
+
eval("\n\nvar _Object$keys = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\");\nvar _Object$getOwnPropertySymbols = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-symbols */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-symbols.js\");\nvar _Object$getOwnPropertyDescriptor2 = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\");\nvar _Object$getOwnPropertyDescriptors = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptors */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptors.js\");\nvar _Object$defineProperties = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-properties */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-properties.js\");\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _now = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/date/now */ \"../../../node_modules/@babel/runtime-corejs2/core-js/date/now.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/defineProperty */ \"../../../node_modules/@babel/runtime-corejs2/helpers/defineProperty.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"./node_modules/@webex/common/dist/index.js\");\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _commonTimers = __webpack_require__(/*! @webex/common-timers */ \"./node_modules/@webex/common-timers/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! uuid */ \"../../../node_modules/uuid/index.js\"));\nvar _metrics = _interopRequireDefault(__webpack_require__(/*! ./metrics */ \"./node_modules/@webex/internal-plugin-device/dist/metrics.js\"));\nvar _constants = __webpack_require__(/*! ./constants */ \"./node_modules/@webex/internal-plugin-device/dist/constants.js\");\nvar _featuresModel = _interopRequireDefault(__webpack_require__(/*! ./features/features-model */ \"./node_modules/@webex/internal-plugin-device/dist/features/features-model.js\"));\nvar _ipNetworkDetector = _interopRequireDefault(__webpack_require__(/*! ./ipNetworkDetector */ \"./node_modules/@webex/internal-plugin-device/dist/ipNetworkDetector.js\"));\nvar _types = __webpack_require__(/*! ./types */ \"./node_modules/@webex/internal-plugin-device/dist/types.js\");\nvar _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _obj; // Internal Dependencies\nfunction ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor2(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor2(t, r)); }); } return e; }\n/**\n * Determine if the plugin should be initialized based on cached storage.\n *\n * @returns {boolean} - If the device is ephemeral.\n */\nfunction decider() {\n return !this.config.ephemeral;\n}\nvar Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)('@'), _dec2 = (0, _webexCore.waitForValue)('@'), _dec3 = (0, _webexCore.waitForValue)('@'), _dec4 = (0, _webexCore.waitForValue)('@'), _dec5 = (0, _common.deprecated)('device#markUrlFailedAndGetNew(): Use services#markFailedUrl()'), _dec6 = (0, _webexCore.persist)('@', decider), (_obj = {\n // Ampersand property members.\n\n namespace: 'Device',\n // Allow for extra properties to prevent the plugin from failing due to\n // **WDM** service DTO changes.\n extraProperties: 'allow',\n idAttribute: 'url',\n children: {\n /**\n * The class object that contains all of the feature collections.\n *\n * @type {FeaturesModel}\n */\n features: _featuresModel.default,\n /**\n * Helper class for detecting what IP network version (ipv4, ipv6) we're on.\n *\n * @type {IpNetworkDetector}\n */\n ipNetworkDetector: _ipNetworkDetector.default\n },\n /**\n * A collection of device properties mostly assigned by the retrieved DTO from\n * the **WDM** service that are mapped against the ampersand properties.\n *\n * @type {Object}\n */\n props: {\n /**\n * This property determines whether or not giphy support is enabled.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n clientMessagingGiphy: 'string',\n /**\n * This property should store the company name.\n *\n * @type {string}\n */\n customerCompanyName: 'string',\n /**\n * This property should store the logo url.\n *\n * @type {string}\n */\n customerLogoUrl: 'string',\n /**\n * This property doesn't have any real values, but is sent during device\n * refresh to prevent the **wdm** service from falling back to an iOS device\n * type.\n *\n * @type {string}\n */\n deviceType: 'string',\n /**\n * This property should store the help url.\n *\n * @type {string}\n */\n helpUrl: 'string',\n /**\n * This property should store the intranet inactivity timer duration.\n *\n * @type {number}\n */\n intranetInactivityDuration: 'number',\n /**\n * This property stores the url required to validate if the device is able\n * to actively reach the intranet network.\n *\n * @type {string}\n */\n intranetInactivityCheckUrl: 'string',\n /**\n * This property stores the inactivity timer duration, and could possibly\n * deprecate the `intranetInactivityDuration` property.\n *\n * @type {number}\n */\n inNetworkInactivityDuration: 'number',\n /**\n * This property stores the ECM (external content management) enabled value\n * for the whole organization.\n *\n * @type {boolean}\n */\n ecmEnabledForAllUsers: ['boolean', false, false],\n /**\n * This property stores an array of ECM (external content management)\n * providers that are currently available.\n *\n * @returns {Array<string>}\n */\n ecmSupportedStorageProviders: ['array', false, function () {\n return [];\n }],\n /**\n * This property stores the modification time value retrieved from the\n * **WDM** endpoint formatted as ISO 8601.\n *\n * @type {string}\n */\n modificationTime: 'string',\n /**\n * This property stores the navigation bar color.\n *\n * @type {string}\n */\n navigationBarColor: 'string',\n /**\n * This property stores the partner company's name when available.\n *\n * @type {string}\n */\n partnerCompanyName: 'string',\n /**\n * This property stores the partner company's logo when available.\n *\n * @type {string}\n */\n partnerLogoUrl: 'string',\n /**\n * This property stores the availability of people data from the **WDM**\n * service.\n *\n * @type {boolean}\n */\n peopleInsightsEnabled: 'boolean',\n /**\n * This property stores the reporting site's description when available.\n *\n * @type {string}\n */\n reportingSiteDesc: 'string',\n /**\n * This property stores the reporting site's access url when available.\n *\n * @type {string}\n */\n reportingSiteUrl: 'string',\n /**\n * This property stores the encryption key url when available.\n *\n * @type {string}\n */\n searchEncryptionKeyUrl: 'string',\n /**\n * This property stores the availability of support-provided text from the\n * **WDM** service.\n *\n * @type {boolean}\n */\n showSupportText: 'boolean',\n /**\n * This property stores the support provider's company name when available.\n *\n * @type {string}\n */\n supportProviderCompanyName: 'string',\n /**\n * This property stores the support provider's logo url when available.\n *\n * @type {string}\n */\n supportProviderLogoUrl: 'string',\n /**\n * This property stores the device's url retrieved from a registration\n * request. This property gets set via the initial registration process by a\n * `this.set()` method.\n *\n * @type {string}\n */\n url: 'string',\n /**\n * This property stores the device's userId uuid value, which can also be\n * derived from the device's registerd user's userId retrieved from\n * the **Hydra** service.\n *\n * @type {string}\n */\n userId: 'string',\n /**\n * This property stores whether or not file sharing is enabled\n *\n * @type {'BLOCK_BOTH' | 'BLOCK_UPLOAD'}\n */\n webFileShareControl: 'string',\n /**\n * This property stores the current web socket url used by the registered\n * device.\n *\n * @type {string}\n */\n webSocketUrl: 'string',\n /**\n * This property stores the value indicating whether or not white board file\n * sharing is enabled for the current device.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n whiteboardFileShareControl: 'string'\n },\n /**\n * A list of derived properties that populate based when their parent data\n * available via the device's properties.\n *\n * @type {Object}\n */\n derived: {\n /**\n * This property determines if the current device is registered.\n *\n * @type {boolean}\n */\n registered: {\n deps: ['url'],\n /**\n * Checks if the device is registered by validating that the url exists.\n * Amperstand does not allow this to method to be written as an arrow\n * function.\n *\n * @returns {boolean}\n */\n fn: function fn() {\n return !!this.url;\n }\n }\n },\n /**\n * Stores timer data as well as other state details.\n *\n * @type {Object}\n */\n session: {\n /**\n * This property stores the logout timer object\n *\n * @type {any}\n */\n logoutTimer: 'any',\n /**\n * This property stores the date for the last activity the user made\n * with the current device.\n *\n * @type {number}\n */\n lastUserActivityDate: 'number',\n /**\n * This property stores whether or not the reachability check has been\n * performed to prevent the reachability check from performing its\n * operation more than once after a successful check.\n *\n * @returns {boolean}\n */\n isReachabilityChecked: ['boolean', false, false],\n /**\n * This property stores whether or not the next refresh or register request should request energy forecast data\n * in order to prevent over fetching energy forecasts\n *\n * @type {boolean}\n */\n energyForecastConfig: 'boolean',\n /**\n * This property stores whether or not the current device is in a meeting\n * to prevent an unneeded timeout of a meeting due to inactivity.\n *\n * @type {boolean}\n */\n isInMeeting: 'boolean',\n /**\n * This property identifies if the device is currently in network to prevent\n * the `resetLogoutTimer()` method from being called repeatedly once its\n * known client is connected to the organization's internal network.\n *\n * @type {boolean}\n */\n isInNetwork: 'boolean'\n },\n // Event method members.\n /**\n * Trigger meeting started event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingStarted: function meetingStarted() {\n this.webex.trigger('meeting started');\n },\n /**\n * Trigger meeting ended event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingEnded: function meetingEnded() {\n this.webex.trigger('meeting ended');\n },\n /**\n * Set the value of energy forecast config for the current registered device.\n * @param {boolean} [energyForecastConfig=false] - fetch an energy forecast on the next refresh/register\n * @returns {void}\n */\n setEnergyForecastConfig: function setEnergyForecastConfig() {\n var energyForecastConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n this.energyForecastConfig = energyForecastConfig;\n },\n refresh: function refresh() {\n var _this = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: refreshing');\n\n // Validate that the device can be registered.\n return this.canRegister().then(function () {\n // Validate if the device is not registered and register instead.\n if (!_this.registered) {\n _this.logger.info('device: device not registered, registering');\n return _this.register(deviceRegistrationOptions);\n }\n\n // Merge body configurations, overriding defaults.\n var body = _objectSpread(_objectSpread({}, _this.serialize()), _this.config.body ? _this.config.body : {});\n\n // Remove unneeded properties from the body object.\n delete body.features;\n delete body.mediaCluster;\n delete body.etag;\n\n // Append a ttl value if the device is marked as ephemeral.\n if (_this.config.ephemeral) {\n body.ttl = _this.config.ephemeralDeviceTTL;\n }\n\n // Merge header configurations, overriding defaults.\n var headers = _objectSpread(_objectSpread(_objectSpread({}, _this.config.defaults.headers ? _this.config.defaults.headers : {}), _this.config.headers ? _this.config.headers : {}), _this.etag ? {\n 'If-None-Match': _this.etag\n } : {});\n var _deviceRegistrationOp = deviceRegistrationOptions.includeDetails,\n includeDetails = _deviceRegistrationOp === void 0 ? _types.CatalogDetails.all : _deviceRegistrationOp;\n var requestId = _uuid.default.v4();\n _this.set('refresh-request-id', requestId);\n return _this.request({\n method: 'PUT',\n uri: _this.url,\n body: body,\n headers: headers,\n qs: {\n includeUpstreamServices: \"\".concat(includeDetails).concat(_this.config.energyForecast && _this.energyForecastConfig ? ',energyforecast' : '')\n }\n }).then(function (response) {\n // If we've signed out in the mean time, the request ID will have changed\n if (_this.get('refresh-request-id') !== requestId) {\n _this.logger.info('device: refresh request ID mismatch, ignoring response');\n return _promise.default.resolve();\n }\n return _this.processRegistrationSuccess(response);\n }).catch(function (reason) {\n // Handle a 404 error, which indicates that the device is no longer\n // valid and needs to be registered as a new device.\n if (reason.statusCode === 404) {\n _this.logger.info('device: refresh failed, device is not valid');\n _this.logger.info('device: attempting to register a new device');\n _this.clear();\n return _this.register(deviceRegistrationOptions);\n }\n return _promise.default.reject(reason);\n });\n });\n },\n /**\n * Fetches the web devices and deletes the third of them which are not recent devices in use\n * @returns {Promise<void, Error>}\n */\n deleteDevices: function deleteDevices() {\n var _this2 = this;\n // Fetch devices with a GET request\n return this.request({\n method: 'GET',\n service: 'wdm',\n resource: 'devices'\n }).then(function (response) {\n var devices = response.body.devices;\n var _this2$_getBody = _this2._getBody(),\n deviceType = _this2$_getBody.deviceType;\n\n // Filter devices of type deviceType\n var webDevices = devices.filter(function (item) {\n return item.deviceType === deviceType;\n });\n var sortedDevices = (0, _lodash.orderBy)(webDevices, [function (item) {\n return new Date(item.modificationTime);\n }]);\n\n // If there are more than two devices, delete the last third\n if (sortedDevices.length > 2) {\n var totalItems = sortedDevices.length;\n var countToDelete = Math.ceil(totalItems / 3);\n var urlsToDelete = sortedDevices.slice(0, countToDelete).map(function (item) {\n return item.url;\n });\n return _promise.default.race(urlsToDelete.map(function (url) {\n return _this2.request({\n uri: url,\n method: 'DELETE'\n });\n }));\n }\n return _promise.default.resolve();\n }).catch(function (error) {\n _this2.logger.error('Failed to retrieve devices:', error);\n return _promise.default.reject(error);\n });\n },\n register: function register() {\n var _this3 = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: registering');\n this.webex.internal.newMetrics.callDiagnosticMetrics.setDeviceInfo(this);\n\n // Validate that the device can be registered.\n return this.canRegister().then(function () {\n // Validate if the device is already registered and refresh instead.\n if (_this3.registered) {\n _this3.logger.info('device: device already registered, refreshing');\n return _this3.refresh(deviceRegistrationOptions);\n }\n return _this3._registerInternal(deviceRegistrationOptions).catch(function (error) {\n var _error$body;\n if ((error === null || error === void 0 ? void 0 : (_error$body = error.body) === null || _error$body === void 0 ? void 0 : _error$body.message) === 'User has excessive device registrations') {\n return _this3.deleteDevices().then(function () {\n return _this3._registerInternal(deviceRegistrationOptions);\n });\n }\n throw error;\n });\n });\n },\n _getBody: function _getBody() {\n return _objectSpread(_objectSpread({}, this.config.defaults.body ? this.config.defaults.body : {}), this.config.body ? this.config.body : {});\n },\n _registerInternal: function _registerInternal() {\n var _this4 = this;\n var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger.info('device: making registration request');\n\n // Merge body configurations, overriding defaults.\n var body = this._getBody();\n\n // Merge header configurations, overriding defaults.\n var headers = _objectSpread(_objectSpread({}, this.config.defaults.headers ? this.config.defaults.headers : {}), this.config.headers ? this.config.headers : {});\n\n // Append a ttl value if the device is marked as ephemeral\n if (this.config.ephemeral) {\n body.ttl = this.config.ephemeralDeviceTTL;\n }\n this.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.request'\n });\n var _deviceRegistrationOp2 = deviceRegistrationOptions.includeDetails,\n includeDetails = _deviceRegistrationOp2 === void 0 ? _types.CatalogDetails.all : _deviceRegistrationOp2;\n var requestId = _uuid.default.v4();\n this.set('register-request-id', requestId);\n\n // This will be replaced by a `create()` method.\n return this.request({\n method: 'POST',\n service: 'wdm',\n resource: 'devices',\n body: body,\n headers: headers,\n qs: {\n includeUpstreamServices: \"\".concat(includeDetails).concat(this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : '')\n }\n }).catch(function (error) {\n _this4.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response'\n });\n throw error;\n }).then(function (response) {\n // If we've signed out in the mean time, the request ID will have changed\n if (_this4.get('register-request-id') !== requestId) {\n _this4.logger.info('device: register request ID mismatch, ignoring response');\n return _promise.default.resolve();\n }\n\n // Do not add any processing of response above this as that will affect timestamp\n _this4.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response'\n });\n _this4.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_SUCCESSFUL);\n return _this4.processRegistrationSuccess(response);\n }).catch(function (error) {\n _this4.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_FAILED, {\n fields: {\n error: error\n }\n });\n throw error;\n });\n },\n unregister: function unregister() {\n var _this5 = this;\n this.logger.info('device: unregistering');\n if (!this.registered) {\n this.logger.warn('device: not registered');\n return _promise.default.resolve();\n }\n return this.request({\n uri: this.url,\n method: 'DELETE'\n }).then(function () {\n return _this5.clear();\n }).catch(function (reason) {\n if (reason.statusCode === 404) {\n _this5.logger.info('device: 404 when deleting device, device is already deleted, clearing device');\n _this5.clear();\n }\n throw reason;\n });\n },\n /* eslint-enable require-jsdoc */\n // Helper method members\n /**\n * Determine if registration methods can be performed. This method utilizes\n * the `services` plugin to confirm if the appropriate service urls are\n * available for device registration.\n *\n * @returns {Promise<void, Error>}\n */\n canRegister: function canRegister() {\n this.logger.info('device: validating if registration can occur');\n\n // Destructure the services plugin for ease of reference.\n var services = this.webex.internal.services;\n\n // Wait for the postauth catalog to populate.\n return services.waitForCatalog('postauth', this.config.canRegisterWaitDuration).then(function () {\n return (\n // Validate that the service exists after waiting for the catalog.\n services.get('wdm') ? _promise.default.resolve() : _promise.default.reject(new Error(['device: cannot register,', \"'wdm' service is not available from the postauth catalog\"].join(' ')))\n );\n });\n },\n /**\n * Check if the device can currently reach the inactivity check url.\n *\n * @returns {Promise<void, Error>}\n */\n checkNetworkReachability: function checkNetworkReachability() {\n var _this6 = this;\n this.logger.info('device: checking network reachability');\n\n // Validate if the device has been checked and reset the logout timer.\n if (this.isReachabilityChecked) {\n return _promise.default.resolve(this.resetLogoutTimer());\n }\n this.isReachabilityChecked = true;\n\n // Validate if the device has a intranet checking url.\n if (!this.intranetInactivityCheckUrl) {\n this.isInNetwork = false;\n return _promise.default.resolve(this.resetLogoutTimer());\n }\n\n // Clear unnecessary headers for reachability request.\n var headers = {\n 'cisco-no-http-redirect': null,\n 'spark-user-agent': null,\n trackingid: null\n };\n\n // Send the network reachability request.\n return this.request({\n headers: headers,\n method: 'GET',\n uri: this.intranetInactivityCheckUrl\n }).then(function () {\n _this6.isInNetwork = true;\n return _promise.default.resolve(_this6.resetLogoutTimer());\n }).catch(function () {\n _this6.logger.info('device: did not reach ping endpoint');\n _this6.logger.info('device: triggering off-network timer');\n _this6.isInNetwork = false;\n return _promise.default.resolve(_this6.resetLogoutTimer());\n });\n },\n /**\n * Clears the registration ttl value if available.\n *\n * @param {Object} options - Values to be cleared.\n * @returns {void}\n */\n clear: function clear() {\n this.logger.info('device: clearing registered device');\n\n // Prototype the extended class in order to preserve the parent member.\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n (0, _apply.default)(_webexCore.WebexPlugin.prototype.clear, this, args);\n },\n /**\n * Get the current websocket url with the appropriate priority host.\n *\n * @param {boolean} [wait=false] - Willing to wait on a valid url.\n * @returns {Promise<string, Error>} - The priority-mapped web socket url.\n */\n getWebSocketUrl: function getWebSocketUrl() {\n var _this7 = this;\n var wait = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n this.logger.info('device: getting the current websocket url');\n\n // Destructure the services plugin for ease of reference.\n var services = this.webex.internal.services;\n\n // Validate if the method should wait for registration.\n if (wait) {\n return this.waitForRegistration().then(function () {\n return services.convertUrlToPriorityHostUrl(_this7.webSocketUrl);\n }).catch(function (error) {\n _this7.logger.warn(error.message);\n return _promise.default.reject(new Error('device: failed to get the current websocket url'));\n });\n }\n\n // Validate if the device is registered.\n if (!this.registered) {\n return _promise.default.reject(new Error('device: cannot get websocket url, device is not registered'));\n }\n\n // Attempt to collect the priority-host-mapped web socket URL.\n var wsUrl = services.convertUrlToPriorityHostUrl(this.webSocketUrl);\n\n // Validate that the url was collected.\n if (wsUrl) {\n return _promise.default.resolve(wsUrl);\n }\n return _promise.default.reject(new Error('device: failed to get the current websocket url'));\n },\n /**\n * Process a successful device registration.\n *\n * @param {Object} response - response object from registration success.\n * @returns {void}\n */\n processRegistrationSuccess: function processRegistrationSuccess(response) {\n var _this8 = this;\n this.logger.info('device: received registration payload');\n\n // Clone the response body for service cleaning.\n var body = _objectSpread({}, response.body);\n\n // Clean service data.\n delete body.services;\n delete body.serviceHostMap;\n var _ref = response.headers || {},\n etag = _ref.etag;\n if (this.etag && etag && this.etag === etag) {\n // If current etag matches the previous one and we have sent\n // If-None-Match header the developer and entitlement feature\n // toggles will not be returned\n var features = body.features;\n delete body.features;\n // When using the etag feature cache, user and entitlement features are still returned\n this.features.user.reset(features.user);\n this.features.entitlement.reset(features.entitlement);\n }\n\n // Assign the recieved DTO from **WDM** to this device.\n this.set(body);\n\n // Assign the new etag to this device.\n this.set({\n etag: etag\n });\n\n // Validate if device is ephemeral and setup refresh timer.\n if (this.config.ephemeral) {\n this.logger.info('device: enqueuing device refresh');\n var delay = (this.config.ephemeralDeviceTTL / 2 + 60) * 1000;\n this.refreshTimer = (0, _commonTimers.safeSetTimeout)(function () {\n return _this8.refresh();\n }, delay);\n }\n\n // Emit the registration:success event.\n this.trigger(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, this);\n },\n /**\n * Reset the current local logout timer for the registered device if\n * registered.\n *\n * @returns {void}\n */\n resetLogoutTimer: function resetLogoutTimer() {\n this.logger.info('device: resetting logout timer');\n\n // Clear current logout timer.\n clearTimeout(this.logoutTimer);\n\n // Remove last activity date event listener.\n this.off('change:lastUserActivityDate');\n\n // Remove the logout timer.\n this.unset('logoutTimer');\n\n // Validate if the device is currently in a meeting and is configured to\n // required inactivity enforcement.\n if (!this.isInMeeting && this.config.enableInactivityEnforcement && this.isReachabilityChecked) {\n if (this.isInNetwork) {\n this.setLogoutTimer(this.inNetworkInactivityDuration);\n } else {\n this.setLogoutTimer(this.intranetInactivityDuration);\n }\n }\n },\n /**\n * Set the value of the logout timer for the current registered device.\n *\n * @param {number} duration - Value in seconds of the new logout timer.\n * @returns {void}\n */\n setLogoutTimer: function setLogoutTimer(duration) {\n var _this9 = this;\n this.logger.info('device: setting logout timer');\n if (!duration || duration <= 0) {\n return;\n }\n\n // Setup user activity date event listener.\n this.on('change:lastUserActivityDate', function () {\n _this9.resetLogoutTimer();\n });\n\n // Initialize a new timer.\n this.logoutTimer = (0, _commonTimers.safeSetTimeout)(function () {\n _this9.webex.logout();\n }, duration * 1000);\n },\n /**\n * Wait for the device to be registered.\n *\n * @param {number} [timeout=10] - The maximum duration to wait, in seconds.\n * @returns {Promise<void, Error>}\n */\n waitForRegistration: function waitForRegistration() {\n var _this10 = this;\n var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;\n this.logger.info('device: waiting for registration');\n return new _promise.default(function (resolve, reject) {\n if (_this10.registered) {\n resolve();\n }\n var timeoutTimer = (0, _commonTimers.safeSetTimeout)(function () {\n return reject(new Error('device: timeout occured while waiting for registration'));\n }, timeout * 1000);\n _this10.once(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, function () {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n markUrlFailedAndGetNew: function markUrlFailedAndGetNew(url) {\n return _promise.default.resolve(this.webex.internal.services.markFailedUrl(url));\n },\n initialize: function initialize() {\n var _this11 = this;\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n // Prototype the extended class in order to preserve the parent member.\n (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args);\n\n // Initialize feature events and listeners.\n _constants.FEATURE_COLLECTION_NAMES.forEach(function (collectionName) {\n _this11.features.on(\"change:\".concat(collectionName), function (model, value, options) {\n _this11.trigger('change', _this11, options);\n _this11.trigger('change:features', _this11, _this11.features, options);\n });\n });\n\n // Initialize network reachability checking event for url change.\n this.on('change:intranetInactivityCheckUrl', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:intranetInactivityDuration', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:inNetworkInactivityDuration', function () {\n _this11.checkNetworkReachability();\n });\n\n // Initialize listener for activity checking.\n this.listenTo(this.webex, 'user-activity', function () {\n _this11.lastUserActivityDate = (0, _now.default)();\n });\n\n // Initialize listener for meeting started event.\n this.listenTo(this.webex, 'meeting started', function () {\n _this11.isInMeeting = true;\n _this11.resetLogoutTimer();\n });\n\n // Initialize listener for meeting ended event.\n this.listenTo(this.webex, 'meeting ended', function () {\n _this11.isInMeeting = false;\n _this11.resetLogoutTimer();\n });\n } /* eslint-enable require-jsdoc */,\n version: \"3.8.0-next.12\"\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"refresh\", [_common.oneFlight, _dec], (0, _getOwnPropertyDescriptor.default)(_obj, \"refresh\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"register\", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, \"register\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"_registerInternal\", [_common.oneFlight, _dec3], (0, _getOwnPropertyDescriptor.default)(_obj, \"_registerInternal\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"unregister\", [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor.default)(_obj, \"unregister\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"markUrlFailedAndGetNew\", [_dec5], (0, _getOwnPropertyDescriptor.default)(_obj, \"markUrlFailedAndGetNew\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"initialize\", [_dec6], (0, _getOwnPropertyDescriptor.default)(_obj, \"initialize\"), _obj)), _obj)));\nvar _default = exports[\"default\"] = Device;\n//# sourceMappingURL=device.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/@webex/internal-plugin-device/dist/device.js?");
|
|
12053
12053
|
|
|
12054
12054
|
/***/ }),
|
|
12055
12055
|
|
|
@@ -12126,7 +12126,7 @@ eval("\n\nvar _Reflect$construct = __webpack_require__(/*! @babel/runtime-corejs
|
|
|
12126
12126
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12127
12127
|
|
|
12128
12128
|
"use strict";
|
|
12129
|
-
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/regenerator */ \"../../../node_modules/@babel/runtime-corejs2/regenerator/index.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js\"));\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\n/*!\n * Copyright (c) 2015-2023 Cisco Systems, Inc. See LICENSE file.\n */\n\nvar STATE = {\n INITIAL: 'initial',\n IN_PROGRESS: 'in-progress',\n IDLE: 'idle'\n};\n\n/**\n * @class\n */\nvar IpNetworkDetector = _webexCore.WebexPlugin.extend({\n idAttribute: 'IpNetworkDetectorId',\n namespace: 'Device',\n props: {\n firstIpV4: ['number', true, -1],\n // time [ms] it took to receive first IPv4 candidate\n firstIpV6: ['number', true, -1],\n // time [ms] it took to receive first IPv6 candidate\n firstMdns: ['number', true, -1],\n // time [ms] it took to receive first mDNS candidate\n totalTime: ['number', true, -1],\n // total time [ms] it took to do the last IP network detection\n state: ['string', true, STATE.INITIAL],\n pendingDetection: ['object', false, undefined]\n },\n derived: {\n /**\n * True if we know we're on an IPv4 network,\n * False if we know that we are not on an IPv4 network,\n * undefined if we are not sure\n */\n supportsIpV4: {\n deps: ['firstIpV4', 'firstIpV6', 'firstMdns', 'totalTime'],\n /**\n * Function for calculating the value of supportsIpV4 prop\n * @returns {boolean | undefined}\n */\n fn: function fn() {\n if (this.firstIpV4 >= 0) {\n return true;\n }\n if (this.totalTime < 0) {\n // we haven't completed the detection, yet\n return undefined;\n }\n if (this.receivedOnlyMDnsCandidates()) {\n return undefined;\n }\n return false;\n }\n },\n /**\n * True if we know we're on an IPv6 network,\n * False if we know that we are not on an IPv6 network,\n * undefined if we are not sure\n */\n supportsIpV6: {\n deps: ['firstIpV4', 'firstIpV6', 'firstMdns', 'totalTime'],\n /**\n * Function for calculating the value of supportsIpV6 prop\n * @returns {boolean | undefined}\n */\n fn: function fn() {\n if (this.firstIpV6 >= 0) {\n return true;\n }\n if (this.totalTime < 0) {\n // we haven't completed the detection, yet\n return undefined;\n }\n if (this.receivedOnlyMDnsCandidates()) {\n return undefined;\n }\n return false;\n }\n }\n },\n /**\n * Returns true if we have received only mDNS candidates - browsers usually do that if we don't have any user media permissions\n *\n * @private\n * @returns {boolean}\n */\n receivedOnlyMDnsCandidates: function receivedOnlyMDnsCandidates() {\n return this.totalTime >= 0 && this.firstMdns >= 0 && this.firstIpV4 < 0 && this.firstIpV6 < 0;\n },\n /**\n *\n * @param {RTCPeerConnection} pc Peer connection to use\n * @private\n * @returns {Promise<void>}\n */\n gatherLocalCandidates: function gatherLocalCandidates(pc) {\n var _this = this;\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {\n return _regenerator.default.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n return _context.abrupt(\"return\", new _promise.default(function (resolve, reject) {\n var done = false;\n _this.firstIpV4 = -1;\n _this.firstIpV6 = -1;\n _this.firstMdns = -1;\n _this.totalTime = -1;\n var startTime = performance.now();\n var doneGatheringIceCandidates = function doneGatheringIceCandidates() {\n if (done) {\n return;\n }\n done = true;\n _this.totalTime = performance.now() - startTime;\n resolve();\n };\n pc.onicecandidate = function (event) {\n var _event$candidate;\n if ((_event$candidate = event.candidate) !== null && _event$candidate !== void 0 && _event$candidate.address) {\n if (event.candidate.address.endsWith('.local')) {\n // if we don't have camera/mic permissions, browser just gives us mDNS candidates\n if (_this.firstMdns === -1) {\n _this.firstMdns = performance.now() - startTime;\n }\n } else if (event.candidate.address.includes(':')) {\n if (_this.firstIpV6 === -1) {\n _this.firstIpV6 = performance.now() - startTime;\n }\n } else if (_this.firstIpV4 === -1) {\n _this.firstIpV4 = performance.now() - startTime;\n }\n if (_this.firstIpV4 >= 0 && _this.firstIpV6 >= 0) {\n // if we've got both ipv4 and ipv6 candidates, there is no need to wait for any more candidates, we can resolve now\n resolve();\n }\n } else if (event.candidate === null) {\n doneGatheringIceCandidates();\n }\n };\n pc.onicegatheringstatechange = function () {\n if (pc.iceGatheringState === 'complete') {\n doneGatheringIceCandidates();\n }\n };\n pc.createDataChannel('data');\n pc.createOffer().then(function (offer) {\n return pc.setLocalDescription(offer);\n }).catch(function (e) {\n _this.webex.logger.error('Failed to detect ip network version:', e);\n reject(e);\n });\n }));\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }))();\n },\n /**\n * Detects if we are on IPv4 and/or IPv6 network. Once it resolves, read the\n * supportsIpV4 and supportsIpV6 props to find out the result.\n *\n * @param {boolean} force - if false, the detection will only be done if we haven't managed to get any meaningful results yet\n * @returns {Promise<void>}\n */\n detect: function detect() {\n var _arguments = arguments,\n _this2 = this;\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {\n var force, results, pc, forceParam;\n return _regenerator.default.wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n force = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : false;\n if (!(_this2.state === STATE.IN_PROGRESS)) {\n _context2.next = 4;\n break;\n }\n _this2.pendingDetection = {\n force: force\n };\n return _context2.abrupt(\"return\");\n case 4:\n if (!(!force && _this2.state !== STATE.INITIAL && !_this2.receivedOnlyMDnsCandidates())) {\n _context2.next = 6;\n break;\n }\n return _context2.abrupt(\"return\");\n case 6:\n _context2.prev = 6;\n _this2.state = STATE.IN_PROGRESS;\n pc = new RTCPeerConnection();\n _context2.next = 11;\n return _this2.gatherLocalCandidates(pc);\n case 11:\n results = _context2.sent;\n case 12:\n _context2.prev = 12;\n pc.close();\n _this2.state = STATE.IDLE;\n return _context2.finish(12);\n case 16:\n if (_this2.pendingDetection) {\n forceParam = _this2.pendingDetection.force;\n _this2.pendingDetection = undefined;\n _this2.detect(forceParam);\n }\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[6,, 12, 16]]);\n }))();\n },\n version: \"3.8.0-next.
|
|
12129
|
+
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/regenerator */ \"../../../node_modules/@babel/runtime-corejs2/regenerator/index.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js\"));\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\n/*!\n * Copyright (c) 2015-2023 Cisco Systems, Inc. See LICENSE file.\n */\n\nvar STATE = {\n INITIAL: 'initial',\n IN_PROGRESS: 'in-progress',\n IDLE: 'idle'\n};\n\n/**\n * @class\n */\nvar IpNetworkDetector = _webexCore.WebexPlugin.extend({\n idAttribute: 'IpNetworkDetectorId',\n namespace: 'Device',\n props: {\n firstIpV4: ['number', true, -1],\n // time [ms] it took to receive first IPv4 candidate\n firstIpV6: ['number', true, -1],\n // time [ms] it took to receive first IPv6 candidate\n firstMdns: ['number', true, -1],\n // time [ms] it took to receive first mDNS candidate\n totalTime: ['number', true, -1],\n // total time [ms] it took to do the last IP network detection\n state: ['string', true, STATE.INITIAL],\n pendingDetection: ['object', false, undefined]\n },\n derived: {\n /**\n * True if we know we're on an IPv4 network,\n * False if we know that we are not on an IPv4 network,\n * undefined if we are not sure\n */\n supportsIpV4: {\n deps: ['firstIpV4', 'firstIpV6', 'firstMdns', 'totalTime'],\n /**\n * Function for calculating the value of supportsIpV4 prop\n * @returns {boolean | undefined}\n */\n fn: function fn() {\n if (this.firstIpV4 >= 0) {\n return true;\n }\n if (this.totalTime < 0) {\n // we haven't completed the detection, yet\n return undefined;\n }\n if (this.receivedOnlyMDnsCandidates()) {\n return undefined;\n }\n return false;\n }\n },\n /**\n * True if we know we're on an IPv6 network,\n * False if we know that we are not on an IPv6 network,\n * undefined if we are not sure\n */\n supportsIpV6: {\n deps: ['firstIpV4', 'firstIpV6', 'firstMdns', 'totalTime'],\n /**\n * Function for calculating the value of supportsIpV6 prop\n * @returns {boolean | undefined}\n */\n fn: function fn() {\n if (this.firstIpV6 >= 0) {\n return true;\n }\n if (this.totalTime < 0) {\n // we haven't completed the detection, yet\n return undefined;\n }\n if (this.receivedOnlyMDnsCandidates()) {\n return undefined;\n }\n return false;\n }\n }\n },\n /**\n * Returns true if we have received only mDNS candidates - browsers usually do that if we don't have any user media permissions\n *\n * @private\n * @returns {boolean}\n */\n receivedOnlyMDnsCandidates: function receivedOnlyMDnsCandidates() {\n return this.totalTime >= 0 && this.firstMdns >= 0 && this.firstIpV4 < 0 && this.firstIpV6 < 0;\n },\n /**\n *\n * @param {RTCPeerConnection} pc Peer connection to use\n * @private\n * @returns {Promise<void>}\n */\n gatherLocalCandidates: function gatherLocalCandidates(pc) {\n var _this = this;\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {\n return _regenerator.default.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n return _context.abrupt(\"return\", new _promise.default(function (resolve, reject) {\n var done = false;\n _this.firstIpV4 = -1;\n _this.firstIpV6 = -1;\n _this.firstMdns = -1;\n _this.totalTime = -1;\n var startTime = performance.now();\n var doneGatheringIceCandidates = function doneGatheringIceCandidates() {\n if (done) {\n return;\n }\n done = true;\n _this.totalTime = performance.now() - startTime;\n resolve();\n };\n pc.onicecandidate = function (event) {\n var _event$candidate;\n if ((_event$candidate = event.candidate) !== null && _event$candidate !== void 0 && _event$candidate.address) {\n if (event.candidate.address.endsWith('.local')) {\n // if we don't have camera/mic permissions, browser just gives us mDNS candidates\n if (_this.firstMdns === -1) {\n _this.firstMdns = performance.now() - startTime;\n }\n } else if (event.candidate.address.includes(':')) {\n if (_this.firstIpV6 === -1) {\n _this.firstIpV6 = performance.now() - startTime;\n }\n } else if (_this.firstIpV4 === -1) {\n _this.firstIpV4 = performance.now() - startTime;\n }\n if (_this.firstIpV4 >= 0 && _this.firstIpV6 >= 0) {\n // if we've got both ipv4 and ipv6 candidates, there is no need to wait for any more candidates, we can resolve now\n resolve();\n }\n } else if (event.candidate === null) {\n doneGatheringIceCandidates();\n }\n };\n pc.onicegatheringstatechange = function () {\n if (pc.iceGatheringState === 'complete') {\n doneGatheringIceCandidates();\n }\n };\n pc.createDataChannel('data');\n pc.createOffer().then(function (offer) {\n return pc.setLocalDescription(offer);\n }).catch(function (e) {\n _this.webex.logger.error('Failed to detect ip network version:', e);\n reject(e);\n });\n }));\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }))();\n },\n /**\n * Detects if we are on IPv4 and/or IPv6 network. Once it resolves, read the\n * supportsIpV4 and supportsIpV6 props to find out the result.\n *\n * @param {boolean} force - if false, the detection will only be done if we haven't managed to get any meaningful results yet\n * @returns {Promise<void>}\n */\n detect: function detect() {\n var _arguments = arguments,\n _this2 = this;\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {\n var force, results, pc, forceParam;\n return _regenerator.default.wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n force = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : false;\n if (!(_this2.state === STATE.IN_PROGRESS)) {\n _context2.next = 4;\n break;\n }\n _this2.pendingDetection = {\n force: force\n };\n return _context2.abrupt(\"return\");\n case 4:\n if (!(!force && _this2.state !== STATE.INITIAL && !_this2.receivedOnlyMDnsCandidates())) {\n _context2.next = 6;\n break;\n }\n return _context2.abrupt(\"return\");\n case 6:\n _context2.prev = 6;\n _this2.state = STATE.IN_PROGRESS;\n pc = new RTCPeerConnection();\n _context2.next = 11;\n return _this2.gatherLocalCandidates(pc);\n case 11:\n results = _context2.sent;\n case 12:\n _context2.prev = 12;\n pc.close();\n _this2.state = STATE.IDLE;\n return _context2.finish(12);\n case 16:\n if (_this2.pendingDetection) {\n forceParam = _this2.pendingDetection.force;\n _this2.pendingDetection = undefined;\n _this2.detect(forceParam);\n }\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[6,, 12, 16]]);\n }))();\n },\n version: \"3.8.0-next.12\"\n});\nvar _default = exports[\"default\"] = IpNetworkDetector;\n//# sourceMappingURL=ipNetworkDetector.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/@webex/internal-plugin-device/dist/ipNetworkDetector.js?");
|
|
12130
12130
|
|
|
12131
12131
|
/***/ }),
|
|
12132
12132
|
|
|
@@ -12181,7 +12181,7 @@ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-co
|
|
|
12181
12181
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12182
12182
|
|
|
12183
12183
|
"use strict";
|
|
12184
|
-
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/regenerator */ \"../../../node_modules/@babel/runtime-corejs2/regenerator/index.js\"));\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js\"));\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! uuid */ \"../../../node_modules/uuid/index.js\"));\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nvar Support = _webexCore.WebexPlugin.extend({\n namespace: 'Support',\n getFeedbackUrl: function getFeedbackUrl(options) {\n options = options || {};\n return this.request({\n method: 'POST',\n api: 'conversation',\n resource: 'users/deskFeedbackUrl',\n body: (0, _lodash.defaults)(options, {\n appVersion: this.config.appVersion,\n appType: this.config.appType,\n feedbackId: options.feedbackId || _uuid.default.v4(),\n languageCode: this.config.languageCode\n })\n }).then(function (res) {\n return res.body.url;\n });\n },\n getSupportUrl: function getSupportUrl() {\n return this.webex.request({\n method: 'GET',\n api: 'conversation',\n resource: 'users/deskSupportUrl',\n qs: {\n languageCode: this.config.languageCode\n }\n }).then(function (res) {\n return res.body.url;\n });\n },\n /**\n * Sends logs to the backend\n *\n * @param {Object} metadata metadata about the logs\n * @param {Array} logs logs to send, if undefined, SDK's logs will be sent\n * @param {Object} options additional options\n * @param {string} options.type 'full' or 'diff', if not specified then the config.incrementalLogs value is used to determine the type,\n * this option only applies if logs parameter is undefined\n * 'diff' means that only the logs since the last log upload will be sent\n * 'full' means that all the logs from internal buffers will be sent\n * @returns {Promise}\n */\n submitLogs: function submitLogs(metadata, logs) {\n var _this = this;\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var metadataArray = this._constructFileMetadata(metadata);\n var type = options.type;\n\n // this is really testing that Ampersand is fully ready. once it's ready, these exist\n if (!logs && this.webex.logger.sdkBuffer && this.webex.logger.clientBuffer && this.webex.logger.buffer) {\n var diff = type !== undefined ? type === 'diff' : this.config.incrementalLogs;\n logs = this.webex.logger.formatLogs({\n diff: diff\n });\n }\n var filename;\n if (metadata.locusId && metadata.callStart) {\n filename = \"\".concat(metadata.locusId, \"_\").concat(metadata.callStart, \".txt\");\n } else {\n filename = \"\".concat(this.webex.sessionId, \".txt\");\n }\n var userId;\n return this.webex.credentials.getUserToken().catch(function () {\n return _this.webex.credentials.getClientToken();\n }).then( /*#__PURE__*/function () {\n var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(token) {\n var headers, initalOpts, finalOpts, uploadOptions;\n return _regenerator.default.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n headers = {\n authorization: token.toString()\n };\n initalOpts = {\n service: 'clientLogs',\n resource: 'logs/urls'\n };\n finalOpts = {\n service: 'clientLogs',\n resource: 'logs/meta'\n };\n uploadOptions = (0, _lodash.defaults)(initalOpts, {\n file: logs,\n shouldAttemptReauth: false,\n headers: headers,\n phases: {\n initialize: {\n body: {\n file: filename\n }\n },\n upload: {\n $uri: function $uri(session) {\n return session.tempURL;\n }\n },\n finalize: (0, _lodash.defaults)(finalOpts, {\n $body: function $body(session) {\n userId = session.userId;\n return {\n filename: session.logFilename,\n data: metadataArray,\n userId: _this.webex.internal.device.userId || session.userId\n };\n }\n })\n }\n });\n return _context.abrupt(\"return\", _this.webex.upload(uploadOptions));\n case 5:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n return function (_x) {\n return _ref.apply(this, arguments);\n };\n }()).then(function (body) {\n if (userId && !body.userId) {\n body.userId = userId;\n }\n return body;\n });\n },\n /**\n * Constructs an array of key-value pairs for log upload.\n * @param {*} metadata\n * @returns {array}\n */\n _constructFileMetadata: function _constructFileMetadata(metadata) {\n var metadataArray = ['locusId', 'appVersion', 'callStart', 'feedbackId', 'correlationId', 'meetingId', 'surveySessionId', 'productAreaTag', 'issueTypeTag', 'issueDescTag', 'locussessionid', 'autoupload'].map(function (key) {\n if (metadata[key]) {\n return {\n key: key,\n value: metadata[key]\n };\n }\n return null;\n }).filter(function (entry) {\n return Boolean(entry);\n });\n if (this.webex.sessionId) {\n metadataArray.push({\n key: 'trackingId',\n value: this.webex.sessionId\n });\n }\n if (this.webex.internal.support.config.appVersion) {\n metadataArray.push({\n key: 'appVersion',\n value: this.webex.internal.support.config.appVersion\n });\n }\n if (this.webex.internal.device.userId) {\n metadataArray.push({\n key: 'userId',\n value: this.webex.internal.device.userId\n });\n }\n if (this.webex.internal.device.orgId) {\n metadataArray.push({\n key: 'orgId',\n value: this.webex.internal.device.orgId\n });\n }\n return metadataArray;\n },\n version: \"3.8.0-next.
|
|
12184
|
+
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/regenerator */ \"../../../node_modules/@babel/runtime-corejs2/regenerator/index.js\"));\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js\"));\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! uuid */ \"../../../node_modules/uuid/index.js\"));\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nvar Support = _webexCore.WebexPlugin.extend({\n namespace: 'Support',\n getFeedbackUrl: function getFeedbackUrl(options) {\n options = options || {};\n return this.request({\n method: 'POST',\n api: 'conversation',\n resource: 'users/deskFeedbackUrl',\n body: (0, _lodash.defaults)(options, {\n appVersion: this.config.appVersion,\n appType: this.config.appType,\n feedbackId: options.feedbackId || _uuid.default.v4(),\n languageCode: this.config.languageCode\n })\n }).then(function (res) {\n return res.body.url;\n });\n },\n getSupportUrl: function getSupportUrl() {\n return this.webex.request({\n method: 'GET',\n api: 'conversation',\n resource: 'users/deskSupportUrl',\n qs: {\n languageCode: this.config.languageCode\n }\n }).then(function (res) {\n return res.body.url;\n });\n },\n /**\n * Sends logs to the backend\n *\n * @param {Object} metadata metadata about the logs\n * @param {Array} logs logs to send, if undefined, SDK's logs will be sent\n * @param {Object} options additional options\n * @param {string} options.type 'full' or 'diff', if not specified then the config.incrementalLogs value is used to determine the type,\n * this option only applies if logs parameter is undefined\n * 'diff' means that only the logs since the last log upload will be sent\n * 'full' means that all the logs from internal buffers will be sent\n * @returns {Promise}\n */\n submitLogs: function submitLogs(metadata, logs) {\n var _this = this;\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var metadataArray = this._constructFileMetadata(metadata);\n var type = options.type;\n\n // this is really testing that Ampersand is fully ready. once it's ready, these exist\n if (!logs && this.webex.logger.sdkBuffer && this.webex.logger.clientBuffer && this.webex.logger.buffer) {\n var diff = type !== undefined ? type === 'diff' : this.config.incrementalLogs;\n logs = this.webex.logger.formatLogs({\n diff: diff\n });\n }\n var filename;\n if (metadata.locusId && metadata.callStart) {\n filename = \"\".concat(metadata.locusId, \"_\").concat(metadata.callStart, \".txt\");\n } else {\n filename = \"\".concat(this.webex.sessionId, \".txt\");\n }\n var userId;\n return this.webex.credentials.getUserToken().catch(function () {\n return _this.webex.credentials.getClientToken();\n }).then( /*#__PURE__*/function () {\n var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(token) {\n var headers, initalOpts, finalOpts, uploadOptions;\n return _regenerator.default.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n headers = {\n authorization: token.toString()\n };\n initalOpts = {\n service: 'clientLogs',\n resource: 'logs/urls'\n };\n finalOpts = {\n service: 'clientLogs',\n resource: 'logs/meta'\n };\n uploadOptions = (0, _lodash.defaults)(initalOpts, {\n file: logs,\n shouldAttemptReauth: false,\n headers: headers,\n phases: {\n initialize: {\n body: {\n file: filename\n }\n },\n upload: {\n $uri: function $uri(session) {\n return session.tempURL;\n }\n },\n finalize: (0, _lodash.defaults)(finalOpts, {\n $body: function $body(session) {\n userId = session.userId;\n return {\n filename: session.logFilename,\n data: metadataArray,\n userId: _this.webex.internal.device.userId || session.userId\n };\n }\n })\n }\n });\n return _context.abrupt(\"return\", _this.webex.upload(uploadOptions));\n case 5:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n return function (_x) {\n return _ref.apply(this, arguments);\n };\n }()).then(function (body) {\n if (userId && !body.userId) {\n body.userId = userId;\n }\n return body;\n });\n },\n /**\n * Constructs an array of key-value pairs for log upload.\n * @param {*} metadata\n * @returns {array}\n */\n _constructFileMetadata: function _constructFileMetadata(metadata) {\n var metadataArray = ['locusId', 'appVersion', 'callStart', 'feedbackId', 'correlationId', 'meetingId', 'surveySessionId', 'productAreaTag', 'issueTypeTag', 'issueDescTag', 'locussessionid', 'autoupload'].map(function (key) {\n if (metadata[key]) {\n return {\n key: key,\n value: metadata[key]\n };\n }\n return null;\n }).filter(function (entry) {\n return Boolean(entry);\n });\n if (this.webex.sessionId) {\n metadataArray.push({\n key: 'trackingId',\n value: this.webex.sessionId\n });\n }\n if (this.webex.internal.support.config.appVersion) {\n metadataArray.push({\n key: 'appVersion',\n value: this.webex.internal.support.config.appVersion\n });\n }\n if (this.webex.internal.device.userId) {\n metadataArray.push({\n key: 'userId',\n value: this.webex.internal.device.userId\n });\n }\n if (this.webex.internal.device.orgId) {\n metadataArray.push({\n key: 'orgId',\n value: this.webex.internal.device.orgId\n });\n }\n return metadataArray;\n },\n version: \"3.8.0-next.14\"\n});\nvar _default = exports[\"default\"] = Support;\n//# sourceMappingURL=support.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/@webex/internal-plugin-support/dist/support.js?");
|
|
12185
12185
|
|
|
12186
12186
|
/***/ }),
|
|
12187
12187
|
|
|
@@ -12192,7 +12192,7 @@ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-co
|
|
|
12192
12192
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12193
12193
|
|
|
12194
12194
|
"use strict";
|
|
12195
|
-
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/regenerator */ \"../../../node_modules/@babel/runtime-corejs2/regenerator/index.js\"));\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js\"));\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/slicedToArray.js\"));\nvar _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/typeof */ \"../../../node_modules/@babel/runtime-corejs2/helpers/typeof.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _stringify = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/json/stringify */ \"../../../node_modules/@babel/runtime-corejs2/core-js/json/stringify.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _assign = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/assign */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/assign.js\"));\nvar _entries = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/entries */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/entries.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _deleteProperty = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/delete-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/delete-property.js\"));\nvar _parseInt2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/parse-int */ \"../../../node_modules/@babel/runtime-corejs2/core-js/parse-int.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"../../../node_modules/querystring-es3/index.js\"));\nvar _url = _interopRequireDefault(__webpack_require__(/*! url */ \"../../../node_modules/url/url.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"./node_modules/@webex/common/dist/index.js\");\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! uuid */ \"../../../node_modules/uuid/index.js\"));\nvar _dec, _dec2, _obj;\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n/* eslint camelcase: [0] */\nvar jwt = __webpack_require__(/*! jsonwebtoken */ \"../../../node_modules/jsonwebtoken/index.js\");\nvar OAUTH2_CSRF_TOKEN = 'oauth2-csrf-token';\nvar EMPTY_OBJECT_STRING = _common.base64.encode((0, _stringify.default)({}));\n\n/**\n * Browser support for OAuth2. Automatically parses the URL hash for an access\n * token\n * @class\n * @name AuthorizationBrowser\n */\nvar Authorization = _webexCore.WebexPlugin.extend((_dec = (0, _common.whileInFlight)('isAuthorizing'), _dec2 = (0, _common.whileInFlight)('isAuthorizing'), (_obj = {\n derived: {\n /**\n * Alias of {@link AuthorizationBrowser#isAuthorizing}\n * @instance\n * @memberof AuthorizationBrowser\n * @type {boolean}\n */\n isAuthenticating: {\n deps: ['isAuthorizing'],\n fn: function fn() {\n return this.isAuthorizing;\n }\n }\n },\n session: {\n /**\n * Indicates if an Authorization Code exchange is inflight\n * @instance\n * @memberof AuthorizationBrowser\n * @type {boolean}\n */\n isAuthorizing: {\n default: false,\n type: 'boolean'\n },\n ready: {\n default: false,\n type: 'boolean'\n }\n },\n namespace: 'Credentials',\n /**\n * Initializer\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} attrs {@link AmpersandState}\n * @param {boolean} attrs.parse Controls whether or not the the url should get\n * parsed for an access token\n * @private\n * @returns {Authorization}\n */\n // eslint-disable-next-line complexity\n initialize: function initialize(attrs, options) {\n var _this = this;\n var ret = (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, [attrs, options]);\n\n // Reminder, we can't do parse based on config, because config is not\n // available until nextTick and we want to be able to throw errors found in\n // the url.\n if (attrs.parse === false) {\n this.ready = true;\n return ret;\n }\n var location = _url.default.parse(this.webex.getWindow().location.href, true);\n this._checkForErrors(location);\n var hash = location.hash;\n if (!hash) {\n this.ready = true;\n return ret;\n }\n if (hash.includes('#')) {\n hash = hash.substr(1);\n }\n location.hash = _querystring.default.parse(hash);\n if (location.hash.state) {\n location.hash.state = JSON.parse(_common.base64.decode(location.hash.state));\n }\n var tokenData = this._parseHash(location);\n if (!tokenData) {\n return ret;\n }\n this._cleanUrl(location);\n\n // Wait until nextTick in case `credentials` hasn't initialized yet\n process.nextTick(function () {\n _this.webex.credentials.set({\n supertoken: tokenData\n });\n _this.ready = true;\n });\n return ret;\n },\n /**\n * Initiates the OAuth flow for user authentication.\n * This function determines the type of OAuth flow to use based on the client type configuration.\n * If the client is configured as \"confidential\", it will initiate the Authorization Code Grant flow;\n * otherwise, it will initiate the Implicit Grant flow.\n *\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options - The options to configure the OAuth flow.\n * @param {Object} [options.state] - An optional state object that can be used to include additional\n * information such as security tokens. A CSRF token will be automatically generated and added to\n * this state object.\n * @param {boolean|Object} [options.separateWindow] - Determines if the login should open in a separate window.\n * This can be a boolean or an object specifying window features:\n * - If `true`, a new window with default dimensions is opened.\n * - If an object, custom window features can be specified (e.g., `{width: 800, height: 600}`).\n * @returns {Promise<void>} - A promise that resolves when the appropriate OAuth flow has been initiated.\n * The promise does not necessarily indicate the completion of the login process.\n * @throws {Error} - Throws an error if there are issues initiating the OAuth flow.\n */\n initiateLogin: function initiateLogin() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n options.state = options.state || {};\n options.state.csrf_token = this._generateSecurityToken();\n\n // If we're not explicitly a confidential client, assume we're a public\n // client\n if (this.config.clientType === 'confidential') {\n return this.initiateAuthorizationCodeGrant(options);\n }\n return this.initiateImplicitGrant(options);\n },\n /**\n * Initiates the Implicit Grant flow for authorization.\n * This function constructs the login URL and either opens it in a new\n * window or in the current window based on the provided options.\n * Typically called via {@link AuthorizationBrowser#initiateLogin}.\n *\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options - The options to configure the login flow.\n * @param {Object} [options.separateWindow] - Determines if the login should open in a separate window.\n * This can be a boolean or an object specifying window features:\n * - If `true`, a new window with default dimensions is opened.\n * - If an object, custom window features can be specified (e.g., `{width: 800, height: 600}`).\n * @returns {Promise<void>} - A promise that resolves immediately after initiating the login flow.\n * This promise does not indicate the completion of the login process.\n * @throws {Error} - Throws an error if the login URL cannot be constructed or if window opening fails.\n */\n initiateImplicitGrant: function initiateImplicitGrant(options) {\n this.logger.info('authorization: initiating implicit grant flow');\n var loginUrl = this.webex.credentials.buildLoginUrl((0, _assign.default)({\n response_type: 'token'\n }, options));\n if (options !== null && options !== void 0 && options.separateWindow) {\n // Default window settings\n var defaultWindowSettings = {\n width: 600,\n height: 800\n };\n\n // Merge user provided settings with defaults\n var windowSettings = (0, _assign.default)(defaultWindowSettings, (0, _typeof2.default)(options.separateWindow) === 'object' ? options.separateWindow : {});\n // Convert settings object to window.open features string\n var windowFeatures = (0, _entries.default)(windowSettings).map(function (_ref) {\n var _ref2 = (0, _slicedToArray2.default)(_ref, 2),\n key = _ref2[0],\n value = _ref2[1];\n return \"\".concat(key, \"=\").concat(value);\n }).join(',');\n this.webex.getWindow().open(loginUrl, '_blank', windowFeatures);\n } else {\n // Default behavior - open in same window\n this.webex.getWindow().location = loginUrl;\n }\n return _promise.default.resolve();\n },\n /**\n * Kicks off the Implicit Code grant flow. Typically called via\n * {@link AuthorizationBrowser#initiateLogin}\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @returns {Promise}\n */\n initiateAuthorizationCodeGrant: function initiateAuthorizationCodeGrant(options) {\n this.logger.info('authorization: initiating authorization code grant flow');\n this.webex.getWindow().location = this.webex.credentials.buildLoginUrl((0, _assign.default)({\n response_type: 'code'\n }, options));\n return _promise.default.resolve();\n },\n /**\n * Requests a Webex access token for a user already authenticated into\n * your product.\n *\n * Note: You'll need to supply a jwtRefreshCallback of the form\n * `Promise<jwt> = jwtRefreshCallback(webex)` for automatic token refresh to\n * work.\n *\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @param {Object} options.jwt This is a jwt generated by your backend that\n * identifies a user in your system\n * @returns {Promise}\n */\n requestAccessTokenFromJwt: function requestAccessTokenFromJwt(_ref3) {\n var _this2 = this;\n var jwt = _ref3.jwt;\n var hydraUri = this.webex.internal.services.get('hydra', true);\n if (hydraUri && hydraUri.slice(-1) !== '/') {\n // add a `/` to hydra's uri from the services catalog so that\n // it matches the current env service format.\n hydraUri += '/';\n }\n hydraUri = hydraUri || process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1/';\n return this.webex.request({\n method: 'POST',\n uri: \"\".concat(hydraUri, \"jwt/login\"),\n headers: {\n authorization: jwt\n }\n }).then(function (_ref4) {\n var body = _ref4.body;\n return {\n access_token: body.token,\n token_type: 'Bearer',\n expires_in: body.expiresIn\n };\n }).then(function (token) {\n _this2.webex.credentials.set({\n supertoken: token\n });\n }).then(function () {\n return _this2.webex.internal.services.initServiceCatalogs();\n });\n },\n /**\n * Called by {@link WebexCore#logout()}. Redirects to the logout page\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @param {boolean} options.noRedirect if true, does not redirect\n * @returns {Promise}\n */\n logout: function logout() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (!options.noRedirect) {\n this.webex.getWindow().location = this.webex.credentials.buildLogoutUrl(options);\n }\n },\n /**\n * Creates a jwt user token\n * @param {object} options\n * @param {String} options.issuer Guest Issuer ID\n * @param {String} options.secretId Guest Secret ID\n * @param {String} options.displayName Guest Display Name | optional\n * @param {String} options.expiresIn\n * @returns {Promise<object>}\n */\n createJwt: function createJwt(_ref5) {\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {\n var issuer, secretId, displayName, expiresIn, secret, payload, alg, jwtToken;\n return _regenerator.default.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n issuer = _ref5.issuer, secretId = _ref5.secretId, displayName = _ref5.displayName, expiresIn = _ref5.expiresIn;\n secret = Buffer.from(secretId, 'base64');\n payload = {\n \"sub\": \"guest-user-\".concat((0, _uuid.default)()),\n \"iss\": issuer,\n \"name\": displayName || \"Guest User - \".concat((0, _uuid.default)())\n };\n alg = 'HS256';\n _context.prev = 4;\n jwtToken = jwt.sign(payload, secret, {\n expiresIn: expiresIn\n });\n return _context.abrupt(\"return\", _promise.default.resolve({\n jwt: jwtToken\n }));\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](4);\n return _context.abrupt(\"return\", _promise.default.reject(_context.t0));\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[4, 9]]);\n }))();\n },\n /**\n * Checks if the result of the login redirect contains an error string\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Promise}\n */\n _checkForErrors: function _checkForErrors(location) {\n var query = location.query;\n if (query && query.error) {\n var ErrorConstructor = _webexCore.grantErrors.select(query.error);\n throw new ErrorConstructor(query);\n }\n },\n /**\n * Removes no-longer needed values from the url (access token, csrf token, etc)\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Promise}\n */\n _cleanUrl: function _cleanUrl(location) {\n location = (0, _lodash.cloneDeep)(location);\n if (this.webex.getWindow().history && this.webex.getWindow().history.replaceState) {\n ['access_token', 'token_type', 'expires_in', 'refresh_token', 'refresh_token_expires_in'].forEach(function (key) {\n return (0, _deleteProperty.default)(location.hash, key);\n });\n if (!(0, _lodash.isEmpty)(location.hash.state)) {\n location.hash.state = _common.base64.encode((0, _stringify.default)((0, _lodash.omit)(location.hash.state, 'csrf_token')));\n if (location.hash.state === EMPTY_OBJECT_STRING) {\n (0, _deleteProperty.default)(location.hash, 'state');\n }\n } else {\n (0, _deleteProperty.default)(location.hash, 'state');\n }\n location.hash = _querystring.default.stringify(location.hash);\n this.webex.getWindow().history.replaceState({}, null, _url.default.format(location));\n }\n },\n /**\n * Generates a CSRF token and sticks in in sessionStorage\n * @instance\n * @memberof AuthorizationBrowser\n * @private\n * @returns {Promise}\n */\n _generateSecurityToken: function _generateSecurityToken() {\n this.logger.info('authorization: generating csrf token');\n var token = _uuid.default.v4();\n this.webex.getWindow().sessionStorage.setItem('oauth2-csrf-token', token);\n return token;\n },\n /**\n * Parses the url hash into an access token object\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Object}\n */\n _parseHash: function _parseHash(location) {\n var hash = (0, _lodash.cloneDeep)(location.hash);\n if (hash) {\n this._verifySecurityToken(hash);\n }\n if (!hash.access_token) {\n this.ready = true;\n return undefined;\n }\n if (hash.expires_in) {\n hash.expires_in = (0, _parseInt2.default)(hash.expires_in, 10);\n }\n if (hash.refresh_token_expires_in) {\n hash.refresh_token_expires_in = (0, _parseInt2.default)(hash.refresh_token_expires_in, 10);\n }\n return hash;\n },\n /**\n * Checks if the CSRF token in sessionStorage is the same as the one returned\n * in the url.\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} hash\n * @private\n * @returns {Promise}\n */\n _verifySecurityToken: function _verifySecurityToken(hash) {\n var sessionToken = this.webex.getWindow().sessionStorage.getItem(OAUTH2_CSRF_TOKEN);\n this.webex.getWindow().sessionStorage.removeItem(OAUTH2_CSRF_TOKEN);\n if (!sessionToken) {\n return;\n }\n if (!hash.state) {\n throw new Error(\"Expected CSRF token \".concat(sessionToken, \", but not found in redirect hash\"));\n }\n if (!hash.state.csrf_token) {\n throw new Error(\"Expected CSRF token \".concat(sessionToken, \", but not found in redirect hash\"));\n }\n var token = hash.state.csrf_token;\n if (token !== sessionToken) {\n throw new Error(\"CSRF token \".concat(token, \" does not match stored token \").concat(sessionToken));\n }\n },\n version: \"3.8.0-next.12\"\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"initiateImplicitGrant\", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, \"initiateImplicitGrant\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"initiateAuthorizationCodeGrant\", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, \"initiateAuthorizationCodeGrant\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"requestAccessTokenFromJwt\", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, \"requestAccessTokenFromJwt\"), _obj)), _obj)));\nvar _default = exports[\"default\"] = Authorization;\n//# sourceMappingURL=authorization.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/@webex/plugin-authorization-browser/dist/authorization.js?");
|
|
12195
|
+
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/regenerator */ \"../../../node_modules/@babel/runtime-corejs2/regenerator/index.js\"));\nvar _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/asyncToGenerator */ \"../../../node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js\"));\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/slicedToArray.js\"));\nvar _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/typeof */ \"../../../node_modules/@babel/runtime-corejs2/helpers/typeof.js\"));\nvar _applyDecoratedDescriptor2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/applyDecoratedDescriptor */ \"../../../node_modules/@babel/runtime-corejs2/helpers/applyDecoratedDescriptor.js\"));\nvar _stringify = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/json/stringify */ \"../../../node_modules/@babel/runtime-corejs2/core-js/json/stringify.js\"));\nvar _apply = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/apply */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/apply.js\"));\nvar _assign = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/assign */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/assign.js\"));\nvar _entries = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/entries */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/entries.js\"));\nvar _promise = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/promise */ \"../../../node_modules/@babel/runtime-corejs2/core-js/promise.js\"));\nvar _deleteProperty = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/delete-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/delete-property.js\"));\nvar _parseInt2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/parse-int */ \"../../../node_modules/@babel/runtime-corejs2/core-js/parse-int.js\"));\nvar _getOwnPropertyDescriptor = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/get-own-property-descriptor */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/get-own-property-descriptor.js\"));\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"../../../node_modules/querystring-es3/index.js\"));\nvar _url = _interopRequireDefault(__webpack_require__(/*! url */ \"../../../node_modules/url/url.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"./node_modules/@webex/common/dist/index.js\");\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! uuid */ \"../../../node_modules/uuid/index.js\"));\nvar _dec, _dec2, _obj;\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n/* eslint camelcase: [0] */\nvar jwt = __webpack_require__(/*! jsonwebtoken */ \"../../../node_modules/jsonwebtoken/index.js\");\nvar OAUTH2_CSRF_TOKEN = 'oauth2-csrf-token';\nvar EMPTY_OBJECT_STRING = _common.base64.encode((0, _stringify.default)({}));\n\n/**\n * Browser support for OAuth2. Automatically parses the URL hash for an access\n * token\n * @class\n * @name AuthorizationBrowser\n */\nvar Authorization = _webexCore.WebexPlugin.extend((_dec = (0, _common.whileInFlight)('isAuthorizing'), _dec2 = (0, _common.whileInFlight)('isAuthorizing'), (_obj = {\n derived: {\n /**\n * Alias of {@link AuthorizationBrowser#isAuthorizing}\n * @instance\n * @memberof AuthorizationBrowser\n * @type {boolean}\n */\n isAuthenticating: {\n deps: ['isAuthorizing'],\n fn: function fn() {\n return this.isAuthorizing;\n }\n }\n },\n session: {\n /**\n * Indicates if an Authorization Code exchange is inflight\n * @instance\n * @memberof AuthorizationBrowser\n * @type {boolean}\n */\n isAuthorizing: {\n default: false,\n type: 'boolean'\n },\n ready: {\n default: false,\n type: 'boolean'\n }\n },\n namespace: 'Credentials',\n /**\n * Initializer\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} attrs {@link AmpersandState}\n * @param {boolean} attrs.parse Controls whether or not the the url should get\n * parsed for an access token\n * @private\n * @returns {Authorization}\n */\n // eslint-disable-next-line complexity\n initialize: function initialize(attrs, options) {\n var _this = this;\n var ret = (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, [attrs, options]);\n\n // Reminder, we can't do parse based on config, because config is not\n // available until nextTick and we want to be able to throw errors found in\n // the url.\n if (attrs.parse === false) {\n this.ready = true;\n return ret;\n }\n var location = _url.default.parse(this.webex.getWindow().location.href, true);\n this._checkForErrors(location);\n var hash = location.hash;\n if (!hash) {\n this.ready = true;\n return ret;\n }\n if (hash.includes('#')) {\n hash = hash.substr(1);\n }\n location.hash = _querystring.default.parse(hash);\n if (location.hash.state) {\n location.hash.state = JSON.parse(_common.base64.decode(location.hash.state));\n }\n var tokenData = this._parseHash(location);\n if (!tokenData) {\n return ret;\n }\n this._cleanUrl(location);\n\n // Wait until nextTick in case `credentials` hasn't initialized yet\n process.nextTick(function () {\n _this.webex.credentials.set({\n supertoken: tokenData\n });\n _this.ready = true;\n });\n return ret;\n },\n /**\n * Initiates the OAuth flow for user authentication.\n * This function determines the type of OAuth flow to use based on the client type configuration.\n * If the client is configured as \"confidential\", it will initiate the Authorization Code Grant flow;\n * otherwise, it will initiate the Implicit Grant flow.\n *\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options - The options to configure the OAuth flow.\n * @param {Object} [options.state] - An optional state object that can be used to include additional\n * information such as security tokens. A CSRF token will be automatically generated and added to\n * this state object.\n * @param {boolean|Object} [options.separateWindow] - Determines if the login should open in a separate window.\n * This can be a boolean or an object specifying window features:\n * - If `true`, a new window with default dimensions is opened.\n * - If an object, custom window features can be specified (e.g., `{width: 800, height: 600}`).\n * @returns {Promise<void>} - A promise that resolves when the appropriate OAuth flow has been initiated.\n * The promise does not necessarily indicate the completion of the login process.\n * @throws {Error} - Throws an error if there are issues initiating the OAuth flow.\n */\n initiateLogin: function initiateLogin() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n options.state = options.state || {};\n options.state.csrf_token = this._generateSecurityToken();\n\n // If we're not explicitly a confidential client, assume we're a public\n // client\n if (this.config.clientType === 'confidential') {\n return this.initiateAuthorizationCodeGrant(options);\n }\n return this.initiateImplicitGrant(options);\n },\n /**\n * Initiates the Implicit Grant flow for authorization.\n * This function constructs the login URL and either opens it in a new\n * window or in the current window based on the provided options.\n * Typically called via {@link AuthorizationBrowser#initiateLogin}.\n *\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options - The options to configure the login flow.\n * @param {Object} [options.separateWindow] - Determines if the login should open in a separate window.\n * This can be a boolean or an object specifying window features:\n * - If `true`, a new window with default dimensions is opened.\n * - If an object, custom window features can be specified (e.g., `{width: 800, height: 600}`).\n * @returns {Promise<void>} - A promise that resolves immediately after initiating the login flow.\n * This promise does not indicate the completion of the login process.\n * @throws {Error} - Throws an error if the login URL cannot be constructed or if window opening fails.\n */\n initiateImplicitGrant: function initiateImplicitGrant(options) {\n this.logger.info('authorization: initiating implicit grant flow');\n var loginUrl = this.webex.credentials.buildLoginUrl((0, _assign.default)({\n response_type: 'token'\n }, options));\n if (options !== null && options !== void 0 && options.separateWindow) {\n // Default window settings\n var defaultWindowSettings = {\n width: 600,\n height: 800\n };\n\n // Merge user provided settings with defaults\n var windowSettings = (0, _assign.default)(defaultWindowSettings, (0, _typeof2.default)(options.separateWindow) === 'object' ? options.separateWindow : {});\n // Convert settings object to window.open features string\n var windowFeatures = (0, _entries.default)(windowSettings).map(function (_ref) {\n var _ref2 = (0, _slicedToArray2.default)(_ref, 2),\n key = _ref2[0],\n value = _ref2[1];\n return \"\".concat(key, \"=\").concat(value);\n }).join(',');\n this.webex.getWindow().open(loginUrl, '_blank', windowFeatures);\n } else {\n // Default behavior - open in same window\n this.webex.getWindow().location = loginUrl;\n }\n return _promise.default.resolve();\n },\n /**\n * Kicks off the Implicit Code grant flow. Typically called via\n * {@link AuthorizationBrowser#initiateLogin}\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @returns {Promise}\n */\n initiateAuthorizationCodeGrant: function initiateAuthorizationCodeGrant(options) {\n this.logger.info('authorization: initiating authorization code grant flow');\n this.webex.getWindow().location = this.webex.credentials.buildLoginUrl((0, _assign.default)({\n response_type: 'code'\n }, options));\n return _promise.default.resolve();\n },\n /**\n * Requests a Webex access token for a user already authenticated into\n * your product.\n *\n * Note: You'll need to supply a jwtRefreshCallback of the form\n * `Promise<jwt> = jwtRefreshCallback(webex)` for automatic token refresh to\n * work.\n *\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @param {Object} options.jwt This is a jwt generated by your backend that\n * identifies a user in your system\n * @returns {Promise}\n */\n requestAccessTokenFromJwt: function requestAccessTokenFromJwt(_ref3) {\n var _this2 = this;\n var jwt = _ref3.jwt;\n var hydraUri = this.webex.internal.services.get('hydra', true);\n if (hydraUri && hydraUri.slice(-1) !== '/') {\n // add a `/` to hydra's uri from the services catalog so that\n // it matches the current env service format.\n hydraUri += '/';\n }\n hydraUri = hydraUri || process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1/';\n return this.webex.request({\n method: 'POST',\n uri: \"\".concat(hydraUri, \"jwt/login\"),\n headers: {\n authorization: jwt\n }\n }).then(function (_ref4) {\n var body = _ref4.body;\n return {\n access_token: body.token,\n token_type: 'Bearer',\n expires_in: body.expiresIn\n };\n }).then(function (token) {\n _this2.webex.credentials.set({\n supertoken: token\n });\n }).then(function () {\n return _this2.webex.internal.services.initServiceCatalogs();\n });\n },\n /**\n * Called by {@link WebexCore#logout()}. Redirects to the logout page\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @param {boolean} options.noRedirect if true, does not redirect\n * @returns {Promise}\n */\n logout: function logout() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (!options.noRedirect) {\n this.webex.getWindow().location = this.webex.credentials.buildLogoutUrl(options);\n }\n },\n /**\n * Creates a jwt user token\n * @param {object} options\n * @param {String} options.issuer Guest Issuer ID\n * @param {String} options.secretId Guest Secret ID\n * @param {String} options.displayName Guest Display Name | optional\n * @param {String} options.expiresIn\n * @returns {Promise<object>}\n */\n createJwt: function createJwt(_ref5) {\n return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {\n var issuer, secretId, displayName, expiresIn, secret, payload, alg, jwtToken;\n return _regenerator.default.wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n issuer = _ref5.issuer, secretId = _ref5.secretId, displayName = _ref5.displayName, expiresIn = _ref5.expiresIn;\n secret = Buffer.from(secretId, 'base64');\n payload = {\n \"sub\": \"guest-user-\".concat((0, _uuid.default)()),\n \"iss\": issuer,\n \"name\": displayName || \"Guest User - \".concat((0, _uuid.default)())\n };\n alg = 'HS256';\n _context.prev = 4;\n jwtToken = jwt.sign(payload, secret, {\n expiresIn: expiresIn\n });\n return _context.abrupt(\"return\", _promise.default.resolve({\n jwt: jwtToken\n }));\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](4);\n return _context.abrupt(\"return\", _promise.default.reject(_context.t0));\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[4, 9]]);\n }))();\n },\n /**\n * Checks if the result of the login redirect contains an error string\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Promise}\n */\n _checkForErrors: function _checkForErrors(location) {\n var query = location.query;\n if (query && query.error) {\n var ErrorConstructor = _webexCore.grantErrors.select(query.error);\n throw new ErrorConstructor(query);\n }\n },\n /**\n * Removes no-longer needed values from the url (access token, csrf token, etc)\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Promise}\n */\n _cleanUrl: function _cleanUrl(location) {\n location = (0, _lodash.cloneDeep)(location);\n if (this.webex.getWindow().history && this.webex.getWindow().history.replaceState) {\n ['access_token', 'token_type', 'expires_in', 'refresh_token', 'refresh_token_expires_in'].forEach(function (key) {\n return (0, _deleteProperty.default)(location.hash, key);\n });\n if (!(0, _lodash.isEmpty)(location.hash.state)) {\n location.hash.state = _common.base64.encode((0, _stringify.default)((0, _lodash.omit)(location.hash.state, 'csrf_token')));\n if (location.hash.state === EMPTY_OBJECT_STRING) {\n (0, _deleteProperty.default)(location.hash, 'state');\n }\n } else {\n (0, _deleteProperty.default)(location.hash, 'state');\n }\n location.hash = _querystring.default.stringify(location.hash);\n this.webex.getWindow().history.replaceState({}, null, _url.default.format(location));\n }\n },\n /**\n * Generates a CSRF token and sticks in in sessionStorage\n * @instance\n * @memberof AuthorizationBrowser\n * @private\n * @returns {Promise}\n */\n _generateSecurityToken: function _generateSecurityToken() {\n this.logger.info('authorization: generating csrf token');\n var token = _uuid.default.v4();\n this.webex.getWindow().sessionStorage.setItem('oauth2-csrf-token', token);\n return token;\n },\n /**\n * Parses the url hash into an access token object\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Object}\n */\n _parseHash: function _parseHash(location) {\n var hash = (0, _lodash.cloneDeep)(location.hash);\n if (hash) {\n this._verifySecurityToken(hash);\n }\n if (!hash.access_token) {\n this.ready = true;\n return undefined;\n }\n if (hash.expires_in) {\n hash.expires_in = (0, _parseInt2.default)(hash.expires_in, 10);\n }\n if (hash.refresh_token_expires_in) {\n hash.refresh_token_expires_in = (0, _parseInt2.default)(hash.refresh_token_expires_in, 10);\n }\n return hash;\n },\n /**\n * Checks if the CSRF token in sessionStorage is the same as the one returned\n * in the url.\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} hash\n * @private\n * @returns {Promise}\n */\n _verifySecurityToken: function _verifySecurityToken(hash) {\n var sessionToken = this.webex.getWindow().sessionStorage.getItem(OAUTH2_CSRF_TOKEN);\n this.webex.getWindow().sessionStorage.removeItem(OAUTH2_CSRF_TOKEN);\n if (!sessionToken) {\n return;\n }\n if (!hash.state) {\n throw new Error(\"Expected CSRF token \".concat(sessionToken, \", but not found in redirect hash\"));\n }\n if (!hash.state.csrf_token) {\n throw new Error(\"Expected CSRF token \".concat(sessionToken, \", but not found in redirect hash\"));\n }\n var token = hash.state.csrf_token;\n if (token !== sessionToken) {\n throw new Error(\"CSRF token \".concat(token, \" does not match stored token \").concat(sessionToken));\n }\n },\n version: \"3.8.0-next.13\"\n}, ((0, _applyDecoratedDescriptor2.default)(_obj, \"initiateImplicitGrant\", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, \"initiateImplicitGrant\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"initiateAuthorizationCodeGrant\", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, \"initiateAuthorizationCodeGrant\"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, \"requestAccessTokenFromJwt\", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, \"requestAccessTokenFromJwt\"), _obj)), _obj)));\nvar _default = exports[\"default\"] = Authorization;\n//# sourceMappingURL=authorization.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/@webex/plugin-authorization-browser/dist/authorization.js?");
|
|
12196
12196
|
|
|
12197
12197
|
/***/ }),
|
|
12198
12198
|
|
|
@@ -12258,7 +12258,7 @@ eval("\n\nvar _typeof = __webpack_require__(/*! @babel/runtime-corejs2/helpers/t
|
|
|
12258
12258
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12259
12259
|
|
|
12260
12260
|
"use strict";
|
|
12261
|
-
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.levels = exports[\"default\"] = void 0;\nvar _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/typeof */ \"../../../node_modules/@babel/runtime-corejs2/helpers/typeof.js\"));\nvar _toConsumableArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/toConsumableArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/toConsumableArray.js\"));\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/slicedToArray.js\"));\nvar _keys = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\"));\nvar _entries = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/entries */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/entries.js\"));\nvar _deleteProperty = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/delete-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/delete-property.js\"));\nvar _stringify = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/json/stringify */ \"../../../node_modules/@babel/runtime-corejs2/core-js/json/stringify.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"./node_modules/@webex/common/dist/index.js\");\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nvar precedence = {\n silent: 0,\n group: 1,\n groupEnd: 2,\n error: 3,\n warn: 4,\n log: 5,\n info: 6,\n debug: 7,\n trace: 8\n};\nvar levels = exports.levels = (0, _keys.default)(precedence).filter(function (level) {\n return level !== 'silent';\n});\nvar fallbacks = {\n error: ['log'],\n warn: ['error', 'log'],\n info: ['log'],\n debug: ['info', 'log'],\n trace: ['debug', 'info', 'log']\n};\nvar LOG_TYPES = {\n SDK: 'sdk',\n CLIENT: 'client'\n};\nvar SDK_LOG_TYPE_NAME = 'wx-js-sdk';\nvar authTokenKeyPattern = /[Aa]uthorization/;\n\n/**\n * Recursively strips \"authorization\" fields from the specified object\n * @param {Object} object\n * @param {Array<mixed>} [visited]\n * @private\n * @returns {Object}\n */\nfunction walkAndFilter(object) {\n var visited = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n if (visited.includes(object)) {\n // Prevent circular references\n return object;\n }\n visited.push(object);\n if ((0, _lodash.isArray)(object)) {\n return object.map(function (o) {\n return walkAndFilter(o, visited);\n });\n }\n if (!(0, _lodash.isObject)(object)) {\n if ((0, _lodash.isString)(object)) {\n if (_common.patterns.containsEmails.test(object)) {\n return object.replace(_common.patterns.containsEmails, '[REDACTED]');\n }\n if (_common.patterns.containsMTID.test(object)) {\n return object.replace(_common.patterns.containsMTID, '$1[REDACTED]');\n }\n }\n return object;\n }\n for (var _i = 0, _Object$entries = (0, _entries.default)(object); _i < _Object$entries.length; _i++) {\n var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),\n key = _Object$entries$_i[0],\n value = _Object$entries$_i[1];\n if (authTokenKeyPattern.test(key)) {\n (0, _deleteProperty.default)(object, key);\n } else {\n object[key] = walkAndFilter(value, visited);\n }\n }\n return object;\n}\n\n/**\n * @class\n */\nvar Logger = _webexCore.WebexPlugin.extend({\n namespace: 'Logger',\n derived: {\n level: {\n cache: false,\n fn: function fn() {\n return this.getCurrentLevel();\n }\n },\n client_level: {\n cache: false,\n fn: function fn() {\n return this.getCurrentClientLevel();\n }\n }\n },\n session: {\n // for when configured to use single buffer\n buffer: {\n type: 'object',\n default: function _default() {\n return {\n buffer: [],\n nextIndex: 0\n };\n }\n },\n groupLevel: {\n type: 'number',\n default: function _default() {\n return 0;\n }\n },\n // for when configured to use separate buffers\n sdkBuffer: {\n type: 'object',\n default: function _default() {\n return {\n buffer: [],\n nextIndex: 0\n };\n }\n },\n clientBuffer: {\n type: 'object',\n default: function _default() {\n return {\n buffer: [],\n nextIndex: 0\n };\n }\n }\n },\n /**\n * Ensures auth headers don't get printed in logs\n * @param {Array<mixed>} args\n * @private\n * @memberof Logger\n * @returns {Array<mixed>}\n */\n filter: function filter() {\n for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return args.map(function (arg) {\n // WebexHttpError already ensures auth tokens don't get printed, so, no\n // need to alter it here.\n if (arg instanceof Error) {\n // karma logs won't print subclassed errors correctly, so we need\n // explicitly call their tostring methods.\n if (false) { var ret; }\n return arg;\n }\n arg = (0, _lodash.cloneDeep)(arg);\n return walkAndFilter(arg);\n });\n },\n /**\n * Determines if the current level allows logs at the specified level to be\n * printed\n * @param {string} level\n * @param {string} type type of log, SDK or client\n * @private\n * @memberof Logger\n * @returns {boolean}\n */\n shouldPrint: function shouldPrint(level) {\n var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LOG_TYPES.SDK;\n return precedence[level] <= precedence[type === LOG_TYPES.SDK ? this.getCurrentLevel() : this.getCurrentClientLevel()];\n },\n /**\n * Determines if the current level allows logs at the specified level to be\n * put into the log buffer. We're configuring it omit trace and debug logs\n * because there are *a lot* of debug logs that really don't provide value at\n * runtime (they're helpful for debugging locally, but really just pollute the\n * uploaded logs and push useful info out).\n * @param {string} level\n * @param {string} type type of log, SDK or client\n * @private\n * @memberof Logger\n * @returns {boolean}\n */\n shouldBuffer: function shouldBuffer(level) {\n return precedence[level] <= (this.config.bufferLogLevel ? precedence[this.config.bufferLogLevel] : precedence.info);\n },\n /**\n * Indicates the current SDK log level based on env vars, feature toggles, and\n * user type.\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {string}\n */\n // eslint-disable-next-line complexity\n getCurrentLevel: function getCurrentLevel() {\n // If a level has been explicitly set via config, alway use it.\n if (this.config.level) {\n return this.config.level;\n }\n if (levels.includes(process.env.WEBEX_LOG_LEVEL)) {\n return process.env.WEBEX_LOG_LEVEL;\n }\n\n // Always use debug-level logging in test mode;\n if (false) {}\n\n // Use server-side-feature toggles to configure log levels\n var level = this.webex.internal.device && this.webex.internal.device.features.developer.get('log-level');\n if (level) {\n if (levels.includes(level)) {\n return level;\n }\n }\n return 'error';\n },\n /**\n * Indicates the current client log level based on config, defaults to SDK level\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {string}\n */\n getCurrentClientLevel: function getCurrentClientLevel() {\n // If a client log level has been explicitly set via config, alway use it.\n if (this.config.clientLevel) {\n return this.config.clientLevel;\n }\n\n // otherwise default to SDK level\n return this.getCurrentLevel();\n },\n /**\n * Format logs (for upload)\n *\n * If separate client, SDK buffers is configured, merge the buffers, if configured\n *\n * @instance\n * @memberof Logger\n * @public\n * @memberof Logger\n * @param {Object} options\n * @param {boolean} options.diff whether to only format the diff from last call to formatLogs(), false by default\n * @returns {string} formatted buffer\n */\n formatLogs: function formatLogs() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n function getDate(log) {\n return log[1];\n }\n var _options$diff = options.diff,\n diff = _options$diff === void 0 ? false : _options$diff;\n var buffer = [];\n var clientIndex = diff ? this.clientBuffer.nextIndex : 0;\n var sdkIndex = diff ? this.sdkBuffer.nextIndex : 0;\n if (this.config.separateLogBuffers) {\n // merge the client and sdk buffers\n // while we have entries in either buffer\n while (clientIndex < this.clientBuffer.buffer.length || sdkIndex < this.sdkBuffer.buffer.length) {\n // if we have remaining entries in the SDK buffer\n if (sdkIndex < this.sdkBuffer.buffer.length && (\n // and we haven't exhausted all the client buffer entries, or SDK date is before client date\n clientIndex >= this.clientBuffer.buffer.length || new Date(getDate(this.sdkBuffer.buffer[sdkIndex])) <= new Date(getDate(this.clientBuffer.buffer[clientIndex])))) {\n // then add to the SDK buffer\n buffer.push(this.sdkBuffer.buffer[sdkIndex]);\n sdkIndex += 1;\n }\n // otherwise if we haven't exhausted all the client buffer entries, add client entry, whether it was because\n // it was the only remaining entries or date was later (the above if)\n else if (clientIndex < this.clientBuffer.buffer.length) {\n buffer.push(this.clientBuffer.buffer[clientIndex]);\n clientIndex += 1;\n }\n }\n if (diff) {\n this.clientBuffer.nextIndex = clientIndex;\n this.sdkBuffer.nextIndex = sdkIndex;\n }\n } else if (diff) {\n buffer = this.buffer.buffer.slice(this.buffer.nextIndex);\n this.buffer.nextIndex = this.buffer.buffer.length;\n } else {\n buffer = this.buffer.buffer;\n }\n return buffer.join('\\n');\n },\n version: \"3.8.0-next.11\"\n});\n\n/**\n * Creates a logger method\n *\n *\n * @param {string} level level to create (info, error, warn, etc.)\n * @param {string} impl the level to use when writing to console\n * @param {string} type type of log, SDK or client\n * @param {bool} neverPrint function never prints to console\n * @param {bool} alwaysBuffer function always logs to log buffer\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {function} logger method with specified params\n */\nfunction makeLoggerMethod(level, impl, type) {\n var neverPrint = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n var alwaysBuffer = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n // Much of the complexity in the following function is due to a test-mode-only\n // helper\n return function wrappedConsoleMethod() {\n // it would be easier to just pass in the name and buffer here, but the config isn't completely initialized\n // in Ampersand, even if the initialize method is used to set this up. so we keep the type to achieve\n // a sort of late binding to allow retrieving a name from config.\n var logType = type;\n var clientName = logType === LOG_TYPES.SDK ? SDK_LOG_TYPE_NAME : this.config.clientName || logType;\n var bufferRef;\n var historyLength;\n if (this.config.separateLogBuffers) {\n historyLength = this.config.clientHistoryLength ? this.config.clientHistoryLength : this.config.historyLength;\n bufferRef = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;\n } else {\n bufferRef = this.buffer;\n historyLength = this.config.historyLength;\n }\n try {\n var shouldPrint = !neverPrint && this.shouldPrint(level, logType);\n var shouldBuffer = alwaysBuffer || this.shouldBuffer(level);\n if (!shouldBuffer && !shouldPrint) {\n return;\n }\n var filtered = [clientName].concat((0, _toConsumableArray2.default)(this.filter.apply(this, arguments)));\n var stringified = filtered.map(function (item) {\n if (item instanceof Error) {\n return item.toString();\n }\n if ((0, _typeof2.default)(item) === 'object') {\n var cache = [];\n var returnItem;\n try {\n returnItem = (0, _stringify.default)(item, function (_key, value) {\n if ((0, _typeof2.default)(value) === 'object' && value !== null) {\n if (cache.includes(value)) {\n // Circular reference found, discard key\n return undefined;\n }\n // Store value in our collection\n cache.push(value);\n }\n return value;\n });\n } catch (e) {\n returnItem = \"Failed to stringify: \".concat(item);\n }\n cache = null;\n return returnItem;\n }\n return item;\n });\n if (shouldPrint) {\n var _console;\n // when logging an object in browsers, we tend to get a dynamic\n // reference, thus going back to look at the logged value doesn't\n // necessarily show the state at log time, thus we print the stringified\n // value.\n var toPrint = _common.inBrowser ? stringified : filtered;\n\n /* istanbul ignore if */\n if (false) {}\n // eslint-disable-next-line no-console\n (_console = console)[impl].apply(_console, (0, _toConsumableArray2.default)(toPrint));\n }\n if (shouldBuffer) {\n var logDate = new Date();\n stringified.unshift(logDate.toISOString());\n stringified.unshift('| '.repeat(this.groupLevel));\n bufferRef.buffer.push(stringified);\n if (bufferRef.buffer.length > historyLength) {\n // we've gone over the buffer limit, trim it down\n var deleteCount = bufferRef.buffer.length - historyLength;\n bufferRef.buffer.splice(0, deleteCount);\n\n // and adjust the corresponding buffer index used for log diff uploads\n bufferRef.nextIndex -= deleteCount;\n if (bufferRef.nextIndex < 0) {\n bufferRef.nextIndex = 0;\n }\n }\n if (level === 'group') this.groupLevel += 1;\n if (level === 'groupEnd' && this.groupLevel > 0) this.groupLevel -= 1;\n }\n } catch (reason) {\n if (!neverPrint) {\n /* istanbul ignore next */\n // eslint-disable-next-line no-console\n console.warn(\"failed to execute Logger#\".concat(level), reason);\n }\n }\n };\n}\nlevels.forEach(function (level) {\n var impls = fallbacks[level];\n var impl = level;\n if (impls) {\n impls = impls.slice();\n // eslint-disable-next-line no-console\n while (!console[impl]) {\n impl = impls.pop();\n }\n }\n\n // eslint-disable-next-line complexity\n Logger.prototype[\"client_\".concat(level)] = makeLoggerMethod(level, impl, LOG_TYPES.CLIENT);\n Logger.prototype[level] = makeLoggerMethod(level, impl, LOG_TYPES.SDK);\n});\nLogger.prototype.client_logToBuffer = makeLoggerMethod(levels.info, levels.info, LOG_TYPES.CLIENT, true, true);\nLogger.prototype.logToBuffer = makeLoggerMethod(levels.info, levels.info, LOG_TYPES.SDK, true, true);\nvar _default2 = exports[\"default\"] = Logger;\n//# sourceMappingURL=logger.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/@webex/plugin-logger/dist/logger.js?");
|
|
12261
|
+
eval("/* provided dependency */ var process = __webpack_require__(/*! process/browser */ \"../../../node_modules/process/browser.js\");\n\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.levels = exports[\"default\"] = void 0;\nvar _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/typeof */ \"../../../node_modules/@babel/runtime-corejs2/helpers/typeof.js\"));\nvar _toConsumableArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/toConsumableArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/toConsumableArray.js\"));\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/helpers/slicedToArray */ \"../../../node_modules/@babel/runtime-corejs2/helpers/slicedToArray.js\"));\nvar _keys = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/keys */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/keys.js\"));\nvar _entries = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/object/entries */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/entries.js\"));\nvar _deleteProperty = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/reflect/delete-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/reflect/delete-property.js\"));\nvar _stringify = _interopRequireDefault(__webpack_require__(/*! @babel/runtime-corejs2/core-js/json/stringify */ \"../../../node_modules/@babel/runtime-corejs2/core-js/json/stringify.js\"));\nvar _common = __webpack_require__(/*! @webex/common */ \"./node_modules/@webex/common/dist/index.js\");\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _lodash = __webpack_require__(/*! lodash */ \"../../../node_modules/lodash/lodash.js\");\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nvar precedence = {\n silent: 0,\n group: 1,\n groupEnd: 2,\n error: 3,\n warn: 4,\n log: 5,\n info: 6,\n debug: 7,\n trace: 8\n};\nvar levels = exports.levels = (0, _keys.default)(precedence).filter(function (level) {\n return level !== 'silent';\n});\nvar fallbacks = {\n error: ['log'],\n warn: ['error', 'log'],\n info: ['log'],\n debug: ['info', 'log'],\n trace: ['debug', 'info', 'log']\n};\nvar LOG_TYPES = {\n SDK: 'sdk',\n CLIENT: 'client'\n};\nvar SDK_LOG_TYPE_NAME = 'wx-js-sdk';\nvar authTokenKeyPattern = /[Aa]uthorization/;\n\n/**\n * Recursively strips \"authorization\" fields from the specified object\n * @param {Object} object\n * @param {Array<mixed>} [visited]\n * @private\n * @returns {Object}\n */\nfunction walkAndFilter(object) {\n var visited = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n if (visited.includes(object)) {\n // Prevent circular references\n return object;\n }\n visited.push(object);\n if ((0, _lodash.isArray)(object)) {\n return object.map(function (o) {\n return walkAndFilter(o, visited);\n });\n }\n if (!(0, _lodash.isObject)(object)) {\n if ((0, _lodash.isString)(object)) {\n if (_common.patterns.containsEmails.test(object)) {\n return object.replace(_common.patterns.containsEmails, '[REDACTED]');\n }\n if (_common.patterns.containsMTID.test(object)) {\n return object.replace(_common.patterns.containsMTID, '$1[REDACTED]');\n }\n }\n return object;\n }\n for (var _i = 0, _Object$entries = (0, _entries.default)(object); _i < _Object$entries.length; _i++) {\n var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),\n key = _Object$entries$_i[0],\n value = _Object$entries$_i[1];\n if (authTokenKeyPattern.test(key)) {\n (0, _deleteProperty.default)(object, key);\n } else {\n object[key] = walkAndFilter(value, visited);\n }\n }\n return object;\n}\n\n/**\n * @class\n */\nvar Logger = _webexCore.WebexPlugin.extend({\n namespace: 'Logger',\n derived: {\n level: {\n cache: false,\n fn: function fn() {\n return this.getCurrentLevel();\n }\n },\n client_level: {\n cache: false,\n fn: function fn() {\n return this.getCurrentClientLevel();\n }\n }\n },\n session: {\n // for when configured to use single buffer\n buffer: {\n type: 'object',\n default: function _default() {\n return {\n buffer: [],\n nextIndex: 0\n };\n }\n },\n groupLevel: {\n type: 'number',\n default: function _default() {\n return 0;\n }\n },\n // for when configured to use separate buffers\n sdkBuffer: {\n type: 'object',\n default: function _default() {\n return {\n buffer: [],\n nextIndex: 0\n };\n }\n },\n clientBuffer: {\n type: 'object',\n default: function _default() {\n return {\n buffer: [],\n nextIndex: 0\n };\n }\n }\n },\n /**\n * Ensures auth headers don't get printed in logs\n * @param {Array<mixed>} args\n * @private\n * @memberof Logger\n * @returns {Array<mixed>}\n */\n filter: function filter() {\n for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return args.map(function (arg) {\n // WebexHttpError already ensures auth tokens don't get printed, so, no\n // need to alter it here.\n if (arg instanceof Error) {\n // karma logs won't print subclassed errors correctly, so we need\n // explicitly call their tostring methods.\n if (false) { var ret; }\n return arg;\n }\n arg = (0, _lodash.cloneDeep)(arg);\n return walkAndFilter(arg);\n });\n },\n /**\n * Determines if the current level allows logs at the specified level to be\n * printed\n * @param {string} level\n * @param {string} type type of log, SDK or client\n * @private\n * @memberof Logger\n * @returns {boolean}\n */\n shouldPrint: function shouldPrint(level) {\n var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LOG_TYPES.SDK;\n return precedence[level] <= precedence[type === LOG_TYPES.SDK ? this.getCurrentLevel() : this.getCurrentClientLevel()];\n },\n /**\n * Determines if the current level allows logs at the specified level to be\n * put into the log buffer. We're configuring it omit trace and debug logs\n * because there are *a lot* of debug logs that really don't provide value at\n * runtime (they're helpful for debugging locally, but really just pollute the\n * uploaded logs and push useful info out).\n * @param {string} level\n * @param {string} type type of log, SDK or client\n * @private\n * @memberof Logger\n * @returns {boolean}\n */\n shouldBuffer: function shouldBuffer(level) {\n return precedence[level] <= (this.config.bufferLogLevel ? precedence[this.config.bufferLogLevel] : precedence.info);\n },\n /**\n * Indicates the current SDK log level based on env vars, feature toggles, and\n * user type.\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {string}\n */\n // eslint-disable-next-line complexity\n getCurrentLevel: function getCurrentLevel() {\n // If a level has been explicitly set via config, alway use it.\n if (this.config.level) {\n return this.config.level;\n }\n if (levels.includes(process.env.WEBEX_LOG_LEVEL)) {\n return process.env.WEBEX_LOG_LEVEL;\n }\n\n // Always use debug-level logging in test mode;\n if (false) {}\n\n // Use server-side-feature toggles to configure log levels\n var level = this.webex.internal.device && this.webex.internal.device.features.developer.get('log-level');\n if (level) {\n if (levels.includes(level)) {\n return level;\n }\n }\n return 'error';\n },\n /**\n * Indicates the current client log level based on config, defaults to SDK level\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {string}\n */\n getCurrentClientLevel: function getCurrentClientLevel() {\n // If a client log level has been explicitly set via config, alway use it.\n if (this.config.clientLevel) {\n return this.config.clientLevel;\n }\n\n // otherwise default to SDK level\n return this.getCurrentLevel();\n },\n /**\n * Format logs (for upload)\n *\n * If separate client, SDK buffers is configured, merge the buffers, if configured\n *\n * @instance\n * @memberof Logger\n * @public\n * @memberof Logger\n * @param {Object} options\n * @param {boolean} options.diff whether to only format the diff from last call to formatLogs(), false by default\n * @returns {string} formatted buffer\n */\n formatLogs: function formatLogs() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n function getDate(log) {\n return log[1];\n }\n var _options$diff = options.diff,\n diff = _options$diff === void 0 ? false : _options$diff;\n var buffer = [];\n var clientIndex = diff ? this.clientBuffer.nextIndex : 0;\n var sdkIndex = diff ? this.sdkBuffer.nextIndex : 0;\n if (this.config.separateLogBuffers) {\n // merge the client and sdk buffers\n // while we have entries in either buffer\n while (clientIndex < this.clientBuffer.buffer.length || sdkIndex < this.sdkBuffer.buffer.length) {\n // if we have remaining entries in the SDK buffer\n if (sdkIndex < this.sdkBuffer.buffer.length && (\n // and we haven't exhausted all the client buffer entries, or SDK date is before client date\n clientIndex >= this.clientBuffer.buffer.length || new Date(getDate(this.sdkBuffer.buffer[sdkIndex])) <= new Date(getDate(this.clientBuffer.buffer[clientIndex])))) {\n // then add to the SDK buffer\n buffer.push(this.sdkBuffer.buffer[sdkIndex]);\n sdkIndex += 1;\n }\n // otherwise if we haven't exhausted all the client buffer entries, add client entry, whether it was because\n // it was the only remaining entries or date was later (the above if)\n else if (clientIndex < this.clientBuffer.buffer.length) {\n buffer.push(this.clientBuffer.buffer[clientIndex]);\n clientIndex += 1;\n }\n }\n if (diff) {\n this.clientBuffer.nextIndex = clientIndex;\n this.sdkBuffer.nextIndex = sdkIndex;\n }\n } else if (diff) {\n buffer = this.buffer.buffer.slice(this.buffer.nextIndex);\n this.buffer.nextIndex = this.buffer.buffer.length;\n } else {\n buffer = this.buffer.buffer;\n }\n return buffer.join('\\n');\n },\n version: \"3.8.0-next.12\"\n});\n\n/**\n * Creates a logger method\n *\n *\n * @param {string} level level to create (info, error, warn, etc.)\n * @param {string} impl the level to use when writing to console\n * @param {string} type type of log, SDK or client\n * @param {bool} neverPrint function never prints to console\n * @param {bool} alwaysBuffer function always logs to log buffer\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {function} logger method with specified params\n */\nfunction makeLoggerMethod(level, impl, type) {\n var neverPrint = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n var alwaysBuffer = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n // Much of the complexity in the following function is due to a test-mode-only\n // helper\n return function wrappedConsoleMethod() {\n // it would be easier to just pass in the name and buffer here, but the config isn't completely initialized\n // in Ampersand, even if the initialize method is used to set this up. so we keep the type to achieve\n // a sort of late binding to allow retrieving a name from config.\n var logType = type;\n var clientName = logType === LOG_TYPES.SDK ? SDK_LOG_TYPE_NAME : this.config.clientName || logType;\n var bufferRef;\n var historyLength;\n if (this.config.separateLogBuffers) {\n historyLength = this.config.clientHistoryLength ? this.config.clientHistoryLength : this.config.historyLength;\n bufferRef = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;\n } else {\n bufferRef = this.buffer;\n historyLength = this.config.historyLength;\n }\n try {\n var shouldPrint = !neverPrint && this.shouldPrint(level, logType);\n var shouldBuffer = alwaysBuffer || this.shouldBuffer(level);\n if (!shouldBuffer && !shouldPrint) {\n return;\n }\n var filtered = [clientName].concat((0, _toConsumableArray2.default)(this.filter.apply(this, arguments)));\n var stringified = filtered.map(function (item) {\n if (item instanceof Error) {\n return item.toString();\n }\n if ((0, _typeof2.default)(item) === 'object') {\n var cache = [];\n var returnItem;\n try {\n returnItem = (0, _stringify.default)(item, function (_key, value) {\n if ((0, _typeof2.default)(value) === 'object' && value !== null) {\n if (cache.includes(value)) {\n // Circular reference found, discard key\n return undefined;\n }\n // Store value in our collection\n cache.push(value);\n }\n return value;\n });\n } catch (e) {\n returnItem = \"Failed to stringify: \".concat(item);\n }\n cache = null;\n return returnItem;\n }\n return item;\n });\n if (shouldPrint) {\n var _console;\n // when logging an object in browsers, we tend to get a dynamic\n // reference, thus going back to look at the logged value doesn't\n // necessarily show the state at log time, thus we print the stringified\n // value.\n var toPrint = _common.inBrowser ? stringified : filtered;\n\n /* istanbul ignore if */\n if (false) {}\n // eslint-disable-next-line no-console\n (_console = console)[impl].apply(_console, (0, _toConsumableArray2.default)(toPrint));\n }\n if (shouldBuffer) {\n var logDate = new Date();\n stringified.unshift(logDate.toISOString());\n stringified.unshift('| '.repeat(this.groupLevel));\n bufferRef.buffer.push(stringified);\n if (bufferRef.buffer.length > historyLength) {\n // we've gone over the buffer limit, trim it down\n var deleteCount = bufferRef.buffer.length - historyLength;\n bufferRef.buffer.splice(0, deleteCount);\n\n // and adjust the corresponding buffer index used for log diff uploads\n bufferRef.nextIndex -= deleteCount;\n if (bufferRef.nextIndex < 0) {\n bufferRef.nextIndex = 0;\n }\n }\n if (level === 'group') this.groupLevel += 1;\n if (level === 'groupEnd' && this.groupLevel > 0) this.groupLevel -= 1;\n }\n } catch (reason) {\n if (!neverPrint) {\n /* istanbul ignore next */\n // eslint-disable-next-line no-console\n console.warn(\"failed to execute Logger#\".concat(level), reason);\n }\n }\n };\n}\nlevels.forEach(function (level) {\n var impls = fallbacks[level];\n var impl = level;\n if (impls) {\n impls = impls.slice();\n // eslint-disable-next-line no-console\n while (!console[impl]) {\n impl = impls.pop();\n }\n }\n\n // eslint-disable-next-line complexity\n Logger.prototype[\"client_\".concat(level)] = makeLoggerMethod(level, impl, LOG_TYPES.CLIENT);\n Logger.prototype[level] = makeLoggerMethod(level, impl, LOG_TYPES.SDK);\n});\nLogger.prototype.client_logToBuffer = makeLoggerMethod(levels.info, levels.info, LOG_TYPES.CLIENT, true, true);\nLogger.prototype.logToBuffer = makeLoggerMethod(levels.info, levels.info, LOG_TYPES.SDK, true, true);\nvar _default2 = exports[\"default\"] = Logger;\n//# sourceMappingURL=logger.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/@webex/plugin-logger/dist/logger.js?");
|
|
12262
12262
|
|
|
12263
12263
|
/***/ }),
|
|
12264
12264
|
|
|
@@ -12346,7 +12346,7 @@ eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ?
|
|
|
12346
12346
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
12347
12347
|
|
|
12348
12348
|
"use strict";
|
|
12349
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst mobx_1 = __webpack_require__(/*! mobx */ \"../../../node_modules/mobx/dist/mobx.esm.js\");\nconst contact_center_1 = __importDefault(__webpack_require__(/*! webex/contact-center */ \"./node_modules/webex/dist/contact-center.js\"));\nclass Store {\n constructor() {\n this.teams = [];\n this.loginOptions = [];\n this.idleCodes = [];\n this.agentId = '';\n this.currentTheme = 'LIGHT';\n this.wrapupCodes = [];\n this.incomingTask = null;\n this.currentTask = null;\n this.isAgentLoggedIn = false;\n this.deviceType = '';\n this.
|
|
12349
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst mobx_1 = __webpack_require__(/*! mobx */ \"../../../node_modules/mobx/dist/mobx.esm.js\");\nconst contact_center_1 = __importDefault(__webpack_require__(/*! webex/contact-center */ \"./node_modules/webex/dist/contact-center.js\"));\nconst util_1 = __webpack_require__(/*! ./util */ \"./src/util.ts\");\nclass Store {\n constructor() {\n this.teams = [];\n this.loginOptions = [];\n this.idleCodes = [];\n this.agentId = '';\n this.currentTheme = 'LIGHT';\n this.wrapupCodes = [];\n this.incomingTask = null;\n this.currentTask = null;\n this.isAgentLoggedIn = false;\n this.deviceType = '';\n this.taskList = {};\n this.dialNumber = '';\n this.currentState = '';\n this.customState = null;\n this.consultCompleted = false;\n this.consultInitiated = false;\n this.consultAccepted = false;\n this.isQueueConsultInProgress = false;\n this.currentConsultQueueId = '';\n this.consultStartTimeStamp = undefined;\n this.showMultipleLoginAlert = false;\n this.callControlAudio = null;\n this.consultOfferReceived = false;\n this.featureFlags = {};\n this.isEndConsultEnabled = false;\n this.allowConsultToQueue = false;\n this.taskMetaData = {};\n (0, mobx_1.makeAutoObservable)(this, {\n cc: mobx_1.observable.ref,\n });\n }\n static getInstance() {\n if (!Store.instance) {\n console.log('Creating new store instance');\n Store.instance = new Store();\n }\n console.log('Returning store instance');\n return Store.instance;\n }\n registerCC(webex) {\n if (webex) {\n this.cc = webex.cc;\n }\n if (typeof webex === 'undefined' && typeof this.cc === 'undefined') {\n throw new Error('Webex SDK not initialized');\n }\n this.logger = this.cc.LoggerProxy;\n return this.cc\n .register()\n .then((response) => {\n var _a;\n this.featureFlags = (0, util_1.getFeatureFlags)(response);\n this.teams = response.teams;\n this.loginOptions = response.webRtcEnabled\n ? response.loginVoiceOptions\n : response.loginVoiceOptions.filter((option) => option !== 'BROWSER');\n this.idleCodes = response.idleCodes;\n this.agentId = response.agentId;\n this.wrapupCodes = response.wrapupCodes;\n this.isAgentLoggedIn = response.isAgentLoggedIn;\n this.deviceType = (_a = response.deviceType) !== null && _a !== void 0 ? _a : 'AGENT_DN';\n this.dialNumber = response.defaultDn;\n this.currentState = response.lastStateAuxCodeId;\n this.lastStateChangeTimestamp = response.lastStateChangeTimestamp;\n this.lastIdleCodeChangeTimestamp = response.lastIdleCodeChangeTimestamp;\n this.isEndConsultEnabled = response.isEndConsultEnabled;\n this.allowConsultToQueue = response.allowConsultToQueue;\n })\n .catch((error) => {\n this.logger.error(`Error registering contact center: ${error}`, {\n module: 'cc-store#store.ts',\n method: 'registerCC',\n });\n return Promise.reject(error);\n });\n }\n init(options, setupEventListeners) {\n if ('webex' in options) {\n // If devs decide to go with webex, they will have to listen to the ready event before calling init\n // This has to be documented\n setupEventListeners(options.webex.cc);\n return this.registerCC(options.webex);\n }\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n reject(new Error('Webex SDK failed to initialize'));\n }, 6000);\n const webex = contact_center_1.default.init({\n config: options.webexConfig,\n credentials: {\n access_token: options.access_token,\n },\n });\n webex.once('ready', () => {\n setupEventListeners(webex.cc);\n clearTimeout(timer);\n this.registerCC(webex)\n .then(() => {\n resolve();\n })\n .catch((error) => {\n reject(error);\n });\n });\n });\n }\n}\nexports[\"default\"] = Store;\n\n\n//# sourceURL=webpack://@webex/cc-store/./src/store.ts?");
|
|
12350
12350
|
|
|
12351
12351
|
/***/ }),
|
|
12352
12352
|
|
|
@@ -12357,7 +12357,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12357
12357
|
/***/ ((__unused_webpack_module, exports) => {
|
|
12358
12358
|
|
|
12359
12359
|
"use strict";
|
|
12360
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ENGAGED_USERNAME = exports.ENGAGED_LABEL = exports.TASK_EVENTS = exports.CC_EVENTS = void 0;\nvar TASK_EVENTS;\n(function (TASK_EVENTS) {\n TASK_EVENTS[\"TASK_INCOMING\"] = \"task:incoming\";\n TASK_EVENTS[\"TASK_ASSIGNED\"] = \"task:assigned\";\n TASK_EVENTS[\"TASK_MEDIA\"] = \"task:media\";\n TASK_EVENTS[\"TASK_HOLD\"] = \"task:hold\";\n TASK_EVENTS[\"TASK_UNHOLD\"] = \"task:unhold\";\n TASK_EVENTS[\"TASK_CONSULT\"] = \"task:consult\";\n TASK_EVENTS[\"TASK_CONSULT_END\"] = \"task:consultEnd\";\n TASK_EVENTS[\"TASK_CONSULT_ACCEPTED\"] = \"task:consultAccepted\";\n TASK_EVENTS[\"TASK_PAUSE\"] = \"task:pause\";\n TASK_EVENTS[\"TASK_RESUME\"] = \"task:resume\";\n TASK_EVENTS[\"TASK_END\"] = \"task:end\";\n TASK_EVENTS[\"TASK_WRAPUP\"] = \"task:wrapup\";\n TASK_EVENTS[\"TASK_REJECT\"] = \"task:rejected\";\n TASK_EVENTS[\"TASK_HYDRATE\"] = \"task:hydrate\";\n TASK_EVENTS[\"TASK_CONSULTING\"] = \"task:consulting\";\n TASK_EVENTS[\"TASK_CONSULT_QUEUE_CANCELLED\"] = \"task:consultQueueCancelled\";\n TASK_EVENTS[\"AGENT_CONTACT_ASSIGNED\"] = \"AgentContactAssigned\";\n TASK_EVENTS[\"CONTACT_RECORDING_PAUSED\"] = \"ContactRecordingPaused\";\n TASK_EVENTS[\"CONTACT_RECORDING_RESUMED\"] = \"ContactRecordingResumed\";\n TASK_EVENTS[\"AGENT_WRAPPEDUP\"] = \"AgentWrappedUp\";\n TASK_EVENTS[\"AGENT_CONSULT_CREATED\"] = \"AgentConsultCreated\";\n})(TASK_EVENTS || (exports.TASK_EVENTS = TASK_EVENTS = {})); // TODO: remove this once cc sdk exports this enum\n// Events that are received on the contact center SDK\n// TODO: Export & Import these constants from SDK\nvar CC_EVENTS;\n(function (CC_EVENTS) {\n CC_EVENTS[\"AGENT_DN_REGISTERED\"] = \"AgentDNRegistered\";\n CC_EVENTS[\"AGENT_LOGOUT_SUCCESS\"] = \"AgentLogoutSuccess\";\n CC_EVENTS[\"AGENT_STATION_LOGIN_SUCCESS\"] = \"AgentStationLoginSuccess\";\n CC_EVENTS[\"AGENT_MULTI_LOGIN\"] = \"agent:multiLogin\";\n CC_EVENTS[\"AGENT_STATE_CHANGE\"] = \"agent:stateChange\";\n CC_EVENTS[\"AGENT_RELOGIN_SUCCESS\"] = \"AgentReloginSuccess\";\n CC_EVENTS[\"AGENT_OFFER_CONSULT\"] = \"AgentOfferConsult\";\n})(CC_EVENTS || (exports.CC_EVENTS = CC_EVENTS = {}));\nconst ENGAGED_LABEL = 'ENGAGED';\nexports.ENGAGED_LABEL = ENGAGED_LABEL;\nconst ENGAGED_USERNAME = 'Engaged';\nexports.ENGAGED_USERNAME = ENGAGED_USERNAME;\n\n\n//# sourceURL=webpack://@webex/cc-store/./src/store.types.ts?");
|
|
12360
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ENGAGED_USERNAME = exports.ENGAGED_LABEL = exports.TASK_EVENTS = exports.CC_EVENTS = void 0;\nvar TASK_EVENTS;\n(function (TASK_EVENTS) {\n TASK_EVENTS[\"TASK_INCOMING\"] = \"task:incoming\";\n TASK_EVENTS[\"TASK_ASSIGNED\"] = \"task:assigned\";\n TASK_EVENTS[\"TASK_MEDIA\"] = \"task:media\";\n TASK_EVENTS[\"TASK_HOLD\"] = \"task:hold\";\n TASK_EVENTS[\"TASK_UNHOLD\"] = \"task:unhold\";\n TASK_EVENTS[\"TASK_CONSULT\"] = \"task:consult\";\n TASK_EVENTS[\"TASK_CONSULT_END\"] = \"task:consultEnd\";\n TASK_EVENTS[\"TASK_CONSULT_ACCEPTED\"] = \"task:consultAccepted\";\n TASK_EVENTS[\"TASK_PAUSE\"] = \"task:pause\";\n TASK_EVENTS[\"TASK_RESUME\"] = \"task:resume\";\n TASK_EVENTS[\"TASK_END\"] = \"task:end\";\n TASK_EVENTS[\"TASK_WRAPUP\"] = \"task:wrapup\";\n TASK_EVENTS[\"TASK_REJECT\"] = \"task:rejected\";\n TASK_EVENTS[\"TASK_HYDRATE\"] = \"task:hydrate\";\n TASK_EVENTS[\"TASK_CONSULTING\"] = \"task:consulting\";\n TASK_EVENTS[\"TASK_CONSULT_QUEUE_CANCELLED\"] = \"task:consultQueueCancelled\";\n TASK_EVENTS[\"AGENT_CONTACT_ASSIGNED\"] = \"AgentContactAssigned\";\n TASK_EVENTS[\"CONTACT_RECORDING_PAUSED\"] = \"ContactRecordingPaused\";\n TASK_EVENTS[\"CONTACT_RECORDING_RESUMED\"] = \"ContactRecordingResumed\";\n TASK_EVENTS[\"AGENT_WRAPPEDUP\"] = \"AgentWrappedUp\";\n TASK_EVENTS[\"AGENT_OFFER_CONTACT\"] = \"AgentOfferContact\";\n TASK_EVENTS[\"AGENT_CONSULT_CREATED\"] = \"AgentConsultCreated\";\n})(TASK_EVENTS || (exports.TASK_EVENTS = TASK_EVENTS = {})); // TODO: remove this once cc sdk exports this enum\n// Events that are received on the contact center SDK\n// TODO: Export & Import these constants from SDK\nvar CC_EVENTS;\n(function (CC_EVENTS) {\n CC_EVENTS[\"AGENT_DN_REGISTERED\"] = \"AgentDNRegistered\";\n CC_EVENTS[\"AGENT_LOGOUT_SUCCESS\"] = \"AgentLogoutSuccess\";\n CC_EVENTS[\"AGENT_STATION_LOGIN_SUCCESS\"] = \"AgentStationLoginSuccess\";\n CC_EVENTS[\"AGENT_MULTI_LOGIN\"] = \"agent:multiLogin\";\n CC_EVENTS[\"AGENT_STATE_CHANGE\"] = \"agent:stateChange\";\n CC_EVENTS[\"AGENT_RELOGIN_SUCCESS\"] = \"AgentReloginSuccess\";\n CC_EVENTS[\"AGENT_OFFER_CONSULT\"] = \"AgentOfferConsult\";\n})(CC_EVENTS || (exports.CC_EVENTS = CC_EVENTS = {}));\nconst ENGAGED_LABEL = 'ENGAGED';\nexports.ENGAGED_LABEL = ENGAGED_LABEL;\nconst ENGAGED_USERNAME = 'Engaged';\nexports.ENGAGED_USERNAME = ENGAGED_USERNAME;\n\n\n//# sourceURL=webpack://@webex/cc-store/./src/store.types.ts?");
|
|
12361
12361
|
|
|
12362
12362
|
/***/ }),
|
|
12363
12363
|
|
|
@@ -12368,7 +12368,18 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
12368
12368
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
12369
12369
|
|
|
12370
12370
|
"use strict";
|
|
12371
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst store_types_1 = __webpack_require__(/*! ./store.types */ \"./src/store.types.ts\");\nconst store_1 = __importDefault(__webpack_require__(/*! ./store */ \"./src/store.ts\"));\nconst mobx_1 = __webpack_require__(/*! mobx */ \"../../../node_modules/mobx/dist/mobx.esm.js\");\nclass StoreWrapper {\n constructor() {\n this.setCurrentTheme = (theme) => {\n this.store.currentTheme = theme;\n };\n this.setShowMultipleLoginAlert = (value) => {\n this.store.showMultipleLoginAlert = value;\n };\n this.setDeviceType = (option) => {\n this.store.deviceType = option;\n };\n this.setDialNumber = (input) => {\n this.store.dialNumber = input;\n };\n this.setCurrentState = (state) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentState = state;\n this.store.customState = null;\n });\n };\n this.setLastStateChangeTimestamp = (timestamp) => {\n (0, mobx_1.runInAction)(() => {\n this.store.lastStateChangeTimestamp = timestamp;\n });\n };\n this.setLastIdleCodeChangeTimestamp = (timestamp) => {\n (0, mobx_1.runInAction)(() => {\n this.store.lastIdleCodeChangeTimestamp = timestamp;\n });\n };\n this.setIsAgentLoggedIn = (value) => {\n this.store.isAgentLoggedIn = value;\n };\n this.setWrapupRequired = (value) => {\n this.store.wrapupRequired = value;\n };\n this.setCurrentTask = (task) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentTask = task;\n });\n };\n this.setIncomingTask = (task) => {\n this.store.incomingTask = task;\n };\n this.setTaskList = (taskList) => {\n this.store.taskList = taskList;\n };\n this.setWrapupCodes = (wrapupCodes) => {\n this.store.wrapupCodes = wrapupCodes;\n };\n this.setConsultCompleted = (value) => {\n this.store.consultCompleted = value;\n };\n this.setConsultInitiated = (value) => {\n this.store.consultInitiated = value;\n };\n this.setConsultAccepted = (value) => {\n this.store.consultAccepted = value;\n };\n this.setConsultOfferReceived = (value) => {\n this.store.consultOfferReceived = value;\n };\n this.setConsultStartTimeStamp = (timestamp) => {\n this.store.consultStartTimeStamp = timestamp;\n };\n this.setCallControlAudio = (audio) => {\n this.store.callControlAudio = audio;\n };\n this.setIsQueueConsultInProgress = (value) => {\n (0, mobx_1.runInAction)(() => {\n this.store.isQueueConsultInProgress = value;\n });\n };\n this.setCurrentConsultQueueId = (queueId) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentConsultQueueId = queueId;\n });\n };\n this.setState = (state) => {\n if ('reset' in state) {\n (0, mobx_1.runInAction)(() => {\n this.store.customState = null;\n });\n return;\n }\n if ('id' in state) {\n (0, mobx_1.runInAction)(() => {\n this.setCurrentState(state.id);\n this.store.customState = null;\n });\n }\n else {\n (0, mobx_1.runInAction)(() => {\n this.store.customState = state;\n });\n }\n };\n this.setTaskRejected = (callback) => {\n this.onTaskRejected = callback;\n };\n this.setCCCallback = (event, callback) => {\n if (!callback)\n return;\n this.store.cc.on(event, callback);\n };\n this.setTaskCallback = (event, callback, taskId) => {\n if (!callback)\n return;\n const task = this.store.taskList.find((task) => task.data.interactionId === taskId);\n if (!task)\n return;\n task.on(event, callback);\n };\n this.removeCCCallback = (event) => {\n this.store.cc.off(event);\n };\n this.removeTaskCallback = (event, callback, taskId) => {\n if (!callback)\n return;\n const task = this.store.taskList.find((task) => task.data.interactionId === taskId);\n if (!task)\n return;\n task.off(event, callback);\n };\n this.registerCC = (webex) => {\n return this.store.registerCC(webex);\n };\n this.handleTaskRemove = (event) => {\n const taskId = event;\n // Remove the task from the taskList\n const taskToRemove = this.store.taskList.find((task) => task.data.interactionId === taskId);\n if (taskToRemove) {\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_END, this.handleTaskEnd);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(taskToRemove.interactionId, reason));\n taskToRemove.off(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n taskToRemove.off(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n taskToRemove.off(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n this.setCallControlAudio(null);\n }\n }\n const updateTaskList = this.store.taskList.filter((task) => task.data.interactionId !== taskId);\n (0, mobx_1.runInAction)(() => {\n var _a, _b;\n this.setTaskList(updateTaskList);\n this.setWrapupRequired(false);\n this.setConsultAccepted(false);\n this.setConsultInitiated(false);\n this.setConsultCompleted(false);\n // Remove the task from currentTask or incomingTask if it is the same task\n if (((_a = this.store.currentTask) === null || _a === void 0 ? void 0 : _a.data.interactionId) === taskId) {\n this.setCurrentTask(null);\n }\n if (((_b = this.store.incomingTask) === null || _b === void 0 ? void 0 : _b.data.interactionId) === taskId) {\n this.setIncomingTask(null);\n }\n // reset the custom state\n this.setState({\n reset: true,\n });\n });\n };\n this.handleTaskEnd = (event) => {\n // If the call is ended by agent we get the task object in event.data\n // If the call is ended by customer we get the task object directly\n const task = event.data ? event.data : event;\n if (task.wrapUpRequired) {\n this.setWrapupRequired(true);\n }\n else {\n this.handleTaskRemove(task.interactionId);\n }\n };\n this.handleTaskAssigned = (event) => {\n const task = event;\n (0, mobx_1.runInAction)(() => {\n if (this.consultAccepted) {\n this.setConsultAccepted(false);\n this.setConsultInitiated(false);\n this.setConsultCompleted(false);\n this.setConsultOfferReceived(false);\n }\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n });\n };\n this.handleTaskWrapUp = (event) => {\n const task = event;\n this.setWrapupRequired(false);\n this.handleTaskRemove(task.interactionId);\n };\n this.handleTaskMedia = (track) => {\n this.setCallControlAudio(new MediaStream([track]));\n };\n // Case to handle multi session\n this.handleConsultCreated = () => {\n this.setConsultInitiated(true);\n this.setConsultStartTimeStamp(Date.now());\n };\n this.handleConsulting = (event) => {\n this.setConsultCompleted(true);\n this.setCurrentTask(event);\n this.handleIncomingTask(event);\n this.setConsultStartTimeStamp(Date.now());\n };\n this.handleConsultEnd = (event) => {\n const task = event;\n this.setConsultInitiated(false);\n this.setIsQueueConsultInProgress(false);\n this.setCurrentConsultQueueId(null);\n if (this.consultAccepted) {\n this.setConsultAccepted(false);\n this.handleTaskRemove(task.data.interactionId);\n }\n else if (this.consultOfferReceived) {\n this.setConsultOfferReceived(false);\n this.handleTaskRemove(task.data.interactionId);\n }\n this.setConsultCompleted(false);\n this.setConsultStartTimeStamp(null);\n };\n this.handleConsultOffer = () => {\n this.setConsultOfferReceived(true);\n };\n this.handleConsultAccepted = (event) => {\n const task = event;\n (0, mobx_1.runInAction)(() => {\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n this.setConsultAccepted(true);\n this.setConsultStartTimeStamp(Date.now());\n this.setConsultCompleted(true);\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n });\n };\n this.handleConsultQueueCancelled = () => {\n this.setConsultInitiated(false);\n this.setIsQueueConsultInProgress(false);\n this.setCurrentConsultQueueId(null);\n this.setConsultStartTimeStamp(null);\n };\n this.handleIncomingTask = (event) => {\n const task = event;\n if (this.store.taskList.some((t) => t.data.interactionId === task.data.interactionId)) {\n // Task already present in the taskList\n return;\n }\n // Attach event listeners to the task\n task.on(store_types_1.TASK_EVENTS.TASK_END, () => this.handleTaskEnd(task));\n // When we receive TASK_ASSIGNED the task was accepted by the agent and we need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n task.on(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n // When we receive TASK_REJECT sdk changes the agent status\n // When we receive TASK_REJECT that means the task was not accepted by the agent and we wont need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(task.data.interactionId, reason));\n task.on(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n task.on(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n this.setIncomingTask(task);\n this.setTaskList([...this.store.taskList, task]);\n };\n this.handleStateChange = (data) => {\n var _a;\n if (data && typeof data === 'object' && data.type === 'AgentStateChangeSuccess') {\n const DEFAULT_CODE = '0'; // Default code when no aux code is present\n this.setCurrentState(((_a = data.auxCodeId) === null || _a === void 0 ? void 0 : _a.trim()) !== '' ? data.auxCodeId : DEFAULT_CODE);\n this.setLastStateChangeTimestamp(data.lastStateChangeTimestamp);\n this.setLastIdleCodeChangeTimestamp(data.lastIdleCodeChangeTimestamp);\n }\n };\n this.handleMultiLoginCloseSession = (data) => {\n if (data && typeof data === 'object' && data.type === 'AgentMultiLoginCloseSession') {\n this.setShowMultipleLoginAlert(true);\n }\n };\n this.handleTaskHydrate = (event) => {\n const task = event;\n task.on(store_types_1.TASK_EVENTS.TASK_END, () => this.handleTaskEnd(task));\n // When we receive TASK_ASSIGNED the task was accepted by the agent and we need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n task.on(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n // When we receive TASK_REJECT sdk changes the agent status\n // When we receive TASK_REJECT that means the task was not accepted by the agent and we wont need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(task.data.interactionId, reason));\n task.on(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n task.on(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n if (!this.store.taskList.some((t) => t.data.interactionId === task.data.interactionId)) {\n this.setTaskList([...this.store.taskList, task]);\n }\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n if (task.data.interaction.state === 'consulting') {\n if (task.data.isConsulted) {\n this.setConsultAccepted(true);\n }\n else {\n this.setConsultInitiated(true);\n }\n this.setConsultStartTimeStamp(Date.now());\n this.setConsultCompleted(true);\n }\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n const { interaction } = task.data;\n const { isTerminated } = interaction;\n // Update call control states\n if (isTerminated) {\n // wrapup\n this.setWrapupRequired(task.data.wrapUpRequired);\n if (!task.data.wrapUpRequired) {\n this.setState({\n reset: true,\n });\n }\n return;\n }\n };\n this.handleTaskReject = (taskId, reason) => {\n if (this.onTaskRejected) {\n this.onTaskRejected(reason || 'No reason provided');\n }\n this.handleTaskRemove(taskId);\n };\n this.getBuddyAgents = () => __awaiter(this, void 0, void 0, function* () {\n try {\n const response = yield this.store.cc.getBuddyAgents({\n mediaType: 'telephony',\n state: 'Available',\n });\n return response.data.agentList;\n }\n catch (error) {\n return Promise.reject(error);\n }\n });\n this.getQueues = () => __awaiter(this, void 0, void 0, function* () {\n try {\n let queueList = yield this.store.cc.getQueues();\n queueList = queueList.filter((queue) => queue.channelType === 'TELEPHONY');\n return queueList;\n }\n catch (error) {\n console.error('Error fetching queues:', error);\n return Promise.reject(error);\n }\n });\n this.cleanUpStore = () => {\n (0, mobx_1.runInAction)(() => {\n this.setIsAgentLoggedIn(false);\n this.setDeviceType('AGENT_DN');\n this.setDialNumber('');\n this.setIncomingTask(null);\n this.setCurrentTask(null);\n this.setTaskList([]);\n this.setWrapupRequired(false);\n this.setLastStateChangeTimestamp(undefined);\n this.setLastIdleCodeChangeTimestamp(undefined);\n this.setShowMultipleLoginAlert(false);\n this.setConsultStartTimeStamp(undefined);\n });\n };\n this.setupIncomingTaskHandler = (ccSDK) => {\n let listenersAdded = false;\n const handleLogOut = () => {\n this.cleanUpStore();\n removeEventListeners();\n listenersAdded = false;\n };\n const addEventListeners = () => {\n ccSDK.on(store_types_1.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_STATE_CHANGE, this.handleStateChange);\n ccSDK.on(store_types_1.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_MULTI_LOGIN, this.handleMultiLoginCloseSession);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_LOGOUT_SUCCESS, handleLogOut);\n };\n const removeEventListeners = () => {\n ccSDK.off(store_types_1.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_STATE_CHANGE, this.handleStateChange);\n ccSDK.off(store_types_1.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_MULTI_LOGIN, this.handleMultiLoginCloseSession);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_LOGOUT_SUCCESS, handleLogOut);\n };\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n const handleLogin = (payload) => {\n (0, mobx_1.runInAction)(() => {\n var _a;\n this.setIsAgentLoggedIn(true);\n this.setDeviceType(payload.deviceType);\n this.setDialNumber(payload.dn);\n this.setCurrentState(((_a = payload.auxCodeId) === null || _a === void 0 ? void 0 : _a.trim()) !== '' ? payload.auxCodeId : '0');\n this.setLastStateChangeTimestamp(payload.lastStateChangeTimestamp);\n this.setLastIdleCodeChangeTimestamp(payload.lastIdleCodeChangeTimestamp);\n });\n };\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_STATION_LOGIN_SUCCESS, handleLogin);\n [store_types_1.CC_EVENTS.AGENT_DN_REGISTERED, store_types_1.CC_EVENTS.AGENT_RELOGIN_SUCCESS].forEach((event) => {\n ccSDK.on(`${event}`, () => {\n if (!listenersAdded) {\n addEventListeners();\n listenersAdded = true;\n }\n });\n });\n };\n this.store = store_1.default.getInstance();\n }\n // Proxy all methods and properties of the original store\n get teams() {\n return this.store.teams;\n }\n get loginOptions() {\n return this.store.loginOptions;\n }\n get cc() {\n return this.store.cc;\n }\n get logger() {\n return this.store.logger;\n }\n get idleCodes() {\n return this.store.idleCodes.filter((code) => {\n return code.name === 'RONA' || !code.isSystem;\n });\n }\n get agentId() {\n return this.store.agentId;\n }\n get deviceType() {\n return this.store.deviceType;\n }\n get dialNumber() {\n return this.store.dialNumber;\n }\n get wrapupCodes() {\n return this.store.wrapupCodes;\n }\n get currentTask() {\n return this.store.currentTask;\n }\n get isAgentLoggedIn() {\n return this.store.isAgentLoggedIn;\n }\n get taskList() {\n return this.store.taskList;\n }\n get incomingTask() {\n return this.store.incomingTask;\n }\n get wrapupRequired() {\n return this.store.wrapupRequired;\n }\n get currentState() {\n return this.store.currentState;\n }\n get lastStateChangeTimestamp() {\n return this.store.lastStateChangeTimestamp;\n }\n get lastIdleCodeChangeTimestamp() {\n return this.store.lastIdleCodeChangeTimestamp;\n }\n get showMultipleLoginAlert() {\n return this.store.showMultipleLoginAlert;\n }\n get currentTheme() {\n return this.store.currentTheme;\n }\n get customState() {\n return this.store.customState;\n }\n get consultCompleted() {\n return this.store.consultCompleted;\n }\n get consultInitiated() {\n return this.store.consultInitiated;\n }\n get consultAccepted() {\n return this.store.consultAccepted;\n }\n get consultStartTimeStamp() {\n return this.store.consultStartTimeStamp;\n }\n get callControlAudio() {\n return this.store.callControlAudio;\n }\n get consultOfferReceived() {\n return this.store.consultOfferReceived;\n }\n get isQueueConsultInProgress() {\n return this.store.isQueueConsultInProgress;\n }\n get currentConsultQueueId() {\n return this.store.currentConsultQueueId;\n }\n get isEndConsultEnabled() {\n return this.store.isEndConsultEnabled;\n }\n get allowConsultToQueue() {\n return this.store.allowConsultToQueue;\n }\n init(options) {\n return this.store.init(options, this.setupIncomingTaskHandler);\n }\n}\n// Create and export a single instance of the wrapper\nconst storeWrapper = new StoreWrapper();\nexports[\"default\"] = storeWrapper;\n\n\n//# sourceURL=webpack://@webex/cc-store/./src/storeEventsWrapper.ts?");
|
|
12371
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst store_types_1 = __webpack_require__(/*! ./store.types */ \"./src/store.types.ts\");\nconst store_1 = __importDefault(__webpack_require__(/*! ./store */ \"./src/store.ts\"));\nconst mobx_1 = __webpack_require__(/*! mobx */ \"../../../node_modules/mobx/dist/mobx.esm.js\");\nclass StoreWrapper {\n constructor() {\n this.setTaskMetaData = (taskId, data) => {\n this.store.taskMetaData[taskId] = data;\n };\n this.setCurrentTheme = (theme) => {\n this.store.currentTheme = theme;\n };\n this.setShowMultipleLoginAlert = (value) => {\n this.store.showMultipleLoginAlert = value;\n };\n this.setDeviceType = (option) => {\n this.store.deviceType = option;\n };\n this.setDialNumber = (input) => {\n this.store.dialNumber = input;\n };\n this.setCurrentState = (state) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentState = state;\n this.store.customState = null;\n });\n };\n this.setLastStateChangeTimestamp = (timestamp) => {\n (0, mobx_1.runInAction)(() => {\n this.store.lastStateChangeTimestamp = timestamp;\n });\n };\n this.setLastIdleCodeChangeTimestamp = (timestamp) => {\n (0, mobx_1.runInAction)(() => {\n this.store.lastIdleCodeChangeTimestamp = timestamp;\n });\n };\n this.setIsAgentLoggedIn = (value) => {\n this.store.isAgentLoggedIn = value;\n };\n this.setCurrentTask = (task) => {\n (0, mobx_1.runInAction)(() => {\n var _a, _b, _c;\n // Save data from the current task if it exists\n if (this.currentTask) {\n const interactionId = (_b = (_a = this.currentTask) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.interactionId;\n this.setTaskMetaData(interactionId, {\n consultCompleted: this.store.consultCompleted,\n consultInitiated: this.store.consultInitiated,\n consultAccepted: this.store.consultAccepted,\n isQueueConsultInProgress: this.store.isQueueConsultInProgress,\n currentConsultQueueId: this.store.currentConsultQueueId,\n consultStartTimeStamp: this.store.consultStartTimeStamp,\n consultOfferReceived: this.store.consultOfferReceived,\n });\n }\n // Update the current task\n this.store.currentTask = task ? Object.assign(Object.create(Object.getPrototypeOf(task)), task) : null;\n // Restore data for the new task if available\n const currentTaskMetaData = this.store.taskMetaData[(_c = task === null || task === void 0 ? void 0 : task.data) === null || _c === void 0 ? void 0 : _c.interactionId];\n if (currentTaskMetaData) {\n const { consultAccepted = false, consultInitiated = false, consultCompleted = false, isQueueConsultInProgress = false, currentConsultQueueId = null, consultStartTimeStamp = null, consultOfferReceived = false, } = currentTaskMetaData;\n this.setConsultAccepted(consultAccepted);\n this.setConsultInitiated(consultInitiated);\n this.setConsultCompleted(consultCompleted);\n this.setIsQueueConsultInProgress(isQueueConsultInProgress);\n this.setCurrentConsultQueueId(currentConsultQueueId);\n this.setConsultStartTimeStamp(consultStartTimeStamp);\n this.setConsultOfferReceived(consultOfferReceived);\n }\n });\n };\n this.setIncomingTask = (task) => {\n this.store.incomingTask = task;\n };\n this.refreshTaskList = () => {\n var _a, _b;\n (0, mobx_1.runInAction)(() => {\n this.store.taskList = this.store.cc.taskManager.getAllTasks();\n });\n if (this.currentTask) {\n this.setCurrentTask(this.taskList[(_b = (_a = this.currentTask) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.interactionId]);\n }\n else if (this.store.taskList.length > 0) {\n this.setCurrentTask(this.store.taskList[Object.keys(this.store.taskList)[0]]);\n }\n };\n this.setWrapupCodes = (wrapupCodes) => {\n this.store.wrapupCodes = wrapupCodes;\n };\n this.setConsultCompleted = (value) => {\n this.store.consultCompleted = value;\n };\n this.setConsultInitiated = (value) => {\n this.store.consultInitiated = value;\n };\n this.setConsultAccepted = (value) => {\n this.store.consultAccepted = value;\n };\n this.setConsultOfferReceived = (value) => {\n this.store.consultOfferReceived = value;\n };\n this.setConsultStartTimeStamp = (timestamp) => {\n this.store.consultStartTimeStamp = timestamp;\n };\n this.setCallControlAudio = (audio) => {\n this.store.callControlAudio = audio;\n };\n this.setIsQueueConsultInProgress = (value) => {\n (0, mobx_1.runInAction)(() => {\n this.store.isQueueConsultInProgress = value;\n });\n };\n this.setCurrentConsultQueueId = (queueId) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentConsultQueueId = queueId;\n });\n };\n this.setState = (state) => {\n if ('reset' in state) {\n (0, mobx_1.runInAction)(() => {\n this.store.customState = null;\n });\n return;\n }\n if ('id' in state) {\n (0, mobx_1.runInAction)(() => {\n this.setCurrentState(state.id);\n this.store.customState = null;\n });\n }\n else {\n (0, mobx_1.runInAction)(() => {\n this.store.customState = state;\n });\n }\n };\n this.setTaskRejected = (callback) => {\n this.onTaskRejected = callback;\n };\n this.setTaskAssigned = (callback) => {\n this.onTaskAssigned = callback;\n };\n this.setCCCallback = (event, callback) => {\n if (!callback)\n return;\n this.store.cc.on(event, callback);\n };\n this.setTaskCallback = (event, callback, taskId) => {\n if (!callback)\n return;\n const task = this.store.taskList[taskId];\n if (!task)\n return;\n task.on(event, callback);\n };\n this.removeCCCallback = (event) => {\n this.store.cc.off(event);\n };\n this.removeTaskCallback = (event, callback, taskId) => {\n if (!callback)\n return;\n const task = this.store.taskList[taskId];\n if (!task)\n return;\n task.off(event, callback);\n };\n this.registerCC = (webex) => {\n return this.store.registerCC(webex);\n };\n this.handleTaskRemove = (taskId) => {\n const taskToRemove = this.store.taskList[taskId];\n if (taskToRemove) {\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_END, this.handleTaskEnd);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(taskToRemove, reason));\n taskToRemove.off(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n taskToRemove.off(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n taskToRemove.off(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n taskToRemove.off(store_types_1.TASK_EVENTS.AGENT_OFFER_CONTACT, this.refreshTaskList);\n if (this.deviceType === 'BROWSER') {\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n this.setCallControlAudio(null);\n }\n }\n (0, mobx_1.runInAction)(() => {\n var _a, _b, _c;\n this.setConsultAccepted(false);\n this.setConsultInitiated(false);\n this.setConsultCompleted(false);\n delete this.taskMetaData[taskId];\n if (((_a = this.store.currentTask) === null || _a === void 0 ? void 0 : _a.data.interactionId) === taskId) {\n this.setCurrentTask(null);\n }\n if (((_c = (_b = this.store.incomingTask) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.interactionId) === taskId) {\n this.setIncomingTask(null);\n }\n this.setState({\n reset: true,\n });\n this.refreshTaskList();\n });\n };\n this.handleTaskEnd = () => {\n this.refreshTaskList();\n };\n this.handleTaskAssigned = (event) => {\n const task = event;\n if (this.onTaskAssigned) {\n this.onTaskAssigned(task);\n }\n (0, mobx_1.runInAction)(() => {\n var _a;\n if (this.currentTask) {\n this.setTaskMetaData(this.currentTask.data.interactionId, {\n consultCompleted: this.store.consultCompleted,\n consultInitiated: this.store.consultInitiated,\n consultAccepted: this.store.consultAccepted,\n isQueueConsultInProgress: this.store.isQueueConsultInProgress,\n currentConsultQueueId: this.store.currentConsultQueueId,\n consultStartTimeStamp: this.store.consultStartTimeStamp,\n consultOfferReceived: this.store.consultOfferReceived,\n });\n }\n else {\n this.setTaskMetaData((_a = task === null || task === void 0 ? void 0 : task.data) === null || _a === void 0 ? void 0 : _a.interactionId, {\n consultCompleted: false,\n consultInitiated: false,\n consultAccepted: false,\n isQueueConsultInProgress: false,\n currentConsultQueueId: '',\n consultStartTimeStamp: null,\n consultOfferReceived: false,\n });\n }\n if (this.consultAccepted) {\n this.setConsultAccepted(false);\n this.setConsultInitiated(false);\n this.setConsultCompleted(false);\n this.setConsultOfferReceived(false);\n }\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n });\n };\n this.handleTaskWrapUp = (task) => {\n var _a;\n this.handleTaskRemove((_a = task === null || task === void 0 ? void 0 : task.data) === null || _a === void 0 ? void 0 : _a.interactionId);\n };\n this.handleTaskMedia = (track) => {\n this.setCallControlAudio(new MediaStream([track]));\n };\n // Case to handle multi session\n this.handleConsultCreated = () => {\n this.setConsultInitiated(true);\n this.setConsultStartTimeStamp(Date.now());\n };\n this.handleConsulting = (event) => {\n this.setConsultCompleted(true);\n this.setCurrentTask(event);\n this.handleIncomingTask(event);\n this.setConsultStartTimeStamp(Date.now());\n };\n this.handleConsultEnd = (event) => {\n const task = event;\n this.setConsultInitiated(false);\n this.setIsQueueConsultInProgress(false);\n this.setCurrentConsultQueueId(null);\n if (this.consultAccepted) {\n this.setConsultAccepted(false);\n this.handleTaskRemove(task.data.interactionId);\n }\n else if (this.consultOfferReceived) {\n this.setConsultOfferReceived(false);\n this.handleTaskRemove(task.data.interactionId);\n }\n this.setConsultCompleted(false);\n this.setConsultStartTimeStamp(null);\n };\n this.handleConsultOffer = () => {\n this.setConsultOfferReceived(true);\n };\n this.handleConsultAccepted = (event) => {\n const task = event;\n (0, mobx_1.runInAction)(() => {\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n this.setConsultAccepted(true);\n this.setConsultStartTimeStamp(Date.now());\n this.setConsultCompleted(true);\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n });\n };\n this.handleConsultQueueCancelled = () => {\n this.setConsultInitiated(false);\n this.setIsQueueConsultInProgress(false);\n this.setCurrentConsultQueueId(null);\n this.setConsultStartTimeStamp(null);\n };\n this.handleIncomingTask = (event) => {\n const task = event;\n // Attach event listeners to the task\n task.on(store_types_1.TASK_EVENTS.TASK_END, this.handleTaskEnd);\n // When we receive TASK_ASSIGNED the task was accepted by the agent and we need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n task.on(store_types_1.TASK_EVENTS.AGENT_OFFER_CONTACT, this.refreshTaskList);\n task.on(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n // When we receive TASK_REJECT sdk changes the agent status\n // When we receive TASK_REJECT that means the task was not accepted by the agent and we wont need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(task, reason));\n task.on(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n task.on(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n this.setIncomingTask(task);\n this.refreshTaskList();\n };\n this.handleStateChange = (data) => {\n var _a;\n if (data && typeof data === 'object' && data.type === 'AgentStateChangeSuccess') {\n const DEFAULT_CODE = '0'; // Default code when no aux code is present\n this.setCurrentState(((_a = data.auxCodeId) === null || _a === void 0 ? void 0 : _a.trim()) !== '' ? data.auxCodeId : DEFAULT_CODE);\n this.setLastStateChangeTimestamp(data.lastStateChangeTimestamp);\n this.setLastIdleCodeChangeTimestamp(data.lastIdleCodeChangeTimestamp);\n }\n };\n this.handleMultiLoginCloseSession = (data) => {\n if (data && typeof data === 'object' && data.type === 'AgentMultiLoginCloseSession') {\n this.setShowMultipleLoginAlert(true);\n }\n };\n this.handleTaskHydrate = (event) => {\n const task = event;\n task.on(store_types_1.TASK_EVENTS.TASK_END, this.handleTaskEnd);\n // When we receive TASK_ASSIGNED the task was accepted by the agent and we need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n task.on(store_types_1.TASK_EVENTS.AGENT_OFFER_CONTACT, this.refreshTaskList);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n task.on(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n // When we receive TASK_REJECT sdk changes the agent status\n // When we receive TASK_REJECT that means the task was not accepted by the agent and we wont need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(task, reason));\n task.on(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n task.on(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n this.refreshTaskList();\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n if (task.data.interaction.state === 'consulting') {\n if (task.data.isConsulted) {\n this.setConsultAccepted(true);\n }\n else {\n this.setConsultInitiated(true);\n }\n this.setConsultStartTimeStamp(Date.now());\n this.setConsultCompleted(true);\n }\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n const { interaction } = task.data;\n const { isTerminated } = interaction;\n // Update call control states\n if (isTerminated) {\n if (!task.data.wrapUpRequired) {\n this.setState({\n reset: true,\n });\n }\n return;\n }\n };\n this.handleTaskReject = (task, reason) => {\n if (this.onTaskRejected) {\n this.onTaskRejected(task, reason || 'No reason provided');\n }\n this.handleTaskRemove(task.data.interactionId);\n };\n this.getBuddyAgents = () => __awaiter(this, void 0, void 0, function* () {\n try {\n const response = yield this.store.cc.getBuddyAgents({\n mediaType: 'telephony',\n state: 'Available',\n });\n return response.data.agentList;\n }\n catch (error) {\n return Promise.reject(error);\n }\n });\n this.getQueues = () => __awaiter(this, void 0, void 0, function* () {\n try {\n let queueList = yield this.store.cc.getQueues();\n queueList = queueList.filter((queue) => queue.channelType === 'TELEPHONY');\n return queueList;\n }\n catch (error) {\n console.error('Error fetching queues:', error);\n return Promise.reject(error);\n }\n });\n this.cleanUpStore = () => {\n (0, mobx_1.runInAction)(() => {\n this.setIsAgentLoggedIn(false);\n this.setDeviceType('AGENT_DN');\n this.setDialNumber('');\n this.setIncomingTask(null);\n this.setCurrentTask(null);\n this.refreshTaskList();\n this.setLastStateChangeTimestamp(undefined);\n this.setLastIdleCodeChangeTimestamp(undefined);\n this.setShowMultipleLoginAlert(false);\n this.setConsultStartTimeStamp(undefined);\n });\n };\n this.setupIncomingTaskHandler = (ccSDK) => {\n let listenersAdded = false;\n const handleLogOut = () => {\n this.cleanUpStore();\n removeEventListeners();\n listenersAdded = false;\n };\n const addEventListeners = () => {\n ccSDK.on(store_types_1.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_STATE_CHANGE, this.handleStateChange);\n ccSDK.on(store_types_1.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_MULTI_LOGIN, this.handleMultiLoginCloseSession);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_LOGOUT_SUCCESS, handleLogOut);\n };\n const removeEventListeners = () => {\n ccSDK.off(store_types_1.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_STATE_CHANGE, this.handleStateChange);\n ccSDK.off(store_types_1.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_MULTI_LOGIN, this.handleMultiLoginCloseSession);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_LOGOUT_SUCCESS, handleLogOut);\n };\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n const handleLogin = (payload) => {\n (0, mobx_1.runInAction)(() => {\n var _a;\n this.setIsAgentLoggedIn(true);\n this.setDeviceType(payload.deviceType);\n this.setDialNumber(payload.dn);\n this.setCurrentState(((_a = payload.auxCodeId) === null || _a === void 0 ? void 0 : _a.trim()) !== '' ? payload.auxCodeId : '0');\n this.setLastStateChangeTimestamp(payload.lastStateChangeTimestamp);\n this.setLastIdleCodeChangeTimestamp(payload.lastIdleCodeChangeTimestamp);\n });\n };\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_STATION_LOGIN_SUCCESS, handleLogin);\n [store_types_1.CC_EVENTS.AGENT_DN_REGISTERED, store_types_1.CC_EVENTS.AGENT_RELOGIN_SUCCESS].forEach((event) => {\n ccSDK.on(`${event}`, () => {\n if (!listenersAdded) {\n addEventListeners();\n listenersAdded = true;\n }\n });\n });\n };\n this.store = store_1.default.getInstance();\n }\n // Proxy all methods and properties of the original store\n get featureFlags() {\n return this.store.featureFlags;\n }\n get teams() {\n return this.store.teams;\n }\n get loginOptions() {\n return this.store.loginOptions;\n }\n get cc() {\n return this.store.cc;\n }\n get logger() {\n return this.store.logger;\n }\n get idleCodes() {\n return this.store.idleCodes.filter((code) => {\n return code.name === 'RONA' || !code.isSystem;\n });\n }\n get agentId() {\n return this.store.agentId;\n }\n get deviceType() {\n return this.store.deviceType;\n }\n get dialNumber() {\n return this.store.dialNumber;\n }\n get wrapupCodes() {\n return this.store.wrapupCodes;\n }\n get currentTask() {\n return this.store.currentTask;\n }\n get isAgentLoggedIn() {\n return this.store.isAgentLoggedIn;\n }\n get taskList() {\n return this.store.taskList;\n }\n get incomingTask() {\n return this.store.incomingTask;\n }\n get currentState() {\n return this.store.currentState;\n }\n get lastStateChangeTimestamp() {\n return this.store.lastStateChangeTimestamp;\n }\n get lastIdleCodeChangeTimestamp() {\n return this.store.lastIdleCodeChangeTimestamp;\n }\n get showMultipleLoginAlert() {\n return this.store.showMultipleLoginAlert;\n }\n get currentTheme() {\n return this.store.currentTheme;\n }\n get customState() {\n return this.store.customState;\n }\n get consultCompleted() {\n return this.store.consultCompleted;\n }\n get consultInitiated() {\n return this.store.consultInitiated;\n }\n get consultAccepted() {\n return this.store.consultAccepted;\n }\n get consultStartTimeStamp() {\n return this.store.consultStartTimeStamp;\n }\n get callControlAudio() {\n return this.store.callControlAudio;\n }\n get consultOfferReceived() {\n return this.store.consultOfferReceived;\n }\n get isQueueConsultInProgress() {\n return this.store.isQueueConsultInProgress;\n }\n get currentConsultQueueId() {\n return this.store.currentConsultQueueId;\n }\n get isEndConsultEnabled() {\n return this.store.isEndConsultEnabled;\n }\n get allowConsultToQueue() {\n return this.store.allowConsultToQueue;\n }\n get taskMetaData() {\n return this.store.taskMetaData;\n }\n init(options) {\n return this.store.init(options, this.setupIncomingTaskHandler);\n }\n}\n// Create and export a single instance of the wrapper\nconst storeWrapper = new StoreWrapper();\nexports[\"default\"] = storeWrapper;\n\n\n//# sourceURL=webpack://@webex/cc-store/./src/storeEventsWrapper.ts?");
|
|
12372
|
+
|
|
12373
|
+
/***/ }),
|
|
12374
|
+
|
|
12375
|
+
/***/ "./src/util.ts":
|
|
12376
|
+
/*!*********************!*\
|
|
12377
|
+
!*** ./src/util.ts ***!
|
|
12378
|
+
\*********************/
|
|
12379
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
12380
|
+
|
|
12381
|
+
"use strict";
|
|
12382
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.getFeatureFlags = getFeatureFlags;\nfunction getFeatureFlags(agentProfile) {\n const featureFlagkeys = [\n 'isOutboundEnabledForTenant',\n 'isOutboundEnabledForAgent',\n 'isAdhocDialingEnabled',\n 'isCampaignManagementEnabled',\n 'isEndCallEnabled',\n 'isEndConsultEnabled',\n 'agentPersonalStatsEnabled',\n 'isCallMonitoringEnabled',\n 'isMidCallMonitoringEnabled',\n 'isBargeInEnabled',\n 'isManagedTeamsEnabled',\n 'isManagedQueuesEnabled',\n 'isSendMessageEnabled',\n 'isAgentStateChangeEnabled',\n 'isSignOutAgentsEnabled',\n 'isTimeoutDesktopInactivityEnabled',\n 'isAnalyzerEnabled',\n 'webRtcEnabled',\n 'isRecordingManagementEnabled',\n 'allowConsultToQueue',\n ];\n const keyValuePairs = featureFlagkeys.reduce((acc, key) => {\n const value = agentProfile[key];\n if (value !== undefined) {\n acc[key] = value;\n }\n return acc;\n }, {});\n return keyValuePairs;\n}\n\n\n//# sourceURL=webpack://@webex/cc-store/./src/util.ts?");
|
|
12372
12383
|
|
|
12373
12384
|
/***/ }),
|
|
12374
12385
|
|
|
@@ -12401,7 +12412,7 @@ eval("/* provided dependency */ var process = __webpack_require__(/*! process/br
|
|
|
12401
12412
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12402
12413
|
|
|
12403
12414
|
"use strict";
|
|
12404
|
-
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _merge = _interopRequireDefault(__webpack_require__(/*! lodash/merge */ \"../../../node_modules/lodash/merge.js\"));\nvar _webexCore = _interopRequireDefault(__webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\"));\n__webpack_require__(/*! @webex/plugin-authorization */ \"./node_modules/@webex/plugin-authorization/dist/index.browser.js\");\n__webpack_require__(/*! @webex/plugin-cc */ \"../../../node_modules/@webex/plugin-cc/dist/index.js\");\n__webpack_require__(/*! @webex/internal-plugin-mercury */ \"../../../node_modules/@webex/internal-plugin-mercury/dist/index.js\");\n__webpack_require__(/*! @webex/plugin-logger */ \"./node_modules/@webex/plugin-logger/dist/index.js\");\n__webpack_require__(/*! @webex/internal-plugin-support */ \"./node_modules/@webex/internal-plugin-support/dist/index.js\");\nvar config = __webpack_require__(/*! ./config */ \"./node_modules/webex/dist/config.js\");\nvar Webex = _webexCore.default.extend({\n webex: true,\n version: \"3.8.0-next.
|
|
12415
|
+
eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _merge = _interopRequireDefault(__webpack_require__(/*! lodash/merge */ \"../../../node_modules/lodash/merge.js\"));\nvar _webexCore = _interopRequireDefault(__webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\"));\n__webpack_require__(/*! @webex/plugin-authorization */ \"./node_modules/@webex/plugin-authorization/dist/index.browser.js\");\n__webpack_require__(/*! @webex/plugin-cc */ \"../../../node_modules/@webex/plugin-cc/dist/index.js\");\n__webpack_require__(/*! @webex/internal-plugin-mercury */ \"../../../node_modules/@webex/internal-plugin-mercury/dist/index.js\");\n__webpack_require__(/*! @webex/plugin-logger */ \"./node_modules/@webex/plugin-logger/dist/index.js\");\n__webpack_require__(/*! @webex/internal-plugin-support */ \"./node_modules/@webex/internal-plugin-support/dist/index.js\");\nvar config = __webpack_require__(/*! ./config */ \"./node_modules/webex/dist/config.js\");\nvar Webex = _webexCore.default.extend({\n webex: true,\n version: \"3.8.0-next.61\"\n});\nWebex.init = function init() {\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n attrs.config = (0, _merge.default)({}, config, attrs.config); // eslint-disable-line no-param-reassign\n\n return new Webex(attrs);\n};\nvar _default = exports[\"default\"] = Webex;\n//# sourceMappingURL=contact-center.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/webex/dist/contact-center.js?");
|
|
12405
12416
|
|
|
12406
12417
|
/***/ }),
|
|
12407
12418
|
|