@webex/webex-core 3.12.0-next.63 → 3.12.0-next.65

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.
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+
3
+ var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
4
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
5
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
+ _Object$defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.default = void 0;
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
11
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/map"));
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
13
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
15
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
16
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
17
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
18
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
19
+ var _statelessWebexPlugin = _interopRequireDefault(require("./stateless-webex-plugin"));
20
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
21
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /*!
22
+ * Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
23
+ */ // @ts-ignore
24
+ /**
25
+ * Detects an HTML document prefix in an otherwise successful binary asset response.
26
+ * @param {ArrayBuffer} buffer
27
+ * @returns {boolean}
28
+ */
29
+ function looksLikeHtmlDocument(buffer) {
30
+ var prefix = new TextDecoder().decode(buffer.slice(0, 256)).trimStart();
31
+ return prefix.startsWith('<');
32
+ }
33
+
34
+ /**
35
+ * Resolves and downloads static assets for SDK plugins. Requests are shared between callers and
36
+ * cached after a successful response.
37
+ */
38
+ var StaticAssetLoader = exports.default = /*#__PURE__*/function (_StatelessWebexPlugin) {
39
+ /**
40
+ * @param {Object} attrs
41
+ * @param {string} attrs.baseUrl - Base URL for the plugin's static assets.
42
+ * @param {Object} options
43
+ * @param {Object} [options.parent] - The parent Webex SDK instance.
44
+ */
45
+ function StaticAssetLoader(attrs) {
46
+ var _this;
47
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
48
+ (0, _classCallCheck2.default)(this, StaticAssetLoader);
49
+ _this = _callSuper(this, StaticAssetLoader, [attrs, options]);
50
+ (0, _defineProperty2.default)(_this, "baseUrl", void 0);
51
+ (0, _defineProperty2.default)(_this, "assets", new _map.default());
52
+ _this.baseUrl = attrs.baseUrl.replace(/\/+$/, ''); // remove trailing slashes
53
+ return _this;
54
+ }
55
+
56
+ /**
57
+ * Returns the URL for an asset in the configured asset directory.
58
+ * @param {string} assetName
59
+ * @returns {string}
60
+ */
61
+ (0, _inherits2.default)(StaticAssetLoader, _StatelessWebexPlugin);
62
+ return (0, _createClass2.default)(StaticAssetLoader, [{
63
+ key: "getUrl",
64
+ value: function getUrl(assetName) {
65
+ return "".concat(this.baseUrl, "/").concat(assetName.replace(/^\/+/, '')); // regex removes leading slashes from the asset name
66
+ }
67
+
68
+ /**
69
+ * Downloads an asset as bytes. Failed requests are evicted so a later call can retry.
70
+ * @param {string} assetName
71
+ * @returns {Promise<Uint8Array>}
72
+ */
73
+ }, {
74
+ key: "getBytes",
75
+ value: (function () {
76
+ var _getBytes = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(assetName) {
77
+ var _this2 = this;
78
+ var url, asset, _t, _t2;
79
+ return _regenerator.default.wrap(function (_context) {
80
+ while (1) switch (_context.prev = _context.next) {
81
+ case 0:
82
+ url = this.getUrl(assetName);
83
+ asset = this.assets.get(url);
84
+ if (!asset) {
85
+ // @ts-ignore - StatelessWebexPlugin exposes request from the parent Webex instance.
86
+ asset = this.request({
87
+ method: 'GET',
88
+ uri: url,
89
+ responseType: 'buffer',
90
+ // Assets may be hosted on a third-party CDN: never send the user's token, and suppress
91
+ // the SDK's custom headers so the request doesn't trigger a CORS preflight.
92
+ addAuthHeader: false,
93
+ headers: {
94
+ trackingid: null,
95
+ 'spark-user-agent': null,
96
+ 'cisco-no-http-redirect': null
97
+ }
98
+ }).then(function (response) {
99
+ var _response$headers, _response$headers$con;
100
+ if (response.statusCode < 200 || response.statusCode >= 300) {
101
+ throw new Error("Failed to fetch static asset ".concat(url, ": HTTP ").concat(response.statusCode));
102
+ }
103
+ var contentType = (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : (_response$headers$con = _response$headers['content-type']) === null || _response$headers$con === void 0 ? void 0 : _response$headers$con.split(';')[0].trim().toLowerCase();
104
+ if (contentType === 'text/html' || contentType === 'application/xhtml+xml') {
105
+ throw new Error("Failed to fetch static asset ".concat(url, ": unexpected HTML content type \"").concat(contentType, "\""));
106
+ }
107
+ var responseBody = response.body;
108
+ var buffer;
109
+ if (responseBody instanceof ArrayBuffer) {
110
+ buffer = responseBody;
111
+ } else if (ArrayBuffer.isView(responseBody)) {
112
+ buffer = responseBody.buffer.slice(responseBody.byteOffset, responseBody.byteOffset + responseBody.byteLength);
113
+ } else {
114
+ throw new Error("Failed to fetch static asset ".concat(url, ": response body is not binary data"));
115
+ }
116
+
117
+ // Some static servers return an HTML fallback page with a successful status and a
118
+ // generic binary content type. Reject it before callers pass those bytes to modules
119
+ // that expect binary data, such as WASM.
120
+ if (looksLikeHtmlDocument(buffer)) {
121
+ throw new Error("Failed to fetch static asset ".concat(url, ": response body looks like an HTML document"));
122
+ }
123
+ return buffer;
124
+ }).catch(function (error) {
125
+ _this2.assets.delete(url);
126
+ throw error;
127
+ });
128
+ this.assets.set(url, asset);
129
+ }
130
+ _t = Uint8Array;
131
+ _context.next = 1;
132
+ return asset;
133
+ case 1:
134
+ _t2 = _context.sent.slice(0);
135
+ return _context.abrupt("return", new _t(_t2));
136
+ case 2:
137
+ case "end":
138
+ return _context.stop();
139
+ }
140
+ }, _callee, this);
141
+ }));
142
+ function getBytes(_x) {
143
+ return _getBytes.apply(this, arguments);
144
+ }
145
+ return getBytes;
146
+ }())
147
+ }]);
148
+ }(_statelessWebexPlugin.default);
149
+ //# sourceMappingURL=static-asset-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_statelessWebexPlugin","_interopRequireDefault","require","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","_Reflect$construct","constructor","apply","Boolean","prototype","valueOf","call","looksLikeHtmlDocument","buffer","prefix","TextDecoder","decode","slice","trimStart","startsWith","StaticAssetLoader","exports","_StatelessWebexPlugin","attrs","_this","options","arguments","length","undefined","_classCallCheck2","_defineProperty2","_map","baseUrl","replace","_inherits2","_createClass2","key","value","getUrl","assetName","concat","_getBytes","_asyncToGenerator2","_regenerator","mark","_callee","_this2","url","asset","_t","_t2","wrap","_context","prev","next","assets","get","request","method","uri","responseType","addAuthHeader","headers","trackingid","then","response","_response$headers","_response$headers$con","statusCode","Error","contentType","split","trim","toLowerCase","responseBody","body","ArrayBuffer","isView","byteOffset","byteLength","catch","error","delete","set","Uint8Array","sent","abrupt","stop","getBytes","_x","StatelessWebexPlugin"],"sources":["static-asset-loader.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.\n */\n\n// @ts-ignore\nimport StatelessWebexPlugin from './stateless-webex-plugin';\n\n/**\n * Detects an HTML document prefix in an otherwise successful binary asset response.\n * @param {ArrayBuffer} buffer\n * @returns {boolean}\n */\nfunction looksLikeHtmlDocument(buffer: ArrayBuffer): boolean {\n const prefix = new TextDecoder().decode(buffer.slice(0, 256)).trimStart();\n\n return prefix.startsWith('<');\n}\n\n/**\n * Resolves and downloads static assets for SDK plugins. Requests are shared between callers and\n * cached after a successful response.\n */\nexport default class StaticAssetLoader extends StatelessWebexPlugin {\n private readonly baseUrl: string;\n\n private readonly assets = new Map<string, Promise<ArrayBuffer>>();\n\n /**\n * @param {Object} attrs\n * @param {string} attrs.baseUrl - Base URL for the plugin's static assets.\n * @param {Object} options\n * @param {Object} [options.parent] - The parent Webex SDK instance.\n */\n constructor(attrs: {baseUrl: string}, options: {parent?: any} = {}) {\n super(attrs, options);\n this.baseUrl = attrs.baseUrl.replace(/\\/+$/, ''); // remove trailing slashes\n }\n\n /**\n * Returns the URL for an asset in the configured asset directory.\n * @param {string} assetName\n * @returns {string}\n */\n getUrl(assetName: string): string {\n return `${this.baseUrl}/${assetName.replace(/^\\/+/, '')}`; // regex removes leading slashes from the asset name\n }\n\n /**\n * Downloads an asset as bytes. Failed requests are evicted so a later call can retry.\n * @param {string} assetName\n * @returns {Promise<Uint8Array>}\n */\n async getBytes(assetName: string): Promise<Uint8Array> {\n const url = this.getUrl(assetName);\n let asset = this.assets.get(url);\n\n if (!asset) {\n // @ts-ignore - StatelessWebexPlugin exposes request from the parent Webex instance.\n asset = this.request({\n method: 'GET',\n uri: url,\n responseType: 'buffer',\n // Assets may be hosted on a third-party CDN: never send the user's token, and suppress\n // the SDK's custom headers so the request doesn't trigger a CORS preflight.\n addAuthHeader: false,\n headers: {\n trackingid: null,\n 'spark-user-agent': null,\n 'cisco-no-http-redirect': null,\n },\n })\n .then((response: any) => {\n if (response.statusCode < 200 || response.statusCode >= 300) {\n throw new Error(`Failed to fetch static asset ${url}: HTTP ${response.statusCode}`);\n }\n\n const contentType = response.headers?.['content-type']\n ?.split(';')[0]\n .trim()\n .toLowerCase();\n\n if (contentType === 'text/html' || contentType === 'application/xhtml+xml') {\n throw new Error(\n `Failed to fetch static asset ${url}: unexpected HTML content type \"${contentType}\"`\n );\n }\n\n const responseBody = response.body;\n let buffer: ArrayBuffer;\n\n if (responseBody instanceof ArrayBuffer) {\n buffer = responseBody;\n } else if (ArrayBuffer.isView(responseBody)) {\n buffer = responseBody.buffer.slice(\n responseBody.byteOffset,\n responseBody.byteOffset + responseBody.byteLength\n ) as ArrayBuffer;\n } else {\n throw new Error(\n `Failed to fetch static asset ${url}: response body is not binary data`\n );\n }\n\n // Some static servers return an HTML fallback page with a successful status and a\n // generic binary content type. Reject it before callers pass those bytes to modules\n // that expect binary data, such as WASM.\n if (looksLikeHtmlDocument(buffer)) {\n throw new Error(\n `Failed to fetch static asset ${url}: response body looks like an HTML document`\n );\n }\n\n return buffer;\n })\n .catch((error: Error) => {\n this.assets.delete(url);\n throw error;\n });\n this.assets.set(url, asset);\n }\n\n return new Uint8Array((await asset).slice(0));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAC,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,CAAAC,OAAA,EAAAH,CAAA,OAAAI,2BAAA,CAAAD,OAAA,EAAAJ,CAAA,EAAAM,yBAAA,KAAAC,kBAAA,CAAAN,CAAA,EAAAC,CAAA,YAAAC,gBAAA,CAAAC,OAAA,EAAAJ,CAAA,EAAAQ,WAAA,IAAAP,CAAA,CAAAQ,KAAA,CAAAT,CAAA,EAAAE,CAAA;AAAA,SAAAI,0BAAA,cAAAN,CAAA,IAAAU,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAN,kBAAA,CAAAG,OAAA,iCAAAV,CAAA,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4B,GAAG,CAACpC,GAAG,EAAEC,KAAK,CAAC;cAC7B;cAACC,EAAA,GAEUmC,UAAU;cAAAhC,QAAA,CAAAE,IAAA;cAAA,OAAQN,KAAK;YAAA;cAAAE,GAAA,GAAAE,QAAA,CAAAiC,IAAA,CAAEpE,KAAK,CAAC,CAAC;cAAA,OAAAmC,QAAA,CAAAkC,MAAA,eAAArC,EAAA,CAAAC,GAAA;YAAA;YAAA;cAAA,OAAAE,QAAA,CAAAmC,IAAA;UAAA;QAAA,GAAA1C,OAAA;MAAA,CAC5C;MAAA,SAtEK2C,QAAQA,CAAAC,EAAA;QAAA,OAAAhD,SAAA,CAAAlC,KAAA,OAAAmB,SAAA;MAAA;MAAA,OAAR8D,QAAQ;IAAA;EAAA;AAAA,EA9B+BE,6BAAoB","ignoreList":[]}
@@ -57,7 +57,7 @@ var Logger = _webexPlugin.default.extend({
57
57
  info: wrapConsoleMethod('info'),
58
58
  debug: wrapConsoleMethod('debug'),
59
59
  trace: wrapConsoleMethod('trace'),
60
- version: "3.12.0-next.63"
60
+ version: "3.12.0-next.65"
61
61
  });
