@webex/calling 3.12.0-next.3 → 3.12.0-next.30
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.js +463 -205
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +170 -77
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +32 -8
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +581 -445
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +53 -30
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +35 -0
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/calling/types.js +2 -0
- package/dist/CallingClient/calling/types.js.map +1 -1
- package/dist/CallingClient/constants.js +24 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +16 -1
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +694 -406
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +202 -21
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.js +41 -104
- package/dist/CallingClient/registration/webWorker.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.test.js +39 -153
- package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
- package/dist/CallingClient/utils/constants.js +46 -0
- package/dist/CallingClient/utils/constants.js.map +1 -0
- package/dist/CallingClient/utils/index.js +63 -0
- package/dist/CallingClient/utils/index.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js +122 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js +211 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js.map +1 -0
- package/dist/CallingClient/utils/request.js +349 -0
- package/dist/CallingClient/utils/request.js.map +1 -0
- package/dist/CallingClient/utils/request.test.js +881 -0
- package/dist/CallingClient/utils/request.test.js.map +1 -0
- package/dist/CallingClient/utils/types.js +7 -0
- package/dist/CallingClient/utils/types.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js +28 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js +139 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js.map +1 -0
- package/dist/Contacts/ContactsClient.test.js +3 -8
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Events/types.js +1 -11
- package/dist/Events/types.js.map +1 -1
- package/dist/Metrics/index.js +60 -0
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +356 -0
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js +11 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/common/Utils.js +138 -44
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/testUtil.js +8 -4
- package/dist/common/testUtil.js.map +1 -1
- package/dist/common/types.js +2 -0
- package/dist/common/types.js.map +1 -1
- package/dist/mobius-socket/config.js +24 -0
- package/dist/mobius-socket/config.js.map +1 -0
- package/dist/mobius-socket/errors.js +150 -0
- package/dist/mobius-socket/errors.js.map +1 -0
- package/dist/mobius-socket/index.js +57 -0
- package/dist/mobius-socket/index.js.map +1 -0
- package/dist/mobius-socket/mobius-socket-events.test.js +485 -0
- package/dist/mobius-socket/mobius-socket-events.test.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.js +804 -0
- package/dist/mobius-socket/mobius-socket.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.test.js +1833 -0
- package/dist/mobius-socket/mobius-socket.test.js.map +1 -0
- package/dist/mobius-socket/socket/constants.js +34 -0
- package/dist/mobius-socket/socket/constants.js.map +1 -0
- package/dist/mobius-socket/socket/index.js +15 -0
- package/dist/mobius-socket/socket/index.js.map +1 -0
- package/dist/mobius-socket/socket/socket-base.js +604 -0
- package/dist/mobius-socket/socket/socket-base.js.map +1 -0
- package/dist/mobius-socket/socket/socket.js +19 -0
- package/dist/mobius-socket/socket/socket.js.map +1 -0
- package/dist/mobius-socket/socket/socket.shim.js +26 -0
- package/dist/mobius-socket/socket/socket.shim.js.map +1 -0
- package/dist/mobius-socket/socket/types.js +7 -0
- package/dist/mobius-socket/socket/types.js.map +1 -0
- package/dist/mobius-socket/socket.test.js +727 -0
- package/dist/mobius-socket/socket.test.js.map +1 -0
- package/dist/mobius-socket/test/mocha-helpers.js +23 -0
- package/dist/mobius-socket/test/mocha-helpers.js.map +1 -0
- package/dist/mobius-socket/test/promise-tick.js +28 -0
- package/dist/mobius-socket/test/promise-tick.js.map +1 -0
- package/dist/mobius-socket/types.js +7 -0
- package/dist/mobius-socket/types.js.map +1 -0
- package/dist/module/CallingClient/CallingClient.js +141 -10
- package/dist/module/CallingClient/calling/call.js +24 -6
- package/dist/module/CallingClient/calling/callManager.js +27 -7
- package/dist/module/CallingClient/calling/types.js +2 -0
- package/dist/module/CallingClient/constants.js +20 -0
- package/dist/module/CallingClient/registration/register.js +226 -62
- package/dist/module/CallingClient/registration/webWorker.js +42 -61
- package/dist/module/CallingClient/registration/webWorkerStr.js +47 -82
- package/dist/module/CallingClient/utils/constants.js +30 -0
- package/dist/module/CallingClient/utils/index.js +5 -0
- package/dist/module/CallingClient/utils/mobiusSocketMapper.js +72 -0
- package/dist/module/CallingClient/utils/request.js +162 -0
- package/dist/module/CallingClient/utils/types.js +1 -0
- package/dist/module/CallingClient/utils/wsFeatureFlag.js +12 -0
- package/dist/module/Events/types.js +0 -10
- package/dist/module/Metrics/index.js +46 -0
- package/dist/module/Metrics/types.js +10 -0
- package/dist/module/common/Utils.js +52 -12
- package/dist/module/common/testUtil.js +5 -1
- package/dist/module/common/types.js +2 -0
- package/dist/module/mobius-socket/config.js +15 -0
- package/dist/module/mobius-socket/errors.js +64 -0
- package/dist/module/mobius-socket/index.js +24 -0
- package/dist/module/mobius-socket/mobius-socket.js +571 -0
- package/dist/module/mobius-socket/socket/constants.js +10 -0
- package/dist/module/mobius-socket/socket/index.js +4 -0
- package/dist/module/mobius-socket/socket/socket-base.js +368 -0
- package/dist/module/mobius-socket/socket/socket.js +9 -0
- package/dist/module/mobius-socket/socket/socket.shim.js +12 -0
- package/dist/module/mobius-socket/socket/types.js +1 -0
- package/dist/module/mobius-socket/types.js +1 -0
- package/dist/types/CallingClient/CallingClient.d.ts +7 -0
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts +2 -0
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts +3 -2
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/types.d.ts +21 -9
- package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +20 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +6 -0
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +3 -1
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
- package/dist/types/CallingClient/utils/constants.d.ts +30 -0
- package/dist/types/CallingClient/utils/constants.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/index.d.ts +6 -0
- package/dist/types/CallingClient/utils/index.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts +5 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/request.d.ts +23 -0
- package/dist/types/CallingClient/utils/request.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/types.d.ts +29 -0
- package/dist/types/CallingClient/utils/types.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts +4 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts.map +1 -0
- package/dist/types/Events/types.d.ts +0 -10
- package/dist/types/Events/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +11 -1
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +24 -0
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +9 -2
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +4 -1
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +3 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/dist/types/mobius-socket/config.d.ts +17 -0
- package/dist/types/mobius-socket/config.d.ts.map +1 -0
- package/dist/types/mobius-socket/errors.d.ts +32 -0
- package/dist/types/mobius-socket/errors.d.ts.map +1 -0
- package/dist/types/mobius-socket/index.d.ts +14 -0
- package/dist/types/mobius-socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts +48 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/constants.d.ts +11 -0
- package/dist/types/mobius-socket/socket/constants.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/index.d.ts +5 -0
- package/dist/types/mobius-socket/socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts +43 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/types.d.ts +61 -0
- package/dist/types/mobius-socket/socket/types.d.ts.map +1 -0
- package/dist/types/mobius-socket/types.d.ts +21 -0
- package/dist/types/mobius-socket/types.d.ts.map +1 -0
- package/package.json +20 -5
- package/src/mobius-socket/socket/socket.shim.ts +22 -0
- package/src/mobius-socket/socket/socket.ts +14 -0
|
@@ -18,18 +18,32 @@ export function filterMobiusUris(mobiusServers, defaultMobiusUrl) {
|
|
|
18
18
|
};
|
|
19
19
|
const urisArrayPrimary = [];
|
|
20
20
|
const urisArrayBackup = [];
|
|
21
|
+
const wssArrayPrimary = [];
|
|
22
|
+
const wssArrayBackup = [];
|
|
21
23
|
if (mobiusServers?.primary?.uris) {
|
|
22
24
|
log.info('Adding Primary uris', logContext);
|
|
23
25
|
for (const uri of mobiusServers.primary.uris) {
|
|
24
26
|
urisArrayPrimary.push(`${uri}${URL_ENDPOINT}`);
|
|
25
27
|
}
|
|
26
28
|
}
|
|
29
|
+
if (mobiusServers?.primary?.wss) {
|
|
30
|
+
log.info('Adding Primary wss uris', logContext);
|
|
31
|
+
for (const wssUri of mobiusServers.primary.wss) {
|
|
32
|
+
wssArrayPrimary.push(wssUri);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
27
35
|
if (mobiusServers?.backup?.uris) {
|
|
28
36
|
log.info('Adding Backup uris', logContext);
|
|
29
37
|
for (const uri of mobiusServers.backup.uris) {
|
|
30
38
|
urisArrayBackup.push(`${uri}${URL_ENDPOINT}`);
|
|
31
39
|
}
|
|
32
40
|
}
|
|
41
|
+
if (mobiusServers?.backup?.wss) {
|
|
42
|
+
log.info('Adding Backup wss uris', logContext);
|
|
43
|
+
for (const wssUri of mobiusServers.backup.wss) {
|
|
44
|
+
wssArrayBackup.push(wssUri);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
33
47
|
log.info('Adding Default uri', logContext);
|
|
34
48
|
if (!urisArrayPrimary.length && !urisArrayBackup.length) {
|
|
35
49
|
urisArrayPrimary.push(`${defaultMobiusUrl}${URL_ENDPOINT}`);
|
|
@@ -39,6 +53,8 @@ export function filterMobiusUris(mobiusServers, defaultMobiusUrl) {
|
|
|
39
53
|
}
|
|
40
54
|
const primaryUris = [];
|
|
41
55
|
const backupUris = [];
|
|
56
|
+
const primaryWss = [];
|
|
57
|
+
const backupWss = [];
|
|
42
58
|
for (let i = 0; i < urisArrayPrimary.length; i += 1) {
|
|
43
59
|
if (primaryUris.indexOf(urisArrayPrimary[i]) === -1) {
|
|
44
60
|
primaryUris.push(urisArrayPrimary[i]);
|
|
@@ -49,7 +65,17 @@ export function filterMobiusUris(mobiusServers, defaultMobiusUrl) {
|
|
|
49
65
|
backupUris.push(urisArrayBackup[i]);
|
|
50
66
|
}
|
|
51
67
|
}
|
|
52
|
-
|
|
68
|
+
for (let i = 0; i < wssArrayPrimary.length; i += 1) {
|
|
69
|
+
if (primaryWss.indexOf(wssArrayPrimary[i]) === -1) {
|
|
70
|
+
primaryWss.push(wssArrayPrimary[i]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (let i = 0; i < wssArrayBackup.length; i += 1) {
|
|
74
|
+
if (backupWss.indexOf(wssArrayBackup[i]) === -1) {
|
|
75
|
+
backupWss.push(wssArrayBackup[i]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { primary: primaryUris, backup: backupUris, primaryWss, backupWss };
|
|
53
79
|
}
|
|
54
80
|
function updateCallErrorContext(errContext, type, message, correlationId, callError) {
|
|
55
81
|
const errObj = {};
|
|
@@ -74,12 +100,14 @@ function updateErrorContext(errContext, type, message, clientError) {
|
|
|
74
100
|
errObj.message = message;
|
|
75
101
|
clientError.setError(errObj);
|
|
76
102
|
}
|
|
77
|
-
export function emitFinalFailure(emitterCb, loggerContext) {
|
|
78
|
-
const clientError = createLineError('', {}, ERROR_TYPE.DEFAULT, RegistrationStatus.INACTIVE);
|
|
79
|
-
updateLineErrorContext(loggerContext, ERROR_TYPE.SERVICE_UNAVAILABLE,
|
|
103
|
+
export function emitFinalFailure(emitterCb, loggerContext, message) {
|
|
104
|
+
const clientError = createLineError(message || '', {}, ERROR_TYPE.DEFAULT, RegistrationStatus.INACTIVE);
|
|
105
|
+
updateLineErrorContext(loggerContext, ERROR_TYPE.SERVICE_UNAVAILABLE, message ||
|
|
106
|
+
'An unknown error occurred. Wait a moment and try again. Please contact the administrator if the problem persists.', RegistrationStatus.INACTIVE, clientError);
|
|
80
107
|
emitterCb(clientError);
|
|
81
108
|
}
|
|
82
|
-
export async function handleRegistrationErrors(err, emitterCb, loggerContext, retry429Cb, restoreRegCb) {
|
|
109
|
+
export async function handleRegistrationErrors(err, emitterCb, loggerContext, retry429Cb, restoreRegCb, serverCount = 1) {
|
|
110
|
+
let shouldDisconnect = false;
|
|
83
111
|
const lineError = createLineError('', {}, ERROR_TYPE.DEFAULT, RegistrationStatus.INACTIVE);
|
|
84
112
|
const errorCode = Number(err.statusCode);
|
|
85
113
|
let finalError = false;
|
|
@@ -90,6 +118,7 @@ export async function handleRegistrationErrors(err, emitterCb, loggerContext, re
|
|
|
90
118
|
log.warn(`400 Bad Request`, loggerContext);
|
|
91
119
|
updateLineErrorContext(loggerContext, ERROR_TYPE.BAD_REQUEST, 'Invalid input. Please verify the required parameters, sign out and then sign back in with the valid data', RegistrationStatus.INACTIVE, lineError);
|
|
92
120
|
emitterCb(lineError, finalError);
|
|
121
|
+
shouldDisconnect = serverCount > 1;
|
|
93
122
|
break;
|
|
94
123
|
}
|
|
95
124
|
case ERROR_CODE.UNAUTHORIZED: {
|
|
@@ -97,6 +126,7 @@ export async function handleRegistrationErrors(err, emitterCb, loggerContext, re
|
|
|
97
126
|
log.warn(`401 Unauthorized`, loggerContext);
|
|
98
127
|
updateLineErrorContext(loggerContext, ERROR_TYPE.TOKEN_ERROR, 'User is unauthorized due to an expired token. Sign out, then sign back in.', RegistrationStatus.INACTIVE, lineError);
|
|
99
128
|
emitterCb(lineError, finalError);
|
|
129
|
+
shouldDisconnect = serverCount > 1;
|
|
100
130
|
break;
|
|
101
131
|
}
|
|
102
132
|
case ERROR_CODE.DEVICE_NOT_FOUND: {
|
|
@@ -104,6 +134,7 @@ export async function handleRegistrationErrors(err, emitterCb, loggerContext, re
|
|
|
104
134
|
log.warn(`404 Device Not Found`, loggerContext);
|
|
105
135
|
updateLineErrorContext(loggerContext, ERROR_TYPE.NOT_FOUND, 'Webex Calling is unable to find your device. Sign out, then sign back in', RegistrationStatus.INACTIVE, lineError);
|
|
106
136
|
emitterCb(lineError, finalError);
|
|
137
|
+
shouldDisconnect = serverCount > 1;
|
|
107
138
|
break;
|
|
108
139
|
}
|
|
109
140
|
case ERROR_CODE.TOO_MANY_REQUESTS: {
|
|
@@ -112,20 +143,23 @@ export async function handleRegistrationErrors(err, emitterCb, loggerContext, re
|
|
|
112
143
|
const caller = loggerContext.method || 'handleErrors';
|
|
113
144
|
if (retry429Cb && err.headers) {
|
|
114
145
|
const retryAfter = Number(err.headers['retry-after']);
|
|
115
|
-
retry429Cb(retryAfter, caller);
|
|
146
|
+
await retry429Cb(retryAfter, caller);
|
|
116
147
|
}
|
|
148
|
+
shouldDisconnect = false;
|
|
117
149
|
break;
|
|
118
150
|
}
|
|
119
151
|
case ERROR_CODE.INTERNAL_SERVER_ERROR: {
|
|
120
152
|
log.warn(`500 Internal Server Error`, loggerContext);
|
|
121
153
|
updateLineErrorContext(loggerContext, ERROR_TYPE.SERVER_ERROR, 'An unknown error occurred while placing the request. Wait a moment and try again.', RegistrationStatus.INACTIVE, lineError);
|
|
122
154
|
emitterCb(lineError, finalError);
|
|
155
|
+
shouldDisconnect = serverCount > 1;
|
|
123
156
|
break;
|
|
124
157
|
}
|
|
125
158
|
case ERROR_CODE.SERVICE_UNAVAILABLE: {
|
|
126
159
|
log.warn(`503 Service Unavailable`, loggerContext);
|
|
127
160
|
updateLineErrorContext(loggerContext, ERROR_TYPE.SERVICE_UNAVAILABLE, 'An error occurred on the server while processing the request. Wait a moment and try again.', RegistrationStatus.INACTIVE, lineError);
|
|
128
161
|
emitterCb(lineError, finalError);
|
|
162
|
+
shouldDisconnect = serverCount > 1;
|
|
129
163
|
break;
|
|
130
164
|
}
|
|
131
165
|
case ERROR_CODE.FORBIDDEN: {
|
|
@@ -135,7 +169,8 @@ export async function handleRegistrationErrors(err, emitterCb, loggerContext, re
|
|
|
135
169
|
log.warn('Error response has no body, throwing default error', loggerContext);
|
|
136
170
|
updateLineErrorContext(loggerContext, ERROR_TYPE.FORBIDDEN_ERROR, 'An unauthorized action has been received. This action has been blocked. Please contact the administrator if this persists.', RegistrationStatus.INACTIVE, lineError);
|
|
137
171
|
emitterCb(lineError, finalError);
|
|
138
|
-
|
|
172
|
+
shouldDisconnect = serverCount > 1;
|
|
173
|
+
return { finalError, shouldDisconnect };
|
|
139
174
|
}
|
|
140
175
|
const code = Number(errorBody.errorCode);
|
|
141
176
|
log.warn(`Error code found : ${code}`, loggerContext);
|
|
@@ -147,6 +182,7 @@ export async function handleRegistrationErrors(err, emitterCb, loggerContext, re
|
|
|
147
182
|
const caller = loggerContext.method || 'handleErrors';
|
|
148
183
|
await restoreRegCb(errorBody, caller);
|
|
149
184
|
}
|
|
185
|
+
shouldDisconnect = false;
|
|
150
186
|
break;
|
|
151
187
|
}
|
|
152
188
|
case DEVICE_ERROR_CODE.DEVICE_CREATION_DISABLED: {
|
|
@@ -155,6 +191,7 @@ export async function handleRegistrationErrors(err, emitterCb, loggerContext, re
|
|
|
155
191
|
updateLineErrorContext(loggerContext, ERROR_TYPE.FORBIDDEN_ERROR, errorMessage, RegistrationStatus.INACTIVE, lineError);
|
|
156
192
|
log.warn(errorMessage, loggerContext);
|
|
157
193
|
emitterCb(lineError, true);
|
|
194
|
+
shouldDisconnect = true;
|
|
158
195
|
break;
|
|
159
196
|
}
|
|
160
197
|
case DEVICE_ERROR_CODE.DEVICE_CREATION_FAILED: {
|
|
@@ -162,6 +199,7 @@ export async function handleRegistrationErrors(err, emitterCb, loggerContext, re
|
|
|
162
199
|
updateLineErrorContext(loggerContext, ERROR_TYPE.FORBIDDEN_ERROR, errorMessage, RegistrationStatus.INACTIVE, lineError);
|
|
163
200
|
log.warn(errorMessage, loggerContext);
|
|
164
201
|
emitterCb(lineError, finalError);
|
|
202
|
+
shouldDisconnect = serverCount > 1;
|
|
165
203
|
break;
|
|
166
204
|
}
|
|
167
205
|
default: {
|
|
@@ -169,6 +207,7 @@ export async function handleRegistrationErrors(err, emitterCb, loggerContext, re
|
|
|
169
207
|
updateLineErrorContext(loggerContext, ERROR_TYPE.FORBIDDEN_ERROR, errorMessage, RegistrationStatus.INACTIVE, lineError);
|
|
170
208
|
log.warn(errorMessage, loggerContext);
|
|
171
209
|
emitterCb(lineError, finalError);
|
|
210
|
+
shouldDisconnect = serverCount > 1;
|
|
172
211
|
}
|
|
173
212
|
}
|
|
174
213
|
break;
|
|
@@ -177,9 +216,10 @@ export async function handleRegistrationErrors(err, emitterCb, loggerContext, re
|
|
|
177
216
|
updateLineErrorContext(loggerContext, ERROR_TYPE.DEFAULT, 'Unknown error', RegistrationStatus.INACTIVE, lineError);
|
|
178
217
|
log.warn(`Unknown Error`, loggerContext);
|
|
179
218
|
emitterCb(lineError, finalError);
|
|
219
|
+
shouldDisconnect = serverCount > 1;
|
|
180
220
|
}
|
|
181
221
|
}
|
|
182
|
-
return finalError;
|
|
222
|
+
return { finalError, shouldDisconnect };
|
|
183
223
|
}
|
|
184
224
|
export async function handleCallingClientErrors(err, emitterCb, loggerContext) {
|
|
185
225
|
const clientError = createClientError('', {}, ERROR_TYPE.DEFAULT, RegistrationStatus.INACTIVE);
|
|
@@ -851,7 +891,7 @@ export function inferIdFromUuid(id, decodeType) {
|
|
|
851
891
|
function isValidServiceIndicator(indicator) {
|
|
852
892
|
return Object.values(ServiceIndicator).some((v) => v === indicator);
|
|
853
893
|
}
|
|
854
|
-
function isValidServiceDomain(serviceData) {
|
|
894
|
+
export function isValidServiceDomain(serviceData) {
|
|
855
895
|
const regexp = /^[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/i;
|
|
856
896
|
const { domain } = serviceData;
|
|
857
897
|
if (!domain) {
|
|
@@ -866,9 +906,6 @@ export function validateServiceData(serviceData) {
|
|
|
866
906
|
if (!isValidServiceIndicator(serviceData.indicator)) {
|
|
867
907
|
throw new Error(`Invalid service indicator, Allowed values are: ${formattedValues}`);
|
|
868
908
|
}
|
|
869
|
-
if (!isValidServiceDomain(serviceData)) {
|
|
870
|
-
throw new Error('Invalid service domain.');
|
|
871
|
-
}
|
|
872
909
|
}
|
|
873
910
|
export function modifySdpForIPv4(sdp) {
|
|
874
911
|
try {
|
|
@@ -941,3 +978,6 @@ export async function uploadLogs(metaData = {}, throwError = false) {
|
|
|
941
978
|
return undefined;
|
|
942
979
|
}
|
|
943
980
|
}
|
|
981
|
+
export function normalizeMobiusUris(urls) {
|
|
982
|
+
return urls.map((url) => (!url.endsWith('/') ? `${url}/` : url));
|
|
983
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import platform from 'platform';
|
|
2
|
+
import { CISCO_DEVICE_URL } from '../CallingClient/constants';
|
|
2
3
|
const MediaSDKMock = jest.createMockFromModule('@webex/internal-media-core');
|
|
3
4
|
export function getTestUtilsWebex() {
|
|
4
5
|
return {
|
|
@@ -34,6 +35,9 @@ export function getTestUtilsWebex() {
|
|
|
34
35
|
entitlement: {
|
|
35
36
|
models: [{ _values: { key: 'bc-sp-standard' } }],
|
|
36
37
|
},
|
|
38
|
+
developer: {
|
|
39
|
+
get: jest.fn().mockReturnValue({ value: false }),
|
|
40
|
+
},
|
|
37
41
|
},
|
|
38
42
|
},
|
|
39
43
|
encryption: {
|
|
@@ -106,7 +110,7 @@ export const mockCallingClient = {
|
|
|
106
110
|
export const getMockRequestTemplate = () => {
|
|
107
111
|
return {
|
|
108
112
|
headers: {
|
|
109
|
-
|
|
113
|
+
[CISCO_DEVICE_URL]: 'https://wdm-intb.ciscospark.com/wdm/api/v1/devices/c5ae3b86-1bb7-40f1-a6a9-c296ee7e61d5',
|
|
110
114
|
'spark-user-agent': 'webex-calling/beta',
|
|
111
115
|
},
|
|
112
116
|
service: 'mobius',
|
|
@@ -62,6 +62,8 @@ export var WorkerMessageType;
|
|
|
62
62
|
(function (WorkerMessageType) {
|
|
63
63
|
WorkerMessageType["START_KEEPALIVE"] = "START_KEEPALIVE";
|
|
64
64
|
WorkerMessageType["CLEAR_KEEPALIVE"] = "CLEAR_KEEPALIVE";
|
|
65
|
+
WorkerMessageType["SEND_KEEPALIVE"] = "SEND_KEEPALIVE";
|
|
66
|
+
WorkerMessageType["KEEPALIVE_RESULT"] = "KEEPALIVE_RESULT";
|
|
65
67
|
WorkerMessageType["KEEPALIVE_SUCCESS"] = "KEEPALIVE_SUCCESS";
|
|
66
68
|
WorkerMessageType["KEEPALIVE_FAILURE"] = "KEEPALIVE_FAILURE";
|
|
67
69
|
})(WorkerMessageType || (WorkerMessageType = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
const mobiusSocketConfig = {
|
|
5
|
+
wssResponseTimeout: 10000,
|
|
6
|
+
backoffTimeMax: 32000,
|
|
7
|
+
backoffTimeReset: 1000,
|
|
8
|
+
initialConnectionMaxRetries: 0,
|
|
9
|
+
maxRetries: 0,
|
|
10
|
+
forceCloseDelay: 2000,
|
|
11
|
+
dedupCacheMaxSize: 1000,
|
|
12
|
+
};
|
|
13
|
+
export default {
|
|
14
|
+
mobiusSocket: mobiusSocketConfig,
|
|
15
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
import { Exception } from '@webex/common';
|
|
5
|
+
export class ConnectionError extends Exception {
|
|
6
|
+
static defaultMessage = 'Failed to connect to socket';
|
|
7
|
+
code;
|
|
8
|
+
reason;
|
|
9
|
+
constructor(event) {
|
|
10
|
+
super(event);
|
|
11
|
+
}
|
|
12
|
+
parse(event = {}) {
|
|
13
|
+
Object.defineProperties(this, {
|
|
14
|
+
code: {
|
|
15
|
+
value: event.code,
|
|
16
|
+
},
|
|
17
|
+
reason: {
|
|
18
|
+
value: event.reason,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
return event.reason;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class UnknownResponse extends ConnectionError {
|
|
25
|
+
static defaultMessage = 'UnknownResponse is produced by IE when we receive a 4XXX. You probably want to treat this like a NotFound';
|
|
26
|
+
constructor(event) {
|
|
27
|
+
super(event);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class BadRequest extends ConnectionError {
|
|
31
|
+
static defaultMessage = 'BadRequest usually implies an attempt to use service account credentials';
|
|
32
|
+
constructor(event) {
|
|
33
|
+
super(event);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class NotAuthorized extends ConnectionError {
|
|
37
|
+
static defaultMessage = 'Please refresh your access token';
|
|
38
|
+
constructor(event) {
|
|
39
|
+
super(event);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class Forbidden extends ConnectionError {
|
|
43
|
+
static defaultMessage = 'Forbidden usually implies these credentials are not entitled for Webex';
|
|
44
|
+
constructor(event) {
|
|
45
|
+
super(event);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function createWssResponseError(response, statusCode, statusMessage) {
|
|
49
|
+
const error = new Error(statusMessage || `Mobius websocket request failed with status ${statusCode || 'unknown'}`);
|
|
50
|
+
error.name = 'MobiusSocketResponseError';
|
|
51
|
+
error.statusCode = statusCode;
|
|
52
|
+
error.statusMessage = statusMessage;
|
|
53
|
+
error.response = response;
|
|
54
|
+
error.trackingId = response?.trackingId;
|
|
55
|
+
return error;
|
|
56
|
+
}
|
|
57
|
+
export function createTimeoutError(request) {
|
|
58
|
+
const errorPayload = {
|
|
59
|
+
type: 'response_event',
|
|
60
|
+
subtype: request.type,
|
|
61
|
+
trackingId: request.trackingId,
|
|
62
|
+
};
|
|
63
|
+
return createWssResponseError(errorPayload, 408, 'Mobius websocket response timed out');
|
|
64
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
import '@webex/internal-plugin-device';
|
|
5
|
+
import '@webex/internal-plugin-feature';
|
|
6
|
+
import '@webex/internal-plugin-metrics';
|
|
7
|
+
import MobiusSocket from './mobius-socket';
|
|
8
|
+
import config from './config';
|
|
9
|
+
let mobiusSocketInstance;
|
|
10
|
+
export function getMobiusSocketInstance(webex, mobiusSocketConfig) {
|
|
11
|
+
if (mobiusSocketInstance) {
|
|
12
|
+
return mobiusSocketInstance;
|
|
13
|
+
}
|
|
14
|
+
mobiusSocketInstance = new MobiusSocket(webex, {
|
|
15
|
+
...config.mobiusSocket,
|
|
16
|
+
...mobiusSocketConfig,
|
|
17
|
+
});
|
|
18
|
+
return mobiusSocketInstance;
|
|
19
|
+
}
|
|
20
|
+
export function resetMobiusSocketInstance() {
|
|
21
|
+
mobiusSocketInstance = undefined;
|
|
22
|
+
}
|
|
23
|
+
export default MobiusSocket;
|
|
24
|
+
export { MobiusSocket };
|