@webex/webex-core 1.154.2 → 1.155.0
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/interceptors/webex-user-agent.js +12 -5
- package/dist/interceptors/webex-user-agent.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/services.js +1 -1
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +2 -2
- package/package.json +5 -5
- package/src/interceptors/webex-user-agent.js +20 -5
- package/test/unit/spec/interceptors/webex-user-agent.js +22 -1
|
@@ -79,16 +79,23 @@ var WebexUserAgentInterceptor = /*#__PURE__*/function (_Interceptor) {
|
|
|
79
79
|
* @returns {Object}
|
|
80
80
|
*/
|
|
81
81
|
function onRequest(options) {
|
|
82
|
+
var _this$webex$config, _this$webex;
|
|
83
|
+
|
|
82
84
|
options.headers = options.headers || {};
|
|
83
85
|
|
|
84
|
-
var _ref =
|
|
86
|
+
var _ref = (_this$webex$config = (_this$webex = this.webex) === null || _this$webex === void 0 ? void 0 : _this$webex.config) !== null && _this$webex$config !== void 0 ? _this$webex$config : {},
|
|
85
87
|
appName = _ref.appName,
|
|
86
|
-
appVersion = _ref.appVersion
|
|
88
|
+
appVersion = _ref.appVersion,
|
|
89
|
+
appPlatform = _ref.appPlatform;
|
|
90
|
+
|
|
91
|
+
var sparkUserAgent = "".concat(strings.get(this));
|
|
87
92
|
|
|
88
|
-
|
|
93
|
+
if (appName) {
|
|
94
|
+
sparkUserAgent += " ".concat(appName, "/").concat(appVersion !== null && appVersion !== void 0 ? appVersion : '0.0');
|
|
95
|
+
}
|
|
89
96
|
|
|
90
|
-
if (
|
|
91
|
-
sparkUserAgent
|
|
97
|
+
if (appPlatform) {
|
|
98
|
+
sparkUserAgent += " ".concat(appPlatform);
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
if (options.uri && options.uri.includes('https://idbroker')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webex-user-agent.js"],"names":["strings","WebexUserAgentInterceptor","options","libName","libVersion","set","inBrowser","headers","webex","config","appName","appVersion","sparkUserAgent","get","uri","includes","credentials","samlUrl","tokenUrl","authorizeUrl","Interceptor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;;;;;AAGA,IAAMA,OAAO,GAAG,sBAAhB;AAEA;AACA;AACA;;IACqBC,yB;;;;;AACnB;AACF;AACA;AACA;AACA;AACA;AACE,uCAA0B;AAAA;;AAAA,QAAdC,OAAc,uEAAJ,EAAI;AAAA;AACxB,QAAMC,OAAO,GAAG,mBAAID,OAAJ,EAAa,aAAb,EAA4B,KAA5B,IAAqC,OAArC,GAA+C,cAA/D;AACA,QAAME,UAAU,GAAG,mBAAIF,OAAJ,EAAa,eAAb,EAA8B,aAA9B,CAAnB;AAEA,8BAAMA,OAAN;AACAF,IAAAA,OAAO,CAACK,GAAR,wDAAqBF,OAArB,cAAgCC,UAAhC,eAA+CE,oBAAY,KAAZ,GAAoB,MAAnE;AALwB;AAMzB;AAED;AACF;AACA;;;;;;AAKE;AACF;AACA;AACA;AACA;AACE,uBAAUJ,OAAV,EAAmB;AACjBA,MAAAA,OAAO,CAACK,OAAR,GAAkBL,OAAO,CAACK,OAAR,IAAmB,EAArC;;AACA,
|
|
1
|
+
{"version":3,"sources":["webex-user-agent.js"],"names":["strings","WebexUserAgentInterceptor","options","libName","libVersion","set","inBrowser","headers","webex","config","appName","appVersion","appPlatform","sparkUserAgent","get","uri","includes","credentials","samlUrl","tokenUrl","authorizeUrl","Interceptor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;;;;;AAGA,IAAMA,OAAO,GAAG,sBAAhB;AAEA;AACA;AACA;;IACqBC,yB;;;;;AACnB;AACF;AACA;AACA;AACA;AACA;AACE,uCAA0B;AAAA;;AAAA,QAAdC,OAAc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C,MAAX,CAAkBQ,WAAlB,CAA8BE,QAAnD,CADA,IAEAjB,OAAO,CAACa,GAAR,CAAYC,QAAZ,CAAqB,KAAKR,KAAL,CAAWC,MAAX,CAAkBQ,WAAlB,CAA8BG,YAAnD,CAJF,CADF,EAOE;AACA,eAAOlB,OAAP;AACD;;AAED,UAAI,sBAAsBA,OAAO,CAACK,OAAlC,EAA2C;AACzC,YAAI,CAACL,OAAO,CAACK,OAAR,CAAgB,kBAAhB,CAAL,EAA0C;AACxC,uCAAuBL,OAAO,CAACK,OAA/B,EAAwC,kBAAxC;AACD;;AAED,eAAOL,OAAP;AACD;;AAEDA,MAAAA,OAAO,CAACK,OAAR,CAAgB,kBAAhB,IAAsCM,cAAtC;AAEA,aAAOX,OAAP;AACD;;;WApDD,kBAAgB;AACd,aAAO,IAAID,yBAAJ,CAA8B;AAACO,QAAAA,KAAK,EAAE;AAAR,OAA9B,CAAP;AACD;;;EApBoDa,qB","sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser} from '@webex/common';\nimport {Interceptor} from '@webex/http-core';\nimport {get} from 'lodash';\n\nconst strings = new WeakMap();\n\n/**\n * @class\n */\nexport default class WebexUserAgentInterceptor extends Interceptor {\n /**\n * @param {Object} [options={}]\n * @param {WebexCore} [options.webex]\n * @private\n * @returns {WebexUserAgentInterceptor}\n */\n constructor(options = {}) {\n const libName = get(options, 'webex.webex', false) ? 'webex' : 'webex-js-sdk';\n const libVersion = get(options, 'webex.version', 'development');\n\n super(options);\n strings.set(this, `${libName}/${libVersion} (${inBrowser ? 'web' : 'node'})`);\n }\n\n /**\n * @returns {WebexUserAgentInterceptor}\n */\n static create() {\n return new WebexUserAgentInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n options.headers = options.headers || {};\n const {\n appName,\n appVersion,\n appPlatform\n } = this.webex?.config ?? {};\n let sparkUserAgent = `${strings.get(this)}`;\n\n if (appName) {\n sparkUserAgent += ` ${appName}/${appVersion ?? '0.0'}`;\n }\n\n if (appPlatform) {\n sparkUserAgent += ` ${appPlatform}`;\n }\n\n if (options.uri && options.uri.includes('https://idbroker')) {\n return options;\n }\n\n if (\n options.uri &&\n (\n options.uri.includes(this.webex.config.credentials.samlUrl) ||\n options.uri.includes(this.webex.config.credentials.tokenUrl) ||\n options.uri.includes(this.webex.config.credentials.authorizeUrl)\n )\n ) {\n return options;\n }\n\n if ('spark-user-agent' in options.headers) {\n if (!options.headers['spark-user-agent']) {\n Reflect.deleteProperty(options.headers, 'spark-user-agent');\n }\n\n return options;\n }\n\n options.headers['spark-user-agent'] = sparkUserAgent;\n\n return options;\n }\n}\n"]}
|
package/dist/lib/batcher.js
CHANGED
|
@@ -329,7 +329,7 @@ var Batcher = _webexPlugin.default.extend({
|
|
|
329
329
|
fingerprintResponse: function fingerprintResponse(item) {
|
|
330
330
|
throw new Error('fingerprintResponse() must be implemented');
|
|
331
331
|
},
|
|
332
|
-
version: "1.
|
|
332
|
+
version: "1.155.0"
|
|
333
333
|
});
|
|
334
334
|
|
|
335
335
|
var _default2 = Batcher;
|
|
@@ -590,7 +590,7 @@ var Credentials = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
590
590
|
this.refresh();
|
|
591
591
|
}
|
|
592
592
|
},
|
|
593
|
-
version: "1.
|
|
593
|
+
version: "1.155.0"
|
|
594
594
|
}, ((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)));
|
|
595
595
|
|
|
596
596
|
var _default = Credentials;
|
|
@@ -605,7 +605,7 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
605
605
|
return res.body;
|
|
606
606
|
});
|
|
607
607
|
},
|
|
608
|
-
version: "1.
|
|
608
|
+
version: "1.155.0"
|
|
609
609
|
}, ((0, _applyDecoratedDescriptor2.default)(_obj, "downscope", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, "downscope"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "revoke", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "revoke"), _obj)), _obj)));
|
|
610
610
|
|
|
611
611
|
var _default = Token;
|
package/dist/plugins/logger.js
CHANGED
|
@@ -70,7 +70,7 @@ var Logger = _webexPlugin.default.extend({
|
|
|
70
70
|
info: wrapConsoleMethod('info'),
|
|
71
71
|
debug: wrapConsoleMethod('debug'),
|
|
72
72
|
trace: wrapConsoleMethod('trace'),
|
|
73
|
-
version: "1.
|
|
73
|
+
version: "1.155.0"
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
(0, _webexCore.registerPlugin)('logger', Logger);
|
package/dist/webex-core.js
CHANGED
|
@@ -159,7 +159,7 @@ var MAX_FILE_SIZE_IN_MB = 2048;
|
|
|
159
159
|
*/
|
|
160
160
|
|
|
161
161
|
var WebexCore = _ampersandState.default.extend((_obj = {
|
|
162
|
-
version: "1.
|
|
162
|
+
version: "1.155.0",
|
|
163
163
|
children: {
|
|
164
164
|
internal: _webexInternalCore.default
|
|
165
165
|
},
|
|
@@ -757,7 +757,7 @@ var WebexCore = _ampersandState.default.extend((_obj = {
|
|
|
757
757
|
}
|
|
758
758
|
}, ((0, _applyDecoratedDescriptor2.default)(_obj, "_uploadPhaseUpload", [_common.retry], (0, _getOwnPropertyDescriptor.default)(_obj, "_uploadPhaseUpload"), _obj)), _obj));
|
|
759
759
|
|
|
760
|
-
WebexCore.version = "1.
|
|
760
|
+
WebexCore.version = "1.155.0";
|
|
761
761
|
(0, _webexInternalCorePluginMixin.default)(_webexInternalCore.default, _config.default, interceptors);
|
|
762
762
|
(0, _webexCorePluginMixin.default)(WebexCore, _config.default, interceptors);
|
|
763
763
|
var _default = WebexCore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/webex-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.155.0",
|
|
4
4
|
"description": "Plugin handling for Cisco Webex",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"contributors": [
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"@babel/runtime-corejs2": "^7.14.8",
|
|
29
29
|
"lodash": "^4.17.21",
|
|
30
30
|
"ampersand-state": "^5.0.3",
|
|
31
|
-
"@webex/common": "1.
|
|
31
|
+
"@webex/common": "1.155.0",
|
|
32
32
|
"ampersand-events": "^2.0.2",
|
|
33
|
-
"@webex/http-core": "1.
|
|
33
|
+
"@webex/http-core": "1.155.0",
|
|
34
34
|
"uuid": "^3.3.2",
|
|
35
35
|
"jsonwebtoken": "^8.5.1",
|
|
36
|
-
"@webex/common-timers": "1.
|
|
36
|
+
"@webex/common-timers": "1.155.0",
|
|
37
37
|
"ampersand-collection": "^2.0.2",
|
|
38
38
|
"crypto-js": "^4.1.1",
|
|
39
|
-
"@webex/webex-core": "1.
|
|
39
|
+
"@webex/webex-core": "1.155.0",
|
|
40
40
|
"core-decorators": "^0.20.0",
|
|
41
41
|
"envify": "^4.1.0"
|
|
42
42
|
}
|
|
@@ -40,18 +40,33 @@ export default class WebexUserAgentInterceptor extends Interceptor {
|
|
|
40
40
|
*/
|
|
41
41
|
onRequest(options) {
|
|
42
42
|
options.headers = options.headers || {};
|
|
43
|
-
const {
|
|
44
|
-
|
|
43
|
+
const {
|
|
44
|
+
appName,
|
|
45
|
+
appVersion,
|
|
46
|
+
appPlatform
|
|
47
|
+
} = this.webex?.config ?? {};
|
|
48
|
+
let sparkUserAgent = `${strings.get(this)}`;
|
|
45
49
|
|
|
46
|
-
if (appName
|
|
47
|
-
sparkUserAgent
|
|
50
|
+
if (appName) {
|
|
51
|
+
sparkUserAgent += ` ${appName}/${appVersion ?? '0.0'}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (appPlatform) {
|
|
55
|
+
sparkUserAgent += ` ${appPlatform}`;
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
if (options.uri && options.uri.includes('https://idbroker')) {
|
|
51
59
|
return options;
|
|
52
60
|
}
|
|
53
61
|
|
|
54
|
-
if (
|
|
62
|
+
if (
|
|
63
|
+
options.uri &&
|
|
64
|
+
(
|
|
65
|
+
options.uri.includes(this.webex.config.credentials.samlUrl) ||
|
|
66
|
+
options.uri.includes(this.webex.config.credentials.tokenUrl) ||
|
|
67
|
+
options.uri.includes(this.webex.config.credentials.authorizeUrl)
|
|
68
|
+
)
|
|
69
|
+
) {
|
|
55
70
|
return options;
|
|
56
71
|
}
|
|
57
72
|
|
|
@@ -54,7 +54,28 @@ describe('webex-core', () => {
|
|
|
54
54
|
|
|
55
55
|
assert.property(options, 'headers');
|
|
56
56
|
assert.property(options.headers, 'spark-user-agent');
|
|
57
|
-
assert.equal(options.headers['spark-user-agent'], `
|
|
57
|
+
assert.equal(options.headers['spark-user-agent'], `webex-js-sdk/${pkg.version} (${typeof window === 'undefined' ? 'node' : 'web'}) sample/1.0.0`);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('adds a spark-user-agent header using appName/appVersion + appPlatform from config', () => {
|
|
61
|
+
const interceptor = Reflect.apply(WebexUserAgentInterceptor.create, {
|
|
62
|
+
version: pkg.version,
|
|
63
|
+
config: {
|
|
64
|
+
appName: 'sample',
|
|
65
|
+
appVersion: '1.0.0',
|
|
66
|
+
appPlatform: 'custom-label/1.0.0'
|
|
67
|
+
}
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
const options = {
|
|
71
|
+
headers: {}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
interceptor.onRequest(options);
|
|
75
|
+
|
|
76
|
+
assert.property(options, 'headers');
|
|
77
|
+
assert.property(options.headers, 'spark-user-agent');
|
|
78
|
+
assert.equal(options.headers['spark-user-agent'], `webex-js-sdk/${pkg.version} (${typeof window === 'undefined' ? 'node' : 'web'}) sample/1.0.0 custom-label/1.0.0`);
|
|
58
79
|
});
|
|
59
80
|
|
|
60
81
|
describe('when consumed by the webex package', () => {
|