@webex/calling 3.12.0-next.92 → 3.12.0-next.94
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/registration/register.js +128 -58
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +362 -76
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/common/Utils.js +7 -18
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +3 -6
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/module/CallingClient/registration/register.js +32 -7
- package/dist/module/common/Utils.js +7 -12
- package/dist/types/CallingClient/registration/register.d.ts +1 -0
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +0 -1
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HARD_STOP_REASON","exports"],"sources":["types.ts"],"sourcesContent":["import {Devices, IDeviceInfo, RegistrationStatus} from '../../common/types';\nimport {LineError} from '../../Errors/catalog/LineError';\nimport {MobiusAsyncEvent} from '../calling/types';\n\nexport type Header = {\n [key: string]: string;\n};\n\n/**\n * Reason a registration is torn down without any re-registration attempt.\n * The values double as the label used in hard-stop log messages.\n */\nexport enum HARD_STOP_REASON {\n REGISTRATION_DOWN = 'registration-down',\n SESSION_SUPERSEDED = 'session-superseded',\n}\n\n/**\n * Describes a hard stop of the registration. A superseded session must carry the\n * {@link LineError} that is handed to the SDK consumer as the reason on\n * `LINE_EVENTS.UNREGISTERED`; a registration-down stop carries no reason.\n */\nexport type HardStop =\n | {reason: HARD_STOP_REASON.REGISTRATION_DOWN; error?: undefined}\n | {reason: HARD_STOP_REASON.SESSION_SUPERSEDED; error: LineError};\n\nexport type restoreRegistrationCallBack = (\n restoreData: IDeviceInfo,\n caller: string\n) => Promise<boolean>;\n\nexport type retry429CallBack = (retryAfter: number, caller: string) => Promise<void>;\n\nexport type sessionSupersededCallBack = (clientError: LineError) => Promise<void>;\n\n/**\n * Specialized handlers a caller of `handleRegistrationErrors` opts into. A flow only\n * passes the handlers for the status codes it can act on, which is what keeps handling\n * such as the `409` session-superseded hard stop scoped to the keepalive flow.\n */\nexport type RegistrationErrorHandlers = {\n /** Invoked on `429` so the caller can reschedule its own flow after `Retry-After`. */\n retry429Cb?: retry429CallBack;\n /** Invoked on `403` device-limit so the caller can restore the existing registration. */\n restoreRegCb?: restoreRegistrationCallBack;\n /** Invoked on `409` so the caller can hard stop a superseded calling session. */\n sessionSupersededCb?: sessionSupersededCallBack;\n};\n\n/**\n * Outcome of `handleRegistrationErrors`.\n */\nexport type RegistrationErrorResult = {\n /** The error is terminal — the caller must not retry. */\n finalError: boolean;\n /** The Mobius WebSocket of the failed server must be torn down before moving on. */\n shouldDisconnect: boolean;\n
|
|
1
|
+
{"version":3,"names":["HARD_STOP_REASON","exports"],"sources":["types.ts"],"sourcesContent":["import {Devices, IDeviceInfo, RegistrationStatus} from '../../common/types';\nimport {LineError} from '../../Errors/catalog/LineError';\nimport {MobiusAsyncEvent} from '../calling/types';\n\nexport type Header = {\n [key: string]: string;\n};\n\n/**\n * Reason a registration is torn down without any re-registration attempt.\n * The values double as the label used in hard-stop log messages.\n */\nexport enum HARD_STOP_REASON {\n REGISTRATION_DOWN = 'registration-down',\n SESSION_SUPERSEDED = 'session-superseded',\n}\n\n/**\n * Describes a hard stop of the registration. A superseded session must carry the\n * {@link LineError} that is handed to the SDK consumer as the reason on\n * `LINE_EVENTS.UNREGISTERED`; a registration-down stop carries no reason.\n */\nexport type HardStop =\n | {reason: HARD_STOP_REASON.REGISTRATION_DOWN; error?: undefined}\n | {reason: HARD_STOP_REASON.SESSION_SUPERSEDED; error: LineError};\n\nexport type restoreRegistrationCallBack = (\n restoreData: IDeviceInfo,\n caller: string\n) => Promise<boolean>;\n\nexport type retry429CallBack = (retryAfter: number, caller: string) => Promise<void>;\n\nexport type sessionSupersededCallBack = (clientError: LineError) => Promise<void>;\n\n/**\n * Specialized handlers a caller of `handleRegistrationErrors` opts into. A flow only\n * passes the handlers for the status codes it can act on, which is what keeps handling\n * such as the `409` session-superseded hard stop scoped to the keepalive flow.\n */\nexport type RegistrationErrorHandlers = {\n /** Invoked on `429` so the caller can reschedule its own flow after `Retry-After`. */\n retry429Cb?: retry429CallBack;\n /** Invoked on `403` device-limit so the caller can restore the existing registration. */\n restoreRegCb?: restoreRegistrationCallBack;\n /** Invoked on `409` so the caller can hard stop a superseded calling session. */\n sessionSupersededCb?: sessionSupersededCallBack;\n};\n\n/**\n * Outcome of `handleRegistrationErrors`.\n */\nexport type RegistrationErrorResult = {\n /** The error is terminal — the caller must not retry. */\n finalError: boolean;\n /** The Mobius WebSocket of the failed server must be torn down before moving on. */\n shouldDisconnect: boolean;\n};\n\nexport type FailoverCacheState = {\n attempt: number;\n timeElapsed: number;\n retryScheduledTime: number;\n serverType: 'primary' | 'backup';\n};\n\n/**\n * Represents an interface for managing registration-related operations.\n */\nexport interface IRegistration {\n /**\n * Sets the primary and backup Mobius server URLs.\n *\n * @param primaryMobiusUris - An array of primary Mobius server URLs.\n * @param backupMobiusUris - An array of backup Mobius server URLs.\n */\n setMobiusServers(primaryMobiusUris: string[], backupMobiusUris: string[]): void;\n\n /**\n * Triggers the registration process with the given list of servers\n * Registration is attempted with primary and backup until it succeeds or the list is exhausted\n */\n triggerRegistration(): Promise<void>;\n\n /**\n * Checks if the device is currently registered.\n *\n */\n isDeviceRegistered(): boolean;\n\n /**\n * Sets the status of the registration.\n *\n * @param value - The registration status to set.\n */\n setStatus(value: RegistrationStatus): void;\n\n /**\n * Retrieves the current registration status.\n *\n */\n getStatus(): RegistrationStatus;\n\n /**\n * Retrieves information about the device as {@link IDeviceInfo}.\n *\n */\n getDeviceInfo(): IDeviceInfo;\n\n /**\n * Clears the keep-alive timer used for registration.\n */\n clearKeepaliveTimer(): void;\n\n /**\n * Deregisters the device.\n */\n deregister(closeMobiusWss: boolean): void;\n\n /**\n * Sets the active Mobius server URL to use for registration.\n *\n * @param url - The Mobius server URL to set as active.\n */\n setActiveMobiusUrl(url: string): void;\n\n /**\n * Retrieves the active Mobius server URL.\n *\n */\n getActiveMobiusUrl(): string;\n\n /**\n * Attempts to reconnect after a connection failure.\n *\n * @param caller - The caller's identifier for reconnection.\n */\n reconnectOnFailure(caller: string): Promise<void>;\n\n /**\n * Checks if a reconnection attempt is pending.\n *\n */\n isReconnectPending(): boolean;\n\n /**\n * Restores the connection and attempts refreshing existing registration with server.\n * Allows retry if not restored in the first attempt.\n *\n * @param retry - Set to `true` to trigger a retry after restoration.\n */\n handleConnectionRestoration(retry: boolean): Promise<boolean>;\n\n /**\n * Populate deviceInfo from a devices response (e.g., getDevices API).\n */\n setDeviceInfo(body: Devices): void;\n\n /**\n * Handles a Mobius REGISTRATION_DOWN async event. Ends the first active\n * call (if any) and runs registration-side cleanup.\n *\n * @param event - The Mobius async event payload (optional).\n */\n handleRegistrationDownEvent(event?: MobiusAsyncEvent): Promise<void>;\n}\n"],"mappings":";;;;;;;AAQA;AACA;AACA;AACA;AAHA,IAIYA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AAK5B;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AAeA;AACA;AACA","ignoreList":[]}
|
package/dist/common/Utils.js
CHANGED
|
@@ -291,11 +291,9 @@ function _handleRegistrationErrors() {
|
|
|
291
291
|
restoreRegCb,
|
|
292
292
|
sessionSupersededCb,
|
|
293
293
|
shouldDisconnect,
|
|
294
|
-
handledByCallback,
|
|
295
294
|
lineError,
|
|
296
295
|
errorCode,
|
|
297
296
|
finalError,
|
|
298
|
-
handleUnknownError,
|
|
299
297
|
caller,
|
|
300
298
|
retryAfter,
|
|
301
299
|
errorBody,
|
|
@@ -315,18 +313,9 @@ function _handleRegistrationErrors() {
|
|
|
315
313
|
serverCount = _args.length > 4 && _args[4] !== undefined ? _args[4] : 1;
|
|
316
314
|
retry429Cb = handlers.retry429Cb, restoreRegCb = handlers.restoreRegCb, sessionSupersededCb = handlers.sessionSupersededCb;
|
|
317
315
|
shouldDisconnect = false;
|
|
318
|
-
handledByCallback = false;
|
|
319
316
|
lineError = (0, _LineError.createLineError)('', {}, _types2.ERROR_TYPE.DEFAULT, _types3.RegistrationStatus.INACTIVE);
|
|
320
317
|
errorCode = Number(err.statusCode);
|
|
321
318
|
finalError = false;
|
|
322
|
-
/* Treatment for a status code this handler has no specific rule for: notify the
|
|
323
|
-
* consumer and leave the retry decision to the caller. */
|
|
324
|
-
handleUnknownError = function handleUnknownError() {
|
|
325
|
-
updateLineErrorContext(loggerContext, _types2.ERROR_TYPE.DEFAULT, 'Unknown error', _types3.RegistrationStatus.INACTIVE, lineError);
|
|
326
|
-
_Logger.default.warn("Unknown Error", loggerContext);
|
|
327
|
-
emitterCb(lineError, finalError);
|
|
328
|
-
shouldDisconnect = serverCount > 1;
|
|
329
|
-
};
|
|
330
319
|
_Logger.default.warn("Status code: -> ".concat(errorCode), loggerContext);
|
|
331
320
|
_t = errorCode;
|
|
332
321
|
_context.next = _t === _types2.ERROR_CODE.BAD_REQUEST ? 1 : _t === _types2.ERROR_CODE.UNAUTHORIZED ? 2 : _t === _types2.ERROR_CODE.DEVICE_NOT_FOUND ? 3 : _t === _types2.ERROR_CODE.CONFLICT ? 4 : _t === _types2.ERROR_CODE.TOO_MANY_REQUESTS ? 7 : _t === _types2.ERROR_CODE.INTERNAL_SERVER_ERROR ? 9 : _t === _types2.ERROR_CODE.SERVICE_UNAVAILABLE ? 10 : _t === _types2.ERROR_CODE.FORBIDDEN ? 11 : 19;
|
|
@@ -358,11 +347,10 @@ function _handleRegistrationErrors() {
|
|
|
358
347
|
_context.next = 5;
|
|
359
348
|
break;
|
|
360
349
|
}
|
|
361
|
-
|
|
350
|
+
_Logger.default.warn("409 Conflict: ignored, caller does not handle a superseded session", loggerContext);
|
|
362
351
|
return _context.abrupt("continue", 20);
|
|
363
352
|
case 5:
|
|
364
353
|
finalError = true;
|
|
365
|
-
handledByCallback = true;
|
|
366
354
|
_Logger.default.warn("409 Conflict: session superseded by another device for this user", loggerContext);
|
|
367
355
|
updateLineErrorContext(loggerContext, _types2.ERROR_TYPE.SESSION_SUPERSEDED, _constants.SESSION_SUPERSEDED_MESSAGE, _types3.RegistrationStatus.INACTIVE, lineError);
|
|
368
356
|
_context.next = 6;
|
|
@@ -409,8 +397,7 @@ function _handleRegistrationErrors() {
|
|
|
409
397
|
shouldDisconnect = serverCount > 1;
|
|
410
398
|
return _context.abrupt("return", {
|
|
411
399
|
finalError: finalError,
|
|
412
|
-
shouldDisconnect: shouldDisconnect
|
|
413
|
-
handledByCallback: handledByCallback
|
|
400
|
+
shouldDisconnect: shouldDisconnect
|
|
414
401
|
});
|
|
415
402
|
case 12:
|
|
416
403
|
code = Number(errorBody.errorCode);
|
|
@@ -455,12 +442,14 @@ function _handleRegistrationErrors() {
|
|
|
455
442
|
case 18:
|
|
456
443
|
return _context.abrupt("continue", 20);
|
|
457
444
|
case 19:
|
|
458
|
-
|
|
445
|
+
updateLineErrorContext(loggerContext, _types2.ERROR_TYPE.DEFAULT, 'Unknown error', _types3.RegistrationStatus.INACTIVE, lineError);
|
|
446
|
+
_Logger.default.warn("Unknown Error", loggerContext);
|
|
447
|
+
emitterCb(lineError, finalError);
|
|
448
|
+
shouldDisconnect = serverCount > 1;
|
|
459
449
|
case 20:
|
|
460
450
|
return _context.abrupt("return", {
|
|
461
451
|
finalError: finalError,
|
|
462
|
-
shouldDisconnect: shouldDisconnect
|
|
463
|
-
handledByCallback: handledByCallback
|
|
452
|
+
shouldDisconnect: shouldDisconnect
|
|
464
453
|
});
|
|
465
454
|
case 21:
|
|
466
455
|
case "end":
|