62
62
  (0, _webexCore.registerPlugin)('logger', Logger);
63
63
  var _default = exports.default = Logger;
@@ -98,7 +98,7 @@ var MAX_FILE_SIZE_IN_MB = 2048;
98
98
  * @class
99
99
  */
100
100
  var WebexCore = _ampersandState.default.extend((_obj = {
101
- version: "3.12.0-next.63",
101
+ version: "3.12.0-next.65",
102
102
  children: {
103
103
  internal: _webexInternalCore.default
104
104
  },
@@ -642,7 +642,7 @@ var WebexCore = _ampersandState.default.extend((_obj = {
642
642
  });
643
643
  }
644
644
  }, (0, _applyDecoratedDescriptor2.default)(_obj, "_uploadPhaseUpload", [_common.retry], (0, _getOwnPropertyDescriptor.default)(_obj, "_uploadPhaseUpload"), _obj), _obj));
645
- WebexCore.version = "3.12.0-next.63";
645
+ WebexCore.version = "3.12.0-next.65";
646
646
  (0, _webexInternalCorePluginMixin.default)(_webexInternalCore.default, _config.default, interceptors);
647
647
  (0, _webexCorePluginMixin.default)(WebexCore, _config.default, interceptors);
648
648
  var _default = exports.default = WebexCore;
