@webex/calling 3.8.1-next.8 → 3.8.1-next.9
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/CallingClient/CallingClient.test.js +8 -6
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +4 -10
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +351 -345
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +292 -263
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.js +115 -0
- package/dist/CallingClient/registration/webWorker.js.map +1 -0
- package/dist/CallingClient/registration/webWorker.test.js +256 -0
- package/dist/CallingClient/registration/webWorker.test.js.map +1 -0
- package/dist/CallingClient/registration/webWorkerStr.js +15 -0
- package/dist/CallingClient/registration/webWorkerStr.js.map +1 -0
- package/dist/common/types.js +8 -1
- package/dist/common/types.js.map +1 -1
- package/dist/module/CallingClient/registration/register.js +54 -54
- package/dist/module/CallingClient/registration/webWorker.js +59 -0
- package/dist/module/CallingClient/registration/webWorkerStr.js +93 -0
- package/dist/module/common/types.js +7 -0
- package/dist/types/CallingClient/registration/register.d.ts +1 -2
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorker.d.ts +2 -0
- package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +3 -0
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -0
- package/dist/types/common/types.d.ts +12 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.messageHandler = void 0;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
11
|
+
var _uuid = require("uuid");
|
|
12
|
+
var _types = require("../../common/types");
|
|
13
|
+
/* eslint-env worker */
|
|
14
|
+
|
|
15
|
+
var keepaliveTimer;
|
|
16
|
+
var messageHandler = exports.messageHandler = function messageHandler(event) {
|
|
17
|
+
var type = event.data.type;
|
|
18
|
+
var postKeepAlive = /*#__PURE__*/function () {
|
|
19
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(accessToken, deviceUrl, url) {
|
|
20
|
+
var response;
|
|
21
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
22
|
+
while (1) switch (_context.prev = _context.next) {
|
|
23
|
+
case 0:
|
|
24
|
+
_context.next = 2;
|
|
25
|
+
return fetch("".concat(url, "/status"), {
|
|
26
|
+
method: _types.HTTP_METHODS.POST,
|
|
27
|
+
headers: {
|
|
28
|
+
'cisco-device-url': deviceUrl,
|
|
29
|
+
'spark-user-agent': 'webex-calling/beta',
|
|
30
|
+
Authorization: "".concat(accessToken),
|
|
31
|
+
trackingId: "web_worker_".concat((0, _uuid.v4)())
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
case 2:
|
|
35
|
+
response = _context.sent;
|
|
36
|
+
if (response.ok) {
|
|
37
|
+
_context.next = 5;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
throw new Error("Keepalive failed with status: ".concat(response.status));
|
|
41
|
+
case 5:
|
|
42
|
+
return _context.abrupt("return", response);
|
|
43
|
+
case 6:
|
|
44
|
+
case "end":
|
|
45
|
+
return _context.stop();
|
|
46
|
+
}
|
|
47
|
+
}, _callee);
|
|
48
|
+
}));
|
|
49
|
+
return function postKeepAlive(_x, _x2, _x3) {
|
|
50
|
+
return _ref.apply(this, arguments);
|
|
51
|
+
};
|
|
52
|
+
}();
|
|
53
|
+
if (type === _types.WorkerMessageType.START_KEEPALIVE) {
|
|
54
|
+
var keepAliveRetryCount = 0;
|
|
55
|
+
var _event$data = event.data,
|
|
56
|
+
accessToken = _event$data.accessToken,
|
|
57
|
+
deviceUrl = _event$data.deviceUrl,
|
|
58
|
+
interval = _event$data.interval,
|
|
59
|
+
retryCountThreshold = _event$data.retryCountThreshold,
|
|
60
|
+
url = _event$data.url;
|
|
61
|
+
if (keepaliveTimer) {
|
|
62
|
+
clearInterval(keepaliveTimer);
|
|
63
|
+
keepaliveTimer = undefined;
|
|
64
|
+
}
|
|
65
|
+
keepaliveTimer = setInterval( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
66
|
+
var res, statusCode;
|
|
67
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
68
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
if (!(keepAliveRetryCount < retryCountThreshold)) {
|
|
71
|
+
_context2.next = 14;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
_context2.prev = 1;
|
|
75
|
+
_context2.next = 4;
|
|
76
|
+
return postKeepAlive(accessToken, deviceUrl, url);
|
|
77
|
+
case 4:
|
|
78
|
+
res = _context2.sent;
|
|
79
|
+
statusCode = res.status;
|
|
80
|
+
if (keepAliveRetryCount > 0) {
|
|
81
|
+
postMessage({
|
|
82
|
+
type: _types.WorkerMessageType.KEEPALIVE_SUCCESS,
|
|
83
|
+
statusCode: statusCode
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
keepAliveRetryCount = 0;
|
|
87
|
+
_context2.next = 14;
|
|
88
|
+
break;
|
|
89
|
+
case 10:
|
|
90
|
+
_context2.prev = 10;
|
|
91
|
+
_context2.t0 = _context2["catch"](1);
|
|
92
|
+
keepAliveRetryCount += 1;
|
|
93
|
+
postMessage({
|
|
94
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
95
|
+
err: _context2.t0,
|
|
96
|
+
keepAliveRetryCount: keepAliveRetryCount
|
|
97
|
+
});
|
|
98
|
+
case 14:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context2.stop();
|
|
101
|
+
}
|
|
102
|
+
}, _callee2, null, [[1, 10]]);
|
|
103
|
+
})), interval * 1000);
|
|
104
|
+
}
|
|
105
|
+
if (type === _types.WorkerMessageType.CLEAR_KEEPALIVE) {
|
|
106
|
+
if (keepaliveTimer) {
|
|
107
|
+
clearInterval(keepaliveTimer);
|
|
108
|
+
keepaliveTimer = undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// eslint-disable-next-line no-restricted-globals
|
|
114
|
+
self.addEventListener('message', messageHandler);
|
|
115
|
+
//# sourceMappingURL=webWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_uuid","require","_types","keepaliveTimer","messageHandler","exports","event","type","data","postKeepAlive","_ref","_asyncToGenerator2","default","_regenerator","mark","_callee","accessToken","deviceUrl","url","response","wrap","_callee$","_context","prev","next","fetch","concat","method","HTTP_METHODS","POST","headers","Authorization","trackingId","uuid","sent","ok","Error","status","abrupt","stop","_x","_x2","_x3","apply","arguments","WorkerMessageType","START_KEEPALIVE","keepAliveRetryCount","_event$data","interval","retryCountThreshold","clearInterval","undefined","setInterval","_callee2","res","statusCode","_callee2$","_context2","postMessage","KEEPALIVE_SUCCESS","t0","KEEPALIVE_FAILURE","err","CLEAR_KEEPALIVE","self","addEventListener"],"sources":["webWorker.ts"],"sourcesContent":["/* eslint-env worker */\nimport {v4 as uuid} from 'uuid';\nimport {HTTP_METHODS, KeepaliveStatusMessage, WorkerMessageType} from '../../common/types';\n\nlet keepaliveTimer: NodeJS.Timer | undefined;\n\nexport const messageHandler = (event: MessageEvent) => {\n const {type} = event.data;\n\n const postKeepAlive = async (accessToken: string, deviceUrl: string, url: string) => {\n const response = await fetch(`${url}/status`, {\n method: HTTP_METHODS.POST,\n headers: {\n 'cisco-device-url': deviceUrl,\n 'spark-user-agent': 'webex-calling/beta',\n Authorization: `${accessToken}`,\n trackingId: `web_worker_${uuid()}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(`Keepalive failed with status: ${response.status}`);\n }\n\n return response;\n };\n\n if (type === WorkerMessageType.START_KEEPALIVE) {\n let keepAliveRetryCount = 0;\n const {accessToken, deviceUrl, interval, retryCountThreshold, url} = event.data;\n\n if (keepaliveTimer) {\n clearInterval(keepaliveTimer);\n keepaliveTimer = undefined;\n }\n\n keepaliveTimer = setInterval(async () => {\n if (keepAliveRetryCount < retryCountThreshold) {\n try {\n const res = await postKeepAlive(accessToken, deviceUrl, url);\n const statusCode = res.status;\n if (keepAliveRetryCount > 0) {\n postMessage({\n type: WorkerMessageType.KEEPALIVE_SUCCESS,\n statusCode,\n } as KeepaliveStatusMessage);\n }\n keepAliveRetryCount = 0;\n } catch (err: unknown) {\n keepAliveRetryCount += 1;\n postMessage({\n type: WorkerMessageType.KEEPALIVE_FAILURE,\n err,\n keepAliveRetryCount,\n } as KeepaliveStatusMessage);\n }\n }\n }, interval * 1000);\n }\n\n if (type === WorkerMessageType.CLEAR_KEEPALIVE) {\n if (keepaliveTimer) {\n clearInterval(keepaliveTimer);\n keepaliveTimer = undefined;\n }\n }\n};\n\n// eslint-disable-next-line no-restricted-globals\nself.addEventListener('message', messageHandler);\n"],"mappings":";;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAFA;;AAIA,IAAIE,cAAwC;AAErC,IAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,SAAjBA,cAAcA,CAAIE,KAAmB,EAAK;EACrD,IAAOC,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EAAA,GAAAH,SAAA;YAExBX,mBAAmB,IAAI,CAAC;YACxBY,WAAW,CAAC;cACVpD,IAAI,EAAEsC,wBAAiB,CAACiB,iBAAiB;cACzCC,GAAG,EAAAL,SAAA,CAAAG,EAAA;cACHd,mBAAmB,EAAnBA;YACF,CAA2B,CAAC;UAAC;UAAA;YAAA,OAAAW,SAAA,CAAAnB,IAAA;QAAA;MAAA,GAAAe,QAAA;IAAA,CAGlC,IAAEL,QAAQ,GAAG,IAAI,CAAC;EACrB;EAEA,IAAI1C,IAAI,KAAKsC,wBAAiB,CAACmB,eAAe,EAAE;IAC9C,IAAI7D,cAAc,EAAE;MAClBgD,aAAa,CAAChD,cAAc,CAAC;MAC7BA,cAAc,GAAGiD,SAAS;IAC5B;EACF;AACF,CAAC;;AAED;AACAa,IAAI,CAACC,gBAAgB,CAAC,SAAS,EAAE9D,cAAc,CAAC"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
4
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
5
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
6
|
+
var _uuid = require("uuid");
|
|
7
|
+
var _webWorker = require("./webWorker");
|
|
8
|
+
var _types = require("../../common/types");
|
|
9
|
+
global.self = global;
|
|
10
|
+
jest.mock('uuid');
|
|
11
|
+
describe('webWorker', function () {
|
|
12
|
+
var postMessageSpy;
|
|
13
|
+
var capturedIntervalCallback;
|
|
14
|
+
var capturedIntervalTimer;
|
|
15
|
+
var clearIntervalSpy;
|
|
16
|
+
beforeEach(function () {
|
|
17
|
+
jest.useFakeTimers();
|
|
18
|
+
global.fetch = jest.fn();
|
|
19
|
+
_uuid.v4.mockReturnValue('mock-uuid');
|
|
20
|
+
postMessageSpy = jest.spyOn(global, 'postMessage').mockImplementation(function () {});
|
|
21
|
+
clearIntervalSpy = jest.spyOn(global, 'clearInterval');
|
|
22
|
+
|
|
23
|
+
// Overriding setInterval so that we capture the callback rather than schedule a timer
|
|
24
|
+
jest.spyOn(global, 'setInterval').mockImplementation(
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
+
function (callback, interval) {
|
|
27
|
+
capturedIntervalCallback = callback;
|
|
28
|
+
// Create a dummy timer object (could be any non-null value)
|
|
29
|
+
capturedIntervalTimer = {
|
|
30
|
+
dummy: true
|
|
31
|
+
};
|
|
32
|
+
return capturedIntervalTimer;
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
afterEach(function () {
|
|
36
|
+
jest.clearAllMocks();
|
|
37
|
+
jest.clearAllTimers();
|
|
38
|
+
jest.useRealTimers();
|
|
39
|
+
});
|
|
40
|
+
it('should start keepalive lifecycle correctly', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
41
|
+
var fakeSuccessResponse, fakeFailureRespponse;
|
|
42
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
fakeSuccessResponse = {
|
|
46
|
+
ok: true,
|
|
47
|
+
status: 200
|
|
48
|
+
};
|
|
49
|
+
global.fetch.mockResolvedValue(fakeSuccessResponse);
|
|
50
|
+
(0, _webWorker.messageHandler)({
|
|
51
|
+
data: {
|
|
52
|
+
type: _types.WorkerMessageType.START_KEEPALIVE,
|
|
53
|
+
accessToken: 'dummy',
|
|
54
|
+
deviceUrl: 'dummyDevice',
|
|
55
|
+
interval: 1,
|
|
56
|
+
retryCountThreshold: 3,
|
|
57
|
+
url: 'http://example.com'
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Manually invoke the captured interval callback to simulate one tick
|
|
62
|
+
_context.next = 5;
|
|
63
|
+
return capturedIntervalCallback();
|
|
64
|
+
case 5:
|
|
65
|
+
expect(global.fetch.mock.calls.length).toBe(1);
|
|
66
|
+
expect(global.fetch).toHaveBeenCalledWith('http://example.com/status', {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
headers: {
|
|
69
|
+
'cisco-device-url': 'dummyDevice',
|
|
70
|
+
'spark-user-agent': 'webex-calling/beta',
|
|
71
|
+
Authorization: 'dummy',
|
|
72
|
+
trackingId: 'web_worker_mock-uuid'
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
expect(postMessageSpy).not.toHaveBeenCalled();
|
|
76
|
+
fakeFailureRespponse = {
|
|
77
|
+
ok: false,
|
|
78
|
+
status: 401
|
|
79
|
+
};
|
|
80
|
+
global.fetch.mockResolvedValue(fakeFailureRespponse);
|
|
81
|
+
(0, _webWorker.messageHandler)({
|
|
82
|
+
data: {
|
|
83
|
+
type: _types.WorkerMessageType.START_KEEPALIVE,
|
|
84
|
+
accessToken: 'dummy',
|
|
85
|
+
deviceUrl: 'dummyDevice',
|
|
86
|
+
interval: 1,
|
|
87
|
+
retryCountThreshold: 3,
|
|
88
|
+
url: 'http://example.com'
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Manually invoke the captured interval callback to simulate one tick
|
|
93
|
+
_context.next = 13;
|
|
94
|
+
return capturedIntervalCallback();
|
|
95
|
+
case 13:
|
|
96
|
+
expect(global.fetch.mock.calls.length).toBe(2);
|
|
97
|
+
expect(postMessageSpy).toHaveBeenCalledWith({
|
|
98
|
+
err: new Error("Keepalive failed with status: 401"),
|
|
99
|
+
keepAliveRetryCount: 1,
|
|
100
|
+
type: 'KEEPALIVE_FAILURE'
|
|
101
|
+
});
|
|
102
|
+
case 15:
|
|
103
|
+
case "end":
|
|
104
|
+
return _context.stop();
|
|
105
|
+
}
|
|
106
|
+
}, _callee);
|
|
107
|
+
})));
|
|
108
|
+
it('should post KEEPALIVE_FAILURE when fetch fails', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
109
|
+
var mockError;
|
|
110
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
111
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
112
|
+
case 0:
|
|
113
|
+
mockError = new Error('Network error');
|
|
114
|
+
global.fetch.mockRejectedValue({
|
|
115
|
+
ok: false,
|
|
116
|
+
err: mockError,
|
|
117
|
+
status: 401
|
|
118
|
+
});
|
|
119
|
+
(0, _webWorker.messageHandler)({
|
|
120
|
+
data: {
|
|
121
|
+
type: _types.WorkerMessageType.START_KEEPALIVE,
|
|
122
|
+
accessToken: 'dummy',
|
|
123
|
+
deviceUrl: 'dummyDevice',
|
|
124
|
+
interval: 1,
|
|
125
|
+
retryCountThreshold: 1,
|
|
126
|
+
url: 'http://example.com'
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
_context2.next = 5;
|
|
130
|
+
return capturedIntervalCallback();
|
|
131
|
+
case 5:
|
|
132
|
+
expect(postMessageSpy).toHaveBeenCalledWith({
|
|
133
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
134
|
+
err: {
|
|
135
|
+
ok: false,
|
|
136
|
+
err: mockError,
|
|
137
|
+
status: 401
|
|
138
|
+
},
|
|
139
|
+
keepAliveRetryCount: 1
|
|
140
|
+
});
|
|
141
|
+
case 6:
|
|
142
|
+
case "end":
|
|
143
|
+
return _context2.stop();
|
|
144
|
+
}
|
|
145
|
+
}, _callee2);
|
|
146
|
+
})));
|
|
147
|
+
it('should post KEEPALIVE_SUCCESS after a failure when fetch succeeds', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
148
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
149
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
150
|
+
case 0:
|
|
151
|
+
// Set fetch so that first tick rejects (failure) and second tick resolves (success)
|
|
152
|
+
global.fetch.mockRejectedValueOnce(new Error('first failure')).mockResolvedValueOnce({
|
|
153
|
+
ok: true,
|
|
154
|
+
status: 200
|
|
155
|
+
});
|
|
156
|
+
(0, _webWorker.messageHandler)({
|
|
157
|
+
data: {
|
|
158
|
+
type: _types.WorkerMessageType.START_KEEPALIVE,
|
|
159
|
+
accessToken: 'dummy',
|
|
160
|
+
deviceUrl: 'dummyDevice',
|
|
161
|
+
interval: 1,
|
|
162
|
+
retryCountThreshold: 3,
|
|
163
|
+
url: 'http://example.com'
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// First tick: trigger failure
|
|
168
|
+
_context3.next = 4;
|
|
169
|
+
return capturedIntervalCallback();
|
|
170
|
+
case 4:
|
|
171
|
+
expect(postMessageSpy.mock.calls[0][0].type).toBe(_types.WorkerMessageType.KEEPALIVE_FAILURE);
|
|
172
|
+
|
|
173
|
+
// Second tick: trigger success.
|
|
174
|
+
_context3.next = 7;
|
|
175
|
+
return capturedIntervalCallback();
|
|
176
|
+
case 7:
|
|
177
|
+
expect(postMessageSpy.mock.calls[1][0].type).toBe(_types.WorkerMessageType.KEEPALIVE_SUCCESS);
|
|
178
|
+
expect(postMessageSpy.mock.calls[1][0].statusCode).toBe(200);
|
|
179
|
+
case 9:
|
|
180
|
+
case "end":
|
|
181
|
+
return _context3.stop();
|
|
182
|
+
}
|
|
183
|
+
}, _callee3);
|
|
184
|
+
})));
|
|
185
|
+
it('should clear keepalive timer on receiving CLEAR_KEEPALIVE message', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
186
|
+
var fakeSuccessResponse, startEvent;
|
|
187
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
188
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
189
|
+
case 0:
|
|
190
|
+
fakeSuccessResponse = {
|
|
191
|
+
ok: true,
|
|
192
|
+
status: 200
|
|
193
|
+
};
|
|
194
|
+
global.fetch.mockResolvedValue(fakeSuccessResponse);
|
|
195
|
+
startEvent = {
|
|
196
|
+
data: {
|
|
197
|
+
type: _types.WorkerMessageType.START_KEEPALIVE,
|
|
198
|
+
accessToken: 'dummy',
|
|
199
|
+
deviceUrl: 'dummyDevice',
|
|
200
|
+
interval: 1,
|
|
201
|
+
retryCountThreshold: 1,
|
|
202
|
+
url: 'http://example.com'
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
(0, _webWorker.messageHandler)(startEvent);
|
|
206
|
+
(0, _webWorker.messageHandler)({
|
|
207
|
+
data: {
|
|
208
|
+
type: _types.WorkerMessageType.CLEAR_KEEPALIVE
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
jest.advanceTimersByTime(3000);
|
|
212
|
+
expect(global.fetch.mock.calls.length).toBeLessThanOrEqual(3);
|
|
213
|
+
expect(clearIntervalSpy).toHaveBeenCalled();
|
|
214
|
+
case 8:
|
|
215
|
+
case "end":
|
|
216
|
+
return _context4.stop();
|
|
217
|
+
}
|
|
218
|
+
}, _callee4);
|
|
219
|
+
})));
|
|
220
|
+
it('improve coverage: should not clear keepalive timer on receiving CLEAR_KEEPALIVE message without keepTimer', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
221
|
+
var fakeSuccessResponse, startEvent;
|
|
222
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
223
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
224
|
+
case 0:
|
|
225
|
+
jest.spyOn(global, 'setInterval').mockReturnValue(undefined);
|
|
226
|
+
fakeSuccessResponse = {
|
|
227
|
+
ok: true,
|
|
228
|
+
status: 200
|
|
229
|
+
};
|
|
230
|
+
global.fetch.mockResolvedValue(fakeSuccessResponse);
|
|
231
|
+
startEvent = {
|
|
232
|
+
data: {
|
|
233
|
+
type: _types.WorkerMessageType.START_KEEPALIVE,
|
|
234
|
+
accessToken: 'dummy',
|
|
235
|
+
deviceUrl: 'dummyDevice',
|
|
236
|
+
interval: 1,
|
|
237
|
+
retryCountThreshold: 1,
|
|
238
|
+
url: 'http://example.com'
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
(0, _webWorker.messageHandler)(startEvent);
|
|
242
|
+
(0, _webWorker.messageHandler)({
|
|
243
|
+
data: {
|
|
244
|
+
type: _types.WorkerMessageType.CLEAR_KEEPALIVE
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
jest.advanceTimersByTime(3000);
|
|
248
|
+
expect(clearIntervalSpy).not.toHaveBeenCalled();
|
|
249
|
+
case 8:
|
|
250
|
+
case "end":
|
|
251
|
+
return _context5.stop();
|
|
252
|
+
}
|
|
253
|
+
}, _callee5);
|
|
254
|
+
})));
|
|
255
|
+
});
|
|
256
|
+
//# sourceMappingURL=webWorker.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_uuid","require","_webWorker","_types","global","self","jest","mock","describe","postMessageSpy","capturedIntervalCallback","capturedIntervalTimer","clearIntervalSpy","beforeEach","useFakeTimers","fetch","fn","uuid","mockReturnValue","spyOn","mockImplementation","callback","interval","dummy","afterEach","clearAllMocks","clearAllTimers","useRealTimers","it","_asyncToGenerator2","default","_regenerator","mark","_callee","fakeSuccessResponse","fakeFailureRespponse","wrap","_callee$","_context","prev","next","ok","status","mockResolvedValue","messageHandler","data","type","WorkerMessageType","START_KEEPALIVE","accessToken","deviceUrl","retryCountThreshold","url","expect","calls","length","toBe","toHaveBeenCalledWith","method","headers","Authorization","trackingId","not","toHaveBeenCalled","err","Error","keepAliveRetryCount","stop","_callee2","mockError","_callee2$","_context2","mockRejectedValue","KEEPALIVE_FAILURE","_callee3","_callee3$","_context3","mockRejectedValueOnce","mockResolvedValueOnce","KEEPALIVE_SUCCESS","statusCode","_callee4","startEvent","_callee4$","_context4","CLEAR_KEEPALIVE","advanceTimersByTime","toBeLessThanOrEqual","_callee5","_callee5$","_context5","undefined"],"sources":["webWorker.test.ts"],"sourcesContent":["import {v4 as uuid} from 'uuid';\nimport {messageHandler} from './webWorker';\nimport {WorkerMessageType} from '../../common/types';\n\n(global as any).self = global;\n\njest.mock('uuid');\n\ndescribe('webWorker', () => {\n let postMessageSpy: jest.SpyInstance;\n let capturedIntervalCallback: any;\n let capturedIntervalTimer: any;\n let clearIntervalSpy: jest.SpyInstance;\n\n beforeEach(() => {\n jest.useFakeTimers();\n global.fetch = jest.fn();\n (uuid as jest.Mock).mockReturnValue('mock-uuid');\n\n postMessageSpy = jest.spyOn(global, 'postMessage').mockImplementation(() => {});\n clearIntervalSpy = jest.spyOn(global, 'clearInterval');\n\n // Overriding setInterval so that we capture the callback rather than schedule a timer\n jest.spyOn(global, 'setInterval').mockImplementation(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n (callback: any, interval: number): NodeJS.Timeout => {\n capturedIntervalCallback = callback;\n // Create a dummy timer object (could be any non-null value)\n capturedIntervalTimer = {dummy: true};\n\n return capturedIntervalTimer as NodeJS.Timeout;\n }\n );\n });\n\n afterEach(() => {\n jest.clearAllMocks();\n jest.clearAllTimers();\n jest.useRealTimers();\n });\n\n it('should start keepalive lifecycle correctly', async () => {\n const fakeSuccessResponse = {ok: true, status: 200};\n (global.fetch as jest.Mock).mockResolvedValue(fakeSuccessResponse);\n\n messageHandler({\n data: {\n type: WorkerMessageType.START_KEEPALIVE,\n accessToken: 'dummy',\n deviceUrl: 'dummyDevice',\n interval: 1,\n retryCountThreshold: 3,\n url: 'http://example.com',\n },\n } as MessageEvent);\n\n // Manually invoke the captured interval callback to simulate one tick\n await capturedIntervalCallback();\n\n expect((global.fetch as jest.Mock).mock.calls.length).toBe(1);\n expect(global.fetch).toHaveBeenCalledWith('http://example.com/status', {\n method: 'POST',\n headers: {\n 'cisco-device-url': 'dummyDevice',\n 'spark-user-agent': 'webex-calling/beta',\n Authorization: 'dummy',\n trackingId: 'web_worker_mock-uuid',\n },\n });\n expect(postMessageSpy).not.toHaveBeenCalled();\n\n const fakeFailureRespponse = {ok: false, status: 401};\n (global.fetch as jest.Mock).mockResolvedValue(fakeFailureRespponse);\n\n messageHandler({\n data: {\n type: WorkerMessageType.START_KEEPALIVE,\n accessToken: 'dummy',\n deviceUrl: 'dummyDevice',\n interval: 1,\n retryCountThreshold: 3,\n url: 'http://example.com',\n },\n } as MessageEvent);\n\n // Manually invoke the captured interval callback to simulate one tick\n await capturedIntervalCallback();\n\n expect((global.fetch as jest.Mock).mock.calls.length).toBe(2);\n expect(postMessageSpy).toHaveBeenCalledWith({\n err: new Error(`Keepalive failed with status: 401`),\n keepAliveRetryCount: 1,\n type: 'KEEPALIVE_FAILURE',\n });\n });\n\n it('should post KEEPALIVE_FAILURE when fetch fails', async () => {\n const mockError = new Error('Network error');\n (global.fetch as jest.Mock).mockRejectedValue({\n ok: false,\n err: mockError,\n status: 401,\n });\n\n messageHandler({\n data: {\n type: WorkerMessageType.START_KEEPALIVE,\n accessToken: 'dummy',\n deviceUrl: 'dummyDevice',\n interval: 1,\n retryCountThreshold: 1,\n url: 'http://example.com',\n },\n } as MessageEvent);\n\n await capturedIntervalCallback();\n\n expect(postMessageSpy).toHaveBeenCalledWith({\n type: WorkerMessageType.KEEPALIVE_FAILURE,\n err: {\n ok: false,\n err: mockError,\n status: 401,\n },\n keepAliveRetryCount: 1,\n });\n });\n\n it('should post KEEPALIVE_SUCCESS after a failure when fetch succeeds', async () => {\n // Set fetch so that first tick rejects (failure) and second tick resolves (success)\n (global.fetch as jest.Mock)\n .mockRejectedValueOnce(new Error('first failure'))\n .mockResolvedValueOnce({ok: true, status: 200});\n\n messageHandler({\n data: {\n type: WorkerMessageType.START_KEEPALIVE,\n accessToken: 'dummy',\n deviceUrl: 'dummyDevice',\n interval: 1,\n retryCountThreshold: 3,\n url: 'http://example.com',\n },\n } as MessageEvent);\n\n // First tick: trigger failure\n await capturedIntervalCallback();\n expect(postMessageSpy.mock.calls[0][0].type).toBe(WorkerMessageType.KEEPALIVE_FAILURE);\n\n // Second tick: trigger success.\n await capturedIntervalCallback();\n expect(postMessageSpy.mock.calls[1][0].type).toBe(WorkerMessageType.KEEPALIVE_SUCCESS);\n expect(postMessageSpy.mock.calls[1][0].statusCode).toBe(200);\n });\n\n it('should clear keepalive timer on receiving CLEAR_KEEPALIVE message', async () => {\n const fakeSuccessResponse = {ok: true, status: 200};\n (global.fetch as jest.Mock).mockResolvedValue(fakeSuccessResponse);\n\n const startEvent = {\n data: {\n type: WorkerMessageType.START_KEEPALIVE,\n accessToken: 'dummy',\n deviceUrl: 'dummyDevice',\n interval: 1,\n retryCountThreshold: 1,\n url: 'http://example.com',\n },\n };\n\n messageHandler(startEvent as MessageEvent);\n messageHandler({data: {type: WorkerMessageType.CLEAR_KEEPALIVE}} as MessageEvent);\n\n jest.advanceTimersByTime(3000);\n expect((global.fetch as jest.Mock).mock.calls.length).toBeLessThanOrEqual(3);\n expect(clearIntervalSpy).toHaveBeenCalled();\n });\n\n it('improve coverage: should not clear keepalive timer on receiving CLEAR_KEEPALIVE message without keepTimer', async () => {\n jest.spyOn(global, 'setInterval').mockReturnValue(undefined);\n const fakeSuccessResponse = {ok: true, status: 200};\n (global.fetch as jest.Mock).mockResolvedValue(fakeSuccessResponse);\n\n const startEvent = {\n data: {\n type: WorkerMessageType.START_KEEPALIVE,\n accessToken: 'dummy',\n deviceUrl: 'dummyDevice',\n interval: 1,\n retryCountThreshold: 1,\n url: 'http://example.com',\n },\n };\n\n messageHandler(startEvent as MessageEvent);\n messageHandler({data: {type: WorkerMessageType.CLEAR_KEEPALIVE}} as MessageEvent);\n\n jest.advanceTimersByTime(3000);\n expect(clearIntervalSpy).not.toHaveBeenCalled();\n });\n});\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAECG,MAAM,CAASC,IAAI,GAAGD,MAAM;AAE7BE,IAAI,CAACC,IAAI,CAAC,MAAM,CAAC;AA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AiB,CAAC;UAEjF/E,IAAI,CAACgF,mBAAmB,CAAC,IAAI,CAAC;UAC9BjC,MAAM,CAACzC,gBAAgB,CAAC,CAACkD,GAAG,CAACC,gBAAgB,CAAC,CAAC;QAAC;QAAA;UAAA,OAAA2B,SAAA,CAAAvB,IAAA;MAAA;IAAA,GAAAqB,QAAA;EAAA,CACjD,GAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* This file contains the stringified version of the web worker code from webWorker.ts
|
|
10
|
+
* It can be used to create a Blob URL for the worker instead of loading it from a separate file
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
var webWorkerStr = "/* eslint-env worker */\n\nconst uuid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n};\n\n// Enum values from the original imports\nconst HTTP_METHODS = {\n GET: 'GET',\n POST: 'POST',\n PUT: 'PUT',\n DELETE: 'DELETE',\n PATCH: 'PATCH',\n};\n\nconst WorkerMessageType = {\n START_KEEPALIVE: 'START_KEEPALIVE',\n CLEAR_KEEPALIVE: 'CLEAR_KEEPALIVE',\n KEEPALIVE_SUCCESS: 'KEEPALIVE_SUCCESS',\n KEEPALIVE_FAILURE: 'KEEPALIVE_FAILURE',\n};\n\nlet keepaliveTimer;\n\nconst messageHandler = (event) => {\n const {type} = event.data;\n\n const postKeepAlive = async (accessToken, deviceUrl, url) => {\n const response = await fetch(`${url}/status`, {\n method: HTTP_METHODS.POST,\n headers: {\n 'cisco-device-url': deviceUrl,\n 'spark-user-agent': 'webex-calling/beta',\n Authorization: `${accessToken}`,\n trackingId: `web_worker_${uuid()}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(`Keepalive failed with status: ${response.status}`);\n }\n\n return response;\n };\n\n if (type === WorkerMessageType.START_KEEPALIVE) {\n let keepAliveRetryCount = 0;\n const {accessToken, deviceUrl, interval, retryCountThreshold, url} = event.data;\n\n if (keepaliveTimer) {\n clearInterval(keepaliveTimer);\n keepaliveTimer = undefined;\n }\n\n keepaliveTimer = setInterval(async () => {\n if (keepAliveRetryCount < retryCountThreshold) {\n try {\n const res = await postKeepAlive(accessToken, deviceUrl, url);\n const statusCode = res.status;\n if (keepAliveRetryCount > 0) {\n self.postMessage({\n type: WorkerMessageType.KEEPALIVE_SUCCESS,\n statusCode,\n });\n }\n keepAliveRetryCount = 0;\n } catch (err) {\n keepAliveRetryCount += 1;\n self.postMessage({\n type: WorkerMessageType.KEEPALIVE_FAILURE,\n err,\n keepAliveRetryCount,\n });\n }\n }\n }, interval * 1000);\n }\n\n if (type === WorkerMessageType.CLEAR_KEEPALIVE) {\n if (keepaliveTimer) {\n clearInterval(keepaliveTimer);\n keepaliveTimer = undefined;\n }\n }\n};\n\nself.addEventListener('message', messageHandler);\n";
|
|
14
|
+
var _default = exports.default = webWorkerStr;
|
|
15
|
+
//# sourceMappingURL=webWorkerStr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["webWorkerStr","_default","exports","default"],"sources":["webWorkerStr.ts"],"sourcesContent":["/**\n * This file contains the stringified version of the web worker code from webWorker.ts\n * It can be used to create a Blob URL for the worker instead of loading it from a separate file\n */\n\nconst webWorkerStr = `/* eslint-env worker */\n\nconst uuid = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n};\n\n// Enum values from the original imports\nconst HTTP_METHODS = {\n GET: 'GET',\n POST: 'POST',\n PUT: 'PUT',\n DELETE: 'DELETE',\n PATCH: 'PATCH',\n};\n\nconst WorkerMessageType = {\n START_KEEPALIVE: 'START_KEEPALIVE',\n CLEAR_KEEPALIVE: 'CLEAR_KEEPALIVE',\n KEEPALIVE_SUCCESS: 'KEEPALIVE_SUCCESS',\n KEEPALIVE_FAILURE: 'KEEPALIVE_FAILURE',\n};\n\nlet keepaliveTimer;\n\nconst messageHandler = (event) => {\n const {type} = event.data;\n\n const postKeepAlive = async (accessToken, deviceUrl, url) => {\n const response = await fetch(\\`\\${url}/status\\`, {\n method: HTTP_METHODS.POST,\n headers: {\n 'cisco-device-url': deviceUrl,\n 'spark-user-agent': 'webex-calling/beta',\n Authorization: \\`\\${accessToken}\\`,\n trackingId: \\`web_worker_\\${uuid()}\\`,\n },\n });\n\n if (!response.ok) {\n throw new Error(\\`Keepalive failed with status: \\${response.status}\\`);\n }\n\n return response;\n };\n\n if (type === WorkerMessageType.START_KEEPALIVE) {\n let keepAliveRetryCount = 0;\n const {accessToken, deviceUrl, interval, retryCountThreshold, url} = event.data;\n\n if (keepaliveTimer) {\n clearInterval(keepaliveTimer);\n keepaliveTimer = undefined;\n }\n\n keepaliveTimer = setInterval(async () => {\n if (keepAliveRetryCount < retryCountThreshold) {\n try {\n const res = await postKeepAlive(accessToken, deviceUrl, url);\n const statusCode = res.status;\n if (keepAliveRetryCount > 0) {\n self.postMessage({\n type: WorkerMessageType.KEEPALIVE_SUCCESS,\n statusCode,\n });\n }\n keepAliveRetryCount = 0;\n } catch (err) {\n keepAliveRetryCount += 1;\n self.postMessage({\n type: WorkerMessageType.KEEPALIVE_FAILURE,\n err,\n keepAliveRetryCount,\n });\n }\n }\n }, interval * 1000);\n }\n\n if (type === WorkerMessageType.CLEAR_KEEPALIVE) {\n if (keepaliveTimer) {\n clearInterval(keepaliveTimer);\n keepaliveTimer = undefined;\n }\n }\n};\n\nself.addEventListener('message', messageHandler);\n`;\n\nexport default webWorkerStr;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;;AAEA,IAAMA,YAAY,o5EA2FjB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaH,YAAY"}
|
package/dist/common/types.js
CHANGED
|
@@ -4,7 +4,7 @@ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/defi
|
|
|
4
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.ServiceIndicator = exports.SORT_BY = exports.SORT = exports.RegistrationStatus = exports.HTTP_METHODS = exports.DecodeType = exports.CallType = exports.CallDirection = exports.CALLING_BACKEND = exports.ALLOWED_SERVICES = void 0;
|
|
7
|
+
exports.WorkerMessageType = exports.ServiceIndicator = exports.SORT_BY = exports.SORT = exports.RegistrationStatus = exports.HTTP_METHODS = exports.DecodeType = exports.CallType = exports.CallDirection = exports.CALLING_BACKEND = exports.ALLOWED_SERVICES = void 0;
|
|
8
8
|
var _constants = require("./constants");
|
|
9
9
|
var ALLOWED_SERVICES = exports.ALLOWED_SERVICES = /*#__PURE__*/function (ALLOWED_SERVICES) {
|
|
10
10
|
ALLOWED_SERVICES["MOBIUS"] = "mobius";
|
|
@@ -65,4 +65,11 @@ var DecodeType = exports.DecodeType = /*#__PURE__*/function (DecodeType) {
|
|
|
65
65
|
DecodeType["ORGANIZATION"] = "ORGANIZATION";
|
|
66
66
|
return DecodeType;
|
|
67
67
|
}({});
|
|
68
|
+
var WorkerMessageType = exports.WorkerMessageType = /*#__PURE__*/function (WorkerMessageType) {
|
|
69
|
+
WorkerMessageType["START_KEEPALIVE"] = "START_KEEPALIVE";
|
|
70
|
+
WorkerMessageType["CLEAR_KEEPALIVE"] = "CLEAR_KEEPALIVE";
|
|
71
|
+
WorkerMessageType["KEEPALIVE_SUCCESS"] = "KEEPALIVE_SUCCESS";
|
|
72
|
+
WorkerMessageType["KEEPALIVE_FAILURE"] = "KEEPALIVE_FAILURE";
|
|
73
|
+
return WorkerMessageType;
|
|
74
|
+
}({});
|
|
68
75
|
//# sourceMappingURL=types.js.map
|
package/dist/common/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_constants","require","ALLOWED_SERVICES","exports","HTTP_METHODS","RegistrationStatus","CALLING_BACKEND","CallType","CallDirection","SORT","SORT_BY","ServiceIndicator","DecodeType"],"sources":["types.ts"],"sourcesContent":["import {SCIM_ENTERPRISE_USER, SCIM_WEBEXIDENTITY_USER} from './constants';\n\nexport type MobiusDeviceId = string;\nexport type MobiusDeviceUri = string;\nexport type SettingEnabled = boolean;\n\nexport enum ALLOWED_SERVICES {\n MOBIUS = 'mobius',\n JANUS = 'janus',\n}\nexport enum HTTP_METHODS {\n GET = 'GET',\n POST = 'POST',\n PATCH = 'PATCH',\n PUT = 'PUT',\n DELETE = 'DELETE',\n}\n\nexport enum RegistrationStatus {\n IDLE = 'IDLE',\n ACTIVE = 'active',\n INACTIVE = 'inactive',\n}\n\nexport enum CALLING_BACKEND {\n WXC = 'WEBEX_CALLING',\n BWRKS = 'BROADWORKS_CALLING',\n UCM = 'UCM_CALLING',\n INVALID = 'Calling backend is currently not supported',\n}\n\nexport type DeviceList = unknown;\nexport type CallId = string; // guid;\nexport type CorrelationId = string;\nexport enum CallType {\n URI = 'uri',\n TEL = 'tel',\n}\nexport type CallDetails = {\n type: CallType;\n address: string; // sip address\n};\n\nexport type CallDestination = CallDetails;\nexport enum CallDirection {\n INBOUND = 'inbound',\n OUTBOUND = 'outbound',\n}\nexport type AvatarId = string;\nexport type DisplayName = string;\nexport type DisplayInformation = {\n avatarSrc: AvatarId | undefined;\n name: DisplayName | undefined;\n num: string | undefined;\n id: string | undefined;\n};\n\nexport type WebexRequestPayload = {\n method?: HTTP_METHODS;\n uri?: string;\n addAuthHeader?: boolean;\n headers?: {\n [key: string]: string | null;\n };\n body?: object;\n statusCode?: number;\n json?: boolean;\n service?: ALLOWED_SERVICES;\n};\n\nexport type ErrorCode = string;\n\nexport type Digit = string | number;\n\nexport type ServerInfo = {\n region: string;\n uris: string[];\n};\n\nexport type MobiusServers = {\n primary: ServerInfo;\n backup: ServerInfo;\n};\n\nexport type IpInfo = {\n ipv4: string;\n ipv6: string;\n};\n\nexport type DeviceType = {\n deviceId: string;\n uri: string;\n status: string;\n lastSeen: string;\n addresses: string[];\n clientDeviceUri: string;\n};\n\nexport type RegionInfo = {\n countryCode: string;\n clientRegion: string;\n};\n\nexport interface IDeviceInfo {\n userId?: string;\n errorCode?: number;\n\n device?: DeviceType;\n devices?: DeviceType[];\n keepaliveInterval?: number;\n callKeepaliveInterval?: number;\n voicePortalNumber?: number;\n voicePortalExtension?: number;\n // cSpell:disable\n rehomingIntervalMin?: number;\n rehomingIntervalMax?: number;\n /* cSpell:enable */\n}\n\nexport interface IMetaContext {\n file?: string;\n method?: string;\n}\n\nexport enum SORT {\n ASC = 'ASC',\n DESC = 'DESC',\n DEFAULT = 'DESC',\n}\n\nexport enum SORT_BY {\n END_TIME = 'endTime',\n DEFAULT = 'endTime',\n START_TIME = 'startTime',\n}\n\nexport enum ServiceIndicator {\n CALLING = 'calling',\n CONTACT_CENTER = 'contactcenter',\n GUEST_CALLING = 'guestcalling',\n}\n\nexport type ServiceData = {\n indicator: ServiceIndicator;\n domain?: string;\n};\n\nexport type PhoneNumber = {\n type: string;\n value: string;\n primary?: boolean;\n};\n\nexport type PersonInfo = {\n id: string;\n emails: string[];\n phoneNumbers: PhoneNumber[];\n displayName: string;\n nickName: string;\n firstName: string;\n lastName: string;\n avatar: string;\n orgId: string;\n created: string;\n lastModified: string;\n lastActivity: string;\n status: string;\n type: string;\n};\n\nexport type PeopleListResponse = {\n items: PersonInfo[];\n notFoundIds: string[];\n};\n\nexport enum DecodeType {\n PEOPLE = 'PEOPLE',\n ORGANIZATION = 'ORGANIZATION',\n}\n\nexport type ContactDetail = {\n type?: string;\n value: string;\n};\n\nexport interface URIAddress {\n value: string;\n type: string;\n primary?: boolean;\n}\n\nexport type KmsKey = {\n uri: string;\n userId: string;\n createDate: string;\n expirationDate: string;\n bindDate?: string;\n resourceUri?: string;\n};\n\nexport type KmsResourceObject = {\n uri: string;\n keyUris: string[];\n authorizationUris: string[];\n};\n\nexport interface Name {\n familyName: string;\n givenName: string;\n}\n\nexport interface Address {\n city?: string;\n country?: string;\n state?: string;\n street?: string;\n zipCode?: string;\n}\n\ninterface WebexIdentityMeta {\n organizationId: string;\n}\ninterface WebexIdentityUser {\n sipAddresses?: URIAddress[];\n meta?: WebexIdentityMeta;\n}\n\ninterface Manager {\n value: string;\n displayName: string;\n $ref: string;\n}\n\ninterface EnterpriseUser {\n department?: string;\n manager?: Manager;\n}\n\ninterface Resource {\n schemas: string[];\n id: string;\n userName: string;\n active?: boolean;\n name?: Name;\n displayName?: string;\n emails?: URIAddress[];\n userType: string;\n phoneNumbers?: PhoneNumber[];\n photos?: ContactDetail[];\n addresses?: Address[];\n [SCIM_WEBEXIDENTITY_USER]?: WebexIdentityUser;\n [SCIM_ENTERPRISE_USER]?: EnterpriseUser;\n}\n\nexport interface SCIMListResponse {\n schemas: string[];\n totalResults: number;\n itemsPerPage: number;\n startIndex: number;\n Resources: Resource[];\n}\n\nexport type LogsMetaData = {\n callId?: string;\n feedbackId?: string;\n correlationId?: string;\n};\n\nexport type UploadLogsResponse = {\n trackingid?: string;\n url?: string;\n userId?: string;\n feedbackId: string;\n correlationId?: string;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAA0E,IAM9DC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AAAA,IAIhBE,YAAY,GAAAD,OAAA,CAAAC,YAAA,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA;AAAA,IAQZC,kBAAkB,GAAAF,OAAA,CAAAE,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAAA,IAMlBC,eAAe,GAAAH,OAAA,CAAAG,eAAA,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA,OAQE;AAAA,IAEjBC,QAAQ,GAAAJ,OAAA,CAAAI,QAAA,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAAA,IAURC,aAAa,GAAAL,OAAA,CAAAK,aAAA,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAAA,IAgFbC,IAAI,GAAAN,OAAA,CAAAM,IAAA,0BAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAA,OAAJA,IAAI;AAAA;AAAA,IAMJC,OAAO,GAAAP,OAAA,CAAAO,OAAA,0BAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAA,OAAPA,OAAO;AAAA;AAAA,IAMPC,gBAAgB,GAAAR,OAAA,CAAAQ,gBAAA,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AAAA,IAuChBC,UAAU,GAAAT,OAAA,CAAAS,UAAA,0BAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA"}
|
|
1
|
+
{"version":3,"names":["_constants","require","ALLOWED_SERVICES","exports","HTTP_METHODS","RegistrationStatus","CALLING_BACKEND","CallType","CallDirection","SORT","SORT_BY","ServiceIndicator","DecodeType","WorkerMessageType"],"sources":["types.ts"],"sourcesContent":["import {SCIM_ENTERPRISE_USER, SCIM_WEBEXIDENTITY_USER} from './constants';\n\nexport type MobiusDeviceId = string;\nexport type MobiusDeviceUri = string;\nexport type SettingEnabled = boolean;\n\nexport enum ALLOWED_SERVICES {\n MOBIUS = 'mobius',\n JANUS = 'janus',\n}\nexport enum HTTP_METHODS {\n GET = 'GET',\n POST = 'POST',\n PATCH = 'PATCH',\n PUT = 'PUT',\n DELETE = 'DELETE',\n}\n\nexport enum RegistrationStatus {\n IDLE = 'IDLE',\n ACTIVE = 'active',\n INACTIVE = 'inactive',\n}\n\nexport enum CALLING_BACKEND {\n WXC = 'WEBEX_CALLING',\n BWRKS = 'BROADWORKS_CALLING',\n UCM = 'UCM_CALLING',\n INVALID = 'Calling backend is currently not supported',\n}\n\nexport type DeviceList = unknown;\nexport type CallId = string; // guid;\nexport type CorrelationId = string;\nexport enum CallType {\n URI = 'uri',\n TEL = 'tel',\n}\nexport type CallDetails = {\n type: CallType;\n address: string; // sip address\n};\n\nexport type CallDestination = CallDetails;\nexport enum CallDirection {\n INBOUND = 'inbound',\n OUTBOUND = 'outbound',\n}\nexport type AvatarId = string;\nexport type DisplayName = string;\nexport type DisplayInformation = {\n avatarSrc: AvatarId | undefined;\n name: DisplayName | undefined;\n num: string | undefined;\n id: string | undefined;\n};\n\nexport type WebexRequestPayload = {\n method?: HTTP_METHODS;\n uri?: string;\n addAuthHeader?: boolean;\n headers?: {\n [key: string]: string | null;\n };\n body?: object;\n statusCode?: number;\n json?: boolean;\n service?: ALLOWED_SERVICES;\n};\n\nexport type ErrorCode = string;\n\nexport type Digit = string | number;\n\nexport type ServerInfo = {\n region: string;\n uris: string[];\n};\n\nexport type MobiusServers = {\n primary: ServerInfo;\n backup: ServerInfo;\n};\n\nexport type IpInfo = {\n ipv4: string;\n ipv6: string;\n};\n\nexport type DeviceType = {\n deviceId: string;\n uri: string;\n status: string;\n lastSeen: string;\n addresses: string[];\n clientDeviceUri: string;\n};\n\nexport type RegionInfo = {\n countryCode: string;\n clientRegion: string;\n};\n\nexport interface IDeviceInfo {\n userId?: string;\n errorCode?: number;\n\n device?: DeviceType;\n devices?: DeviceType[];\n keepaliveInterval?: number;\n callKeepaliveInterval?: number;\n voicePortalNumber?: number;\n voicePortalExtension?: number;\n // cSpell:disable\n rehomingIntervalMin?: number;\n rehomingIntervalMax?: number;\n /* cSpell:enable */\n}\n\nexport interface IMetaContext {\n file?: string;\n method?: string;\n}\n\nexport enum SORT {\n ASC = 'ASC',\n DESC = 'DESC',\n DEFAULT = 'DESC',\n}\n\nexport enum SORT_BY {\n END_TIME = 'endTime',\n DEFAULT = 'endTime',\n START_TIME = 'startTime',\n}\n\nexport enum ServiceIndicator {\n CALLING = 'calling',\n CONTACT_CENTER = 'contactcenter',\n GUEST_CALLING = 'guestcalling',\n}\n\nexport type ServiceData = {\n indicator: ServiceIndicator;\n domain?: string;\n};\n\nexport type PhoneNumber = {\n type: string;\n value: string;\n primary?: boolean;\n};\n\nexport type PersonInfo = {\n id: string;\n emails: string[];\n phoneNumbers: PhoneNumber[];\n displayName: string;\n nickName: string;\n firstName: string;\n lastName: string;\n avatar: string;\n orgId: string;\n created: string;\n lastModified: string;\n lastActivity: string;\n status: string;\n type: string;\n};\n\nexport type PeopleListResponse = {\n items: PersonInfo[];\n notFoundIds: string[];\n};\n\nexport enum DecodeType {\n PEOPLE = 'PEOPLE',\n ORGANIZATION = 'ORGANIZATION',\n}\n\nexport type ContactDetail = {\n type?: string;\n value: string;\n};\n\nexport interface URIAddress {\n value: string;\n type: string;\n primary?: boolean;\n}\n\nexport type KmsKey = {\n uri: string;\n userId: string;\n createDate: string;\n expirationDate: string;\n bindDate?: string;\n resourceUri?: string;\n};\n\nexport type KmsResourceObject = {\n uri: string;\n keyUris: string[];\n authorizationUris: string[];\n};\n\nexport interface Name {\n familyName: string;\n givenName: string;\n}\n\nexport interface Address {\n city?: string;\n country?: string;\n state?: string;\n street?: string;\n zipCode?: string;\n}\n\ninterface WebexIdentityMeta {\n organizationId: string;\n}\ninterface WebexIdentityUser {\n sipAddresses?: URIAddress[];\n meta?: WebexIdentityMeta;\n}\n\ninterface Manager {\n value: string;\n displayName: string;\n $ref: string;\n}\n\ninterface EnterpriseUser {\n department?: string;\n manager?: Manager;\n}\n\ninterface Resource {\n schemas: string[];\n id: string;\n userName: string;\n active?: boolean;\n name?: Name;\n displayName?: string;\n emails?: URIAddress[];\n userType: string;\n phoneNumbers?: PhoneNumber[];\n photos?: ContactDetail[];\n addresses?: Address[];\n [SCIM_WEBEXIDENTITY_USER]?: WebexIdentityUser;\n [SCIM_ENTERPRISE_USER]?: EnterpriseUser;\n}\n\nexport interface SCIMListResponse {\n schemas: string[];\n totalResults: number;\n itemsPerPage: number;\n startIndex: number;\n Resources: Resource[];\n}\n\nexport enum WorkerMessageType {\n START_KEEPALIVE = 'START_KEEPALIVE',\n CLEAR_KEEPALIVE = 'CLEAR_KEEPALIVE',\n KEEPALIVE_SUCCESS = 'KEEPALIVE_SUCCESS',\n KEEPALIVE_FAILURE = 'KEEPALIVE_FAILURE',\n}\n\nexport type KeepaliveStatusMessage = {\n type: WorkerMessageType.KEEPALIVE_SUCCESS | WorkerMessageType.KEEPALIVE_FAILURE;\n err?: unknown;\n keepAliveRetryCount?: number;\n statusCode?: number;\n};\n\nexport type LogsMetaData = {\n callId?: string;\n feedbackId?: string;\n correlationId?: string;\n};\n\nexport type UploadLogsResponse = {\n trackingid?: string;\n url?: string;\n userId?: string;\n feedbackId: string;\n correlationId?: string;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAA0E,IAM9DC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AAAA,IAIhBE,YAAY,GAAAD,OAAA,CAAAC,YAAA,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AA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