@webex/calling 3.8.1 → 3.9.0-webinar5k.1
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/CallSettings/WxCallBackendConnector.js +2 -2
- package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +94 -27
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/types.js.map +1 -1
- package/dist/CallingClient/CallingClient.js +160 -105
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +168 -102
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/constants.js +3 -3
- package/dist/CallingClient/constants.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 +486 -380
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +441 -309
- 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 +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/Errors/types.js +2 -0
- package/dist/Errors/types.js.map +1 -1
- package/dist/Metrics/index.js +9 -2
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +10 -4
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/common/Utils.js +41 -34
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +265 -119
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/common/types.js +8 -1
- package/dist/common/types.js.map +1 -1
- package/dist/module/CallSettings/WxCallBackendConnector.js +1 -1
- package/dist/module/CallingClient/CallingClient.js +25 -10
- package/dist/module/CallingClient/constants.js +2 -2
- package/dist/module/CallingClient/registration/register.js +101 -65
- package/dist/module/CallingClient/registration/webWorker.js +59 -0
- package/dist/module/CallingClient/registration/webWorkerStr.js +93 -0
- package/dist/module/Errors/types.js +2 -0
- package/dist/module/Metrics/index.js +8 -1
- package/dist/module/common/Utils.js +10 -2
- package/dist/module/common/types.js +7 -0
- package/dist/types/CallSettings/types.d.ts +1 -1
- package/dist/types/CallSettings/types.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +2 -2
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +2 -2
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.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/Errors/types.d.ts +2 -0
- package/dist/types/Errors/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +2 -1
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +12 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/package.json +4 -4
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;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;AAAA,IAuFVC,iBAAiB,GAAAV,OAAA,CAAAU,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
|
|
@@ -289,7 +289,7 @@ export class WxCallBackendConnector {
|
|
|
289
289
|
const vmResponse = await this.getVoicemailSetting();
|
|
290
290
|
if (vmResponse.statusCode === 200) {
|
|
291
291
|
const vm = vmResponse.data.callSetting;
|
|
292
|
-
if (vm.enabled && vm.sendAllCalls
|
|
292
|
+
if (vm.enabled && vm.sendAllCalls?.enabled) {
|
|
293
293
|
const response = {
|
|
294
294
|
...cfResponse,
|
|
295
295
|
data: {
|
|
@@ -69,12 +69,18 @@ export class CallingClient extends Eventing {
|
|
|
69
69
|
method: this.constructor.name,
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
this.
|
|
73
|
-
|
|
74
|
-
this.webex.internal.services._hostCatalog[
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
if (this.webex.internal.services._hostCatalog) {
|
|
73
|
+
this.mobiusClusters =
|
|
74
|
+
(mobiusServiceHost && this.webex.internal.services._hostCatalog[mobiusServiceHost]) ||
|
|
75
|
+
this.webex.internal.services._hostCatalog[MOBIUS_US_PROD] ||
|
|
76
|
+
this.webex.internal.services._hostCatalog[MOBIUS_EU_PROD] ||
|
|
77
|
+
this.webex.internal.services._hostCatalog[MOBIUS_US_INT] ||
|
|
78
|
+
this.webex.internal.services._hostCatalog[MOBIUS_EU_INT];
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const mobiusObject = this.webex.internal.services._services.find((item) => item.serviceName === 'mobius');
|
|
82
|
+
this.mobiusClusters = [mobiusObject.serviceUrls[0].baseUrl];
|
|
83
|
+
}
|
|
78
84
|
this.mobiusHost = '';
|
|
79
85
|
this.registerSessionsListener();
|
|
80
86
|
this.registerCallsClearedListener();
|
|
@@ -113,13 +119,19 @@ export class CallingClient extends Eventing {
|
|
|
113
119
|
}, NETWORK_FLAP_TIMEOUT);
|
|
114
120
|
}
|
|
115
121
|
async getClientRegionInfo() {
|
|
122
|
+
let abort;
|
|
116
123
|
log.info(METHOD_START_MESSAGE, {
|
|
117
124
|
file: CALLING_CLIENT_FILE,
|
|
118
125
|
method: METHODS.GET_CLIENT_REGION_INFO,
|
|
119
126
|
});
|
|
120
127
|
const regionInfo = {};
|
|
121
128
|
for (const mobius of this.mobiusClusters) {
|
|
122
|
-
|
|
129
|
+
if (mobius.host) {
|
|
130
|
+
this.mobiusHost = `https://${mobius.host}${API_V1}`;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
this.mobiusHost = mobius;
|
|
134
|
+
}
|
|
123
135
|
try {
|
|
124
136
|
const temp = await this.webex.request({
|
|
125
137
|
uri: `${this.mobiusHost}${URL_ENDPOINT}${IP_ENDPOINT}`,
|
|
@@ -152,12 +164,15 @@ export class CallingClient extends Eventing {
|
|
|
152
164
|
method: METHODS.GET_CLIENT_REGION_INFO,
|
|
153
165
|
file: CALLING_CLIENT_FILE,
|
|
154
166
|
});
|
|
155
|
-
handleCallingClientErrors(err, (clientError) => {
|
|
156
|
-
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION_ERROR, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, clientError);
|
|
167
|
+
abort = await handleCallingClientErrors(err, (clientError) => {
|
|
168
|
+
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION_ERROR, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, GET_MOBIUS_SERVERS_UTIL, 'UNKNOWN', err.headers?.trackingId ?? '', undefined, clientError);
|
|
157
169
|
this.emit(CALLING_CLIENT_EVENT_KEYS.ERROR, clientError);
|
|
158
170
|
}, { method: GET_MOBIUS_SERVERS_UTIL, file: CALLING_CLIENT_FILE });
|
|
159
171
|
regionInfo.clientRegion = '';
|
|
160
172
|
regionInfo.countryCode = '';
|
|
173
|
+
if (abort) {
|
|
174
|
+
return regionInfo;
|
|
175
|
+
}
|
|
161
176
|
}
|
|
162
177
|
}
|
|
163
178
|
return regionInfo;
|
|
@@ -214,7 +229,7 @@ export class CallingClient extends Eventing {
|
|
|
214
229
|
file: CALLING_CLIENT_FILE,
|
|
215
230
|
});
|
|
216
231
|
handleCallingClientErrors(err, (clientError) => {
|
|
217
|
-
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION_ERROR, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, clientError);
|
|
232
|
+
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION_ERROR, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, GET_MOBIUS_SERVERS_UTIL, 'UNKNOWN', err.headers?.trackingId ?? '', undefined, clientError);
|
|
218
233
|
this.emit(CALLING_CLIENT_EVENT_KEYS.ERROR, clientError);
|
|
219
234
|
}, { method: GET_MOBIUS_SERVERS_UTIL, file: CALLING_CLIENT_FILE });
|
|
220
235
|
useDefault = true;
|
|
@@ -105,10 +105,10 @@ export const BASE_REG_RETRY_TIMER_VAL_IN_SEC = 30;
|
|
|
105
105
|
export const SEC_TO_MSEC_MFACTOR = 1000;
|
|
106
106
|
export const MINUTES_TO_SEC_MFACTOR = 60;
|
|
107
107
|
export const REG_RANDOM_T_FACTOR_UPPER_LIMIT = 10000;
|
|
108
|
-
export const REG_TRY_BACKUP_TIMER_VAL_IN_SEC =
|
|
109
|
-
export const REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC = 114;
|
|
108
|
+
export const REG_TRY_BACKUP_TIMER_VAL_IN_SEC = 114;
|
|
110
109
|
export const REG_FAILBACK_429_MAX_RETRIES = 5;
|
|
111
110
|
export const RETRY_TIMER_UPPER_LIMIT = 60;
|
|
111
|
+
export const REGISTRATION_UTIL = 'triggerRegistration';
|
|
112
112
|
export const REGISTER_UTIL = 'attemptRegistrationWithServers';
|
|
113
113
|
export const GET_MOBIUS_SERVERS_UTIL = 'getMobiusServers';
|
|
114
114
|
export const KEEPALIVE_UTIL = 'startKeepaliveTimer';
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { v4 as uuid } from 'uuid';
|
|
2
2
|
import { METHOD_START_MESSAGE } from '../../common/constants';
|
|
3
3
|
import { emitFinalFailure, handleRegistrationErrors, uploadLogs } from '../../common';
|
|
4
|
-
import
|
|
4
|
+
import webWorkerStr from './webWorkerStr';
|
|
5
|
+
import { METRIC_EVENT, METRIC_TYPE, REG_ACTION, } from '../../Metrics/types';
|
|
5
6
|
import { getMetricManager } from '../../Metrics';
|
|
6
7
|
import { getCallManager } from '../calling';
|
|
7
8
|
import log from '../../Logger';
|
|
8
9
|
import SDKConnector from '../../SDKConnector';
|
|
9
|
-
import { ALLOWED_SERVICES, HTTP_METHODS, RegistrationStatus, ServiceIndicator, } from '../../common/types';
|
|
10
|
-
import { CALLING_USER_AGENT, CISCO_DEVICE_URL, DEVICES_ENDPOINT_RESOURCE, SPARK_USER_AGENT, WEBEX_WEB_CLIENT, BASE_REG_RETRY_TIMER_VAL_IN_SEC, BASE_REG_TIMER_MFACTOR, SEC_TO_MSEC_MFACTOR, REG_RANDOM_T_FACTOR_UPPER_LIMIT, REG_TRY_BACKUP_TIMER_VAL_IN_SEC, MINUTES_TO_SEC_MFACTOR, REG_429_RETRY_UTIL, REG_FAILBACK_429_MAX_RETRIES, FAILBACK_UTIL, REGISTRATION_FILE, DEFAULT_REHOMING_INTERVAL_MIN, DEFAULT_REHOMING_INTERVAL_MAX, DEFAULT_KEEPALIVE_INTERVAL,
|
|
10
|
+
import { ALLOWED_SERVICES, HTTP_METHODS, RegistrationStatus, ServiceIndicator, WorkerMessageType, } from '../../common/types';
|
|
11
|
+
import { CALLING_USER_AGENT, CISCO_DEVICE_URL, DEVICES_ENDPOINT_RESOURCE, SPARK_USER_AGENT, WEBEX_WEB_CLIENT, BASE_REG_RETRY_TIMER_VAL_IN_SEC, BASE_REG_TIMER_MFACTOR, SEC_TO_MSEC_MFACTOR, REG_RANDOM_T_FACTOR_UPPER_LIMIT, REG_TRY_BACKUP_TIMER_VAL_IN_SEC, MINUTES_TO_SEC_MFACTOR, REG_429_RETRY_UTIL, REG_FAILBACK_429_MAX_RETRIES, FAILBACK_UTIL, REGISTRATION_FILE, DEFAULT_REHOMING_INTERVAL_MIN, DEFAULT_REHOMING_INTERVAL_MAX, DEFAULT_KEEPALIVE_INTERVAL, FAILOVER_UTIL, REGISTER_UTIL, RETRY_TIMER_UPPER_LIMIT, KEEPALIVE_UTIL, REGISTRATION_UTIL, METHODS, URL_ENDPOINT, } from '../constants';
|
|
11
12
|
import { LINE_EVENTS } from '../line/types';
|
|
12
13
|
export class Registration {
|
|
13
14
|
sdkConnector;
|
|
@@ -18,7 +19,6 @@ export class Registration {
|
|
|
18
19
|
registrationStatus;
|
|
19
20
|
failbackTimer;
|
|
20
21
|
activeMobiusUrl;
|
|
21
|
-
keepaliveTimer;
|
|
22
22
|
rehomingIntervalMin;
|
|
23
23
|
rehomingIntervalMax;
|
|
24
24
|
mutex;
|
|
@@ -35,6 +35,7 @@ export class Registration {
|
|
|
35
35
|
failoverImmediately = false;
|
|
36
36
|
retryAfter;
|
|
37
37
|
scheduled429Retry = false;
|
|
38
|
+
webWorker;
|
|
38
39
|
constructor(webex, serviceData, mutex, lineEmitter, logLevel, jwe) {
|
|
39
40
|
this.jwe = jwe;
|
|
40
41
|
this.sdkConnector = SDKConnector;
|
|
@@ -73,17 +74,6 @@ export class Registration {
|
|
|
73
74
|
this.primaryMobiusUris = primaryMobiusUris;
|
|
74
75
|
this.backupMobiusUris = backupMobiusUris;
|
|
75
76
|
}
|
|
76
|
-
async postKeepAlive(url) {
|
|
77
|
-
return this.webex.request({
|
|
78
|
-
uri: `${url}/status`,
|
|
79
|
-
method: HTTP_METHODS.POST,
|
|
80
|
-
headers: {
|
|
81
|
-
[CISCO_DEVICE_URL]: this.webex.internal.device.url,
|
|
82
|
-
[SPARK_USER_AGENT]: CALLING_USER_AGENT,
|
|
83
|
-
},
|
|
84
|
-
service: ALLOWED_SERVICES.MOBIUS,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
77
|
async deleteRegistration(url, deviceId, deviceUrl) {
|
|
88
78
|
let response;
|
|
89
79
|
try {
|
|
@@ -167,9 +157,7 @@ export class Registration {
|
|
|
167
157
|
method: FAILOVER_UTIL,
|
|
168
158
|
};
|
|
169
159
|
let interval = this.getRegRetryInterval(attempt);
|
|
170
|
-
const TIMER_THRESHOLD =
|
|
171
|
-
? REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC
|
|
172
|
-
: REG_TRY_BACKUP_TIMER_VAL_IN_SEC;
|
|
160
|
+
const TIMER_THRESHOLD = REG_TRY_BACKUP_TIMER_VAL_IN_SEC;
|
|
173
161
|
if (timeElapsed + interval > TIMER_THRESHOLD) {
|
|
174
162
|
const excessVal = timeElapsed + interval - TIMER_THRESHOLD;
|
|
175
163
|
interval -= excessVal;
|
|
@@ -230,6 +218,40 @@ export class Registration {
|
|
|
230
218
|
this.failbackTimer = undefined;
|
|
231
219
|
}
|
|
232
220
|
}
|
|
221
|
+
async isPrimaryActive() {
|
|
222
|
+
let status;
|
|
223
|
+
for (const mobiusUrl of this.primaryMobiusUris) {
|
|
224
|
+
try {
|
|
225
|
+
const baseUri = mobiusUrl.replace(URL_ENDPOINT, '/');
|
|
226
|
+
const response = await this.webex.request({
|
|
227
|
+
uri: `${baseUri}ping`,
|
|
228
|
+
method: HTTP_METHODS.GET,
|
|
229
|
+
headers: {
|
|
230
|
+
[CISCO_DEVICE_URL]: this.webex.internal.device.url,
|
|
231
|
+
[SPARK_USER_AGENT]: CALLING_USER_AGENT,
|
|
232
|
+
},
|
|
233
|
+
service: ALLOWED_SERVICES.MOBIUS,
|
|
234
|
+
});
|
|
235
|
+
const { statusCode } = response;
|
|
236
|
+
if (statusCode === 200) {
|
|
237
|
+
log.info(`Ping successful for primary Mobius: ${mobiusUrl}`, {
|
|
238
|
+
file: REGISTRATION_FILE,
|
|
239
|
+
method: FAILBACK_UTIL,
|
|
240
|
+
});
|
|
241
|
+
status = 'up';
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
log.warn(`Ping failed for primary Mobius: ${mobiusUrl} with error: ${error}`, {
|
|
247
|
+
file: REGISTRATION_FILE,
|
|
248
|
+
method: FAILBACK_UTIL,
|
|
249
|
+
});
|
|
250
|
+
status = 'down';
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return status === 'up';
|
|
254
|
+
}
|
|
233
255
|
isFailbackRequired() {
|
|
234
256
|
return this.isDeviceRegistered() && this.primaryMobiusUris.indexOf(this.activeMobiusUrl) === -1;
|
|
235
257
|
}
|
|
@@ -260,7 +282,8 @@ export class Registration {
|
|
|
260
282
|
async executeFailback() {
|
|
261
283
|
await this.mutex.runExclusive(async () => {
|
|
262
284
|
if (this.isFailbackRequired()) {
|
|
263
|
-
|
|
285
|
+
const primaryServerStatus = await this.isPrimaryActive();
|
|
286
|
+
if (Object.keys(this.callManager.getActiveCalls()).length === 0 && primaryServerStatus) {
|
|
264
287
|
log.info(`Attempting failback to primary.`, {
|
|
265
288
|
file: REGISTRATION_FILE,
|
|
266
289
|
method: this.executeFailback.name,
|
|
@@ -284,7 +307,7 @@ export class Registration {
|
|
|
284
307
|
}
|
|
285
308
|
}
|
|
286
309
|
else {
|
|
287
|
-
log.info('Active calls present, deferring failback to next cycle.', {
|
|
310
|
+
log.info('Active calls present or primary Mobius is down, deferring failback to next cycle.', {
|
|
288
311
|
file: REGISTRATION_FILE,
|
|
289
312
|
method: this.executeFailback.name,
|
|
290
313
|
});
|
|
@@ -376,7 +399,7 @@ export class Registration {
|
|
|
376
399
|
}
|
|
377
400
|
async triggerRegistration() {
|
|
378
401
|
if (this.primaryMobiusUris.length > 0) {
|
|
379
|
-
const abort = await this.attemptRegistrationWithServers(
|
|
402
|
+
const abort = await this.attemptRegistrationWithServers(REGISTRATION_UTIL, this.primaryMobiusUris);
|
|
380
403
|
if (!this.isDeviceRegistered() && !abort) {
|
|
381
404
|
await this.startFailoverTimer();
|
|
382
405
|
}
|
|
@@ -396,6 +419,9 @@ export class Registration {
|
|
|
396
419
|
return abort;
|
|
397
420
|
}
|
|
398
421
|
for (const url of servers) {
|
|
422
|
+
const serverType = (this.primaryMobiusUris.includes(url) && 'PRIMARY') ||
|
|
423
|
+
(this.backupMobiusUris?.includes(url) && 'BACKUP') ||
|
|
424
|
+
'UNKNOWN';
|
|
399
425
|
try {
|
|
400
426
|
abort = false;
|
|
401
427
|
this.registrationStatus = RegistrationStatus.INACTIVE;
|
|
@@ -415,8 +441,8 @@ export class Registration {
|
|
|
415
441
|
this.setActiveMobiusUrl(url);
|
|
416
442
|
this.setIntervalValues(this.deviceInfo);
|
|
417
443
|
this.metricManager.setDeviceInfo(this.deviceInfo);
|
|
418
|
-
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, undefined);
|
|
419
|
-
this.startKeepaliveTimer(this.deviceInfo.device?.uri, this.deviceInfo.keepaliveInterval);
|
|
444
|
+
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, caller, serverType, resp.headers?.trackingid ?? '', undefined, undefined);
|
|
445
|
+
this.startKeepaliveTimer(this.deviceInfo.device?.uri, this.deviceInfo.keepaliveInterval, serverType);
|
|
420
446
|
this.initiateFailback();
|
|
421
447
|
break;
|
|
422
448
|
}
|
|
@@ -429,7 +455,7 @@ export class Registration {
|
|
|
429
455
|
else {
|
|
430
456
|
this.lineEmitter(LINE_EVENTS.UNREGISTERED);
|
|
431
457
|
}
|
|
432
|
-
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION_ERROR, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, clientError);
|
|
458
|
+
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION_ERROR, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, caller, serverType, body.headers?.trackingid ?? '', undefined, clientError);
|
|
433
459
|
}, { method: caller, file: REGISTRATION_FILE }, (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller), this.restoreRegistrationCallBack());
|
|
434
460
|
if (this.registrationStatus === RegistrationStatus.ACTIVE) {
|
|
435
461
|
log.info(`[${caller}] : Device is already restored, active mobius url: ${this.activeMobiusUrl}`, {
|
|
@@ -446,57 +472,67 @@ export class Registration {
|
|
|
446
472
|
}
|
|
447
473
|
return abort;
|
|
448
474
|
}
|
|
449
|
-
startKeepaliveTimer(url, interval) {
|
|
450
|
-
let keepAliveRetryCount = 0;
|
|
475
|
+
async startKeepaliveTimer(url, interval, serverType) {
|
|
451
476
|
this.clearKeepaliveTimer();
|
|
452
477
|
const RETRY_COUNT_THRESHOLD = this.isCCFlow ? 4 : 5;
|
|
453
|
-
this.
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
478
|
+
await this.mutex.runExclusive(async () => {
|
|
479
|
+
if (this.isDeviceRegistered()) {
|
|
480
|
+
const accessToken = await this.webex.credentials.getUserToken();
|
|
481
|
+
if (!this.webWorker) {
|
|
482
|
+
const blob = new Blob([webWorkerStr], { type: 'application/javascript' });
|
|
483
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
484
|
+
this.webWorker = new Worker(blobUrl);
|
|
485
|
+
URL.revokeObjectURL(blobUrl);
|
|
486
|
+
this.webWorker.postMessage({
|
|
487
|
+
type: WorkerMessageType.START_KEEPALIVE,
|
|
488
|
+
accessToken: String(accessToken),
|
|
489
|
+
deviceUrl: String(this.webex.internal.device.url),
|
|
490
|
+
interval,
|
|
491
|
+
retryCountThreshold: RETRY_COUNT_THRESHOLD,
|
|
492
|
+
url,
|
|
493
|
+
});
|
|
494
|
+
this.webWorker.onmessage = async (event) => {
|
|
495
|
+
const logContext = {
|
|
496
|
+
file: REGISTRATION_FILE,
|
|
497
|
+
method: this.startKeepaliveTimer.name,
|
|
498
|
+
};
|
|
499
|
+
if (event.data.type === WorkerMessageType.KEEPALIVE_SUCCESS) {
|
|
500
|
+
log.info(`Sent Keepalive, status: ${event.data.statusCode}`, logContext);
|
|
464
501
|
this.lineEmitter(LINE_EVENTS.RECONNECTED);
|
|
465
502
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
503
|
+
if (event.data.type === WorkerMessageType.KEEPALIVE_FAILURE) {
|
|
504
|
+
const error = event.data.err;
|
|
505
|
+
log.warn(`Keep-alive missed ${event.data.keepAliveRetryCount} times. Status -> ${error.statusCode} `, logContext);
|
|
506
|
+
const abort = await handleRegistrationErrors(error, (clientError, finalError) => {
|
|
507
|
+
if (finalError) {
|
|
508
|
+
this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
|
|
509
|
+
}
|
|
510
|
+
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION, REG_ACTION.KEEPALIVE_FAILURE, METRIC_TYPE.BEHAVIORAL, KEEPALIVE_UTIL, serverType, error.headers?.trackingid ?? '', event.data.keepAliveRetryCount, clientError);
|
|
511
|
+
}, { method: KEEPALIVE_UTIL, file: REGISTRATION_FILE });
|
|
512
|
+
if (abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD) {
|
|
513
|
+
this.failoverImmediately = this.isCCFlow;
|
|
514
|
+
this.setStatus(RegistrationStatus.INACTIVE);
|
|
515
|
+
this.clearKeepaliveTimer();
|
|
516
|
+
this.clearFailbackTimer();
|
|
517
|
+
this.lineEmitter(LINE_EVENTS.UNREGISTERED);
|
|
518
|
+
if (!abort) {
|
|
519
|
+
await this.reconnectOnFailure(KEEPALIVE_UTIL);
|
|
520
|
+
}
|
|
475
521
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
if (abort || keepAliveRetryCount >= RETRY_COUNT_THRESHOLD) {
|
|
479
|
-
this.failoverImmediately = this.isCCFlow;
|
|
480
|
-
this.setStatus(RegistrationStatus.INACTIVE);
|
|
481
|
-
this.clearKeepaliveTimer();
|
|
482
|
-
this.clearFailbackTimer();
|
|
483
|
-
this.lineEmitter(LINE_EVENTS.UNREGISTERED);
|
|
484
|
-
if (!abort) {
|
|
485
|
-
await this.reconnectOnFailure(this.startKeepaliveTimer.name);
|
|
522
|
+
else {
|
|
523
|
+
this.lineEmitter(LINE_EVENTS.RECONNECTING);
|
|
486
524
|
}
|
|
487
525
|
}
|
|
488
|
-
|
|
489
|
-
this.lineEmitter(LINE_EVENTS.RECONNECTING);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
526
|
+
};
|
|
492
527
|
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
528
|
+
}
|
|
529
|
+
});
|
|
495
530
|
}
|
|
496
531
|
clearKeepaliveTimer() {
|
|
497
|
-
if (this.
|
|
498
|
-
|
|
499
|
-
this.
|
|
532
|
+
if (this.webWorker) {
|
|
533
|
+
this.webWorker.postMessage({ type: WorkerMessageType.CLEAR_KEEPALIVE });
|
|
534
|
+
this.webWorker.terminate();
|
|
535
|
+
this.webWorker = undefined;
|
|
500
536
|
}
|
|
501
537
|
}
|
|
502
538
|
isReconnectPending() {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { v4 as uuid } from 'uuid';
|
|
2
|
+
import { HTTP_METHODS, WorkerMessageType } from '../../common/types';
|
|
3
|
+
let keepaliveTimer;
|
|
4
|
+
export const messageHandler = (event) => {
|
|
5
|
+
const { type } = event.data;
|
|
6
|
+
const postKeepAlive = async (accessToken, deviceUrl, url) => {
|
|
7
|
+
const response = await fetch(`${url}/status`, {
|
|
8
|
+
method: HTTP_METHODS.POST,
|
|
9
|
+
headers: {
|
|
10
|
+
'cisco-device-url': deviceUrl,
|
|
11
|
+
'spark-user-agent': 'webex-calling/beta',
|
|
12
|
+
Authorization: `${accessToken}`,
|
|
13
|
+
trackingId: `web_worker_${uuid()}`,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
throw new Error(`Keepalive failed with status: ${response.status}`);
|
|
18
|
+
}
|
|
19
|
+
return response;
|
|
20
|
+
};
|
|
21
|
+
if (type === WorkerMessageType.START_KEEPALIVE) {
|
|
22
|
+
let keepAliveRetryCount = 0;
|
|
23
|
+
const { accessToken, deviceUrl, interval, retryCountThreshold, url } = event.data;
|
|
24
|
+
if (keepaliveTimer) {
|
|
25
|
+
clearInterval(keepaliveTimer);
|
|
26
|
+
keepaliveTimer = undefined;
|
|
27
|
+
}
|
|
28
|
+
keepaliveTimer = setInterval(async () => {
|
|
29
|
+
if (keepAliveRetryCount < retryCountThreshold) {
|
|
30
|
+
try {
|
|
31
|
+
const res = await postKeepAlive(accessToken, deviceUrl, url);
|
|
32
|
+
const statusCode = res.status;
|
|
33
|
+
if (keepAliveRetryCount > 0) {
|
|
34
|
+
postMessage({
|
|
35
|
+
type: WorkerMessageType.KEEPALIVE_SUCCESS,
|
|
36
|
+
statusCode,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
keepAliveRetryCount = 0;
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
keepAliveRetryCount += 1;
|
|
43
|
+
postMessage({
|
|
44
|
+
type: WorkerMessageType.KEEPALIVE_FAILURE,
|
|
45
|
+
err,
|
|
46
|
+
keepAliveRetryCount,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, interval * 1000);
|
|
51
|
+
}
|
|
52
|
+
if (type === WorkerMessageType.CLEAR_KEEPALIVE) {
|
|
53
|
+
if (keepaliveTimer) {
|
|
54
|
+
clearInterval(keepaliveTimer);
|
|
55
|
+
keepaliveTimer = undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
self.addEventListener('message', messageHandler);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const webWorkerStr = `/* eslint-env worker */
|
|
2
|
+
|
|
3
|
+
const uuid = () => {
|
|
4
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
5
|
+
const r = (Math.random() * 16) | 0;
|
|
6
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
7
|
+
return v.toString(16);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Enum values from the original imports
|
|
12
|
+
const HTTP_METHODS = {
|
|
13
|
+
GET: 'GET',
|
|
14
|
+
POST: 'POST',
|
|
15
|
+
PUT: 'PUT',
|
|
16
|
+
DELETE: 'DELETE',
|
|
17
|
+
PATCH: 'PATCH',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const WorkerMessageType = {
|
|
21
|
+
START_KEEPALIVE: 'START_KEEPALIVE',
|
|
22
|
+
CLEAR_KEEPALIVE: 'CLEAR_KEEPALIVE',
|
|
23
|
+
KEEPALIVE_SUCCESS: 'KEEPALIVE_SUCCESS',
|
|
24
|
+
KEEPALIVE_FAILURE: 'KEEPALIVE_FAILURE',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let keepaliveTimer;
|
|
28
|
+
|
|
29
|
+
const messageHandler = (event) => {
|
|
30
|
+
const {type} = event.data;
|
|
31
|
+
|
|
32
|
+
const postKeepAlive = async (accessToken, deviceUrl, url) => {
|
|
33
|
+
const response = await fetch(\`\${url}/status\`, {
|
|
34
|
+
method: HTTP_METHODS.POST,
|
|
35
|
+
headers: {
|
|
36
|
+
'cisco-device-url': deviceUrl,
|
|
37
|
+
'spark-user-agent': 'webex-calling/beta',
|
|
38
|
+
Authorization: \`\${accessToken}\`,
|
|
39
|
+
trackingId: \`web_worker_\${uuid()}\`,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
throw new Error(\`Keepalive failed with status: \${response.status}\`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return response;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (type === WorkerMessageType.START_KEEPALIVE) {
|
|
51
|
+
let keepAliveRetryCount = 0;
|
|
52
|
+
const {accessToken, deviceUrl, interval, retryCountThreshold, url} = event.data;
|
|
53
|
+
|
|
54
|
+
if (keepaliveTimer) {
|
|
55
|
+
clearInterval(keepaliveTimer);
|
|
56
|
+
keepaliveTimer = undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
keepaliveTimer = setInterval(async () => {
|
|
60
|
+
if (keepAliveRetryCount < retryCountThreshold) {
|
|
61
|
+
try {
|
|
62
|
+
const res = await postKeepAlive(accessToken, deviceUrl, url);
|
|
63
|
+
const statusCode = res.status;
|
|
64
|
+
if (keepAliveRetryCount > 0) {
|
|
65
|
+
self.postMessage({
|
|
66
|
+
type: WorkerMessageType.KEEPALIVE_SUCCESS,
|
|
67
|
+
statusCode,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
keepAliveRetryCount = 0;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
keepAliveRetryCount += 1;
|
|
73
|
+
self.postMessage({
|
|
74
|
+
type: WorkerMessageType.KEEPALIVE_FAILURE,
|
|
75
|
+
err,
|
|
76
|
+
keepAliveRetryCount,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, interval * 1000);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (type === WorkerMessageType.CLEAR_KEEPALIVE) {
|
|
84
|
+
if (keepaliveTimer) {
|
|
85
|
+
clearInterval(keepaliveTimer);
|
|
86
|
+
keepaliveTimer = undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
self.addEventListener('message', messageHandler);
|
|
92
|
+
`;
|
|
93
|
+
export default webWorkerStr;
|
|
@@ -7,12 +7,14 @@ export var ERROR_TYPE;
|
|
|
7
7
|
(function (ERROR_TYPE) {
|
|
8
8
|
ERROR_TYPE["CALL_ERROR"] = "call_error";
|
|
9
9
|
ERROR_TYPE["DEFAULT"] = "default_error";
|
|
10
|
+
ERROR_TYPE["BAD_REQUEST"] = "bad_request";
|
|
10
11
|
ERROR_TYPE["FORBIDDEN_ERROR"] = "forbidden";
|
|
11
12
|
ERROR_TYPE["NOT_FOUND"] = "not_found";
|
|
12
13
|
ERROR_TYPE["REGISTRATION_ERROR"] = "registration_error";
|
|
13
14
|
ERROR_TYPE["SERVICE_UNAVAILABLE"] = "service_unavailable";
|
|
14
15
|
ERROR_TYPE["TIMEOUT"] = "timeout";
|
|
15
16
|
ERROR_TYPE["TOKEN_ERROR"] = "token_error";
|
|
17
|
+
ERROR_TYPE["TOO_MANY_REQUESTS"] = "too_many_requests";
|
|
16
18
|
ERROR_TYPE["SERVER_ERROR"] = "server_error";
|
|
17
19
|
})(ERROR_TYPE || (ERROR_TYPE = {}));
|
|
18
20
|
export var ERROR_CODE;
|
|
@@ -62,7 +62,7 @@ class MetricManager {
|
|
|
62
62
|
setDeviceInfo(deviceInfo) {
|
|
63
63
|
this.deviceInfo = deviceInfo;
|
|
64
64
|
}
|
|
65
|
-
submitRegistrationMetric(name, metricAction, type, clientError) {
|
|
65
|
+
submitRegistrationMetric(name, metricAction, type, caller, serverType, trackingId, keepaliveCount, clientError) {
|
|
66
66
|
let data;
|
|
67
67
|
switch (name) {
|
|
68
68
|
case METRIC_EVENT.REGISTRATION: {
|
|
@@ -76,6 +76,9 @@ class MetricManager {
|
|
|
76
76
|
device_url: this.deviceInfo?.device?.clientDeviceUri,
|
|
77
77
|
mobius_url: this.deviceInfo?.device?.uri,
|
|
78
78
|
calling_sdk_version: process.env.CALLING_SDK_VERSION || VERSION,
|
|
79
|
+
reg_source: caller,
|
|
80
|
+
server_type: serverType,
|
|
81
|
+
trackingId,
|
|
79
82
|
},
|
|
80
83
|
type,
|
|
81
84
|
};
|
|
@@ -93,6 +96,10 @@ class MetricManager {
|
|
|
93
96
|
device_url: this.deviceInfo?.device?.clientDeviceUri,
|
|
94
97
|
mobius_url: this.deviceInfo?.device?.uri,
|
|
95
98
|
calling_sdk_version: process.env.CALLING_SDK_VERSION || VERSION,
|
|
99
|
+
reg_source: caller,
|
|
100
|
+
server_type: serverType,
|
|
101
|
+
trackingId,
|
|
102
|
+
keepalive_count: keepaliveCount,
|
|
96
103
|
error: clientError.getError().message,
|
|
97
104
|
error_type: clientError.getError().type,
|
|
98
105
|
},
|