package/package.json CHANGED
@@ -33,10 +33,10 @@
33
33
  "@sinonjs/fake-timers": "^6.0.1",
34
34
  "@webex/babel-config-legacy": "0.0.0",
35
35
  "@webex/eslint-config-legacy": "0.0.0",
36
- "@webex/internal-plugin-device": "3.12.0-next.58",
36
+ "@webex/internal-plugin-device": "3.12.0-next.60",
37
37
  "@webex/jest-config-legacy": "0.0.0",
38
38
  "@webex/legacy-tools": "0.0.0",
39
- "@webex/plugin-logger": "3.12.0-next.60",
39
+ "@webex/plugin-logger": "3.12.0-next.62",
40
40
  "@webex/test-helper-chai": "3.12.0-next.9",
41
41
  "@webex/test-helper-make-local-url": "3.12.0-next.9",
42
42
  "@webex/test-helper-mocha": "3.12.0-next.9",
@@ -73,5 +73,5 @@
73
73
  "test:style": "eslint ./src/**/*.*",
74
74
  "test:unit": "webex-legacy-tools test --unit --runner jest"
75
75
  },
76
- "version": "3.12.0-next.63"
76
+ "version": "3.12.0-next.65"
77
77
  }
package/src/config.js CHANGED
@@ -17,6 +17,13 @@ export default {
17
17
  trackingIdSuffix: '',
18
18
  AlternateLogger: undefined,
19
19
  credentials: new CredentialsConfig(),
20
+ /**
21
+ * Explicitly selects the Webex environment. When omitted, the environment is inferred from the
22
+ * U2C discovery URL.
23
+ *
24
+ * @type {'integration'|'production'|undefined}
25
+ */
26
+ environment: undefined,
20
27
  fedramp: process.env.ENABLE_FEDRAMP || false,
21
28
  services: {
22
29
  /**
package/src/index.js CHANGED
@@ -41,6 +41,7 @@ export {default, registerPlugin, registerInternalPlugin} from './webex-core';
41
41
  export {default as WebexHttpError} from './lib/webex-http-error';
42
42
  export {default as StatelessWebexPlugin} from './lib/stateless-webex-plugin';
43
43
  export {default as WebexPlugin} from './lib/webex-plugin';
44
+ export {default as StaticAssetLoader} from './lib/static-asset-loader';
44
45
  export {default as AuthInterceptor} from './interceptors/auth';
45
46
  export {default as CatalogUrlInterceptor} from './interceptors/catalog-url';
46
47
  export {default as NetworkTimingInterceptor} from './interceptors/network-timing';
@@ -261,13 +261,23 @@ const Services = WebexPlugin.extend({
261
261
  },
262
262
 
263
263
  /**
264
- * Checks if the current environment is an integration (INT) environment
265
- * by examining the u2c discovery URL from webex config.
264
+ * Checks if the current environment is an integration (INT) environment.
265
+ * Uses the explicit environment config when set, otherwise examines the u2c discovery URL.
266
266
  * INT environments use discovery URLs containing 'intb' (e.g., u2c-intb.ciscospark.com).
267
267
  * @returns {boolean} True if INT environment, false otherwise
268
268
  */
269
269
  isIntegrationEnvironment() {
270
270
  try {
271
+ const configuredEnvironment = this.webex?.config?.environment;
272
+
273
+ if (configuredEnvironment !== undefined) {
274
+ const isIntFromConfig = configuredEnvironment === 'integration';
275
+
276
+ this.logger.info(`services: isIntegrationEnvironment: ${isIntFromConfig} (config)`);
277
+
278
+ return isIntFromConfig;
279
+ }
280
+
271
281
  const u2cUrl = this.webex?.config?.services?.discovery?.u2c || '';
272
282
  const isInt = u2cUrl.includes('intb');
273
283
 
@@ -218,13 +218,23 @@ const Services = WebexPlugin.extend({
218
218
  },
219
219
 
220
220
  /**
221
- * Checks if the current environment is an integration (INT) environment
222
- * by examining the u2c discovery URL from webex config.
221
+ * Checks if the current environment is an integration (INT) environment.
222
+ * Uses the explicit environment config when set, otherwise examines the u2c discovery URL.
223
223
  * INT environments use discovery URLs containing 'intb' (e.g., u2c-intb.ciscospark.com).
224
224
  * @returns {boolean} True if INT environment, false otherwise
225
225
  */
226
226
  isIntegrationEnvironment(): boolean {
227
227
  try {
228
+ const configuredEnvironment = this.webex?.config?.environment;
229
+
230
+ if (configuredEnvironment !== undefined) {
231
+ const isIntFromConfig = configuredEnvironment === 'integration';
232
+
233
+ this.logger.info(`services: isIntegrationEnvironment: ${isIntFromConfig} (config)`);
234
+
235
+ return isIntFromConfig;
236
+ }
237
+
228
238
  const u2cUrl = this.webex?.config?.services?.discovery?.u2c || '';
229
239
  const isInt = u2cUrl.includes('intb');
230
240
 
@@ -0,0 +1,124 @@
1
+ /*!
2
+ * Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ // @ts-ignore
6
+ import StatelessWebexPlugin from './stateless-webex-plugin';
7
+
8
+ /**
9
+ * Detects an HTML document prefix in an otherwise successful binary asset response.
10
+ * @param {ArrayBuffer} buffer
11
+ * @returns {boolean}
12
+ */
13
+ function looksLikeHtmlDocument(buffer: ArrayBuffer): boolean {
14
+ const prefix = new TextDecoder().decode(buffer.slice(0, 256)).trimStart();
15
+
16
+ return prefix.startsWith('<');
17
+ }
18
+
19
+ /**
20
+ * Resolves and downloads static assets for SDK plugins. Requests are shared between callers and
21
+ * cached after a successful response.
22
+ */
23
+ export default class StaticAssetLoader extends StatelessWebexPlugin {
24
+ private readonly baseUrl: string;
25
+
26
+ private readonly assets = new Map<string, Promise<ArrayBuffer>>();
27
+
28
+ /**
29
+ * @param {Object} attrs
30
+ * @param {string} attrs.baseUrl - Base URL for the plugin's static assets.
31
+ * @param {Object} options
32
+ * @param {Object} [options.parent] - The parent Webex SDK instance.
33
+ */
34
+ constructor(attrs: {baseUrl: string}, options: {parent?: any} = {}) {
35
+ super(attrs, options);
36
+ this.baseUrl = attrs.baseUrl.replace(/\/+$/, ''); // remove trailing slashes
37
+ }
38
+
39
+ /**
40
+ * Returns the URL for an asset in the configured asset directory.
41
+ * @param {string} assetName
42
+ * @returns {string}
43
+ */
44
+ getUrl(assetName: string): string {
45
+ return `${this.baseUrl}/${assetName.replace(/^\/+/, '')}`; // regex removes leading slashes from the asset name
46
+ }
47
+
48
+ /**
49
+ * Downloads an asset as bytes. Failed requests are evicted so a later call can retry.
50
+ * @param {string} assetName
51
+ * @returns {Promise<Uint8Array>}
52
+ */
53
+ async getBytes(assetName: string): Promise<Uint8Array> {
54
+ const url = this.getUrl(assetName);
55
+ let asset = this.assets.get(url);
56
+
57
+ if (!asset) {
58
+ // @ts-ignore - StatelessWebexPlugin exposes request from the parent Webex instance.
59
+ asset = this.request({
60
+ method: 'GET',
61
+ uri: url,
62
+ responseType: 'buffer',
63
+ // Assets may be hosted on a third-party CDN: never send the user's token, and suppress
64
+ // the SDK's custom headers so the request doesn't trigger a CORS preflight.
65
+ addAuthHeader: false,
66
+ headers: {
67
+ trackingid: null,
68
+ 'spark-user-agent': null,
69
+ 'cisco-no-http-redirect': null,
70
+ },
71
+ })
72
+ .then((response: any) => {
73
+ if (response.statusCode < 200 || response.statusCode >= 300) {
74
+ throw new Error(`Failed to fetch static asset ${url}: HTTP ${response.statusCode}`);
75
+ }
76
+
77
+ const contentType = response.headers?.['content-type']
78
+ ?.split(';')[0]
79
+ .trim()
80
+ .toLowerCase();
81
+
82
+ if (contentType === 'text/html' || contentType === 'application/xhtml+xml') {
83
+ throw new Error(
84
+ `Failed to fetch static asset ${url}: unexpected HTML content type "${contentType}"`
85
+ );
86
+ }
87
+
88
+ const responseBody = response.body;
89
+ let buffer: ArrayBuffer;
90
+
91
+ if (responseBody instanceof ArrayBuffer) {
92
+ buffer = responseBody;
93
+ } else if (ArrayBuffer.isView(responseBody)) {
94
+ buffer = responseBody.buffer.slice(
95
+ responseBody.byteOffset,
96
+ responseBody.byteOffset + responseBody.byteLength
97
+ ) as ArrayBuffer;
98
+ } else {
99
+ throw new Error(
100
+ `Failed to fetch static asset ${url}: response body is not binary data`
101
+ );
102
+ }
103
+
104
+ // Some static servers return an HTML fallback page with a successful status and a
105
+ // generic binary content type. Reject it before callers pass those bytes to modules
106
+ // that expect binary data, such as WASM.
107
+ if (looksLikeHtmlDocument(buffer)) {
108
+ throw new Error(
109
+ `Failed to fetch static asset ${url}: response body looks like an HTML document`
110
+ );
111
+ }
112
+
113
+ return buffer;
114
+ })
115
+ .catch((error: Error) => {
116
+ this.assets.delete(url);
117
+ throw error;
118
+ });
119
+ this.assets.set(url, asset);
120
+ }
121
+
122
+ return new Uint8Array((await asset).slice(0));
123
+ }
124
+ }
@@ -1361,6 +1361,32 @@ describe('webex-core', () => {
1361
1361
  });
1362
1362
 
1363
1363
  describe('#isIntegrationEnvironment', () => {
1364
+ it('uses the integration environment config when set, regardless of the u2c URL', () => {
1365
+ services.webex.config = {
1366
+ environment: 'integration',
1367
+ services: {
1368
+ discovery: {
1369
+ u2c: 'https://u2c.wbx2.com/u2c/api/v1',
1370
+ },
1371
+ },
1372
+ };
1373
+
1374
+ assert.isTrue(services.isIntegrationEnvironment());
1375
+ });
1376
+
1377
+ it('uses the production environment config when set, regardless of the u2c URL', () => {
1378
+ services.webex.config = {
1379
+ environment: 'production',
1380
+ services: {
1381
+ discovery: {
1382
+ u2c: 'https://u2c-intb.ciscospark.com/u2c/api/v1',
1383
+ },
1384
+ },
1385
+ };
1386
+
1387
+ assert.isFalse(services.isIntegrationEnvironment());
1388
+ });
1389
+
1364
1390
  it('returns true when u2c URL contains "intb"', () => {
1365
1391
  services.webex.config = {
1366
1392
  services: {
@@ -1283,6 +1283,32 @@ describe('webex-core', () => {
1283
1283
  });
1284
1284
 
1285
1285
  describe('#isIntegrationEnvironment', () => {
1286
+ it('uses the integration environment config when set, regardless of the u2c URL', () => {
1287
+ services.webex.config = {
1288
+ environment: 'integration',
1289
+ services: {
1290
+ discovery: {
1291
+ u2c: 'https://u2c.wbx2.com/u2c/api/v1',
1292
+ },
1293
+ },
1294
+ };
1295
+
1296
+ assert.isTrue(services.isIntegrationEnvironment());
1297
+ });
1298
+
1299
+ it('uses the production environment config when set, regardless of the u2c URL', () => {
1300
+ services.webex.config = {
1301
+ environment: 'production',
1302
+ services: {
1303
+ discovery: {
1304
+ u2c: 'https://u2c-intb.ciscospark.com/u2c/api/v1',
1305
+ },
1306
+ },
1307
+ };
1308
+
1309
+ assert.isFalse(services.isIntegrationEnvironment());
1310
+ });
1311
+
1286
1312
  it('returns true when u2c URL contains "intb"', () => {
1287
1313
  services.webex.config = {
1288
1314
  services: {